Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Add cartesian_to_spherical(). #1365

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MLopez-Ibanez
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Oct 26, 2021

Codecov Report

Merging #1365 (64bc553) into main (01a12df) will increase coverage by 0.30%.
The diff coverage is 100.00%.

❗ Current head 64bc553 differs from pull request most recent head 083ccc1. Consider uploading reports for the commit 083ccc1 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1365      +/-   ##
==========================================
+ Coverage   92.08%   92.38%   +0.30%     
==========================================
  Files          82       82              
  Lines        4346     4283      -63     
  Branches      363      357       -6     
==========================================
- Hits         4002     3957      -45     
+ Misses        255      246       -9     
+ Partials       89       80       -9     
Impacted Files Coverage Δ
src/poliastro/core/util.py 91.48% <100.00%> (-4.07%) ⬇️
src/poliastro/twobody/orbit.py 85.04% <0.00%> (-2.89%) ⬇️
src/poliastro/core/angles.py 95.55% <0.00%> (-0.05%) ⬇️
src/poliastro/core/propagation/__init__.py 96.00% <0.00%> (-0.02%) ⬇️
src/poliastro/twobody/propagation.py 91.75% <0.00%> (ø)
src/poliastro/core/thrust/__init__.py 100.00% <0.00%> (ø)
src/poliastro/core/thrust/change_argp.py 100.00% <0.00%> (ø)
src/poliastro/core/thrust/change_ecc_inc.py 100.00% <0.00%> (ø)
src/poliastro/twobody/thrust/change_argp.py 100.00% <0.00%> (ø)
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 01a12df...083ccc1. Read the comment docs.

@MLopez-Ibanez
Copy link
Contributor Author

@astrojuanlu Something seems wrong with the checks. Not sure why they fail.

Comment on lines +49 to +96
sph_car(np.array([0.5, np.pi / 4, -np.pi / 4]), np.array([0.25, -0.25, 0.35355339]))

sph_car(
np.array([0.5, -np.pi / 4, np.pi / 4]), np.array([-0.25, -0.25, 0.35355339])
)

result = spherical_to_cartesian(np.array([0.5, -np.pi / 4, np.pi / 4]))
expected = np.array([-0.25, -0.25, 0.35355339])
assert np.allclose(expected, result)
sph_car(
np.array([[0.5, np.pi / 4, -np.pi / 4], [0.5, -np.pi / 4, np.pi / 4]]),
np.array([[0.25, -0.25, 0.35355339], [-0.25, -0.25, 0.35355339]]),
)

result = spherical_to_cartesian(
np.array([[0.5, np.pi / 4, -np.pi / 4], [0.5, -np.pi / 4, np.pi / 4]])
sph_car(
np.array([2.60564963, 1.75305207, 4.4458828]),
np.array([-0.674864797187, -2.472029259161, -0.472269863940]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we use pytest.mark.parametrize for these, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no experience with pytest so I cannot give an opinion. But these particular values were chosen because they trigger corner cases due to the use of arctan2 and arccos. There are probably nicer ways to test the corner cases but I didn't have much time to think about them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, if there was a way to sample the full range of values in terms of positive/negative directions, that would be even better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right! I'll have a look at this and try a version with Hypothesis + pytest then

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants