Skip to content

Commit 66f6b4e

Browse files
committed
small nits + ld test
1 parent 840a2ff commit 66f6b4e

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

src/csrc/scalar.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ QuadPrecision_from_object(PyObject *value, QuadBackendType backend)
281281
static PyObject *
282282
QuadPrecision_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs)
283283
{
284-
PyObject *value = 0;
284+
PyObject *value = NULL;
285285
const char *backend_str = "sleef";
286286
static char *kwlist[] = {"value", "backend", NULL};
287287

@@ -299,7 +299,7 @@ QuadPrecision_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs)
299299
}
300300

301301
if (value == NULL) {
302-
return (PyObject *)QuadPrecision_raw_new(backend);
302+
return (PyObject *)QuadPrecision_raw_new(backend);
303303
}
304304
return (PyObject *)QuadPrecision_from_object(value, backend);
305305
}

tests/test_quaddtype.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6000,7 +6000,31 @@ def test_sleef_purecfma_symbols():
60006000

60016001

60026002
def test_empty_construct():
6003+
# Default backend (sleef): no-arg construction yields zero.
60036004
assert QuadPrecision() == QuadPrecision(0) == 0
6005+
assert QuadPrecision().dtype == QuadPrecDType()
6006+
assert str(QuadPrecision()) == str(QuadPrecision(0))
6007+
6008+
# longdouble backend: no-arg construction also yields zero.
6009+
assert QuadPrecision(backend="longdouble") == QuadPrecision(0, backend="longdouble") == 0
6010+
assert QuadPrecision(backend="longdouble").dtype == QuadPrecDType(backend="longdouble")
6011+
6012+
# Round-trip through dtype.type(), this is the call path pandas uses
6013+
# in `_take_preprocess_indexer_and_fill_value` (see issue #83).
6014+
for backend in ("sleef", "longdouble"):
6015+
dtype = QuadPrecDType(backend=backend)
6016+
zero = dtype.type()
6017+
assert isinstance(zero, QuadPrecision)
6018+
assert zero == 0
6019+
6020+
# Invalid backend must still raise even when no value is supplied.
6021+
with pytest.raises(ValueError):
6022+
QuadPrecision(backend="bogus")
6023+
6024+
# Explicit None should NOT be silently treated as zero, it must go
6025+
# through QuadPrecision_from_object and raise.
6026+
with pytest.raises((TypeError, ValueError)):
6027+
QuadPrecision(None)
60046028

60056029

60066030
def test_pandas_strrep():

0 commit comments

Comments
 (0)