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.

realize_frame does not accept representation_type

See original GitHub issue

I wanted to create a new frame using data coming from elsewhere, so realize_frame is exactly the method I needed. However, despite the name of its only parameter representation_type, the final representation_type of the result is the one coming from the default of the coordinate frame:

In [9]: ICRS().realize_frame(representation_type=CartesianRepresentation(1, 0, 0, unit='km'))
Out[9]: 
<ICRS Coordinate: (ra, dec, distance) in (deg, deg, km)
    (0., 0., 1.)>

In [10]: _.representation_type
Out[10]: astropy.coordinates.representation.SphericalRepresentation

In fact, BaseCoordinateFrame.realize_frame just calls _replicate, passing representation_type as data, which makes more sense, and _replicate does allow the user to override the default representation_type:

In [14]: ICRS()._replicate(data=CartesianRepresentation(1, 0, 0, unit='km'),
    ...: representation_type="cartesian")
Out[14]: 
<ICRS Coordinate: (x, y, z) in km
    (1., 0., 0.)>

I suggest that

  • BaseCoordinateFrame.realize_frame parameter is renamed to data (which is less confusing),
  • that it sets the representation_type using the class of the data,
  • or alternatively that allows the user to override the representation_type in the proper sense:
In [2]: ICRS().realize_frame(data=CartesianRepresentation(1, 0, 0, unit='km'))
Out[2]: 
<ICRS Coordinate: (x, y, z) in km
    (1., 0., 0.)>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mhvkcommented, Sep 12, 2020

My sense would be to just add **kwargs since that is what the “inverse”, replicate_without_data, does as well.

EDIT: the docstring could then explicitly mention that a possibly useful argument is representation_type

1reaction
eteqcommented, Oct 24, 2018

OK, to summarize a short discussion on slack: I think we agreed to switch to data for #7923 but leave for 3.2 the question of whether to add an additional argument or otherwise update the behavior.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

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