Skip to content

Commit 590d9f0

Browse files
committed
add suuport for numpy-1.4, with numpy-1.3 backward compatibility
1 parent 51943fe commit 590d9f0

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

.eric4project/quantities.e4q

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE UserProject SYSTEM "UserProject-4.0.dtd">
33
<!-- eric4 user project file for project quantities -->
4-
<!-- Saved: 2009-10-12, 16:52:56 -->
5-
<!-- Copyright (C) 2009 , -->
64
<UserProject version="4.0">
75
</UserProject>

.eric4project/quantities.e4t

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE Tasks SYSTEM "Tasks-4.2.dtd">
33
<!-- eric4 tasks file for project quantities -->
4-
<!-- Saved: 2009-10-12, 16:52:56 -->
54
<Tasks version="4.2">
65
<Task priority="1" completed="False" bugfix="False">
76
<Summary>TODO: move to constants</Summary>

quantities/quantity.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def astype(self, dtype=None):
204204
def __array_finalize__(self, obj):
205205
self._dimensionality = getattr(obj, 'dimensionality', Dimensionality())
206206

207-
def __array_wrap__(self, obj, context=None):
207+
def __array_prepare__(self, obj, context=None):
208208
if self.__array_priority__ >= Quantity.__array_priority__:
209209
result = obj.view(type(self))
210210
else:
@@ -225,6 +225,13 @@ def __array_wrap__(self, obj, context=None):
225225
print 'https://bugs.launchpad.net/python-quantities'
226226
return result
227227

228+
def __array_wrap__(self, obj, context=None):
229+
if not isinstance(obj, Quantity):
230+
print obj, type(obj)
231+
# backwards compatibility with numpy-1.3
232+
obj = self.__array_prepare__(obj, context)
233+
return obj
234+
228235
@with_doc(np.ndarray.__add__)
229236
@scale_other_units
230237
def __add__(self, other):

0 commit comments

Comments
 (0)