Skip to content

Commit

Permalink
Restore slow warning for _apply_everywhere and _cube_on_cube_operation
Browse files Browse the repository at this point in the history
  • Loading branch information
e-koch committed Oct 18, 2024
1 parent ff4282f commit d14947b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 6 additions & 4 deletions spectral_cube/tests/test_spectral_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ def test_arithmetic_warning(data_vda_jybeam_lower, recwarn, use_dask):

assert not cube._is_huge

if not use_dask:
# make sure the small cube raises a warning about loading into memory
with pytest.warns(UserWarning, match='requires loading the entire'):
cube + 5*cube.unit
# make sure the small cube raises a warning about loading into memory
with pytest.warns(UserWarning, match='requires loading the entire'):
cube + 5*cube.unit

with pytest.warns(UserWarning, match='requires loading the entire'):
cube + cube


def test_huge_disallowed(data_vda_jybeam_lower, use_dask):
Expand Down
9 changes: 7 additions & 2 deletions spectral_cube/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ def wrapper(self, *args, **kwargs):
accepts_how_keyword = 'how' in argspec.args or argspec.varkw == 'how'

warn_how = accepts_how_keyword and ((kwargs.get('how') == 'cube') or 'how' not in kwargs)


# This restores showing the "loading the entire cube into memory" warning for
# _apply_everywhere and _cube_on_cube_operation
if function.__name__ in ['_apply_everywhere', '_cube_on_cube_operation']:
warn_how = True

if self._is_huge and not self.allow_huge_operations:
warn_message = ("This function ({0}) requires loading the entire "
"cube into memory, and the cube is large ({1} "
Expand All @@ -50,7 +55,7 @@ def wrapper(self, *args, **kwargs):
warn_message += ("Alternatively, you may want to consider using an "
"approach that does not load the whole cube into "
"memory by specifying how='slice' or how='ray'. ")

warn_message += ("See {bigdataurl} for details.".format(bigdataurl=bigdataurl))

raise ValueError(warn_message)
Expand Down

0 comments on commit d14947b

Please sign in to comment.