Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion astrodata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def create(*args, **kwargs):
@deprecated(
"Use 'astrodata.from_file'. astrodata.open is deprecated, "
"and will be removed in a future version. They take the "
"same arguments and return the same object.",
"same arguments and return the same object."
)
def open(*args, **kwargs): # pylint: disable=redefined-builtin
"""Return an |AstroData| object from a file.
Expand Down
25 changes: 4 additions & 21 deletions astrodata/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,7 @@ def get_corners(shape):


def assert_most_close(
actual,
desired,
max_miss,
rtol=1e-7,
atol=0,
equal_nan=True,
verbose=True,
actual, desired, max_miss, rtol=1e-7, atol=0, equal_nan=True, verbose=True
):
"""Assert that two objects are equal up to a specified number of elements.

Expand Down Expand Up @@ -478,12 +472,7 @@ def compare_models(model1, model2, rtol=1e-7, atol=0.0, check_inverse=True):


def download_multiple_files(
files,
path=None,
sub_path="",
use_threads=True,
sequential=False,
**kwargs,
files, path=None, sub_path="", use_threads=True, sequential=False, **kwargs
):
"""Download multiple files from the archive and store them at a given path.

Expand Down Expand Up @@ -1202,10 +1191,7 @@ def fake_fits_bytes(
min_choice, max_choice = 0, 64

mask = _RANDOM_NUMBER_GEN.integers(
min_choice,
max_choice,
size=image_shape,
dtype=np.uint16,
min_choice, max_choice, size=image_shape, dtype=np.uint16
)

# Setting some random pixels to zero on the mask
Expand Down Expand Up @@ -1381,10 +1367,7 @@ def test_script_file(

command = [x for x in itertools.chain(*command_components)]

process = subprocess.run(
command,
capture_output=True,
)
process = subprocess.run(command, capture_output=True)

stdout = process.stdout
stderr = process.stderr
Expand Down
10 changes: 3 additions & 7 deletions astrodata/wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def fitswcs_to_gwcs(input_data, *, raise_errors: bool = False):
"Could not create gWCS: %s: %s",
err.__class__.__name__,
err,
)
) # fmt: skip

return None

Expand Down Expand Up @@ -474,19 +474,15 @@ def gwcs_to_fits(ndd, hdr=None):
crval2 = wcs(*(crpix - 1))
try:
sky_center = coord.SkyCoord(
nat2cel.lon.value,
nat2cel.lat.value,
unit=u.deg,
nat2cel.lon.value, nat2cel.lat.value, unit=u.deg
)

except NameError:
pass

else:
sky_center2 = coord.SkyCoord(
crval2[lon_axis],
crval2[lat_axis],
unit=u.deg,
crval2[lon_axis], crval2[lat_axis], unit=u.deg
)

if sky_center.separation(sky_center2).arcsec > 0.01:
Expand Down
73 changes: 14 additions & 59 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class SessionVariables:
"3.10",
"3.11",
"3.12",
]
] # fmt: skip

# devpi server information
devpi_host = "localhost"
Expand Down Expand Up @@ -162,9 +162,7 @@ class DevpiServerManager:
url: ClassVar[str] = SessionVariables.devpi_url()

def __init__(
self,
session: nox.Session,
tmp_dir: Path | None = None,
self, session: nox.Session, tmp_dir: Path | None = None
) -> None:
"""Initialize the context manager."""
self.session = session
Expand Down Expand Up @@ -214,11 +212,7 @@ def generate_config_file(self):
with session.cd(tmp_dir):
session.run("devpi-init", "--serverdir", ".")
session.run(
"devpi-gen-config",
"--serverdir",
tmp_dir,
"--port",
str(port),
"devpi-gen-config", "--serverdir", tmp_dir, "--port", str(port)
)

def wait_for_devpi_startup(self, session: nox.Session) -> bool:
Expand Down Expand Up @@ -275,22 +269,13 @@ def start_devpi_server(self):

# Check that the server is available.abs
result = session.run(
"which",
"devpi-server",
silent=True,
external=True,
"which", "devpi-server", silent=True, external=True
)

devpi_server_path = result.strip()

self.server_process = subprocess.Popen(
[
devpi_server_path,
"--serverdir",
tmp_dir,
"--port",
str(port),
], # noqa: S603
[devpi_server_path, "--serverdir", tmp_dir, "--port", str(port)], # noqa: S603
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
Expand Down Expand Up @@ -393,11 +378,7 @@ def get_poetry_dependencies(

command[2] = f"--with={','.join(groups)}"

session.run(
*command,
external=True,
silent=True,
)
session.run(*command, external=True, silent=True)

log_message = f"Poetry dependencies written to {req_file_path}"

Expand Down Expand Up @@ -554,11 +535,7 @@ def dragons_release_tests(session: nox.Session) -> None:
# Positional arguments after -- are passed to pytest.
pos_args = session.posargs

session.run(
"pytest",
*SessionVariables.dragons_pytest_options,
*pos_args,
)
session.run("pytest", *SessionVariables.dragons_pytest_options, *pos_args)


@nox.session(venv_backend="conda", python="3.12", tags=["dragons"])
Expand Down Expand Up @@ -635,11 +612,7 @@ def dragons_dev_tests(session: nox.Session) -> None:
# Positional arguments after -- are passed to pytest.
pos_args = session.posargs

session.run(
"pytest",
*SessionVariables.dragons_pytest_options,
*pos_args,
)
session.run("pytest", *SessionVariables.dragons_pytest_options, *pos_args)


@nox.session(python=SessionVariables.python_versions)
Expand All @@ -661,14 +634,8 @@ def conda_unit_tests(session: nox.Session) -> None:
"""Run the unit tests."""
# Configure session channels.
apply_data_caching_environment_variable(session)
session.run(
"conda",
"config",
"--env",
"--add",
"channels",
"conda-forge",
)
session.run("conda", "config", "--env", "--add", "channels", "conda-forge")

# Conda-install the dependencies required to *run* astrodata since
# this is a conda test. Then install the dependencies to run the *tests*
# with pip since they are not all available from conda.
Expand Down Expand Up @@ -700,9 +667,7 @@ def unit_test_build(session: nox.Session) -> None:
install_test_dependencies(session, poetry_groups=["test"])

# Install the package from the devpi server
session.install(
"astrodata",
)
session.install("astrodata")

# Positional arguments after -- are passed to pytest.
pos_args = session.posargs
Expand Down Expand Up @@ -738,11 +703,7 @@ def integration_test_build(session: nox.Session) -> None:
# Positional arguments after -- are passed to pytest.
pos_args = session.posargs

session.run(
"pytest",
*SessionVariables.dragons_pytest_options,
*pos_args,
)
session.run("pytest", *SessionVariables.dragons_pytest_options, *pos_args)


@nox.session
Expand Down Expand Up @@ -808,12 +769,7 @@ def build_and_publish_to_devpi(session: nox.Session):
tmp_build_dir = Path(session.create_tmp()) / "build"
tmp_build_dir.mkdir()

session.run(
"poetry",
"build",
f"--output={tmp_build_dir}",
external=True,
)
session.run("poetry", "build", f"--output={tmp_build_dir}", external=True)

# Shows available indexes
poetry_config_env_vars = {
Expand Down Expand Up @@ -1105,8 +1061,7 @@ def initialize_pre_commit(session: nox.Session) -> None:
# above. They are separated here for ease of diagnosis for common problems.
@nox.session(venv_backend="conda", python="3.12")
def dragons_calibration(
session: nox.Session,
dragonsrc_path: Path | None = None,
session: nox.Session, dragonsrc_path: Path | None = None
) -> None:
"""Run the calibration tests."""
apply_data_caching_environment_variable(session)
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ ignore = [
[tool.ruff.format]
skip-magic-trailing-comma = true

[tool.ruff.lint.isort]
split-on-trailing-comma = false

[tool.ruff.lint.pydocstyle]
convention = "numpy"

Expand Down
Loading