8000 Test directly whether Quantity.__index__() works rather than its effect. · mhvk/astropy@e5fdb14 · GitHub
[go: up one dir, main page]

Skip to content

Commit e5fdb14

Browse files
committed
Test directly whether Quantity.__index__() works rather than its effect.
In numpy-dev, the __index__ can no longer be used to multiply lists; for discussion about why, really, this was always broken & wrong, see numpy/numpy#5864.
1 parent 226e272 commit e5fdb14

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

astropy/units/tests/test_quantity.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def test_numeric_converters(self):
467467
assert exc.value.args[0] == converter_err_msg
468468

469469
with pytest.raises(TypeError) as exc:
470-
q1 * ['a', 'b', 'c']
470+
q1.__index__()
471471
assert exc.value.args[0] == index_err_msg
472472

473473
# dimensionless but scaled is OK, however
@@ -480,7 +480,7 @@ def test_numeric_converters(self):
480480
assert long(q2) == long(q2.to(u.dimensionless_unscaled).value)
481481

482482
with pytest.raises(TypeError) as exc:
483-
q2 * ['a', 'b', 'c']
483+
q2.__index__()
484484
assert exc.value.args[0] == index_err_msg
485485

486486
# dimensionless unscaled is OK, though for index needs to be int
@@ -492,7 +492,7 @@ def test_numeric_converters(self):
492492
assert long(q3) == 1
493493

494494
with pytest.raises(TypeError) as exc:
495-
q1 * ['a', 'b', 'c']
495+
q1.__index__()
496496
assert exc.value.args[0] == index_err_msg
497497

498498
# integer dimensionless unscaled is good for all
@@ -503,7 +503,7 @@ def test_numeric_converters(self):
503503
if six.PY2:
504504
assert long(q4) == 2
505505

506-
assert q4 * ['a', 'b', 'c'] == ['a', 'b', 'c', 'a', 'b', 'c']
506+
assert q4.__index__() == 2
507507

508508
# but arrays are not OK
509509
q5 = u.Quantity([1, 2], u.m)
@@ -521,7 +521,7 @@ def test_numeric_converters(self):
521521
assert exc.value.args[0] == converter_err_msg
522522

523523
with pytest.raises(TypeError) as exc:
524-
q5 * ['a', 'b', 'c']
524+
q5.__index__()
525525
assert exc.value.args[0] == index_err_msg
526526

527527
def test_array_converters(self):

0 commit comments

Comments
 (0)
0