Skip to content

Commit

Permalink
style: improve setting of Quantity defaults (#53)
Browse files Browse the repository at this point in the history
Signed-off-by: nstarman <[email protected]>
  • Loading branch information
nstarman authored Mar 5, 2024
1 parent 634f1b8 commit 854eb39
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/coordinax/_d4/spacetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ class FourVector(Abstract4DVector):

_: KW_ONLY
c: Shaped[Quantity["speed"], ""] = eqx.field(
default_factory=lambda: Quantity(299_792.458, "km/s"),
repr=False,
default=Quantity(299_792.458, "km/s"), repr=False
)
"""Speed of light, by default ``Quantity(299_792.458, "km/s")``."""

Expand Down Expand Up @@ -155,7 +154,7 @@ def constructor(
obj.shape[-1] != 4,
f"Cannot construct {cls} from array with shape {obj.shape}.",
)
c = cls.__dataclass_fields__["c"].default_factory()
c = cls.__dataclass_fields__["c"].default
comps = {"t": obj[..., 0] / c, "q": obj[..., 1:]}
return cls(**comps)

Expand Down

0 comments on commit 854eb39

Please sign in to comment.