Skip to content

Commit 25a3acd

Browse files
committed
Update black formatting to run on a supported python version & run formatter.
1 parent 2272340 commit 25a3acd

22 files changed

Lines changed: 58 additions & 55 deletions

docs/source/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
sys.path.insert(0, os.path.abspath("."))
1717
import velociraptor
1818

19-
2019
# -- Project information -----------------------------------------------------
2120

2221
project = "VELOCIraptor Python Tools"

examples/create_hmf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
lowest_halo_mass = 1e9 * unyt.msun
1919
highest_halo_mass = 1e14 * unyt.msun
20-
lowest_mf = 1e-4 / (unyt.Mpc ** 3)
21-
highest_mf = 1e1 / (unyt.Mpc ** 3)
20+
lowest_mf = 1e-4 / (unyt.Mpc**3)
21+
highest_mf = 1e1 / (unyt.Mpc**3)
2222

2323
box_volume = (float(sys.argv[2]) * unyt.Mpc) ** 3
2424

examples/create_smf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
lowest_stellar_mass = 1e7 * unyt.msun
1919
highest_stellar_mass = 1e12 * unyt.msun
20-
lowest_smf = 1e-6 / (unyt.Mpc ** 3)
21-
highest_smf = 10 ** (-0.5) / (unyt.Mpc ** 3)
20+
lowest_smf = 1e-6 / (unyt.Mpc**3)
21+
highest_smf = 10 ** (-0.5) / (unyt.Mpc**3)
2222

2323
box_volume = (float(sys.argv[2]) * unyt.Mpc) ** 3
2424

format.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ if [ ! -d black_formatting_env ]
1414
then
1515
echo "Formatting environment not found, installing it..."
1616
python3 -m venv black_formatting_env
17-
./black_formatting_env/bin/python3 -m pip install click==8.0.4 black==19.3b0
17+
./black_formatting_env/bin/python3 -m pip install black==26.3.1
1818
fi
1919
# Now we know exactly which black to use
2020
black="./black_formatting_env/bin/python3 -m black"
2121

2222
# Formatting command
23-
cmd="$black -t py38 $(find . -name '*.py' -not -path './black_formatting_env/*')"
23+
cmd="$black -t py310 $(find . -name '*.py' -not -path './black_formatting_env/*')"
2424

2525
# Print the help
2626
function show_help {

tests/test_load_catalogue.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88

99
@requires("cosmo_0000.properties")
10-
def test_basic_load_catalogue_no_crash(filename="test_data/cosmo_0000.properties",):
10+
def test_basic_load_catalogue_no_crash(
11+
filename="test_data/cosmo_0000.properties",
12+
):
1113
catalogue = load(filename)
1214

1315
return

velociraptor/autoplotter/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
below: number (in same units)
5757
above: number
5858
# Lines that you can plot on top - line_type can be median or mean
59-
line_type:
59+
line_type:
6060
plot: true/false (true by default) actually plot this?
6161
log: true/false (true by default) use log bins?
6262
scatter: "none", "errorbar", "errorbar_both", or "shaded". Defaults to shaded

velociraptor/autoplotter/lines.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,10 @@ def create_line(
286286
masked_x, self.bins, box_volume=box_volume
287287
)
288288
if self.box_size_correction is not None:
289-
mass_function_output = self.box_size_correction.apply_mass_function_correction(
290-
mass_function_output
289+
mass_function_output = (
290+
self.box_size_correction.apply_mass_function_correction(
291+
mass_function_output
292+
)
291293
)
292294
self.output = (
293295
*mass_function_output,
@@ -334,8 +336,10 @@ def create_line(
334336
return_bin_edges=True,
335337
)
336338
if self.box_size_correction is not None:
337-
mass_function_output = self.box_size_correction.apply_mass_function_correction(
338-
mass_function_output
339+
mass_function_output = (
340+
self.box_size_correction.apply_mass_function_correction(
341+
mass_function_output
342+
)
339343
)
340344
self.output = (
341345
*mass_function_output,
@@ -356,7 +360,6 @@ def highlight_data_outside_domain(
356360
x_lim: List,
357361
y_lim: List,
358362
) -> None:
359-
360363
"""
361364
Add arrows to the plot for each data point residing outside the plot's domain.
362365
The arrows indicate where the missing points are. For a given missing data point
@@ -581,9 +584,9 @@ def plot_line(
581584
if self.scatter == "none" or errors is None:
582585
(line,) = ax.plot(centers, heights, label=label)
583586
elif self.scatter == "errorbar":
584-
(line, *_) = ax.errorbar(centers, heights, yerr=errors, label=label)
587+
line, *_ = ax.errorbar(centers, heights, yerr=errors, label=label)
585588
elif self.scatter == "errorbar_both":
586-
(line, *_) = ax.errorbar(
589+
line, *_ = ax.errorbar(
587590
centers,
588591
heights,
589592
yerr=errors,

velociraptor/autoplotter/metadata.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def _parse_line(self):
5454
def to_dict(self):
5555
"""
5656
Convert the contents of this into a dictionary (not using
57-
__dict__ as that is used for hashing and I don't want to
57+
__dict__ as that is used for hashing and I don't want to
5858
mess with that here)
5959
"""
6060

@@ -71,9 +71,9 @@ def to_dict(self):
7171
additional_points_x_units=str(self.additional_x.units),
7272
additional_points_y=self.additional_y.value.tolist(),
7373
additional_points_y_units=str(self.additional_y.units),
74-
bins_x=self.line.bins.value.tolist()
75-
if self.line.bins is not None
76-
else None,
74+
bins_x=(
75+
self.line.bins.value.tolist() if self.line.bins is not None else None
76+
),
7777
bins_x_units=str(
7878
self.line.bins.units if self.line.bins is not None else None
7979
),

velociraptor/autoplotter/plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def histogram_x_against_y(
4545
) -> Tuple[plt.Figure, plt.Axes]:
4646
"""
4747
Creates a plot of x against y with a 2d histogram in the background.
48-
48+
4949
Actually uses pcolormesh and the numpy histogram method.
5050
"""
5151

velociraptor/catalogue/registration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ def registration_stellar_birth_densities(
13571357
if not field_path[:14] == "BirthDensities" and field_path[-4:] == "star":
13581358
raise RegistrationDoesNotMatchError
13591359

1360-
unit = unit_system.mass / unit_system.length ** 3
1360+
unit = unit_system.mass / unit_system.length**3
13611361

13621362
# Need to do a regex search (average, min, max)
13631363
match_string = "BirthDensities_([a-z]+)_star"
@@ -1390,7 +1390,7 @@ def registration_snii_thermal_feedback_densities(
13901390
):
13911391
raise RegistrationDoesNotMatchError
13921392

1393-
unit = unit_system.mass / unit_system.length ** 3
1393+
unit = unit_system.mass / unit_system.length**3
13941394

13951395
# Need to do a regex search (average, min, max)
13961396
match_string = "DensitiesAtLastSupernovaEvent_([a-z]+)_gas"

0 commit comments

Comments
 (0)