@@ -175,7 +175,7 @@ def test_abs(func_name, func, strat, data):
175
175
)
176
176
x = x [mask ]
177
177
out = func (x )
178
- ph .assert_shape ("abs" , out .shape , x .shape )
178
+ ph .assert_shape (func_name , out .shape , x .shape )
179
179
assert ah .all (
180
180
ah .logical_not (ah .negative_mathematical_sign (out ))
181
181
), f"out elements not all positively signed [{ func_name } ()]\n { out = } "
@@ -376,11 +376,12 @@ def test_bitwise_and(
376
376
s_left = int (_left [idx ])
377
377
s_right = int (_right [idx ])
378
378
s_res = int (res [idx ])
379
- vals_and = s_left & s_right
380
- vals_and = ah .int_to_dtype (
381
- vals_and , dh .dtype_nbits [res .dtype ], dh .dtype_signed [res .dtype ]
379
+ s_and = ah .int_to_dtype (
380
+ s_left & s_right ,
381
+ dh .dtype_nbits [res .dtype ],
382
+ dh .dtype_signed [res .dtype ],
382
383
)
383
- assert vals_and == s_res
384
+ assert s_and == s_res
384
385
385
386
386
387
@pytest .mark .parametrize (
@@ -410,9 +411,7 @@ def test_bitwise_left_shift(
410
411
if not right_is_scalar :
411
412
# TODO: generate indices without broadcasting arrays (see test_equal comment)
412
413
shape = broadcast_shapes (left .shape , right .shape )
413
- ph .assert_shape (
414
- "bitwise_left_shift" , res .shape , shape , repr_name = f"{ res_name } .shape"
415
- )
414
+ ph .assert_shape (func_name , res .shape , shape , repr_name = f"{ res_name } .shape" )
416
415
_left = xp .broadcast_to (left , shape )
417
416
_right = xp .broadcast_to (right , shape )
418
417
@@ -421,12 +420,13 @@ def test_bitwise_left_shift(
421
420
s_left = int (_left [idx ])
422
421
s_right = int (_right [idx ])
423
422
s_res = int (res [idx ])
424
- # We avoid shifting very large ints
425
- vals_shift = s_left << s_right if s_right < dh .dtype_nbits [res .dtype ] else 0
426
- vals_shift = ah .int_to_dtype (
427
- vals_shift , dh .dtype_nbits [res .dtype ], dh .dtype_signed [res .dtype ]
423
+ s_shift = ah .int_to_dtype (
424
+ # We avoid shifting very large ints
425
+ s_left << s_right if s_right < dh .dtype_nbits [res .dtype ] else 0 ,
426
+ dh .dtype_nbits [res .dtype ],
427
+ dh .dtype_signed [res .dtype ],
428
428
)
429
- assert vals_shift == s_res
429
+ assert s_shift == s_res
430
430
431
431
432
432
@pytest .mark .parametrize (
@@ -438,7 +438,7 @@ def test_bitwise_invert(func_name, func, strat, data):
438
438
439
439
out = func (x )
440
440
441
- ph .assert_shape ("bitwise_invert" , out .shape , x .shape )
441
+ ph .assert_shape (func_name , out .shape , x .shape )
442
442
# Compare against the Python ~ operator.
443
443
if out .dtype == xp .bool :
444
444
for idx in ah .ndindex (out .shape ):
@@ -449,11 +449,10 @@ def test_bitwise_invert(func_name, func, strat, data):
449
449
for idx in ah .ndindex (out .shape ):
450
450
s_x = int (x [idx ])
451
451
s_out = int (out [idx ])
452
- s_x_invert = ~ s_x
453
- s_x_invert = ah .int_to_dtype (
454
- s_x_invert , dh .dtype_nbits [out .dtype ], dh .dtype_signed [out .dtype ]
452
+ s_invert = ah .int_to_dtype (
453
+ ~ s_x , dh .dtype_nbits [out .dtype ], dh .dtype_signed [out .dtype ]
455
454
)
456
- assert s_x_invert == s_out
455
+ assert s_invert == s_out
457
456
458
457
459
458
@pytest .mark .parametrize (
@@ -479,7 +478,7 @@ def test_bitwise_or(
479
478
if not right_is_scalar :
480
479
# TODO: generate indices without broadcasting arrays (see test_equal comment)
481
480
shape = broadcast_shapes (left .shape , right .shape )
482
- ph .assert_shape ("bitwise_or" , res .shape , shape , repr_name = f"{ res_name } .shape" )
481
+ ph .assert_shape (func_name , res .shape , shape , repr_name = f"{ res_name } .shape" )
483
482
_left = xp .broadcast_to (left , shape )
484
483
_right = xp .broadcast_to (right , shape )
485
484
@@ -495,11 +494,12 @@ def test_bitwise_or(
495
494
s_left = int (_left [idx ])
496
495
s_right = int (_right [idx ])
497
496
s_res = int (res [idx ])
498
- vals_or = s_left | s_right
499
- vals_or = ah .int_to_dtype (
500
- vals_or , dh .dtype_nbits [res .dtype ], dh .dtype_signed [res .dtype ]
497
+ s_or = ah .int_to_dtype (
498
+ s_left | s_right ,
499
+ dh .dtype_nbits [res .dtype ],
500
+ dh .dtype_signed [res .dtype ],
501
501
)
502
- assert vals_or == s_res
502
+ assert s_or == s_res
503
503
504
504
505
505
@pytest .mark .parametrize (
@@ -540,11 +540,10 @@ def test_bitwise_right_shift(
540
540
s_left = int (_left [idx ])
541
541
s_right = int (_right [idx ])
542
542
s_res = int (res [idx ])
543
- vals_shift = s_left >> s_right
544
- vals_shift = ah .int_to_dtype (
545
- vals_shift , dh .dtype_nbits [res .dtype ], dh .dtype_signed [res .dtype ]
543
+ s_shift = ah .int_to_dtype (
544
+ s_left >> s_right , dh .dtype_nbits [res .dtype ], dh .dtype_signed [res .dtype ]
546
545
)
547
- assert vals_shift == s_res
546
+ assert s_shift == s_res
548
547
549
548
550
549
@pytest .mark .parametrize (
@@ -570,7 +569,7 @@ def test_bitwise_xor(
570
569
if not right_is_scalar :
571
570
# TODO: generate indices without broadcasting arrays (see test_equal comment)
572
571
shape = broadcast_shapes (left .shape , right .shape )
573
- ph .assert_shape ("bitwise_xor" , res .shape , shape , repr_name = f"{ res_name } .shape" )
572
+ ph .assert_shape (func_name , res .shape , shape , repr_name = f"{ res_name } .shape" )
574
573
_left = xp .broadcast_to (left , shape )
575
574
_right = xp .broadcast_to (right , shape )
576
575
@@ -586,11 +585,12 @@ def test_bitwise_xor(
586
585
s_left = int (_left [idx ])
587
586
s_right = int (_right [idx ])
588
587
s_res = int (res [idx ])
589
- vals_xor = s_left ^ s_right
590
- vals_xor = ah .int_to_dtype (
591
- vals_xor , dh .dtype_nbits [res .dtype ], dh .dtype_signed [res .dtype ]
588
+ s_xor = ah .int_to_dtype (
589
+ s_left ^ s_right ,
590
+ dh .dtype_nbits [res .dtype ],
591
+ dh .dtype_signed [res .dtype ],
592
592
)
593
- assert vals_xor == s_res
593
+ assert s_xor == s_res
594
594
595
595
596
596
@given (xps .arrays (dtype = xps .numeric_dtypes (), shape = hh .shapes ()))
@@ -1205,7 +1205,7 @@ def test_not_equal(
1205
1205
# TODO: generate indices without broadcasting arrays (see test_equal comment)
1206
1206
1207
1207
shape = broadcast_shapes (left .shape , right .shape )
1208
- ph .assert_shape ("not_equal" , out .shape , shape )
1208
+ ph .assert_shape (func_name , out .shape , shape )
1209
1209
_left = xp .broadcast_to (left , shape )
1210
1210
_right = xp .broadcast_to (right , shape )
1211
1211
0 commit comments