diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d7edfeda884..82eb85ba4df 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,7 @@ repos: - id: check-yaml - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black-jupyter @@ -39,7 +39,7 @@ repos: additional_dependencies: [black==23.9.1] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.9 + rev: v0.2.0 hooks: - id: ruff args: [--fix] diff --git a/doc/source/cookbook/tests/test_cookbook.py b/doc/source/cookbook/tests/test_cookbook.py index 6a855fc6100..d27f49a5982 100644 --- a/doc/source/cookbook/tests/test_cookbook.py +++ b/doc/source/cookbook/tests/test_cookbook.py @@ -8,6 +8,7 @@ $ sed -e '/where/d' -i nose.cfg setup.cfg $ nosetests doc/source/cookbook/tests/test_cookbook.py -P -v """ + import subprocess import sys diff --git a/tests/nose_runner.py b/tests/nose_runner.py index 630a28e936a..d30d7d3090a 100644 --- a/tests/nose_runner.py +++ b/tests/nose_runner.py @@ -99,9 +99,11 @@ def generate_tasks_input(): exclude_answers = [f"--exclude-test={ex}" for ex in exclude_answers] args = [ - (item + [f"--xunit-file={item[0]}.xml"], exclusive) - if item[0] != "unittests" - else (item + ["--xunit-file=unittests.xml"] + exclude_answers, exclusive) + ( + (item + [f"--xunit-file={item[0]}.xml"], exclusive) + if item[0] != "unittests" + else (item + ["--xunit-file=unittests.xml"] + exclude_answers, exclusive) + ) for item, exclusive in args ] return args diff --git a/tests/pytest_runner.py b/tests/pytest_runner.py index bf9b0f1b7ac..a1659b9ca68 100644 --- a/tests/pytest_runner.py +++ b/tests/pytest_runner.py @@ -6,7 +6,6 @@ for executing answer tests and optionally generating new answers. """ - import glob import os diff --git a/tests/report_failed_answers.py b/tests/report_failed_answers.py index 92ee11c6095..bd885d05c42 100644 --- a/tests/report_failed_answers.py +++ b/tests/report_failed_answers.py @@ -4,7 +4,6 @@ """ - import argparse import base64 import collections diff --git a/yt/__init__.py b/yt/__init__.py index 3152128cddb..44adcc6b7b5 100644 --- a/yt/__init__.py +++ b/yt/__init__.py @@ -7,6 +7,7 @@ * Contribute: https://github.com/yt-project/yt """ + from ._version import __version__, version_info # isort: skip import yt.units as units import yt.utilities.physical_constants as physical_constants diff --git a/yt/data_objects/construction_data_containers.py b/yt/data_objects/construction_data_containers.py index 677d72a9201..fc782efad51 100644 --- a/yt/data_objects/construction_data_containers.py +++ b/yt/data_objects/construction_data_containers.py @@ -1653,6 +1653,7 @@ class YTSurface(YTSelectionContainer3D): ... ] >>> surf.export_ply("my_galaxy.ply", bounds=bounds) """ + _type_name = "surface" _con_args = ("data_source", "surface_field", "field_value") _container_fields = ( diff --git a/yt/data_objects/static_output.py b/yt/data_objects/static_output.py index a362859cccf..98d71f4c51b 100644 --- a/yt/data_objects/static_output.py +++ b/yt/data_objects/static_output.py @@ -85,9 +85,9 @@ # to here, and then have it instantiate EnzoDatasets as appropriate. -_cached_datasets: MutableMapping[ - Union[int, str], "Dataset" -] = weakref.WeakValueDictionary() +_cached_datasets: MutableMapping[Union[int, str], "Dataset"] = ( + weakref.WeakValueDictionary() +) # we set this global to None as a place holder # its actual instantiation is delayed until after yt.__init__ diff --git a/yt/data_objects/time_series.py b/yt/data_objects/time_series.py index 7755bcaca45..444519967dd 100644 --- a/yt/data_objects/time_series.py +++ b/yt/data_objects/time_series.py @@ -143,6 +143,7 @@ class DatasetSeries: ... SlicePlot(ds, "x", ("gas", "density")).save() """ + # this annotation should really be Optional[Type[Dataset]] # but we cannot import the yt.data_objects.static_output.Dataset # class here without creating a circular import for now diff --git a/yt/data_objects/unions.py b/yt/data_objects/unions.py index 30da0a58683..4559a113d3b 100644 --- a/yt/data_objects/unions.py +++ b/yt/data_objects/unions.py @@ -6,8 +6,7 @@ class Union(ABC): @property @abstractmethod - def _union_type(self) -> str: - ... + def _union_type(self) -> str: ... def __init__(self, name, sub_types): self.name = name diff --git a/yt/exthook.py b/yt/exthook.py index 4fdf6df1f12..1aacf0bcbee 100644 --- a/yt/exthook.py +++ b/yt/exthook.py @@ -18,6 +18,7 @@ :copyright: (c) 2015 by Armin Ronacher. :license: BSD, see LICENSE for more details. """ + # This source code was originally in flask/exthook.py import os import sys diff --git a/yt/fields/magnetic_field.py b/yt/fields/magnetic_field.py index 1c4b04526f9..d9e7cb5792b 100644 --- a/yt/fields/magnetic_field.py +++ b/yt/fields/magnetic_field.py @@ -244,9 +244,7 @@ def _mach_alfven(field, data): rm_scale = pc.qp.to("C", "SI") ** 3 / (4.0 * np.pi * pc.eps_0) else: rm_scale = pc.qp**3 / pc.clight - rm_scale *= registry.ds.quan(1.0, "rad") / ( - 2.0 * np.pi * pc.me**2 * pc.clight**3 - ) + rm_scale *= registry.ds.quan(1.0, "rad") / (2.0 * np.pi * pc.me**2 * pc.clight**3) rm_units = registry.ds.quan(1.0, "rad/m**2").units / unit_system["length"] def _rotation_measure(field, data): diff --git a/yt/frontends/adaptahop/data_structures.py b/yt/frontends/adaptahop/data_structures.py index def628de0b3..6cb8e5e1b0c 100644 --- a/yt/frontends/adaptahop/data_structures.py +++ b/yt/frontends/adaptahop/data_structures.py @@ -6,7 +6,6 @@ """ - import os import re from itertools import product diff --git a/yt/frontends/adaptahop/definitions.py b/yt/frontends/adaptahop/definitions.py index 89a5c656849..a1178ba05c1 100644 --- a/yt/frontends/adaptahop/definitions.py +++ b/yt/frontends/adaptahop/definitions.py @@ -4,6 +4,7 @@ """ + from typing import Union from yt.funcs import mylog diff --git a/yt/frontends/adaptahop/fields.py b/yt/frontends/adaptahop/fields.py index fe5edd7ef62..49eabcec690 100644 --- a/yt/frontends/adaptahop/fields.py +++ b/yt/frontends/adaptahop/fields.py @@ -5,6 +5,7 @@ """ + from yt._typing import KnownFieldsT from yt.fields.field_info_container import FieldInfoContainer diff --git a/yt/frontends/adaptahop/io.py b/yt/frontends/adaptahop/io.py index d4521771b53..96e58da8566 100644 --- a/yt/frontends/adaptahop/io.py +++ b/yt/frontends/adaptahop/io.py @@ -6,7 +6,6 @@ """ - from functools import partial from operator import attrgetter from typing import Union diff --git a/yt/frontends/amrvac/data_structures.py b/yt/frontends/amrvac/data_structures.py index 4fe101cfca0..227555b62f9 100644 --- a/yt/frontends/amrvac/data_structures.py +++ b/yt/frontends/amrvac/data_structures.py @@ -4,6 +4,7 @@ """ + import os import struct import warnings diff --git a/yt/frontends/amrvac/fields.py b/yt/frontends/amrvac/fields.py index 0aa8d6027e4..3c82bd47ad4 100644 --- a/yt/frontends/amrvac/fields.py +++ b/yt/frontends/amrvac/fields.py @@ -3,7 +3,6 @@ """ - import functools import numpy as np diff --git a/yt/frontends/amrvac/io.py b/yt/frontends/amrvac/io.py index 5fbc4d0c866..1be3111a341 100644 --- a/yt/frontends/amrvac/io.py +++ b/yt/frontends/amrvac/io.py @@ -4,6 +4,7 @@ """ + import os import numpy as np diff --git a/yt/frontends/artio/data_structures.py b/yt/frontends/artio/data_structures.py index c220c5f82be..d1460fc88b8 100644 --- a/yt/frontends/artio/data_structures.py +++ b/yt/frontends/artio/data_structures.py @@ -483,9 +483,7 @@ def _parse_parameter_file(self): ] self.parameters["unit_m"] = self.artio_parameters["mass_unit"][0] - self.parameters["unit_t"] = ( - self.artio_parameters["time_unit"][0] * abox**2 - ) + self.parameters["unit_t"] = self.artio_parameters["time_unit"][0] * abox**2 self.parameters["unit_l"] = self.artio_parameters["length_unit"][0] * abox if self.artio_parameters["DeltaDC"][0] != 0: diff --git a/yt/frontends/athena/data_structures.py b/yt/frontends/athena/data_structures.py index b19a5a7e090..18e2de43cb4 100644 --- a/yt/frontends/athena/data_structures.py +++ b/yt/frontends/athena/data_structures.py @@ -615,10 +615,10 @@ def _parse_parameter_file(self): self.omega_matter = 0.0 self.hubble_constant = 0.0 self.cosmological_simulation = 0 - self.parameters["Time"] = self.current_time # Hardcode time conversion for now. - self.parameters[ - "HydroMethod" - ] = 0 # Hardcode for now until field staggering is supported. + # Hardcode time conversion for now. + self.parameters["Time"] = self.current_time + # Hardcode for now until field staggering is supported. + self.parameters["HydroMethod"] = 0 if "gamma" in self.specified_parameters: self.parameters["Gamma"] = self.specified_parameters["gamma"] else: diff --git a/yt/frontends/athena_pp/data_structures.py b/yt/frontends/athena_pp/data_structures.py index 95ed790e1a3..506a4109011 100644 --- a/yt/frontends/athena_pp/data_structures.py +++ b/yt/frontends/athena_pp/data_structures.py @@ -241,10 +241,10 @@ def _parse_parameter_file(self): self.omega_matter = 0.0 self.hubble_constant = 0.0 self.cosmological_simulation = 0 - self.parameters["Time"] = self.current_time # Hardcode time conversion for now. - self.parameters[ - "HydroMethod" - ] = 0 # Hardcode for now until field staggering is supported. + # Hardcode time conversion for now. + self.parameters["Time"] = self.current_time + # Hardcode for now until field staggering is supported. + self.parameters["HydroMethod"] = 0 if "gamma" in self.specified_parameters: self.parameters["Gamma"] = self.specified_parameters["gamma"] else: diff --git a/yt/frontends/cf_radial/data_structures.py b/yt/frontends/cf_radial/data_structures.py index 9d362b90311..436517b3004 100644 --- a/yt/frontends/cf_radial/data_structures.py +++ b/yt/frontends/cf_radial/data_structures.py @@ -4,6 +4,7 @@ """ + import contextlib import os import weakref diff --git a/yt/frontends/cf_radial/tests/test_outputs.py b/yt/frontends/cf_radial/tests/test_outputs.py index ce9cc3b3810..f0798ce66e1 100644 --- a/yt/frontends/cf_radial/tests/test_outputs.py +++ b/yt/frontends/cf_radial/tests/test_outputs.py @@ -4,6 +4,7 @@ """ + import os import shutil import tempfile diff --git a/yt/frontends/chimera/fields.py b/yt/frontends/chimera/fields.py index 9b576277bf7..7ca9e80f989 100644 --- a/yt/frontends/chimera/fields.py +++ b/yt/frontends/chimera/fields.py @@ -4,6 +4,7 @@ """ + from yt._typing import KnownFieldsT from yt.fields.field_info_container import FieldInfoContainer diff --git a/yt/frontends/gdf/data_structures.py b/yt/frontends/gdf/data_structures.py index 13fc61d6701..1bb7a88b663 100644 --- a/yt/frontends/gdf/data_structures.py +++ b/yt/frontends/gdf/data_structures.py @@ -278,7 +278,8 @@ def _parse_parameter_file(self): self.omega_matter = 0.0 self.hubble_constant = 0.0 self.cosmological_simulation = 0 - self.parameters["Time"] = 1.0 # Hardcode time conversion for now. + # Hardcode time conversion for now. + self.parameters["Time"] = 1.0 # Hardcode for now until field staggering is supported. self.parameters["HydroMethod"] = 0 self._handle.close() diff --git a/yt/frontends/gdf/tests/conftest.py b/yt/frontends/gdf/tests/conftest.py index ae3c17c486a..2715a202ca0 100644 --- a/yt/frontends/gdf/tests/conftest.py +++ b/yt/frontends/gdf/tests/conftest.py @@ -3,7 +3,6 @@ Purpose: Contains fixtures for loading data. """ - # Test data sedov = "sedov/sedov_tst_0004.h5" diff --git a/yt/frontends/open_pmd/fields.py b/yt/frontends/open_pmd/fields.py index c67dfc18dee..709070981ed 100644 --- a/yt/frontends/open_pmd/fields.py +++ b/yt/frontends/open_pmd/fields.py @@ -68,9 +68,7 @@ def velocity(field, data): momentum = data[ptype, f"particle_momentum_{axis}"] mass = data[ptype, "particle_mass"] weighting = data[ptype, "particle_weighting"] - return momentum / np.sqrt( - (mass * weighting) ** 2 + (momentum**2) / (c**2) - ) + return momentum / np.sqrt((mass * weighting) ** 2 + (momentum**2) / (c**2)) return velocity diff --git a/yt/frontends/owls/owls_ion_tables.py b/yt/frontends/owls/owls_ion_tables.py index abdccb6af2f..b139b4486fa 100644 --- a/yt/frontends/owls/owls_ion_tables.py +++ b/yt/frontends/owls/owls_ion_tables.py @@ -20,7 +20,6 @@ def h5rd(fname, path, dtype=None): class IonTableSpectrum: - """A class to handle the HM01 spectra in the OWLS ionization tables.""" def __init__(self, ion_file): @@ -60,7 +59,6 @@ def return_table_GH1_at_z(self, z): class IonTableOWLS: - """A class to handle OWLS ionization tables.""" DELTA_nH = 0.25 diff --git a/yt/frontends/ramses/field_handlers.py b/yt/frontends/ramses/field_handlers.py index 2c4160d27ed..1cb1203a78a 100644 --- a/yt/frontends/ramses/field_handlers.py +++ b/yt/frontends/ramses/field_handlers.py @@ -144,9 +144,8 @@ class FieldFileHandler(abc.ABC, HandlerMixin): # These properties are static properties ftype: Optional[str] = None # The name to give to the field type fname: Optional[str] = None # The name of the file(s) - attrs: Optional[ - tuple[tuple[str, int, str], ...] - ] = None # The attributes of the header + # The attributes of the header + attrs: Optional[tuple[tuple[str, int, str], ...]] = None known_fields = None # A list of tuple containing the field name and its type config_field: Optional[str] = None # Name of the config section (if any) diff --git a/yt/frontends/sph/io.py b/yt/frontends/sph/io.py index 184623e58a6..785d4d850b5 100644 --- a/yt/frontends/sph/io.py +++ b/yt/frontends/sph/io.py @@ -5,6 +5,7 @@ """ + from yt.utilities.io_handler import BaseParticleIOHandler diff --git a/yt/geometry/coordinates/coordinate_handler.py b/yt/geometry/coordinates/coordinate_handler.py index 6f02dc04cbe..5cda09f4180 100644 --- a/yt/geometry/coordinates/coordinate_handler.py +++ b/yt/geometry/coordinates/coordinate_handler.py @@ -158,8 +158,7 @@ def pixelize( periodic=True, *, return_mask: Literal[False], - ) -> "np.ndarray[Any, np.dtype[np.float64]]": - ... + ) -> "np.ndarray[Any, np.dtype[np.float64]]": ... @overload def pixelize( @@ -175,8 +174,7 @@ def pixelize( return_mask: Literal[True], ) -> tuple[ "np.ndarray[Any, np.dtype[np.float64]]", "np.ndarray[Any, np.dtype[np.bool_]]" - ]: - ... + ]: ... @abc.abstractmethod def pixelize( diff --git a/yt/loaders.py b/yt/loaders.py index 43fbafbeeed..694fe847b8b 100644 --- a/yt/loaders.py +++ b/yt/loaders.py @@ -2,6 +2,7 @@ This module gathers all user-facing functions with a `load_` prefix. """ + import atexit import os import sys diff --git a/yt/sample_data/api.py b/yt/sample_data/api.py index 3d4e84fb3ea..e0de2c12a1f 100644 --- a/yt/sample_data/api.py +++ b/yt/sample_data/api.py @@ -1,6 +1,7 @@ """ This is a collection of helper functions to yt.load_sample """ + import json import re import sys diff --git a/yt/testing.py b/yt/testing.py index 7831fb4a167..ecda3b3ab7f 100644 --- a/yt/testing.py +++ b/yt/testing.py @@ -154,15 +154,19 @@ def amrspace(extent, levels=7, cells=8): # fill non-zero dims dcell = 1.0 / cells left_slice = tuple( - slice(extent[2 * n], extent[2 * n + 1], extent[2 * n + 1]) - if dims_zero[n] - else slice(0.0, 1.0, dcell) + ( + slice(extent[2 * n], extent[2 * n + 1], extent[2 * n + 1]) + if dims_zero[n] + else slice(0.0, 1.0, dcell) + ) for n in range(ndims) ) right_slice = tuple( - slice(extent[2 * n + 1], extent[2 * n], -extent[2 * n + 1]) - if dims_zero[n] - else slice(dcell, 1.0 + dcell, dcell) + ( + slice(extent[2 * n + 1], extent[2 * n], -extent[2 * n + 1]) + if dims_zero[n] + else slice(dcell, 1.0 + dcell, dcell) + ) for n in range(ndims) ) left_norm_grid = np.reshape(np.mgrid[left_slice].T.flat[ndims:], (-1, ndims)) @@ -1541,50 +1545,40 @@ def retf(*args, **kwargs): @_deprecated_numpy_testing_reexport -def assert_array_equal(): - ... +def assert_array_equal(): ... @_deprecated_numpy_testing_reexport -def assert_almost_equal(): - ... +def assert_almost_equal(): ... @_deprecated_numpy_testing_reexport -def assert_equal(): - ... +def assert_equal(): ... @_deprecated_numpy_testing_reexport -def assert_array_less(): - ... +def assert_array_less(): ... @_deprecated_numpy_testing_reexport -def assert_string_equal(): - ... +def assert_string_equal(): ... @_deprecated_numpy_testing_reexport -def assert_array_almost_equal_nulp(): - ... +def assert_array_almost_equal_nulp(): ... @_deprecated_numpy_testing_reexport -def assert_allclose(): - ... +def assert_allclose(): ... @_deprecated_numpy_testing_reexport -def assert_raises(): - ... +def assert_raises(): ... @_deprecated_numpy_testing_reexport -def assert_approx_equal(): - ... +def assert_approx_equal(): ... @_deprecated_numpy_testing_reexport -def assert_array_almost_equal(): - ... +def assert_array_almost_equal(): ... diff --git a/yt/utilities/answer_testing/answer_tests.py b/yt/utilities/answer_testing/answer_tests.py index a5c4a9cd620..31a6fbb8a7e 100644 --- a/yt/utilities/answer_testing/answer_tests.py +++ b/yt/utilities/answer_testing/answer_tests.py @@ -2,6 +2,7 @@ Title: answer_tests.py Purpose: Contains answer tests that are used by yt's various frontends """ + import hashlib import os import tempfile diff --git a/yt/utilities/answer_testing/framework.py b/yt/utilities/answer_testing/framework.py index 1464a30b41f..4abf1531519 100644 --- a/yt/utilities/answer_testing/framework.py +++ b/yt/utilities/answer_testing/framework.py @@ -2,6 +2,7 @@ Title: framework.py Purpose: Contains answer tests that are used by yt's various frontends """ + import contextlib import hashlib import logging diff --git a/yt/utilities/grid_data_format/writer.py b/yt/utilities/grid_data_format/writer.py index 85b1935e6c1..5391dff592b 100644 --- a/yt/utilities/grid_data_format/writer.py +++ b/yt/utilities/grid_data_format/writer.py @@ -145,13 +145,13 @@ def _write_fields_to_gdf( # check that they actually contain something... if display_name: - sg.attrs["field_name"] = np.string_(display_name) + sg.attrs["field_name"] = np.bytes_(display_name) else: - sg.attrs["field_name"] = np.string_(str(field)) + sg.attrs["field_name"] = np.bytes_(str(field)) if units: - sg.attrs["field_units"] = np.string_(units) + sg.attrs["field_units"] = np.bytes_(units) else: - sg.attrs["field_units"] = np.string_("None") + sg.attrs["field_units"] = np.bytes_("None") # @todo: is this always true? sg.attrs["staggering"] = 0 @@ -324,7 +324,7 @@ def _create_new_gdf( # @todo: Particle type iterator sg = g.create_group(particle_type_name) - sg["particle_type_name"] = np.string_(particle_type_name) + sg["particle_type_name"] = np.bytes_(particle_type_name) ### # root datasets -- info about the grids diff --git a/yt/utilities/lib/cykdtree/tests/scaling.py b/yt/utilities/lib/cykdtree/tests/scaling.py index 9b19a922e81..2974c20af2e 100644 --- a/yt/utilities/lib/cykdtree/tests/scaling.py +++ b/yt/utilities/lib/cykdtree/tests/scaling.py @@ -1,4 +1,5 @@ r"""Routines for tracking the scaling of the triangulation routines.""" + import cProfile import os import pstats diff --git a/yt/utilities/lib/tests/test_alt_ray_tracers.py b/yt/utilities/lib/tests/test_alt_ray_tracers.py index 7a61b6bad28..820f0503c6c 100644 --- a/yt/utilities/lib/tests/test_alt_ray_tracers.py +++ b/yt/utilities/lib/tests/test_alt_ray_tracers.py @@ -1,4 +1,5 @@ """Tests for non-cartesian ray tracers.""" + import numpy as np from numpy.testing import assert_equal diff --git a/yt/utilities/lodgeit.py b/yt/utilities/lodgeit.py index 32fea65c1bb..cc4680d2de9 100644 --- a/yt/utilities/lodgeit.py +++ b/yt/utilities/lodgeit.py @@ -24,6 +24,7 @@ 2006 Matt Good , 2005 Raphael Slinckx """ + import os import sys from optparse import OptionParser diff --git a/yt/utilities/sdf.py b/yt/utilities/sdf.py index 42836bc18ac..2ee44c17160 100644 --- a/yt/utilities/sdf.py +++ b/yt/utilities/sdf.py @@ -557,7 +557,6 @@ def _shift_periodic(pos, left, right, domain_width): class SDFIndex: - """docstring for SDFIndex This provides an index mechanism into the full SDF Dataset. diff --git a/yt/utilities/tests/test_config.py b/yt/utilities/tests/test_config.py index 513818a2b06..5ce441070ce 100644 --- a/yt/utilities/tests/test_config.py +++ b/yt/utilities/tests/test_config.py @@ -69,9 +69,11 @@ def _runYTConfig(self, args): args = ["yt", "config"] + args retcode = 0 - with mock.patch.object(sys, "argv", args), mock.patch( - "sys.exit", side_effect=SysExitException - ) as exit, captureOutput() as output: + with ( + mock.patch.object(sys, "argv", args), + mock.patch("sys.exit", side_effect=SysExitException) as exit, + captureOutput() as output, + ): try: yt.utilities.command_line.run_main() except SysExitException: diff --git a/yt/utilities/tree_container.py b/yt/utilities/tree_container.py index d41d4df588d..350e5f96302 100644 --- a/yt/utilities/tree_container.py +++ b/yt/utilities/tree_container.py @@ -3,6 +3,7 @@ class TreeContainer: clump-finder trees. """ + _child_attr = "children" def __init__(self): diff --git a/yt/visualization/color_maps.py b/yt/visualization/color_maps.py index 02cc49b16f9..c4ba1d9c2ab 100644 --- a/yt/visualization/color_maps.py +++ b/yt/visualization/color_maps.py @@ -331,9 +331,9 @@ def make_colormap(ctuple_list, name=None, interpolate=True): # Use np.round to make sure you're on a discrete index interval = int(np.round(next_index) - np.round(rolling_index)) for j in np.arange(3): - cmap[ - int(np.rint(rolling_index)) : int(np.rint(next_index)), j - ] = np.linspace(color[j], next_color[j], num=interval) + cmap[int(np.rint(rolling_index)) : int(np.rint(next_index)), j] = ( + np.linspace(color[j], next_color[j], num=interval) + ) rolling_index = next_index diff --git a/yt/visualization/fixed_resolution.py b/yt/visualization/fixed_resolution.py index 7e1123cdf6f..1076d4730c6 100644 --- a/yt/visualization/fixed_resolution.py +++ b/yt/visualization/fixed_resolution.py @@ -82,6 +82,7 @@ class FixedResolutionBuffer: >>> print(frb1[("gas", "temperature")].max()) 104923.1 K """ + _exclude_fields = ( "pz", "pdz", diff --git a/yt/visualization/fixed_resolution_filters.py b/yt/visualization/fixed_resolution_filters.py index 35063e798bc..25ca0a0250b 100644 --- a/yt/visualization/fixed_resolution_filters.py +++ b/yt/visualization/fixed_resolution_filters.py @@ -27,7 +27,6 @@ def newfunc(self, *args, **kwargs): class FixedResolutionBufferFilter(ABC): - """ This object allows to apply data transformation directly to :class:`yt.visualization.fixed_resolution.FixedResolutionBuffer` @@ -70,7 +69,6 @@ def __call__(self, buff: np.ndarray) -> np.ndarray: class FixedResolutionBufferGaussBeamFilter(FixedResolutionBufferFilter): - """ This filter convolves :class:`yt.visualization.fixed_resolution.FixedResolutionBuffer` with @@ -104,7 +102,6 @@ def apply(self, buff): class FixedResolutionBufferWhiteNoiseFilter(FixedResolutionBufferFilter): - """ This filter adds white noise with the amplitude "bg_lvl" to :class:`yt.visualization.fixed_resolution.FixedResolutionBuffer`. diff --git a/yt/visualization/line_plot.py b/yt/visualization/line_plot.py index 2d44176138c..888f5708ab3 100644 --- a/yt/visualization/line_plot.py +++ b/yt/visualization/line_plot.py @@ -148,6 +148,7 @@ class LinePlot(BaseLinePlot): >>> plot.save() """ + _plot_dict_type = LinePlotDictionary _plot_type = "line_plot" diff --git a/yt/visualization/particle_plots.py b/yt/visualization/particle_plots.py index 6d4b92670bd..4e24f4fada0 100644 --- a/yt/visualization/particle_plots.py +++ b/yt/visualization/particle_plots.py @@ -325,6 +325,7 @@ class ParticleProjectionPlot(PWViewerMPL, NormalPlot): >>> p.save() """ + _plot_type = "Particle" _frb_generator = ParticleImageBuffer @@ -553,6 +554,7 @@ class ParticlePhasePlot(PhasePlot): >>> plot.set_unit("particle_mass", "Msun") """ + _plot_type = "ParticlePhase" def __init__( diff --git a/yt/visualization/plot_window.py b/yt/visualization/plot_window.py index 412cc28f8ad..bb6cae9c9dc 100644 --- a/yt/visualization/plot_window.py +++ b/yt/visualization/plot_window.py @@ -1785,6 +1785,7 @@ class AxisAlignedSlicePlot(SlicePlot, PWViewerMPL): >>> p.save("sliceplot") """ + _plot_type = "Slice" _frb_generator = FixedResolutionBuffer @@ -2011,6 +2012,7 @@ class AxisAlignedProjectionPlot(ProjectionPlot, PWViewerMPL): >>> p = AxisAlignedProjectionPlot(ds, "z", ("gas", "density"), width=(20, "kpc")) """ + _plot_type = "Projection" _frb_generator = FixedResolutionBuffer @@ -2407,6 +2409,7 @@ class OffAxisProjectionPlot(ProjectionPlot, PWViewerMPL): used. Effectively sets a resolution limit to the image if buff_size is smaller than the finest gridding. """ + _plot_type = "OffAxisProjection" _frb_generator = OffAxisProjectionFixedResolutionBuffer _supported_geometries = ("cartesian", "spectral_cube") diff --git a/yt/visualization/profile_plotter.py b/yt/visualization/profile_plotter.py index 141299be1c1..004352cf903 100644 --- a/yt/visualization/profile_plotter.py +++ b/yt/visualization/profile_plotter.py @@ -178,6 +178,7 @@ class ProfilePlot(BaseLinePlot): Use set_line_property to change line properties of one or all profiles. """ + _default_figure_size = (10.0, 8.0) _default_font_size = 18.0 @@ -911,6 +912,7 @@ class PhasePlot(ImagePlotContainer): >>> plot.annotate_title("This is a phase plot") """ + x_log = None y_log = None plot_title = None diff --git a/yt/visualization/tests/test_particle_plot.py b/yt/visualization/tests/test_particle_plot.py index 6d2a735e950..a6cddbae3a5 100644 --- a/yt/visualization/tests/test_particle_plot.py +++ b/yt/visualization/tests/test_particle_plot.py @@ -267,12 +267,10 @@ def test_particle_phase_plot(self): particle_phases.append(ParticlePhasePlot.from_profile(pp)) particle_phases[0]._repr_html_() - with mock.patch( - "matplotlib.backends.backend_agg.FigureCanvasAgg.print_figure" - ), mock.patch( - "matplotlib.backends.backend_pdf.FigureCanvasPdf.print_figure" - ), mock.patch( - "matplotlib.backends.backend_ps.FigureCanvasPS.print_figure" + with ( + mock.patch("matplotlib.backends.backend_agg.FigureCanvasAgg.print_figure"), + mock.patch("matplotlib.backends.backend_pdf.FigureCanvasPdf.print_figure"), + mock.patch("matplotlib.backends.backend_ps.FigureCanvasPS.print_figure"), ): for p in particle_phases: for fname in TEST_FLNMS: @@ -384,12 +382,10 @@ def test_particle_plot(self): ), ] particle_projs[0]._repr_html_() - with mock.patch( - "matplotlib.backends.backend_agg.FigureCanvasAgg.print_figure" - ), mock.patch( - "matplotlib.backends.backend_pdf.FigureCanvasPdf.print_figure" - ), mock.patch( - "matplotlib.backends.backend_ps.FigureCanvasPS.print_figure" + with ( + mock.patch("matplotlib.backends.backend_agg.FigureCanvasAgg.print_figure"), + mock.patch("matplotlib.backends.backend_pdf.FigureCanvasPdf.print_figure"), + mock.patch("matplotlib.backends.backend_ps.FigureCanvasPS.print_figure"), ): for p in particle_projs: for fname in TEST_FLNMS: diff --git a/yt/visualization/volume_rendering/old_camera.py b/yt/visualization/volume_rendering/old_camera.py index 30d1fda4c4e..cca5ff178a0 100644 --- a/yt/visualization/volume_rendering/old_camera.py +++ b/yt/visualization/volume_rendering/old_camera.py @@ -140,6 +140,7 @@ class Camera(ParallelAnalysisInterface): >>> image = cam.snapshot(fn="my_rendering.png") """ + _sampler_object = VolumeRenderSampler _tf_figure = None _render_figure = None diff --git a/yt/visualization/volume_rendering/scene.py b/yt/visualization/volume_rendering/scene.py index e1a9b2e3f08..e45033cb14c 100644 --- a/yt/visualization/volume_rendering/scene.py +++ b/yt/visualization/volume_rendering/scene.py @@ -29,7 +29,6 @@ class Scene: - """A virtual landscape for a volume rendering. The Scene class is meant to be the primary container for the