8000 BUG: Regression #18075 | Fixing Ufunc TD generation order by ganesh-k13 · Pull Request #18751 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Regression #18075 | Fixing Ufunc TD generation order #18751

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

Merged
merged 2 commits into from
Apr 12, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
TST: Test for ufunc orders. Reg (#18075)
  • Loading branch information
ganesh-k13 committed Apr 11, 2021
commit 468ff05d6a3bf1daa19a3066330619bc483b30f6
33 changes: 33 additions & 0 deletions numpy/core/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -2527,3 +2527,36 @@ def cassé(x):

f = np.frompyfunc(cassé, 1, 1)
assert str(f) == "<ufunc 'cassé (vectorized)'>"

@pytest.mark.parametrize("operation", [
'add', 'subtract', 'multiply', 'floor_divide',
'conjugate', 'fmod', 'square', 'reciprocal',
'power', 'absolute', 'negative', 'positive',
'greater', 'greater_equal', 'less',
'less_equal', 'equal', 'not_equal', 'logical_and',
'logical_not', 'logical_or', 'bitwise_and', 'bitwise_or',
'bitwise_xor', 'invert', 'left_shift', 'right_shift',
'gcd', 'lcm'
]
)
@pytest.mark.parametrize("order", [
('b->', 'B->'),
('h->', 'H->'),
('i->', 'I->'),
('l->', 'L->'),
('q->', 'Q->'),
]
)
def test_ufunc_order(self, operation, order):
# gh-18075
# Ensure signed types before unsigned
def get_idx(string, str_lst):
for i, s in enumerate(str_lst):
if string in s:
return i
raise ValueError(f"{string} not in list")
types = getattr(np, operation).types
assert get_idx(order[0], types) < get_idx(order[1], types), (
f"Unexpected types order of ufunc in {operation}"
f"for {order}. Possible fix: Use signed before unsigned"
"in generate_umath.py")
0