yt-project / unyt

Handle, manipulate, and convert data with units in Python
https://unyt.readthedocs.io
BSD 3-Clause "New" or "Revised" License
358 stars 46 forks source link

BUG: implement missing support for `np.cbrt` #491

Closed yuyttenhove closed 4 months ago

yuyttenhove commented 4 months ago

Hi,

I noticed that currently np.cbrt is not supported on unyt arrays. (Getting KeyError: <ufunc 'cbrt'> at unyt/array.py:1814, in unyt_array.__array_ufunc__(self, ufunc, method, *inputs, **kwargs))

This very small pull request adds that. I basically copied what was done for np.sqrt.

I extended the relevant unit test in unyt/tests/test_unyt_array.py and I don't think this part of unyt is documented, so I didn't add any documentation.

neutrinoceros commented 4 months ago

Thanks @yuyttenhove, your patch looks perfect !

Before I merge, do you know of any other functions that we're missing as well ? Or did you just happen to try this one and found that it didn't work ?

yuyttenhove commented 4 months ago

I just happened to stumble on this one and didn't notice any other missing functions during my use of unyt, but I didn't look into it extensively.

neutrinoceros commented 4 months ago

Ok no worries. If you ever find anything else, these patches are always welcome. Thanks again !