Skip to content

Commit

Permalink
Manage num_threads
Browse files Browse the repository at this point in the history
  • Loading branch information
vovaf709 committed Dec 24, 2023
1 parent a0cd64b commit 3fce9c7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions imops/interp2d.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import numpy as np
from scipy.spatial import KDTree
from platform import python_version

# TODO: can we make it submodule like `from imops.cpp import Linear2DInterpolatorCpp`?
from cpp_modules import Linear2DInterpolatorCpp

from .utils import normalize_num_threads
from .backend import Cython


class Linear2DInterpolator(Linear2DInterpolatorCpp):
"""
Expand Down Expand Up @@ -54,7 +59,8 @@ def __init__(
super().__init__(points, num_threads, triangles)
self.kdtree = KDTree(data=points, **kwargs)
self.values = values
self.num_threads = num_threads
# FIXME: add backend dispatch
self.num_threads = normalize_num_threads(num_threads, Cython(), warn_stacklevel=3)

def __call__(self, points: np.ndarray, values: np.ndarray = None, fill_value: float = 0.0) -> np.ndarray:
"""
Expand All @@ -65,7 +71,7 @@ def __call__(self, points: np.ndarray, values: np.ndarray = None, fill_value: fl
points: np.ndarray
2-D array of data point coordinates to interpolate at
values: np.ndarray
1-D array of fp32/fp64 values to use at initial points. If passed, existing values will be replaced
1-D array of fp32/fp64 values to use at initial points. If passed, existing values will be rewritten
fill_value: float
value to fill past edges
Expand Down

0 comments on commit 3fce9c7

Please sign in to comment.