-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drafted missing tests, created coordinates module
- Loading branch information
Jan Luca van den Busch
committed
Jan 29, 2024
1 parent
1e061e3
commit 153ee12
Showing
8 changed files
with
259 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from __future__ import annotations | ||
|
||
import numpy as np | ||
from numpy.typing import ArrayLike, NDArray | ||
|
||
|
||
def sgn(val: ArrayLike) -> NDArray[np.float64]: | ||
return np.where(val == 0, 1.0, np.sign(val, dtype=np.float64)) | ||
|
||
|
||
def angular_to_cylinder(radec: NDArray) -> NDArray[np.float64]: | ||
radec = np.atleast_2d(radec) | ||
xy = np.empty_like(radec, dtype=np.float64) | ||
xy[:, 0] = radec[:, 0] | ||
xy[:, 1] = np.sin(radec[:, 1]) | ||
return xy | ||
|
||
|
||
def cylinder_to_angular(xy: NDArray) -> NDArray[np.float64]: | ||
radec = np.empty_like(xy, dtype=np.float64) | ||
radec[:, 0] = xy[:, 0] | ||
radec[:, 1] = np.arcsin(xy[:, 1]) | ||
return radec | ||
|
||
|
||
def angular_to_euclidean(radec: NDArray) -> NDArray[np.float64]: | ||
radec = np.atleast_2d(radec) | ||
ra = radec[:, 0] | ||
dec = radec[:, 1] | ||
cos_dec = np.cos(dec) | ||
|
||
xyz = np.empty((len(ra), 3), dtype=np.float64) | ||
xyz[:, 0] = np.cos(ra) * cos_dec | ||
xyz[:, 1] = np.sin(ra) * cos_dec | ||
xyz[:, 2] = np.sin(dec) | ||
return xyz | ||
|
||
|
||
def euclidean_to_angular(xyz: NDArray) -> NDArray[np.float64]: | ||
xyz = np.atleast_2d(xyz) | ||
x = xyz[:, 0] | ||
y = xyz[:, 1] | ||
z = xyz[:, 2] | ||
r_d2 = np.sqrt(x * x + y * y) | ||
r_d3 = np.sqrt(x * x + y * y + z * z) | ||
|
||
radec = np.empty((len(x), 2), dtype=np.float64) | ||
x_normed = np.ones_like(x) # fallback for zero-division, arccos(1)=0.0 | ||
np.divide(x, r_d2, where=r_d2 > 0.0, out=x_normed) | ||
radec[:, 0] = np.arccos(x_normed) * sgn(y) % (2.0 * np.pi) | ||
radec[:, 1] = np.arcsin(x / r_d3) | ||
return radec | ||
|
||
|
||
def angle_to_chorddist(angle: ArrayLike) -> NDArray[np.float64]: | ||
return 2.0 * np.sin(angle / 2.0, dtype=np.float64) | ||
|
||
|
||
def chorddist_to_angle(chord: ArrayLike) -> NDArray[np.float64]: | ||
return 2.0 * np.arcsin(chord / 2.0, dtype=np.float64) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
numpy | ||
numpy>=1.21 | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
numpy | ||
numpy>=1.21 | ||
pytest | ||
black | ||
isort | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import pytest | ||
|
||
# from balltree.angulartree import AngularTree | ||
|
||
|
||
class TestAngularTree: | ||
def test_init(self): | ||
pass | ||
|
||
@pytest.mark.skip | ||
def test_data(self): | ||
pass | ||
|
||
@pytest.mark.skip | ||
def test_num_data(self): | ||
pass | ||
|
||
@pytest.mark.skip | ||
def test_leafsize(self): | ||
pass | ||
|
||
@pytest.mark.skip | ||
def test_sum_weight(self): | ||
pass | ||
|
||
@pytest.mark.skip | ||
def test_center(self): | ||
pass | ||
|
||
@pytest.mark.skip | ||
def test_radius(self): | ||
pass | ||
|
||
@pytest.mark.skip | ||
def test_from_random(self): | ||
pass | ||
|
||
@pytest.mark.skip | ||
def test_from_file(self): | ||
pass | ||
|
||
@pytest.mark.skip | ||
def test_to_file(self): | ||
pass | ||
|
||
@pytest.mark.skip | ||
def test_count_nodes(self): | ||
pass | ||
|
||
@pytest.mark.skip | ||
def test_get_node_data(self): | ||
pass | ||
|
||
@pytest.mark.skip | ||
def test_count_radius(self): | ||
pass | ||
|
||
@pytest.mark.skip | ||
def test_count_range(self): | ||
pass | ||
|
||
@pytest.mark.skip | ||
def test_dualcount_radius(self): | ||
pass | ||
|
||
@pytest.mark.skip | ||
def test_dualcount_range(self): | ||
pass |
Oops, something went wrong.