Skip to content
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

fix bad values for high (abs) eta #172

Merged
merged 10 commits into from
Mar 2, 2022
Merged

fix bad values for high (abs) eta #172

merged 10 commits into from
Mar 2, 2022

Conversation

bfis
Copy link
Contributor

@bfis bfis commented Feb 18, 2022

The current eta calculation gives very wrong values for higher (absolute) eta values. This effect is more prominent if the underlying values are float32. The issue lies in the used formula, which adds rho and z, which may be more orders of magnitude apart than the float numbers can represent. The solution is to use a different way (mathematically equivalent) which has greater numerical stability. The same method is used in ROOT.

The behavior introduced in #139 is retained (for the most part). Otherwise, the implementation is closer to ROOT how it handles infinities. It differs from ROOT as follow:

  • for rho=0 (or NaN) it does not introduce (somewhat arbitrary) "maximum" values and yields infinities (or NaN) instead
  • it doesn't perform an sqrt approximation (via Taylor series) for small (abs) eta
  • it retains the sign (of z) for very small eta

Testing should be covered by #36.

Detailed difference between old, new, and ROOT behaviour.

The following tables were produces by this code:

import numpy as np
from vector._compute.spatial.eta import rhophi_z
import ROOT

@np.vectorize
def root_eta(rho, z):
    return ROOT.Math.PxPyPzEVector(np.abs(rho), 0, z, np.nan).Eta()

v = np.array([-np.inf,  -1e20, -1.,  -0.,  np.nan,   0.,   1.,  1e20, np.inf])

# eval via:
rhophi_z(v[:, None], 0, v[None, :])
root_eta(v[:, None], v[None, :])

Axes:
horizontal: z
vertical: rho

old

array([[ 0.000e+000, -0.000e+000, -0.000e+000, -0.000e+000,         nan,  0.000e+000,  0.000e+000,  0.000e+000,  0.000e+000],
       [ 0.000e+000, -8.814e-001, -1.000e-020, -0.000e+000,         nan,  0.000e+000,  1.000e-020,  8.814e-001,  0.000e+000],
       [ 0.000e+000, -1.798e+308, -8.814e-001, -0.000e+000,         nan,  0.000e+000,  8.814e-001,  1.798e+308,  0.000e+000],
       [ 0.000e+000, -1.798e+308, -1.798e+308,  0.000e+000,         nan,  0.000e+000,  1.798e+308,  1.798e+308,  0.000e+000],
       [ 0.000e+000,  0.000e+000,  0.000e+000,  0.000e+000,         nan,  0.000e+000,  0.000e+000,  0.000e+000,  0.000e+000],
       [ 0.000e+000, -1.798e+308, -1.798e+308,  0.000e+000,         nan,  0.000e+000,  1.798e+308,  1.798e+308,  0.000e+000],
       [ 0.000e+000, -1.798e+308, -8.814e-001, -0.000e+000,         nan,  0.000e+000,  8.814e-001,  1.798e+308,  0.000e+000],
       [ 0.000e+000, -8.814e-001, -1.000e-020, -0.000e+000,         nan,  0.000e+000,  1.000e-020,  8.814e-001,  0.000e+000],
       [ 0.000e+000, -0.000e+000, -0.000e+000, -0.000e+000,         nan,  0.000e+000,  0.000e+000,  0.000e+000,  0.000e+000]])

new

array([[        nan, -0.000e+100, -0.000e+000, -0.000e+000,         nan,  0.000e+000,  0.000e+000,  0.000e+000,         nan],
       [       -inf, -8.814e-001, -1.000e-020, -0.000e+000,         nan,  0.000e+000,  1.000e-020,  8.814e-001,         inf],
       [       -inf, -4.674e+001, -8.814e-001, -0.000e+000,         nan,  0.000e+000,  8.814e-001,  4.674e+001,         inf],
       [       -inf,        -inf,        -inf, -0.000e+000,         nan,  0.000e+000,         inf,         inf,         inf],
       [        nan,         nan,         nan, -0.000e+000,         nan,  0.000e+000,         nan,         nan,         nan],
       [       -inf,        -inf,        -inf, -0.000e+000,         nan,  0.000e+000,         inf,         inf,         inf],
       [       -inf, -4.674e+001, -8.814e-001, -0.000e+000,         nan,  0.000e+000,  8.814e-001,  4.674e+001,         inf],
       [       -inf, -8.814e-001, -1.000e-020, -0.000e+000,         nan,  0.000e+000,  1.000e-020,  8.814e-001,         inf],
       [        nan, -0.000e+000, -0.000e+000, -0.000e+000,         nan,  0.000e+000,  0.000e+000,  0.000e+000,         nan]])


ROOT

array([[       nan,  0.000e+00,  0.000e+00,  0.000e+00,        nan,  0.000e+00,  0.000e+00,  0.000e+00,        nan],
       [      -inf, -8.814e-01,  0.000e+00,  0.000e+00,        nan,  0.000e+00,  0.000e+00,  8.814e-01,        inf],
       [      -inf, -4.674e+01, -8.814e-01,  0.000e+00,        nan,  0.000e+00,  8.814e-01,  4.674e+01,        inf],
       [      -inf, -1.000e+20, -2.276e+04,  0.000e+00,        nan,  0.000e+00,  2.276e+04,  1.000e+20,        inf],
       [      -inf, -1.000e+20, -2.276e+04,  0.000e+00,        nan,  0.000e+00,  2.276e+04,  1.000e+20,        inf],
       [      -inf, -1.000e+20, -2.276e+04,  0.000e+00,        nan,  0.000e+00,  2.276e+04,  1.000e+20,        inf],
       [      -inf, -4.674e+01, -8.814e-01,  0.000e+00,        nan,  0.000e+00,  8.814e-01,  4.674e+01,        inf],
       [      -inf, -8.814e-01,  0.000e+00,  0.000e+00,        nan,  0.000e+00,  0.000e+00,  8.814e-01,        inf],
       [       nan,  0.000e+00,  0.000e+00,  0.000e+00,        nan,  0.000e+00,  0.000e+00,  0.000e+00,        nan]])

@jpivarski
Copy link
Member

By the way, I'm looking at this. This would be the first compute function to use lib.where, and that might be a problem in Numba. Reading the formula, it looks like it's not necessary: z is in the numerator of an arcsinh, and all you're doing when you replace the z=0 cases with z is you're replacing 0. Oh, unless the x and y cause a NaN. Let me think about that...

@jpivarski
Copy link
Member

Yeah, there were two errors, and you've fixed the non-Numba one. Removing lib.where fixes Numba. If the lib.where is truly necessary, then there might be a work-around for Numba, though I'm not sure.

@bfis
Copy link
Contributor Author

bfis commented Feb 18, 2022

An alternative implementation would look like this:
np.nan_to_num(np.arcsinh(z / np.abs(p)), posinf=inf, neginf=-inf) * np.absolute(np.sign(z))

And yield the following values:

array([[  0.   ,  -0.   ,  -0.   ,  -0.   ,     nan,   0.   ,   0.   ,   0.   ,   0.   ],
       [   -inf,  -0.881,  -0.   ,  -0.   ,     nan,   0.   ,   0.   ,   0.881,     inf],
       [   -inf, -46.745,  -0.881,  -0.   ,     nan,   0.   ,   0.881,  46.745,     inf],
       [   -inf,    -inf,    -inf,   0.   ,     nan,   0.   ,     inf,     inf,     inf],
       [  0.   ,   0.   ,   0.   ,   0.   ,     nan,   0.   ,   0.   ,   0.   ,   0.   ],
       [   -inf,    -inf,    -inf,   0.   ,     nan,   0.   ,     inf,     inf,     inf],
       [   -inf, -46.745,  -0.881,  -0.   ,     nan,   0.   ,   0.881,  46.745,     inf],
       [   -inf,  -0.881,  -0.   ,  -0.   ,     nan,   0.   ,   0.   ,   0.881,     inf],
       [  0.   ,  -0.   ,  -0.   ,  -0.   ,     nan,   0.   ,   0.   ,   0.   ,   0.   ]])

Notable difference is that is turns NaN from several cases in quite unphysical zeros (when rho and z are infinities, or rho is NaN). It also turns some negative zeros positive, but that's not too imporant.

I wonder why there is an issue with numba and where, the documentation says it would be supported (and given it's a fairly simple operation i'd expect it to be). When manually testing it (with numba 0.53.1) it works just fine, so i suspect that the issue is in the "multi-backend support" of vector.

@numba.njit
def eta(p, z):
    return np.where(z, np.arcsinh(z / p), z)

@jpivarski
Copy link
Member

We can't leave the lib.where in there, even if there's a work-around for Numba. It causes a visible type-change in the plain object backend:

>>> import vector
>>> xyz = vector.obj(x=1.1, y=2.2, z=3.3)
>>> xyz.theta
0.6405223126794245
>>> xyz.eta
array(1.10358684)

versus

>>> import vector
>>> xyz = vector.obj(x=1.1, y=2.2, z=3.3)
>>> xyz.theta
0.6405223126794245
>>> xyz.eta
1.103586841560145

I'm thinking of a way around this with lib.nan_to_num.

@jpivarski
Copy link
Member

Oh, you beat me to it. The issue with Numba is that it's a different type, which is also an issue in the plain-object backend. Numba computes the np.where correctly, but there's an issue downstream with having a zero-dimensional array instead of a scalar.

@jpivarski
Copy link
Member

This is a little disgusting, but what about

>>> for z in (-np.inf, -1.1, 0.0, 1.1, np.inf, np.nan):
...     print(z, np.nan_to_num((z != 0) * np.inf, posinf=np.nan))
... 
-inf nan
-1.1 nan
0.0 0.0
1.1 nan
inf nan
nan nan

@bfis
Copy link
Contributor Author

bfis commented Feb 18, 2022

Entirely without where it yields this:

array([[    nan,  -0.   ,  -0.   ,  -0.   ,     nan,   0.   ,   0.   ,   0.   ,     nan],
       [   -inf,  -0.881,  -0.   ,  -0.   ,     nan,   0.   ,   0.   ,   0.881,     inf],
       [   -inf, -46.745,  -0.881,  -0.   ,     nan,   0.   ,   0.881,  46.745,     inf],
       [   -inf,    -inf,    -inf,     nan,     nan,     nan,     inf,     inf,     inf],
       [    nan,     nan,     nan,     nan,     nan,     nan,     nan,     nan,     nan],
       [   -inf,    -inf,    -inf,     nan,     nan,     nan,     inf,     inf,     inf],
       [   -inf, -46.745,  -0.881,  -0.   ,     nan,   0.   ,   0.881,  46.745,     inf],
       [   -inf,  -0.881,  -0.   ,  -0.   ,     nan,   0.   ,   0.   ,   0.881,     inf],
       [    nan,  -0.   ,  -0.   ,  -0.   ,     nan,   0.   ,   0.   ,   0.   ,     nan]])

The NaNs for rho=NaN are acceptable, but for rho=0=z it's an issue.

@jpivarski
Copy link
Member

So far, this one is looking good (the solution I called "disgusting" a moment ago):

 def xy_z(lib, x, y, z):
-    return lib.where(z, lib.arcsinh(z / lib.sqrt(x**2 + y**2)), z)
+    return lib.nan_to_num(
+        lib.arcsinh(z / lib.sqrt(x**2 + y**2)),
+        nan=lib.nan_to_num((z != 0) * float("inf"), posinf=float("nan")),
+    )

 def rhophi_z(lib, rho, phi, z):
-    return lib.where(z, lib.arcsinh(z / rho), z)
+    return lib.nan_to_num(
+        lib.arcsinh(z / rho),
+        nan=lib.nan_to_num((z != 0) * float("inf"), posinf=float("nan")),
+    )

Looking at all the values with:

>>> import vector
>>> values = [float("-inf"), -1.1, 0.0, 1.1, float("inf"), float("nan")]
>>> for x in values:
...     for y in values:
...         for z in values:
...             xyz = vector.obj(x=x, y=y, z=z)
...             print(f"{x:4} {y:4} {z:4} | {xyz.eta}")

I don't think any of those eta == 0 cases are undesirable. What do you think?

@jpivarski
Copy link
Member

The "disassemble check" is intended to constrain the kinds of functions that are used in compute functions, and if it had run long enough, it would have complained about lib.where. In the most recent run, it complained about lib.arcsinh, but that should definitely be an allowed function. I've fixed that (by including all the hyperbolics).

@bfis
Copy link
Contributor Author

bfis commented Feb 18, 2022

With your proposal it looks like this:

array([[    nan,  -0.   ,  -0.   ,  -0.   ,     nan,   0.   ,   0.   ,   0.   ,     nan],
       [   -inf,  -0.881,  -0.   ,  -0.   ,     nan,   0.   ,   0.   ,   0.881,     inf],
       [   -inf, -46.745,  -0.881,  -0.   ,     nan,   0.   ,   0.881,  46.745,     inf],
       [   -inf,    -inf,    -inf,   0.   ,     nan,   0.   ,     inf,     inf,     inf],
       [    nan,     nan,     nan,   0.   ,     nan,   0.   ,     nan,     nan,     nan],
       [   -inf,    -inf,    -inf,   0.   ,     nan,   0.   ,     inf,     inf,     inf],
       [   -inf, -46.745,  -0.881,  -0.   ,     nan,   0.   ,   0.881,  46.745,     inf],
       [   -inf,  -0.881,  -0.   ,  -0.   ,     nan,   0.   ,   0.   ,   0.881,     inf],
       [    nan,  -0.   ,  -0.   ,  -0.   ,     nan,   0.   ,   0.   ,   0.   ,     nan]])

I thinks this is ok - nobody will miss missing minus for z=-0.

Copy link
Member

@jpivarski jpivarski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're happy with these results (the edge cases match your expectations), then I am, too.

inf and nan were only added to math in Python 3.5, but we're only supporting Python 3.6 and above, so this is totally fine. Better, even, than constructing them from strings (though Python byte-compilation probably optimizes that sort of thing, or at least, it can).

@jpivarski
Copy link
Member

I'm looking at the Awkward error.

@jpivarski
Copy link
Member

The problem is that the argument passed to nan in lib.nan_to_num has to be scalar. Huh.

@bfis
Copy link
Contributor Author

bfis commented Feb 18, 2022

The problem is that the argument passed to nan in lib.nan_to_num has to be scalar. Huh.

This also seem to be the case for the numba "implementation" ...

@jpivarski
Copy link
Member

I was wrong about np.nan_to_num: it can take an array as the nan. Maybe ak.nan_to_num doesn't know that, though.

>>> array = np.array([1, 2, 3, np.nan, np.nan, 10])
>>> np.nan_to_num(array, nan=np.array([999, 999, 999, 123, 321, 999]))
array([  1.,   2.,   3., 123., 321.,  10.])

@jpivarski
Copy link
Member

Fortunately, Numba has implemented nan_to_num now! We can get that by requiring a sufficiently recent version of Numba and then not overriding it with this faulty implementation.

>>> import numpy as np
>>> import numba as nb
>>> nb.__version__
'0.55.1'
>>> def f(array):
...     return np.nan_to_num(array, nan=np.array([999, 999, 999, 123, 321, 999]))
... 
>>> array = np.array([1, 2, 3, np.nan, np.nan, 10])
>>> f(array)
array([  1.,   2.,   3., 123., 321.,  10.])

Then we just need a working ak.nan_to_num to handle the other error. This eta solution is workable.

@jpivarski
Copy link
Member

numba/numba#6857 and numba/numba#5977

I'm seeing if we can do without these workaround-implementations now.

@jpivarski
Copy link
Member

I was wrong—I was seeing Vector's implementation of np.nan_to_num, not Numba's. (Setuptools' entry_points can be confusing.) Numba hasn't defined it yet; we can't switch over.

I'm running out of time. I'll have to come back to this later.

@jpivarski
Copy link
Member

I've fixed the Numba implementation of np.nan_to_num (in Vector, because core Numba still doesn't have it) and the Awkward implementation of ak.nan_to_num to allow the nan, posinf, neginf arguments to be arrays (as long as they're broadcastable). These two fixes solve all the failing tests.

Along the way, I learned that if you don't set posinf and neginf (i.e. leave them as None), they'll be replaced with the largest and smallest finite value. That's a surprise to me, and it means that we should explicitly set them to plus and minus infinity as you've done here. I'll do that in another PR.

Unfortunately, this PR is going to be blocked until I publish a non-release candidate version of Awkward Array on PyPI. That's overdue, anyway, so I should focus on that.

@jpivarski
Copy link
Member

I'll do that in another PR.

#173.

bfis added 3 commits February 23, 2022 18:14
- should not break numba
- should decay 0-rank array to scalar
@jpivarski
Copy link
Member

Why are you reverting this to the lib.where version? That one can't work because of #172 (comment). The latest nan_to_num solution does work with Awkward's main branch, which we've been trying to get into a non-rc release for days now. Most recently: https://github.com/scikit-hep/awkward-1.0/actions/runs/1878761521

Once Awkward 1.8.0 is released, this PR will simply pass tests with the nan_to_num solution. I think that's the one that comes after 12ae4d6.

@jpivarski
Copy link
Member

I don't know what you did, but it has the right type:

>>> import vector
>>> xyz = vector.obj(x=1.1, y=2.2, z=3.3)
>>> xyz.theta
0.6405223126794245
>>> xyz.eta
1.103586841560145

I'm checking more deeply now. (And I can loosen the disassemble-check to allow lib.where if this is the right way to go.)

@jpivarski
Copy link
Member

Multiplying by 1 turns a zero-dimensional array into a scalar. I had no idea!

>>> np.where(0, 1, 1.1)
array(1.1)
>>> np.where(0, 1, 1.1) * 1
1.1
>>> type(np.where(0, 1, 1.1) * 1)
<class 'numpy.float64'>

While that's brilliant, I'm a little uncomfortable with the solution because new backends might not be able to handle it. I've been hoping, for instance, that we'll be able to add SymPy as a backend. lib.nan_to_num is something that we could justifiably make a pass-through (identity function) in SymPy, but what would be the right translation of lib.where? For this case, it would be "take the first argument, ignore the second" because the purpose of this lib.where is to handle exceptional values—we know that the "normal" values are in the first argument, "exceptional" ones are in the second. If we always use lib.where that way, we could make that the appropriate translation...

Do the lib.where and lib.nan_to_num solutions have different extreme values? Is one set or the other more appropriate? If lib.where gives more appropriate extreme values, then that would be the reason for selecting it, and we'll just follow this rule that we only use it for extreme-value cleanup, and that the extreme values are always in the second argument. A disassembler-check can't enforce that; it would be a rule that we'd have to enforce manually.

@henryiii
Copy link
Member

I’d recommend checking against the new NumPy API. It’s a lot more strict, and it is supposed to be implemented by all the other libs eventually. I think it handles scalars very differently.

@bfis
Copy link
Contributor Author

bfis commented Feb 24, 2022

@jpivarski

While that's brilliant, I'm a little uncomfortable with the solution because new backends might not be able to handle it. I've been hoping, for instance, that we'll be able to add SymPy as a backend. lib.nan_to_num is something that we could justifiably make a pass-through (identity function) in SymPy, but what would be the right translation of lib.where? For this case, it would be "take the first argument, ignore the second" because the purpose of this lib.where is to handle exceptional values—we know that the "normal" values are in the first argument, "exceptional" ones are in the second. If we always use lib.where that way, we could make that the appropriate translation...

Sympy has the Piecewise function that can express the where behavior like this: Piecewise((z, z == 0), (np.arcsinh(rho / z), True)). Since this is hardly an exotic concept in math I think making use of it is appropriate.
I would not establish a convention which requires where to be used in a particular way, since this would be fairly error prone.
I also think that just replacing nan_to_num with an identity is fairly error pone too. For example, the solution prior to the where reintroduction (lib.nan_to_num((z != 0) * inf, posinf=nan)) would actually yield infinities instead of zeros for the case that z=rho=0, which is very problematic.

Do the lib.where and lib.nan_to_num solutions have different extreme values? Is one set or the other more appropriate? If lib.where gives more appropriate extreme values, then that would be the reason for selecting it, and we'll just follow this rule that we only use it for extreme-value cleanup, and that the extreme values are always in the second argument. A disassembler-check can't enforce that; it would be a rule that we'd have to enforce manually.

The extreme values do not chaange, merely the values for for z=-0. and rho=0 or rho=nan would receive the correct sign. However, I still think that this is the more appropriate solution than hacking together the (practically) same effect by abusing nan_to_num (mutliple times).

FYI, the value matrix looks like follows (same as the New one in the description) and most closely follows the ROOT values sans their (questionable) quirks:

array([[    nan,  -0.   ,  -0.   ,  -0.   ,     nan,   0.   ,   0.   ,   0.   ,     nan],
       [   -inf,  -0.881,  -0.   ,  -0.   ,     nan,   0.   ,   0.   ,   0.881,     inf],
       [   -inf, -46.745,  -0.881,  -0.   ,     nan,   0.   ,   0.881,  46.745,     inf],
       [   -inf,    -inf,    -inf,  -0.   ,     nan,   0.   ,     inf,     inf,     inf],
       [    nan,     nan,     nan,  -0.   ,     nan,   0.   ,     nan,     nan,     nan],
       [   -inf,    -inf,    -inf,  -0.   ,     nan,   0.   ,     inf,     inf,     inf],
       [   -inf, -46.745,  -0.881,  -0.   ,     nan,   0.   ,   0.881,  46.745,     inf],
       [   -inf,  -0.881,  -0.   ,  -0.   ,     nan,   0.   ,   0.   ,   0.881,     inf],
       [    nan,  -0.   ,  -0.   ,  -0.   ,     nan,   0.   ,   0.   ,   0.   ,     nan]])

@henryiii

I’d recommend checking against the new NumPy API. It’s a lot more strict, and it is supposed to be implemented by all the other libs eventually. I think it handles scalars very differently.

I'm not familiar with what you are talking about. Is there an where/NumPy API variant that does handle scalars vs. rank-0 arrays consistently i.e. without unexpectedly changing from one to the other?

@jpivarski
Copy link
Member

I guess I have to say that I'm more uncomfortable with the solution of multiplying the result of np.where by 1 to turn it from a zero-dimensional array into a scalar. For a library so concerned with portability across different values of "lib", that's relying pretty strongly on what looks like a NumPy quirk. I don't know how to test the new API, either, but this is exactly the sort of thing CuPy likes to break, for instance. (Even if they're in the wrong for doing so...)

