Skip to content
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

Add missing noexcept on cython function #60

Merged
merged 7 commits into from
Oct 16, 2023
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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: true
fail-fast: false
matrix:
os: ["windows-latest", "ubuntu-latest", "macos-latest"]
python-version: ["3.8", "3.9", "3.10"]
Expand All @@ -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
5 changes: 1 addition & 4 deletions continuous_integration/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@ channels:
dependencies:
- xarray
- dask
- distributed
- toolz
- Cython
- sphinx
- pillow
- pyyaml
- coveralls
- coverage
- codecov
- scipy
- h5py
- pytest
- pytest-cov
- pyproj
- pyproj >=3
- pyresample
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]
2 changes: 1 addition & 1 deletion geotiepoints/_simple_modis_interpolator.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ cdef inline floating _calc_offset_250(
floating[:, ::1] y,
floating m,
Py_ssize_t offset,
) nogil:
) noexcept nogil:
return result_view[offset + 3] - m * y[offset + 3, 0]


Expand Down
Loading