From eb5b2c380292e3deb204c5e8584b18b39113ada0 Mon Sep 17 00:00:00 2001 From: emilyhunt Date: Mon, 29 Sep 2025 10:48:11 +0200 Subject: [PATCH] Run ruff check & ruff format --- pyproject.toml | 4 ++++ src/hr_selection_function/__init__.py | 4 ++-- src/hr_selection_function/data.py | 4 ++-- src/hr_selection_function/math.py | 2 +- tests/test_gaia.py | 4 ++-- tests/test_import.py | 2 +- tests/test_models.py | 2 +- 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 97d094a..3d5a1c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,3 +33,7 @@ notebooks = [ [build-system] requires = ["hatchling"] build-backend = "hatchling.build" + +[tool.ruff.lint] +ignore = ["E741"] + diff --git a/src/hr_selection_function/__init__.py b/src/hr_selection_function/__init__.py index 45809d1..0d82223 100644 --- a/src/hr_selection_function/__init__.py +++ b/src/hr_selection_function/__init__.py @@ -1,7 +1,7 @@ from .config import _DEFAULT_DIRECTORY from .data import set_data_directory -from .models import HR24SelectionFunction, NStarsPredictor -from .gaia import M10Estimator, MSubsampleEstimator, GaiaDensityEstimator +from .models import HR24SelectionFunction, NStarsPredictor # noqa: F401 +from .gaia import M10Estimator, MSubsampleEstimator, GaiaDensityEstimator # noqa: F401 set_data_directory(_DEFAULT_DIRECTORY) diff --git a/src/hr_selection_function/data.py b/src/hr_selection_function/data.py index 85d487e..c04d9e6 100644 --- a/src/hr_selection_function/data.py +++ b/src/hr_selection_function/data.py @@ -100,7 +100,7 @@ def _check_data_directory(directory: Path | str) -> tuple[Path, bool]: if isinstance(directory, str): try: directory = Path(directory) - except Exception as e: + except Exception: raise ValueError( f"Unable to cast user-specified directory '{directory}' into a path. " "Are you sure it is a valid path on your operating system?" @@ -125,7 +125,7 @@ def _check_data_directory(directory: Path | str) -> tuple[Path, bool]: def _check_data_downloaded(directory: Path | None = None) -> bool: # Todo this function should really check file size too - + if directory is None: directory = _CONFIG["data_dir"] directory = Path(directory) diff --git a/src/hr_selection_function/math.py b/src/hr_selection_function/math.py index a9fe6e5..342d202 100644 --- a/src/hr_selection_function/math.py +++ b/src/hr_selection_function/math.py @@ -5,7 +5,7 @@ from numba import njit def vectorized_multivariate_normal( values: np.ndarray, means: np.ndarray, covariances: np.ndarray ) -> np.ndarray: - """Calculate the PDF of n_queries different multivariate normal distributions at + """Calculate the PDF of n_queries different multivariate normal distributions at n_queries different points in a fast and vectorized way. Significantly faster than scipy.stats.multivariate_normal.pdf() when n_queries is large. diff --git a/tests/test_gaia.py b/tests/test_gaia.py index 64d82c2..79af165 100644 --- a/tests/test_gaia.py +++ b/tests/test_gaia.py @@ -59,7 +59,7 @@ def test_MSubsampleEstimator(): def test_GaiaDensityEstimator(): - l, b, pmra, pmdec, parallax, result_expected = _get_test_density_data() # noqa: E741 + l, b, pmra, pmdec, parallax, result_expected = _get_test_density_data() model = GaiaDensityEstimator() result_actual = model(l, b, pmra, pmdec, parallax) @@ -79,7 +79,7 @@ def _get_test_density_data(l_and_b=True): 136.28666583570796, 125.97131795417525, 213.97631324679773, - ] # noqa: E741 + ] b = [ -0.9346927099010592, 3.6108482027563507, diff --git a/tests/test_import.py b/tests/test_import.py index 8e054bb..18f3c35 100644 --- a/tests/test_import.py +++ b/tests/test_import.py @@ -3,4 +3,4 @@ def test_import(): # you joke but its amazing how easy it is to break this one line of fucken code - import hr_selection_function + import hr_selection_function # noqa: F401 diff --git a/tests/test_models.py b/tests/test_models.py index c6e8df0..0917098 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -126,7 +126,7 @@ def get_test_cluster(): l=np.linspace(0, 360, endpoint=False) * u.deg, b=np.linspace(-80, 80) * u.deg, distance=np.linspace(500, 5000) * u.pc, - frame="galactic" + frame="galactic", ) mass = np.linspace(50, 5000) extinction = np.linspace(0, 5) -- 2.54.0