Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Negative dimension error when using an empty mask #164

Open
adrianapostema opened this issue Jul 13, 2023 · 2 comments
Open

Negative dimension error when using an empty mask #164

adrianapostema opened this issue Jul 13, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@adrianapostema
Copy link

adrianapostema commented Jul 13, 2023

I know that this used to work prior to the current version (don't remember which), but at the moment when I create an empty mask using a non-spatial criteria this error gets thrown:

Traceback (most recent call last):
  File "/group/stsgrp2/adriana/swift-survey-2023/mass1to2/protoearth/protoearth0.91x0.455th30/compare_disk_quantities.py", line 713, in <module>
    datamantle = apply_index(databnd, indmantle)
  File "/group/stsgrp2/adriana/swift-survey-2023/mass1to2/protoearth/protoearth0.91x0.455th30/compare_disk_quantities.py", line 203, in apply_index
    data2.gas.coordinates.convert_to_mks()
  File "/home/apostema/.local/lib/python3.9/site-packages/swiftsimio/reader.py", line 1123, in getter
    read_ranges_from_file(
  File "/home/apostema/.local/lib/python3.9/site-packages/swiftsimio/accelerated.py", line 517, in read_ranges_from_file
    return read_ranges(handle, ranges, output_shape, output_type, columns)
  File "/home/apostema/.local/lib/python3.9/site-packages/swiftsimio/accelerated.py", line 418, in read_ranges_from_file_chunked
    output = np.empty(output_shape, dtype=output_type)
ValueError: negative dimensions are not allowed

When I look at the dimensions that try to get broadcasted I get this: (-94633298979068, 3), which seems to be occurring because I'm applying a mask that doesn't contain any particles (something that happens regularly).
Somehow it looks like something gets passed in as an arbitrarily large value as part of ranges in read_ranges_from_file_chunked in accelerated.py.
Empty masks are something that used to be able to occur without a fatal error happening.

@MatthieuSchaller MatthieuSchaller added the bug Something isn't working label Aug 25, 2023
@MatthieuSchaller
Copy link
Member

Could you provide a small reproducible example?
What version of swiftsimio and unyt is this with?

Looks like there is an overflow happening here.

@JBorrow
Copy link
Member

JBorrow commented Sep 7, 2023

Yes, looks like an overflow in the numba-ized part of the code. This should be tested for (we run the tests with numba's overflow protection on) but please let me know of a minimal example and we can add this to the test suite and fix it.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants