From a2e060139bd5b367bed4fa78e75cfd4b259a880e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Sun, 5 Mar 2023 23:52:45 +0100 Subject: [PATCH] BLD: fix compilation errors with Cython 3.0.0b1 (pow return type) --- .github/workflows/wheels.yaml | 2 +- pyproject.toml | 2 +- yt/frontends/ramses/io_utils.pyx | 3 +++ yt/utilities/lib/basic_octree.pyx | 7 ++++--- yt/utilities/lib/geometry_utils.pyx | 7 ++++++- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/wheels.yaml b/.github/workflows/wheels.yaml index 4ac2be9b5af..ab9e90c2111 100644 --- a/.github/workflows/wheels.yaml +++ b/.github/workflows/wheels.yaml @@ -84,7 +84,7 @@ jobs: - name: Install build time dependencies shell: bash run: | - python -m pip install "Cython>=0.29.21,<3.0" + python -m pip install "Cython>=0.29.33,<3.0" python -m pip install oldest-supported-numpy python -m pip install --upgrade wheel python -m pip install --upgrade setuptools diff --git a/pyproject.toml b/pyproject.toml index c054a89e043..8dd8cbe9d94 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ requires = [ # Cython 3.0 is the next version after 0.29, and a major change, # we forbid it until we can properly test against it # https://github.com/yt-project/yt/issues/4355 - "Cython>=0.29.21,<3.0", + "Cython>=0.29.33,<3.0", "oldest-supported-numpy", ] diff --git a/yt/frontends/ramses/io_utils.pyx b/yt/frontends/ramses/io_utils.pyx index 9052baebc4d..7becee63486 100644 --- a/yt/frontends/ramses/io_utils.pyx +++ b/yt/frontends/ramses/io_utils.pyx @@ -14,6 +14,7 @@ ctypedef np.int32_t INT32_t ctypedef np.int64_t INT64_t ctypedef np.float64_t DOUBLE_t +@cython.cpow(True) @cython.boundscheck(False) @cython.wraparound(False) @cython.cdivision(True) @@ -82,6 +83,7 @@ def read_amr(FortranFile f, dict headers, return max_level +@cython.cpow(True) @cython.boundscheck(False) @cython.wraparound(False) @cython.cdivision(True) @@ -132,6 +134,7 @@ cpdef read_offset(FortranFile f, INT64_t min_level, INT64_t domain_id, INT64_t n return offset, level_count +@cython.cpow(True) @cython.boundscheck(False) @cython.wraparound(False) @cython.cdivision(True) diff --git a/yt/utilities/lib/basic_octree.pyx b/yt/utilities/lib/basic_octree.pyx index 0e1223dc3a5..d4d26422192 100644 --- a/yt/utilities/lib/basic_octree.pyx +++ b/yt/utilities/lib/basic_octree.pyx @@ -38,7 +38,7 @@ cdef struct OctreeNode: np.float64_t *val np.float64_t weight_val np.int64_t pos[3] - int level + np.uint64_t level int nvals int max_level # The maximum level under this node with mass. OctreeNode *children[2][2][2] @@ -129,7 +129,7 @@ cdef class Octree: def __cinit__(self, np.ndarray[np.int64_t, ndim=1] top_grid_dims, int nvals, int incremental = False): - cdef int i, j, k + cdef np.uint64_t i, j, k self.incremental = incremental cdef np.int64_t pos[3] cdef np.float64_t *vals = alloca( @@ -499,7 +499,8 @@ cdef class Octree: cdef int node_ID(self, OctreeNode *node): # Returns an unique ID for this node based on its position and level. - cdef int ID, i, offset, root + cdef int ID, offset, root + cdef np.uint64_t i cdef np.int64_t this_grid_dims[3] offset = 0 root = 1 diff --git a/yt/utilities/lib/geometry_utils.pyx b/yt/utilities/lib/geometry_utils.pyx index 1a3790f148c..b22bbd97768 100644 --- a/yt/utilities/lib/geometry_utils.pyx +++ b/yt/utilities/lib/geometry_utils.pyx @@ -85,6 +85,7 @@ cdef np.int64_t tsb(np.int64_t x, np.int64_t width): i += 1 return i +@cython.cpow(True) @cython.cdivision(True) @cython.boundscheck(False) @cython.wraparound(False) @@ -92,6 +93,7 @@ cdef np.int64_t bitrange(np.int64_t x, np.int64_t width, np.int64_t start, np.int64_t end): return x >> (width-end) & ((2**(end-start))-1) +@cython.cpow(True) @cython.cdivision(True) @cython.boundscheck(False) @cython.wraparound(False) @@ -100,6 +102,7 @@ cdef np.int64_t rrot(np.int64_t x, np.int64_t i, np.int64_t width): x = (x>>i) | (x<