Skip to content

Commit 187c52a

Browse files
committed
Correct several ruff formatting issues
1 parent 3611f67 commit 187c52a

File tree

5 files changed

+31
-25
lines changed

5 files changed

+31
-25
lines changed

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,6 @@ exclude_lines = [
106106
[tool.ruff]
107107
extend-exclude = ["examples"]
108108

109-
[tool.ruff.lint.isort]
110-
known-first-party = ["qusi", "ramjet"]
109+
[tool.ruff.lint]
110+
ignore = ["RET504"]
111+
isort.known-first-party = ["qusi", "ramjet"]

tests/photometric_database/test_tess_ffi_light_curve.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class TestTessFfiDataInterface:
1212
@pytest.fixture
1313
def ffi_pickle_contents(self) -> tuple[int, float, float, float, int, int, np.ndarray, np.ndarray, np.ndarray,
14-
np.ndarray, np.ndarray, np.ndarray]:
14+
np.ndarray, np.ndarray, np.ndarray]:
1515
"""
1616
Creates a mock content of one of Brian Powell's FFI data files.
1717
@@ -119,7 +119,8 @@ def test_can_get_floor_magnitude_from_ffi_style_file_path(self):
119119
magnitude1 = light_curve.get_floor_magnitude_from_file_path(
120120
'data/ffi_microlensing_database/light_curves/tesslcs_sector_1/tesslcs_tmag_14_15/tesslc_1234567.pkl')
121121
assert magnitude1 == 14
122-
with pytest.raises(ValueError):
122+
with pytest.raises(ValueError,
123+
match='tesslc_12345678.pkl does not match a known pattern to extract magnitude from.'):
123124
light_curve.get_floor_magnitude_from_file_path('tesslc_12345678.pkl')
124125

125126
def test_can_get_floor_magnitude_from_104_ffi_style_file_path(self):
@@ -130,19 +131,21 @@ def test_can_get_floor_magnitude_from_104_ffi_style_file_path(self):
130131
magnitude1 = light_curve.get_floor_magnitude_from_file_path(
131132
'data/ffi_microlensing_database/light_curves/tesslcs_sector_1_104/tesslcs_tmag_14_15/tesslc_1234567.pkl')
132133
assert magnitude1 == 14
133-
with pytest.raises(ValueError):
134+
with pytest.raises(ValueError,
135+
match='tesslc_12345678.pkl does not match a known pattern to extract magnitude from.'):
134136
light_curve.get_floor_magnitude_from_file_path('tesslc_12345678.pkl')
135137

136138
def test_all_ffi_column_names_have_matches_in_the_pickle_indexes(self):
137-
index_names = list(map(lambda index: index.name, TessFfiPickleIndex))
139+
index_names = [index.name for index in TessFfiPickleIndex]
138140
for column_name in TessFfiColumnName:
139141
assert column_name.name in index_names
140142

141143
@patch.object(module.pickle, 'load')
142-
@patch.object(Path, 'open')
143-
def test_from_path_factory_sets_the_tic_id_and_sector_of_the_light_curve(self, mock_open, mock_pickle_load,
144+
def test_from_path_factory_sets_the_tic_id_and_sector_of_the_light_curve(self, mock_pickle_load,
144145
ffi_pickle_contents):
145-
mock_pickle_load.return_value = ffi_pickle_contents
146-
light_curve = TessFfiLightCurve.from_path(Path('tesslcs_sector_1_104/tesslcs_tmag_14_15/tesslc_1234567.pkl'))
147-
assert light_curve.tic_id == 1234567
148-
assert light_curve.sector == 1
146+
with patch.object(Path, 'open'):
147+
mock_pickle_load.return_value = ffi_pickle_contents
148+
light_curve = TessFfiLightCurve.from_path(
149+
Path('tesslcs_sector_1_104/tesslcs_tmag_14_15/tesslc_1234567.pkl'))
150+
assert light_curve.tic_id == 1234567
151+
assert light_curve.sector == 1

tests/photometric_database/test_tess_light_curve.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ def test_setting_tic_rows_from_mast_for_list(self):
1111
light_curve0.tic_id = 266980320
1212
light_curve1 = TessLightCurve()
1313
light_curve1.tic_id = 231663901
14-
assert light_curve0._tic_row is None
15-
assert light_curve1._tic_row is None
14+
assert light_curve0._tic_row is None # noqa SLF001
15+
assert light_curve1._tic_row is None # noqa SLF001
1616
TessLightCurve.load_tic_rows_from_mast_for_list([light_curve0, light_curve1])
17-
assert light_curve0._tic_row is not None
18-
assert light_curve1._tic_row is not None
19-
assert float(light_curve0._tic_row['Tmag']) == pytest.approx(9.179, rel=1e-3)
17+
assert light_curve0._tic_row is not None # noqa SLF001
18+
assert light_curve1._tic_row is not None # noqa SLF001
19+
assert float(light_curve0._tic_row['Tmag']) == pytest.approx(9.179, rel=1e-3) # noqa SLF001
2020

2121
@pytest.mark.slow
2222
@pytest.mark.external
2323
def test_setting_tic_rows_from_mast_for_list_notes_missing_row_for_tic_ids_not_in_tic(self):
2424
light_curve0 = TessLightCurve()
2525
light_curve0.tic_id = 99999999999999999
26-
assert light_curve0._tic_row is None
26+
assert light_curve0._tic_row is None # noqa SLF001
2727
TessLightCurve.load_tic_rows_from_mast_for_list([light_curve0])
28-
assert light_curve0._tic_row is MissingTicRow
28+
assert light_curve0._tic_row is MissingTicRow # noqa SLF001

tests/photometric_database/test_tess_target.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_retrieving_radius_from_gaia(self):
3131

3232
assert gaia_radius == pytest.approx(4.2563343)
3333

34-
@pytest.mark.parametrize('transit_depth, target_radius, target_contamination_ratio, expected_body_radius',
34+
@pytest.mark.parametrize(('transit_depth', 'target_radius', 'target_contamination_ratio', 'expected_body_radius'),
3535
[(0.01011, 1.0, 0.0, 0.1005484),
3636
(0.02, 1.0, 0.1, 0.1483239),
3737
(0.01, 2.0, 0.5, 0.2449489)])
@@ -45,7 +45,7 @@ def test_can_estimate_radius_of_transiting_body(self, transit_depth, target_radi
4545

4646
assert body_radius == pytest.approx(expected_body_radius)
4747

48-
@pytest.mark.parametrize('contamination_ratio, allow_unknown_contamination_ratio',
48+
@pytest.mark.parametrize(('contamination_ratio', 'allow_unknown_contamination_ratio'),
4949
[(np.nan, False),
5050
(None, False)])
5151
def test_not_allowing_estimate_radius_of_transiting_body_with_unknown_contamination(
@@ -56,11 +56,11 @@ def test_not_allowing_estimate_radius_of_transiting_body_with_unknown_contaminat
5656
target.radius = target_radius
5757
target.contamination_ratio = contamination_ratio
5858

59-
with pytest.raises(ValueError):
59+
with pytest.raises(ValueError, match=r'Contamination ratio (None|nan) cannot be used to calculate the radius.'):
6060
_ = target.calculate_transiting_body_radius(
6161
transit_depth=transit_depth, allow_unknown_contamination_ratio=allow_unknown_contamination_ratio)
6262

63-
@pytest.mark.parametrize('contamination_ratio, allow_unknown_contamination_ratio',
63+
@pytest.mark.parametrize(('contamination_ratio', 'allow_unknown_contamination_ratio'),
6464
[(np.nan, True),
6565
(None, True)])
6666
def test_allowing_estimate_radius_of_transiting_body_with_unknown_contamination(

tests/photometric_database/test_tess_two_minute_cadence_light_curve.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def test_from_path_factory_light_curve_uses_correct_default_times_and_fluxes(sel
4343
with patch.object(module.fits, 'open') as mock_open:
4444
mock_open.return_value.__enter__.return_value = fake_hdu_list
4545
light_curve = TessMissionLightCurve.from_path(Path('TIC 169480782 sector 5.fits'))
46-
assert np.array_equal(light_curve.times, fake_hdu_list[1].data[TessMissionLightCurveFitsIndex.TIME__BTJD.value])
46+
assert np.array_equal(light_curve.times,
47+
fake_hdu_list[1].data[TessMissionLightCurveFitsIndex.TIME__BTJD.value])
4748
assert np.array_equal(light_curve.fluxes,
4849
fake_hdu_list[1].data[TessMissionLightCurveFitsIndex.PDCSAP_FLUX.value])
4950

@@ -58,7 +59,8 @@ def test_can_get_tic_id_and_sector_from_human_readable_file_name(self):
5859
assert sector1 == 5
5960

6061
def test_get_tic_id_and_sector_raises_error_with_unknown_pattern(self):
61-
with pytest.raises(ValueError):
62+
with pytest.raises(ValueError,
63+
match='a b c d e f g does not match a known pattern to extract TIC ID and sector from.'):
6264
TessMissionLightCurve.get_tic_id_and_sector_from_file_path(Path('a b c d e f g'))
6365

6466
def test_can_get_tic_id_and_sector_from_tess_obs_id_style_file_name(self):

0 commit comments

Comments
 (0)