Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruff root files #2849

Merged
merged 2 commits into from
Oct 21, 2024
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 tardis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
" after TARDIS."
)
else:
from astropy import physical_constants, astronomical_constants
from astropy import astronomical_constants, physical_constants

physical_constants.set("codata2014")
astronomical_constants.set("iau2012")
Expand Down
1 change: 1 addition & 0 deletions tardis/_astropy_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@

# Create the test function for self test
from astropy.tests.runner import TestRunner

test = TestRunner.make_test_runner_in(os.path.dirname(__file__))
5 changes: 2 additions & 3 deletions tardis/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import logging


logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -70,9 +69,9 @@ def run_tardis(
-----
Please see the `logging tutorial <https://tardis-sn.github.io/tardis/io/optional/logging_configuration.html>`_ to know more about `log_level` and `specific` options.
"""
from tardis.io.logger.logger import logging_state
from tardis.io.configuration.config_reader import Configuration
from tardis.io.atom_data.base import AtomData
from tardis.io.configuration.config_reader import Configuration
from tardis.io.logger.logger import logging_state
from tardis.simulation import Simulation

if isinstance(config, Configuration):
Expand Down
10 changes: 4 additions & 6 deletions tardis/scripts/cmfgen2tardis.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import os
import sys
import argparse
import os

Check warning on line 2 in tardis/scripts/cmfgen2tardis.py

View check run for this annotation

Codecov / codecov/patch

tardis/scripts/cmfgen2tardis.py#L2

Added line #L2 was not covered by tests

import numpy as np
import pandas as pd

from tardis.io.atom_data import AtomData

# The from_hdf() method requires an argument, so the line below doesn't work
# atomic_dataset = AtomData.from_hdf()

Expand Down Expand Up @@ -40,7 +38,7 @@
def convert_format(file_path):
quantities_row = []
prop_list = ["Velocity", "Density", "Electron density", "Temperature"]
with open(file_path, "r") as f:
with open(file_path) as f:

Check warning on line 41 in tardis/scripts/cmfgen2tardis.py

View check run for this annotation

Codecov / codecov/patch

tardis/scripts/cmfgen2tardis.py#L41

Added line #L41 was not covered by tests
for line in f:
items = line.replace("(", "").replace(")", "").split()
n = len(items)
Expand Down Expand Up @@ -102,7 +100,7 @@
)

filename = os.path.splitext(os.path.basename(args.input_path))[0]
save_fname = ".".join((filename, "csv"))
save_fname = f"{filename}.csv"

Check warning on line 103 in tardis/scripts/cmfgen2tardis.py

View check run for this annotation

Codecov / codecov/patch

tardis/scripts/cmfgen2tardis.py#L103

Added line #L103 was not covered by tests
resultant_df = pd.concat([density_df, abundances_df], axis=1)
resultant_df.columns = pd.MultiIndex.from_tuples(
zip(resultant_df.columns, quantities_row)
Expand Down
2 changes: 1 addition & 1 deletion tardis/tests/fixtures/atom_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from copy import deepcopy
from pathlib import Path

import pytest

from tardis.io.atom_data.base import AtomData
Expand Down
7 changes: 4 additions & 3 deletions tardis/tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import glob
import os
import yaml

import pandas as pd
import pytest
import yaml

# NOTE: the __githash__ variable is not available anymore
# on `version.py`. Find another way to fix it!
Expand Down Expand Up @@ -87,8 +88,8 @@ def reference(request, data_path):
else:
try:
reference = pd.HDFStore(data_path["reference_path"], "r")
except IOError:
raise IOError(
except OSError:
raise OSError(
f'Reference file {data_path["reference_path"]} does not exist and is needed'
f" for the tests"
)
Expand Down
8 changes: 4 additions & 4 deletions tardis/tests/integration_tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import os

import yaml
import pytest
import matplotlib
import pytest
import yaml

matplotlib.use("Agg")
import matplotlib.pyplot as plt
from numpy.testing import assert_allclose

from tardis.io.atom_data.base import AtomData
from tardis.simulation import Simulation
from tardis.io.configuration.config_reader import Configuration
from tardis.simulation import Simulation

pytestmarker = [pytest.mark.no_cover, pytest.mark.integration]

Expand Down Expand Up @@ -71,7 +71,7 @@ def model_quantities(request):
reason="integration tests are not included in this run",
)
@pytest.mark.integration
class TestIntegration(object):
class TestIntegration:
"""Slow integration test for various setups present in subdirectories of
``tardis/tests/integration_tests``.
"""
Expand Down
26 changes: 12 additions & 14 deletions tardis/tests/test_util.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
import pytest
import numpy as np
import numpy.testing as npt
from io import StringIO

import numpy as np
import pytest
from astropy import units as u
from io import StringIO

from tardis.util.base import (
MalformedSpeciesError,
MalformedElementSymbolError,
MalformedQuantityError,
int_to_roman,
roman_to_int,
MalformedSpeciesError,
atomic_number2element_symbol,
calculate_luminosity,
create_synpp_yaml,
convert_abundances_format,
element_symbol2atomic_number,
int_to_roman,
intensity_black_body,
species_tuple_to_string,
species_string_to_tuple,
parse_quantity,
element_symbol2atomic_number,
atomic_number2element_symbol,
reformat_element_symbol,
quantity_linspace,
convert_abundances_format,
reformat_element_symbol,
roman_to_int,
species_string_to_tuple,
species_tuple_to_string,
)


Expand Down
Loading