Skip to content

fix #234 : implemented support for np.__array_ufunc__ #762

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion doc/source/changes/version_0_32.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ New features
Miscellaneous improvements
^^^^^^^^^^^^^^^^^^^^^^^^^^

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


Fixes
Expand Down
18 changes: 9 additions & 9 deletions larray/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
from larray.core.session import Session, local_arrays, global_arrays, arrays
from larray.core.constants import nan, inf, pi, e, euler_gamma
from larray.core.metadata import Metadata
from larray.core.ufuncs import wrap_elementwise_array_func, maximum, minimum, where
from larray.core.npufuncs import (sin, cos, tan, arcsin, arccos, arctan, hypot, arctan2, degrees,
radians, unwrap, sinh, cosh, tanh, arcsinh, arccosh, arctanh,
angle, real, imag, conj,
round, around, round_, rint, fix, floor, ceil, trunc,
exp, expm1, exp2, log, log10, log2, log1p, logaddexp, logaddexp2,
i0, sinc, signbit, copysign, frexp, ldexp,
convolve, clip, sqrt, absolute, fabs, sign, fmax, fmin, nan_to_num,
real_if_close, interp, isnan, isinf, inverse)
from larray.core.ufuncs import (wrap_elementwise_array_func, maximum, minimum, where,
sin, cos, tan, arcsin, arccos, arctan, hypot, arctan2, degrees,
radians, unwrap, sinh, cosh, tanh, arcsinh, arccosh, arctanh,
angle, real, imag, conj,
round, around, round_, rint, fix, floor, ceil, trunc,
exp, expm1, exp2, log, log10, log2, log1p, logaddexp, logaddexp2,
i0, sinc, signbit, copysign, frexp, ldexp,
convolve, clip, sqrt, absolute, fabs, sign, fmax, fmin, nan_to_num,
real_if_close, interp, isnan, isinf, inverse)

from larray.inout.misc import from_lists, from_string
from larray.inout.pandas import from_frame, from_series
Expand Down
7 changes: 4 additions & 3 deletions larray/core/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
from larray.core.constants import nan
from larray.core.metadata import Metadata
from larray.core.expr import ExprNode
from larray.core.ufuncs import SupportsNumpyUfuncs
from larray.core.group import (Group, IGroup, LGroup, remove_nested_groups, _to_key, _to_keys,
_translate_sheet_name, _translate_group_key_hdf)
from larray.core.axis import Axis, AxisReference, AxisCollection, X, _make_axis
Expand Down Expand Up @@ -700,7 +701,7 @@ def _handle_meta(meta, title):
return Metadata(meta)


class LArray(ABCLArray):
class LArray(ABCLArray, SupportsNumpyUfuncs):
r"""
A LArray object represents a multidimensional, homogeneous array of fixed-size items with labeled axes.

Expand Down Expand Up @@ -5862,7 +5863,7 @@ def eq(self, other, rtol=0, atol=0, nans_equal=False):
if not nans_equal:
return self == other
else:
from larray.core.npufuncs import isnan
from larray.core.ufuncs import isnan

def general_isnan(a):
if np.issubclass_(a.dtype.type, np.inexact):
Expand Down Expand Up @@ -6625,7 +6626,7 @@ def clip(self, minval=None, maxval=None, out=None):
a1 0 1 2
a2 2 2 2
"""
from larray.core.npufuncs import clip
from larray.core.ufuncs import clip
return clip(self, minval, maxval, out)

@deprecate_kwarg('transpose', 'wide')
Expand Down
135 changes: 0 additions & 135 deletions larray/core/npufuncs.py

This file was deleted.

Loading