Skip to content

NaN tests + Workflow + README fixes #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 4, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
24 changes: 15 additions & 9 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,22 +194,28 @@ jobs:
path: ./quaddtype/wheelhouse/*.whl
name: wheels-windows-${{ matrix.architecture }}

publish_to_testpypi:
name: Publish to TestPyPI
publish_to_pypi:
name: Publish to PyPI
needs: [build_wheels_linux, build_wheels_macos, build_wheels_windows]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/quaddtype-v')

environment:
name: quadtype_release
url: https://pypi.org/p/numpy-quaddtype

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Publish to TestPyPI
uses: pypa/[email protected]

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
packages-dir: dist/*

create_release:
Expand All @@ -231,7 +237,7 @@ jobs:
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.QUADDTYPE_GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
Expand All @@ -244,4 +250,4 @@ jobs:
with:
files: ./artifacts/**/*.whl
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.QUADDTYPE_GITHUB_TOKEN }}
28 changes: 12 additions & 16 deletions quaddtype/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Numpy-QuadDType

A cross-platform Quad (128-bit) float Data-Type for NumPy.

## Installation

```
pip install numpy==2.1.0
pip install -i https://test.pypi.org/simple/ quaddtype
```bash
pip install numpy
pip install numpy-quaddtype
```

## Usage
Expand All @@ -21,38 +23,32 @@ np.array([1,2,3], dtype=QuadPrecDType("sleef"))
np.array([1,2,3], dtype=QuadPrecDType("longdouble"))
```

## Install from source
## Installation from source

The code needs the quad precision pieces of the sleef library, which
is not available on most systems by default, so we have to generate
that first. The below assumes one has the required pieces to build
sleef (cmake and libmpfr-dev), and that one is in the package
directory locally.

```
git clone https://github.com/shibatch/sleef.git
```bash
git clone --branch 3.8 https://github.com/shibatch/sleef.git
cd sleef
cmake -S . -B build -DSLEEF_BUILD_QUAD:BOOL=ON -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON
cmake --build build/ --clean-first -j
cd ..
```

In principle, one can now install this system-wide, but easier would
seem to use the version that was just created, as follows:
```
Building the `numpy-quaddtype` package from locally installed sleef:
```bash
export SLEEF_DIR=$PWD/sleef/build
export LIBRARY_PATH=$SLEEF_DIR/lib
export C_INCLUDE_PATH=$SLEEF_DIR/include
export CPLUS_INCLUDE_PATH=$SLEEF_DIR/include
python3 -m venv temp
source temp/bin/activate

# Install the package
pip install meson-python numpy pytest
pip install -e . -v --no-build-isolation
export LD_LIBRARY_PATH=$SLEEF_DIR/lib
```

Here, we created an editable install on purpose, so one can just work
from the package directory if needed, e.g., to run the tests with,
```
python -m pytest
```
4 changes: 4 additions & 0 deletions quaddtype/tests/test_quaddtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ def test_unary_ops(op, val, expected):

assert result == expected_val, f"{op}({val}) should be {expected}, but got {result}"

def test_inf():
assert QuadPrecision("inf") > QuadPrecision("1e1000")
assert QuadPrecision("-inf") < QuadPrecision("-1e1000")


def test_dtype_creation():
dtype = QuadPrecDType()
Expand Down