Skip to content

Commit c448fff

Browse files
committed
🎉 init: coordinax_astro
Signed-off-by: Nathaniel Starkman <nstarman@users.noreply.github.com>
1 parent c910d2f commit c448fff

File tree

29 files changed

+940
-747
lines changed

29 files changed

+940
-747
lines changed

‎.github/workflows/ci.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ jobs:
6969
run: uv python install ${{ matrix.python-version }}
7070

7171
- name: Install the project
72-
run: uv sync --group test
72+
run: uv sync --all-packages --group test --active
7373

7474
- name: Test package
7575
run: >-
76-
uv run pytest -ra --cov --cov-report=xml --cov-report=term
76+
uv run --frozen pytest --cov --cov-report=xml --cov-report=term
7777
--durations=20 --arraydiff -m"not slow"
7878
7979
- name: Upload coverage report
@@ -108,8 +108,8 @@ jobs:
108108

109109
- name: Test package
110110
run: >-
111-
uv run pytest -ra --cov --cov-report=xml --cov-report=term
112-
--durations=20
111+
uv run --active --frozen pytest --cov --cov-report=xml
112+
--cov-report=term --durations=20
113113
114114
- name: Upload coverage report
115115
uses: codecov/codecov-action@v5.4.3

‎docs/guides/vectors.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ CartesianVel3D(
6868
{class}`~coordinax.vecs.CartesianPosND`
6969
- Similar classes for velocities (`CartesianVel*`), accelerations
7070
(`CartesianAcc*`), etc.
71-
- Spacetime vectors {class}`~coordinax.vecs.FourVector`
71+
- Spacetime vectors {class}`~coordinax_astro.FourVector`
7272

7373
## Conversion Between Representations
7474

‎noxfile.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def docs(session: nox.Session) -> None:
9494
if args.builder != "html" and args.serve:
9595
session.error("Must not specify non-HTML builder with --serve")
9696

97-
session.run("uv", "sync", "--group", "docs", "--active")
97+
session.run("uv", "sync", "--all-packages", "--group", "docs", "--active")
9898
session.chdir("docs")
9999

100100
if args.builder == "linkcheck":

‎packages/coordinax-astro/README.md‎

Whitespace-only changes.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[project]
2+
name = "coordinax_astro"
3+
dynamic = ["version"]
4+
description = "Astronomical coordinates in JAX"
5+
readme = "README.md"
6+
license = "MIT"
7+
requires-python = ">=3.11"
8+
authors = [
9+
{ name = "Coordinax Devs", email = "nstarman@users.noreply.github.com" },
10+
{ name = "Nathaniel Starkman", email = "nstarman@users.noreply.github.com" },
11+
{ name = "Adrian Price-Whelan", email = "adrn@users.noreply.github.com" },
12+
]
13+
classifiers = [
14+
"Development Status :: 3 - Alpha",
15+
"Intended Audience :: Science/Research",
16+
"Intended Audience :: Developers",
17+
"Operating System :: OS Independent",
18+
"Programming Language :: Python",
19+
"Programming Language :: Python :: 3",
20+
"Programming Language :: Python :: 3 :: Only",
21+
"Programming Language :: Python :: 3.11",
22+
"Programming Language :: Python :: 3.12",
23+
"Programming Language :: Python :: 3.13",
24+
"Topic :: Scientific/Engineering",
25+
"Typing :: Typed",
26+
]
27+
dependencies = [
28+
"coordinax",
29+
]
30+
31+
[tool.uv.sources]
32+
coordinax = { workspace = true }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"""Coordinax for Astronomy."""
2+
3+
__all__ = [
4+
"FourVector",
5+
]
6+
7+
from ._src import FourVector
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"""Frames for Astronomy."""
2+
3+
__all__ = [
4+
"FourVector",
5+
]
6+
7+
from .vecs import FourVector
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""Frames for Astronomy."""
2+
3+
__all__ = [
4+
"FourVector",
5+
]
6+
7+
from .spacetime import FourVector
8+
9+
# Register by importing
10+
# isort: split
11+
from . import (
12+
register_convert, # noqa: F401
13+
register_primitives, # noqa: F401
14+
register_vectorapi, # noqa: F401
15+
)

src/coordinax/_src/vectors/d4/register_convert.py renamed to packages/coordinax-astro/src/coordinax_astro/_src/vecs/register_convert.py

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,8 @@
1111
import unxt as u
1212
from unxt.quantity import BareQuantity
1313

14+
import coordinax.vecs as cxv
1415
from .spacetime import FourVector
15-
from coordinax._src.vectors.d3 import (
16-
CartesianPos3D,
17-
CylindricalPos,
18-
LonLatSphericalPos,
19-
MathSphericalPos,
20-
SphericalPos,
21-
)
2216

2317

2418
@conversion_method(type_from=FourVector, type_to=BareQuantity)
@@ -77,8 +71,8 @@ def fourvec_to_quantity(obj: FourVector, /) -> Shaped[u.Quantity["length"], "*ba
7771
return jnp.concat([ct, cart], axis=-1)
7872

7973

80-
@conversion_method(type_from=FourVector, type_to=CartesianPos3D) # type: ignore[arg-type]
81-
def convert_4vec_to_cart3d(obj: FourVector, /) -> CartesianPos3D:
74+
@conversion_method(type_from=FourVector, type_to=cxv.CartesianPos3D) # type: ignore[arg-type]
75+
def convert_4vec_to_cart3d(obj: FourVector, /) -> cxv.CartesianPos3D:
8276
"""Convert a 4-vector to a Cartesian 3-vector.
8377
8478
Examples
@@ -93,11 +87,11 @@ def convert_4vec_to_cart3d(obj: FourVector, /) -> CartesianPos3D:
9387
[1 2 3]>
9488
9589
"""
96-
return convert(obj.q, CartesianPos3D)
90+
return convert(obj.q, cxv.CartesianPos3D)
9791

9892

99-
@conversion_method(type_from=FourVector, type_to=CylindricalPos) # type: ignore[arg-type]
100-
def convert_4vec_to_cylindrical(obj: FourVector, /) -> CylindricalPos:
93+
@conversion_method(type_from=FourVector, type_to=cxv.CylindricalPos) # type: ignore[arg-type]
94+
def convert_4vec_to_cylindrical(obj: FourVector, /) -> cxv.CylindricalPos:
10195
"""Convert a 4-vector to a Cylindrical 3-vector.
10296
10397
Examples
@@ -112,11 +106,11 @@ def convert_4vec_to_cylindrical(obj: FourVector, /) -> CylindricalPos:
112106
[2.236 1.107 3. ]>
113107
114108
"""
115-
return convert(obj.q, CylindricalPos)
109+
return convert(obj.q, cxv.CylindricalPos)
116110

117111

118-
@conversion_method(type_from=FourVector, type_to=SphericalPos) # type: ignore[arg-type]
119-
def convert_4vec_to_spherical(obj: FourVector, /) -> SphericalPos:
112+
@conversion_method(type_from=FourVector, type_to=cxv.SphericalPos) # type: ignore[arg-type]
113+
def convert_4vec_to_spherical(obj: FourVector, /) -> cxv.SphericalPos:
120114
"""Convert a 4-vector to a spherical 3-vector.
121115
122116
Examples
@@ -131,11 +125,11 @@ def convert_4vec_to_spherical(obj: FourVector, /) -> SphericalPos:
131125
[3.742 0.641 1.107]>
132126
133127
"""
134-
return convert(obj.q, SphericalPos)
128+
return convert(obj.q, cxv.SphericalPos)
135129

136130

137-
@conversion_method(type_from=FourVector, type_to=LonLatSphericalPos) # type: ignore[arg-type]
138-
def convert_4vec_to_lonlat_spherical(obj: FourVector, /) -> LonLatSphericalPos:
131+
@conversion_method(type_from=FourVector, type_to=cxv.LonLatSphericalPos) # type: ignore[arg-type]
132+
def convert_4vec_to_lonlat_spherical(obj: FourVector, /) -> cxv.LonLatSphericalPos:
139133
"""Convert a 4-vector to a lon-lat spherical 3-vector.
140134
141135
Examples
@@ -150,11 +144,11 @@ def convert_4vec_to_lonlat_spherical(obj: FourVector, /) -> LonLatSphericalPos:
150144
[ 1.107 53.301 3.742]>
151145
152146
"""
153-
return convert(obj.q, LonLatSphericalPos)
147+
return convert(obj.q, cxv.LonLatSphericalPos)
154148

155149

156-
@conversion_method(type_from=FourVector, type_to=MathSphericalPos) # type: ignore[arg-type]
157-
def convert_4vec_to_mathsph(obj: FourVector, /) -> MathSphericalPos:
150+
@conversion_method(type_from=FourVector, type_to=cxv.MathSphericalPos) # type: ignore[arg-type]
151+
def convert_4vec_to_mathsph(obj: FourVector, /) -> cxv.MathSphericalPos:
158152
"""Convert a 4-vector to a math spherical 3-vector.
159153
160154
Examples
@@ -169,4 +163,4 @@ def convert_4vec_to_mathsph(obj: FourVector, /) -> MathSphericalPos:
169163
[3.742 1.107 0.641]>
170164
171165
"""
172-
return convert(obj.q, MathSphericalPos)
166+
return convert(obj.q, cxv.MathSphericalPos)

src/coordinax/_src/vectors/d4/register_primitives.py renamed to packages/coordinax-astro/src/coordinax_astro/_src/vecs/register_primitives.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import quaxed.numpy as jnp
1212
from dataclassish import replace
1313

14+
import coordinax.vecs as cxv
1415
from .spacetime import FourVector
15-
from coordinax._src.vectors.d3 import AbstractPos3D
1616

1717

1818
@register(jax.lax.add_p)
@@ -32,7 +32,9 @@ def add_p_4vs(self: FourVector, other: FourVector, /) -> FourVector:
3232
[3 5 7 9]>
3333
3434
"""
35-
return replace(self, t=self.t + other.t, q=cast(AbstractPos3D, self.q + other.q))
35+
return replace(
36+
self, t=self.t + other.t, q=cast(cxv.AbstractPos3D, self.q + other.q)
37+
)
3638

3739

3840
@register(jax.lax.broadcast_in_dim_p)
@@ -44,7 +46,7 @@ def broadcast_in_dim_p_4v(
4446
return replace(
4547
obj,
4648
t=jnp.broadcast_to(obj.t, batch),
47-
q=cast(AbstractPos3D, jnp.broadcast_to(obj.q, (*batch, 3))), # type: ignore[arg-type]
49+
q=cast(cxv.AbstractPos3D, jnp.broadcast_to(obj.q, (*batch, 3))), # type: ignore[arg-type]
4850
)
4951

5052

@@ -83,7 +85,7 @@ def neg_p_4v(self: FourVector, /) -> FourVector:
8385
[-1 -1 -2 -3]>
8486
8587
"""
86-
return replace(self, t=-self.t, q=cast(AbstractPos3D, -self.q))
88+
return replace(self, t=-self.t, q=cast(cxv.AbstractPos3D, -self.q))
8789

8890

8991
@register(jax.lax.sub_p)
@@ -103,4 +105,4 @@ def sub_p_4v_4v(lhs: FourVector, rhs: FourVector, /) -> FourVector:
103105
[-1 -3 -3 -3]>
104106
105107
"""
106-
return replace(lhs, t=lhs.t - rhs.t, q=cast(AbstractPos3D, lhs.q - rhs.q))
108+
return replace(lhs, t=lhs.t - rhs.t, q=cast(cxv.AbstractPos3D, lhs.q - rhs.q))

0 commit comments

Comments
 (0)