Skip to content

Commit c66c8fc

Browse files
committed
- fix #234 : implemented support for np.__array_ufunc__
- merged npufuncs.py module into ufuncs.py - updated setup.cfg config file to skip all functions derived from Numpy and for which copied doctests fail
1 parent 2590c1c commit c66c8fc

File tree

8 files changed

+430
-316
lines changed

8 files changed

+430
-316
lines changed

doc/source/changes/version_0_32.rst.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ New features
4949
Miscellaneous improvements
5050
^^^^^^^^^^^^^^^^^^^^^^^^^^
5151

52-
* improved something.
52+
* made it possible to pass LArray objects to Numpy ufuncs directly (e.g. np.sqrt(ndtest(3)), closes :issue:`234`).
5353

5454

5555
Fixes

larray/__init__.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
from larray.core.session import Session, local_arrays, global_arrays, arrays
1313
from larray.core.constants import nan, inf, pi, e, euler_gamma
1414
from larray.core.metadata import Metadata
15-
from larray.core.ufuncs import wrap_elementwise_array_func, maximum, minimum, where
16-
from larray.core.npufuncs import (sin, cos, tan, arcsin, arccos, arctan, hypot, arctan2, degrees,
17-
radians, unwrap, sinh, cosh, tanh, arcsinh, arccosh, arctanh,
18-
angle, real, imag, conj,
19-
round, around, round_, rint, fix, floor, ceil, trunc,
20-
exp, expm1, exp2, log, log10, log2, log1p, logaddexp, logaddexp2,
21-
i0, sinc, signbit, copysign, frexp, ldexp,
22-
convolve, clip, sqrt, absolute, fabs, sign, fmax, fmin, nan_to_num,
23-
real_if_close, interp, isnan, isinf, inverse)
15+
from larray.core.ufuncs import (wrap_elementwise_array_func, maximum, minimum, where,
16+
sin, cos, tan, arcsin, arccos, arctan, hypot, arctan2, degrees,
17+
radians, unwrap, sinh, cosh, tanh, arcsinh, arccosh, arctanh,
18+
angle, real, imag, conj,
19+
round, around, round_, rint, fix, floor, ceil, trunc,
20+
exp, expm1, exp2, log, log10, log2, log1p, logaddexp, logaddexp2,
21+
i0, sinc, signbit, copysign, frexp, ldexp,
22+
convolve, clip, sqrt, absolute, fabs, sign, fmax, fmin, nan_to_num,
23+
real_if_close, interp, isnan, isinf, inverse)
2424

2525
from larray.inout.misc import from_lists, from_string
2626
from larray.inout.pandas import from_frame, from_series

larray/core/array.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
from larray.core.constants import nan
5858
from larray.core.metadata import Metadata
5959
from larray.core.expr import ExprNode
60+
from larray.core.ufuncs import SupportsNumpyUfuncs
6061
from larray.core.group import (Group, IGroup, LGroup, remove_nested_groups, _to_key, _to_keys,
6162
_translate_sheet_name, _translate_group_key_hdf)
6263
from larray.core.axis import Axis, AxisReference, AxisCollection, X, _make_axis
@@ -700,7 +701,7 @@ def _handle_meta(meta, title):
700701
return Metadata(meta)
701702

702703

703-
class LArray(ABCLArray):
704+
class LArray(ABCLArray, SupportsNumpyUfuncs):
704705
r"""
705706
A LArray object represents a multidimensional, homogeneous array of fixed-size items with labeled axes.
706707
@@ -5862,7 +5863,7 @@ def eq(self, other, rtol=0, atol=0, nans_equal=False):
58625863
if not nans_equal:
58635864
return self == other
58645865
else:
5865-
from larray.core.npufuncs import isnan
5866+
from larray.core.ufuncs import isnan
58665867

58675868
def general_isnan(a):
58685869
if np.issubclass_(a.dtype.type, np.inexact):
@@ -6625,7 +6626,7 @@ def clip(self, minval=None, maxval=None, out=None):
66256626
a1 0 1 2
66266627
a2 2 2 2
66276628
"""
6628-
from larray.core.npufuncs import clip
6629+
from larray.core.ufuncs import clip
66296630
return clip(self, minval, maxval, out)
66306631

66316632
@deprecate_kwarg('transpose', 'wide')

larray/core/npufuncs.py

-135
This file was deleted.

0 commit comments

Comments
 (0)