Skip to content
Merged
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
14 changes: 7 additions & 7 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ">=3.11.0"
python-version: ">=3.12"

- name: Install cibuildwheel
run: pip install cibuildwheel==3.1.4

- name: Build wheels
env:
CIBW_BUILD: "cp311-manylinux_x86_64 cp312-manylinux_x86_64 cp313-manylinux_x86_64 cp314-manylinux_x86_64 cp314t-manylinux_x86_64"
CIBW_BUILD: "cp312-manylinux_x86_64 cp313-manylinux_x86_64 cp314-manylinux_x86_64 cp314t-manylinux_x86_64"
CIBW_ENABLE: cpython-prerelease cpython-freethreading
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_BUILD_VERBOSITY: "3"
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ">=3.11.0"
python-version: ">=3.12"

- name: Install dependencies
run: |
Expand All @@ -88,7 +88,7 @@ jobs:

- name: Build wheels
env:
CIBW_BUILD: "cp311-* cp312-* cp313-* cp314-* cp314t-*"
CIBW_BUILD: "cp312-* cp313-* cp314-* cp314t-*"
CIBW_ENABLE: cpython-prerelease cpython-freethreading
# CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }}
CIBW_BUILD_VERBOSITY: "3"
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ">=3.11.0"
python-version: ">=3.12"
architecture: ${{ matrix.architecture }}

- name: Install CMake
Expand All @@ -149,7 +149,7 @@ jobs:

- name: Build wheels
env:
CIBW_BUILD: "cp311-* cp312-* cp313-* cp314-* cp314t-*"
CIBW_BUILD: "cp312-* cp313-* cp314-* cp314t-*"
CIBW_ENABLE: cpython-prerelease cpython-freethreading
CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }}
CIBW_BUILD_VERBOSITY: "3"
Expand Down Expand Up @@ -177,7 +177,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ">=3.11.0"
python-version: ">=3.12"

- name: Install system dependencies
run: |
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ A cross-platform Quad (128-bit) float Data-Type for NumPy.
## Installation

```bash
pip install "numpy>=2.4"
pip install "numpy>=2.5.3"
pip install numpy-quaddtype
```

Expand Down Expand Up @@ -70,15 +70,15 @@ np.array([1,2,3], dtype=QuadPrecDType("longdouble"))

### Linux/Unix/macOS

**Prerequisites:** gcc/clang, CMake (≥3.15), Python 3.11+, Git, NumPy ≥ 2.4
**Prerequisites:** gcc/clang, CMake (≥3.15), Python 3.12+, Git, NumPy ≥ 2.5.3

```bash
# setup the virtual env
python3 -m venv temp
source temp/bin/activate

# Install build and test dependencies
pip install pytest meson meson-python "numpy>=2.4"
pip install pytest meson meson-python "numpy>=2.5.3"

# To build without QBLAS (default for MSVC)
# export CFLAGS="-DDISABLE_QUADBLAS"
Expand All @@ -92,7 +92,7 @@ python -m pytest tests

### Windows

**Prerequisites:** Visual Studio 2017+ (with MSVC), CMake (≥3.15), Python 3.11+, Git
**Prerequisites:** Visual Studio 2017+ (with MSVC), CMake (≥3.15), Python 3.12+, Git

1. **Setup Development Environment**

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:alt: PyPI version
```

