Skip to content

Commit

Permalink
For strict channel priority in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Oct 16, 2023
1 parent 0a9be1b commit 1dbfecf
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
channel-priority: strict
python-version: ${{ matrix.python-version }}
activate-environment: test-environment
environment-file: continuous_integration/environment.yaml
Expand Down
17 changes: 17 additions & 0 deletions cython_test.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# cython: language_level=3, boundscheck=False, cdivision=True, wraparound=False, initializedcheck=False, nonecheck=False
cimport cython
import numpy as np
cimport numpy as np

np.import_array()

def test_func():
cdef np.ndarray[float, ndim=2] arr = np.zeros((5, 5), dtype=np.float32)
cdef float[:, ::1] arr_view = arr
_run(arr_view)

cdef void _run(float[:, ::1] arr_view) noexcept nogil:
cdef float[:, :] tmp = _get_upper_left_corner(arr_view)

cdef inline float[:, :] _get_upper_left_corner(float[:, ::1] arr) noexcept nogil:
return arr[:1, :1]
34 changes: 34 additions & 0 deletions cython_test2.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# cython: language_level=3, boundscheck=False, cdivision=True, wraparound=False, initializedcheck=False, nonecheck=False
cimport cython
import numpy as np
cimport numpy as np

np.import_array()

def test_func():
cdef np.ndarray[float, ndim=2] arr = np.zeros((5, 5), dtype=np.float32)
cdef float[:, ::1] arr_view = arr
t = Test(5.0)
t.call_me(arr_view)


cdef class Test:

cdef float _a

def __cinit__(self, float a):
self._a = a

cdef void call_me(self, float[:, ::1] my_arr) noexcept:
with nogil:
self._call_me(my_arr)

cdef void _call_me(self, float[:, ::1] my_arr) noexcept nogil:
cdef Py_ssize_t idx
cdef float[:, :] my_arr2 = _get_upper_left_corner(my_arr)
for idx in range(my_arr2.shape[0]):
my_arr2[idx, 0] = self._a


cdef inline float[:, :] _get_upper_left_corner(float[:, ::1] arr) noexcept nogil:
return arr[:3, :3]

0 comments on commit 1dbfecf

Please sign in to comment.