File: 0003-no-numba.patch

package info (click to toggle)
xarray-eopf 0.2.7-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,712 kB
  • sloc: python: 3,300; makefile: 3
file content (44 lines) | stat: -rw-r--r-- 1,244 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
From: Antonio Valentino <antonio.valentino@tiscali.it>
Date: Sat, 28 Mar 2026 23:08:40 +0000
Subject: no-numba

Forwarded: https://github.com/EOPF-Sample-Service/xarray-eopf/pull/77
---
 xarray_eopf/coarsen.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/xarray_eopf/coarsen.py b/xarray_eopf/coarsen.py
index c8cf0f9..d745f9e 100644
--- a/xarray_eopf/coarsen.py
+++ b/xarray_eopf/coarsen.py
@@ -7,7 +7,10 @@
 or have special implementations compared to their numpy equivalents.
 """
 
-import numba as nb
+try:
+    import numba as nb
+except ImportError:
+    nb = None
 import numpy as np
 
 _ALL = slice(None)
@@ -113,7 +116,7 @@ def mode(block: np.ndarray, axis: tuple[int, ...] | None = None) -> np.ndarray:
     return mode_indices.reshape(block.shape[:-ndim])
 
 
-@nb.njit()
+# @nb.njit()
 def _mode_from_normalized(
     flat_block: np.ndarray, offset: int, mode_range: int
 ) -> np.ndarray:  # pragma: no cover
@@ -132,6 +135,9 @@ def _mode_from_normalized(
         out[i] = mode_val + offset
     return out
 
+if nb is not None:
+    _mode_from_normalized = nb.njit(_mode_from_normalized)
+
 
 first.__doc__ = _DOC.format(property="first value")
 last.__doc__ = _DOC.format(property="last value")