From f0df5221e1a03166e2c0c0bc3e35f1de4e500243 Mon Sep 17 00:00:00 2001 From: Spencer Nelson Date: Tue, 10 Oct 2023 17:30:41 -0700 Subject: [PATCH] Reformat to 110 line length --- adam_core/__init__.py | 3 + adam_core/coordinates/cartesian.py | 27 ++----- adam_core/coordinates/cometary.py | 16 ++--- adam_core/coordinates/covariances.py | 22 ++---- adam_core/coordinates/keplerian.py | 17 ++--- adam_core/coordinates/origin.py | 9 +-- adam_core/coordinates/residuals.py | 9 +-- adam_core/coordinates/spherical.py | 25 ++----- adam_core/coordinates/tests/conftest.py | 32 +++------ .../coordinates/tests/test_benchmarks.py | 10 +-- adam_core/coordinates/tests/test_cartesian.py | 4 +- adam_core/coordinates/tests/test_origin.py | 20 ++---- adam_core/coordinates/tests/test_residuals.py | 40 ++--------- .../tests/test_transforms_cometary.py | 24 ++----- .../tests/test_transforms_keplerian.py | 16 ++--- .../tests/test_transforms_rotation.py | 28 ++------ .../tests/test_transforms_spice.py | 8 +-- .../tests/test_transforms_translation.py | 58 ++++----------- adam_core/coordinates/times.py | 1 - adam_core/coordinates/transform.py | 71 +++++-------------- adam_core/coordinates/variants.py | 29 ++------ adam_core/dynamics/aberrations.py | 20 ++---- adam_core/dynamics/barker.py | 3 +- adam_core/dynamics/chi.py | 9 +-- adam_core/dynamics/ephemeris.py | 9 +-- adam_core/dynamics/kepler.py | 13 +--- adam_core/dynamics/propagation.py | 8 +-- adam_core/dynamics/stumpff.py | 4 +- adam_core/dynamics/tests/conftest.py | 12 +--- adam_core/dynamics/tests/test_ephemeris.py | 12 ++-- adam_core/dynamics/tests/test_kepler.py | 32 +++------ adam_core/dynamics/tests/test_propagation.py | 26 ++----- adam_core/observations/associations.py | 1 - adam_core/observations/detections.py | 4 +- adam_core/observations/exposures.py | 4 +- .../observations/tests/test_detections.py | 8 +-- .../observations/tests/test_exposures.py | 43 +++-------- adam_core/observers/observers.py | 4 +- adam_core/observers/state.py | 16 ++--- adam_core/observers/tests/test_benchmarks.py | 4 +- adam_core/observers/tests/test_state.py | 5 +- .../observers/tests/testdata/get_states.py | 4 +- adam_core/orbits/ephemeris.py | 1 - adam_core/orbits/orbits.py | 1 - adam_core/orbits/query/horizons.py | 12 +--- adam_core/orbits/query/sbdb.py | 28 ++------ adam_core/orbits/query/tests/__init__.py | 4 +- adam_core/orbits/query/tests/test_sbdb.py | 8 +-- adam_core/orbits/tests/test_orbits.py | 4 +- adam_core/orbits/tests/test_variants.py | 1 - adam_core/orbits/variants.py | 9 +-- adam_core/propagator/propagator.py | 31 ++------ adam_core/propagator/pyoorb.py | 30 ++------ adam_core/propagator/utils.py | 4 +- adam_core/time/tests/test_time.py | 8 +-- adam_core/time/time.py | 48 ++++--------- adam_core/utils/helpers/data/get_test_data.py | 33 ++------- adam_core/utils/helpers/observations.py | 24 +++---- adam_core/utils/mpc.py | 20 ++---- adam_core/utils/spice.py | 4 +- adam_core/utils/tests/test_benchmarks.py | 4 +- pyproject.toml | 9 +-- 62 files changed, 240 insertions(+), 753 deletions(-) diff --git a/adam_core/__init__.py b/adam_core/__init__.py index baf60887..6225cf0c 100644 --- a/adam_core/__init__.py +++ b/adam_core/__init__.py @@ -1,2 +1,5 @@ from .__version__ import __version__ +__all__ = [ + "__version__", +] diff --git a/adam_core/coordinates/cartesian.py b/adam_core/coordinates/cartesian.py index 42d48780..edd2bc14 100644 --- a/adam_core/coordinates/cartesian.py +++ b/adam_core/coordinates/cartesian.py @@ -30,7 +30,6 @@ class CartesianCoordinates(qv.Table): - x = qv.Float64Column(nullable=True) y = qv.Float64Column(nullable=True) z = qv.Float64Column(nullable=True) @@ -158,9 +157,7 @@ def sigma_v_mag(self) -> np.ndarray: """ return np.sqrt(np.sum(self.covariance.sigmas[:, 3:6] ** 2, axis=1)) - def rotate( - self, rotation_matrix: np.ndarray, frame_out: str - ) -> "CartesianCoordinates": + def rotate(self, rotation_matrix: np.ndarray, frame_out: str) -> "CartesianCoordinates": """ Rotate Cartesian coordinates and their covariances by the given rotation matrix. @@ -188,24 +185,16 @@ def rotate( coords_rotated = np.ma.dot(masked_coords, rotation_matrix.T, strict=False) # Extract covariances - masked_covariances = np.ma.masked_array( - self.covariance.to_matrix(), fill_value=0.0 - ) + masked_covariances = np.ma.masked_array(self.covariance.to_matrix(), fill_value=0.0) masked_covariances.mask = np.isnan(masked_covariances.data) # Rotate covariances - covariances_rotated = ( - rotation_matrix @ masked_covariances.filled() @ rotation_matrix.T - ) + covariances_rotated = rotation_matrix @ masked_covariances.filled() @ rotation_matrix.T # Reset the mask to the original mask covariances_rotated[masked_covariances.mask] = np.NaN # Check if any covariance elements are near zero, if so set them to zero - near_zero = len( - covariances_rotated[ - np.abs(covariances_rotated) < COVARIANCE_ROTATION_TOLERANCE - ] - ) + near_zero = len(covariances_rotated[np.abs(covariances_rotated) < COVARIANCE_ROTATION_TOLERANCE]) if near_zero > 0: logger.debug( f"{near_zero} covariance elements are within {COVARIANCE_ROTATION_TOLERANCE:.0e}" @@ -292,9 +281,7 @@ def to_keplerian(self) -> "KeplerianCoordinates": return KeplerianCoordinates.from_cartesian(self) @classmethod - def from_keplerian( - cls, keplerian: "KeplerianCoordinates" - ) -> "CartesianCoordinates": + def from_keplerian(cls, keplerian: "KeplerianCoordinates") -> "CartesianCoordinates": return keplerian.to_cartesian() def to_spherical(self) -> "SphericalCoordinates": @@ -303,7 +290,5 @@ def to_spherical(self) -> "SphericalCoordinates": return SphericalCoordinates.from_cartesian(self) @classmethod - def from_spherical( - cls, spherical: "SphericalCoordinates" - ) -> "CartesianCoordinates": + def from_spherical(cls, spherical: "SphericalCoordinates") -> "CartesianCoordinates": return spherical.to_cartesian() diff --git a/adam_core/coordinates/cometary.py b/adam_core/coordinates/cometary.py index 44f606ca..0089822d 100644 --- a/adam_core/coordinates/cometary.py +++ b/adam_core/coordinates/cometary.py @@ -224,9 +224,7 @@ def to_cartesian(self) -> CartesianCoordinates: tol=1e-15, ) else: - covariances_cartesian = np.empty( - (len(coords_cartesian), 6, 6), dtype=np.float64 - ) + covariances_cartesian = np.empty((len(coords_cartesian), 6, 6), dtype=np.float64) covariances_cartesian.fill(np.nan) covariances_cartesian = CoordinateCovariances.from_matrix(covariances_cartesian) @@ -279,9 +277,7 @@ def from_cartesian(cls, cartesian: CartesianCoordinates) -> "CometaryCoordinates mu=mu, ) else: - covariances_cometary = np.empty( - (len(coords_cometary), 6, 6), dtype=np.float64 - ) + covariances_cometary = np.empty((len(coords_cometary), 6, 6), dtype=np.float64) covariances_cometary.fill(np.nan) covariances_cometary = CoordinateCovariances.from_matrix(covariances_cometary) @@ -306,9 +302,7 @@ def to_keplerian(self) -> "KeplerianCoordinates": return KeplerianCoordinates.from_cartesian(self.to_cartesian()) @classmethod - def from_keplerian( - cls, keplerian_coordinates: "KeplerianCoordinates" - ) -> "CometaryCoordinates": + def from_keplerian(cls, keplerian_coordinates: "KeplerianCoordinates") -> "CometaryCoordinates": return cls.from_cartesian(keplerian_coordinates.to_cartesian()) def to_spherical(self) -> "SphericalCoordinates": @@ -317,7 +311,5 @@ def to_spherical(self) -> "SphericalCoordinates": return SphericalCoordinates.from_cartesian(self.to_cartesian()) @classmethod - def from_spherical( - cls, spherical_coordinates: "SphericalCoordinates" - ) -> "CometaryCoordinates": + def from_spherical(cls, spherical_coordinates: "SphericalCoordinates") -> "CometaryCoordinates": return cls.from_cartesian(spherical_coordinates.to_cartesian()) diff --git a/adam_core/coordinates/covariances.py b/adam_core/coordinates/covariances.py index e2a91e25..b44459e1 100644 --- a/adam_core/coordinates/covariances.py +++ b/adam_core/coordinates/covariances.py @@ -123,9 +123,7 @@ def from_matrix(cls, covariances: np.ndarray) -> "CoordinateCovariances": """ # cov = pa.FixedShapeTensorArray.from_numpy_ndarray(covariances) if covariances.shape[1:] != (6, 6): - raise ValueError( - f"Covariance matrices should have shape (N, 6, 6) but got {covariances.shape}" - ) + raise ValueError(f"Covariance matrices should have shape (N, 6, 6) but got {covariances.shape}") cov = covariances.flatten() offsets = np.arange(0, (len(covariances) + 1) * 36, 36, dtype=np.int64) return cls.from_kwargs(values=pa.ListArray.from_arrays(offsets, cov)) @@ -323,9 +321,7 @@ def weighted_mean(samples: np.ndarray, W: np.ndarray) -> np.ndarray: return np.dot(W, samples) -def weighted_covariance( - mean: np.ndarray, samples: np.ndarray, W_cov: np.ndarray -) -> np.ndarray: +def weighted_covariance(mean: np.ndarray, samples: np.ndarray, W_cov: np.ndarray) -> np.ndarray: """ Calculate a covariance matrix from samples and their corresponding weights. @@ -581,10 +577,7 @@ def covariances_from_df( covariances[:, i, j] = df[f"cov_{coord_names[i]}_{coord_names[j]}"].values covariances[:, j, i] = covariances[:, i, j] except KeyError: - logger.debug( - "No covariance column found for dimensions" - f" {coord_names[i]},{coord_names[j]}." - ) + logger.debug("No covariance column found for dimensions" f" {coord_names[i]},{coord_names[j]}.") return covariances @@ -685,14 +678,9 @@ def covariances_from_table( for i, j in zip(ii, jj): try: - covariances[:, i, j] = table[ - f"cov_{coord_names[i]}_{coord_names[j]}" - ].values + covariances[:, i, j] = table[f"cov_{coord_names[i]}_{coord_names[j]}"].values covariances[:, j, i] = covariances[:, i, j] except KeyError: - logger.debug( - "No covariance column found for dimensions" - f" {coord_names[i]},{coord_names[j]}." - ) + logger.debug("No covariance column found for dimensions" f" {coord_names[i]},{coord_names[j]}.") return covariances diff --git a/adam_core/coordinates/keplerian.py b/adam_core/coordinates/keplerian.py index 5dc074d1..8d056d7a 100644 --- a/adam_core/coordinates/keplerian.py +++ b/adam_core/coordinates/keplerian.py @@ -33,7 +33,6 @@ class KeplerianCoordinates(qv.Table): - a = qv.Float64Column() e = qv.Float64Column() i = qv.Float64Column() @@ -210,9 +209,7 @@ def to_cartesian(self) -> CartesianCoordinates: tol=1e-15, ) else: - covariances_cartesian = np.empty( - (len(coords_cartesian), 6, 6), dtype=np.float64 - ) + covariances_cartesian = np.empty((len(coords_cartesian), 6, 6), dtype=np.float64) covariances_cartesian.fill(np.nan) covariances_cartesian = CoordinateCovariances.from_matrix(covariances_cartesian) @@ -257,9 +254,7 @@ def from_cartesian(cls, cartesian: CartesianCoordinates): mu=mu, ) else: - covariances_keplerian = np.empty( - (len(coords_keplerian), 6, 6), dtype=np.float64 - ) + covariances_keplerian = np.empty((len(coords_keplerian), 6, 6), dtype=np.float64) covariances_keplerian.fill(np.nan) covariances_keplerian = CoordinateCovariances.from_matrix(covariances_keplerian) @@ -283,9 +278,7 @@ def to_cometary(self) -> "CometaryCoordinates": return CometaryCoordinates.from_cartesian(self.to_cartesian()) @classmethod - def from_cometary( - cls, cometary_coordinates: "CometaryCoordinates" - ) -> "KeplerianCoordinates": + def from_cometary(cls, cometary_coordinates: "CometaryCoordinates") -> "KeplerianCoordinates": return cls.from_cartesian(cometary_coordinates.to_cartesian()) def to_spherical(self) -> "SphericalCoordinates": @@ -294,7 +287,5 @@ def to_spherical(self) -> "SphericalCoordinates": return SphericalCoordinates.from_cartesian(self.to_cartesian()) @classmethod - def from_spherical( - cls, spherical_coordinates: "SphericalCoordinates" - ) -> "KeplerianCoordinates": + def from_spherical(cls, spherical_coordinates: "SphericalCoordinates") -> "KeplerianCoordinates": return cls.from_cartesian(spherical_coordinates.to_cartesian()) diff --git a/adam_core/coordinates/origin.py b/adam_core/coordinates/origin.py index 5905556b..00b238dd 100644 --- a/adam_core/coordinates/origin.py +++ b/adam_core/coordinates/origin.py @@ -59,7 +59,6 @@ class OriginGravitationalParameters(float, Enum): # TODO: Replace with DictionaryColumn or similar # Investigate whether this class is even necessary class Origin(qv.Table): - code = qv.StringColumn() def __init__(self, table: pa.Table, mu: Optional[float] = None): @@ -89,9 +88,7 @@ def __ne__(self, other: object) -> np.ndarray: @property def mu(self): if self._mu is None: - logger.debug( - "Origin.mu called without mu set. Finding mu in OriginGravitationalParameters." - ) + logger.debug("Origin.mu called without mu set. Finding mu in OriginGravitationalParameters.") codes = np.array(self.code) if len(np.unique(codes)) > 1: raise ValueError("Origin.mu called on table with multiple origins.") @@ -99,9 +96,7 @@ def mu(self): try: return OriginGravitationalParameters[codes[0]].value except KeyError: - raise ValueError( - "Origin.mu called on table with unrecognized origin code." - ) + raise ValueError("Origin.mu called on table with unrecognized origin code.") else: return self._mu diff --git a/adam_core/coordinates/residuals.py b/adam_core/coordinates/residuals.py index 52815b9d..ced4b56b 100644 --- a/adam_core/coordinates/residuals.py +++ b/adam_core/coordinates/residuals.py @@ -31,16 +31,13 @@ class Residuals(qv.Table): - values = qv.ListColumn(pa.float64(), nullable=True) chi2 = qv.Float64Column(nullable=True) dof = qv.Int64Column(nullable=True) probability = qv.Float64Column(nullable=True) @classmethod - def calculate( - cls, observed: CoordinateType, predicted: CoordinateType - ) -> "Residuals": + def calculate(cls, observed: CoordinateType, predicted: CoordinateType) -> "Residuals": """ Calculate the residuals between the observed and predicted coordinates. The observed coordinate's covariance matrix is used to calculate the chi2 and degrees of freedom. @@ -95,9 +92,7 @@ def calculate( batch_dimensions, batch_coords, batch_covariances, - ) = _batch_coords_and_covariances( - observed.values, observed.covariance.to_matrix() - ) + ) = _batch_coords_and_covariances(observed.values, observed.covariance.to_matrix()) for indices, dimensions, coords, covariances in zip( batch_indices, batch_dimensions, batch_coords, batch_covariances diff --git a/adam_core/coordinates/spherical.py b/adam_core/coordinates/spherical.py index dd35bc0c..ed99b66d 100644 --- a/adam_core/coordinates/spherical.py +++ b/adam_core/coordinates/spherical.py @@ -33,7 +33,6 @@ class SphericalCoordinates(qv.Table): - rho = qv.Float64Column(nullable=True) lon = qv.Float64Column(nullable=True) lat = qv.Float64Column(nullable=True) @@ -47,9 +46,7 @@ class SphericalCoordinates(qv.Table): @property def values(self) -> np.ndarray: - return np.array( - self.table.select(["rho", "lon", "lat", "vrho", "vlon", "vlat"]) - ) + return np.array(self.table.select(["rho", "lon", "lat", "vrho", "vlon", "vlat"])) @property def sigma_rho(self): @@ -164,9 +161,7 @@ def to_cartesian(self) -> CartesianCoordinates: self.values, covariances_spherical, _spherical_to_cartesian ) else: - covariances_cartesian = np.empty( - (len(coords_cartesian), 6, 6), dtype=np.float64 - ) + covariances_cartesian = np.empty((len(coords_cartesian), 6, 6), dtype=np.float64) covariances_cartesian.fill(np.nan) covariances_cartesian = CoordinateCovariances.from_matrix(covariances_cartesian) @@ -197,9 +192,7 @@ def from_cartesian(cls, cartesian: CartesianCoordinates) -> "SphericalCoordinate cartesian.values, cartesian_covariances, _cartesian_to_spherical ) else: - covariances_spherical = np.empty( - (len(coords_spherical), 6, 6), dtype=np.float64 - ) + covariances_spherical = np.empty((len(coords_spherical), 6, 6), dtype=np.float64) covariances_spherical.fill(np.nan) covariances_spherical = CoordinateCovariances.from_matrix(covariances_spherical) @@ -224,9 +217,7 @@ def to_cometary(self) -> "CometaryCoordinates": return CometaryCoordinates.from_cartesian(self.to_cartesian()) @classmethod - def from_cometary( - cls, cometary_coordinates: "CometaryCoordinates" - ) -> "SphericalCoordinates": + def from_cometary(cls, cometary_coordinates: "CometaryCoordinates") -> "SphericalCoordinates": return cls.from_cartesian(cometary_coordinates.to_cartesian()) def to_keplerian(self) -> "KeplerianCoordinates": @@ -235,13 +226,9 @@ def to_keplerian(self) -> "KeplerianCoordinates": return KeplerianCoordinates.from_cartesian(self.to_cartesian()) @classmethod - def from_keplerian( - cls, keplerian_coordinates: "KeplerianCoordinates" - ) -> "SphericalCoordinates": + def from_keplerian(cls, keplerian_coordinates: "KeplerianCoordinates") -> "SphericalCoordinates": return cls.from_cartesian(keplerian_coordinates.to_cartesian()) @classmethod - def from_spherical( - cls, spherical_coordinates: "SphericalCoordinates" - ) -> "SphericalCoordinates": + def from_spherical(cls, spherical_coordinates: "SphericalCoordinates") -> "SphericalCoordinates": return spherical_coordinates diff --git a/adam_core/coordinates/tests/conftest.py b/adam_core/coordinates/tests/conftest.py index 5f6fa9fd..33c4d798 100644 --- a/adam_core/coordinates/tests/conftest.py +++ b/adam_core/coordinates/tests/conftest.py @@ -6,43 +6,27 @@ @pytest.fixture def orbital_elements(): - orbital_elements_file = files("adam_core.utils.helpers.data").joinpath( - "elements_sun_ec.csv" - ) - df = pd.read_csv( - orbital_elements_file, index_col=False, float_precision="round_trip" - ) + orbital_elements_file = files("adam_core.utils.helpers.data").joinpath("elements_sun_ec.csv") + df = pd.read_csv(orbital_elements_file, index_col=False, float_precision="round_trip") return df @pytest.fixture def orbital_elements_equatorial(): - orbital_elements_file = files("adam_core.utils.helpers.data").joinpath( - "elements_sun_eq.csv" - ) - df = pd.read_csv( - orbital_elements_file, index_col=False, float_precision="round_trip" - ) + orbital_elements_file = files("adam_core.utils.helpers.data").joinpath("elements_sun_eq.csv") + df = pd.read_csv(orbital_elements_file, index_col=False, float_precision="round_trip") return df @pytest.fixture def orbital_elements_barycentric(): - orbital_elements_file = files("adam_core.utils.helpers.data").joinpath( - "elements_ssb_ec.csv" - ) - df = pd.read_csv( - orbital_elements_file, index_col=False, float_precision="round_trip" - ) + orbital_elements_file = files("adam_core.utils.helpers.data").joinpath("elements_ssb_ec.csv") + df = pd.read_csv(orbital_elements_file, index_col=False, float_precision="round_trip") return df @pytest.fixture def orbital_elements_barycentric_equatorial(): - orbital_elements_file = files("adam_core.utils.helpers.data").joinpath( - "elements_ssb_eq.csv" - ) - df = pd.read_csv( - orbital_elements_file, index_col=False, float_precision="round_trip" - ) + orbital_elements_file = files("adam_core.utils.helpers.data").joinpath("elements_ssb_eq.csv") + df = pd.read_csv(orbital_elements_file, index_col=False, float_precision="round_trip") return df diff --git a/adam_core/coordinates/tests/test_benchmarks.py b/adam_core/coordinates/tests/test_benchmarks.py index 41152bc9..8ccb01d5 100644 --- a/adam_core/coordinates/tests/test_benchmarks.py +++ b/adam_core/coordinates/tests/test_benchmarks.py @@ -16,18 +16,14 @@ [SphericalCoordinates, KeplerianCoordinates, CometaryCoordinates], ids=lambda x: f"to={x.__name__},", ) -@pytest.mark.parametrize( - "frame", ["equatorial", "ecliptic"], ids=lambda x: f"frame={x}," -) +@pytest.mark.parametrize("frame", ["equatorial", "ecliptic"], ids=lambda x: f"frame={x},") @pytest.mark.parametrize( "origin", [OriginCodes.SUN, OriginCodes.SOLAR_SYSTEM_BARYCENTER], ids=lambda x: f"origin={x.name},", ) @pytest.mark.benchmark(group="coord_transforms") -def test_benchmark_transform_cartesian_coordinates( - benchmark, representation, frame, origin -): +def test_benchmark_transform_cartesian_coordinates(benchmark, representation, frame, origin): if origin == OriginCodes.SOLAR_SYSTEM_BARYCENTER: pytest.skip("barycenter transform not yet implemented") @@ -53,7 +49,6 @@ def test_benchmark_transform_cartesian_coordinates( @pytest.mark.benchmark(group="coordinate_covariances") def test_benchmark_CoordinateCovariances_to_matrix(benchmark): - covariances_filled = [np.random.random(36) for _ in range(500)] covariances_missing = [None for _ in range(500)] coordinate_covariances = CoordinateCovariances.from_kwargs( @@ -64,7 +59,6 @@ def test_benchmark_CoordinateCovariances_to_matrix(benchmark): @pytest.mark.benchmark(group="coordinate_covariances") def test_benchmark_CoordinateCovariances_from_matrix(benchmark): - covariances = np.random.random((1000, 6, 6)) covariances[500:, :, :] = np.nan benchmark(CoordinateCovariances.from_matrix, covariances) diff --git a/adam_core/coordinates/tests/test_cartesian.py b/adam_core/coordinates/tests/test_cartesian.py index 8e39f38b..4d57c029 100644 --- a/adam_core/coordinates/tests/test_cartesian.py +++ b/adam_core/coordinates/tests/test_cartesian.py @@ -59,9 +59,7 @@ def test_CartesianCoordinates_rotate(): # Covariances should also be rotated (this is a bit harder to test) but we # write out the explicit matrix multiplication) covariances_rotated = rot_matrix @ covariances @ rot_matrix.T - np.testing.assert_almost_equal( - coords_rotated.covariance.to_matrix(), covariances_rotated - ) + np.testing.assert_almost_equal(coords_rotated.covariance.to_matrix(), covariances_rotated) return diff --git a/adam_core/coordinates/tests/test_origin.py b/adam_core/coordinates/tests/test_origin.py index 93e57242..0c56700b 100644 --- a/adam_core/coordinates/tests/test_origin.py +++ b/adam_core/coordinates/tests/test_origin.py @@ -12,21 +12,11 @@ def test_origin_eq__(): np.testing.assert_equal(origin != "SUN", np.array([False, True, False])) # Test equality with numpy array - np.testing.assert_equal( - origin == np.array(["SUN", "EARTH", "SUN"]), np.array([True, True, True]) - ) - np.testing.assert_equal( - origin == np.array(["SUN", "EARTH", "EARTH"]), np.array([True, True, False]) - ) - np.testing.assert_equal( - origin != np.array(["SUN", "EARTH", "EARTH"]), np.array([False, False, True]) - ) - np.testing.assert_equal( - origin == np.array(["SUN", "SUN", "SUN"]), np.array([True, False, True]) - ) - np.testing.assert_equal( - origin != np.array(["SUN", "SUN", "SUN"]), np.array([False, True, False]) - ) + np.testing.assert_equal(origin == np.array(["SUN", "EARTH", "SUN"]), np.array([True, True, True])) + np.testing.assert_equal(origin == np.array(["SUN", "EARTH", "EARTH"]), np.array([True, True, False])) + np.testing.assert_equal(origin != np.array(["SUN", "EARTH", "EARTH"]), np.array([False, False, True])) + np.testing.assert_equal(origin == np.array(["SUN", "SUN", "SUN"]), np.array([True, False, True])) + np.testing.assert_equal(origin != np.array(["SUN", "SUN", "SUN"]), np.array([False, True, False])) # Test equality with Origin np.testing.assert_equal( diff --git a/adam_core/coordinates/tests/test_residuals.py b/adam_core/coordinates/tests/test_residuals.py index 4867ccb1..a2d3b024 100644 --- a/adam_core/coordinates/tests/test_residuals.py +++ b/adam_core/coordinates/tests/test_residuals.py @@ -43,13 +43,9 @@ def test_calculate_chi2_mahalanobis(): mahalanobis_distance = np.zeros(2) for i in range(2): - mahalanobis_distance[i] = mahalanobis( - observed[i], predicted[i], np.linalg.inv(covariances[i]) - ) + mahalanobis_distance[i] = mahalanobis(observed[i], predicted[i], np.linalg.inv(covariances[i])) - assert np.allclose( - calculate_chi2(observed - predicted, covariances), mahalanobis_distance**2 - ) + assert np.allclose(calculate_chi2(observed - predicted, covariances), mahalanobis_distance**2) def test_batch_coords_and_covariances_single_batch_no_missing_values(): @@ -73,13 +69,7 @@ def test_batch_coords_and_covariances_single_batch_no_missing_values(): batch_coords, batch_covariances, ) = _batch_coords_and_covariances(coords, covariances) - assert ( - len(batch_indices) - == len(batch_dimensions) - == len(batch_coords) - == len(batch_covariances) - == 1 - ) + assert len(batch_indices) == len(batch_dimensions) == len(batch_coords) == len(batch_covariances) == 1 np.testing.assert_equal(batch_indices[0], np.array([0, 1])) np.testing.assert_equal(batch_dimensions[0], np.array([0, 1, 2])) np.testing.assert_equal(batch_coords[0], coords) @@ -107,13 +97,7 @@ def test_batch_coords_and_covariances_single_batch_missing_values(): batch_coords, batch_covariances, ) = _batch_coords_and_covariances(coords, covariances) - assert ( - len(batch_indices) - == len(batch_dimensions) - == len(batch_coords) - == len(batch_covariances) - == 1 - ) + assert len(batch_indices) == len(batch_dimensions) == len(batch_coords) == len(batch_covariances) == 1 np.testing.assert_equal(batch_indices[0], np.array([0, 1])) np.testing.assert_equal(batch_dimensions[0], np.array([0, 2])) np.testing.assert_equal(batch_coords[0], np.array([[1.0, 3.0], [2.0, 4.0]])) @@ -142,13 +126,7 @@ def test_batch_coords_and_covariances_single_batch_missing_values(): batch_coords, batch_covariances, ) = _batch_coords_and_covariances(coords, covariances) - assert ( - len(batch_indices) - == len(batch_dimensions) - == len(batch_coords) - == len(batch_covariances) - == 1 - ) + assert len(batch_indices) == len(batch_dimensions) == len(batch_coords) == len(batch_covariances) == 1 np.testing.assert_equal(batch_indices[0], np.array([0, 1])) np.testing.assert_equal(batch_dimensions[0], np.array([2])) np.testing.assert_equal(batch_coords[0], np.array([[3.0], [4.0]])) @@ -176,13 +154,7 @@ def test_batch_coords_and_covariances_multiple_batches(): batch_coords, batch_covariances, ) = _batch_coords_and_covariances(coords, covariances) - assert ( - len(batch_indices) - == len(batch_dimensions) - == len(batch_coords) - == len(batch_covariances) - == 2 - ) + assert len(batch_indices) == len(batch_dimensions) == len(batch_coords) == len(batch_covariances) == 2 np.testing.assert_equal(batch_indices[0], np.array([0])) np.testing.assert_equal(batch_dimensions[0], np.array([0, 2])) np.testing.assert_equal(batch_coords[0], np.array([[1.0, 3.0]])) diff --git a/adam_core/coordinates/tests/test_transforms_cometary.py b/adam_core/coordinates/tests/test_transforms_cometary.py index 8c7a8afc..7ac73309 100644 --- a/adam_core/coordinates/tests/test_transforms_cometary.py +++ b/adam_core/coordinates/tests/test_transforms_cometary.py @@ -11,12 +11,8 @@ def test_cometary_to_cartesian_elliptical(orbital_elements): # Limit to elliptical orbits orbital_elements = orbital_elements[orbital_elements["e"] < 1] - cometary_elements = orbital_elements[ - ["q", "e", "incl", "Omega", "w", "tp_mjd"] - ].values - cartesian_elements_expected = orbital_elements[ - ["x", "y", "z", "vx", "vy", "vz"] - ].values + cometary_elements = orbital_elements[["q", "e", "incl", "Omega", "w", "tp_mjd"]].values + cartesian_elements_expected = orbital_elements[["x", "y", "z", "vx", "vy", "vz"]].values t0_mjd = orbital_elements["mjd_tdb"].values cartesian_elements_actual = cometary_to_cartesian(cometary_elements, t0_mjd) @@ -42,12 +38,8 @@ def test_cometary_to_cartesian_hyperbolic(orbital_elements): # Limit to hyperbolic orbits orbital_elements = orbital_elements[orbital_elements["e"] > 1] - cometary_elements = orbital_elements[ - ["q", "e", "incl", "Omega", "w", "tp_mjd"] - ].values - cartesian_elements_expected = orbital_elements[ - ["x", "y", "z", "vx", "vy", "vz"] - ].values + cometary_elements = orbital_elements[["q", "e", "incl", "Omega", "w", "tp_mjd"]].values + cartesian_elements_expected = orbital_elements[["x", "y", "z", "vx", "vy", "vz"]].values t0_mjd = orbital_elements["mjd_tdb"].values cartesian_elements_actual = cometary_to_cartesian(cometary_elements, t0_mjd) @@ -73,9 +65,7 @@ def test_cartesian_to_cometary_elliptical(orbital_elements): # Limit to elliptical orbits orbital_elements = orbital_elements[orbital_elements["e"] < 1] - cometary_elements_expected = orbital_elements[ - ["q", "e", "incl", "Omega", "w", "tp_mjd"] - ].values + cometary_elements_expected = orbital_elements[["q", "e", "incl", "Omega", "w", "tp_mjd"]].values epochs = orbital_elements["mjd_tdb"].values cartesian_elements = orbital_elements[["x", "y", "z", "vx", "vy", "vz"]].values @@ -127,9 +117,7 @@ def test_cartesian_to_cometary_hyperbolic(orbital_elements): # Limit to hyperbolic orbits orbital_elements = orbital_elements[orbital_elements["e"] > 1] - cometary_elements_expected = orbital_elements[ - ["q", "e", "incl", "Omega", "w", "tp_mjd"] - ].values + cometary_elements_expected = orbital_elements[["q", "e", "incl", "Omega", "w", "tp_mjd"]].values epochs = orbital_elements["mjd_tdb"].values cartesian_elements = orbital_elements[["x", "y", "z", "vx", "vy", "vz"]].values diff --git a/adam_core/coordinates/tests/test_transforms_keplerian.py b/adam_core/coordinates/tests/test_transforms_keplerian.py index 0b5d1b2f..01236a81 100644 --- a/adam_core/coordinates/tests/test_transforms_keplerian.py +++ b/adam_core/coordinates/tests/test_transforms_keplerian.py @@ -12,9 +12,7 @@ def test_keplerian_to_cartesian_elliptical(orbital_elements): orbital_elements = orbital_elements[orbital_elements["e"] < 1] keplerian_elements = orbital_elements[["a", "e", "incl", "Omega", "w", "M"]].values - cartesian_elements_expected = orbital_elements[ - ["x", "y", "z", "vx", "vy", "vz"] - ].values + cartesian_elements_expected = orbital_elements[["x", "y", "z", "vx", "vy", "vz"]].values cartesian_elements_actual = keplerian_to_cartesian(keplerian_elements) diff = cartesian_elements_actual - cartesian_elements_expected @@ -38,9 +36,7 @@ def test_keplerian_to_cartesian_hyperbolic(orbital_elements): orbital_elements = orbital_elements[orbital_elements["e"] > 1] keplerian_elements = orbital_elements[["a", "e", "incl", "Omega", "w", "M"]].values - cartesian_elements_expected = orbital_elements[ - ["x", "y", "z", "vx", "vy", "vz"] - ].values + cartesian_elements_expected = orbital_elements[["x", "y", "z", "vx", "vy", "vz"]].values cartesian_elements_actual = keplerian_to_cartesian(keplerian_elements) diff = cartesian_elements_actual - cartesian_elements_expected @@ -74,9 +70,7 @@ def test_cartesian_to_keplerian_elliptical(orbital_elements): keplerian_elements_actual = cartesian_to_keplerian(cartesian_elements, epochs) # Remove semi-latus rectum - keplerian_elements_actual = keplerian_elements_actual[ - :, [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] - ] + keplerian_elements_actual = keplerian_elements_actual[:, [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]] # Calculate the difference diff = keplerian_elements_actual - keplerian_elements_expected @@ -163,9 +157,7 @@ def test_cartesian_to_keplerian_hyperbolic(orbital_elements): keplerian_elements_actual = cartesian_to_keplerian(cartesian_elements, epochs) # Remove semi-latus rectum - keplerian_elements_actual = keplerian_elements_actual[ - :, [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] - ] + keplerian_elements_actual = keplerian_elements_actual[:, [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]] # Calculate the difference diff = keplerian_elements_actual - keplerian_elements_expected diff --git a/adam_core/coordinates/tests/test_transforms_rotation.py b/adam_core/coordinates/tests/test_transforms_rotation.py index a514d0f2..7be54cb5 100644 --- a/adam_core/coordinates/tests/test_transforms_rotation.py +++ b/adam_core/coordinates/tests/test_transforms_rotation.py @@ -28,13 +28,9 @@ def test_cartesian_to_frame(orbital_elements, orbital_elements_equatorial): vx=orbital_elements_equatorial["vx"].values, vy=orbital_elements_equatorial["vy"].values, vz=orbital_elements_equatorial["vz"].values, - time=Timestamp.from_mjd( - orbital_elements_equatorial["mjd_tdb"].values, scale="tdb" - ), + time=Timestamp.from_mjd(orbital_elements_equatorial["mjd_tdb"].values, scale="tdb"), frame="equatorial", - origin=Origin.from_kwargs( - code=["SUN" for i in range(len(orbital_elements_equatorial))] - ), + origin=Origin.from_kwargs(code=["SUN" for i in range(len(orbital_elements_equatorial))]), ) # Convert equatorial coordinates to ecliptic @@ -45,9 +41,7 @@ def test_cartesian_to_frame(orbital_elements, orbital_elements_equatorial): assert cartesian_coordinates_ecliptic_actual.frame == "ecliptic" # Test that the two coordinates are equal to 10 mm in position and 10 nm/s in velocity - assert_coords_equal( - cartesian_coordinates_ecliptic_actual, cartesian_coordinates_ecliptic - ) + assert_coords_equal(cartesian_coordinates_ecliptic_actual, cartesian_coordinates_ecliptic) # Convert ecliptic coordinates to equatorial cartesian_coordinates_equatorial_actual = cartesian_to_frame( @@ -57,9 +51,7 @@ def test_cartesian_to_frame(orbital_elements, orbital_elements_equatorial): assert cartesian_coordinates_equatorial_actual.frame == "equatorial" # Test that the two coordinates are equal to 10 mm in position and 10 nm/s in velocity - assert_coords_equal( - cartesian_coordinates_equatorial_actual, cartesian_coordinates_equatorial - ) + assert_coords_equal(cartesian_coordinates_equatorial_actual, cartesian_coordinates_equatorial) def test_transform_coordinates_frame(orbital_elements, orbital_elements_equatorial): @@ -93,9 +85,7 @@ def test_transform_coordinates_frame(orbital_elements, orbital_elements_equatori scale="tdb", ), frame="equatorial", - origin=Origin.from_kwargs( - code=["SUN" for i in range(len(orbital_elements_equatorial))] - ), + origin=Origin.from_kwargs(code=["SUN" for i in range(len(orbital_elements_equatorial))]), ) # Convert equatorial coordinates to ecliptic @@ -106,9 +96,7 @@ def test_transform_coordinates_frame(orbital_elements, orbital_elements_equatori assert cartesian_coordinates_ecliptic_actual.frame == "ecliptic" # Test that the two coordinates are equal to 10 mm in position and 10 nm/s in velocity - assert_coords_equal( - cartesian_coordinates_ecliptic_actual, cartesian_coordinates_ecliptic - ) + assert_coords_equal(cartesian_coordinates_ecliptic_actual, cartesian_coordinates_ecliptic) # Convert ecliptic coordinates to equatorial cartesian_coordinates_equatorial_actual = transform_coordinates( @@ -118,6 +106,4 @@ def test_transform_coordinates_frame(orbital_elements, orbital_elements_equatori assert cartesian_coordinates_equatorial_actual.frame == "equatorial" # Test that the two coordinates are equal to 10 mm in position and 10 nm/s in velocity - assert_coords_equal( - cartesian_coordinates_equatorial_actual, cartesian_coordinates_equatorial - ) + assert_coords_equal(cartesian_coordinates_equatorial_actual, cartesian_coordinates_equatorial) diff --git a/adam_core/coordinates/tests/test_transforms_spice.py b/adam_core/coordinates/tests/test_transforms_spice.py index ec0c93d3..97a80ed8 100644 --- a/adam_core/coordinates/tests/test_transforms_spice.py +++ b/adam_core/coordinates/tests/test_transforms_spice.py @@ -114,9 +114,7 @@ def test_cartesian_to_keplerian_elliptical_against_spice(orbital_elements): keplerian_elements_spice = np.empty((len(cartesian_elements), 8)) for i in range(len(keplerian_elements_spice)): - keplerian_elements_spice[i] = sp.oscelt( - np.copy(cartesian_elements[i]), t0_jd[i], MU - ) + keplerian_elements_spice[i] = sp.oscelt(np.copy(cartesian_elements[i]), t0_jd[i], MU) # Keplerian elements from SPICE report periapse distance instead of semi-major axis # and angles are in radians instead of degrees, also returned are the gravitational @@ -189,9 +187,7 @@ def test_cartesian_to_keplerian_hyperbolic_against_spice(orbital_elements): keplerian_elements_spice = np.empty((len(cartesian_elements), 8)) for i in range(len(keplerian_elements_spice)): - keplerian_elements_spice[i] = sp.oscelt( - np.copy(cartesian_elements[i]), t0_jd[i], MU - ) + keplerian_elements_spice[i] = sp.oscelt(np.copy(cartesian_elements[i]), t0_jd[i], MU) # Keplerian elements from SPICE report periapse distance instead of semi-major axis # and angles are in radians instead of degrees, also returned are the gravitational diff --git a/adam_core/coordinates/tests/test_transforms_translation.py b/adam_core/coordinates/tests/test_transforms_translation.py index b466d3a9..2a4a0799 100644 --- a/adam_core/coordinates/tests/test_transforms_translation.py +++ b/adam_core/coordinates/tests/test_transforms_translation.py @@ -57,10 +57,7 @@ def test_cartesian_to_origin(orbital_elements, orbital_elements_barycentric): ), frame="ecliptic", origin=Origin.from_kwargs( - code=[ - "SOLAR_SYSTEM_BARYCENTER" - for i in range(len(orbital_elements_barycentric)) - ] + code=["SOLAR_SYSTEM_BARYCENTER" for i in range(len(orbital_elements_barycentric))] ), ) @@ -70,9 +67,7 @@ def test_cartesian_to_origin(orbital_elements, orbital_elements_barycentric): OriginCodes.SOLAR_SYSTEM_BARYCENTER, ) - assert_coords_equal( - cartesian_coordinates_barycentric, cartesian_coordinates_barycentric - ) + assert_coords_equal(cartesian_coordinates_barycentric, cartesian_coordinates_barycentric) # Convert barycentric cartesian coordinates to heliocentric cartesian coordinates cartesian_coordinates_heliocentric_actual = cartesian_to_origin( @@ -80,9 +75,7 @@ def test_cartesian_to_origin(orbital_elements, orbital_elements_barycentric): OriginCodes.SUN, ) - assert_coords_equal( - cartesian_coordinates_heliocentric_actual, cartesian_coordinates_heliocentric - ) + assert_coords_equal(cartesian_coordinates_heliocentric_actual, cartesian_coordinates_heliocentric) # Now lets complicate matters by concatenating heliocentric and barycentric # cartesian coordinates and converting them to barycentric cartesian coordinates @@ -95,13 +88,9 @@ def test_cartesian_to_origin(orbital_elements, orbital_elements_barycentric): OriginCodes.SOLAR_SYSTEM_BARYCENTER, ) - cartesian_coordinates_barycentric_ = concatenate( - [cartesian_coordinates_barycentric for i in range(2)] - ) + cartesian_coordinates_barycentric_ = concatenate([cartesian_coordinates_barycentric for i in range(2)]) - assert_coords_equal( - cartesian_coordinates_barycentric_actual, cartesian_coordinates_barycentric_ - ) + assert_coords_equal(cartesian_coordinates_barycentric_actual, cartesian_coordinates_barycentric_) # Now lets complicate matters again by concatenating heliocentric and barycentric # cartesian coordinates and converting them to heliocentric cartesian coordinates @@ -114,13 +103,9 @@ def test_cartesian_to_origin(orbital_elements, orbital_elements_barycentric): OriginCodes.SUN, ) - cartesian_coordinates_heliocentric_ = concatenate( - [cartesian_coordinates_heliocentric for i in range(2)] - ) + cartesian_coordinates_heliocentric_ = concatenate([cartesian_coordinates_heliocentric for i in range(2)]) - assert_coords_equal( - cartesian_coordinates_heliocentric_actual, cartesian_coordinates_heliocentric_ - ) + assert_coords_equal(cartesian_coordinates_heliocentric_actual, cartesian_coordinates_heliocentric_) def test_transform_coordinates_origin(orbital_elements, orbital_elements_barycentric): @@ -155,10 +140,7 @@ def test_transform_coordinates_origin(orbital_elements, orbital_elements_barycen ), frame="ecliptic", origin=Origin.from_kwargs( - code=[ - "SOLAR_SYSTEM_BARYCENTER" - for i in range(len(orbital_elements_barycentric)) - ] + code=["SOLAR_SYSTEM_BARYCENTER" for i in range(len(orbital_elements_barycentric))] ), ) @@ -168,9 +150,7 @@ def test_transform_coordinates_origin(orbital_elements, orbital_elements_barycen origin_out=OriginCodes.SOLAR_SYSTEM_BARYCENTER, ) - assert_coords_equal( - cartesian_coordinates_barycentric, cartesian_coordinates_barycentric - ) + assert_coords_equal(cartesian_coordinates_barycentric, cartesian_coordinates_barycentric) # Convert barycentric cartesian coordinates to heliocentric cartesian coordinates cartesian_coordinates_heliocentric_actual = transform_coordinates( @@ -178,9 +158,7 @@ def test_transform_coordinates_origin(orbital_elements, orbital_elements_barycen origin_out=OriginCodes.SUN, ) - assert_coords_equal( - cartesian_coordinates_heliocentric_actual, cartesian_coordinates_heliocentric - ) + assert_coords_equal(cartesian_coordinates_heliocentric_actual, cartesian_coordinates_heliocentric) # Now lets complicate matters by concatenating heliocentric and barycentric # cartesian coordinates and converting them to barycentric cartesian coordinates @@ -193,13 +171,9 @@ def test_transform_coordinates_origin(orbital_elements, orbital_elements_barycen origin_out=OriginCodes.SOLAR_SYSTEM_BARYCENTER, ) - cartesian_coordinates_barycentric_ = concatenate( - [cartesian_coordinates_barycentric for i in range(2)] - ) + cartesian_coordinates_barycentric_ = concatenate([cartesian_coordinates_barycentric for i in range(2)]) - assert_coords_equal( - cartesian_coordinates_barycentric_actual, cartesian_coordinates_barycentric_ - ) + assert_coords_equal(cartesian_coordinates_barycentric_actual, cartesian_coordinates_barycentric_) # Now lets complicate matters again by concatenating heliocentric and barycentric # cartesian coordinates and converting them to heliocentric cartesian coordinates @@ -212,10 +186,6 @@ def test_transform_coordinates_origin(orbital_elements, orbital_elements_barycen origin_out=OriginCodes.SUN, ) - cartesian_coordinates_heliocentric_ = concatenate( - [cartesian_coordinates_heliocentric for i in range(2)] - ) + cartesian_coordinates_heliocentric_ = concatenate([cartesian_coordinates_heliocentric for i in range(2)]) - assert_coords_equal( - cartesian_coordinates_heliocentric_actual, cartesian_coordinates_heliocentric_ - ) + assert_coords_equal(cartesian_coordinates_heliocentric_actual, cartesian_coordinates_heliocentric_) diff --git a/adam_core/coordinates/times.py b/adam_core/coordinates/times.py index 9db87b14..debef3b0 100644 --- a/adam_core/coordinates/times.py +++ b/adam_core/coordinates/times.py @@ -9,7 +9,6 @@ class Times(qv.Table): - # Stores the time as a pair of float64 values in the same style as erfa/astropy: # The first one is the day-part of a Julian date, and the second is # the fractional day-part. diff --git a/adam_core/coordinates/transform.py b/adam_core/coordinates/transform.py index 29af132f..84325538 100644 --- a/adam_core/coordinates/transform.py +++ b/adam_core/coordinates/transform.py @@ -47,9 +47,7 @@ @jit -def _cartesian_to_spherical( - coords_cartesian: Union[np.ndarray, jnp.ndarray] -) -> jnp.ndarray: +def _cartesian_to_spherical(coords_cartesian: Union[np.ndarray, jnp.ndarray]) -> jnp.ndarray: """ Convert a single Cartesian coordinate to a spherical coordinate. @@ -95,9 +93,7 @@ def _cartesian_to_spherical( lambda _: jnp.arcsin(z / rho), None, ) - lat = jnp.where( - (lat >= 3 * jnp.pi / 2) & (lat <= 2 * jnp.pi), lat - 2 * jnp.pi, lat - ) + lat = jnp.where((lat >= 3 * jnp.pi / 2) & (lat <= 2 * jnp.pi), lat - 2 * jnp.pi, lat) vrho = lax.cond( rho == 0.0, @@ -137,9 +133,7 @@ def _cartesian_to_spherical( ) -def cartesian_to_spherical( - coords_cartesian: Union[np.ndarray, jnp.ndarray] -) -> jnp.ndarray: +def cartesian_to_spherical(coords_cartesian: Union[np.ndarray, jnp.ndarray]) -> jnp.ndarray: """ Convert Cartesian coordinates to a spherical coordinates. @@ -173,9 +167,7 @@ def cartesian_to_spherical( @jit -def _spherical_to_cartesian( - coords_spherical: Union[np.ndarray, jnp.ndarray] -) -> jnp.ndarray: +def _spherical_to_cartesian(coords_spherical: Union[np.ndarray, jnp.ndarray]) -> jnp.ndarray: """ Convert a single spherical coordinate to a Cartesian coordinate. @@ -221,16 +213,8 @@ def _spherical_to_cartesian( y = rho * cos_lat * sin_lon z = rho * sin_lat - vx = ( - cos_lat * cos_lon * vrho - - rho * cos_lat * sin_lon * vlon - - rho * sin_lat * cos_lon * vlat - ) - vy = ( - cos_lat * sin_lon * vrho - + rho * cos_lat * cos_lon * vlon - - rho * sin_lat * sin_lon * vlat - ) + vx = cos_lat * cos_lon * vrho - rho * cos_lat * sin_lon * vlon - rho * sin_lat * cos_lon * vlat + vy = cos_lat * sin_lon * vrho + rho * cos_lat * cos_lon * vlon - rho * sin_lat * sin_lon * vlat vz = sin_lat * vrho + rho * cos_lat * vlat coords_cartesian = coords_cartesian.at[0].set(x) @@ -252,9 +236,7 @@ def _spherical_to_cartesian( ) -def spherical_to_cartesian( - coords_spherical: Union[np.ndarray, jnp.ndarray] -) -> jnp.ndarray: +def spherical_to_cartesian(coords_spherical: Union[np.ndarray, jnp.ndarray]) -> jnp.ndarray: """ Convert spherical coordinates to Cartesian coordinates. @@ -386,9 +368,7 @@ def _cartesian_to_keplerian( # In certain conventions when the orbit is zero inclined or 180 inclined # the ascending node is set to 0 as opposed to being undefined. This is what # SPICE does so we will do the same. - raan = jnp.where( - (i < FLOAT_TOLERANCE) | (jnp.abs(i - 2 * jnp.pi) < FLOAT_TOLERANCE), 0.0, raan - ) + raan = jnp.where((i < FLOAT_TOLERANCE) | (jnp.abs(i - 2 * jnp.pi) < FLOAT_TOLERANCE), 0.0, raan) # Calculate the argument of periapsis # Equation 2.4-9 in Bate, Mueller, & White [1] @@ -439,9 +419,7 @@ def _cartesian_to_keplerian( # Calculate the orbital period which for parabolic and hyperbolic # orbits is infinite while for all closed orbits # is well defined. - P = lax.cond( - e < (1.0 - FLOAT_TOLERANCE), lambda n: 2 * jnp.pi / n, lambda n: jnp.inf, n - ) + P = lax.cond(e < (1.0 - FLOAT_TOLERANCE), lambda n: 2 * jnp.pi / n, lambda n: jnp.inf, n) # In the case of closed orbits, if the mean anomaly is # greater than 180 degrees then the orbit is @@ -641,9 +619,7 @@ def _keplerian_to_cartesian_p( 0, ] ) - v_PQW = jnp.array( - [-jnp.sqrt(mu / p) * jnp.sin(nu), jnp.sqrt(mu / p) * (e + jnp.cos(nu)), 0] - ) + v_PQW = jnp.array([-jnp.sqrt(mu / p) * jnp.sin(nu), jnp.sqrt(mu / p) * (e + jnp.cos(nu)), 0]) cos_raan = jnp.cos(raan) sin_raan = jnp.sin(raan) @@ -921,9 +897,7 @@ def keplerian_to_cartesian( a = coords_keplerian[:, 0] e = coords_keplerian[:, 1] - parabolic = np.where((e < (1.0 + FLOAT_TOLERANCE)) & (e > (1.0 - FLOAT_TOLERANCE)))[ - 0 - ] + parabolic = np.where((e < (1.0 + FLOAT_TOLERANCE)) & (e > (1.0 - FLOAT_TOLERANCE)))[0] if len(parabolic) > 0: msg = ( "Parabolic orbits (e = 1.0 +- 1e-15) are best represented using Cometary coordinates.\n" @@ -948,9 +922,7 @@ def keplerian_to_cartesian( ) raise ValueError(err) - coords_cartesian = _keplerian_to_cartesian_a_vmap( - coords_keplerian, mu, max_iter, tol - ) + coords_cartesian = _keplerian_to_cartesian_a_vmap(coords_keplerian, mu, max_iter, tol) return coords_cartesian @@ -1132,9 +1104,7 @@ def _cometary_to_cartesian( coords_keplerian = coords_keplerian.at[4].set(ap) coords_keplerian = coords_keplerian.at[5].set(jnp.degrees(M)) - coords_cartesian = _keplerian_to_cartesian_q( - coords_keplerian, mu=mu, max_iter=max_iter, tol=tol - ) + coords_cartesian = _keplerian_to_cartesian_q(coords_keplerian, mu=mu, max_iter=max_iter, tol=tol) return coords_cartesian @@ -1191,15 +1161,11 @@ def cometary_to_cartesian( vy : y-velocity in units of au per day. vz : z-velocity in units of au per day. """ - coords_cartesian = _cometary_to_cartesian_vmap( - coords_cometary, t0, mu, max_iter, tol - ) + coords_cartesian = _cometary_to_cartesian_vmap(coords_cometary, t0, mu, max_iter, tol) return coords_cartesian -def cartesian_to_origin( - coords: CartesianCoordinates, origin: OriginCodes -) -> "CartesianCoordinates": +def cartesian_to_origin(coords: CartesianCoordinates, origin: OriginCodes) -> "CartesianCoordinates": """ Translate coordinates to a different origin. @@ -1232,13 +1198,11 @@ def cartesian_to_origin( times = coords.time for origin_in in unique_origins: - mask = pc.equal(coords.origin.code, origin_in).to_numpy(zero_copy_only=False) origin_in_str = origin_in.as_py() # Could use try / except block here but this is more explicit if origin_in_str in OriginCodes.__members__: - vectors[mask] = get_perturber_state( OriginCodes[origin_in_str], times.apply_mask(mask), @@ -1247,7 +1211,6 @@ def cartesian_to_origin( ).values elif origin_in_str in OBSERVATORY_CODES: - vectors[mask] = get_observer_state( origin_in_str, times.apply_mask(mask), @@ -1349,9 +1312,7 @@ def transform_coordinates( representation_out_ = representation_out if representation_out_ not in CoordinatesClasses: - raise ValueError( - "Unsupported representation_out: {}".format(representation_out_) - ) + raise ValueError("Unsupported representation_out: {}".format(representation_out_)) coord_frame = coords.frame # Extract the origins from the input coordinates. These typically correspond diff --git a/adam_core/coordinates/variants.py b/adam_core/coordinates/variants.py index 5b669ff8..df93caaf 100644 --- a/adam_core/coordinates/variants.py +++ b/adam_core/coordinates/variants.py @@ -101,9 +101,7 @@ def create_coordinate_variants( If the input coordinates are not supported. """ if coordinates.covariance.is_all_nan(): - raise ValueError( - "Cannot sample coordinate covariances when covariances are all undefined." - ) + raise ValueError("Cannot sample coordinate covariances when covariances are all undefined.") class VariantCoordinates(qv.Table): index = qv.Int64Column() @@ -124,7 +122,6 @@ class VariantCoordinates(qv.Table): variants_list = [] for i, coordinate_i in enumerate(coordinates): - mean = coordinate_i.values[0] cov = coordinate_i.covariance.to_matrix()[0] @@ -138,20 +135,14 @@ class VariantCoordinates(qv.Table): ) if method == "sigma-point": - samples, W, W_cov = sample_covariance_sigma_points( - mean, cov, alpha=alpha, beta=beta, kappa=kappa - ) + samples, W, W_cov = sample_covariance_sigma_points(mean, cov, alpha=alpha, beta=beta, kappa=kappa) elif method == "monte-carlo": - samples, W, W_cov = sample_covariance_random( - mean, cov, num_samples=num_samples - ) + samples, W, W_cov = sample_covariance_random(mean, cov, num_samples=num_samples) elif method == "auto": # Sample with sigma points - samples, W, W_cov = sample_covariance_sigma_points( - mean, cov, alpha=alpha, beta=beta, kappa=kappa - ) + samples, W, W_cov = sample_covariance_sigma_points(mean, cov, alpha=alpha, beta=beta, kappa=kappa) # Check if the sigma point sampling is good enough by seeing if we can # recover the mean and covariance from the sigma points @@ -163,9 +154,7 @@ class VariantCoordinates(qv.Table): diff_mean = np.abs(mean_sg - mean) diff_cov = np.abs(cov_sg - cov) if np.any(diff_mean >= 1e-12) or np.any(diff_cov >= 1e-12): - samples, W, W_cov = sample_covariance_random( - mean, cov, num_samples=num_samples - ) + samples, W, W_cov = sample_covariance_random(mean, cov, num_samples=num_samples) else: raise ValueError(f"Unknown coordinate covariance sampling method: {method}") @@ -174,12 +163,8 @@ class VariantCoordinates(qv.Table): VariantCoordinates.from_kwargs( index=np.full(len(samples), i), sample=coordinates.from_kwargs( - origin=qv.concatenate( - [coordinate_i.origin for i in range(len(samples))] - ), - time=qv.concatenate( - [coordinate_i.time for i in range(len(samples))] - ), + origin=qv.concatenate([coordinate_i.origin for i in range(len(samples))]), + time=qv.concatenate([coordinate_i.time for i in range(len(samples))]), frame=coordinate_i.frame, **{dim: samples[:, i] for i, dim in enumerate(dimensions)}, ), diff --git a/adam_core/dynamics/aberrations.py b/adam_core/dynamics/aberrations.py index d6b271bc..34f36122 100644 --- a/adam_core/dynamics/aberrations.py +++ b/adam_core/dynamics/aberrations.py @@ -60,7 +60,6 @@ def _add_light_time( @jit def _iterate_light_time(p): - orbit_i = p[0] t0 = p[1] lt0 = p[2] @@ -78,9 +77,7 @@ def _iterate_light_time(p): # Propagate backwards to new epoch t1 = t0 - lt - orbit_propagated = _propagate_2body( - orbit, t0, t1, mu=mu, max_iter=max_iter, tol=tol - ) + orbit_propagated = _propagate_2body(orbit, t0, t1, mu=mu, max_iter=max_iter, tol=tol) p[0] = orbit_propagated p[1] = t1 @@ -103,9 +100,7 @@ def _while_condition(p): # Vectorization Map: _add_light_time -_add_light_time_vmap = jit( - vmap(_add_light_time, in_axes=(0, 0, 0, None, None, None, None), out_axes=(0, 0)) -) +_add_light_time_vmap = jit(vmap(_add_light_time, in_axes=(0, 0, 0, None, None, None, None), out_axes=(0, 0))) @jit @@ -151,16 +146,12 @@ def add_light_time( lt : `~jax.numpy.ndarray` (N) Light time correction (t0 - corrected_t0). """ - orbits_aberrated, lts = _add_light_time_vmap( - orbits, t0, observer_positions, lt_tol, mu, max_iter, tol - ) + orbits_aberrated, lts = _add_light_time_vmap(orbits, t0, observer_positions, lt_tol, mu, max_iter, tol) return orbits_aberrated, lts @jit -def add_stellar_aberration( - orbits: jnp.ndarray, observer_states: jnp.ndarray -) -> jnp.ndarray: +def add_stellar_aberration(orbits: jnp.ndarray, observer_states: jnp.ndarray) -> jnp.ndarray: """ The motion of the observer in an inertial frame will cause an object to appear in a different location than its true geometric location. This @@ -200,8 +191,7 @@ def add_stellar_aberration( rho = topo_states[:, :3] / delta rho_dot_gamma = jnp.sum(rho * gamma, axis=1, keepdims=True) rho_aberrated = rho_aberrated.at[:].set( - (beta_inv * rho + gamma + rho_dot_gamma * gamma / (1 + beta_inv)) - / (1 + rho_dot_gamma) + (beta_inv * rho + gamma + rho_dot_gamma * gamma / (1 + beta_inv)) / (1 + rho_dot_gamma) ) rho_aberrated = rho_aberrated.at[:].multiply(delta) diff --git a/adam_core/dynamics/barker.py b/adam_core/dynamics/barker.py index f34f0537..2df755a5 100644 --- a/adam_core/dynamics/barker.py +++ b/adam_core/dynamics/barker.py @@ -27,7 +27,6 @@ def solve_barker(M: float) -> float: """ # Equation 3.32 in Curtis (2014) [1] nu = 2 * jnp.arctan( - (3 * M + jnp.sqrt((3 * M) ** 2 + 1)) ** (1 / 3) - - (3 * M + jnp.sqrt((3 * M) ** 2 + 1)) ** (-1 / 3) + (3 * M + jnp.sqrt((3 * M) ** 2 + 1)) ** (1 / 3) - (3 * M + jnp.sqrt((3 * M) ** 2 + 1)) ** (-1 / 3) ) return nu diff --git a/adam_core/dynamics/chi.py b/adam_core/dynamics/chi.py index 90788c0a..d2ce898a 100644 --- a/adam_core/dynamics/chi.py +++ b/adam_core/dynamics/chi.py @@ -20,9 +20,7 @@ def calc_chi( mu: float = MU, max_iter: int = 100, tol: float = 1e-16, -) -> Tuple[ - np.float64, np.float64, np.float64, np.float64, np.float64, np.float64, np.float64 -]: +) -> Tuple[np.float64, np.float64, np.float64, np.float64, np.float64, np.float64, np.float64]: """ Calculate universal anomaly chi using Newton-Raphson. @@ -77,7 +75,6 @@ def calc_chi( # Define while loop body function @jit def _chi_newton_raphson(p): - chi = p[0] ratio = p[-2] iterations = p[-1] @@ -95,9 +92,7 @@ def _chi_newton_raphson(p): - sqrt_mu * dt ) fp = ( - r_mag * rv_mag / sqrt_mu * chi * (1 - alpha * chi2 * c3) - + (1 - alpha * r_mag) * chi2 * c2 - + r_mag + r_mag * rv_mag / sqrt_mu * chi * (1 - alpha * chi2 * c3) + (1 - alpha * r_mag) * chi2 * c2 + r_mag ) ratio = f / fp diff --git a/adam_core/dynamics/ephemeris.py b/adam_core/dynamics/ephemeris.py index 41ab5e93..16892a62 100644 --- a/adam_core/dynamics/ephemeris.py +++ b/adam_core/dynamics/ephemeris.py @@ -203,9 +203,7 @@ def generate_ephemeris_2body( # Stack the observer coordinates and codes for each orbit in the propagated orbits num_orbits = len(propagated_orbits_barycentric.orbit_id.unique()) - observer_coordinates = np.tile( - observers_barycentric.coordinates.values, (num_orbits, 1) - ) + observer_coordinates = np.tile(observers_barycentric.coordinates.values, (num_orbits, 1)) observer_codes = np.tile(observers.code.to_numpy(zero_copy_only=False), num_orbits) times = propagated_orbits.coordinates.time.to_astropy() @@ -223,7 +221,6 @@ def generate_ephemeris_2body( light_time = np.array(light_time) if not propagated_orbits.coordinates.covariance.is_all_nan(): - cartesian_covariances = propagated_orbits.coordinates.covariance.to_matrix() covariances_spherical = transform_covariances_jacobian( propagated_orbits.coordinates.values, @@ -239,9 +236,7 @@ def generate_ephemeris_2body( tol=tol, stellar_aberration=stellar_aberration, ) - covariances_spherical = CoordinateCovariances.from_matrix( - np.array(covariances_spherical) - ) + covariances_spherical = CoordinateCovariances.from_matrix(np.array(covariances_spherical)) else: covariances_spherical = None diff --git a/adam_core/dynamics/kepler.py b/adam_core/dynamics/kepler.py index 53534694..250aeddc 100644 --- a/adam_core/dynamics/kepler.py +++ b/adam_core/dynamics/kepler.py @@ -30,9 +30,7 @@ def calc_mean_anomaly(nu: float, e: float) -> float: E, M = lax.cond( e < 1.0, _calc_elliptical_anomalies, - lambda nu, e: lax.cond( - e > 1.0, _calc_hyperbolic_anomalies, _calc_parabolic_anomalies, nu, e - ), + lambda nu, e: lax.cond(e > 1.0, _calc_hyperbolic_anomalies, _calc_parabolic_anomalies, nu, e), nu, e, ) @@ -179,16 +177,11 @@ def _while_condition(p): nu = lax.cond( e < 1.0, - lambda E, e, M: 2 - * jnp.arctan2( - jnp.sqrt(1 + e) * jnp.sin(E / 2), jnp.sqrt(1 - e) * jnp.cos(E / 2) - ), + lambda E, e, M: 2 * jnp.arctan2(jnp.sqrt(1 + e) * jnp.sin(E / 2), jnp.sqrt(1 - e) * jnp.cos(E / 2)), lambda E, e, M: lax.cond( e > 1.0, lambda H, e, M: 2 - * jnp.arctan( - jnp.sqrt(e + 1) * jnp.sinh(H / 2) / (jnp.sqrt(e - 1) * jnp.cosh(H / 2)) - ), + * jnp.arctan(jnp.sqrt(e + 1) * jnp.sinh(H / 2) / (jnp.sqrt(e - 1) * jnp.cosh(H / 2))), lambda P, e, M: solve_barker(M), p[0], p[1], diff --git a/adam_core/dynamics/propagation.py b/adam_core/dynamics/propagation.py index cece063a..ea6570b9 100644 --- a/adam_core/dynamics/propagation.py +++ b/adam_core/dynamics/propagation.py @@ -68,9 +68,7 @@ def _propagate_2body( # Vectorization Map: _propagate_2body -_propagate_2body_vmap = jit( - vmap(_propagate_2body, in_axes=(0, 0, 0, None, None, None), out_axes=(0)) -) +_propagate_2body_vmap = jit(vmap(_propagate_2body, in_axes=(0, 0, 0, None, None, None), out_axes=(0))) def propagate_2body( @@ -122,9 +120,7 @@ def propagate_2body( t0_ = np.repeat(t0, n_times) t1_ = np.tile(t1, n_orbits) - orbits_propagated = _propagate_2body_vmap( - orbits_array_, t0_, t1_, mu, max_iter, tol - ) + orbits_propagated = _propagate_2body_vmap(orbits_array_, t0_, t1_, mu, max_iter, tol) orbits_propagated = np.array(orbits_propagated) if not orbits.coordinates.covariance.is_all_nan(): diff --git a/adam_core/dynamics/stumpff.py b/adam_core/dynamics/stumpff.py index efd6600d..475942f7 100644 --- a/adam_core/dynamics/stumpff.py +++ b/adam_core/dynamics/stumpff.py @@ -5,9 +5,7 @@ config.update("jax_enable_x64", True) -STUMPFF_TYPES = Tuple[ - jnp.float64, jnp.float64, jnp.float64, jnp.float64, jnp.float64, jnp.float64 -] +STUMPFF_TYPES = Tuple[jnp.float64, jnp.float64, jnp.float64, jnp.float64, jnp.float64, jnp.float64] @jit diff --git a/adam_core/dynamics/tests/conftest.py b/adam_core/dynamics/tests/conftest.py index 2581e52f..606a45d3 100644 --- a/adam_core/dynamics/tests/conftest.py +++ b/adam_core/dynamics/tests/conftest.py @@ -8,20 +8,14 @@ @pytest.fixture def orbital_elements(): - orbital_elements_file = files("adam_core.utils.helpers.data").joinpath( - "elements_sun_ec.csv" - ) - df = pd.read_csv( - orbital_elements_file, index_col=False, float_precision="round_trip" - ) + orbital_elements_file = files("adam_core.utils.helpers.data").joinpath("elements_sun_ec.csv") + df = pd.read_csv(orbital_elements_file, index_col=False, float_precision="round_trip") return df @pytest.fixture def propagated_orbits(): - return Orbits.from_parquet( - files("adam_core.utils.helpers.data").joinpath("propagated_orbits.parquet") - ) + return Orbits.from_parquet(files("adam_core.utils.helpers.data").joinpath("propagated_orbits.parquet")) @pytest.fixture diff --git a/adam_core/dynamics/tests/test_ephemeris.py b/adam_core/dynamics/tests/test_ephemeris.py index 541e013e..d4f455c9 100644 --- a/adam_core/dynamics/tests/test_ephemeris.py +++ b/adam_core/dynamics/tests/test_ephemeris.py @@ -103,8 +103,7 @@ def test_generate_ephemeris_2body(object_id, propagated_orbits, ephemeris): # Calculate the offset in light travel time light_time_diff = np.abs( - ephemeris_orbit_2body.light_time.to_numpy() - - (ephemeris_orbit["lighttime"].values * 60 / 86400) + ephemeris_orbit_2body.light_time.to_numpy() - (ephemeris_orbit["lighttime"].values * 60 / 86400) ) * (u.d).to(u.microsecond) # Assert that the light time is less than the tolerance @@ -112,14 +111,13 @@ def test_generate_ephemeris_2body(object_id, propagated_orbits, ephemeris): # Calculate the difference in RA and Dec angular_diff = np.abs( - ephemeris_orbit_2body.coordinates.values[:, 1:3] - - ephemeris_orbit[["RA", "DEC"]].values + ephemeris_orbit_2body.coordinates.values[:, 1:3] - ephemeris_orbit[["RA", "DEC"]].values ) * (u.deg).to(u.milliarcsecond) # Topocentric difference - range_diff = np.abs( - ephemeris_orbit_2body.coordinates.values[:, 0] - ephemeris_orbit["delta"].values - ) * (u.au).to(u.m) + range_diff = np.abs(ephemeris_orbit_2body.coordinates.values[:, 0] - ephemeris_orbit["delta"].values) * ( + u.au + ).to(u.m) # Assert that the position is less than the tolerance np.testing.assert_array_less(angular_diff, angular_tolerance) diff --git a/adam_core/dynamics/tests/test_kepler.py b/adam_core/dynamics/tests/test_kepler.py index a56bdcd9..c01f6af1 100644 --- a/adam_core/dynamics/tests/test_kepler.py +++ b/adam_core/dynamics/tests/test_kepler.py @@ -25,27 +25,21 @@ def test_calc_mean_anomaly_elliptical(): e = 0.5 M_desired = nu M_actual = calc_mean_anomaly(nu, e) - npt.assert_allclose( - M_actual, M_desired, rtol=RELATIVE_TOLERANCE, atol=ABSOLUTE_TOLERANCE - ) + npt.assert_allclose(M_actual, M_desired, rtol=RELATIVE_TOLERANCE, atol=ABSOLUTE_TOLERANCE) # Apoapsis point nu = np.pi e = 0.5 M_desired = nu M_actual = calc_mean_anomaly(nu, e) - npt.assert_allclose( - M_actual, M_desired, rtol=RELATIVE_TOLERANCE, atol=ABSOLUTE_TOLERANCE - ) + npt.assert_allclose(M_actual, M_desired, rtol=RELATIVE_TOLERANCE, atol=ABSOLUTE_TOLERANCE) # Periapsis point (at 360 degrees) nu = 2 * np.pi e = 0.5 M_desired = 0.0 M_actual = calc_mean_anomaly(nu, e) - npt.assert_allclose( - M_actual, M_desired, rtol=RELATIVE_TOLERANCE, atol=ABSOLUTE_TOLERANCE - ) + npt.assert_allclose(M_actual, M_desired, rtol=RELATIVE_TOLERANCE, atol=ABSOLUTE_TOLERANCE) def test__calc_elliptical_anomalies(): @@ -141,27 +135,21 @@ def test_solve_kepler_elliptical(): M = 0.0 nu_desired = 0.0 nu_actual = solve_kepler(e, M) - npt.assert_allclose( - nu_actual, nu_desired, rtol=RELATIVE_TOLERANCE, atol=ABSOLUTE_TOLERANCE - ) + npt.assert_allclose(nu_actual, nu_desired, rtol=RELATIVE_TOLERANCE, atol=ABSOLUTE_TOLERANCE) # Apoapsis point e = 0.5 M = np.pi nu_desired = np.pi nu_actual = solve_kepler(e, M) - npt.assert_allclose( - nu_actual, nu_desired, rtol=RELATIVE_TOLERANCE, atol=ABSOLUTE_TOLERANCE - ) + npt.assert_allclose(nu_actual, nu_desired, rtol=RELATIVE_TOLERANCE, atol=ABSOLUTE_TOLERANCE) # Periapsis point (at 360 degrees) e = 0.5 M = 2 * np.pi nu_desired = 0.0 nu_actual = solve_kepler(e, M) - npt.assert_allclose( - nu_actual, nu_desired, rtol=RELATIVE_TOLERANCE, atol=ABSOLUTE_TOLERANCE - ) + npt.assert_allclose(nu_actual, nu_desired, rtol=RELATIVE_TOLERANCE, atol=ABSOLUTE_TOLERANCE) def test_solve_kepler_parabolic(): @@ -174,9 +162,7 @@ def test_solve_kepler_parabolic(): M = 0.0 nu_desired = 0.0 nu_actual = solve_kepler(e, M) - npt.assert_allclose( - nu_actual, nu_desired, rtol=RELATIVE_TOLERANCE, atol=ABSOLUTE_TOLERANCE - ) + npt.assert_allclose(nu_actual, nu_desired, rtol=RELATIVE_TOLERANCE, atol=ABSOLUTE_TOLERANCE) def test_solve_kepler_hyperbolic(): @@ -189,9 +175,7 @@ def test_solve_kepler_hyperbolic(): M = 0.0 nu_desired = 0.0 nu_actual = solve_kepler(e, M) - npt.assert_allclose( - nu_actual, nu_desired, rtol=RELATIVE_TOLERANCE, atol=ABSOLUTE_TOLERANCE - ) + npt.assert_allclose(nu_actual, nu_desired, rtol=RELATIVE_TOLERANCE, atol=ABSOLUTE_TOLERANCE) def test_solve_kepler_elliptical_orbits(orbital_elements): diff --git a/adam_core/dynamics/tests/test_propagation.py b/adam_core/dynamics/tests/test_propagation.py index 78f96367..a92b477e 100644 --- a/adam_core/dynamics/tests/test_propagation.py +++ b/adam_core/dynamics/tests/test_propagation.py @@ -21,12 +21,10 @@ def test__propagate_2body_against_spice_elliptical(orbital_elements): dts = np.arange(0, 10000, 10) for t0_i, cartesian_i in zip(t0, cartesian_elements): - spice_propagated = np.empty((len(dts), 6)) cartesian_propagated = np.empty((len(dts), 6)) for j, dt_i in enumerate(dts): - spice_propagated[j] = sp.prop2b(MU, np.ascontiguousarray(cartesian_i), dt_i) cartesian_propagated[j] = _propagate_2body(cartesian_i, t0_i, t0_i + dt_i) @@ -53,12 +51,10 @@ def test__propagate_2body_against_spice_hyperbolic(orbital_elements): dts = np.arange(0, 10000, 10) for t0_i, cartesian_i in zip(t0, cartesian_elements): - spice_propagated = np.empty((len(dts), 6)) cartesian_propagated = np.empty((len(dts), 6)) for j, dt_i in enumerate(dts): - spice_propagated[j] = sp.prop2b(MU, np.ascontiguousarray(cartesian_i), dt_i) cartesian_propagated[j] = _propagate_2body(cartesian_i, t0_i, t0_i + dt_i) @@ -98,9 +94,7 @@ def test_propagate_2body_against_spice_elliptical(orbital_elements): t0, scale="tdb", ), - origin=Origin.from_kwargs( - code=["SUN" for i in range(len(cartesian_elements))] - ), + origin=Origin.from_kwargs(code=["SUN" for i in range(len(cartesian_elements))]), frame="ecliptic", ), ) @@ -115,15 +109,12 @@ def test_propagate_2body_against_spice_elliptical(orbital_elements): spice_propagated = [] times_mjd = times.mjd() for i, cartesian_i in enumerate(cartesian_elements): - # Calculate dts from t0 for this orbit (each orbit's t0 is different) # but the final times we are propagating to are the same for all orbits dts = times_mjd - t0[i] spice_propagated_i = np.empty((len(dts), 6)) for j, dt_i in enumerate(dts): - spice_propagated_i[j] = sp.prop2b( - MU, np.ascontiguousarray(cartesian_i), dt_i - ) + spice_propagated_i[j] = sp.prop2b(MU, np.ascontiguousarray(cartesian_i), dt_i) spice_propagated.append(spice_propagated_i) @@ -168,9 +159,7 @@ def test_propagate_2body_against_spice_hyperbolic(orbital_elements): t0, scale="tdb", ), - origin=Origin.from_kwargs( - code=["SUN" for i in range(len(cartesian_elements))] - ), + origin=Origin.from_kwargs(code=["SUN" for i in range(len(cartesian_elements))]), frame="ecliptic", ), ) @@ -185,15 +174,12 @@ def test_propagate_2body_against_spice_hyperbolic(orbital_elements): spice_propagated = [] times_mjd = times.mjd() for i, cartesian_i in enumerate(cartesian_elements): - # Calculate dts from t0 for this orbit (each orbit's t0 is different) # but the final times we are propagating to are the same for all orbits dts = times_mjd - t0[i] spice_propagated_i = np.empty((len(dts), 6)) for j, dt_i in enumerate(dts): - spice_propagated_i[j] = sp.prop2b( - MU, np.ascontiguousarray(cartesian_i), dt_i - ) + spice_propagated_i[j] = sp.prop2b(MU, np.ascontiguousarray(cartesian_i), dt_i) spice_propagated.append(spice_propagated_i) @@ -265,9 +251,7 @@ def test_benchmark_propagate_2body(benchmark, orbital_elements): t0, scale="tdb", ), - origin=Origin.from_kwargs( - code=["SUN" for i in range(len(cartesian_elements))] - ), + origin=Origin.from_kwargs(code=["SUN" for i in range(len(cartesian_elements))]), frame="ecliptic", ), ) diff --git a/adam_core/observations/associations.py b/adam_core/observations/associations.py index da0d48e3..17151cd0 100644 --- a/adam_core/observations/associations.py +++ b/adam_core/observations/associations.py @@ -9,7 +9,6 @@ class Associations(qv.Table): - detection_id = qv.StringColumn() object_id = qv.StringColumn(nullable=True) diff --git a/adam_core/observations/detections.py b/adam_core/observations/detections.py index a0b47d12..12aca169 100644 --- a/adam_core/observations/detections.py +++ b/adam_core/observations/detections.py @@ -70,9 +70,7 @@ def group_by_healpixel( mask = pyarrow.compute.equal(healpixels, healpixel) yield (healpixel, self.apply_mask(mask)) - def link_to_exposures( - self, exposures: Exposures - ) -> qv.Linkage[PointSourceDetections, Exposures]: + def link_to_exposures(self, exposures: Exposures) -> qv.Linkage[PointSourceDetections, Exposures]: """ Links the detections to the exposures. """ diff --git a/adam_core/observations/exposures.py b/adam_core/observations/exposures.py index 0ec653ba..45d6a48b 100644 --- a/adam_core/observations/exposures.py +++ b/adam_core/observations/exposures.py @@ -55,9 +55,7 @@ def observers( indices_for_code = pc.indices_nonzero(mask) times_for_code = exposures_for_code.midpoint() - coords_for_code = state.get_observer_state( - code, times_for_code, frame=frame, origin=origin - ) + coords_for_code = state.get_observer_state(code, times_for_code, frame=frame, origin=origin) coords.append(coords_for_code) indices.append(indices_for_code) diff --git a/adam_core/observations/tests/test_detections.py b/adam_core/observations/tests/test_detections.py index ca9f96d6..c86e2a2a 100644 --- a/adam_core/observations/tests/test_detections.py +++ b/adam_core/observations/tests/test_detections.py @@ -47,9 +47,7 @@ def test_detections_link_to_exposures(): def test_detection_healpixels(): - ra, dec = healpy.pixelfunc.pix2ang( - nside=16, ipix=[1, 2, 3, 4, 5], nest=True, lonlat=True - ) + ra, dec = healpy.pixelfunc.pix2ang(nside=16, ipix=[1, 2, 3, 4, 5], nest=True, lonlat=True) det = PointSourceDetections.from_kwargs( id=["d1", "d2", "d3", "d4", "d5"], exposure_id=["e1", "e1", "e2", "e1", "e2"], @@ -68,9 +66,7 @@ def test_detection_healpixels(): def test_detection_group_by_healpixel(): healpixels = [3, 1, 1, 2, 1, 3, 1, 2] ids = ["d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8"] - ra, dec = healpy.pixelfunc.pix2ang( - nside=16, ipix=healpixels, nest=True, lonlat=True - ) + ra, dec = healpy.pixelfunc.pix2ang(nside=16, ipix=healpixels, nest=True, lonlat=True) det = PointSourceDetections.from_kwargs( id=ids, exposure_id=[""] * 8, diff --git a/adam_core/observations/tests/test_exposures.py b/adam_core/observations/tests/test_exposures.py index b55ce504..b143bdc8 100644 --- a/adam_core/observations/tests/test_exposures.py +++ b/adam_core/observations/tests/test_exposures.py @@ -25,27 +25,16 @@ def test_exposure_midpoints(): ) midpoints = exp.midpoint() - assert midpoints == Timestamp.from_iso8601( - ["2000-01-01T00:00:30", "2000-01-02T00:00:15"] - ) + assert midpoints == Timestamp.from_iso8601(["2000-01-01T00:00:30", "2000-01-02T00:00:15"]) def test_exposure_states(): observer_state_dir = ( - pathlib.Path(os.path.dirname(__file__)) - / ".." - / ".." - / "observers" - / "tests" - / "testdata" + pathlib.Path(os.path.dirname(__file__)) / ".." / ".." / "observers" / "tests" / "testdata" ) - w84_state_data = CartesianCoordinates.from_parquet( - observer_state_dir / "W84_sun.parquet" - ) - i41_state_data = CartesianCoordinates.from_parquet( - observer_state_dir / "I41_sun.parquet" - ) + w84_state_data = CartesianCoordinates.from_parquet(observer_state_dir / "W84_sun.parquet") + i41_state_data = CartesianCoordinates.from_parquet(observer_state_dir / "I41_sun.parquet") # Mix up w84 and i41 in one big exposure table codes = ["W84", "I41", "W84", "I41", "W84"] @@ -88,24 +77,12 @@ def test_exposure_states(): # precision. That would require extremely careful numerical # analysis, though. The current values of maxulp are just # empirical. - np.testing.assert_array_max_ulp( - expected.x.to_numpy(), states.x.to_numpy(), dtype=np.float32 - ) - np.testing.assert_array_max_ulp( - expected.y.to_numpy(), states.y.to_numpy(), dtype=np.float32 - ) - np.testing.assert_array_max_ulp( - expected.z.to_numpy(), states.z.to_numpy(), maxulp=64, dtype=np.float32 - ) - np.testing.assert_array_max_ulp( - expected.vx.to_numpy(), states.vx.to_numpy(), dtype=np.float32 - ) - np.testing.assert_array_max_ulp( - expected.vy.to_numpy(), states.vy.to_numpy(), maxulp=2, dtype=np.float32 - ) - np.testing.assert_array_max_ulp( - expected.vz.to_numpy(), states.vz.to_numpy(), maxulp=22, dtype=np.float32 - ) + np.testing.assert_array_max_ulp(expected.x.to_numpy(), states.x.to_numpy(), dtype=np.float32) + np.testing.assert_array_max_ulp(expected.y.to_numpy(), states.y.to_numpy(), dtype=np.float32) + np.testing.assert_array_max_ulp(expected.z.to_numpy(), states.z.to_numpy(), maxulp=64, dtype=np.float32) + np.testing.assert_array_max_ulp(expected.vx.to_numpy(), states.vx.to_numpy(), dtype=np.float32) + np.testing.assert_array_max_ulp(expected.vy.to_numpy(), states.vy.to_numpy(), maxulp=2, dtype=np.float32) + np.testing.assert_array_max_ulp(expected.vz.to_numpy(), states.vz.to_numpy(), maxulp=22, dtype=np.float32) np.testing.assert_allclose(expected.x.to_numpy(), states.x.to_numpy()) np.testing.assert_allclose(expected.y.to_numpy(), states.y.to_numpy()) diff --git a/adam_core/observers/observers.py b/adam_core/observers/observers.py index ab738be1..72d8a0be 100644 --- a/adam_core/observers/observers.py +++ b/adam_core/observers/observers.py @@ -43,9 +43,7 @@ class ObservatoryGeodetics(qv.Table): name=OBSCODES["Name"].values, ) -OBSERVATORY_CODES = { - x for x in OBSERVATORY_GEODETICS.code.to_numpy(zero_copy_only=False) -} +OBSERVATORY_CODES = {x for x in OBSERVATORY_GEODETICS.code.to_numpy(zero_copy_only=False)} class Observers(qv.Table): diff --git a/adam_core/observers/state.py b/adam_core/observers/state.py index 53816db0..0231e0cd 100644 --- a/adam_core/observers/state.py +++ b/adam_core/observers/state.py @@ -77,9 +77,7 @@ def get_observer_state( # Get observatory geodetic information geodetics = OBSERVATORY_GEODETICS.select("code", code) if len(geodetics) == 0: - raise ValueError( - f"Observatory code '{code}' not found in the observatory geodetics table." - ) + raise ValueError(f"Observatory code '{code}' not found in the observatory geodetics table.") geodetics = geodetics.table.to_pylist()[0] # Unpack geodetic information @@ -96,9 +94,7 @@ def get_observer_state( raise ValueError(err) # Grab Earth state vector (this function handles duplicate times) - state = get_perturber_state( - OriginCodes.EARTH, times, frame=frame, origin=origin - ) + state = get_perturber_state(OriginCodes.EARTH, times, frame=frame, origin=origin) # If the code is 500 (geocenter), we can just return the Earth state vector if code == "500": @@ -111,9 +107,7 @@ def get_observer_state( cos_longitude = np.cos(np.radians(longitude)) # Calculate pointing vector from geocenter to observatory - o_hat_ITRF93 = np.array( - [cos_longitude * cos_phi, sin_longitude * cos_phi, sin_phi] - ) + o_hat_ITRF93 = np.array([cos_longitude * cos_phi, sin_longitude * cos_phi, sin_phi]) # Multiply pointing vector with Earth radius to get actual vector o_vec_ITRF93 = np.dot(R_EARTH, o_hat_ITRF93) @@ -145,9 +139,7 @@ def get_observer_state( # Calculate the velocity (thank you numpy broadcasting) rotation_direction = np.cross(o_hat_ITRF93, Z_AXIS) - v_obs[mask] = v_geo[mask] + rotation_matrix @ ( - -OMEGA_EARTH * R_EARTH * rotation_direction - ) + v_obs[mask] = v_geo[mask] + rotation_matrix @ (-OMEGA_EARTH * R_EARTH * rotation_direction) return CartesianCoordinates.from_kwargs( time=times, diff --git a/adam_core/observers/tests/test_benchmarks.py b/adam_core/observers/tests/test_benchmarks.py index 61c90498..fc00e9ef 100644 --- a/adam_core/observers/tests/test_benchmarks.py +++ b/adam_core/observers/tests/test_benchmarks.py @@ -12,9 +12,7 @@ ids=lambda x: f"times={x},", ) @pytest.mark.parametrize("code", ["X05", "500"], ids=lambda x: f"code={x},") -@pytest.mark.parametrize( - "frame", ["equatorial", "ecliptic"], ids=lambda x: f"frame={x}," -) +@pytest.mark.parametrize("frame", ["equatorial", "ecliptic"], ids=lambda x: f"frame={x},") @pytest.mark.parametrize( "origin", [OriginCodes.SUN, OriginCodes.SOLAR_SYSTEM_BARYCENTER], diff --git a/adam_core/observers/tests/test_state.py b/adam_core/observers/tests/test_state.py index f58d5997..85a50806 100644 --- a/adam_core/observers/tests/test_state.py +++ b/adam_core/observers/tests/test_state.py @@ -26,7 +26,6 @@ def test_get_observer_state_OriginCodes(): OriginCodes.JUPITER_BARYCENTER, ] for code in codes: - times = Timestamp.from_mjd(np.arange(59000, 60000), scale="tdb") perturber_state = get_perturber_state( code, times, frame="ecliptic", origin=OriginCodes.SOLAR_SYSTEM_BARYCENTER @@ -75,9 +74,7 @@ def test_get_observer_state(code, origin): # Calculate the offset in position in meters r_offset = np.linalg.norm(residual_values[:, :3], axis=1) * KM_P_AU * 1000 # Calculate the offset in velocity in mm/s - v_offset = ( - np.linalg.norm(residual_values[:, 3:], axis=1) * KM_P_AU / S_P_DAY * 1000000 - ) + v_offset = np.linalg.norm(residual_values[:, 3:], axis=1) * KM_P_AU / S_P_DAY * 1000000 np.testing.assert_array_less(r_offset, expected_precision[code]["r"]) np.testing.assert_array_less(v_offset, expected_precision[code]["v"]) diff --git a/adam_core/observers/tests/testdata/get_states.py b/adam_core/observers/tests/testdata/get_states.py index 861e4ca4..2af5a2d4 100644 --- a/adam_core/observers/tests/testdata/get_states.py +++ b/adam_core/observers/tests/testdata/get_states.py @@ -19,9 +19,7 @@ location=code, epochs={"start": "2013-01-01", "stop": "2023-01-01", "step": "10d"}, ) - result = horizons.vectors( - refplane="ecliptic", aberrations="geometric" - ).to_pandas() + result = horizons.vectors(refplane="ecliptic", aberrations="geometric").to_pandas() # Flip the signs of the state to get the state of the observer states = CartesianCoordinates.from_kwargs( diff --git a/adam_core/orbits/ephemeris.py b/adam_core/orbits/ephemeris.py index 705ddf92..5aeb8558 100644 --- a/adam_core/orbits/ephemeris.py +++ b/adam_core/orbits/ephemeris.py @@ -5,7 +5,6 @@ class Ephemeris(qv.Table): - orbit_id = qv.StringColumn() object_id = qv.StringColumn(nullable=True) coordinates = SphericalCoordinates.as_column() diff --git a/adam_core/orbits/orbits.py b/adam_core/orbits/orbits.py index d380c47a..02650d94 100644 --- a/adam_core/orbits/orbits.py +++ b/adam_core/orbits/orbits.py @@ -11,7 +11,6 @@ class Orbits(qv.Table): - orbit_id = qv.StringColumn(default=lambda: uuid.uuid4().hex) object_id = qv.StringColumn(nullable=True) coordinates = CartesianCoordinates.as_column() diff --git a/adam_core/orbits/query/horizons.py b/adam_core/orbits/query/horizons.py index 36ef81ec..9a306bab 100644 --- a/adam_core/orbits/query/horizons.py +++ b/adam_core/orbits/query/horizons.py @@ -57,9 +57,7 @@ def _get_horizons_vectors( location=location, id_type=id_type, ) - vectors = obj.vectors( - refplane=refplane, aberrations=aberrations, cache=False - ).to_pandas() + vectors = obj.vectors(refplane=refplane, aberrations=aberrations, cache=False).to_pandas() vectors.insert(0, "orbit_id", f"{i:05d}") dfs.append(vectors) @@ -185,9 +183,7 @@ def _get_horizons_ephemeris( return ephemeris -def query_horizons_ephemeris( - object_ids: Union[List, npt.ArrayLike], observers: Observers -) -> pd.DataFrame: +def query_horizons_ephemeris(object_ids: Union[List, npt.ArrayLike], observers: Observers) -> pd.DataFrame: """ Query JPL Horizons (through astroquery) for an object's predicted ephemeris as seen from a given location at the given times. @@ -284,9 +280,7 @@ def query_horizons( orbit_id = vectors["orbit_id"].values object_id = vectors["targetname"].values - return Orbits.from_kwargs( - orbit_id=orbit_id, object_id=object_id, coordinates=coordinates - ) + return Orbits.from_kwargs(orbit_id=orbit_id, object_id=object_id, coordinates=coordinates) elif coordinate_type == "keplerian": elements = _get_horizons_elements( diff --git a/adam_core/orbits/query/sbdb.py b/adam_core/orbits/query/sbdb.py index 983a2b36..09f4c3c7 100644 --- a/adam_core/orbits/query/sbdb.py +++ b/adam_core/orbits/query/sbdb.py @@ -35,43 +35,31 @@ def _convert_SBDB_covariances( covariances[:, 0, 0] = sbdb_covariances[:, 1, 1] # sigma_qq covariances[:, 1, 0] = covariances[:, 0, 1] = sbdb_covariances[:, 0, 1] # sigma_qe covariances[:, 2, 0] = covariances[:, 0, 2] = sbdb_covariances[:, 5, 1] # sigma_qi - covariances[:, 3, 0] = covariances[:, 0, 3] = sbdb_covariances[ - :, 3, 1 - ] # sigma_qraan + covariances[:, 3, 0] = covariances[:, 0, 3] = sbdb_covariances[:, 3, 1] # sigma_qraan covariances[:, 4, 0] = covariances[:, 0, 4] = sbdb_covariances[:, 4, 1] # sigma_qap covariances[:, 5, 0] = covariances[:, 0, 5] = sbdb_covariances[:, 2, 1] # sigma_qtp # sigma_e{x} covariances[:, 1, 1] = sbdb_covariances[:, 0, 0] # sigma_ee covariances[:, 2, 1] = covariances[:, 1, 2] = sbdb_covariances[:, 5, 0] # sigma_ei - covariances[:, 3, 1] = covariances[:, 1, 3] = sbdb_covariances[ - :, 3, 0 - ] # sigma_eraan + covariances[:, 3, 1] = covariances[:, 1, 3] = sbdb_covariances[:, 3, 0] # sigma_eraan covariances[:, 4, 1] = covariances[:, 1, 4] = sbdb_covariances[:, 4, 0] # sigma_eap covariances[:, 5, 1] = covariances[:, 1, 5] = sbdb_covariances[:, 2, 0] # sigma_etp # sigma_i{x} covariances[:, 2, 2] = sbdb_covariances[:, 5, 5] # sigma_ii - covariances[:, 3, 2] = covariances[:, 2, 3] = sbdb_covariances[ - :, 3, 5 - ] # sigma_iraan + covariances[:, 3, 2] = covariances[:, 2, 3] = sbdb_covariances[:, 3, 5] # sigma_iraan covariances[:, 4, 2] = covariances[:, 2, 4] = sbdb_covariances[:, 4, 5] # sigma_iap covariances[:, 5, 2] = covariances[:, 2, 5] = sbdb_covariances[:, 2, 5] # sigma_itp # sigma_raan{x} covariances[:, 3, 3] = sbdb_covariances[:, 3, 3] # sigma_raanraan - covariances[:, 4, 3] = covariances[:, 3, 4] = sbdb_covariances[ - :, 4, 3 - ] # sigma_raanap - covariances[:, 5, 3] = covariances[:, 3, 5] = sbdb_covariances[ - :, 2, 3 - ] # sigma_raantp + covariances[:, 4, 3] = covariances[:, 3, 4] = sbdb_covariances[:, 4, 3] # sigma_raanap + covariances[:, 5, 3] = covariances[:, 3, 5] = sbdb_covariances[:, 2, 3] # sigma_raantp # sigma_ap{x} covariances[:, 4, 4] = sbdb_covariances[:, 4, 4] # sigma_apap - covariances[:, 5, 4] = covariances[:, 4, 5] = sbdb_covariances[ - :, 2, 4 - ] # sigma_aptp + covariances[:, 5, 4] = covariances[:, 4, 5] = sbdb_covariances[:, 2, 4] # sigma_aptp # sigma_tp{x} covariances[:, 5, 5] = sbdb_covariances[:, 2, 2] # sigma_tptp @@ -202,9 +190,7 @@ def query_sbdb(ids: npt.ArrayLike) -> Orbits: coords_cometary[i, 2] = elements["i"].value coords_cometary[i, 3] = elements["om"].value coords_cometary[i, 4] = elements["w"].value - coords_cometary[i, 5] = ( - Timestamp.from_jd([elements["tp"].value], scale="tdb").mjd()[0].as_py() - ) + coords_cometary[i, 5] = Timestamp.from_jd([elements["tp"].value], scale="tdb").mjd()[0].as_py() covariances_cometary = _convert_SBDB_covariances(covariances_sbdb) times = Timestamp.from_jd(times, scale="tdb") diff --git a/adam_core/orbits/query/tests/__init__.py b/adam_core/orbits/query/tests/__init__.py index 47a20e63..f4448a62 100644 --- a/adam_core/orbits/query/tests/__init__.py +++ b/adam_core/orbits/query/tests/__init__.py @@ -36,8 +36,6 @@ def test_convert_SBDB_covariances(): flip_mask = np.where(cometary_covariances != adam_format) for i, j, k in zip(*flip_mask): - cometary_covariances[i, j, k] = "_".join( - cometary_covariances[i, j, k].split("_")[::-1] - ) + cometary_covariances[i, j, k] = "_".join(cometary_covariances[i, j, k].split("_")[::-1]) npt.assert_equal(cometary_covariances, adam_format) diff --git a/adam_core/orbits/query/tests/test_sbdb.py b/adam_core/orbits/query/tests/test_sbdb.py index 1c5e7dfc..a146b394 100644 --- a/adam_core/orbits/query/tests/test_sbdb.py +++ b/adam_core/orbits/query/tests/test_sbdb.py @@ -44,9 +44,7 @@ def test__convert_SBDB_covariances(): flip_mask = np.where(cometary_covariances != adam_core_format) for i, j, k in zip(*flip_mask): - cometary_covariances[i, j, k] = "_".join( - cometary_covariances[i, j, k].split("_")[::-1] - ) + cometary_covariances[i, j, k] = "_".join(cometary_covariances[i, j, k].split("_")[::-1]) npt.assert_equal(cometary_covariances, adam_core_format) @@ -98,9 +96,7 @@ def test_query_sbdb_for_missing_value(): @contextmanager def mock_sbdb_query(response_file: str): with patch("adam_core.orbits.query.sbdb.SBDB.query") as mock_sbdb_query: - resp_path = os.path.join( - os.path.dirname(__file__), "testdata", "sbdb", response_file - ) + resp_path = os.path.join(os.path.dirname(__file__), "testdata", "sbdb", response_file) response_dict = json.load(open(resp_path, "r")) response_value = SBDB()._process_data(OrderedDict(response_dict)) mock_sbdb_query.return_value = response_value diff --git a/adam_core/orbits/tests/test_orbits.py b/adam_core/orbits/tests/test_orbits.py index 9f730b2b..eb2f7a17 100644 --- a/adam_core/orbits/tests/test_orbits.py +++ b/adam_core/orbits/tests/test_orbits.py @@ -18,9 +18,7 @@ def test_orbits__init__(): frame="ecliptic", ) - orbits = Orbits.from_kwargs( - coordinates=coordinates, orbit_id=["1"], object_id=["Test Orbit"] - ) + orbits = Orbits.from_kwargs(coordinates=coordinates, orbit_id=["1"], object_id=["Test Orbit"]) assert orbits.orbit_id[0].as_py() == "1" assert orbits.object_id[0].as_py() == "Test Orbit" diff --git a/adam_core/orbits/tests/test_variants.py b/adam_core/orbits/tests/test_variants.py index fef3a887..5561b343 100644 --- a/adam_core/orbits/tests/test_variants.py +++ b/adam_core/orbits/tests/test_variants.py @@ -5,7 +5,6 @@ def test_VariantOrbits(): - # Get a sample of real orbits orbits = make_real_orbits(10) diff --git a/adam_core/orbits/variants.py b/adam_core/orbits/variants.py index 7f872b01..25974787 100644 --- a/adam_core/orbits/variants.py +++ b/adam_core/orbits/variants.py @@ -11,7 +11,6 @@ class VariantOrbits(qv.Table): - orbit_id = qv.StringColumn(default=lambda: uuid.uuid4().hex) object_id = qv.StringColumn(nullable=True) weights = qv.Float64Column(nullable=True) @@ -79,9 +78,7 @@ def create( coordinates=variant_coordinates.sample, ) - def link_to_orbits( - self, orbits: Orbits - ) -> qv.MultiKeyLinkage[Orbits, "VariantOrbits"]: + def link_to_orbits(self, orbits: Orbits) -> qv.MultiKeyLinkage[Orbits, "VariantOrbits"]: """ Link variants to the orbits from which they were generated. @@ -147,9 +144,7 @@ def collapse(self, orbits: Orbits) -> Orbits: samples = variants.coordinates.values mean = orbit.coordinates.values[0] - covariance = weighted_covariance( - mean, samples, variants.weights_cov.to_numpy() - ).reshape(1, 6, 6) + covariance = weighted_covariance(mean, samples, variants.weights_cov.to_numpy()).reshape(1, 6, 6) orbit_collapsed = orbit.set_column( "coordinates.covariance", CoordinateCovariances.from_matrix(covariance) diff --git a/adam_core/propagator/propagator.py b/adam_core/propagator/propagator.py index 0bd7b36a..68b2dc0c 100644 --- a/adam_core/propagator/propagator.py +++ b/adam_core/propagator/propagator.py @@ -17,9 +17,7 @@ OrbitType = Union[Orbits, VariantOrbits] -def propagation_worker( - orbits: OrbitType, times: Timestamp, propagator: "Propagator" -) -> Orbits: +def propagation_worker(orbits: OrbitType, times: Timestamp, propagator: "Propagator") -> Orbits: propagated = propagator._propagate_orbits(orbits, times) return propagated @@ -93,25 +91,16 @@ def propagate_orbits( variants = None if max_processes is None or max_processes > 1: - with concurrent.futures.ProcessPoolExecutor( - max_workers=max_processes - ) as executor: - + with concurrent.futures.ProcessPoolExecutor(max_workers=max_processes) as executor: # Add orbits to propagate to futures futures = [] for orbit_chunk in _iterate_chunks(orbits, chunk_size): - futures.append( - executor.submit(propagation_worker, orbit_chunk, times, self) - ) + futures.append(executor.submit(propagation_worker, orbit_chunk, times, self)) # Add variants to propagate to futures if variants is not None: for variant_chunk in _iterate_chunks(variants, chunk_size): - futures.append( - executor.submit( - propagation_worker, variant_chunk, times, self - ) - ) + futures.append(executor.submit(propagation_worker, variant_chunk, times, self)) propagated_list: List[Orbits] = [] variants_list: List[VariantOrbits] = [] @@ -122,9 +111,7 @@ def propagate_orbits( elif isinstance(result, VariantOrbits): variants_list.append(result) else: - raise ValueError( - f"Unexpected result type from propagation worker: {type(result)}" - ) + raise ValueError(f"Unexpected result type from propagation worker: {type(result)}") propagated = qv.concatenate(propagated_list) if len(variants_list) > 0: @@ -191,14 +178,10 @@ def generate_ephemeris( observer. """ if max_processes is None or max_processes > 1: - with concurrent.futures.ProcessPoolExecutor( - max_workers=max_processes - ) as executor: + with concurrent.futures.ProcessPoolExecutor(max_workers=max_processes) as executor: futures = [] for orbit_chunk in _iterate_chunks(orbits, chunk_size): - futures.append( - executor.submit(ephemeris_worker, orbit_chunk, observers, self) - ) + futures.append(executor.submit(ephemeris_worker, orbit_chunk, observers, self)) ephemeris_list = [] for future in concurrent.futures.as_completed(futures): diff --git a/adam_core/propagator/pyoorb.py b/adam_core/propagator/pyoorb.py index 24316851..9b0e9ab5 100644 --- a/adam_core/propagator/pyoorb.py +++ b/adam_core/propagator/pyoorb.py @@ -37,10 +37,7 @@ class OpenOrbOrbitType(enum.Enum): class PYOORB(Propagator): - def __init__( - self, *, dynamical_model: str = "N", ephemeris_file: str = "de430.dat" - ): - + def __init__(self, *, dynamical_model: str = "N", ephemeris_file: str = "de430.dat"): self.dynamical_model = dynamical_model self.ephemeris_file = ephemeris_file @@ -54,9 +51,7 @@ def __init__( "Cannot find OORB_DATA directory. Please set the OORB_DATA environment variable." ) else: - os.environ["OORB_DATA"] = os.path.join( - os.environ["CONDA_PREFIX"], "share/openorb" - ) + os.environ["OORB_DATA"] = os.path.join(os.environ["CONDA_PREFIX"], "share/openorb") oorb_data = os.environ["OORB_DATA"] @@ -169,9 +164,7 @@ def _configure_orbits( return orbits_pyoorb @staticmethod - def _configure_epochs( - epochs: np.ndarray, time_scale: OpenOrbTimescale - ) -> np.ndarray: + def _configure_epochs(epochs: np.ndarray, time_scale: OpenOrbTimescale) -> np.ndarray: """ Convert an array of times into the format expected by PYOORB. @@ -189,9 +182,7 @@ def _configure_epochs( """ num_times = len(epochs) time_scale_list = [time_scale.value for i in range(num_times)] - epochs_pyoorb = np.array( - list(np.vstack([epochs, time_scale_list]).T), dtype=np.double, order="F" - ) + epochs_pyoorb = np.array(list(np.vstack([epochs, time_scale_list]).T), dtype=np.double, order="F") return epochs_pyoorb def _propagate_orbits(self, orbits: OrbitType, times: Timestamp) -> OrbitType: @@ -221,9 +212,7 @@ def _propagate_orbits(self, orbits: OrbitType, times: Timestamp) -> OrbitType: ) # Convert epochs into PYOORB format - epochs_pyoorb = self._configure_epochs( - times.rescale("tt").mjd(), OpenOrbTimescale.TT - ) + epochs_pyoorb = self._configure_epochs(times.rescale("tt").mjd(), OpenOrbTimescale.TT) # Propagate orbits to each epoch and append to list # of new states @@ -263,9 +252,7 @@ def _propagate_orbits(self, orbits: OrbitType, times: Timestamp) -> OrbitType: # Check to make sure the desired times are within 1 microsecond # of the times returned by PYOORB - _assert_times_almost_equal( - mjd_tt, np.repeat(epochs_pyoorb[:, 0], len(orbits)), tolerance=0.001 - ) + _assert_times_almost_equal(mjd_tt, np.repeat(epochs_pyoorb[:, 0], len(orbits)), tolerance=0.001) # Convert output epochs to TDB times_ = Timestamp.from_mjd(mjd_tt, scale="tt").rescale("tdb") @@ -292,7 +279,6 @@ def _propagate_orbits(self, orbits: OrbitType, times: Timestamp) -> OrbitType: ) elif isinstance(orbits, VariantOrbits): - # Map the object and orbit IDs back to the input arrays object_ids = orbits.object_id.to_numpy(zero_copy_only=False)[orbit_ids_] orbit_ids = orbits.orbit_id.to_numpy(zero_copy_only=False)[orbit_ids_] @@ -385,9 +371,7 @@ def _generate_ephemeris( ) if err != 0: - raise RuntimeError( - f"PYOORB ephemeris generation failed with error code {err}." - ) + raise RuntimeError(f"PYOORB ephemeris generation failed with error code {err}.") # Stack 3D ephemeris into single 2D array ephemeris = np.vstack(ephemeris) diff --git a/adam_core/propagator/utils.py b/adam_core/propagator/utils.py index fee6042c..bd3eec70 100644 --- a/adam_core/propagator/utils.py +++ b/adam_core/propagator/utils.py @@ -32,9 +32,7 @@ def _iterate_chunks(iterable: Sequence, chunk_size: int) -> Iterable: yield iterable[i : i + chunk_size] -def _assert_times_almost_equal( - have: np.ndarray, want: np.ndarray, tolerance: float = 0.1 -): +def _assert_times_almost_equal(have: np.ndarray, want: np.ndarray, tolerance: float = 0.1): """ Raises a ValueError if the time arrays (in units of days such as MJD) are not within the tolerance in milliseconds of each other. diff --git a/adam_core/time/tests/test_time.py b/adam_core/time/tests/test_time.py index 2639cbc9..089e3124 100644 --- a/adam_core/time/tests/test_time.py +++ b/adam_core/time/tests/test_time.py @@ -14,7 +14,6 @@ class Wrapper(qv.Table): class TestTimeUnits: - ts = Timestamp.from_kwargs( days=[0, 10000, 20000], nanos=[0, 1_000_000_000, 2_000_000_000], @@ -156,7 +155,6 @@ def test_roundtrip_second_precision(self): class TestTimeMath: - t1 = Timestamp.from_kwargs( days=[0, 50000, 60000], nanos=[0, 43200_000_000_000, 86400_000_000_000 - 1], @@ -412,7 +410,7 @@ def test_difference_scalar(self): {"in_days": 2, "in_nanos": 200, "out_days": 1, "out_nanos": 100}, ] - for (i, c) in enumerate(cases): + for i, c in enumerate(cases): t1 = Timestamp.from_kwargs( days=[c["in_days"]], nanos=[c["in_nanos"]], @@ -494,9 +492,7 @@ def test_one(self): assert have.nanos.to_pylist() == [2] def test_multple(self): - t = Timestamp.from_kwargs( - days=[1, 1, 2, 2, 1, 1], nanos=[2, 3, 4, 5, 2, 3], scale="tdb" - ) + t = Timestamp.from_kwargs(days=[1, 1, 2, 2, 1, 1], nanos=[2, 3, 4, 5, 2, 3], scale="tdb") have = t.unique() assert have.scale == "tdb" assert len(have) == 4 diff --git a/adam_core/time/time.py b/adam_core/time/time.py index 4204ba11..024f625e 100644 --- a/adam_core/time/time.py +++ b/adam_core/time/time.py @@ -59,9 +59,7 @@ def to_numpy(self) -> np.ndarray: return self.rescale("tdb").mjd().to_numpy(False) @classmethod - def from_iso8601( - cls, iso: pa.lib.StringArray | list[str], scale="utc" - ) -> Timestamp: + def from_iso8601(cls, iso: pa.lib.StringArray | list[str], scale="utc") -> Timestamp: """ Create a Timestamp from ISO 8601 strings (for example, '2020-01-02T14:15:16'). """ @@ -102,9 +100,7 @@ def equals(self, other: Timestamp, precision: str = "ns") -> pa.BooleanArray: else: return self.equals_array(other, precision) - def equals_scalar( - self, days: int, nanos: int, precision: str = "ns" - ) -> pa.BooleanArray: + def equals_scalar(self, days: int, nanos: int, precision: str = "ns") -> pa.BooleanArray: delta_days, delta_nanos = self.difference_scalar(days, nanos) if precision == "ns": max_deviation = 0 @@ -215,9 +211,7 @@ def to_astropy(self) -> astropy.time.Time: scale=self.scale, ) - def add_nanos( - self, nanos: pa.lib.Int64Array | int, check_range: bool = True - ) -> Timestamp: + def add_nanos(self, nanos: pa.lib.Int64Array | int, check_range: bool = True) -> Timestamp: """ Add nanoseconds to the timestamp. Negative nanoseconds are allowed. @@ -236,18 +230,14 @@ def add_nanos( if not -86400e9 <= nanos < 86400e9: raise ValueError("Nanoseconds out of range") else: - if not pc.all( - pc.and_(pc.greater_equal(nanos, -86400e9), pc.less(nanos, 86400e9)) - ).as_py(): + if not pc.all(pc.and_(pc.greater_equal(nanos, -86400e9), pc.less(nanos, 86400e9))).as_py(): raise ValueError("Nanoseconds out of range") nanos = pc.add_checked(self.nanos, nanos) overflows = pc.greater_equal(nanos, 86400 * 1e9) underflows = pc.less(nanos, 0) - mask = pa.StructArray.from_arrays( - [overflows, underflows], names=["overflows", "underflows"] - ) + mask = pa.StructArray.from_arrays([overflows, underflows], names=["overflows", "underflows"]) nanos = pc.case_when( mask, pc.subtract(nanos, int(86400 * 1e9)), @@ -265,9 +255,7 @@ def add_nanos( v2 = v1.set_column("nanos", nanos) return v2 - def add_seconds( - self, seconds: pa.lib.Int64Array | int | pa.DoubleArray | float - ) -> Timestamp: + def add_seconds(self, seconds: pa.lib.Int64Array | int | pa.DoubleArray | float) -> Timestamp: """ Add seconds to the timestamp. Negative seconds are supported. @@ -335,9 +323,7 @@ def add_days(self, days: pa.lib.Int64Array | int) -> Timestamp: """ return self.set_column("days", pc.add(self.days, days)) - def add_fractional_days( - self, fractional_days: pa.lib.DoubleArray | float - ) -> Timestamp: + def add_fractional_days(self, fractional_days: pa.lib.DoubleArray | float) -> Timestamp: """ Add fractional days to the timestamp. @@ -355,9 +341,7 @@ def add_fractional_days( return self.add_days(days).add_nanos(nanos) - def difference_scalar( - self, days: int, nanos: int - ) -> tuple[pa.Int64Array, pa.Int64Array]: + def difference_scalar(self, days: int, nanos: int) -> tuple[pa.Int64Array, pa.Int64Array]: """ Compute the difference between this timestamp and a scalar timestamp. @@ -392,9 +376,7 @@ def difference_scalar( nanos1 = pc.subtract(self.nanos, nanos) overflows = pc.greater_equal(nanos1, 86400 * 1e9) underflows = pc.less(nanos1, 0) - mask = pa.StructArray.from_arrays( - [overflows, underflows], names=["overflows", "underflows"] - ) + mask = pa.StructArray.from_arrays([overflows, underflows], names=["overflows", "underflows"]) nanos2 = pc.case_when( mask, pc.subtract(nanos1, int(86400 * 1e9)), @@ -414,17 +396,13 @@ def difference(self, other: Timestamp) -> tuple[pa.Int64Array, pa.Int64Array]: Compute the element-wise difference between this timestamp and another. """ if self.scale != other.scale: - raise ValueError( - "Cannot compute difference between timestamps with different scales" - ) + raise ValueError("Cannot compute difference between timestamps with different scales") days1 = pc.subtract(self.days, other.days) nanos1 = pc.subtract(self.nanos, other.nanos) overflows = pc.greater_equal(nanos1, 86400 * 1e9) underflows = pc.less(nanos1, 0) - mask = pa.StructArray.from_arrays( - [overflows, underflows], names=["overflows", "underflows"] - ) + mask = pa.StructArray.from_arrays([overflows, underflows], names=["overflows", "underflows"]) nanos2 = pc.case_when( mask, pc.subtract(nanos1, int(86400 * 1e9)), @@ -478,9 +456,7 @@ def _duration_arrays_within_tolerance( if max_nanos_deviation == 0: return pc.and_(pc.equal(delta_days, 0), pc.equal(delta_nanos, 0)) - cond1 = pc.and_( - pc.equal(delta_days, 0), pc.less(pc.abs(delta_nanos), max_nanos_deviation) - ) + cond1 = pc.and_(pc.equal(delta_days, 0), pc.less(pc.abs(delta_nanos), max_nanos_deviation)) cond2 = pc.and_( pc.equal(delta_days, -1), pc.greater_equal(pc.abs(delta_nanos), 86400 * 1e9 - max_nanos_deviation), diff --git a/adam_core/utils/helpers/data/get_test_data.py b/adam_core/utils/helpers/data/get_test_data.py index ff0513be..3a4198f2 100644 --- a/adam_core/utils/helpers/data/get_test_data.py +++ b/adam_core/utils/helpers/data/get_test_data.py @@ -45,9 +45,7 @@ def _get_orbital_elements( aberrations="geometric", refplane=refplane, ) - vectors_df = vectors_df[ - ["targetname", "datetime_jd", "x", "y", "z", "vx", "vy", "vz"] - ] + vectors_df = vectors_df[["targetname", "datetime_jd", "x", "y", "z", "vx", "vy", "vz"]] elements_df = _get_horizons_elements( object_ids, @@ -77,9 +75,7 @@ def _get_orbital_elements( horizons_elements = vectors_df.merge(elements_df, on=["targetname", "datetime_jd"]) - horizons_elements.insert( - 1, "mjd_tdb", Timestamp.from_jd(horizons_elements["datetime_jd"]).mjd() - ) + horizons_elements.insert(1, "mjd_tdb", Timestamp.from_jd(horizons_elements["datetime_jd"]).mjd()) horizons_elements.insert( len(horizons_elements.columns), "tp_mjd", @@ -122,14 +118,10 @@ def _get_orbital_elements( frame_out = "ec" for origin in ["@sun", "@ssb"]: - horizons_elements_dfs = [] for orbit in orbits: prov_designation = ( - orbit.object_id.to_numpy(zero_copy_only=False)[0] - .split("(") - .pop() - .split(")")[0] + orbit.object_id.to_numpy(zero_copy_only=False)[0].split("(").pop().split(")")[0] ) horizons_elements_df = _get_orbital_elements( @@ -144,16 +136,12 @@ def _get_orbital_elements( if origin == "@sun": horizons_elements_df.to_csv( - files("adam_core.utils.helpers.data").joinpath( - f"elements_sun_{frame_out}.csv" - ), + files("adam_core.utils.helpers.data").joinpath(f"elements_sun_{frame_out}.csv"), index=False, ) else: horizons_elements_df.to_csv( - files("adam_core.utils.helpers.data").joinpath( - f"elements_ssb_{frame_out}.csv" - ), + files("adam_core.utils.helpers.data").joinpath(f"elements_ssb_{frame_out}.csv"), index=False, ) @@ -173,12 +161,7 @@ def _get_orbital_elements( for i, orbit in enumerate(orbits): # Get the provisional designation - prov_designation = ( - orbit.object_id.to_numpy(zero_copy_only=False)[0] - .split("(") - .pop() - .split(")")[0] - ) + prov_designation = orbit.object_id.to_numpy(zero_copy_only=False)[0].split("(").pop().split(")")[0] # Extract times from orbit and propagate +/- 30 days times = orbit.coordinates.time.add_fractional_days(dts) @@ -207,6 +190,4 @@ def _get_orbital_elements( ) ephemeris_df = pd.concat(ephemeris_dfs, ignore_index=True) - ephemeris_df.to_csv( - files("adam_core.utils.helpers.data").joinpath("ephemeris.csv"), index=False - ) + ephemeris_df.to_csv(files("adam_core.utils.helpers.data").joinpath("ephemeris.csv"), index=False) diff --git a/adam_core/utils/helpers/observations.py b/adam_core/utils/helpers/observations.py index d51cff69..2e4f9448 100644 --- a/adam_core/utils/helpers/observations.py +++ b/adam_core/utils/helpers/observations.py @@ -25,9 +25,7 @@ def make_observations() -> Tuple[Exposures, PointSourceDetections, Associations] Table of associations. """ # Load the ephemeris (these are predicted ephemerides generated via JPL Horizons) - ephemeris = pd.read_csv( - files("adam_core.utils.helpers.data").joinpath("ephemeris.csv") - ) + ephemeris = pd.read_csv(files("adam_core.utils.helpers.data").joinpath("ephemeris.csv")) # Now lets create simulated exposures and detections exposure_times = { @@ -52,9 +50,9 @@ def make_observations() -> Tuple[Exposures, PointSourceDetections, Associations] # For everything else (which is just W84 at the moment) every observation is reported at the midpoint else: - ephemeris.loc[observatory_mask, "exposure_start"] = ephemeris[ - observatory_mask - ]["mjd_utc"].values - (exposure_times[observatory_code] / 2 / 86400) + ephemeris.loc[observatory_mask, "exposure_start"] = ephemeris[observatory_mask][ + "mjd_utc" + ].values - (exposure_times[observatory_code] / 2 / 86400) # Create an exposures table exposures = ( @@ -67,14 +65,12 @@ def make_observations() -> Tuple[Exposures, PointSourceDetections, Associations] exposures.insert( 0, "exposure_id", - exposures["observatory_code"].astype(str) - + "_" - + [f"{i:04d}" for i in range(len(exposures))], + exposures["observatory_code"].astype(str) + "_" + [f"{i:04d}" for i in range(len(exposures))], ) for observatory_code in exposures["observatory_code"].unique(): - exposures.loc[ - exposures["observatory_code"] == observatory_code, "duration" - ] = exposure_times[observatory_code] + exposures.loc[exposures["observatory_code"] == observatory_code, "duration"] = exposure_times[ + observatory_code + ] exposures["filter"] = "V" # Attached exposure IDs to the ephemerides @@ -84,9 +80,7 @@ def make_observations() -> Tuple[Exposures, PointSourceDetections, Associations] ) # Create detections - detections = ephemeris[ - ["exposure_id", "observatory_code", "mjd_utc", "RA", "DEC", "V"] - ].copy() + detections = ephemeris[["exposure_id", "observatory_code", "mjd_utc", "RA", "DEC", "V"]].copy() detections.rename( columns={ "RA": "ra", diff --git a/adam_core/utils/mpc.py b/adam_core/utils/mpc.py index 5395bd75..0da984bb 100644 --- a/adam_core/utils/mpc.py +++ b/adam_core/utils/mpc.py @@ -84,9 +84,7 @@ def pack_numbered_designation(designation: str) -> str: """ number = int(designation) if number > 15396335: - raise ValueError( - "Numbered designation is too large. Maximum supported is 15396335." - ) + raise ValueError("Numbered designation is too large. Maximum supported is 15396335.") if number <= 99999: return "{:05}".format(number) @@ -140,17 +138,11 @@ def pack_provisional_designation(designation: str) -> str: The half-month letter is I or Z. """ if len(designation) < 6: - raise ValueError( - "Provisional designations should be at least 6 characters long." - ) + raise ValueError("Provisional designations should be at least 6 characters long.") if not designation[:3].isdecimal(): - raise ValueError( - "Expected the first 4 characters of the provisional designation to be a year." - ) + raise ValueError("Expected the first 4 characters of the provisional designation to be a year.") if designation[4] != " ": - raise ValueError( - "Expected the 5th character of the provisional designation to be a space." - ) + raise ValueError("Expected the 5th character of the provisional designation to be a space.") if "-" in designation: raise ValueError("Provisional designations cannot contain a hyphen.") @@ -408,9 +400,7 @@ def unpack_survey_designation(designation_pf: str) -> str: number = int(designation_pf[3:8]) survey_pf = designation_pf[0:3] if survey_pf not in {"PLS", "T1S", "T2S", "T3S"}: - raise ValueError( - "Packed survey designation must start with PLS, T1S, T2S, or T3S." - ) + raise ValueError("Packed survey designation must start with PLS, T1S, T2S, or T3S.") if survey_pf == "PLS": survey = "P-L" diff --git a/adam_core/utils/spice.py b/adam_core/utils/spice.py index 2672bfb1..39ebfa97 100644 --- a/adam_core/utils/spice.py +++ b/adam_core/utils/spice.py @@ -126,9 +126,7 @@ def get_perturber_state( for i, epoch in enumerate(unique_epochs_et): mask = pc.equal(epochs_et, epoch).to_numpy(False) - state, lt = sp.spkez( - perturber.value, epoch.as_py(), frame_spice, "NONE", origin.value - ) + state, lt = sp.spkez(perturber.value, epoch.as_py(), frame_spice, "NONE", origin.value) states[mask, :] = state # Convert to AU and AU per day diff --git a/adam_core/utils/tests/test_benchmarks.py b/adam_core/utils/tests/test_benchmarks.py index 52492a59..8809df3c 100644 --- a/adam_core/utils/tests/test_benchmarks.py +++ b/adam_core/utils/tests/test_benchmarks.py @@ -16,9 +16,7 @@ [OriginCodes.EARTH, OriginCodes.SUN, OriginCodes.SOLAR_SYSTEM_BARYCENTER], ids=lambda x: f"perturber={x.name},", ) -@pytest.mark.parametrize( - "frame", ["equatorial", "ecliptic"], ids=lambda x: f"frame={x}," -) +@pytest.mark.parametrize("frame", ["equatorial", "ecliptic"], ids=lambda x: f"frame={x},") @pytest.mark.parametrize( "origin", [OriginCodes.SUN, OriginCodes.SOLAR_SYSTEM_BARYCENTER], diff --git a/pyproject.toml b/pyproject.toml index fd7df505..4b89c809 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,8 +90,8 @@ lint = [ "isort --check-only ./adam_core", ] format = [ - "black ./adam_core ./test", - "isort ./adam_core ./test" + "black ./adam_core", + "isort ./adam_core" ] typecheck = [ "mypy --strict ./adam_core" @@ -118,10 +118,7 @@ profile = "black" [tool.ruff] line-length = 110 target-version = "py311" -ignore = [ - "W503", - "E203" -] +ignore = [] exclude = [ "build" ]