Skip to content

Commit f696848

Browse files
committed
fix tests
1 parent 534a64e commit f696848

2 files changed

Lines changed: 21 additions & 28 deletions

File tree

quaddtype/numpy_quaddtype/src/casts.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,13 +1236,13 @@ static inline int quad_to_numpy_same_value_check(quad_value x, QuadBackendType b
12361236
if(backend == BACKEND_SLEEF) {
12371237
if(Sleef_iunordq1(x.sleef_value, roundtrip.sleef_value))
12381238
return 1;
1239-
else if(Sleef_icmpeqq1(x.sleef_value, roundtrip.sleef_value))
1239+
if(Sleef_icmpeqq1(x.sleef_value, roundtrip.sleef_value))
12401240
return 1;
12411241
}
12421242
else {
12431243
if(std::isnan(x.longdouble_value) && std::isnan(roundtrip.longdouble_value))
12441244
return 1;
1245-
else if(x.longdouble_value == roundtrip.longdouble_value)
1245+
if(x.longdouble_value == roundtrip.longdouble_value)
12461246
return 1;
12471247
}
12481248
Sleef_quad sleef_val = quad_to_sleef_quad(&x, backend);
@@ -1259,6 +1259,23 @@ static inline int quad_to_numpy_same_value_check(quad_value x, QuadBackendType b
12591259
return -1;
12601260
}
12611261

1262+
// template <typename T>
1263+
// static inline int quad_to_numpy_same_value_check(quad_value x, QuadBackendType backend, typename NpyType<T>::TYPE *y)
1264+
// {
1265+
// *y = from_quad<T>(x, backend);
1266+
// quad_value roundtrip = to_quad<T>(*y, backend);
1267+
// if(backend == BACKEND_SLEEF) {
1268+
// if(Sleef_icmpeqq1(x.sleef_value, roundtrip.sleef_value))
1269+
// return 1;
1270+
// }
1271+
// else {
1272+
// if(x.longdouble_value == roundtrip.longdouble_value)
1273+
// return 1;
1274+
// }
1275+
// PyErr_SetString(PyExc_ValueError, "could not cast 'same_value' to QuadType");
1276+
// return -1;
1277+
// }
1278+
12621279
// Type trait to check if a type is a floating-point type for casting purposes
12631280
template <typename T>
12641281
struct is_float_type : std::false_type {};

quaddtype/tests/test_quaddtype.py

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5448,29 +5448,5 @@ def test_same_value_cast_quad_to_int(self, dtype, passing, failing):
54485448

54495449
for val in failing:
54505450
q = np.array([val], dtype=QuadPrecDType())
5451-
with pytest.raises(ValueError, match="could not cast 'same_value'"):
5452-
q.astype(dtype, casting="same_value")
5453-
5454-
@pytest.mark.parametrize("dtype", ["half", "float16",
5455-
"float", "float32",
5456-
"double", "float64",
5457-
"longdouble",])
5458-
@pytest.mark.parametrize("values", [
5459-
5460-
])
5461-
def test_same_value_cast_floats(self, dtype, values):
5462-
pass
5463-
5464-
@pytest.mark.parametrize("dtype", [
5465-
"S50", "U50", "<U50", ">U50", "S100", "U100", "<U100", ">U100", np.dtypes.StringDType()])
5466-
@pytest.mark.parametrize("values", [
5467-
])
5468-
def test_same_value_cast_strings_enough_width(self, dtype, values):
5469-
pass
5470-
5471-
@pytest.mark.parametrize("dtype", [
5472-
"S20", "U20", "<U20", ">U20"])
5473-
@pytest.mark.parametrize("values", [
5474-
])
5475-
def test_same_value_cast_strings_small_width(self, dtype, values):
5476-
pass
5451+
with pytest.raises(ValueError):
5452+
q.astype(dtype, casting="same_value")

0 commit comments

Comments
 (0)