Implementation of numpy.divide that works with dtype kwarg. Temporary compatibility fix for a bug in numpy's version. See https://github.com/numpy/numpy/issues/3484 for the relevant issue.
(x1, x2, out=None, dtype=None)
| 54 | except TypeError: |
| 55 | # Divide with dtype doesn't work on Python 3 |
| 56 | def divide(x1, x2, out=None, dtype=None): # type: ignore[misc] |
| 57 | """Implementation of numpy.divide that works with dtype kwarg. |
| 58 | |
| 59 | Temporary compatibility fix for a bug in numpy's version. See |
| 60 | https://github.com/numpy/numpy/issues/3484 for the relevant issue.""" |
| 61 | x = np.divide(x1, x2, out) |
| 62 | if dtype is not None: |
| 63 | x = x.astype(dtype) |
| 64 | return x |
| 65 | |
| 66 | ma_divide = np.ma.core._DomainedBinaryOperation( |
| 67 | divide, np.ma.core._DomainSafeDivide(), 0, 1 # type: ignore[attr-defined] |