Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/big_endian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:
python -m pip install --break-system-packages --no-deps . -v --no-build-isolation --force-reinstall &&

# Install test dependencies separately
python -m pip install --break-system-packages pytest pytest-run-parallel pytest-timeout mpmath &&
python -m pip install --break-system-packages .[test] &&

python -m pytest -vvv --color=yes --timeout=600 --tb=short tests/
'"
7 changes: 3 additions & 4 deletions .github/workflows/test_old_cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ jobs:
# For Sandy Bridge (x86-64-v2), we need to disable FMA code paths
# since FMA instructions are not available on that microarchitecture
if [ "${{ matrix.cpu[0] }}" = "snb" ]; then
pip install . --no-build-isolation -v -Csetup-args=-Ddisable_fma=true
pip install .[test] --no-build-isolation -v -Csetup-args=-Ddisable_fma=true
else
pip install . --no-build-isolation -v
pip install .[test] --no-build-isolation -v
fi

- name: Test import on ${{ matrix.cpu[1] }}
Expand All @@ -74,5 +74,4 @@ jobs:

- name: Run tests on ${{ matrix.cpu[1] }}
run: |
pip install pytest mpmath
sde -${{ matrix.cpu[0] }} -- python -m pytest tests/ -v --tb=short -v -s
sde -${{ matrix.cpu[0] }} -- python -m pytest tests/ -v --tb=short -v -s
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ dependencies = [
test = [
"pytest",
"mpmath",
"pytest-run-parallel"
"pytest-run-parallel",
"pandas"
]

docs = [
Expand Down
9 changes: 6 additions & 3 deletions src/csrc/scalar.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,11 @@ QuadPrecision_from_object(PyObject *value, QuadBackendType backend)
static PyObject *
QuadPrecision_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs)
{
PyObject *value;
PyObject *value = 0;
const char *backend_str = "sleef";
static char *kwlist[] = {"value", "backend", NULL};

if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|s", kwlist, &value, &backend_str)) {
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Os", kwlist, &value, &backend_str)) {
return NULL;
}

Expand All @@ -298,6 +298,9 @@ QuadPrecision_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs)
return NULL;
}

if (value == NULL) {
return (PyObject *)QuadPrecision_raw_new(backend);
}
return (PyObject *)QuadPrecision_from_object(value, backend);
}

Expand Down Expand Up @@ -747,4 +750,4 @@ init_quadprecision_scalar(void)
{
QuadPrecision_Type.tp_base = &PyFloatingArrType_Type;
return PyType_Ready(&QuadPrecision_Type);
}
}
24 changes: 23 additions & 1 deletion tests/test_quaddtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -5996,4 +5996,26 @@ def test_sleef_purecfma_symbols():
for sym in purecfma_symbols[:5]:
print(f" {sym}")
if len(purecfma_symbols) > 5:
print(f" ... and {len(purecfma_symbols) - 5} more")
print(f" ... and {len(purecfma_symbols) - 5} more")


def test_empty_construct():
assert QuadPrecision() == QuadPrecision(0) == 0


def test_pandas_strrep():
"""Test that we can construct a pandas data frame with quad precision columns

Make sure the string representation can be generated
"""
import pandas as pd

BIG_NUMBER=123456789098765432123456789
x = np.arange(500, dtype=np.float64) * BIG_NUMBER
y = np.arange(500, dtype=QuadPrecDType()) * BIG_NUMBER
df = pd.DataFrame({"col1": x, "col2": y})
assert isinstance(str(df), str) # Make sure this doesn't fail
assert df["col1"].dtype == np.float64
assert df["col2"].dtype == QuadPrecDType()
assert df["col1"].iloc[499] != QuadPrecision(499 * BIG_NUMBER)
assert df["col2"].iloc[499] == QuadPrecision(499 * BIG_NUMBER)
Loading