Skip to content

Commit

Permalink
chore: finalize classes (#113)
Browse files Browse the repository at this point in the history
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
  • Loading branch information
nstarman committed Jan 30, 2024
1 parent 795fcf7 commit f692ac8
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/galax/dynamics/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


class AbstractPhaseSpacePosition(eqx.Module, strict=True): # type: ignore[call-arg, misc]
"""Abstract Base Class of Phase-Space Positions.
"""Abstract base class of Phase-Space Positions.
Todo:
----
Expand Down
2 changes: 2 additions & 0 deletions src/galax/dynamics/_orbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
__all__ = ["Orbit"]

from functools import partial
from typing import final

import equinox as eqx
import jax
Expand All @@ -16,6 +17,7 @@
from ._base import AbstractPhaseSpacePosition


@final
class Orbit(AbstractPhaseSpacePosition):
"""Represents an orbit.
Expand Down
3 changes: 2 additions & 1 deletion src/galax/dynamics/mockstream/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from dataclasses import replace
from functools import partial
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, final

import equinox as eqx
import jax
Expand All @@ -22,6 +22,7 @@
from galax.potential._potential.base import AbstractPotentialBase


@final
class MockStream(AbstractPhaseSpacePosition):
"""Mock stream object.
Expand Down
2 changes: 1 addition & 1 deletion src/galax/dynamics/mockstream/_df/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


class AbstractStreamDF(eqx.Module, strict=True): # type: ignore[call-arg, misc]
"""Abstract Base Class of Stream Distribution Functions."""
"""Abstract base class of Stream Distribution Functions."""

lead: bool = eqx.field(default=True, static=True)
trail: bool = eqx.field(default=True, static=True)
Expand Down
3 changes: 2 additions & 1 deletion src/galax/dynamics/mockstream/_df/fardal.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""galax: Galactic Dynamix in Jax."""


__all__ = ["FardalStreamDF"]


from functools import partial
from typing import final

import jax
import jax.experimental.array_api as xp
Expand All @@ -23,6 +23,7 @@
from .base import AbstractStreamDF


@final
class FardalStreamDF(AbstractStreamDF):
"""Fardal Stream Distribution Function.
Expand Down
3 changes: 2 additions & 1 deletion src/galax/dynamics/mockstream/_mockstream_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from dataclasses import KW_ONLY
from functools import partial
from typing import TypeAlias
from typing import TypeAlias, final

import equinox as eqx
import jax
Expand Down Expand Up @@ -35,6 +35,7 @@ def _interleave_concat(
)


@final
class MockStreamGenerator(eqx.Module): # type: ignore[misc]
"""Generate a mock stellar stream in the specified external potential."""

Expand Down
3 changes: 2 additions & 1 deletion src/galax/integrate/_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from collections.abc import Mapping
from dataclasses import KW_ONLY
from typing import Any
from typing import Any, final

import equinox as eqx
import jax.experimental.array_api as xp
Expand All @@ -25,6 +25,7 @@
from ._base import FCallable


@final
class DiffraxIntegrator(AbstractIntegrator):
"""Thin wrapper around ``diffrax.diffeqsolve``."""

Expand Down
3 changes: 2 additions & 1 deletion src/galax/potential/_potential/param/attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

from dataclasses import dataclass, field
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, NoReturn
from typing import TYPE_CHECKING, Any, NoReturn, final

from .field import ParameterField

if TYPE_CHECKING:
from galax.potential._potential.base import AbstractPotentialBase


@final
@dataclass(frozen=True, slots=True)
class ParametersAttribute:
"""Mapping of the :class:`~galax.potential.ParameterField` values.
Expand Down
6 changes: 4 additions & 2 deletions src/galax/potential/_potential/param/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import abc
from dataclasses import KW_ONLY, replace
from functools import partial
from typing import TYPE_CHECKING, Any, Protocol, runtime_checkable
from typing import TYPE_CHECKING, Any, Protocol, final, runtime_checkable

import astropy.units as u
import equinox as eqx
Expand All @@ -27,7 +27,7 @@


class AbstractParameter(eqx.Module, strict=True): # type: ignore[call-arg, misc]
"""Abstract Base Class for Parameters on a Potential.
"""Abstract base class for Parameters on a Potential.
Parameters are time-dependent quantities that are used to define a
Potential. They can be constant (see `ConstantParameter`), or they can be
Expand Down Expand Up @@ -61,6 +61,7 @@ def __call__(self, t: FloatOrIntScalarLike, **kwargs: Any) -> FloatArrayAnyShape
...


@final
class ConstantParameter(AbstractParameter):
"""Time-independent potential parameter."""

Expand Down Expand Up @@ -134,6 +135,7 @@ def __call__(self, t: FloatScalar, **kwargs: Any) -> FloatArrayAnyShape:
...


@final
class UserParameter(AbstractParameter):
"""User-defined Parameter.
Expand Down
2 changes: 2 additions & 0 deletions src/galax/potential/_potential/param/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Annotated,
Any,
cast,
final,
get_args,
get_origin,
get_type_hints,
Expand All @@ -27,6 +28,7 @@
from galax.potential._potential.base import AbstractPotentialBase


@final
@dataclass(frozen=True, slots=True)
class ParameterField:
"""Descriptor for a Potential Parameter.
Expand Down
3 changes: 2 additions & 1 deletion src/galax/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
]

from collections.abc import Iterator
from typing import ClassVar, Union
from typing import ClassVar, Union, final

import astropy.units as u
from astropy.units.physical import _physical_unit_mapping
Expand Down Expand Up @@ -162,6 +162,7 @@ def as_preferred(self, quantity: u.Quantity) -> u.Quantity:
return quantity.to(self.preferred(quantity.unit.physical_type))


@final
class DimensionlessUnitSystem(UnitSystem):
"""A unit system with only dimensionless units."""

Expand Down

0 comments on commit f692ac8

Please sign in to comment.