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

numpy: matrix multiplication by left give wrong results #39

Closed
canesin opened this issue Jul 30, 2013 · 10 comments
Closed

numpy: matrix multiplication by left give wrong results #39

canesin opened this issue Jul 30, 2013 · 10 comments
Labels

Comments

@canesin
Copy link

canesin commented Jul 30, 2013

Hi, this is a issue related to #37 , multiplication by left don't work with a numpy matrix, as matrices are not commutative for multiplication. It don't fail, it give wrong results.

https://gist.github.com/canesin/6115159

@hgrecco
Copy link
Owner

hgrecco commented Aug 7, 2013

Thanks again for the report. I am looking for a good solution for this.

@canesin
Copy link
Author

canesin commented Aug 14, 2013

Any news on this ?? I discovered that maybe this affects other operations also, like comparisons.

@hgrecco
Copy link
Owner

hgrecco commented Aug 14, 2013

I have a working solution for #37 and #39 that involves refactoring everything so that Quantity dervies from several numpy classes. Briefly:

class Quantity(np.matrixlib.defmatrix.matrix, np.ma.core.MaskedArray, np.ndarray):
# here goes the class definition.

I find this extremely ugly, but seems to be the only thing that works. The problem is related to the fact that matrix and masked array take preference in spite of the the array priority.

@canesin
Copy link
Author

canesin commented Aug 22, 2013

It has other implications besides being ugly ?? You could push the fix as a temporary and refactor in the future, maybe create a enhancement issue for that.

@akirkby
Copy link

akirkby commented Jul 8, 2014

I'm having the same issue doing numpy matrix operations while using Pint... any news on this fix?

@hgrecco
Copy link
Owner

hgrecco commented Jul 8, 2014

I have just pushed something I was working on to a temporary branch named _npsubclass. I putting this in the wild to get some comments and ideas. The main change is that Quantity now is a subclass from ndarray (which is an alias for object when NumPy is not available). This solves the problem of Quantity not being recognized by as array but introduces other.

I would like to emphasize that this is very preliminary work. We still do not know if this is the right approach or even if it is a good approach. Therefore we cannot promise that I will become part of Pint.

@akirkby
Copy link

akirkby commented Jul 9, 2014

Thanks Hernan, I'll check it out

Sent from my iPhone

On Jul 8, 2014, at 10:50 AM, Hernan Grecco [email protected] wrote:

I have just pushed something I was working on to a temporary branch named _npsubclass. I putting this in the wild to get some comments and ideas. The main change is that Quantity now is a subclass from ndarray (which is an alias for object when NumPy is not available). This solves the problem of Quantity not being recognized by as array but introduces other.

I would like to emphasize that this is very preliminary work. We still do not know if this is the right approach or even if it is a good approach. Therefore we cannot promise that I will become part of Pint.


Reply to this email directly or view it on GitHub.

@hgrecco
Copy link
Owner

hgrecco commented Dec 3, 2019

Review once that #905 is implemented

@jthielen
Copy link
Contributor

Based on https://docs.scipy.org/doc/numpy-1.17.0/reference/generated/numpy.matrix.html, NumPy matrices should no longer be used, instead, regular arrays should be used. So, can this be closed as wontfix due to upstream deprecation?

@hgrecco
Copy link
Owner

hgrecco commented Dec 11, 2019

Agreed!

@hgrecco hgrecco closed this as completed Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants