From 2cccee1de17c2afe2e07881d10d9b9b42f56edbb Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Thu, 17 Nov 2016 10:28:19 +0000 Subject: [PATCH] Fix TypeError: 'NoneType' object is not iterable --- pint/quantity.py | 6 +++++- pint/testsuite/test_numpy.py | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pint/quantity.py b/pint/quantity.py index e0c551f63..448d34091 100644 --- a/pint/quantity.py +++ b/pint/quantity.py @@ -1223,7 +1223,7 @@ def tolist(self): __array_priority__ = 17 def __array_prepare__(self, obj, context=None): - # If this uf is handled by Pint, write it down in the handling dictionary. + # If we have no context, assume this is unhandled if context is None: return obj @@ -1246,6 +1246,10 @@ def __array_prepare__(self, obj, context=None): return obj def __array_wrap__(self, obj, context=None): + # If we have no context, assume this is unhandled + if context is None: + return self.magnitude.__array_wrap__(obj, context) + uf, objs, huh = context # if this ufunc is not handled by Pint, pass it to the magnitude. diff --git a/pint/testsuite/test_numpy.py b/pint/testsuite/test_numpy.py index 3c365fa27..e3030fa6d 100644 --- a/pint/testsuite/test_numpy.py +++ b/pint/testsuite/test_numpy.py @@ -463,7 +463,6 @@ def test_maximum(self): # TODO # self.assertEqual(x.units, ureg.m * ureg.s) - @unittest.expectedFailure def test_linalg_solve(self): ureg = self.ureg A = np.eye(2) * ureg.s