venv
This commit is contained in:
@@ -92,3 +92,34 @@ def ignore_invalid(condition=True):
|
||||
|
||||
with ignore_invalid():
|
||||
line_string_nan = shapely.LineString([(np.nan, np.nan), (np.nan, np.nan)])
|
||||
|
||||
|
||||
class ArrayLike:
|
||||
"""
|
||||
Simple numpy Array like class that implements the
|
||||
ufunc protocol.
|
||||
"""
|
||||
|
||||
def __init__(self, array):
|
||||
self._array = np.asarray(array)
|
||||
|
||||
def __len__(self):
|
||||
return len(self._array)
|
||||
|
||||
def __getitem(self, key):
|
||||
return self._array[key]
|
||||
|
||||
def __iter__(self):
|
||||
return self._array.__iter__()
|
||||
|
||||
def __array__(self):
|
||||
return np.asarray(self._array)
|
||||
|
||||
def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
|
||||
if method == "__call__":
|
||||
inputs = [
|
||||
arg._array if isinstance(arg, self.__class__) else arg for arg in inputs
|
||||
]
|
||||
return self.__class__(ufunc(*inputs, **kwargs))
|
||||
else:
|
||||
return NotImplemented
|
||||
|
||||
Reference in New Issue
Block a user