You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Differential frame attributes can't be serialized to YAML #6447
This was first reported in #6446, although #6446 is actually two related issues - this one and a slightly different one (which I am declaring #6446 to actually be about).
This issue is that differential objects can't get written out to ECSV. To see this in operation:
This raises a RepresenterError: cannot represent an object: ( 11.1, 232.24, 7.25) km / s
(if the galcen_v_sun=None business isn't obvious, it's that it sets that attribute to the default value:)
>>> sc1 = SkyCoord([1], [2], unit='deg')
>>> sc1.galcen_v_sun
>>> sc2 = SkyCoord([1], [2], unit='deg', galcen_v_sun=None)
>>> sc2.galcen_v_sun
<CartesianDifferential (d_x, d_y, d_z) in km / s
( 11.1, 232.24, 7.25)>
So the core problem seems to be that CartesianDifferential isn't something that ECSV can handle. @taldcroft, is this because these features were being implemented in parallel and therefore it's an oversight? CartesianDifferential is very similar to CartesianRepresentation, so I'd think it would be pretty straightforward to include?
It is not specific to differentials - obsgeoloc can also not be reproduced - the problem is that the list of "safe" objects to represent as yaml got incomplete (in io.misc.yaml). Since dumping for most astropy classes is done via info, it might be easiest if representations acquired their own info class. @taldcroft - would you think this is indeed best?
The Info framework has infrastructure for constructing and representing that makes this implementation pretty simple. I could probably do this for 3.0 but not in the next month. @mhvk also knows quite well how all this works.
changed the title [-]Differential frame attributes can't be written in ECSV tables[/-][+]Differential frame attributes can't be serialized to YAML[/+]on Aug 16, 2017
Yes, it shows we both thought about ecsv quite a bit recently -- and yes, since we suggest to use representation objects for general vectors, I think it makes sense that they would be able to be used as mixin columns.
I just had a quick look at coordinates representation.py and it should be reasonably straightforward to support YAML serialization of these in the existing framework. But not being familiar with this code there might be gotchas.
It came up in the planning telecon today, so just to be clear: this issue still exists in master. When I go back and look in the traceback, the thing that it says it doesn't know how to represent is indeed the <CartesianDifferential (d_x, d_y, d_z) in km / s ( 11.1, 232.24, 7.25)>, so it does indeed seem that there needs to be Info for the differential objects.
Activity
mhvk commentedon Aug 16, 2017
It is not specific to differentials -
obsgeoloccan also not be reproduced - the problem is that the list of "safe" objects to represent asyamlgot incomplete (inio.misc.yaml). Since dumping for most astropy classes is done viainfo, it might be easiest if representations acquired their own info class. @taldcroft - would you think this is indeed best?taldcroft commentedon Aug 16, 2017
@eteq - the underlying problem is not in ECSV but in the YAML coverage for this new kind of astropy core object. See:
https://github.com/astropy/astropy/blob/master/astropy/io/misc/yaml.py
If one implements
_cartesian_differential_representerand_cartesian_differential_constructorfunctions then YAML and ECSV should just work. One might look atEarthLocationandEarthLocationInfofor inspiration, i.e. https://github.com/astropy/astropy/blob/8516dad/astropy/coordinates/earth.py#L87The
Infoframework has infrastructure for constructing and representing that makes this implementation pretty simple. I could probably do this for 3.0 but not in the next month. @mhvk also knows quite well how all this works.[-]Differential frame attributes can't be written in ECSV tables[/-][+]Differential frame attributes can't be serialized to YAML[/+]taldcroft commentedon Aug 16, 2017
I changed the issue title to represent the root problem.
taldcroft commentedon Aug 16, 2017
@mhvk - I see you wrote a comment while I was writing mine..
taldcroft commentedon Aug 16, 2017
@mhvk - yes, I independently suggested adding
Infoclasses. Would it make sense forRepresentationobjects to be Table mixin columns?mhvk commentedon Aug 16, 2017
Yes, it shows we both thought about ecsv quite a bit recently -- and yes, since we suggest to use representation objects for general vectors, I think it makes sense that they would be able to be used as mixin columns.
taldcroft commentedon Dec 8, 2017
I just had a quick look at coordinates
representation.pyand it should be reasonably straightforward to support YAML serialization of these in the existing framework. But not being familiar with this code there might be gotchas.eteq commentedon Dec 8, 2017
It came up in the planning telecon today, so just to be clear: this issue still exists in master. When I go back and look in the traceback, the thing that it says it doesn't know how to represent is indeed the
<CartesianDifferential (d_x, d_y, d_z) in km / s ( 11.1, 232.24, 7.25)>, so it does indeed seem that there needs to beInfofor the differential objects.cc @taldcroft @mhvk
mhvk commentedon Apr 27, 2020
This will be fixed by #10210