```{image} https://img.shields.io/badge/python-3.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue.svg
```{image} https://img.shields.io/badge/python-3.12%20%7C%203.13%20%7C%203.14-blue.svg
:alt: Python versions
```

Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requires = [
"meson-python>=0.18.0",
"wheel",
"cmake",
"numpy>=2.4"
"numpy>=2.5.3"
]
build-backend = "mesonpy"

Expand All @@ -20,16 +20,15 @@ maintainers = [{name = "NumPy Developers", email = "numpy-discussion@python.org"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Free Threading",
"Typing :: Typed",
]
requires-python = ">=3.11.0"
requires-python = ">=3.12"
dependencies = [
"numpy>=2.4"
"numpy>=2.5.3"
]

[project.optional-dependencies]
Expand Down
78 changes: 2 additions & 76 deletions src/csrc/umath/binary_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,48 +492,10 @@ create_quad_binary_2out_ufunc(PyObject *numpy, const char *ufunc_name)
return -1;
}

PyObject *promoter_capsule =
PyCapsule_New((void *)&quad_ufunc_promoter, "numpy._ufunc_promoter", NULL);
if (promoter_capsule == NULL) {
if (quad_add_promoters(ufunc) < 0) {
Py_DECREF(ufunc);
return -1;
}

// Register promoter for (QuadPrecDType, Any, Any, Any)
PyObject *DTypes = PyTuple_Pack(4, &QuadPrecDType, &PyArrayDescr_Type,
&PyArrayDescr_Type, &PyArrayDescr_Type);
if (DTypes == NULL) {
Py_DECREF(promoter_capsule);
Py_DECREF(ufunc);
return -1;
}

if (PyUFunc_AddPromoter(ufunc, DTypes, promoter_capsule) < 0) {
Py_DECREF(promoter_capsule);
Py_DECREF(DTypes);
Py_DECREF(ufunc);
return -1;
}
Py_DECREF(DTypes);

// Register promoter for (Any, QuadPrecDType, Any, Any)
DTypes = PyTuple_Pack(4, &PyArrayDescr_Type, &QuadPrecDType,
&PyArrayDescr_Type, &PyArrayDescr_Type);
if (DTypes == NULL) {
Py_DECREF(promoter_capsule);
Py_DECREF(ufunc);
return -1;
}

if (PyUFunc_AddPromoter(ufunc, DTypes, promoter_capsule) < 0) {
Py_DECREF(promoter_capsule);
Py_DECREF(DTypes);
Py_DECREF(ufunc);
return -1;
}
Py_DECREF(promoter_capsule);
Py_DECREF(DTypes);

Py_DECREF(ufunc);
return 0;
}
Expand Down Expand Up @@ -572,46 +534,10 @@ create_quad_binary_ufunc(PyObject *numpy, const char *ufunc_name)
return -1;
}

PyObject *promoter_capsule =
PyCapsule_New((void *)&quad_ufunc_promoter, "numpy._ufunc_promoter", NULL);
if (promoter_capsule == NULL) {
Py_DECREF(ufunc);
return -1;
}

// Register promoter for (QuadPrecDType, Any, Any)
PyObject *DTypes = PyTuple_Pack(3, &QuadPrecDType, &PyArrayDescr_Type, &PyArrayDescr_Type);
if (DTypes == NULL) {
Py_DECREF(promoter_capsule);
Py_DECREF(ufunc);
return -1;
}

if (PyUFunc_AddPromoter(ufunc, DTypes, promoter_capsule) < 0) {
Py_DECREF(promoter_capsule);
Py_DECREF(DTypes);
Py_DECREF(ufunc);
return -1;
}
Py_DECREF(DTypes);

// Register promoter for (Any, QuadPrecDType, Any)
DTypes = PyTuple_Pack(3, &PyArrayDescr_Type, &QuadPrecDType, &PyArrayDescr_Type);
if (DTypes == NULL) {
Py_DECREF(promoter_capsule);
Py_DECREF(ufunc);
return -1;
}

if (PyUFunc_AddPromoter(ufunc, DTypes, promoter_capsule) < 0) {
Py_DECREF(promoter_capsule);
Py_DECREF(DTypes);
if (quad_add_promoters(ufunc) < 0) {
Py_DECREF(ufunc);
return -1;
}
Py_DECREF(promoter_capsule);
Py_DECREF(DTypes);

Py_DECREF(ufunc);
return 0;
}
Expand Down
18 changes: 1 addition & 17 deletions src/csrc/umath/comparison_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,21 +269,6 @@ comparison_object_output_is_bool(PyUFuncObject *ufunc)
strcmp(ufunc->name, "logical_xor") != 0;
}

// Registers `promoter` for a single (in1, in2, out) DType pattern.
static int
add_comparison_promoter(PyObject *ufunc, PyObject *promoter, PyArray_DTypeMeta *in1,
PyArray_DTypeMeta *in2, PyArray_DTypeMeta *out)
{
PyObject *DTypes = PyTuple_Pack(3, (PyObject *)in1, (PyObject *)in2, (PyObject *)out);
if (DTypes == NULL) {
return -1;
}

int res = PyUFunc_AddPromoter(ufunc, DTypes, promoter);
Py_DECREF(DTypes);
return res;
}

NPY_NO_EXPORT int
comparison_ufunc_promoter(PyObject *ufunc_obj, PyArray_DTypeMeta *const op_dtypes[],
PyArray_DTypeMeta *const signature[], PyArray_DTypeMeta *new_op_dtypes[])
Expand Down Expand Up @@ -401,8 +386,7 @@ create_quad_comparison_ufunc(PyObject *numpy, const char *ufunc_name)
};

for (size_t i = 0; i < sizeof(promoter_patterns) / sizeof(promoter_patterns[0]); i++) {
if (add_comparison_promoter(ufunc, promoter_capsule, promoter_patterns[i][0],
promoter_patterns[i][1], promoter_patterns[i][2]) < 0) {
if (quad_add_promoter(ufunc, promoter_capsule, promoter_patterns[i]) < 0) {
Py_DECREF(promoter_capsule);
Py_DECREF(ufunc);
return -1;
Expand Down
42 changes: 2 additions & 40 deletions src/csrc/umath/matmul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,48 +518,10 @@ init_matmul_ops(PyObject *numpy)
return -1;
}

PyObject *promoter_capsule =
PyCapsule_New((void *)&quad_ufunc_promoter, "numpy._ufunc_promoter", NULL);
if (promoter_capsule == NULL) {
if (quad_add_promoters(ufunc) < 0) {
Py_DECREF(ufunc);
return -1;
}

// Register promoter for (QuadPrecDType, Any, Any)
PyObject *DTypes = PyTuple_Pack(3, &QuadPrecDType, &PyArrayDescr_Type, &PyArrayDescr_Type);
if (DTypes == NULL) {
Py_DECREF(promoter_capsule);
Py_DECREF(ufunc);
return -1;
}

if (PyUFunc_AddPromoter(ufunc, DTypes, promoter_capsule) < 0) {
Py_DECREF(promoter_capsule);
Py_DECREF(DTypes);
Py_DECREF(ufunc);
return -1;
}
Py_DECREF(DTypes);

// Register promoter for (Any, QuadPrecDType, Any)
DTypes = PyTuple_Pack(3, &PyArrayDescr_Type, &QuadPrecDType, &PyArrayDescr_Type);
if (DTypes == NULL) {
Py_DECREF(promoter_capsule);
Py_DECREF(ufunc);
return -1;
}

if (PyUFunc_AddPromoter(ufunc, DTypes, promoter_capsule) < 0) {
Py_DECREF(promoter_capsule);
Py_DECREF(DTypes);
Py_DECREF(ufunc);
return -1;
}
Py_DECREF(DTypes);

Py_DECREF(promoter_capsule);

Py_DECREF(ufunc);

return 0;
}
}
11 changes: 11 additions & 0 deletions src/csrc/umath/unary_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern "C" {
#include "scalar.h"
#include "dtype.h"
#include "ops.hpp"
#include "umath/promoters.hpp"

static NPY_CASTING
quad_unary_op_resolve_descriptors(PyObject *self, PyArray_DTypeMeta *const dtypes[],
Expand Down Expand Up @@ -140,6 +141,11 @@ create_quad_unary_ufunc(PyObject *numpy, const char *ufunc_name)
return -1;
}

if (quad_add_promoters(ufunc) < 0) {
Py_DECREF(ufunc);
return -1;
}

Py_DECREF(ufunc);
return 0;
}
Expand Down Expand Up @@ -409,6 +415,11 @@ create_quad_unary_2out_ufunc(PyObject *numpy, const char *ufunc_name)
return -1;
}

if (quad_add_promoters(ufunc) < 0) {
Py_DECREF(ufunc);
return -1;
}

Py_DECREF(ufunc);
return 0;
}
Expand Down
Loading
Loading