Changeset 2574
- Timestamp:
- 06/21/12 15:00:20 (13 years ago)
- Location:
- trunk/python
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapmath.py
r2538 r2574 1022 1022 Otherwise, the array operation is done in-sitsu. 1023 1023 """ 1024 if insitu is None: insitu = rcParams['insitu'] 1024 1025 nrow = scan.nrow() 1025 1026 s = None -
trunk/python/scantable.py
r2541 r2574 3470 3470 @asaplog_post_dec 3471 3471 def __add__(self, other): 3472 varlist = vars() 3472 """ 3473 implicit on all axes and on Tsys 3474 """ 3475 varlist = vars() 3476 s = self.__op( other, "ADD" ) 3477 s._add_history("operator +", varlist) 3478 return s 3479 3480 @asaplog_post_dec 3481 def __sub__(self, other): 3482 """ 3483 implicit on all axes and on Tsys 3484 """ 3485 varlist = vars() 3486 s = self.__op( other, "SUB" ) 3487 s._add_history("operator -", varlist) 3488 return s 3489 3490 @asaplog_post_dec 3491 def __mul__(self, other): 3492 """ 3493 implicit on all axes and on Tsys 3494 """ 3495 varlist = vars() 3496 s = self.__op( other, "MUL" ) ; 3497 s._add_history("operator *", varlist) 3498 return s 3499 3500 3501 @asaplog_post_dec 3502 def __div__(self, other): 3503 """ 3504 implicit on all axes and on Tsys 3505 """ 3506 varlist = vars() 3507 s = self.__op( other, "DIV" ) 3508 s._add_history("operator /", varlist) 3509 return s 3510 3511 @asaplog_post_dec 3512 def __op( self, other, mode ): 3473 3513 s = None 3474 3514 if isinstance(other, scantable): 3475 s = scantable(self._math._binaryop(self, other, "ADD"))3515 s = scantable(self._math._binaryop(self, other, mode)) 3476 3516 elif isinstance(other, float): 3477 s = scantable(self._math._unaryop(self, other, "ADD", False)) 3517 if other == 0.0: 3518 raise ZeroDivisionError("Dividing by zero is not recommended") 3519 s = scantable(self._math._unaryop(self, other, mode, False)) 3478 3520 elif isinstance(other, list) or isinstance(other, numpy.ndarray): 3479 3521 if isinstance(other[0], list) \ 3480 3522 or isinstance(other[0], numpy.ndarray): 3481 3523 from asapmath import _array2dOp 3482 s = _array2dOp( self .copy(), other, "ADD", False )3524 s = _array2dOp( self, other, mode, False ) 3483 3525 else: 3484 s = scantable( self._math._arrayop( self .copy(), other,3485 "ADD", False ) )3526 s = scantable( self._math._arrayop( self, other, 3527 mode, False ) ) 3486 3528 else: 3487 3529 raise TypeError("Other input is not a scantable or float value") 3488 s._add_history("operator +", varlist)3489 return s3490 3491 @asaplog_post_dec3492 def __sub__(self, other):3493 """3494 implicit on all axes and on Tsys3495 """3496 varlist = vars()3497 s = None3498 if isinstance(other, scantable):3499 s = scantable(self._math._binaryop(self, other, "SUB"))3500 elif isinstance(other, float):3501 s = scantable(self._math._unaryop(self, other, "SUB", False))3502 elif isinstance(other, list) or isinstance(other, numpy.ndarray):3503 if isinstance(other[0], list) \3504 or isinstance(other[0], numpy.ndarray):3505 from asapmath import _array2dOp3506 s = _array2dOp( self.copy(), other, "SUB", False )3507 else:3508 s = scantable( self._math._arrayop( self.copy(), other,3509 "SUB", False ) )3510 else:3511 raise TypeError("Other input is not a scantable or float value")3512 s._add_history("operator -", varlist)3513 return s3514 3515 @asaplog_post_dec3516 def __mul__(self, other):3517 """3518 implicit on all axes and on Tsys3519 """3520 varlist = vars()3521 s = None3522 if isinstance(other, scantable):3523 s = scantable(self._math._binaryop(self, other, "MUL"))3524 elif isinstance(other, float):3525 s = scantable(self._math._unaryop(self, other, "MUL", False))3526 elif isinstance(other, list) or isinstance(other, numpy.ndarray):3527 if isinstance(other[0], list) \3528 or isinstance(other[0], numpy.ndarray):3529 from asapmath import _array2dOp3530 s = _array2dOp( self.copy(), other, "MUL", False )3531 else:3532 s = scantable( self._math._arrayop( self.copy(), other,3533 "MUL", False ) )3534 else:3535 raise TypeError("Other input is not a scantable or float value")3536 s._add_history("operator *", varlist)3537 return s3538 3539 3540 @asaplog_post_dec3541 def __div__(self, other):3542 """3543 implicit on all axes and on Tsys3544 """3545 varlist = vars()3546 s = None3547 if isinstance(other, scantable):3548 s = scantable(self._math._binaryop(self, other, "DIV"))3549 elif isinstance(other, float):3550 if other == 0.0:3551 raise ZeroDivisionError("Dividing by zero is not recommended")3552 s = scantable(self._math._unaryop(self, other, "DIV", False))3553 elif isinstance(other, list) or isinstance(other, numpy.ndarray):3554 if isinstance(other[0], list) \3555 or isinstance(other[0], numpy.ndarray):3556 from asapmath import _array2dOp3557 s = _array2dOp( self.copy(), other, "DIV", False )3558 else:3559 s = scantable( self._math._arrayop( self.copy(), other,3560 "DIV", False ) )3561 else:3562 raise TypeError("Other input is not a scantable or float value")3563 s._add_history("operator /", varlist)3564 3530 return s 3565 3531
Note:
See TracChangeset
for help on using the changeset viewer.