From d00f947b4e98dd05c6432c4087cec2432d0e825b Mon Sep 17 00:00:00 2001 From: Qiyun Zhu Date: Wed, 10 Apr 2024 12:35:59 -0700 Subject: [PATCH] Supporting NumPy 2.0 (#950) * added numpy-2.0 support * Update ChangeLog.md --- ChangeLog.md | 1 + biom/_filter.pyx | 1 + biom/_subsample.pyx | 2 ++ biom/_transform.pyx | 1 + 4 files changed, 5 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 8cb9d77b..622634d5 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -6,6 +6,7 @@ biom 2.1.15-dev Performance improvements: +* Add NumPy 2.0 support. PR [#950](https://github.com/biocore/biom-format/pull/950) ensures code compatibility with NumPy 2.0. This support is yet to be added to the CI testing matrix. * Revise `Table._fast_merge` to use COO directly. For very large tables, this reduces runtime by ~50x and memory by ~5x. See PR [#913](https://github.com/biocore/biom-format/pull/933). * Drastically reduce the memory needs of subsampling when sums are large. Also adds 64-bit support. See PR [#935](https://github.com/biocore/biom-format/pull/935). * Improve handling of not-perfectly-integer inputs. See PR [#938](https://github.com/biocore/biom-format/pull/938). diff --git a/biom/_filter.pyx b/biom/_filter.pyx index 3c94ac54..879db01d 100644 --- a/biom/_filter.pyx +++ b/biom/_filter.pyx @@ -13,6 +13,7 @@ from types import FunctionType import numpy as np cimport numpy as cnp +cnp.import_array() cdef cnp.ndarray[cnp.uint8_t, ndim=1] \ diff --git a/biom/_subsample.pyx b/biom/_subsample.pyx index 6bf212ac..35892025 100644 --- a/biom/_subsample.pyx +++ b/biom/_subsample.pyx @@ -8,6 +8,8 @@ import numpy as np cimport numpy as cnp +cnp.import_array() + cdef _subsample_with_replacement(cnp.ndarray[cnp.float64_t, ndim=1] data, cnp.ndarray[cnp.int32_t, ndim=1] indptr, diff --git a/biom/_transform.pyx b/biom/_transform.pyx index 8a15018f..0d500042 100644 --- a/biom/_transform.pyx +++ b/biom/_transform.pyx @@ -9,6 +9,7 @@ import numpy as np cimport numpy as cnp +cnp.import_array() def _transform(arr, ids, metadata, function, axis):