question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Initializing an EarthLocation now causes a TypeError about casting

See original GitHub issue

Description

After updating numpy and astropy, I get a TypeError when initializing an EarthLocation object.

Expected behavior

This previously worked just fine.

Actual behavior

TypeError raised.

Steps to Reproduce

Python 3.6.9 (default, Sep  7 2019, 20:24:16) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.

In [3]: import astropy.coordinates                                                                                                                                                             

In [4]: import astropy.units as u                                                                                                                                                              

In [5]: astropy.coordinates.EarthLocation.from_geocentric(23.0,55.0,-10.0,unit=u.m)                                                                                                            
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-502c18d74f82> in <module>
----> 1 astropy.coordinates.EarthLocation.from_geocentric(23.0,55.0,-10.0,unit=u.m)

/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/astropy/coordinates/earth.py in from_geocentric(cls, x, y, z, unit)
    251         struc = np.empty(x.shape, cls._location_dtype)
    252         struc['x'], struc['y'], struc['z'] = x, y, z
--> 253         return super().__new__(cls, struc, unit, copy=False)
    254 
    255     @classmethod

/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/astropy/units/quantity.py in __new__(cls, value, unit, dtype, copy, order, subok, ndmin)
    377         if dtype is None and (not np.can_cast(np.float32, value.dtype)
    378                               or value.dtype.kind == 'O'):
--> 379             value = value.astype(float)
    380 
    381         value = value.view(cls)

TypeError: Cannot cast array from dtype([('x', '<f8'), ('y', '<f8'), ('z', '<f8')]) to dtype('float64') according to the rule 'unsafe'

System Details

Versions:

Darwin-15.6.0-x86_64-i386-64bit Python 3.6.9 (default, Sep 7 2019, 20:24:16) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] Numpy 1.17.2 Scipy 1.3.1 astropy 3.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
aarchibacommented, Oct 1, 2019

Works for me on astropy 3.2.1.

1reaction
bsipoczcommented, Nov 22, 2019

@lacfry - As the discussion above concludes the issue is not present on for the later version. However those are not compatible with python2.7.

The latest release on the 2.0.x series is 2.0.16, I suggest try to upgrade to that version as many bug fixes has been backported into those LTS releases. If that still doesn’t work, your best chance option is to downgrade numpy to 1.16.2

Read more comments on GitHub >

github_iconTop Results From Across the Web

EarthLocation — Astropy v5.2
Initialization is first attempted assuming geocentric (x, y, z) coordinates are given; if that fails, another attempt is made assuming geodetic coordinates ( ......
Read more >
Source code for astropy.time.core
A `Time` object is initialized with one or more times in the ``val`` argument. ... EarthLocation` or tuple, optional If given as an...
Read more >
Astropy Documentation - Read the Docs
The FITS File handling (astropy.io.fits) sub-package now provides a ... TypeError: Only dimensionless scalar quantities can be converted.
Read more >
Full Changelog — Astropy v1.2.dev14793
[#3504]; Initializing a Table with Column objects no longer requires that the column ... Pickling of EarthLocation instances now also works on Python...
Read more >
pycobertura report - LIGO Scientific Collaboration
ligo/skymap/coordinates/__init__.py, 8, 0, 100.00% ... FIXME: for now, the Python wrapper expects all of the SNR time series to # also be the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found