Skip to content

Commit bcd3cec

Browse files
authored
πŸŽ‰ init: coordinax-interop-astropy (#482)
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
1 parent 065eacb commit bcd3cec

68 files changed

Lines changed: 2698 additions & 1261 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

β€Ždocs/contributing.mdβ€Ž

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ When opening an issue to report a problem, please try to provide:
99

1010
## Contributing Code and Documentation
1111

12-
So you are interested in contributing to the `coordinax`? Excellent! We love
13-
contributions! `coordinax` is open source, built on open source, and we'd love
14-
to have you hang out in our community.
12+
So you are interested in contributing to the {mod}`coordinax`? Excellent! We
13+
love contributions! {mod}`coordinax` is open source, built on open source, and
14+
we'd love to have you hang out in our community.
1515

1616
## How to Contribute, Best Practices
1717

18-
Most contributions to `coordinax` are done via
18+
Most contributions to {mod}`coordinax` are done via
1919
[pull requests](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests)
2020
from GitHub users' forks of the
21-
[`coordinax` repository](https://github.com/GalacticDynamics/coordinax). If you
22-
are new to this style of development, check out Astropy's
21+
[{mod}`coordinax` repository](https://github.com/GalacticDynamics/coordinax). If
22+
you are new to this style of development, check out {mod}`astropy`'s
2323
[development workflow](https://docs.astropy.org/en/latest/development/quickstart.html).
2424

2525
Once you open a pull request (which should be opened against the `main` branch,
@@ -38,8 +38,8 @@ following:
3838
description in the main documentation (in `docs/`).
3939

4040
- **Performance improvements**: if you are making changes that impact
41-
`coordinax` performance, consider adding a performance benchmark in `tests`. A
42-
maintainer will also be able to run comparative benchmarks to catch
41+
{mod}`coordinax` performance, consider adding a performance benchmark in
42+
`tests`. A maintainer will also be able to run comparative benchmarks to catch
4343
performance changes. The PR needs to have the `run-benchmarks` label to run
4444
the workflow.
4545

@@ -48,12 +48,12 @@ following:
4848
Before being merged, a pull request for a new feature will be reviewed to see if
4949
it meets the following requirements. If you are unsure about how to meet all of
5050
these requirements, please submit the PR and ask for help and/or guidance. A
51-
`coordinax` maintainer will collaborate with you to make sure that the pull
51+
{mod}`coordinax` maintainer will collaborate with you to make sure that the pull
5252
request meets the requirements for inclusion in the package:
5353

5454
**Relevance:**
5555

56-
- Is the submission relevant to `coordinax`?
56+
- Is the submission relevant to {mod}`coordinax`?
5757
- Does the code perform as expected?
5858
- If applicable, are references included to the origin source for the algorithm?
5959
- Has the code been tested against previously existing implementations?
@@ -63,7 +63,7 @@ request meets the requirements for inclusion in the package:
6363
- Are the coding guidelines followed?
6464
- Is the code compatible with the supported versions of Python?
6565
- Are there dependencies other than the run-time dependencies listed in
66-
pyproject.toml?
66+
`pyproject.toml`?
6767

6868
**Testing:**
6969

β€Ždocs/conventions.mdβ€Ž

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
## Naming Conventions
44

5-
`coordinax` uses a few conventions to make the code more readable and to avoid
6-
verbosity. Many of these are also found in the [Glossary](glossary.md).
5+
{mod}`coordinax` uses a few conventions to make the code more readable and to
6+
avoid verbosity. Many of these are also found in the [Glossary](glossary.md).
77

88
- `Abstract...`: a class that is not meant to be instantiated directly, but
99
rather to be subclassed. Abstract classes are prefixed with 'Abstract'.
@@ -16,10 +16,10 @@ verbosity. Many of these are also found in the [Glossary](glossary.md).
1616

1717
## Functional vs Object-Oriented APIs
1818

19-
As `JAX` is function-oriented, but Python is generally object-oriented,
20-
`coordinax` provides both functional and object-oriented APIs. The functional
21-
APIs are the primary APIs, but the object-oriented APIs are easy to use and call
22-
the functional APIs, so lose none of the power.
19+
As {mod}`JAX` is function-oriented, but Python is generally object-oriented,
20+
{mod}`coordinax` provides both functional and object-oriented APIs. The
21+
functional APIs are the primary APIs, but the object-oriented APIs are easy to
22+
use and call the functional APIs, so lose none of the power.
2323

2424
As an example, consider the following code snippets:
2525

@@ -64,16 +64,22 @@ SphericalPos(
6464

6565
`coordinax` uses [multiple dispatch](https://beartype.github.io/plum/) to hook
6666
into `quax`'s flexible and extensible system to enable custom array-ish objects,
67-
like {class}`~unxt.quantity.Quantity`, in `JAX`. Also, `coordinax` uses multiple
68-
dispatch to enable deep interoperability between `coordinax` and other
69-
libraries, like `astropy` (and anything user-defined).
67+
like {class}`~unxt.quantity.Quantity`, in {mod}`JAX`. Also, {mod}`coordinax`
68+
uses multiple dispatch to enable deep interoperability between {mod}`coordinax`
69+
and other libraries, like {mod}`astropy` (and anything user-defined).
7070

71-
For example, `coordinax` provides a {meth}`~coordinax.vecs.AbstractVector.from_`
72-
method that can convert an `astropy.Representation` to a
71+
For example, if {mod}`coordinax-interop-astropy` is installed, {mod}`coordinax`
72+
registers to {meth}`~coordinax.vecs.AbstractVector.from_` a method that can
73+
convert an `astropy.Representation` to a
7374
{class}`~coordinax.vecs.AbstractVector`:
7475

75-
```{code-block} python
76+
<!-- invisible-code-block: python
77+
import importlib.util
78+
-->
79+
80+
<!-- skip: start if(importlib.util.find_spec('coordinax_interop_astropy') is None, reason="coordinax-interop-astropy not installed") -->
7681

82+
```{code-block} python
7783
>>> import astropy.coordinates as apyc
7884
>>> import coordinax.vecs as cxv
7985
@@ -82,13 +88,15 @@ method that can convert an `astropy.Representation` to a
8288
<CartesianRepresentation (x, y, z) in m
8389
(1., 2., 3.)>
8490
85-
>>> xq = cxv.CartesianPos3D.from_(aq) # unxt Quantity
91+
>>> xq = cxv.CartesianPos3D.from_(aq)
8692
>>> print(xq)
8793
<CartesianPos3D: (x, y, z) [m]
8894
[1. 2. 3.]>
8995
9096
```
9197

98+
<!-- skip: end -->
99+
92100
This easy interoperability is enabled by multiple dispatch, which allows the
93101
{meth}`~coordinax.vecs.AbstractVector.from_` method to dispatch to the correct
94102
implementation based on the types of the arguments.

β€Ždocs/index.mdβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ coordinax-api <packages/coordinax-api/index>
1313
coordinax <self>
1414
coordinax-astro <packages/coordinax-astro/index>
1515
coordinax-hypothesis <packages/coordinax-hypothesis/index>
16+
coordinax-interop-astropy <packages/coordinax-interop-astropy/index>
1617
```
1718

1819
```{toctree}
@@ -41,12 +42,13 @@ interop/*
4142
```{toctree}
4243
:maxdepth: 2
4344
:hidden:
44-
:caption: πŸ”Œ API Reference
45+
:caption: πŸ“˜ API Reference
4546
4647
coordinax-api <packages/coordinax-api/api>
4748
coordinax <api/index.md>
4849
coordinax-astro <packages/coordinax-astro/api>
4950
coordinax-hypothesis <packages/coordinax-hypothesis/api>
51+
coordinax-interop-astropy <packages/coordinax-interop-astropy/api>
5052
```
5153

5254
```{toctree}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../packages/coordinax-interop-astropy/docs

β€Žnoxfile.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def pytest(s: nox.Session, /, package: PackageEnum) -> None:
127127
# Documentation
128128

129129

130-
@session(uv_groups=["docs"], reuse_venv=True)
130+
@session(uv_groups=["docs"], uv_extras=["workspace"], reuse_venv=True)
131131
def docs(s: nox.Session, /) -> None:
132132
"""Build the docs. Pass "--serve" to serve. Pass "-b linkcheck" to check links."""
133133
parser = argparse.ArgumentParser()

β€Žpackages/coordinax-api/docs/index.mdβ€Ž

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,12 @@ The `coordinax-api` package follows these principles:
104104

105105
Use `coordinax-api` when you:
106106

107-
- Want to implement coordinax protocols in your own package
108-
- Need coordinax integration without the full coordinax dependency
109-
- Are building a library that provides vector types compatible with coordinax
107+
- Want to implement {mod}`coordinax` protocols in your own package
108+
- Need {mod}`coordinax` integration without the full {mod}`coordinax` dependency
109+
- Are building a library that provides vector types compatible with
110+
{mod}`coordinax`
110111

111-
Use the full `coordinax` package when you:
112+
Use the full {mod}`coordinax` package when you:
112113

113114
- Need concrete vector implementations (CartesianPos3D, SphericalPos, etc.)
114115
- Want to perform actual coordinate transformations

β€Žpackages/coordinax-astro/src/coordinax_astro/__init__.pyβ€Ž

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,3 @@
99
from .frame_transforms import *
1010
from .galactocentric import Galactocentric
1111
from .icrs import ICRS
12-
13-
# Interoperability. Importing this module will register interop frameworks.
14-
# isort: split
15-
from . import _interop
16-
17-
# clean up namespace
18-
del _interop

β€Žpackages/coordinax-astro/src/coordinax_astro/_interop/__init__.pyβ€Ž

Lines changed: 0 additions & 8 deletions
This file was deleted.

β€Žpackages/coordinax-astro/src/coordinax_astro/_interop/interop_astropy/__init__.pyβ€Ž

Lines changed: 0 additions & 5 deletions
This file was deleted.

β€Žpackages/coordinax-astro/src/coordinax_astro/_interop/interop_astropy/frames.pyβ€Ž

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
Β (0)