From 06399a99b0eab5864f9a3bad513752b6f39c259a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Sep 2024 22:47:26 +0000 Subject: [PATCH 1/2] Bump the actions group across 1 directory with 2 updates Bumps the actions group with 2 updates in the /.github/workflows directory: [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) and [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish). Updates `pypa/cibuildwheel` from 2.19.1 to 2.20.0 - [Release notes](https://github.com/pypa/cibuildwheel/releases) - [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md) - [Commits](https://github.com/pypa/cibuildwheel/compare/v2.19.1...v2.20.0) Updates `pypa/gh-action-pypi-publish` from 1.9.0 to 1.10.0 - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.9.0...v1.10.0) --- updated-dependencies: - dependency-name: pypa/cibuildwheel dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions ... Signed-off-by: dependabot[bot] --- .github/workflows/wheels.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yaml b/.github/workflows/wheels.yaml index 7302197..109a7eb 100644 --- a/.github/workflows/wheels.yaml +++ b/.github/workflows/wheels.yaml @@ -27,7 +27,7 @@ jobs: - uses: actions/checkout@v4 - name: Build wheels for CPython - uses: pypa/cibuildwheel@v2.19.1 + uses: pypa/cibuildwheel@v2.20.0 with: output-dir: dist env: @@ -80,4 +80,4 @@ jobs: pattern: wheels-* merge-multiple: true - - uses: pypa/gh-action-pypi-publish@v1.9.0 + - uses: pypa/gh-action-pypi-publish@v1.10.0 From ed270b0f606dbed7acf120e2e7b48de3f1abe91d Mon Sep 17 00:00:00 2001 From: Corentin Cadiou Date: Mon, 2 Sep 2024 15:10:03 +0200 Subject: [PATCH 2/2] Autofix --- doc/extensions/pythonscript_sphinxext.py | 4 ++-- doc/extensions/yt_colormaps.py | 4 ++-- doc/extensions/yt_cookbook.py | 8 ++++---- setup.py | 2 +- .../cosmological_observation/api.py | 2 ++ .../cosmological_observation/light_cone/api.py | 2 ++ .../light_cone/light_cone.py | 6 +++--- .../light_cone/tests/test_light_cone.py | 2 +- yt_astro_analysis/halo_analysis/api.py | 9 +++++++++ .../halo_catalog/halo_callbacks.py | 17 ++++++++--------- .../halo_analysis/halo_catalog/halo_filters.py | 2 +- .../halo_analysis/halo_finding/api.py | 2 ++ .../halo_analysis/halo_finding/halo_objects.py | 8 ++++---- .../halo_analysis/halo_finding/rockstar/api.py | 3 +++ .../halo_finding/rockstar/rockstar.py | 4 ++-- .../halo_analysis/tests/test_halo_catalog.py | 2 +- yt_astro_analysis/ppv_cube/api.py | 2 ++ yt_astro_analysis/ppv_cube/ppv_cube.py | 2 +- .../radmc3d_export/RadMC3DInterface.py | 4 ++-- yt_astro_analysis/radmc3d_export/api.py | 2 ++ 20 files changed, 54 insertions(+), 33 deletions(-) diff --git a/doc/extensions/pythonscript_sphinxext.py b/doc/extensions/pythonscript_sphinxext.py index dd1edf3..730aa60 100644 --- a/doc/extensions/pythonscript_sphinxext.py +++ b/doc/extensions/pythonscript_sphinxext.py @@ -42,7 +42,7 @@ def run(self): # Use sphinx logger? uid = uuid.uuid4().hex[:8] print("") - print(">> Contents of the script: %s" % uid) + print(f">> Contents of the script: {uid}") print(content) print("") @@ -87,7 +87,7 @@ def get_image_tag(filename, image_dir, image_rel_dir): my_uuid = uuid.uuid4().hex shutil.move(filename, image_dir + os.path.sep + my_uuid + filename) relative_filename = image_rel_dir + os.path.sep + my_uuid + filename - return '
' % relative_filename + return f'
' def make_image_dir(setup, rst_dir): diff --git a/doc/extensions/yt_colormaps.py b/doc/extensions/yt_colormaps.py index db0c77e..f9d045d 100644 --- a/doc/extensions/yt_colormaps.py +++ b/doc/extensions/yt_colormaps.py @@ -58,9 +58,9 @@ def run(self): lines = [] for im in images: im_name = os.path.join("_static", os.path.basename(im)) - lines.append(".. image:: %s" % im_name) + lines.append(f".. image:: {im_name}") lines.append(" :width: 400") - lines.append(" :target: ../../_images/%s" % os.path.basename(im)) + lines.append(f" :target: ../../_images/{os.path.basename(im)}") lines.append("\n") lines.append("\n") self.state_machine.insert_input(lines, rst_file) diff --git a/doc/extensions/yt_cookbook.py b/doc/extensions/yt_cookbook.py index b9a9714..7916c1a 100644 --- a/doc/extensions/yt_cookbook.py +++ b/doc/extensions/yt_cookbook.py @@ -58,19 +58,19 @@ def run(self): ) im_path = os.path.join(rst_dir, "_static") - images = sorted(glob.glob(os.path.join(im_path, "%s__*.png" % script_name))) + images = sorted(glob.glob(os.path.join(im_path, f"{script_name}__*.png"))) lines = [] lines.append(f"(`{script_bn} <{script_fn}>`__)") lines.append("\n") lines.append("\n") - lines.append(".. literalinclude:: %s" % self.arguments[0]) + lines.append(f".. literalinclude:: {self.arguments[0]}") lines.append("\n") lines.append("\n") for im in images: im_name = os.path.join("_static", os.path.basename(im)) - lines.append(".. image:: %s" % im_name) + lines.append(f".. image:: {im_name}") lines.append(" :width: 400") - lines.append(" :target: ../_images/%s" % os.path.basename(im)) + lines.append(f" :target: ../_images/{os.path.basename(im)}") lines.append("\n") lines.append("\n") for ext in data_patterns: diff --git a/setup.py b/setup.py index 57b2069..537a9e9 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ def get_version(filename): for line in f.readlines(): if line.startswith("__version__"): return line.split("=")[1].strip()[1:-1] - raise RuntimeError("Could not get version from %s." % filename) + raise RuntimeError(f"Could not get version from {filename}.") VERSION = get_version("yt_astro_analysis/__init__.py") diff --git a/yt_astro_analysis/cosmological_observation/api.py b/yt_astro_analysis/cosmological_observation/api.py index 1cc153a..f443372 100644 --- a/yt_astro_analysis/cosmological_observation/api.py +++ b/yt_astro_analysis/cosmological_observation/api.py @@ -15,3 +15,5 @@ from yt_astro_analysis.cosmological_observation.cosmology_splice import CosmologySplice from yt_astro_analysis.cosmological_observation.light_cone.api import LightCone + +__all__ = ["CosmologySplice", "LightCone"] diff --git a/yt_astro_analysis/cosmological_observation/light_cone/api.py b/yt_astro_analysis/cosmological_observation/light_cone/api.py index 7052bba..9c005ea 100644 --- a/yt_astro_analysis/cosmological_observation/light_cone/api.py +++ b/yt_astro_analysis/cosmological_observation/light_cone/api.py @@ -14,3 +14,5 @@ # ----------------------------------------------------------------------------- from .light_cone import LightCone + +__all__ = ["LightCone"] diff --git a/yt_astro_analysis/cosmological_observation/light_cone/light_cone.py b/yt_astro_analysis/cosmological_observation/light_cone/light_cone.py index 4cb9614..1bc06c8 100644 --- a/yt_astro_analysis/cosmological_observation/light_cone/light_cone.py +++ b/yt_astro_analysis/cosmological_observation/light_cone/light_cone.py @@ -453,7 +453,7 @@ def _save_light_cone_solution(self, filename="light_cone.dat"): mylog.info("Saving light cone solution to %s.", filename) f = open(filename, "w") - f.write("# parameter_filename = %s\n" % self.parameter_filename) + f.write(f"# parameter_filename = {self.parameter_filename}\n") f.write("\n") f.write( "# Slice Dataset Redshift depth/box " @@ -491,10 +491,10 @@ def _save_light_cone_stack( ) field_node = f"{field}_{weight_field}" - weight_field_node = "weight_field_%s" % weight_field + weight_field_node = f"weight_field_{weight_field}" if filename is None: - filename = os.path.join(self.output_dir, "%s_data" % self.output_prefix) + filename = os.path.join(self.output_dir, f"{self.output_prefix}_data") if not (filename.endswith(".h5")): filename += ".h5" diff --git a/yt_astro_analysis/cosmological_observation/light_cone/tests/test_light_cone.py b/yt_astro_analysis/cosmological_observation/light_cone/tests/test_light_cone.py index cada2c3..a2328d9 100644 --- a/yt_astro_analysis/cosmological_observation/light_cone/tests/test_light_cone.py +++ b/yt_astro_analysis/cosmological_observation/light_cone/tests/test_light_cone.py @@ -84,7 +84,7 @@ def run(self): punits = ( _funits[self.field] * _funits[self.weight_field] * _funits["length"] ) - wunits = fh["weight_field_%s" % self.weight_field].attrs["units"] + wunits = fh[f"weight_field_{self.weight_field}"].attrs["units"] pwunits = _funits[self.weight_field] * _funits["length"] assert wunits == str(pwunits.units) assert units == str(punits.units) diff --git a/yt_astro_analysis/halo_analysis/api.py b/yt_astro_analysis/halo_analysis/api.py index 62a0418..4c1482c 100644 --- a/yt_astro_analysis/halo_analysis/api.py +++ b/yt_astro_analysis/halo_analysis/api.py @@ -25,3 +25,12 @@ VisibleDeprecationWarning, stacklevel=2, ) + +__all__ = [ + "add_quantity", + "add_callback", + "add_filter", + "add_finding_method", + "add_recipe", + "HaloCatalog", +] diff --git a/yt_astro_analysis/halo_analysis/halo_catalog/halo_callbacks.py b/yt_astro_analysis/halo_analysis/halo_catalog/halo_callbacks.py index 3a07813..4e16066 100644 --- a/yt_astro_analysis/halo_analysis/halo_catalog/halo_callbacks.py +++ b/yt_astro_analysis/halo_analysis/halo_catalog/halo_callbacks.py @@ -57,7 +57,7 @@ def halo_sphere(halo, radius_field="virial_radius", factor=1.0, field_parameters """ dds = halo.halo_catalog.data_ds - center = dds.arr([halo.quantities["particle_position_%s" % axis] for axis in "xyz"]) + center = dds.arr([halo.quantities[f"particle_position_{axis}"] for axis in "xyz"]) radius = factor * halo.quantities[radius_field] if radius <= 0.0: halo.data_object = None @@ -255,7 +255,7 @@ def profile( field: my_profile.standard_deviation[field] for field in my_profile.standard_deviation } - variance_storage = "%s_variance" % storage + variance_storage = f"{storage}_variance" if hasattr(halo, variance_storage): halo_variance_store = getattr(halo, variance_storage) else: @@ -315,7 +315,7 @@ def save_profiles(halo, storage="profiles", filename=None, output_dir="."): if isinstance(my_profile[field], YTArray): my_profile[field].convert_to_cgs() _yt_array_hdf5(profile_group, str(field), my_profile[field]) - variance_storage = "%s_variance" % storage + variance_storage = f"{storage}_variance" if hasattr(halo, variance_storage): my_profile = getattr(halo, variance_storage) variance_group = fh.create_group("variance") @@ -364,7 +364,7 @@ def load_profiles(halo, storage="profiles", fields=None, filename=None, output_d "%s_%06d.h5" % (filename, halo.quantities["particle_identifier"]), ) if not os.path.exists(output_file): - raise RuntimeError("Profile file not found: %s." % output_file) + raise RuntimeError(f"Profile file not found: {output_file}.") mylog.info( "Loading halo %d profile data from %s.", halo.quantities["particle_identifier"], @@ -397,7 +397,7 @@ def load_profiles(halo, storage="profiles", fields=None, filename=None, output_d my_variance[field] = _hdf5_yt_array( my_group, field, ds=halo.halo_catalog.halos_ds ) - setattr(halo, "%s_variance" % storage, my_variance) + setattr(halo, f"{storage}_variance", my_variance) fh.close() @@ -451,8 +451,7 @@ def virial_quantities( if overdensity_field not in profile_data: raise RuntimeError( - "virial_quantities callback requires profile of %s." - % str(overdensity_field) + f"virial_quantities callback requires profile of {str(overdensity_field)}." ) overdensity = profile_data[overdensity_field] @@ -630,7 +629,7 @@ def iterative_center_of_mass( ) center_orig = halo.halo_catalog.data_ds.arr( - [halo.quantities["particle_position_%s" % axis] for axis in "xyz"] + [halo.quantities[f"particle_position_{axis}"] for axis in "xyz"] ) sphere = halo.halo_catalog.data_ds.sphere( center_orig, outer_radius * halo.quantities[radius_field] @@ -653,7 +652,7 @@ def iterative_center_of_mass( ) for i, axis in enumerate("xyz"): - halo.quantities["particle_position_%s" % axis] = sphere.center[i] + halo.quantities[f"particle_position_{axis}"] = sphere.center[i] del sphere diff --git a/yt_astro_analysis/halo_analysis/halo_catalog/halo_filters.py b/yt_astro_analysis/halo_analysis/halo_catalog/halo_filters.py index f280534..60ab593 100644 --- a/yt_astro_analysis/halo_analysis/halo_catalog/halo_filters.py +++ b/yt_astro_analysis/halo_analysis/halo_catalog/halo_filters.py @@ -31,7 +31,7 @@ def quantity_value(halo, field, operator, value, units): """ if field not in halo.quantities: - raise RuntimeError("Halo object does not contain %s quantity." % field) + raise RuntimeError(f"Halo object does not contain {field} quantity.") h_value = halo.quantities[field].in_units(units).to_ndarray() return eval(f"{h_value} {operator} {value}") diff --git a/yt_astro_analysis/halo_analysis/halo_finding/api.py b/yt_astro_analysis/halo_analysis/halo_finding/api.py index 0795bd4..a8875c3 100644 --- a/yt_astro_analysis/halo_analysis/halo_finding/api.py +++ b/yt_astro_analysis/halo_analysis/halo_finding/api.py @@ -26,3 +26,5 @@ ) from yt_astro_analysis.halo_finding.halo_objects import FOFHaloFinder, HOPHaloFinder + +__all__ = ["FOFHaloFinder", "HOPHaloFinder"] diff --git a/yt_astro_analysis/halo_analysis/halo_finding/halo_objects.py b/yt_astro_analysis/halo_analysis/halo_finding/halo_objects.py index ecdc575..2c8b33e 100644 --- a/yt_astro_analysis/halo_analysis/halo_finding/halo_objects.py +++ b/yt_astro_analysis/halo_analysis/halo_finding/halo_objects.py @@ -573,7 +573,7 @@ def maximum_density_location(self): class HaloList: - _fields = ["particle_position_%s" % ax for ax in "xyz"] + _fields = [f"particle_position_{ax}" for ax in "xyz"] def __init__(self, data_source, redshift=-1, ptype="all"): """ @@ -627,7 +627,7 @@ def _parse_output(self): ) md_i = np.argmax(dens[cp:cp_c]) px, py, pz = ( - self.particle_fields["particle_position_%s" % ax][group_indices] + self.particle_fields[f"particle_position_{ax}"][group_indices] for ax in "xyz" ) self._max_dens[i] = (dens[cp:cp_c][md_i], px[md_i], py[md_i], pz[md_i]) @@ -651,7 +651,7 @@ class HOPHaloList(HaloList): _name = "HOP" _halo_class = HOPHalo - _fields = ["particle_position_%s" % ax for ax in "xyz"] + ["particle_mass"] + _fields = [f"particle_position_{ax}" for ax in "xyz"] + ["particle_mass"] def __init__(self, data_source, threshold=160.0, ptype="all"): self.threshold = threshold @@ -740,7 +740,7 @@ def _reposition_particles(self, bounds): LE, RE = bounds dw = self.ds.domain_right_edge - self.ds.domain_left_edge for i, ax in enumerate("xyz"): - arr = self._data_source[self.ptype, "particle_position_%s" % ax] + arr = self._data_source[self.ptype, f"particle_position_{ax}"] arr[arr < LE[i] - self.padding] += dw[i] arr[arr > RE[i] + self.padding] -= dw[i] diff --git a/yt_astro_analysis/halo_analysis/halo_finding/rockstar/api.py b/yt_astro_analysis/halo_analysis/halo_finding/rockstar/api.py index 291af29..942aa34 100644 --- a/yt_astro_analysis/halo_analysis/halo_finding/rockstar/api.py +++ b/yt_astro_analysis/halo_analysis/halo_finding/rockstar/api.py @@ -28,3 +28,6 @@ from yt_astro_analysis.halo_analysis.halo_finding.rockstar.rockstar import ( RockstarHaloFinder, ) + + +__all__ = ["RockstarHaloFinder"] diff --git a/yt_astro_analysis/halo_analysis/halo_finding/rockstar/rockstar.py b/yt_astro_analysis/halo_analysis/halo_finding/rockstar/rockstar.py index 50e8ef3..7d0d58c 100644 --- a/yt_astro_analysis/halo_analysis/halo_finding/rockstar/rockstar.py +++ b/yt_astro_analysis/halo_analysis/halo_finding/rockstar/rockstar.py @@ -301,7 +301,7 @@ def _setup_parameters(self, ts): if ptype not in tds.particle_types and ptype != "all": has_particle_filter = tds.add_particle_filter(ptype) if not has_particle_filter: - raise RuntimeError("Particle type (filter) %s not found." % (ptype)) + raise RuntimeError(f"Particle type (filter) {ptype} not found.") dd = tds.all_data() # Get DM particle mass. @@ -370,7 +370,7 @@ def run(self, block_ratio=1, callbacks=None, restart=False): if restart: restart_file = os.path.join(self.outbase, "restart.cfg") if not os.path.exists(restart_file): - raise RuntimeError("Restart file %s not found" % (restart_file)) + raise RuntimeError(f"Restart file {restart_file} not found") with open(restart_file) as restart_fh: for par in restart_fh: if par.startswith("RESTART_SNAP"): diff --git a/yt_astro_analysis/halo_analysis/tests/test_halo_catalog.py b/yt_astro_analysis/halo_analysis/tests/test_halo_catalog.py index 79bfd54..d17cf99 100644 --- a/yt_astro_analysis/halo_analysis/tests/test_halo_catalog.py +++ b/yt_astro_analysis/halo_analysis/tests/test_halo_catalog.py @@ -60,7 +60,7 @@ def run(self): hc.add_quantity("nstars") hc.create() - fn = os.path.join(tmpdir, str(dds), "%s.0.h5" % str(dds)) + fn = os.path.join(tmpdir, str(dds), f"{str(dds)}.0.h5") ds = load(fn) ad = ds.all_data() mi, ma = ad.quantities.extrema("nstars") diff --git a/yt_astro_analysis/ppv_cube/api.py b/yt_astro_analysis/ppv_cube/api.py index 1e5b306..dfa11a1 100644 --- a/yt_astro_analysis/ppv_cube/api.py +++ b/yt_astro_analysis/ppv_cube/api.py @@ -11,3 +11,5 @@ # ----------------------------------------------------------------------------- from yt_astro_analysis.ppv_cube.ppv_cube import PPVCube + +__all__ = ["PPVCube"] diff --git a/yt_astro_analysis/ppv_cube/ppv_cube.py b/yt_astro_analysis/ppv_cube/ppv_cube.py index de21026..f3edd3a 100644 --- a/yt_astro_analysis/ppv_cube/ppv_cube.py +++ b/yt_astro_analysis/ppv_cube/ppv_cube.py @@ -39,7 +39,7 @@ def _v_los(field, data): elif isinstance(normal, str): def _v_los(field, data): - return -data["gas", "velocity_%s" % normal] + return -data["gas", f"velocity_{normal}"] else: orient = Orientation(normal) diff --git a/yt_astro_analysis/radmc3d_export/RadMC3DInterface.py b/yt_astro_analysis/radmc3d_export/RadMC3DInterface.py index d44c69c..d9d5ca8 100644 --- a/yt_astro_analysis/radmc3d_export/RadMC3DInterface.py +++ b/yt_astro_analysis/radmc3d_export/RadMC3DInterface.py @@ -376,7 +376,7 @@ def write_source_files(self, sources, wavelengths): # write wavelength information for wavelength in wavelengths: - fhandle.write("%f \n" % wavelength) + fhandle.write(f"{wavelength:f} \n") # finally write blackbody temperature for each source for source in sources: @@ -394,7 +394,7 @@ def write_source_files(self, sources, wavelengths): fhandle.write("%d \n" % nlam) for wavelength in wavelengths: - fhandle.write("%f \n" % wavelength) + fhandle.write(f"{wavelength:f} \n") # done with both fhandle.close() diff --git a/yt_astro_analysis/radmc3d_export/api.py b/yt_astro_analysis/radmc3d_export/api.py index ff8de05..ee459f2 100644 --- a/yt_astro_analysis/radmc3d_export/api.py +++ b/yt_astro_analysis/radmc3d_export/api.py @@ -18,3 +18,5 @@ RadMC3DSource, RadMC3DWriter, ) + +__all__ = ["read_radmc3d_image", "RadMC3DSource", "RadMC3DWriter"]