Skip to content

Commit e894e08

Browse files
committed
Fix some warnings with modern pytest
1 parent a3d4bbc commit e894e08

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

numexpr/tests/test_numexpr.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def test_str_contains_long_needle(self):
296296
b = b'a' * 40
297297
res = evaluate('contains(a, b)')
298298
assert_equal(res, True)
299-
299+
300300
def test_where_scalar_bool(self):
301301
a = True
302302
b = array([1, 2])
@@ -318,7 +318,7 @@ def test_refcount(self):
318318

319319
def test_locals_clears_globals(self):
320320
# Check for issue #313, whereby clearing f_locals also clear f_globals
321-
# if in the top-frame. This cannot be done inside `unittest` as it is always
321+
# if in the top-frame. This cannot be done inside `unittest` as it is always
322322
# executing code in a child frame.
323323
script = r';'.join([
324324
r"import numexpr as ne",
@@ -334,7 +334,7 @@ def test_locals_clears_globals(self):
334334
])
335335
# Raises CalledProcessError on a non-normal exit
336336
check = subprocess.check_call([sys.executable, '-c', script])
337-
# Ideally this test should also be done against ipython but it's not
337+
# Ideally this test should also be done against ipython but it's not
338338
# a requirement.
339339

340340

@@ -521,7 +521,7 @@ def test_sanitize(self):
521521
self.fail()
522522

523523
# Forbid colon for lambda funcs
524-
try:
524+
try:
525525
evaluate('lambda x: x')
526526
except ValueError:
527527
pass
@@ -585,7 +585,7 @@ def test_sanitize(self):
585585
x = np.array(['a', 'b'], dtype=bytes)
586586
evaluate("x == 'b:'")
587587

588-
588+
589589
def test_no_sanitize(self):
590590
try: # Errors on compile() after eval()
591591
evaluate('import os;', sanitize=False)
@@ -605,7 +605,7 @@ def test_no_sanitize(self):
605605
def test_disassemble(self):
606606
assert_equal(disassemble(NumExpr(
607607
"where(m, a, -1)", [('m', bool), ('a', float)])),
608-
[[b'where_fbff', b'r0', b'r1[m]', b'r2[a]', b'c3[-1.0]'],
608+
[[b'where_fbff', b'r0', b'r1[m]', b'r2[a]', b'c3[-1.0]'],
609609
[b'noop', None, None, None]])
610610

611611
def test_constant_deduplication(self):
@@ -624,18 +624,18 @@ def test_f32_constant(self):
624624
assert_equal(ConstantNode(numpy.float32(1)).astKind, "float")
625625
assert_equal(ConstantNode(numpy.float32("nan")).astKind, "float")
626626
assert_equal(ConstantNode(numpy.float32(3)).value.dtype, numpy.dtype("float32"))
627-
assert_array_equal(NumExpr(ConstantNode(numpy.float32(1))).run(),
627+
assert_array_equal(NumExpr(ConstantNode(numpy.float32(1))).run(),
628628
numpy.array(1, dtype="float32"))
629629

630630
def test_unaligned_singleton(self):
631-
# Test for issue #397 whether singletons outputs assigned to consts must be
631+
# Test for issue #397 whether singletons outputs assigned to consts must be
632632
# aligned or not.
633633
a = np.empty(5, dtype=np.uint8)[1:].view(np.int32)
634634
evaluate('3', out=a)
635635
assert_equal(a, 3)
636636

637637
def test_negative_mod(self):
638-
# Test for issue #413, modulus of negative integers. C modulus is
638+
# Test for issue #413, modulus of negative integers. C modulus is
639639
# actually remainder op, and hence different from Python modulus.
640640
a = np.array([-500, -135, 0, 0, 135, 500], dtype=np.int32)
641641
n = np.array([-360, -360, -360, 360, 360, 360], dtype=np.int32)
@@ -650,11 +650,11 @@ def test_negative_mod(self):
650650
def test_negative_power_scalar(self):
651651
# Test for issue #428, where the power is negative and the base is an
652652
# integer. This was running afoul in the precomputation in `expressions.py:pow_op()`
653-
base = np.array([-2, -1, 0, 1, 2, 3], dtype=np.int32)
653+
base = np.array([-2, -1, 1, 2, 3], dtype=np.int32)
654654
out_i = evaluate('base ** -1.0')
655655
assert_equal(out_i, np.power(base, -1.0))
656656

657-
base = np.array([-2, -1, 0, 1, 2, 3], dtype=np.int64)
657+
base = np.array([-2, -1, 1, 2, 3], dtype=np.int64)
658658
out_l = evaluate('base ** -1.0')
659659
assert_equal(out_l, np.power(base, -1.0))
660660

@@ -878,11 +878,10 @@ def method():
878878
expr == '(a+1) ** -1'):
879879
continue
880880

881-
m = make_test_method(a, a2, b, c, d, e, x,
882-
expr, test_scalar, dtype,
883-
optimization, exact,
884-
section_name)
885-
yield m
881+
make_test_method(a, a2, b, c, d, e, x,
882+
expr, test_scalar, dtype,
883+
optimization, exact,
884+
section_name)
886885

887886

888887
class test_int64(TestCase):
@@ -1120,7 +1119,7 @@ def _environment(key, value):
11201119
# Test cases for the threading configuration
11211120
class test_threading_config(TestCase):
11221121
def test_max_threads_unset(self):
1123-
# Has to be done in a subprocess as `importlib.reload` doesn't let us
1122+
# Has to be done in a subprocess as `importlib.reload` doesn't let us
11241123
# re-initialize the threadpool
11251124
script = '\n'.join([
11261125
"import os",
@@ -1132,7 +1131,7 @@ def test_max_threads_unset(self):
11321131
subprocess.check_call([sys.executable, '-c', script])
11331132

11341133
def test_max_threads_set(self):
1135-
# Has to be done in a subprocess as `importlib.reload` doesn't let us
1134+
# Has to be done in a subprocess as `importlib.reload` doesn't let us
11361135
# re-initialize the threadpool
11371136
script = '\n'.join([
11381137
"import os",
@@ -1247,7 +1246,7 @@ def print_versions():
12471246
(sysname, nodename, release, os_version, machine, processor) = platform.uname()
12481247
print('Platform: %s-%s-%s' % (sys.platform, machine, os_version))
12491248
try:
1250-
# cpuinfo doesn't work on OSX well it seems, so protect these outputs
1249+
# cpuinfo doesn't work on OSX well it seems, so protect these outputs
12511250
# with a try block
12521251
cpu_info = cpu.info[0]
12531252
print('CPU vendor: %s' % cpu_info.get('VendorIdentifier', ''))

0 commit comments

Comments
 (0)