Skip to content

Commit

Permalink
fix windows test numerical precision error, now round all to 6 decima…
Browse files Browse the repository at this point in the history
…l places
  • Loading branch information
knaidoo29 committed Nov 27, 2024
1 parent 6e60eb0 commit 04d0133
Showing 1 changed file with 85 additions and 85 deletions.
170 changes: 85 additions & 85 deletions mistree/tests/test_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@

def test_spherical_2_cartesian():
x, y, z = mist.spherical_2_cartesian(1., 0., 0.)
assert x == 0.
assert y == 0.
assert z == 1.
assert round(x, 6) == 0.
assert round(y, 6) == 0.
assert round(z, 6) == 1.
x, y, z = mist.spherical_2_cartesian(1., 90., 90.)
assert round(x, 6) == 0.
assert y == 1.
assert round(y, 6) == 1.
assert round(z, 6) == 0.
x, y, z = mist.spherical_2_cartesian(1., 90., 45.)
assert round(x, 6) == 0.
assert round(y, 6) == round(1./np.sqrt(2.), 6)
assert round(z, 6) == round(1./np.sqrt(2.), 6)
x, y, z = mist.spherical_2_cartesian(1., 0., 0., units='radians')
assert x == 0.
assert y == 0.
assert z == 1.
assert round(x, 6) == 0.
assert round(y, 6) == 0.
assert round(z, 6) == 1.
x, y, z = mist.spherical_2_cartesian(1., np.pi/2., np.pi/2., units='radians')
assert round(x, 6) == 0.
assert y == 1.
assert round(y, 6) == 1.
assert round(z, 6) == 0.
x, y, z = mist.spherical_2_cartesian(1., np.pi/2., np.pi/4., units='radians')
assert round(x, 6) == 0.
Expand All @@ -43,64 +43,64 @@ def test_celestial_2_cartesian():
p = mist.celestial_2_cartesian(1., 0., 0., output='spherical')
assert len(p) == 2
phi, theta, x, y, z = mist.celestial_2_cartesian(1., 0., 90.)
assert phi == 0.
assert theta == 0.
assert x == 0.
assert y == 0.
assert z == 1.
assert round(phi, 6) == 0.
assert round(theta, 6) == 0.
assert round(x, 6) == 0.
assert round(y, 6) == 0.
assert round(z, 6) == 1.
x, y, z = mist.celestial_2_cartesian(1., 0., 90., output='cartesian')
assert x == 0.
assert y == 0.
assert z == 1.
assert round(x, 6) == 0.
assert round(y, 6) == 0.
assert round(z, 6) == 1.
phi, theta, x, y, z = mist.celestial_2_cartesian(1., 0., 0.)
assert phi == 0.
assert round(phi, 6) == 0.
assert round(theta, 6) == round(np.pi/2., 6)
assert x == 1.
assert y == 0.
assert round(x, 6) == 1.
assert round(y, 6) == 0.
assert round(z, 6) == 0.
x, y, z = mist.celestial_2_cartesian(1., 0., 0., output='cartesian')
assert x == 1.
assert y == 0.
assert round(x, 6) == 1.
assert round(y, 6) == 0.
assert round(z, 6) == 0.
phi, theta, x, y, z = mist.celestial_2_cartesian(1., 0., 45.)
assert phi == 0.
assert round(phi, 6) == 0.
assert round(theta, 6) == round(np.pi/4., 6)
assert round(x, 6) == round(np.sqrt(2.)/2., 6)
assert y == 0.
assert round(y, 6) == 0.
assert round(z, 6) == round(np.sqrt(2.)/2., 6)
x, y, z = mist.celestial_2_cartesian(1., 0., 45., output='cartesian')
assert round(x, 6) == round(np.sqrt(2.)/2., 6)
assert y == 0.
assert round(y, 6) == 0.
assert round(z, 6) == round(np.sqrt(2.)/2., 6)
phi, theta, x, y, z = mist.celestial_2_cartesian(1., 0., np.pi/2., units='radians')
assert phi == 0.
assert theta == 0.
assert x == 0.
assert y == 0.
assert z == 1.
assert round(phi, 6) == 0.
assert round(theta, 6) == 0.
assert round(x, 6) == 0.
assert round(y, 6) == 0.
assert round(z, 6) == 1.
x, y, z = mist.celestial_2_cartesian(1., 0., np.pi/2., output='cartesian', units='radians')
assert x == 0.
assert y == 0.
assert z == 1.
assert round(x, 6) == 0.
assert round(y, 6) == 0.
assert round(z, 6) == 1.
phi, theta, x, y, z = mist.celestial_2_cartesian(1., 0., 0., units='radians')
assert phi == 0.
assert round(phi, 6) == 0.
assert round(theta, 6) == round(np.pi/2., 6)
assert x == 1.
assert y == 0.
assert round(x, 6) == 1.
assert round(y, 6) == 0.
assert round(z, 6) == 0.
x, y, z = mist.celestial_2_cartesian(1., 0., 0., output='cartesian', units='radians')
assert x == 1.
assert y == 0.
assert round(x, 6) == 1.
assert round(y, 6) == 0.
assert round(z, 6) == 0.
phi, theta, x, y, z = mist.celestial_2_cartesian(1., 0., np.pi/4., units='radians')
assert phi == 0.
assert round(phi, 6) == 0.
assert round(theta, 6) == round(np.pi/4., 6)
assert round(x, 6) == round(np.sqrt(2.)/2., 6)
assert y == 0.
assert round(y, 6) == 0.
assert round(z, 6) == round(np.sqrt(2.)/2., 6)
x, y, z = mist.celestial_2_cartesian(1., 0., np.pi/4., output='cartesian', units='radians')
assert round(x, 6) == round(np.sqrt(2.)/2., 6)
assert y == 0.
assert round(y, 6) == 0.
assert round(z, 6) == round(np.sqrt(2.)/2., 6)
phi, theta, x, y, z = mist.celestial_2_cartesian(np.random.random_sample(100),
360.*np.random.random_sample(100),
Expand All @@ -114,35 +114,35 @@ def test_celestial_2_cartesian():

def test_spherical_2_unit_sphere():
x, y, z = mist.spherical_2_unit_sphere(0., 0.)
assert x == 0.
assert y == 0.
assert z == 1.
assert round(x, 6) == 0.
assert round(y, 6) == 0.
assert round(z, 6) == 1.
x, y, z = mist.spherical_2_unit_sphere(0., 90.)
assert x == 1.
assert y == 0.
assert round(x, 6) == 1.
assert round(y, 6) == 0.
assert round(z, 6) == 0.
x, y, z = mist.spherical_2_unit_sphere(90., 90.)
assert round(x, 6) == 0.
assert y == 1.
assert round(y, 6) == 1.
assert round(z, 6) == 0.
x, y, z = mist.spherical_2_unit_sphere(45., 45.)
assert round(x, 6) == 0.5
assert round(y, 6) == 0.5
assert round(z, 6) == round(np.sqrt(2.)/2., 6)
x, y, z = mist.spherical_2_unit_sphere(0., 0., units='radians')
assert x == 0.
assert y == 0.
assert z == 1.
assert round(x, 6) == 0.
assert round(y, 6) == 0.
assert round(z, 6) == 1.
x, y, z = mist.spherical_2_unit_sphere(0., np.pi/2., units='radians')
assert x == 1.
assert y == 0.
assert round(x, 6) == 1.
assert round(y, 6) == 0.
assert round(z, 6) == 0.
x, y, z = mist.spherical_2_unit_sphere(np.pi/2., np.pi/2., units='radians')
assert round(x, 6) == 0.
assert y == 1.
assert round(y, 6) == 1.
assert round(z, 6) == 0.
x, y, z = mist.spherical_2_unit_sphere(np.pi/4., np.pi/4., units='radians')
assert x == 0.5
assert round(x, 6) == 0.5
assert round(y, 6) == 0.5
assert round(z, 6) == round(np.sqrt(2.)/2., 6)
x, y, z = mist.spherical_2_unit_sphere(180.*np.random.random_sample(100), 360.*np.random.random_sample(100))
Expand All @@ -156,64 +156,64 @@ def test_celestial_2_unit_sphere():
p = mist.celestial_2_unit_sphere(0., 0., output='cartesian')
assert len(p) == 3
phi, theta, x, y, z = mist.celestial_2_unit_sphere(0., 90.)
assert phi == 0.
assert theta == 0.
assert x == 0.
assert y == 0.
assert z == 1.
assert round(phi, 6) == 0.
assert round(theta, 6) == 0.
assert round(x, 6) == 0.
assert round(y, 6) == 0.
assert round(z, 6) == 1.
x, y, z = mist.celestial_2_unit_sphere(0., 90., output='cartesian')
assert x == 0.
assert y == 0.
assert z == 1.
assert round(x, 6) == 0.
assert round(y, 6) == 0.
assert round(z, 6) == 1.
phi, theta, x, y, z = mist.celestial_2_unit_sphere(0., 0.)
assert phi == 0.
assert round(phi, 6) == 0.
assert round(theta, 6) == round(np.pi/2., 6)
assert x == 1.
assert y == 0.
assert round(x, 6) == 1.
assert round(y, 6) == 0.
assert round(z, 6) == 0.
x, y, z = mist.celestial_2_unit_sphere(0., 0., output='cartesian')
assert x == 1.
assert y == 0.
assert round(x, 6) == 1.
assert round(y, 6) == 0.
assert round(z, 6) == 0.
phi, theta, x, y, z = mist.celestial_2_unit_sphere(0., 45.)
assert phi == 0.
assert round(phi, 6) == 0.
assert round(theta, 6) == round(np.pi/4., 6)
assert round(x, 6) == round(np.sqrt(2.)/2., 6)
assert y == 0.
assert round(y, 6) == 0.
assert round(z, 6) == round(np.sqrt(2.)/2., 6)
x, y, z = mist.celestial_2_unit_sphere(0., 45., output='cartesian')
assert round(x, 6) == round(np.sqrt(2.)/2., 6)
assert y == 0.
assert round(y, 6) == 0.
assert round(z, 6) == round(np.sqrt(2.)/2., 6)
phi, theta, x, y, z = mist.celestial_2_unit_sphere(0., np.pi/2., units='radians')
assert phi == 0.
assert theta == 0.
assert x == 0.
assert y == 0.
assert z == 1.
assert round(phi, 6) == 0.
assert round(theta, 6) == 0.
assert round(x, 6) == 0.
assert round(y, 6) == 0.
assert round(z, 6) == 1.
x, y, z = mist.celestial_2_unit_sphere(0., np.pi/2., output='cartesian', units='radians')
assert x == 0.
assert y == 0.
assert z == 1.
assert round(x, 6) == 0.
assert round(y, 6) == 0.
assert round(z, 6) == 1.
phi, theta, x, y, z = mist.celestial_2_unit_sphere(0., 0., units='radians')
assert phi == 0.
assert round(phi, 6) == 0.
assert round(theta, 6) == round(np.pi/2., 6)
assert x == 1.
assert y == 0.
assert round(x, 6) == 1.
assert round(y, 6) == 0.
assert round(z, 6) == 0.
x, y, z = mist.celestial_2_unit_sphere(0., 0., output='cartesian', units='radians')
assert x == 1.
assert y == 0.
assert round(x, 6) == 1.
assert round(y, 6) == 0.
assert round(z, 6) == 0.
phi, theta, x, y, z = mist.celestial_2_unit_sphere(0., np.pi/4., units='radians')
assert phi == 0.
assert round(phi, 6) == 0.
assert round(theta, 6) == round(np.pi/4., 6)
assert round(x, 6) == round(np.sqrt(2.)/2., 6)
assert y == 0.
assert round(y, 6) == 0.
assert round(z, 6) == round(np.sqrt(2.)/2., 6)
x, y, z = mist.celestial_2_unit_sphere(0., np.pi/4., output='cartesian', units='radians')
assert round(x, 6) == round(np.sqrt(2.)/2., 6)
assert y == 0.
assert round(y, 6) == 0.
assert round(z, 6) == round(np.sqrt(2.)/2., 6)
phi, theta, x, y, z = mist.celestial_2_unit_sphere(360.*np.random.random_sample(100),
180.*np.random.random_sample(100) - 90.)
Expand Down

0 comments on commit 04d0133

Please sign in to comment.