Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ENH,WIP: Adding "casting" keyword to close and equal functions in numeric (fix #17136) #18950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
Loading
from
Open
Prev Previous commit
Next Next commit
linting
  • Loading branch information
lschwetlick committed May 9, 2021
commit 80588fe5abbcc0a2c0b154708abf8cc981d2748b
15 changes: 10 additions & 5 deletions 15 numpy/core/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -2172,7 +2172,8 @@ def identity(n, dtype=None, *, like=None):
)(identity)


def _allclose_dispatcher(a, b, rtol=None, atol=None, equal_nan=None, casting=None):
def _allclose_dispatcher(a, b, rtol=None, atol=None, equal_nan=None,
casting=None):
return (a, b)


Expand Down Expand Up @@ -2250,7 +2251,8 @@ def allclose(a, b, rtol=1.e-5, atol=1.e-8, equal_nan=False, casting='unsafe'):
return bool(res)


def _isclose_dispatcher(a, b, rtol=None, atol=None, equal_nan=None, casting=None):
def _isclose_dispatcher(a, b, rtol=None, atol=None, equal_nan=None,
casting=None):
return (a, b)


Expand Down Expand Up @@ -2342,7 +2344,8 @@ def within_tol(x, y, atol, rtol):
y = asanyarray(b)

if not np.can_cast(x.dtype, y.dtype, casting=casting):
lschwetlick marked this conversation as resolved.
Show resolved Hide resolved
raise TypeError("Cannot compare types '%s' and '%s' with casting rule %s" %(str(x.dtype), str(y.dtype), casting))
raise TypeError("Cannot compare types '%s' and '%s' with casting rule"
" %s" %(str(x.dtype), str(y.dtype), casting))


# Make sure y is an inexact type to avoid bad behavior on abs(MIN_INT).
Expand Down Expand Up @@ -2448,7 +2451,8 @@ def array_equal(a1, a2, equal_nan=False, casting='unsafe'):
return False

if not np.can_cast(a1.dtype, a2.dtype, casting=casting):
raise TypeError("Cannot compare types '%s' and '%s' with casting rule %s" %(str(a1.dtype), str(a2.dtype), casting))
raise TypeError("Cannot compare types '%s' and '%s' with casting rule"
" %s" %(str(a1.dtype), str(a2.dtype), casting))

if not equal_nan:
return bool(asarray(a1 == a2).all())
Expand Down Expand Up @@ -2511,7 +2515,8 @@ def array_equiv(a1, a2, casting='unsafe'):
return False

if not np.can_cast(a1.dtype, a2.dtype, casting=casting):
raise TypeError("Cannot compare types '%s' and '%s' with casting rule %s" %(str(a1.dtype), str(a2.dtype), casting))
raise TypeError("Cannot compare types '%s' and '%s' with casting rule "
"%s" %(str(a1.dtype), str(a2.dtype), casting))

return bool(asarray(a1 == a2).all())

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.