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

Support numpy/ndarray #5

Open
matterhorn103 opened this issue Apr 22, 2024 · 2 comments
Open

Support numpy/ndarray #5

matterhorn103 opened this issue Apr 22, 2024 · 2 comments
Labels
dream Would be great one day

Comments

@matterhorn103
Copy link
Owner

matterhorn103 commented Apr 22, 2024

Essentially this means supporting arrays via one of two strategies:

  1. Developing a quantity numpy dtype with the appropriate properties
  2. Developing a custom array, called quanstants.array or quanstants.ndarray or qarray or quarray

In general there will only be support for arrays of quantities of the same unit. An array will consist of numerical values and a single associated unit.

This should make implementation less complicated and more efficient, as the elements of the array are then purely numerical, and the unit arithmetic only has to be done once per operation. Uncertainties will still have to be tracked though.

I personally need to do more research into the way ndarrays and dtypes work before having an idea as to exactly how the implementation should look.

In any case, a custom array type should follow the Python array API standard.

Sadly decimal numbers are not a supported dtype. This would mean either implementing the behaviour ourselves, or converting the numbers to floats when put into an array.

Applications using numpy are less likely to require the exactness of Decimal anyway, so this seems like a reasonable compromise.

pandas dataframes using numpy arrays would suffer. However, the plan (#6) is to support polars, and then that can be recommended preferentially.

@matterhorn103 matterhorn103 added the dream Would be great one day label Apr 22, 2024
@matterhorn103
Copy link
Owner Author

Only numpy>=2.0 will be supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dream Would be great one day
Projects
None yet
Development

No branches or pull requests

1 participant