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

Use .value to avoid error calling nan_to_num on quantity #50

Merged
merged 4 commits into from Aug 17, 2014

Conversation

keflavich
Copy link
Contributor

Using a cube with BUNIT = 'K', I ran into the following traceback:

  File "/Users/adam/repos/pvextractor/pvextractor/pvextractor.py", line 97, in extract_pv_slice
    order=order, respect_nan=respect_nan)
  File "/Users/adam/repos/pvextractor/pvextractor/geometry/slices.py", line 42, in extract_slice
    slice = extract_line_slice(cube, x, y, order=order)
  File "/Users/adam/repos/pvextractor/pvextractor/geometry/line_slices.py", line 59, in extract_line_slice
    total_slice = map_coordinates(np.nan_to_num(cube), [zi,yi,xi], order=order, cval=np.nan)
  File "/Users/adam/anaconda/envs/astropy27/lib/python2.7/site-packages/numpy/lib/type_check.py", line 379, in nan_to_num
    y[are_inf] = maxf
  File "/Users/adam/repos/astropy/astropy/units/quantity.py", line 807, in __setitem__
    self.view(np.ndarray).__setitem__(i, self._to_own_unit(value))
  File "/Users/adam/repos/astropy/astropy/units/quantity.py", line 1023, in _to_own_unit
    raise exc
UnitsError: '' (dimensionless) and 'K' (temperature) are not convertible

pvextractor works on ndarrays; it has no reason to concern itself with flux units.

@astrofrog
Copy link
Member

Looks good! Can you add a regression test?

@keflavich
Copy link
Contributor Author

We actually never had tests using SpectralCube objects, so those are needed.

@keflavich
Copy link
Contributor Author

@astrofrog - check it out, class-level parameterization.

@keflavich
Copy link
Contributor Author

These test failures probably result from my having a more recent SpectralCube version that parses units appropriately. Oops.

@keflavich
Copy link
Contributor Author

@astrofrog - I think this is ready to merge; go ahead if you agree

@astrofrog
Copy link
Member

Looks good, thanks!

astrofrog added a commit that referenced this pull request Aug 17, 2014
Use .value to avoid error calling nan_to_num on quantity
@astrofrog astrofrog merged commit dd97fda into radio-astro-tools:master Aug 17, 2014
@keflavich keflavich deleted the use_value branch November 22, 2021 14:19
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

Successfully merging this pull request may close these issues.

None yet

2 participants