Skip to content

Commit

Permalink
Workaround for getting numpy.linalg.pinv argument default with numpy …
Browse files Browse the repository at this point in the history
…1.17
  • Loading branch information
paulromano committed Jul 31, 2019
1 parent 0e0bfd3 commit 8f301bf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion uncertainties/unumpy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,13 @@ def pinv_with_derivatives(arr, input_type, derivatives, rcond):
yield term1+term2+term3

# Default rcond argument for the generalization of numpy.linalg.pinv:
pinv_default = numpy.linalg.pinv.__defaults__[0] # Python 1, 2.6+:
try:
pinv_default = numpy.linalg.pinv.__defaults__[0] # Python 1, 2.6+:
except TypeError:
# In numpy 1.17+, pinv is wrapped using a decorator which unfortunately
# results in the metadata (argument defaults) being lost. However, we can
# still get at the original function using the __wrapped__ attribute.
pinv_default = numpy.linalg.pinv.__wrapped__.__defaults__[0]

pinv_with_uncert = func_with_deriv_to_uncert_func(pinv_with_derivatives)

Expand Down

0 comments on commit 8f301bf

Please sign in to comment.