-
Notifications
You must be signed in to change notification settings - Fork 49
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
Segmentation fault with u.Msun
#540
Comments
Can you share the exact version of Python you're using (down to the patch level), your provider (Python.org, conda, something else ?) and the version of numpy you are running with ? unyt itself is pure Python so I highly doubt that the memory access error is on our side. |
FWIW, running your first example on my system produces a |
Note that the key difference betwee |
I'm able to avoid this diff --git a/unyt/_array_functions.py b/unyt/_array_functions.py
index 62aca69..a752fd8 100644
--- a/unyt/_array_functions.py
+++ b/unyt/_array_functions.py
@@ -288,7 +288,8 @@ def _histogramdd(
if density:
for s in sample:
counts /= getattr(s, "units", 1)
- counts *= getattr(weights, "units", 1)
+ if weights is not None and hasattr(weights, "units"):
+ counts *= weights.units
return counts, tuple(_bin * getattr(s, "units", 1) for _bin, s in zip(bins, sample)) (it also seems to work when I pass |
That seems like it should be equivalent, wonder what's triggering the recursion... also wonder if it's a deeper issue that might crop up elsewhere, or if this fix is enough. (Also just to mention - when I first encountered this in a pytest run it came with a partial stack trace before the segfault, that indeed looked like something recursing a lot.) |
multipliying an array by a scalar |
Description
Trying to histogram a unyt array initialized with
unyt_array(arr, units)
in density mode when units areu.Msun
crashes with a segmentation fault... but not when units areu.solMass
, and not when the array is initialized asnp.array(...) * u.Msun
.What I Did
This is rearing its head in the updated handling of the
histogramdd
argumentdensity
but is pretty clearly more fundamental than anything I've directly introduced. Here's as much as I've managed to isolate it so far:That exits with a segmentation fault.
This however exits cleanly:
So does this:
The text was updated successfully, but these errors were encountered: