Skip to content

Commit

Permalink
build: rename to xmmutablemap (#12)
Browse files Browse the repository at this point in the history
* build: rename to xmmutablemap
* docs: setup
* build: add testpypi

Signed-off-by: nstarman <[email protected]>
  • Loading branch information
nstarman authored Aug 7, 2024
1 parent af3da5b commit 5dfc5fc
Show file tree
Hide file tree
Showing 17 changed files with 89 additions and 209 deletions.
4 changes: 2 additions & 2 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ email: [email protected]
full_name: Galactic Dynamics Maintainers
license: MIT
org: GalacticDynamics
project_name: immutable_map_jax
project_name: xmmutablemap
project_short_description: Immutable Map, compatible with JAX & Equinox
url: https://github.com/GalacticDynamics/immutable_map_jax
url: https://github.com/GalacticDynamics/xmmutablemap
vcs: true
17 changes: 1 addition & 16 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ specific jobs:
```console
$ nox -s lint # Lint only
$ nox -s tests # Python tests
$ nox -s docs -- --serve # Build and serve the docs
$ nox -s build # Make an SDist and wheel
```

Expand Down Expand Up @@ -71,21 +70,7 @@ pytest
Use pytest-cov to generate coverage reports:

```bash
pytest --cov=immutable_map_jax
```

# Building docs

You can build the docs using:

```bash
nox -s docs
```

You can see a preview with:

```bash
nox -s docs -- --serve
pytest --cov=xmmutablemap
```

# Pre-commit
Expand Down
26 changes: 21 additions & 5 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ jobs:

- uses: hynek/build-and-inspect-python-package@v2

publish:
test-publish:
needs: [dist]
name: Publish to PyPI
environment: pypi
name: Publish to TestPyPI
environment:
name: testpypi
permissions:
id-token: write
runs-on: ubuntu-latest
Expand All @@ -49,6 +50,21 @@ jobs:
- uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'release' && github.event.action == 'published'
with:
# Remember to tell (test-)pypi about this repo before publishing
# Remove this line to publish to PyPI
repository-url: https://test.pypi.org/legacy/

publish:
needs: [test-publish]
name: Publish to PyPI
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/download-artifact@v4
with:
name: Packages
path: dist

- uses: pypa/gh-action-pypi-publish@release/v1
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ instance/
# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/
Expand Down
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,3 @@ repos:
hooks:
- id: check-dependabot
- id: check-github-workflows
- id: check-readthedocs
18 changes: 0 additions & 18 deletions .readthedocs.yaml

This file was deleted.

68 changes: 50 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,59 @@
# immutable_map_jax
<h1 align='center'> xmmutablemap </h1>
<h2 align="center"><cod>Jax</code>-compatible Immutable Map</h2>

[![Actions Status][actions-badge]][actions-link]
[![Documentation Status][rtd-badge]][rtd-link]
JAX prefers immutable objects but neither Python nor JAX provide an immutable
dictionary. 😢 </br> This repository defines a light-weight immutable map
(lower-level than a dict) that JAX understands as a PyTree. 🎉 🕶️

## Installation

[![PyPI version][pypi-version]][pypi-link]
[![Conda-Forge][conda-badge]][conda-link]
[![PyPI platforms][pypi-platforms]][pypi-link]
[![PyPI version][pypi-version]][pypi-link]

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

```bash
pip install xmmutablemap
```

## Documentation

[![GitHub Discussion][github-discussions-badge]][github-discussions-link]
<!-- [![Documentation Status][rtd-badge]][rtd-link] -->

`xmutablemap` provides the class `ImmutableMap`, which is a full implementation
of
[Python's `Mapping` ABC](https://docs.python.org/3/library/collections.abc.html#collections-abstract-base-classes).
If you've used a `dict` then you already know how to use `ImmutableMap`! The
things `ImmutableMap` adds is 1) immutability (and related benefits like
hashability) and 2) compatibility with `JAX`.

```python
from xmmutablemap import ImmutableMap

print(ImmutableMap(a=1, b=2, c=3))
# ImmutableMap({'a': 1, 'b': 2, 'c': 3})

print(ImmutableMap({"a": 1, "b": 2.0, "c": "3"}))
# ImmutableMap({'a': 1, 'b': 2.0, 'c': '3'})
```

## Development

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

<!-- SPHINX-START -->
We welcome contributions!

<!-- prettier-ignore-start -->
[actions-badge]: https://github.com/GalacticDynamics/immutable_map_jax/workflows/CI/badge.svg
[actions-link]: https://github.com/GalacticDynamics/immutable_map_jax/actions
[conda-badge]: https://img.shields.io/conda/vn/conda-forge/immutable_map_jax
[conda-link]: https://github.com/conda-forge/immutable_map_jax-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/immutable_map_jax/discussions
[pypi-link]: https://pypi.org/project/immutable_map_jax/
[pypi-platforms]: https://img.shields.io/pypi/pyversions/immutable_map_jax
[pypi-version]: https://img.shields.io/pypi/v/immutable_map_jax
[rtd-badge]: https://readthedocs.org/projects/immutable_map_jax/badge/?version=latest
[rtd-link]: https://immutable_map_jax.readthedocs.io/en/latest/?badge=latest
[actions-badge]: https://github.com/GalacticDynamics/xmmutablemap/workflows/CI/badge.svg
[actions-link]: https://github.com/GalacticDynamics/xmmutablemap/actions
[conda-badge]: https://img.shields.io/conda/vn/conda-forge/xmmutablemap
[conda-link]: https://github.com/conda-forge/xmmutablemap-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/xmmutablemap/discussions -->
[pypi-link]: https://pypi.org/project/xmmutablemap/
[pypi-platforms]: https://img.shields.io/pypi/pyversions/xmmutablemap
[pypi-version]: https://img.shields.io/pypi/v/xmmutablemap
[zenodo-badge]: https://zenodo.org/badge/755708966.svg
[zenodo-link]: https://zenodo.org/doi/10.5281/zenodo.10850557

<!-- prettier-ignore-end -->
45 changes: 0 additions & 45 deletions docs/conf.py

This file was deleted.

17 changes: 0 additions & 17 deletions docs/index.md

This file was deleted.

64 changes: 1 addition & 63 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import argparse
import shutil
from pathlib import Path

Expand Down Expand Up @@ -32,7 +31,7 @@ def pylint(session: nox.Session) -> None:
# This needs to be installed into the package environment, and is slower
# than a pre-commit check
session.install(".", "pylint")
session.run("pylint", "immutable_map_jax", *session.posargs)
session.run("pylint", "xmmutablemap", *session.posargs)


@nox.session
Expand All @@ -44,67 +43,6 @@ def tests(session: nox.Session) -> None:
session.run("pytest", *session.posargs)


@nox.session(reuse_venv=True)
def docs(session: nox.Session) -> None:
"""
Build the docs. Pass "--serve" to serve. Pass "-b linkcheck" to check links.
"""

parser = argparse.ArgumentParser()
parser.add_argument("--serve", action="store_true", help="Serve after building")
parser.add_argument(
"-b", dest="builder", default="html", help="Build target (default: html)"
)
args, posargs = parser.parse_known_args(session.posargs)

if args.builder != "html" and args.serve:
session.error("Must not specify non-HTML builder with --serve")

extra_installs = ["sphinx-autobuild"] if args.serve else []

session.install("-e.[docs]", *extra_installs)
session.chdir("docs")

if args.builder == "linkcheck":
session.run(
"sphinx-build", "-b", "linkcheck", ".", "_build/linkcheck", *posargs
)
return

shared_args = (
"-n", # nitpicky mode
"-T", # full tracebacks
f"-b={args.builder}",
".",
f"_build/{args.builder}",
*posargs,
)

if args.serve:
session.run("sphinx-autobuild", *shared_args)
else:
session.run("sphinx-build", "--keep-going", *shared_args)


@nox.session
def build_api_docs(session: nox.Session) -> None:
"""
Build (regenerate) API docs.
"""

session.install("sphinx")
session.chdir("docs")
session.run(
"sphinx-apidoc",
"-o",
"api/",
"--module-first",
"--no-toc",
"--force",
"../src/immutable_map_jax",
)


@nox.session
def build(session: nox.Session) -> None:
"""
Expand Down
23 changes: 8 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"


[project]
name = "immutable_map_jax"
name = "xmmutablemap"
authors = [
{ name = "Galactic Dynamics Maintainers", email = "[email protected]" },
]
Expand Down Expand Up @@ -44,24 +44,17 @@ dev = [
"pytest >=6",
"pytest-cov >=3",
]
docs = [
"sphinx>=7.0",
"myst_parser>=0.13",
"sphinx_copybutton",
"sphinx_autodoc_typehints",
"furo>=2023.08.17",
]

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


[tool.hatch]
version.source = "vcs"
build.hooks.vcs.version-file = "src/immutable_map_jax/_version.py"
build.hooks.vcs.version-file = "src/xmmutablemap/_version.py"

[tool.hatch.envs.default]
features = ["test"]
Expand All @@ -82,7 +75,7 @@ testpaths = [


[tool.coverage]
run.source = ["immutable_map_jax"]
run.source = ["xmmutablemap"]
report.exclude_also = [
'\.\.\.',
'if typing.TYPE_CHECKING:',
Expand All @@ -99,7 +92,7 @@ disallow_untyped_defs = false
disallow_incomplete_defs = false

[[tool.mypy.overrides]]
module = "immutable_map_jax.*"
module = "xmmutablemap.*"
disallow_untyped_defs = true
disallow_incomplete_defs = true

Expand Down
Loading

0 comments on commit 5dfc5fc

Please sign in to comment.