Skip to content

Commit 33f69c0

Browse files
committed
TST: finish removing tests that won't ever work
1 parent de5b876 commit 33f69c0

File tree

5 files changed

+52
-207
lines changed

5 files changed

+52
-207
lines changed

torch_np/tests/numpy_tests/core/test_dtype.py

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@
44
import types
55
from typing import Any
66

7-
import numpy as np
8-
from numpy.testing import (
9-
assert_, assert_equal, assert_array_equal, assert_raises)
10-
from numpy.compat import pickle
11-
127
import torch_np as np
138
from torch_np.testing import (
14-
assert_, assert_equal, assert_array_equal, assert_raises)
15-
#from numpy.compat import pickle
9+
assert_, assert_equal, assert_array_equal)
10+
from pytest import raises as assert_raises
11+
1612

1713
import pickle
1814
from itertools import permutations
@@ -248,28 +244,13 @@ class TestPromotion:
248244
"""Test cases related to more complex DType promotions. Further promotion
249245
tests are defined in `test_numeric.py`
250246
"""
251-
### @np._no_nep50_warning()
252247
@pytest.mark.parametrize(["other", "expected", "expected_weak"],
253248
[(2**16-1, np.complex64, None),
254249
(2**32-1, np.complex128, np.complex64),
255250
(np.float16(2), np.complex64, None),
256251
(np.float32(2), np.complex64, None),
257-
(np.longdouble(2), np.complex64, np.clongdouble),
258-
# Base of the double value to sidestep any rounding issues:
259-
(np.longdouble(np.nextafter(1.7e308, 0.)),
260-
np.complex128, np.clongdouble),
261-
# Additionally use "nextafter" so the cast can't round down:
262-
(np.longdouble(np.nextafter(1.7e308, np.inf)),
263-
np.clongdouble, None),
264252
# repeat for complex scalars:
265253
(np.complex64(2), np.complex64, None),
266-
(np.clongdouble(2), np.complex64, np.clongdouble),
267-
# Base of the double value to sidestep any rounding issues:
268-
(np.clongdouble(np.nextafter(1.7e308, 0.) * 1j),
269-
np.complex128, np.clongdouble),
270-
# Additionally use "nextafter" so the cast can't round down:
271-
(np.clongdouble(np.nextafter(1.7e308, np.inf)),
272-
np.clongdouble, None),
273254
])
274255
def test_complex_other_value_based(self,
275256
weak_promotion, other, expected, expected_weak):
@@ -318,8 +299,8 @@ def test_python_integer_promotion(self, val):
318299

319300
@pytest.mark.parametrize(["dtypes", "expected"], [
320301
# These promotions are not associative/commutative:
321-
([np.uint16, np.int16, np.float16], np.float32),
322-
([np.uint16, np.int8, np.float16], np.float32),
302+
([np.int16, np.float16], np.float32),
303+
([np.int8, np.float16], np.float32),
323304
([np.uint8, np.int16, np.float16], np.float32),
324305
# The following promotions are not ambiguous, but cover code
325306
# paths of abstract promotion (no particular logic being tested)

torch_np/tests/numpy_tests/core/test_scalar_ctors.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@
88
assert_equal, assert_almost_equal, assert_warns,
99
)
1010

11+
1112
class TestFromString:
13+
@pytest.mark.xfail(reason='XXX: floats from strings')
1214
def test_floating(self):
1315
# Ticket #640, floats from string
1416
fsingle = np.single('1.234')
1517
fdouble = np.double('1.234')
1618
assert_almost_equal(fsingle, 1.234)
1719
assert_almost_equal(fdouble, 1.234)
1820

21+
@pytest.mark.xfail(reason='XXX: floats from strings')
1922
def test_floating_overflow(self):
2023
""" Strings containing an unrepresentable float overflow """
2124
fhalf = np.half('1e10000')
@@ -32,7 +35,6 @@ def test_floating_overflow(self):
3235
fdouble = np.double('-1e10000')
3336
assert_equal(fdouble, -np.inf)
3437

35-
3638
def test_bool(self):
3739
with pytest.raises(TypeError):
3840
np.bool_(False, garbage=True)
@@ -44,8 +46,8 @@ def test_intp(self):
4446
assert_equal(1024, np.intp(1024))
4547

4648
def test_uint64_from_negative(self):
47-
with pytest.warns(DeprecationWarning):
48-
assert_equal(np.uint64(-2), np.uint64(18446744073709551614))
49+
# NumPy test was asserting a DeprecationWarning
50+
assert_equal(np.uint8(-2), np.uint8(254))
4951

5052

5153
int_types = [np.byte, np.short, np.intc, np.int_, np.longlong]
@@ -66,6 +68,12 @@ def _do_test(self, t1, t2):
6668
else:
6769
assert arr.dtype.type is t2
6870

71+
arr1 = np.asarray(x, dtype=t2)
72+
if t2 is None:
73+
assert arr1.dtype.type is t1
74+
else:
75+
assert arr1.dtype.type is t2
76+
6977
@pytest.mark.parametrize('t1', int_types + uint_types)
7078
@pytest.mark.parametrize('t2', int_types + uint_types + [None])
7179
def test_integers(self, t1, t2):

torch_np/tests/numpy_tests/core/test_scalar_methods.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
from pytest import raises as assert_raises
1818

1919

20+
@pytest.mark.skip(reason='XXX: scalar.as_integer_ratio not implemented')
2021
class TestAsIntegerRatio:
2122
# derived in part from the cpython test "test_floatasratio"
2223

2324
@pytest.mark.parametrize("ftype", [
24-
np.half, np.single, np.double, np.longdouble])
25+
np.half, np.single, np.double])
2526
@pytest.mark.parametrize("f, ratio", [
2627
(0.875, (7, 8)),
2728
(-0.875, (-7, 8)),
@@ -79,20 +80,6 @@ def test_against_known_values(self):
7980
(np.double, [0.0, 0.031066908499895136, 0.5214135908877832,
8081
0.45780736035689296, 0.5906586745934036],
8182
[0, -801, 51, 194, -653]),
82-
pytest.param(
83-
np.longdouble,
84-
[0.0, 0.20492557202724854, 0.4277180662199366, 0.9888085019891495,
85-
0.9620175814461964],
86-
[0, -7400, 14266, -7822, -8721],
87-
marks=[
88-
pytest.mark.skipif(
89-
np.finfo(np.double) == np.finfo(np.longdouble),
90-
reason="long double is same as double"),
91-
pytest.mark.skipif(
92-
platform.machine().startswith("ppc"),
93-
reason="IBM double double"),
94-
]
95-
)
9683
])
9784
def test_roundtrip(self, ftype, frac_vals, exp_vals):
9885
for frac, exp in zip(frac_vals, exp_vals):
@@ -136,6 +123,7 @@ def test_false(self, code: str) -> None:
136123
assert not value.is_integer()
137124

