Repository navigation
optimize representation shortcuts when have differentials - #11467
Conversation
|
Hello @nstarman 👋! It looks like you've made some changes in your pull request, so I've checked the code again for style. There are no PEP8 style issues with this pull request - thanks! 🎉 Comment last updated at 2021-04-11 21:09:48 UTC |
|
Yes, good idea! And of course tricky that the tests actually fail. I fear |
cc84b76 to
7a6db14
Compare
|
#11469 is in, so perhaps good to rebase and check that unitspherical works too? |
1f4cedc to
81ab7ff
Compare
|
@mhvk @adrn . Rebased, but it doesn't appear to fix the problem. The issue is that re-representing unit differentials as full differentials doesn't seem to be resolved in this case. The unit keys in the differentials dict don't match the units on the representation, I think because the representation is given a The first error I'm getting is: full error: error.log Edit: also, any recommendations where the tests should go? there are a couple representation test files. |
|
That error indeed suggests the problem is similar (the As for tests, I think this belongs to basic operations, so |
| if issubclass(other_class, PhysicsSphericalRepresentation): | ||
| return other_class(phi=self.lon, theta=90 * u.deg - self.lat, r=1.0, | ||
| copy=False) | ||
| # diffs = self._re_represent_differentials(other_class, |
There was a problem hiding this comment.
I think part of the reason this fails is that baseframe asks for something impossible - to always transform to SphericalDifferential. Probably best to raise a separate issue...
There was a problem hiding this comment.
So can we merge before this is resolved, and then followup PR to uncomment those lines, or just wait?
There was a problem hiding this comment.
I suspect #11467 (comment) will not be trivial. Perhaps the best route is to not use _re_represent_differentials for this function as it preserves the unit keys.
There was a problem hiding this comment.
Not quite sure how much it really helps, but FWIW, tests seem to pass if I write the if-statement as:
elif (issubclass(other_class, SphericalRepresentation)
and (not differential_class
or all(diff.base_representation is self.__class__
for diff in self.differentials.values()))):
That at least is closer to what we want...
There was a problem hiding this comment.
Interesting 🤔 ... Obviously it's up to you and the maintainers, but my personal preference would be not not complicate the if-blocks, merge in this PR without optimizing the UnitSpherical case, and then tackle the problem after that... But happy any which way 👍 .
There was a problem hiding this comment.
I agree my suggestion is not great either, so I'm OK with simply not addressing UnitSpherical here. But in that case I think we should remove the commented out code - since that does not work right now, I don't think it is helpful. A more detailed comment about why it is tricky (maybe just referring to this discussion) would also be good.
There was a problem hiding this comment.
I just removed the commented out code in representations.py, but left it in test_representations.py as that code can just be uncommented as soon as we find a UnitsSpherical fix.
fe0cfcd to
6dee24f
Compare
|
what happened to codecov? |
6dee24f to
273b52e
Compare
|
#11482 is in, so rebased on master, |
273b52e to
43fb244
Compare
There's still a problem. When FK4 gets initialized, I Here is the step from this PR.
|
|
I think the issue stems from / is strongly related to astropy/astropy/coordinates/baseframe.py Line 556 in 02e54d3 Since for some situations it should be "s/m" |
43fb244 to
e0da930
Compare
|
There's also an unexpected lack of problem for UnitSpherical to PhysicsSpherical. I imagine the same error should be encountered, but no test in baseframe.py covers that scenario. |
|
I need to test the bot and unfortunately the bot hates all my PRs, so I am going to close this and then re-open it after a few seconds to see if the towncrier check kicks off, given you have a fragment file already. Sorry for any inconvenience caused and thank you for your understanding! Update: Something isn't right in the bot... Will follow up on OpenAstronomy/baldrick#111 |
|
Weird, I thought I had checked this and that tests passed. Must have messed up.... |
applied suggested ``. _re_represent_differentials()`` method. tests Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
e0da930 to
f3fda96
Compare
|
|
||
| def test_representation_shortcuts(self): | ||
| """Test that shortcuts in ``represent_as`` don't fail.""" | ||
| # diffs = UnitSphericalCosLatDifferential(4*u.mas/u.yr, 5*u.mas/u.yr, |
There was a problem hiding this comment.
Sorry to be nitpicky, but could you add a comment here too? Nothing worse than commented-out code without a reason!
Fine to add a commit with [ci skip] in the commit message to avoid all the tests running again...
Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
Optimize representation shortcuts when there are attached differentials.
In particular, this helps avoid NaN leakage from the distance to angular components.
Applied suggested
. _re_represent_differentials()method.Split from #11444 (suggested in comment by @mhvk)
TODO:
Signed-off-by: Nathaniel Starkman (@nstarman) [email protected]