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
Improve coordinate conversion speed #328
Conversation
Varunvaruns9
commented
Aug 21, 2019
- Combine core and velocity coordinates into one.
- Make base conversion classes which operate only on the values without astropy.
Hello @Varunvaruns9! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2019-09-05 19:40:54 UTC |
Codecov Report
@@ Coverage Diff @@
## master #328 +/- ##
==========================================
- Coverage 94.42% 94.08% -0.35%
==========================================
Files 41 43 +2
Lines 1560 1673 +113
==========================================
+ Hits 1473 1574 +101
- Misses 87 99 +12
Continue to review full report at Codecov.
|
Woah! That's a huge PR! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. I will still make some changes, break up methods to use them with numba!
@@ -0,0 +1,7 @@ | |||
frame module | |||
=============== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmmmm, less number of '='s
docs/source/user_guide.rst
Outdated
145.45557 * u.km/u.s, 251.93643748389 * u.km/u.s, 0 * u.km/u.s) | ||
|
||
bl_coord = pos_vel_coord.bl_differential(a) | ||
bl_coord = pos_vel_coord.to_bl(a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:/ .to(BoyerLindquist)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are all API breaking changes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ritzvik Yes they are, should I change it to to(classname)
or use the old methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ritzvik Yes they are, should I change it to
to(classname)
or use the old methods?
to(classname)
seems a good solution. You can add it but we do need to preserve the old methods also, atleast before 0.3.0
:/
.to(BoyerLindquist)
.to(BoyerLinduist, a)
because a
is definitely required to change other systems into BL. Maybe we can make the .to
function like this?
to(coordinate_class, *args)
or to(coordinate_class, **kwargs)
@Varunvaruns9 this is really a great PR. Wait a little bit, I will be reviewing and may be I can point out where the changes can be made, so that it does not break any APIs |
@ritzvik @shreyasbapat Merged the changes. |
@Varunvaruns9 Well, you can now implement the Also, tests are taking just one and a half minutes now as opposed to 10 mins earlier :) |
I will start working on that after 29th, maybe we can merge this first and I'll make another PR for the new changes. |
That's okay! There's currently 25 commits in this PR, can you scale them down a bit, maybe 4-5 commits? |
I messed up the mathematics somewhere. Atleast that's what I feel |
|
||
|
||
def cartesian_to_spherical_fast( | ||
x, y, z, v_x=None, v_y=None, v_z=None, velocities_provided=False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this function is calling cartesian_to_spherical()
& cartesian_to_spherical_novel()
, shouldn't this function be defined below the other two. I know it doesn't matter in python but anyways, it's a commonly accepted practice in programming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is when we deal with compiled languages. ;D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a commonly accepted practice in programming
It's good to follow certain conventions, although!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will fix it. Don't worry
""" | ||
r = np.sqrt(x ** 2 + y ** 2 + z ** 2) | ||
theta = np.arccos(z / r) | ||
phi = np.arctan2(y, x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could have done r, theta, phi = cartesian_to_spherical_novel(x, y, z)
. Otherwise, there is code duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure which versions of numba people might have.
src/einsteinpy/coordinates/utils.py
Outdated
): | ||
if velocities_provided: | ||
return cartesian_to_bl(x, y, z, a, v_x, v_y, v_z) | ||
return cartesian_to_spherical_novel(x, y, z, a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Silly mistake! cartesian_to_bl_novel(x, y, z, a)
@shreyasbapat I think you should revert the last two commits made by you as we have only 3 coordinate systems as of now, and adding computational graph would just complicate the code base. Let's aim it for |
@shreyasbapat Can we merge the first two commits? Then I can start working on adding new features to plotly plotter. |
@ritzvik last two commits are not computational graph stuff :) |
@Varunvaruns9 I guess yes. It's possible. Revert the commits |
Or rather, give me 15 mins |
@shreyasbapat Any progress? |
Yeah, some minor patches |
@shreyasbapat Fixed it. Theta and phi were switched 🤣 |
Oh man! I was too frustrated! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Methods lack docstrings, but let's tackle that in another PR.
Manually Merged with 9ccf6d6 |