-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: nstarman <[email protected]>
- Loading branch information
Showing
4 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""Compatibility. | ||
TODO: make all the `gala` compat be in a linked package. | ||
""" | ||
|
||
__all__: list[str] = [] | ||
|
||
try: # TODO: less hacky way of supporting optional dependencies | ||
import pytest | ||
except ImportError: | ||
pass | ||
else: | ||
_ = pytest.importorskip("gala") | ||
|
||
import gala.dynamics as gd | ||
from plum import conversion_method | ||
|
||
import galax.coordinates as gcx | ||
|
||
|
||
@conversion_method(type_from=gd.PhaseSpacePosition, type_to=gcx.PhaseSpacePosition) # type: ignore[misc] | ||
def gala_psp_to_galax_psp(obj: gd.PhaseSpacePosition, /) -> gcx.PhaseSpacePosition: | ||
"""`gala.dynamics.PhaseSpacePosition` -> `galax.coordinates.PhaseSpacePosition`.""" | ||
return gcx.PhaseSpacePosition(q=obj.pos, p=obj.vel, t=None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Compatibility. | ||
TODO: make all the `gala` compat be in a linked package. | ||
""" | ||
|
||
__all__: list[str] = [] | ||
|
||
try: # TODO: less hacky way of supporting optional dependencies | ||
import pytest | ||
except ImportError: | ||
pass | ||
else: | ||
_ = pytest.importorskip("gala") | ||
|
||
import gala.dynamics as gd | ||
from plum import conversion_method | ||
|
||
import galax.dynamics as gdx | ||
|
||
|
||
@conversion_method(type_from=gd.Orbit, type_to=gdx.Orbit) # type: ignore[misc] | ||
def gala_orbit_to_galax_orbit(obj: gd.Orbit, /) -> gdx.Orbit: | ||
"""`gala.dynamics.Orbit` -> `galax.dynamics.Orbit`.""" | ||
return gdx.Orbit(q=obj.pos, p=obj.vel, t=obj.t) | ||
|
||
|
||
@conversion_method(type_from=gd.MockStream, type_to=gdx.MockStream) # type: ignore[misc] | ||
def gala_mockstream_to_galax_mockstream(obj: gd.MockStream, /) -> gdx.MockStream: | ||
"""`gala.dynamics.MockStream` -> `galax.dynamics.MockStream`.""" | ||
return gdx.MockStream(q=obj.pos, p=obj.vel, release_time=obj.release_time) |