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

Array Write Protected Error #101

Open
jranalli opened this issue Dec 17, 2024 · 2 comments
Open

Array Write Protected Error #101

jranalli opened this issue Dec 17, 2024 · 2 comments

Comments

@jranalli
Copy link
Collaborator

jranalli commented Dec 17, 2024

Ok, I warn up front that this one is probably going to be very hard to track down.

pyromat version = bleeding edge
np version = 2.1.0
python version = 3.12.3

Steps to reproduce:

from pyromat.igtools import IgtMix
air = IgtMix('0.01289563 Ar + 0.00047711 CO2 + 0.75520558 N2 + 0.23142168 O2')
air.p(p=1, T=300)

Result:
ValueError: output array is read-only

For what it's worth, it's being caused by the array of p being marked as read only, and you're trying to edit its value in place with np.multiply(). If you at an intermediate point within igtmix.p() re-assign the value with p = p.copy() it resolves the issue, but that doesn't seem ideal. I'm not up on the specifics of numpy data typing sufficiently to be able to trace this much further. If I have a chance to test in a different virtual environment with different numpy version, etc. I will do so.

@jranalli
Copy link
Collaborator Author

jranalli commented Dec 17, 2024

Edit, I'm also able to achieve it on the d function call with the same setup as before and:

air.d(p=1, d=1.1)

@jranalli
Copy link
Collaborator Author

jranalli commented Dec 18, 2024

Ok I did a little messing around on a different computer, previous version of this message was in error because I had been using the wrong branch of the pyromat code.

in python 3.10.4
numpy versions 1.26.4 - code sample above fails
numpy version 2.1.0 - code sample above fails
numpy version 2.2.0 - code sample above fails

in python 3.12.8
numpy version 2.2.0 - code sample above fails

I'm not totally clear on whether this is something that's caused by pyromat or the underlying numpy compiled code. Searching for the error suggests that it has to do with when an array occupies a non-contiguous area in the memory. So it's possible that in one step along the way, the inplace calls are resulting in something affecting the memory.

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

No branches or pull requests

1 participant