You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: astropy/units/quantity.py
+58-56Lines changed: 58 additions & 56 deletions
Original file line number
Diff line number
Diff line change
@@ -190,91 +190,93 @@ def cgs(self):
190
190
191
191
# Arithmetic operations
192
192
def__add__(self, other):
193
-
""" Addition between `Quantity` objects. All operations return a new `Quantity` object
194
-
with the units of the **left** object.
193
+
""" Addition between `Quantity` objects and other objects. If
194
+
they are both `Quantity` objects, results in the units of the
195
+
**left** object if they are compatible, otherwise this fails.
195
196
"""
196
-
ifnotisinstance(other, Quantity):
197
-
raiseTypeError("Object of type '{0}' cannot be added with a Quantity object. Addition is only supported between Quantity objects.".format(other.__class__))
raiseTypeError("Object of type '{0}' cannot be added with a "
201
+
"Quantity object. Addition is only supported between Quantity "
202
+
"objects with compatible units.".format(other.__class__))
203
+
199
204
200
205
def__sub__(self, other):
201
-
""" Subtraction between `Quantity` objects. All operations return a new `Quantity` object
202
-
with the units of the **left** object.
206
+
""" Subtraction between `Quantity` objects and other objects.
207
+
If they are both `Quantity` objects, results in the units of the
208
+
**left** object if they are compatible, otherwise this fails.
203
209
"""
204
-
ifnotisinstance(other, Quantity):
205
-
raiseTypeError("Object of type '{0}' cannot be subtracted with a Quantity object. Subtraction is only supported between Quantity objects.".format(other.__class__))
0 commit comments