138125

126+
@pytest.mark.skip(reason='XXX: implementation details of the type system differ')
139127
@pytest.mark.skipif(sys.version_info < (3, 9), reason="Requires python 3.9")
140128
class TestClassGetItem:
141129
@pytest.mark.parametrize("cls", [
@@ -166,7 +154,7 @@ def test_abc_complexfloating_subscript_tuple(self, arg_len: int) -> None:
166154
with pytest.raises(TypeError, match=match):
167155
np.complexfloating[arg_tup]
168156

169-
@pytest.mark.parametrize("cls", [np.generic, np.flexible, np.character])
157+
@pytest.mark.parametrize("cls", [np.generic])
170158
def test_abc_non_numeric(self, cls: Type[np.generic]) -> None:
171159
with pytest.raises(TypeError):
172160
cls[Any]
@@ -198,6 +186,7 @@ def test_class_getitem_38(cls: Type[np.number]) -> None:
198186
cls[Any]
199187

200188

189+
@pytest.mark.skip(reason="scalartype(...).bit_count() not implemented")
201190
class TestBitCount:
202191
# derived in part from the cpython test "test_bit_count"
203192

torch_np/tests/numpy_tests/core/test_scalarinherit.py

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"""
44
import pytest
55

6-
import numpy as np
7-
from numpy.testing import assert_, assert_raises
6+
import torch_np as np
7+
from torch_np.testing import assert_
8+
from pytest import raises as assert_raises
89

910

1011
class A:
@@ -30,6 +31,7 @@ class B1(np.float64, HasNew):
3031
pass
3132

3233

34+
@pytest.mark.xfail(reason='scalar repr: numpy plain to make more explicit')
3335
class TestInherit:
3436
def test_init(self):
3537
x = B(1.0)
@@ -54,45 +56,3 @@ def test_gh_15395(self):
5456
with pytest.raises(TypeError):
5557
B1(1.0, 2.0)
5658

57-
58-
class TestCharacter:
59-
def test_char_radd(self):
60-
# GH issue 9620, reached gentype_add and raise TypeError
61-
np_s = np.string_('abc')
62-
np_u = np.unicode_('abc')
63-
s = b'def'
64-
u = 'def'
65-
assert_(np_s.__radd__(np_s) is NotImplemented)
66-
assert_(np_s.__radd__(np_u) is NotImplemented)
67-
assert_(np_s.__radd__(s) is NotImplemented)
68-
assert_(np_s.__radd__(u) is NotImplemented)
69-
assert_(np_u.__radd__(np_s) is NotImplemented)
70-
assert_(np_u.__radd__(np_u) is NotImplemented)
71-
assert_(np_u.__radd__(s) is NotImplemented)
72-
assert_(np_u.__radd__(u) is NotImplemented)
73-
assert_(s + np_s == b'defabc')
74-
assert_(u + np_u == 'defabc')
75-
76-
class MyStr(str, np.generic):
77-
# would segfault
78-
pass
79-
80-
with assert_raises(TypeError):
81-
# Previously worked, but gave completely wrong result
82-
ret = s + MyStr('abc')
83-
84-
class MyBytes(bytes, np.generic):
85-
# would segfault
86-
pass
87-
88-
ret = s + MyBytes(b'abc')
89-
assert(type(ret) is type(s))
90-
assert ret == b"defabc"
91-
92-
def test_char_repeat(self):
93-
np_s = np.string_('abc')
94-
np_u = np.unicode_('abc')
95-
res_s = b'abc' * 5
96-
res_u = 'abc' * 5
97-
assert_(np_s * 5 == res_s)
98-
assert_(np_u * 5 == res_u)

0 commit comments

Comments
 (0)