Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: monorepo #371

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ jobs:
fetch-depth: 0

- uses: hynek/build-and-inspect-python-package@v2
with:
path: packages/galax
upload-name-suffix: "-galax"

# TODO: also galax-interop-astropy and galax-interop-gala

test-publish:
needs: [dist]
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
with:
python-version: "3.x"
- name: Install package
run: python -m pip install ".[test]"
run: python -m pip install "./packages/galax[test]"
- name: Run smoke test
run: python -m pytest tests/smoke -ra

Expand Down Expand Up @@ -79,6 +79,7 @@ jobs:

- name: Install package
run: python -m pip install '.[test]'
# run: python -m pip install './packages/galax[test]'

- name: Test package
run: >-
Expand Down Expand Up @@ -112,7 +113,10 @@ jobs:
allow-prereleases: true

- name: Install package
run: python -m pip install '.[test,interop-all]'
run:
python -m pip install './packages/galax[test]'
'./packages/galax_interop_astropy' './packages/galax_interop_gala'
# run: python -m pip install '.[test]'

- name: Test package
run: >-
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ dmypy.json
cython_debug/

# setuptools_scm
src/_version.py
src/*/_version.py


Expand Down
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ repos:
hooks:
# Run the linter
- id: ruff
name: ruff-lint
types_or: [python, pyi, jupyter]
args: ["--fix", "--show-fixes"]
# Run the formatter
Expand All @@ -79,7 +80,7 @@ repos:
hooks:
- id: mypy
files: src
exclude: ^(src/galax/__init__\.py|src/galax/.*?/__init__\.py)$
exclude: ^(src/galax_suite/galax/.*?/__init__\.py)$
additional_dependencies:
- pytest

Expand Down
4 changes: 2 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

collect_ignore_glob = []
if not HAS_ASTROPY:
collect_ignore_glob.append("src/galax/_galax_interop_astropy/*")
collect_ignore_glob.append("src/galax_interop_astropy/*")
if not HAS_GALA:
collect_ignore_glob.append("src/galax/_galax_interop_gala/*")
collect_ignore_glob.append("src/galax_interop_gala/*")
19 changes: 19 additions & 0 deletions packages/galax/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright 2023 galax maintainers

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
116 changes: 116 additions & 0 deletions packages/galax/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<h1 align='center'> galax </h1>
<h2 align="center">Galactic and Gravitational Dynamics</h2>

## Installation

[![PyPI platforms][pypi-platforms]][pypi-link]
[![PyPI version][pypi-version]][pypi-link]

<!-- [![Conda-Forge][conda-badge]][conda-link] -->

```bash
pip install galax
```

## Documentation

[![Documentation Status][rtd-badge]][rtd-link]

Coming soon. In the meantime, if you've used `gala`, then `galax` should be
familiar!

## Quick example

Let's compute an orbit!

```python
import coordinax as cx
import galax.coordinates as gc
import galax.dynamics as gd
import galax.potential as gp
import jax.numpy as jnp
from unxt import Quantity

w = gc.PhaseSpacePosition(
q=Quantity([8, 0, 0], "kpc"),
p=Quantity([0, 220, 0], "km/s"),
t=Quantity(0, "Myr"),
)

pot = gp.MilkyWayPotential()

orbit = gd.evaluate_orbit(pot, w, Quantity(jnp.linspace(0, 1, 100), "Gyr"))
print(orbit)
# Orbit(
# q=<CartesianPosition3D (x[kpc], y[kpc], z[kpc])
# [[ 8. 0. 0. ]
# ...
# [ 7.804 -0.106 0. ]]>,
# p=<CartesianVelocity3D (d_x[kpc / Myr], d_y[kpc / Myr], d_z[kpc / Myr])
# [[ 0. 0.225 0. ]
# ...
# [ 0.018 0.23 0. ]]>,
# t=Quantity['time'](Array([0., ..., 1000.], dtype=float64), unit='Myr'),
# potential=MilkyWayPotential(...)
# )

orbit_sph = orbit.represent_as(cx.LonLatSphericalPosition)
print(orbit_sph)
# Orbit(
# q=<LonLatSphericalPosition (lon[rad], lat[deg], distance[kpc])
# [[0.000e+00 3.858e-16 8.000e+00]
# ...
# [6.270e+00 3.858e-16 7.805e+00]]>,
# p=<LonLatSphericalVelocity (d_lon[rad / Myr], d_lat[deg / Myr], d_distance[kpc / Myr])
# [[ 0.028 0. 0. ]
# ...
# [ 0.03 0. 0.015]]>,
# t=Quantity['time'](Array([0., ..., 1000.], dtype=float64), unit='Myr'),
# potential=MilkyWayPotential(...})
# )
```

## Citation

[![DOI][zenodo-badge]][zenodo-link]

If you found this library to be useful in academic work, then please cite.

## Development

[![Actions Status][actions-badge]][actions-link]

We welcome contributions!

### Contributors

See the
[AUTHORS.rst](https://github.com/GalacticDynamics/galax/blob/main/AUTHORS.rst)
file for a complete list of contributors to the project.

The [`GalacticDynamics/galax`](https://github.com/GalacticDynamics/galax)
maintainers would like to thank
[@Michael Anckaert](https://github.com/MichaelAnckaert) for transferring the
`galax` project domain on `PyPI` for use by this package. Without his generosity
this package would have had a worse name.

<!-- SPHINX-START -->

<!-- prettier-ignore-start -->
[actions-badge]: https://github.com/GalacticDynamics/galax/workflows/CI/badge.svg
[actions-link]: https://github.com/GalacticDynamics/galax/actions
[codecov-badge]: https://codecov.io/gh/GalacticDynamics/galax/graph/badge.svg?token=PC553LZFFJ
[codecov-link]: https://codecov.io/gh/GalacticDynamics/galax
[conda-badge]: https://img.shields.io/conda/vn/conda-forge/galax
[conda-link]: https://github.com/conda-forge/galax-feedstock
[github-discussions-badge]: https://img.shields.io/static/v1?label=Discussions&message=Ask&color=blue&logo=github
[github-discussions-link]: https://github.com/GalacticDynamics/galax/discussions
[pypi-link]: https://pypi.org/project/galax/
[pypi-platforms]: https://img.shields.io/pypi/pyversions/galax
[pypi-version]: https://img.shields.io/pypi/v/galax
[rtd-badge]: https://readthedocs.org/projects/galax/badge/?version=latest
[rtd-link]: https://galax.readthedocs.io/en/latest/?badge=latest
[zenodo-badge]: https://zenodo.org/badge/706347349.svg
[zenodo-link]: https://zenodo.org/doi/10.5281/zenodo.11553324

<!-- prettier-ignore-end -->
94 changes: 94 additions & 0 deletions packages/galax/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
[build-system]
build-backend = "hatchling.build"
requires = ["hatchling", "hatch-vcs"]


[project]
authors = [
{ name = "galax maintainers", email = "[email protected]" },
{ name = "Jake Nibauer", email = "[email protected]" },
{ name = "Adrian Price-Whelan", email = "[email protected]" },
{ name = "Nathaniel Starkman", email = "[email protected]" },
]
classifiers = [
"Development Status :: 1 - Planning",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering",
"Typing :: Typed",
]
dependencies = [
"astropy >= 6.0",
"beartype >= 0.18",
"coordinax >= 0.7",
"diffrax >= 0.5",
"equinox >=0.11, != 0.11.3",
"jax >= 0.4, != 0.4.27",
"jaxlib != 0.4.27",
"lazy_loader >= 0.4",
"packaging", # for optional dependencies
"quax >= 0.0.3",
"quaxed >= 0.4",
"typing_extensions >= 4.11",
"unxt",
# Temporary
"plum-dispatch < 2.4.2",
]
description = "Galactic Dynamics in Jax."
dynamic = ["version"]
name = "galax"
readme = "README.md"
license.file = "LICENSE"
requires-python = ">=3.11"

[project.optional-dependencies]
# All runtime dependencies
all = ["galax[interop-all]"]
# Interoperability dependencies
interop-all = ["galax-interop-astropy", "galax-interop-gala"]
test = [
# "hypothesis[numpy]",
"nox",
"pre-commit",
"pytest >=6",
"pytest-cov >=3",
"pytest-arraydiff",
"sybil",
]

[project.urls]
"Bug Tracker" = "https://github.com/GalacticDynamics/galax/issues"
Changelog = "https://github.com/GalacticDynamics/galax/releases"
Discussions = "https://github.com/GalacticDynamics/galax/discussions"
Homepage = "https://github.com/GalacticDynamics/galax"


[tool.hatch]
metadata.allow-direct-references = true
version.source = "vcs"
version.raw-options.root = "../.."

[tool.hatch.envs.default]
dependencies = ["pytest", "pytest-cov"]
features = ["test"]
scripts.test = "pytest {args}"

[tool.hatch.build]
directory = "../../dist"
# hooks.vcs.version-file = "../../src/galax_suite/galax/_version.py"

[tool.hatch.build.targets.sdist]
exclude = ["pyproject.toml"]

[tool.hatch.build.targets.sdist.force-include]
"../../src/galax_suite/galax" = "galax"

[tool.hatch.build.targets.wheel.force-include]
"../../src/galax_suite/galax" = "galax"
19 changes: 19 additions & 0 deletions packages/galax_interop_astropy/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright 2023 galax maintainers

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 4 additions & 0 deletions packages/galax_interop_astropy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<h1 align='center'> galax-interop-astropy </h1>
<h2 align="center">Galactic and Gravitational Dynamics</h2>

Galax interoperability with Astropy.
60 changes: 60 additions & 0 deletions packages/galax_interop_astropy/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[build-system]
build-backend = "hatchling.build"
requires = ["hatchling", "hatch-vcs"]


[project]
authors = [
{ name = "galax maintainers", email = "[email protected]" },
{ name = "Jake Nibauer", email = "[email protected]" },
{ name = "Adrian Price-Whelan", email = "[email protected]" },
{ name = "Nathaniel Starkman", email = "[email protected]" },
]
classifiers = [
"Development Status :: 1 - Planning",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering",
"Typing :: Typed",
]
dependencies = ["galax"]
description = "Galax <-> Astropy."
dynamic = ["version"]
name = "galax"
readme = "README.md"
license.file = "LICENSE"
requires-python = ">=3.11"


[project.urls]
"Bug Tracker" = "https://github.com/GalacticDynamics/galax/issues"
Changelog = "https://github.com/GalacticDynamics/galax/releases"
Discussions = "https://github.com/GalacticDynamics/galax/discussions"
Homepage = "https://github.com/GalacticDynamics/galax"
Source = "https://github.com/GalacticDynamics/galax/tree/main/packages/galax_interop_astropy"


[tool.hatch]
metadata.allow-direct-references = true
version.source = "vcs"
version.raw-options.root = "../.."

[tool.hatch.build]
directory = "../dist"
hooks.vcs.version-file = "../../src/galax_suite/galax_interop_astropy/_version.py"

[tool.hatch.build.targets.sdist]
exclude = ["pyproject.toml"]

[tool.hatch.build.targets.sdist.force-include]
"../../src/galax_suite/galax_interop_astropy" = "galax_interop_astropy"

[tool.hatch.build.targets.wheel.force-include]
"../../src/galax_suite/galax_interop_astropy" = "galax_interop_astropy"
Loading
Loading