It's a little ugly that np.nan_to_num has to be called twice, but it's being used in exactly the way it's intended: to replace extreme values. So I'd much rather go back to commit 12ae4d6, which has eta's 6 implementations looking like this:

def xy_z(lib, x, y, z):
return lib.nan_to_num(
lib.arcsinh(z / lib.sqrt(x**2 + y**2)),
nan=lib.nan_to_num((z != 0) * inf, posinf=nan),
posinf=inf,
neginf=-inf,
)
def xy_theta(lib, x, y, theta):
return lib.nan_to_num(-lib.log(lib.tan(0.5 * theta)), nan=0.0)
def xy_eta(lib, x, y, eta):
return eta
def rhophi_z(lib, rho, phi, z):
return lib.nan_to_num(
lib.arcsinh(z / rho),
nan=lib.nan_to_num((z != 0) * inf, posinf=nan),
posinf=inf,
neginf=-inf,
)
def rhophi_theta(lib, rho, phi, theta):
return -lib.log(lib.tan(0.5 * theta))
def rhophi_eta(lib, rho, phi, eta):
return eta

When the tests run again, they'll pick up Awkward 1.8.0 and it should pass. Then I'll accept the PR.

Thanks!

@henryiii
Copy link
Member

henryiii commented Mar 2, 2022

Scalars were dropped from the new API. See https://numpy.org/neps/nep-0047-array-api-standard.html.

@jpivarski
Copy link
Member

It looks like the Array API is now a fully drafted standard, NumPy's adoption of it (NEP 47) is under consideration, and so are the promotion rules for Python scalars (NEP 50), which is partly inspired by a NumPy users poll and also defined by the Array API. Interesting times!

So NumPy will be dropping the distinction between zero-dimensional arrays and scalars (as CuPy already is; I guess they had some say in the Array API!). This would make the * 1 trick still work but be redundant. Noted. But sticking to fewer functions will make it easier to add new backends, so I'd still like to go with the nan_to_num version.

Thanks, @bfis, for reverting it.

@jpivarski jpivarski merged commit 69d0b1d into scikit-hep:main Mar 2, 2022
@henryiii
Copy link
Member

henryiii commented Mar 2, 2022

The Array API is implemented in experimental form in NumPy 1.22, use import numpy.array_api as xp (or whatever prefix you like using).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants