diff --git a/conftest.py b/conftest.py index 4bf55b5f8e0..ba16c9be9db 100644 --- a/conftest.py +++ b/conftest.py @@ -18,7 +18,6 @@ from yt.config import ytcfg from yt.utilities.answer_testing import utils - # Global variables can be added to the pytest namespace answer_files = {} diff --git a/scripts/iyt b/scripts/iyt index 0c230574ca8..d00b60c7dd7 100755 --- a/scripts/iyt +++ b/scripts/iyt @@ -1,9 +1,14 @@ #!python from __future__ import print_function + import os import re -from yt.mods import * + +from IPython.terminal.interactiveshell import TerminalInteractiveShell + from yt.data_objects.data_containers import YTDataContainer +from yt.mods import * + namespace = locals().copy() namespace.pop("__builtins__", None) @@ -24,7 +29,6 @@ except ImportError: code.interact(doc, None, namespace) sys.exit() -from IPython.terminal.interactiveshell import TerminalInteractiveShell ip_shell = TerminalInteractiveShell(user_ns=namespace, banner1 = doc, display_banner = True) if "DISPLAY" in os.environ: diff --git a/scripts/pr_backport.py b/scripts/pr_backport.py index b3f521f5b11..0203c5beb35 100644 --- a/scripts/pr_backport.py +++ b/scripts/pr_backport.py @@ -1,8 +1,9 @@ +import shutil +import tempfile + import dateutil.parser import git import requests -import shutil -import tempfile API_URL = 'https://api.github.com/graphql' diff --git a/setup.py b/setup.py index cedd01cddc9..c2deeb6457c 100644 --- a/setup.py +++ b/setup.py @@ -1,21 +1,24 @@ +import glob import os import platform -from concurrent.futures import ThreadPoolExecutor as Pool -import glob import sys +from concurrent.futures import ThreadPoolExecutor as Pool +from distutils.ccompiler import CCompiler +from distutils.version import LooseVersion from sys import platform as _platform -from setuptools import setup, find_packages -from setuptools.extension import Extension + +import pkg_resources +from setuptools import find_packages, setup from setuptools.command.build_ext import build_ext as _build_ext from setuptools.command.sdist import sdist as _sdist -from setupext import \ - check_for_openmp, \ - check_for_pyembree, \ - read_embree_location, \ - in_conda_env -from distutils.version import LooseVersion -from distutils.ccompiler import CCompiler -import pkg_resources +from setuptools.extension import Extension + +from setupext import ( + check_for_openmp, + check_for_pyembree, + in_conda_env, + read_embree_location, +) def _get_cpu_count(): diff --git a/setupext.py b/setupext.py index 92c456babe0..0b66aaefa1c 100644 --- a/setupext.py +++ b/setupext.py @@ -5,14 +5,13 @@ import subprocess import sys import tempfile - from distutils import log from distutils.ccompiler import new_compiler -from distutils.sysconfig import customize_compiler from distutils.errors import CompileError, LinkError -from pkg_resources import resource_filename -from subprocess import Popen, PIPE +from distutils.sysconfig import customize_compiler +from subprocess import PIPE, Popen +from pkg_resources import resource_filename CCODE = """ #include diff --git a/tests/nose_runner.py b/tests/nose_runner.py index 0ec1e0d52f2..681e170a465 100644 --- a/tests/nose_runner.py +++ b/tests/nose_runner.py @@ -1,18 +1,20 @@ -import sys -import os -import yaml import multiprocessing -import nose +import os +import sys +from io import StringIO +import nose +import numpy +import yaml from coverage import Coverage + +from yt.config import ytcfg +from yt.utilities.answer_testing.framework import AnswerTesting + cov = Coverage(config_file=".coveragerc", branch=True, auto_data=True, concurrency="multiprocessing") cov.start() -from io import StringIO -from yt.config import ytcfg -from yt.utilities.answer_testing.framework import AnswerTesting -import numpy numpy.set_printoptions(threshold=5, edgeitems=1, precision=4) class NoseWorker(multiprocessing.Process): diff --git a/tests/report_failed_answers.py b/tests/report_failed_answers.py index 59ceab60bb3..5a3f9f45c1a 100644 --- a/tests/report_failed_answers.py +++ b/tests/report_failed_answers.py @@ -21,6 +21,7 @@ import nose import numpy import requests + from yt.config import ytcfg from yt.utilities.answer_testing.framework import AnswerTesting from yt.utilities.command_line import FileStreamer diff --git a/yt/analysis_modules/absorption_spectrum/api.py b/yt/analysis_modules/absorption_spectrum/api.py index bb66b6f4b45..fef030c4a9d 100644 --- a/yt/analysis_modules/absorption_spectrum/api.py +++ b/yt/analysis_modules/absorption_spectrum/api.py @@ -1,5 +1,4 @@ -from yt.utilities.exceptions import \ - YTModuleRemoved +from yt.utilities.exceptions import YTModuleRemoved raise YTModuleRemoved( "AbsorptionSpectrum", diff --git a/yt/analysis_modules/cosmological_observation/api.py b/yt/analysis_modules/cosmological_observation/api.py index da1df1ec4b7..6aef8c09554 100644 --- a/yt/analysis_modules/cosmological_observation/api.py +++ b/yt/analysis_modules/cosmological_observation/api.py @@ -1,5 +1,4 @@ -from yt.utilities.exceptions import \ - YTModuleRemoved +from yt.utilities.exceptions import YTModuleRemoved raise YTModuleRemoved( "CosmologySplice and LightCone", diff --git a/yt/analysis_modules/halo_analysis/api.py b/yt/analysis_modules/halo_analysis/api.py index e9eb1f054ad..d9bda9bf991 100644 --- a/yt/analysis_modules/halo_analysis/api.py +++ b/yt/analysis_modules/halo_analysis/api.py @@ -1,5 +1,4 @@ -from yt.utilities.exceptions import \ - YTModuleRemoved +from yt.utilities.exceptions import YTModuleRemoved raise YTModuleRemoved( "halo_analysis", diff --git a/yt/analysis_modules/halo_finding/api.py b/yt/analysis_modules/halo_finding/api.py index c0db4ee5e0c..04ea8fe0f8a 100644 --- a/yt/analysis_modules/halo_finding/api.py +++ b/yt/analysis_modules/halo_finding/api.py @@ -1,5 +1,4 @@ -from yt.utilities.exceptions import \ - YTModuleRemoved +from yt.utilities.exceptions import YTModuleRemoved raise YTModuleRemoved( "halo_finding", diff --git a/yt/analysis_modules/halo_mass_function/api.py b/yt/analysis_modules/halo_mass_function/api.py index b978be38cc8..7b885c34a6e 100644 --- a/yt/analysis_modules/halo_mass_function/api.py +++ b/yt/analysis_modules/halo_mass_function/api.py @@ -1,5 +1,4 @@ -from yt.utilities.exceptions import \ - YTModuleRemoved +from yt.utilities.exceptions import YTModuleRemoved raise YTModuleRemoved( "halo_mass_function", diff --git a/yt/analysis_modules/photon_simulator/api.py b/yt/analysis_modules/photon_simulator/api.py index ed738750d0e..b5be89bdd4a 100644 --- a/yt/analysis_modules/photon_simulator/api.py +++ b/yt/analysis_modules/photon_simulator/api.py @@ -1,5 +1,4 @@ -from yt.utilities.exceptions import \ - YTModuleRemoved +from yt.utilities.exceptions import YTModuleRemoved raise YTModuleRemoved( "photon_simulator", diff --git a/yt/analysis_modules/ppv_cube/api.py b/yt/analysis_modules/ppv_cube/api.py index 26012b96fcb..3c5510cd900 100644 --- a/yt/analysis_modules/ppv_cube/api.py +++ b/yt/analysis_modules/ppv_cube/api.py @@ -1,5 +1,4 @@ -from yt.utilities.exceptions import \ - YTModuleRemoved +from yt.utilities.exceptions import YTModuleRemoved raise YTModuleRemoved( "PPVCube", diff --git a/yt/analysis_modules/radmc3d_export/api.py b/yt/analysis_modules/radmc3d_export/api.py index e1d0478f3ea..a0841e1cf5c 100644 --- a/yt/analysis_modules/radmc3d_export/api.py +++ b/yt/analysis_modules/radmc3d_export/api.py @@ -1,5 +1,4 @@ -from yt.utilities.exceptions import \ - YTModuleRemoved +from yt.utilities.exceptions import YTModuleRemoved raise YTModuleRemoved( "radmc3d_export", diff --git a/yt/analysis_modules/star_analysis/api.py b/yt/analysis_modules/star_analysis/api.py index bc4d7cf5dff..c9a6f8fa523 100644 --- a/yt/analysis_modules/star_analysis/api.py +++ b/yt/analysis_modules/star_analysis/api.py @@ -1,5 +1,4 @@ -from yt.utilities.exceptions import \ - YTModuleRemoved +from yt.utilities.exceptions import YTModuleRemoved raise YTModuleRemoved( "star_analysis", diff --git a/yt/analysis_modules/sunrise_export/api.py b/yt/analysis_modules/sunrise_export/api.py index 2e69ffab1c3..bdac8165aad 100644 --- a/yt/analysis_modules/sunrise_export/api.py +++ b/yt/analysis_modules/sunrise_export/api.py @@ -1,5 +1,4 @@ -from yt.utilities.exceptions import \ - YTModuleRemoved +from yt.utilities.exceptions import YTModuleRemoved raise YTModuleRemoved( "sunrise_export", diff --git a/yt/analysis_modules/sunyaev_zeldovich/api.py b/yt/analysis_modules/sunyaev_zeldovich/api.py index e32ec19a91b..eef2607fa49 100644 --- a/yt/analysis_modules/sunyaev_zeldovich/api.py +++ b/yt/analysis_modules/sunyaev_zeldovich/api.py @@ -1,5 +1,4 @@ -from yt.utilities.exceptions import \ - YTModuleRemoved +from yt.utilities.exceptions import YTModuleRemoved raise YTModuleRemoved( "sunyaev_zeldovich", diff --git a/yt/analysis_modules/two_point_functions/api.py b/yt/analysis_modules/two_point_functions/api.py index 6346eb057a6..8d8ee99a90d 100644 --- a/yt/analysis_modules/two_point_functions/api.py +++ b/yt/analysis_modules/two_point_functions/api.py @@ -1,5 +1,4 @@ -from yt.utilities.exceptions import \ - YTModuleRemoved +from yt.utilities.exceptions import YTModuleRemoved raise YTModuleRemoved( "two_point_functions", diff --git a/yt/api.py b/yt/api.py index d9ec8215162..5ac3ae5ca86 100644 --- a/yt/api.py +++ b/yt/api.py @@ -4,4 +4,3 @@ """ - diff --git a/yt/config.py b/yt/config.py index 4657478749f..52a7a727caf 100644 --- a/yt/config.py +++ b/yt/config.py @@ -1,6 +1,6 @@ +import configparser import os import warnings -import configparser ytcfg_defaults = dict( serialize = 'False', diff --git a/yt/convenience.py b/yt/convenience.py index 2b5423905ed..c1f6038b32e 100644 --- a/yt/convenience.py +++ b/yt/convenience.py @@ -3,14 +3,14 @@ # Named imports from yt.config import ytcfg from yt.funcs import mylog -from yt.utilities.parameter_file_storage import \ - output_type_registry, \ - simulation_time_series_registry, \ - EnzoRunDatabase -from yt.utilities.exceptions import \ - YTOutputNotIdentified, \ - YTSimulationNotIdentified +from yt.utilities.exceptions import YTOutputNotIdentified, YTSimulationNotIdentified from yt.utilities.hierarchy_inspection import find_lowest_subclasses +from yt.utilities.parameter_file_storage import ( + EnzoRunDatabase, + output_type_registry, + simulation_time_series_registry, +) + def _sanitize_load_args(*args): """Filter out non-pathlike arguments, ensure list form, and expand '~' tokens""" diff --git a/yt/data_objects/api.py b/yt/data_objects/api.py index 003137181b6..4dca4a02880 100644 --- a/yt/data_objects/api.py +++ b/yt/data_objects/api.py @@ -1,35 +1,10 @@ -from .grid_patch import \ - AMRGridPatch - -from .octree_subset import \ - OctreeSubset - -from .static_output import \ - Dataset - -from .profiles import \ - create_profile, \ - Profile1D, \ - Profile2D, \ - Profile3D, \ - ParticleProfile - -from .time_series import \ - DatasetSeries, \ - DatasetSeriesObject - -from .analyzer_objects import \ - AnalysisTask, analysis_task - -from .data_containers import \ - data_object_registry - -from . import construction_data_containers as __cdc -from . import selection_data_containers as __sdc - -from .image_array import \ - ImageArray - -from .particle_filters import \ - particle_filter, \ - add_particle_filter +from . import construction_data_containers as __cdc, selection_data_containers as __sdc +from .analyzer_objects import AnalysisTask, analysis_task +from .data_containers import data_object_registry +from .grid_patch import AMRGridPatch +from .image_array import ImageArray +from .octree_subset import OctreeSubset +from .particle_filters import add_particle_filter, particle_filter +from .profiles import ParticleProfile, Profile1D, Profile2D, Profile3D, create_profile +from .static_output import Dataset +from .time_series import DatasetSeries, DatasetSeriesObject diff --git a/yt/data_objects/construction_data_containers.py b/yt/data_objects/construction_data_containers.py index a4eeec752cb..7073b22395b 100644 --- a/yt/data_objects/construction_data_containers.py +++ b/yt/data_objects/construction_data_containers.py @@ -1,62 +1,55 @@ -import numpy as np -from functools import wraps import fileinput import io -from re import finditer -from tempfile import NamedTemporaryFile, TemporaryFile import os import sys import zipfile +from functools import wraps +from re import finditer +from tempfile import NamedTemporaryFile, TemporaryFile + +import numpy as np -from yt.config import ytcfg -from yt.data_objects.data_containers import \ - YTSelectionContainer1D, \ - YTSelectionContainer2D, \ - YTSelectionContainer3D -from yt.data_objects.field_data import \ - YTFieldData -from yt.funcs import \ - ensure_list, \ - mylog, \ - get_memory_usage, \ - iterable, \ - only_on_root -from yt.utilities.exceptions import \ - YTParticleDepositionNotImplemented, \ - YTNoAPIKey, \ - YTTooManyVertices -from yt.fields.field_exceptions import \ - NeedsGridType -from yt.utilities.lib.quad_tree import \ - QuadTree -from yt.utilities.lib.interpolators import \ - ghost_zone_interpolate -from yt.utilities.lib.misc_utilities import \ - fill_region, fill_region_float -from yt.utilities.lib.marching_cubes import \ - march_cubes_grid, march_cubes_grid_flux -from yt.utilities.minimal_representation import \ - MinimalProjectionData -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - parallel_objects, parallel_root_only, communication_system -from yt.units.unit_object import Unit -from yt.units.yt_array import uconcatenate import yt.geometry.particle_deposit as particle_deposit +from yt.config import ytcfg +from yt.data_objects.data_containers import ( + YTSelectionContainer1D, + YTSelectionContainer2D, + YTSelectionContainer3D, +) +from yt.data_objects.field_data import YTFieldData +from yt.extern.tqdm import tqdm +from yt.fields.field_exceptions import NeedsGridType, NeedsOriginalGrid +from yt.frontends.sph.data_structures import ParticleDataset +from yt.frontends.stream.api import load_uniform_grid +from yt.funcs import ensure_list, get_memory_usage, iterable, mylog, only_on_root from yt.geometry.coordinates.cartesian_coordinates import all_data +from yt.units.unit_object import Unit +from yt.units.yt_array import YTArray, uconcatenate +from yt.utilities.exceptions import ( + YTNoAPIKey, + YTParticleDepositionNotImplemented, + YTTooManyVertices, +) from yt.utilities.grid_data_format.writer import write_to_gdf -from yt.fields.field_exceptions import \ - NeedsOriginalGrid -from yt.frontends.stream.api import load_uniform_grid -from yt.frontends.sph.data_structures import ParticleDataset -from yt.units.yt_array import YTArray -from yt.utilities.lib.pixelization_routines import \ - pixelize_sph_kernel_arbitrary_grid, \ - interpolate_sph_grid_gather, \ - interpolate_sph_positions_gather, \ - normalization_3d_utility, \ - normalization_1d_utility -from yt.extern.tqdm import tqdm from yt.utilities.lib.cyoctree import CyOctree +from yt.utilities.lib.interpolators import ghost_zone_interpolate +from yt.utilities.lib.marching_cubes import march_cubes_grid, march_cubes_grid_flux +from yt.utilities.lib.misc_utilities import fill_region, fill_region_float +from yt.utilities.lib.pixelization_routines import ( + interpolate_sph_grid_gather, + interpolate_sph_positions_gather, + normalization_1d_utility, + normalization_3d_utility, + pixelize_sph_kernel_arbitrary_grid, +) +from yt.utilities.lib.quad_tree import QuadTree +from yt.utilities.minimal_representation import MinimalProjectionData +from yt.utilities.parallel_tools.parallel_analysis_interface import ( + communication_system, + parallel_objects, + parallel_root_only, +) + class YTStreamline(YTSelectionContainer1D): """ diff --git a/yt/data_objects/data_containers.py b/yt/data_objects/data_containers.py index ecf2f78934e..0baffffef05 100644 --- a/yt/data_objects/data_containers.py +++ b/yt/data_objects/data_containers.py @@ -1,62 +1,54 @@ import itertools -import uuid - import os -import numpy as np -import weakref import shelve - +import uuid +import weakref from collections import defaultdict from contextlib import contextmanager -from yt.fields.derived_field import \ - DerivedField -from yt.frontends.ytdata.utilities import \ - save_as_dataset -from yt.funcs import \ - get_output_filename, \ - mylog, \ - ensure_list, \ - fix_axis, \ - iterable, \ - validate_width_tuple -from yt.units.yt_array import \ - YTArray, \ - YTQuantity -import yt.units.dimensions as ytdims -from unyt.exceptions import \ - UnitConversionError, \ - UnitParseError -from yt.utilities.exceptions import \ - YTFieldUnitError, \ - YTFieldUnitParseError, \ - YTSpatialFieldUnitError, \ - YTCouldNotGenerateField, \ - YTFieldNotParseable, \ - YTFieldNotFound, \ - YTFieldTypeNotFound, \ - YTDataSelectorNotImplemented, \ - YTDimensionalityError, \ - YTNonIndexedDataContainer, \ - YTBooleanObjectError, \ - YTBooleanObjectsWrongDataset, YTException -from yt.utilities.lib.marching_cubes import \ - march_cubes_grid, march_cubes_grid_flux -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - ParallelAnalysisInterface -from yt.utilities.parameter_file_storage import \ - ParameterFileStore -from yt.utilities.amr_kdtree.api import \ - AMRKDTree -from .derived_quantities import DerivedQuantityCollection -from yt.fields.field_exceptions import \ - NeedsGridType +import numpy as np +from unyt.exceptions import UnitConversionError, UnitParseError + import yt.geometry.selection_routines -from yt.geometry.selection_routines import \ - compose_selector -from yt.units.yt_array import uconcatenate +import yt.units.dimensions as ytdims from yt.data_objects.field_data import YTFieldData from yt.data_objects.profiles import create_profile +from yt.fields.derived_field import DerivedField +from yt.fields.field_exceptions import NeedsGridType +from yt.frontends.ytdata.utilities import save_as_dataset +from yt.funcs import ( + ensure_list, + fix_axis, + get_output_filename, + iterable, + mylog, + validate_width_tuple, +) +from yt.geometry.selection_routines import compose_selector +from yt.units.yt_array import YTArray, YTQuantity, uconcatenate +from yt.utilities.amr_kdtree.api import AMRKDTree +from yt.utilities.exceptions import ( + YTBooleanObjectError, + YTBooleanObjectsWrongDataset, + YTCouldNotGenerateField, + YTDataSelectorNotImplemented, + YTDimensionalityError, + YTException, + YTFieldNotFound, + YTFieldNotParseable, + YTFieldTypeNotFound, + YTFieldUnitError, + YTFieldUnitParseError, + YTNonIndexedDataContainer, + YTSpatialFieldUnitError, +) +from yt.utilities.lib.marching_cubes import march_cubes_grid, march_cubes_grid_flux +from yt.utilities.parallel_tools.parallel_analysis_interface import ( + ParallelAnalysisInterface, +) +from yt.utilities.parameter_file_storage import ParameterFileStore + +from .derived_quantities import DerivedQuantityCollection data_object_registry = {} diff --git a/yt/data_objects/derived_quantities.py b/yt/data_objects/derived_quantities.py index 5b90ecbbe50..b88814559c7 100644 --- a/yt/data_objects/derived_quantities.py +++ b/yt/data_objects/derived_quantities.py @@ -1,16 +1,14 @@ import numpy as np -from yt.funcs import \ - camelcase_to_underscore, \ - ensure_list +from yt.funcs import camelcase_to_underscore, ensure_list from yt.units.yt_array import array_like_field -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - ParallelAnalysisInterface, parallel_objects -from yt.utilities.physical_constants import \ - gravitational_constant_cgs +from yt.utilities.exceptions import YTParticleTypeNotFound +from yt.utilities.parallel_tools.parallel_analysis_interface import ( + ParallelAnalysisInterface, + parallel_objects, +) +from yt.utilities.physical_constants import gravitational_constant_cgs from yt.utilities.physical_ratios import HUGE -from yt.utilities.exceptions import \ - YTParticleTypeNotFound derived_quantity_registry = {} diff --git a/yt/data_objects/grid_patch.py b/yt/data_objects/grid_patch.py index 7dd1e7d6719..55de59a3139 100644 --- a/yt/data_objects/grid_patch.py +++ b/yt/data_objects/grid_patch.py @@ -1,23 +1,21 @@ import warnings import weakref + import numpy as np +import yt.geometry.particle_deposit as particle_deposit from yt.config import ytcfg -from yt.data_objects.data_containers import \ - YTSelectionContainer +from yt.data_objects.data_containers import YTSelectionContainer from yt.funcs import iterable from yt.geometry.selection_routines import convert_mask_to_indices -import yt.geometry.particle_deposit as particle_deposit from yt.units.yt_array import YTArray -from yt.utilities.exceptions import \ - YTFieldTypeNotFound, \ - YTParticleDepositionNotImplemented -from yt.utilities.lib.interpolators import \ - ghost_zone_interpolate -from yt.utilities.lib.mesh_utilities import \ - clamp_edges -from yt.utilities.nodal_data_utils import \ - get_nodal_slices +from yt.utilities.exceptions import ( + YTFieldTypeNotFound, + YTParticleDepositionNotImplemented, +) +from yt.utilities.lib.interpolators import ghost_zone_interpolate +from yt.utilities.lib.mesh_utilities import clamp_edges +from yt.utilities.nodal_data_utils import get_nodal_slices RECONSTRUCT_INDEX = bool(ytcfg.get('yt', 'reconstruct_index')) diff --git a/yt/data_objects/image_array.py b/yt/data_objects/image_array.py index 02c33ecbf3f..5fdaa88149f 100644 --- a/yt/data_objects/image_array.py +++ b/yt/data_objects/image_array.py @@ -1,9 +1,10 @@ import warnings + import numpy as np -from yt.config import \ - ytcfg -from yt.visualization.image_writer import write_bitmap, write_image + +from yt.config import ytcfg from yt.units.yt_array import YTArray +from yt.visualization.image_writer import write_bitmap, write_image class ImageArray(YTArray): diff --git a/yt/data_objects/level_sets/api.py b/yt/data_objects/level_sets/api.py index c14ab973caf..609885e52cb 100644 --- a/yt/data_objects/level_sets/api.py +++ b/yt/data_objects/level_sets/api.py @@ -1,20 +1,11 @@ -from .contour_finder import \ - identify_contours - -from .clump_handling import \ - Clump, \ - find_clumps, \ - get_lowest_clumps - -from .clump_info_items import \ - add_clump_info - -from .clump_validators import \ - add_validator - -from .clump_tools import \ - recursive_all_clumps, \ - return_all_clumps, \ - return_bottom_clumps, \ - recursive_bottom_clumps, \ - clump_list_sort +from .clump_handling import Clump, find_clumps, get_lowest_clumps +from .clump_info_items import add_clump_info +from .clump_tools import ( + clump_list_sort, + recursive_all_clumps, + recursive_bottom_clumps, + return_all_clumps, + return_bottom_clumps, +) +from .clump_validators import add_validator +from .contour_finder import identify_contours diff --git a/yt/data_objects/level_sets/clump_handling.py b/yt/data_objects/level_sets/clump_handling.py index 920ee1c5d62..b2c01ba3701 100644 --- a/yt/data_objects/level_sets/clump_handling.py +++ b/yt/data_objects/level_sets/clump_handling.py @@ -1,23 +1,16 @@ -import numpy as np import uuid -from yt.fields.derived_field import \ - ValidateSpatial -from yt.frontends.ytdata.utilities import \ - save_as_dataset -from yt.funcs import \ - issue_deprecation_warning, \ - get_output_filename, \ - mylog -from yt.utilities.tree_container import \ - TreeContainer - -from .clump_info_items import \ - clump_info_registry -from .clump_validators import \ - clump_validator_registry -from .contour_finder import \ - identify_contours +import numpy as np + +from yt.fields.derived_field import ValidateSpatial +from yt.frontends.ytdata.utilities import save_as_dataset +from yt.funcs import get_output_filename, issue_deprecation_warning, mylog +from yt.utilities.tree_container import TreeContainer + +from .clump_info_items import clump_info_registry +from .clump_validators import clump_validator_registry +from .contour_finder import identify_contours + def add_contour_field(ds, contour_key): def _contours(field, data): diff --git a/yt/data_objects/level_sets/clump_info_items.py b/yt/data_objects/level_sets/clump_info_items.py index f0636b96fd5..d5631c9c8e0 100644 --- a/yt/data_objects/level_sets/clump_info_items.py +++ b/yt/data_objects/level_sets/clump_info_items.py @@ -1,7 +1,6 @@ import numpy as np -from yt.utilities.operator_registry import \ - OperatorRegistry +from yt.utilities.operator_registry import OperatorRegistry clump_info_registry = OperatorRegistry() diff --git a/yt/data_objects/level_sets/clump_tools.py b/yt/data_objects/level_sets/clump_tools.py index e037d35f1c9..d1d4ec446d9 100644 --- a/yt/data_objects/level_sets/clump_tools.py +++ b/yt/data_objects/level_sets/clump_tools.py @@ -1,4 +1,5 @@ import numpy as np + nar = np.array counter = 0 diff --git a/yt/data_objects/level_sets/clump_validators.py b/yt/data_objects/level_sets/clump_validators.py index b57be4ef69c..3cb9a1d17d1 100644 --- a/yt/data_objects/level_sets/clump_validators.py +++ b/yt/data_objects/level_sets/clump_validators.py @@ -1,11 +1,8 @@ import numpy as np -from yt.utilities.lib.misc_utilities import \ - gravitational_binding_energy -from yt.utilities.operator_registry import \ - OperatorRegistry -from yt.utilities.physical_constants import \ - gravitational_constant_cgs as G +from yt.utilities.lib.misc_utilities import gravitational_binding_energy +from yt.utilities.operator_registry import OperatorRegistry +from yt.utilities.physical_constants import gravitational_constant_cgs as G clump_validator_registry = OperatorRegistry() diff --git a/yt/data_objects/level_sets/contour_finder.py b/yt/data_objects/level_sets/contour_finder.py index b05bc12f8a1..31ebd6d8ae5 100644 --- a/yt/data_objects/level_sets/contour_finder.py +++ b/yt/data_objects/level_sets/contour_finder.py @@ -1,13 +1,16 @@ +from collections import defaultdict + import numpy as np -from collections import defaultdict +from yt.funcs import get_pbar, mylog +from yt.utilities.lib.contour_finding import ( + ContourTree, + TileContourTree, + link_node_contours, + update_joins, +) +from yt.utilities.lib.partitioned_grid import PartitionedGrid -from yt.funcs import mylog, get_pbar -from yt.utilities.lib.contour_finding import \ - ContourTree, TileContourTree, link_node_contours, \ - update_joins -from yt.utilities.lib.partitioned_grid import \ - PartitionedGrid def identify_contours(data_source, field, min_val, max_val, cached_fields=None): diff --git a/yt/data_objects/level_sets/tests/test_clump_finding.py b/yt/data_objects/level_sets/tests/test_clump_finding.py index b0a77b2e0b1..f58c04f4e32 100644 --- a/yt/data_objects/level_sets/tests/test_clump_finding.py +++ b/yt/data_objects/level_sets/tests/test_clump_finding.py @@ -1,26 +1,17 @@ -import numpy as np import os import shutil import tempfile +import numpy as np -from yt.data_objects.level_sets.api import \ - add_clump_info, \ - Clump, \ - find_clumps +from yt.convenience import load +from yt.data_objects.level_sets.api import Clump, add_clump_info, find_clumps from yt.data_objects.level_sets.clump_info_items import clump_info_registry -from yt.convenience import \ - load -from yt.fields.derived_field import \ - ValidateParameter -from yt.frontends.stream.api import \ - load_uniform_grid -from yt.testing import \ - assert_array_equal, \ - assert_equal, \ - requires_file -from yt.utilities.answer_testing.framework import \ - data_dir_load +from yt.fields.derived_field import ValidateParameter +from yt.frontends.stream.api import load_uniform_grid +from yt.testing import assert_array_equal, assert_equal, requires_file +from yt.utilities.answer_testing.framework import data_dir_load + def test_clump_finding(): n_c = 8 diff --git a/yt/data_objects/octree_subset.py b/yt/data_objects/octree_subset.py index d1a119b13f5..159c1e27a15 100644 --- a/yt/data_objects/octree_subset.py +++ b/yt/data_objects/octree_subset.py @@ -1,21 +1,21 @@ from contextlib import contextmanager + import numpy as np -from yt.data_objects.data_containers import \ - YTSelectionContainer import yt.geometry.particle_deposit as particle_deposit import yt.geometry.particle_smooth as particle_smooth - +from yt.data_objects.data_containers import YTSelectionContainer from yt.funcs import mylog -from yt.utilities.lib.geometry_utils import compute_morton -from yt.geometry.particle_oct_container import \ - ParticleOctreeContainer -from yt.units.yt_array import YTArray +from yt.geometry.particle_oct_container import ParticleOctreeContainer from yt.units.dimensions import length -from yt.utilities.exceptions import \ - YTInvalidPositionArray, \ - YTFieldTypeNotFound, \ - YTParticleDepositionNotImplemented +from yt.units.yt_array import YTArray +from yt.utilities.exceptions import ( + YTFieldTypeNotFound, + YTInvalidPositionArray, + YTParticleDepositionNotImplemented, +) +from yt.utilities.lib.geometry_utils import compute_morton + def cell_count_cache(func): def cc_cache_func(self, dobj): diff --git a/yt/data_objects/particle_container.py b/yt/data_objects/particle_container.py index e4c06662ef2..0541b18c6d6 100644 --- a/yt/data_objects/particle_container.py +++ b/yt/data_objects/particle_container.py @@ -1,13 +1,12 @@ import contextlib -from yt.data_objects.data_containers import \ - YTFieldData, \ - YTSelectionContainer -from yt.funcs import \ - ensure_list -from yt.utilities.exceptions import \ - YTNonIndexedDataContainer, \ - YTDataSelectorNotImplemented +from yt.data_objects.data_containers import YTFieldData, YTSelectionContainer +from yt.funcs import ensure_list +from yt.utilities.exceptions import ( + YTDataSelectorNotImplemented, + YTNonIndexedDataContainer, +) + def _non_indexed(name): def _func_non_indexed(self, *args, **kwargs): diff --git a/yt/data_objects/particle_filters.py b/yt/data_objects/particle_filters.py index 9e2e8ba3016..ba70994f5a7 100644 --- a/yt/data_objects/particle_filters.py +++ b/yt/data_objects/particle_filters.py @@ -1,8 +1,7 @@ import copy from contextlib import contextmanager -from yt.fields.field_info_container import \ - NullFunc, TranslationFunc +from yt.fields.field_info_container import NullFunc, TranslationFunc from yt.funcs import mylog from yt.utilities.exceptions import YTIllDefinedFilter diff --git a/yt/data_objects/particle_trajectories.py b/yt/data_objects/particle_trajectories.py index 94e83b21c2a..6c7a1a21f28 100644 --- a/yt/data_objects/particle_trajectories.py +++ b/yt/data_objects/particle_trajectories.py @@ -1,15 +1,16 @@ -from yt.data_objects.field_data import YTFieldData -from yt.utilities.lib.particle_mesh_operations import CICSample_3 -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - parallel_root_only -from yt.funcs import mylog, get_pbar -from yt.units.yt_array import array_like_field -from yt.config import ytcfg -from yt.utilities.exceptions import YTIllDefinedParticleData from collections import OrderedDict import numpy as np + +from yt.config import ytcfg +from yt.data_objects.field_data import YTFieldData +from yt.funcs import get_pbar, mylog +from yt.units.yt_array import array_like_field +from yt.utilities.exceptions import YTIllDefinedParticleData +from yt.utilities.lib.particle_mesh_operations import CICSample_3 from yt.utilities.on_demand_imports import _h5py as h5py +from yt.utilities.parallel_tools.parallel_analysis_interface import parallel_root_only + class ParticleTrajectories: r"""A collection of particle trajectories in time over a series of diff --git a/yt/data_objects/particle_unions.py b/yt/data_objects/particle_unions.py index 1d1e0ca9964..770f11a8e32 100644 --- a/yt/data_objects/particle_unions.py +++ b/yt/data_objects/particle_unions.py @@ -1,5 +1,6 @@ from .unions import Union + class ParticleUnion(Union): _union_type = "particle" def __init__(self, name, sub_types): diff --git a/yt/data_objects/profiles.py b/yt/data_objects/profiles.py index 063f6ef5c78..7a4fa7139ef 100644 --- a/yt/data_objects/profiles.py +++ b/yt/data_objects/profiles.py @@ -1,32 +1,32 @@ import numpy as np +from yt.data_objects.field_data import YTFieldData from yt.fields.derived_field import DerivedField -from yt.frontends.ytdata.utilities import \ - save_as_dataset -from yt.funcs import \ - get_output_filename, \ - ensure_list, \ - iterable, \ - issue_deprecation_warning, \ - mylog -from yt.units.yt_array import \ - array_like_field, \ - YTQuantity +from yt.frontends.ytdata.utilities import save_as_dataset +from yt.funcs import ( + ensure_list, + get_output_filename, + issue_deprecation_warning, + iterable, + mylog, +) from yt.units.unit_object import Unit -from yt.data_objects.field_data import YTFieldData -from yt.utilities.exceptions import \ - YTIllDefinedProfile, \ - YTIllDefinedBounds, \ - YTProfileDataShape -from yt.utilities.lib.misc_utilities import \ - new_bin_profile1d, \ - new_bin_profile2d, \ - new_bin_profile3d -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - ParallelAnalysisInterface, parallel_objects -from yt.utilities.lib.particle_mesh_operations import \ - CICDeposit_2, \ - NGPDeposit_2 +from yt.units.yt_array import YTQuantity, array_like_field +from yt.utilities.exceptions import ( + YTIllDefinedBounds, + YTIllDefinedProfile, + YTProfileDataShape, +) +from yt.utilities.lib.misc_utilities import ( + new_bin_profile1d, + new_bin_profile2d, + new_bin_profile3d, +) +from yt.utilities.lib.particle_mesh_operations import CICDeposit_2, NGPDeposit_2 +from yt.utilities.parallel_tools.parallel_analysis_interface import ( + ParallelAnalysisInterface, + parallel_objects, +) def _sanitize_min_max_units(amin, amax, finfo, registry): diff --git a/yt/data_objects/region_expression.py b/yt/data_objects/region_expression.py index 8ea527c8025..67ba3987b15 100644 --- a/yt/data_objects/region_expression.py +++ b/yt/data_objects/region_expression.py @@ -4,8 +4,10 @@ from yt.units.yt_array import YTQuantity from yt.utilities.exceptions import YTDimensionalityError from yt.visualization.line_plot import LineBuffer + from .data_containers import _get_ipython_key_completion + class RegionExpression: _all_data = None def __init__(self, ds): diff --git a/yt/data_objects/selection_data_containers.py b/yt/data_objects/selection_data_containers.py index 8a5c743feed..44f6e6b64d2 100644 --- a/yt/data_objects/selection_data_containers.py +++ b/yt/data_objects/selection_data_containers.py @@ -1,42 +1,41 @@ import numpy as np -from yt.data_objects.data_containers import \ - YTSelectionContainer0D, YTSelectionContainer1D, \ - YTSelectionContainer2D, YTSelectionContainer3D, YTSelectionContainer +from yt.data_objects.data_containers import ( + YTSelectionContainer, + YTSelectionContainer0D, + YTSelectionContainer1D, + YTSelectionContainer2D, + YTSelectionContainer3D, +) from yt.data_objects.static_output import Dataset -from yt.frontends.sph.data_structures import \ - SPHDataset -from yt.funcs import \ - ensure_list, \ - iterable, \ - validate_width_tuple, \ - fix_length, \ - fix_axis, \ - mylog, \ - validate_3d_array, \ - validate_float, \ - validate_iterable, \ - validate_object, \ - validate_axis, \ - validate_center -from yt.units.yt_array import \ - udot, \ - unorm, \ - YTArray, \ - YTQuantity -from yt.utilities.exceptions import \ - YTSphereTooSmall, \ - YTIllDefinedCutRegion, \ - YTEllipsoidOrdering, \ - YTException -from yt.utilities.lib.pixelization_routines import \ - SPHKernelInterpolationTable -from yt.utilities.minimal_representation import \ - MinimalSliceData +from yt.frontends.sph.data_structures import SPHDataset +from yt.funcs import ( + ensure_list, + fix_axis, + fix_length, + iterable, + mylog, + validate_3d_array, + validate_axis, + validate_center, + validate_float, + validate_iterable, + validate_object, + validate_width_tuple, +) +from yt.geometry.selection_routines import points_in_cells +from yt.units.yt_array import YTArray, YTQuantity, udot, unorm +from yt.utilities.exceptions import ( + YTEllipsoidOrdering, + YTException, + YTIllDefinedCutRegion, + YTSphereTooSmall, +) +from yt.utilities.lib.pixelization_routines import SPHKernelInterpolationTable from yt.utilities.math_utils import get_rotation_matrix +from yt.utilities.minimal_representation import MinimalSliceData +from yt.utilities.on_demand_imports import _miniball, _scipy from yt.utilities.orientation import Orientation -from yt.geometry.selection_routines import points_in_cells -from yt.utilities.on_demand_imports import _scipy, _miniball class YTPoint(YTSelectionContainer0D): diff --git a/yt/data_objects/static_output.py b/yt/data_objects/static_output.py index 9a74767393c..1e90612ffcc 100644 --- a/yt/data_objects/static_output.py +++ b/yt/data_objects/static_output.py @@ -1,76 +1,62 @@ import functools import itertools -import numpy as np import os -from stat import ST_CTIME +import pickle import time -import weakref import warnings - +import weakref from collections import defaultdict -import pickle +from stat import ST_CTIME + +import numpy as np from yt.config import ytcfg -from yt.fields.derived_field import \ - DerivedField -from yt.fields.field_type_container import \ - FieldTypeContainer -from yt.funcs import \ - mylog, \ - set_intersection, \ - ensure_list, \ - issue_deprecation_warning, \ - iterable, \ - setdefaultattr -from yt.utilities.cosmology import \ - Cosmology -from yt.utilities.exceptions import \ - YTObjectNotImplemented, \ - YTFieldNotFound, \ - YTGeometryNotSupported, \ - YTIllDefinedParticleFilter -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - parallel_root_only -from yt.utilities.parameter_file_storage import \ - ParameterFileStore, \ - NoParameterShelf, \ - output_type_registry -from yt.units import UnitContainer +from yt.data_objects.data_containers import data_object_registry +from yt.data_objects.particle_filters import filter_registry +from yt.data_objects.particle_unions import ParticleUnion +from yt.data_objects.region_expression import RegionExpression +from yt.fields.derived_field import DerivedField, ValidateSpatial +from yt.fields.field_type_container import FieldTypeContainer +from yt.fields.fluid_fields import setup_gradient_fields +from yt.fields.particle_fields import DEP_MSG_SMOOTH_FIELD +from yt.funcs import ( + ensure_list, + issue_deprecation_warning, + iterable, + mylog, + set_intersection, + setdefaultattr, +) +from yt.geometry.coordinates.api import ( + CartesianCoordinateHandler, + CoordinateHandler, + CylindricalCoordinateHandler, + GeographicCoordinateHandler, + InternalGeographicCoordinateHandler, + PolarCoordinateHandler, + SpectralCubeCoordinateHandler, + SphericalCoordinateHandler, +) +from yt.units import UnitContainer, _wrap_display_ytarray from yt.units.dimensions import current_mks from yt.units.unit_object import Unit, define_unit -from yt.units.unit_systems import unit_system_registry from yt.units.unit_registry import UnitRegistry -from yt.fields.derived_field import \ - ValidateSpatial -from yt.fields.fluid_fields import \ - setup_gradient_fields -from yt.fields.particle_fields import \ - DEP_MSG_SMOOTH_FIELD -from yt.data_objects.particle_filters import \ - filter_registry -from yt.data_objects.particle_unions import \ - ParticleUnion -from yt.data_objects.data_containers import \ - data_object_registry -from yt.utilities.minimal_representation import \ - MinimalDataset -from yt.units.yt_array import \ - YTArray, \ - YTQuantity -from yt.units import \ - _wrap_display_ytarray -from yt.units.unit_systems import create_code_unit_system -from yt.data_objects.region_expression import \ - RegionExpression -from yt.geometry.coordinates.api import \ - CoordinateHandler, \ - CartesianCoordinateHandler, \ - PolarCoordinateHandler, \ - CylindricalCoordinateHandler, \ - SphericalCoordinateHandler, \ - GeographicCoordinateHandler, \ - SpectralCubeCoordinateHandler, \ - InternalGeographicCoordinateHandler +from yt.units.unit_systems import create_code_unit_system, unit_system_registry +from yt.units.yt_array import YTArray, YTQuantity +from yt.utilities.cosmology import Cosmology +from yt.utilities.exceptions import ( + YTFieldNotFound, + YTGeometryNotSupported, + YTIllDefinedParticleFilter, + YTObjectNotImplemented, +) +from yt.utilities.minimal_representation import MinimalDataset +from yt.utilities.parallel_tools.parallel_analysis_interface import parallel_root_only +from yt.utilities.parameter_file_storage import ( + NoParameterShelf, + ParameterFileStore, + output_type_registry, +) # We want to support the movie format in the future. # When such a thing comes to pass, I'll move all the stuff that is constant up diff --git a/yt/data_objects/tests/test_bbox.py b/yt/data_objects/tests/test_bbox.py index 005e12f98c5..878e4b8adda 100644 --- a/yt/data_objects/tests/test_bbox.py +++ b/yt/data_objects/tests/test_bbox.py @@ -2,10 +2,7 @@ import numpy as np -from yt.testing import \ - fake_amr_ds, \ - assert_equal, \ - assert_allclose_units +from yt.testing import assert_allclose_units, assert_equal, fake_amr_ds def test_object_bbox(): diff --git a/yt/data_objects/tests/test_boolean_regions.py b/yt/data_objects/tests/test_boolean_regions.py index a4cca05b178..babf213933f 100644 --- a/yt/data_objects/tests/test_boolean_regions.py +++ b/yt/data_objects/tests/test_boolean_regions.py @@ -1,8 +1,7 @@ -from yt.testing import \ - fake_amr_ds, \ - assert_array_equal import numpy as np +from yt.testing import assert_array_equal, fake_amr_ds + # We use morton indices in this test because they are single floating point # values that uniquely identify each cell. That's a convenient way to compare # inclusion in set operations, since there are no duplicates. diff --git a/yt/data_objects/tests/test_chunking.py b/yt/data_objects/tests/test_chunking.py index 6ec67a96be2..f70673c94db 100644 --- a/yt/data_objects/tests/test_chunking.py +++ b/yt/data_objects/tests/test_chunking.py @@ -1,9 +1,6 @@ -from yt.testing import \ - fake_random_ds, \ - assert_equal, \ - assert_true -from yt.units.yt_array import \ - uconcatenate +from yt.testing import assert_equal, assert_true, fake_random_ds +from yt.units.yt_array import uconcatenate + def _get_dobjs(c): dobjs = [("sphere", ("center", (1.0, "unitary"))), diff --git a/yt/data_objects/tests/test_clone.py b/yt/data_objects/tests/test_clone.py index 8b3087b2b91..4c9339dc76b 100644 --- a/yt/data_objects/tests/test_clone.py +++ b/yt/data_objects/tests/test_clone.py @@ -1,7 +1,5 @@ -from yt.testing import \ - fake_random_ds, \ - assert_equal, \ - assert_array_equal +from yt.testing import assert_array_equal, assert_equal, fake_random_ds + def test_clone_sphere(): # Now we test that we can get different radial velocities based on field diff --git a/yt/data_objects/tests/test_compose.py b/yt/data_objects/tests/test_compose.py index c8a1ca66909..346d9ad9432 100644 --- a/yt/data_objects/tests/test_compose.py +++ b/yt/data_objects/tests/test_compose.py @@ -1,12 +1,8 @@ import numpy as np -from yt.testing import \ - assert_array_equal, \ - fake_amr_ds, \ - fake_random_ds -from yt.units.yt_array import \ - YTArray, \ - uintersect1d +from yt.testing import assert_array_equal, fake_amr_ds, fake_random_ds +from yt.units.yt_array import YTArray, uintersect1d + def setup(): from yt.config import ytcfg diff --git a/yt/data_objects/tests/test_connected_sets.py b/yt/data_objects/tests/test_connected_sets.py index af5aa034b38..f8a4ceeb21b 100644 --- a/yt/data_objects/tests/test_connected_sets.py +++ b/yt/data_objects/tests/test_connected_sets.py @@ -1,6 +1,7 @@ from yt.testing import fake_random_ds from yt.utilities.answer_testing.level_sets_tests import ExtractConnectedSetsTest + def test_connected_sets(): ds = fake_random_ds(16, nprocs=8, particles=16**3) data_source = ds.disk([0.5, 0.5, 0.5], [0., 0., 1.], (8, 'kpc'), (1, 'kpc')) diff --git a/yt/data_objects/tests/test_covering_grid.py b/yt/data_objects/tests/test_covering_grid.py index 6738980dafd..a7624320a69 100644 --- a/yt/data_objects/tests/test_covering_grid.py +++ b/yt/data_objects/tests/test_covering_grid.py @@ -1,19 +1,23 @@ import numpy as np -from yt.fields.derived_field import \ - ValidateParameter -from yt.frontends.stream.data_structures import load_particles -from yt.testing import fake_random_ds, assert_equal, assert_almost_equal, \ - fake_octree_ds, requires_file, requires_module from yt.convenience import load -from yt.testing import \ - assert_array_equal +from yt.fields.derived_field import ValidateParameter +from yt.frontends.stream.data_structures import load_particles +from yt.testing import ( + assert_almost_equal, + assert_array_equal, + assert_equal, + fake_octree_ds, + fake_random_ds, + requires_file, + requires_module, +) +from yt.units import kpc # cylindrical data for covering_grid test cyl_2d = "WDMerger_hdf5_chk_1000/WDMerger_hdf5_chk_1000.hdf5" cyl_3d = "MHD_Cyl3d_hdf5_plt_cnt_0100/MHD_Cyl3d_hdf5_plt_cnt_0100.hdf5" -from yt.units import kpc def setup(): from yt.config import ytcfg diff --git a/yt/data_objects/tests/test_cutting_plane.py b/yt/data_objects/tests/test_cutting_plane.py index 7c938856aa6..a50a963ba27 100644 --- a/yt/data_objects/tests/test_cutting_plane.py +++ b/yt/data_objects/tests/test_cutting_plane.py @@ -1,8 +1,9 @@ -from yt.testing import assert_equal, fake_random_ds -from yt.units.unit_object import Unit import os import tempfile +from yt.testing import assert_equal, fake_random_ds +from yt.units.unit_object import Unit + def setup(): from yt.config import ytcfg diff --git a/yt/data_objects/tests/test_data_collection.py b/yt/data_objects/tests/test_data_collection.py index 07ab66270d5..5a0ca998964 100644 --- a/yt/data_objects/tests/test_data_collection.py +++ b/yt/data_objects/tests/test_data_collection.py @@ -1,9 +1,7 @@ import numpy as np -from yt.testing import \ - fake_random_ds, \ - assert_equal, \ - assert_rel_equal +from yt.testing import assert_equal, assert_rel_equal, fake_random_ds + def setup(): from yt.config import ytcfg diff --git a/yt/data_objects/tests/test_data_containers.py b/yt/data_objects/tests/test_data_containers.py index 328211fc380..0031a49359a 100644 --- a/yt/data_objects/tests/test_data_containers.py +++ b/yt/data_objects/tests/test_data_containers.py @@ -10,10 +10,16 @@ from yt.data_objects.data_containers import YTDataContainer from yt.data_objects.particle_filters import particle_filter -from yt.testing import assert_equal, fake_random_ds, fake_amr_ds,\ - fake_particle_ds, requires_module +from yt.testing import ( + assert_equal, + fake_amr_ds, + fake_particle_ds, + fake_random_ds, + requires_module, +) from yt.utilities.exceptions import YTFieldNotFound + class TestDataContainers(unittest.TestCase): @classmethod def setUpClass(cls): diff --git a/yt/data_objects/tests/test_dataset_access.py b/yt/data_objects/tests/test_dataset_access.py index 53aa828e2c5..3083d7b8245 100644 --- a/yt/data_objects/tests/test_dataset_access.py +++ b/yt/data_objects/tests/test_dataset_access.py @@ -1,13 +1,14 @@ import numpy as np from nose.tools import assert_raises -from yt.testing import \ - assert_equal, \ - assert_almost_equal, \ - fake_amr_ds, \ - fake_particle_ds, \ - fake_random_ds, \ - requires_file +from yt.testing import ( + assert_almost_equal, + assert_equal, + fake_amr_ds, + fake_particle_ds, + fake_random_ds, + requires_file, +) from yt.utilities.answer_testing.framework import data_dir_load from yt.utilities.exceptions import YTDimensionalityError from yt.visualization.line_plot import LineBuffer diff --git a/yt/data_objects/tests/test_derived_quantities.py b/yt/data_objects/tests/test_derived_quantities.py index c2566cca1ce..9007525c689 100644 --- a/yt/data_objects/tests/test_derived_quantities.py +++ b/yt/data_objects/tests/test_derived_quantities.py @@ -1,18 +1,19 @@ import numpy as np -import yt - -from yt.testing import \ - fake_random_ds, \ - fake_sph_orientation_ds, \ - fake_particle_ds, \ - assert_almost_equal, \ - assert_equal, \ - assert_rel_equal, \ - requires_file +import yt from yt import particle_filter +from yt.testing import ( + assert_almost_equal, + assert_equal, + assert_rel_equal, + fake_particle_ds, + fake_random_ds, + fake_sph_orientation_ds, + requires_file, +) + def setup(): from yt.config import ytcfg diff --git a/yt/data_objects/tests/test_ellipsoid.py b/yt/data_objects/tests/test_ellipsoid.py index 53f3642a548..a3c2bc84b1a 100644 --- a/yt/data_objects/tests/test_ellipsoid.py +++ b/yt/data_objects/tests/test_ellipsoid.py @@ -1,8 +1,7 @@ import numpy as np -from yt.testing import \ - fake_random_ds, \ - assert_array_less +from yt.testing import assert_array_less, fake_random_ds + def setup(): from yt.config import ytcfg diff --git a/yt/data_objects/tests/test_exclude_functions.py b/yt/data_objects/tests/test_exclude_functions.py index c16fff04b4f..af7b26d89a8 100644 --- a/yt/data_objects/tests/test_exclude_functions.py +++ b/yt/data_objects/tests/test_exclude_functions.py @@ -1,7 +1,7 @@ import numpy as np -from yt.testing import fake_random_ds, assert_equal from yt.frontends.stream.data_structures import load_uniform_grid +from yt.testing import assert_equal, fake_random_ds def test_exclude_above(): @@ -88,4 +88,3 @@ def test_inside_outside(): only_threes = ad.include_outside('density', 0.9e6, 2.1e6, 'g/m**3') assert np.all(only_threes['density'] == 3) assert len(only_threes['density']) == 10 - diff --git a/yt/data_objects/tests/test_extract_regions.py b/yt/data_objects/tests/test_extract_regions.py index a20ace79a53..02e3e2457aa 100644 --- a/yt/data_objects/tests/test_extract_regions.py +++ b/yt/data_objects/tests/test_extract_regions.py @@ -1,12 +1,14 @@ import numpy as np from yt.convenience import load -from yt.testing import \ - fake_random_ds, \ - fake_amr_ds, \ - assert_equal, \ - assert_almost_equal, \ - requires_file +from yt.testing import ( + assert_almost_equal, + assert_equal, + fake_amr_ds, + fake_random_ds, + requires_file, +) + def setup(): from yt.config import ytcfg diff --git a/yt/data_objects/tests/test_firefly.py b/yt/data_objects/tests/test_firefly.py index 04f284a0e52..4fd396cf16e 100644 --- a/yt/data_objects/tests/test_firefly.py +++ b/yt/data_objects/tests/test_firefly.py @@ -1,6 +1,8 @@ -from yt.testing import fake_particle_ds, requires_module import tempfile +from yt.testing import fake_particle_ds, requires_module + + @requires_module('firefly_api') def test_firefly_JSON_object(): tmpdir = tempfile.mkdtemp() @@ -13,4 +15,3 @@ def test_firefly_JSON_object(): coordinate_units = 'cm', dataset_name='test') reader.dumpToJSON() - diff --git a/yt/data_objects/tests/test_fluxes.py b/yt/data_objects/tests/test_fluxes.py index 9843db17770..ae26154a4d8 100644 --- a/yt/data_objects/tests/test_fluxes.py +++ b/yt/data_objects/tests/test_fluxes.py @@ -1,12 +1,12 @@ import os import shutil import tempfile +from unittest import TestCase import numpy as np -from unittest import TestCase +from yt.testing import assert_almost_equal, assert_equal, fake_random_ds -from yt.testing import fake_random_ds, assert_almost_equal, assert_equal def setup(): from yt.config import ytcfg diff --git a/yt/data_objects/tests/test_glue.py b/yt/data_objects/tests/test_glue.py index 42484054c9c..9f19b6b38d6 100644 --- a/yt/data_objects/tests/test_glue.py +++ b/yt/data_objects/tests/test_glue.py @@ -3,6 +3,7 @@ from yt.config import ytcfg from yt.testing import fake_random_ds, requires_module + def setup_func(): ytcfg["yt", "__withintesting"] = "True" diff --git a/yt/data_objects/tests/test_image_array.py b/yt/data_objects/tests/test_image_array.py index f6bd81d8504..97f035ecd88 100644 --- a/yt/data_objects/tests/test_image_array.py +++ b/yt/data_objects/tests/test_image_array.py @@ -1,13 +1,13 @@ -import numpy as np import os -import tempfile import shutil +import tempfile import unittest import warnings + +import numpy as np + from yt.data_objects.image_array import ImageArray -from yt.testing import \ - assert_equal, \ - requires_module +from yt.testing import assert_equal, requires_module def setup(): diff --git a/yt/data_objects/tests/test_numpy_ops.py b/yt/data_objects/tests/test_numpy_ops.py index 4de052dbd83..3a989010378 100644 --- a/yt/data_objects/tests/test_numpy_ops.py +++ b/yt/data_objects/tests/test_numpy_ops.py @@ -1,6 +1,7 @@ -from yt.testing import fake_random_ds, fake_amr_ds, assert_equal import numpy as np +from yt.testing import assert_equal, fake_amr_ds, fake_random_ds + def setup(): from yt.config import ytcfg diff --git a/yt/data_objects/tests/test_octree.py b/yt/data_objects/tests/test_octree.py index 74d65d19965..2588fcee11c 100644 --- a/yt/data_objects/tests/test_octree.py +++ b/yt/data_objects/tests/test_octree.py @@ -1,11 +1,13 @@ -from yt.testing import \ - fake_sph_grid_ds, assert_almost_equal -from yt.data_objects.construction_data_containers import YTOctree -import tempfile import os import shutil +import tempfile + import numpy as np +from yt.data_objects.construction_data_containers import YTOctree +from yt.testing import assert_almost_equal, fake_sph_grid_ds + + def test_building_tree(): ''' Test function to build an octree and make sure correct number of particles diff --git a/yt/data_objects/tests/test_ortho_rays.py b/yt/data_objects/tests/test_ortho_rays.py index de5b808d1e3..0958d775871 100644 --- a/yt/data_objects/tests/test_ortho_rays.py +++ b/yt/data_objects/tests/test_ortho_rays.py @@ -1,8 +1,6 @@ import numpy as np -from yt.testing import \ - fake_random_ds, \ - assert_equal +from yt.testing import assert_equal, fake_random_ds def test_ortho_ray(): diff --git a/yt/data_objects/tests/test_particle_filter.py b/yt/data_objects/tests/test_particle_filter.py index 34f3364c090..62a6082d78b 100644 --- a/yt/data_objects/tests/test_particle_filter.py +++ b/yt/data_objects/tests/test_particle_filter.py @@ -1,17 +1,16 @@ -import numpy as np import os import shutil import tempfile +import numpy as np from nose.tools import assert_raises from yt.data_objects.particle_filters import add_particle_filter, particle_filter from yt.testing import assert_equal, fake_random_ds, fake_sph_grid_ds +from yt.utilities.exceptions import YTIllDefinedFilter, YTIllDefinedParticleFilter from yt.visualization.plot_window import ProjectionPlot -from yt.utilities.exceptions import YTIllDefinedFilter, \ - YTIllDefinedParticleFilter def test_add_particle_filter(): diff --git a/yt/data_objects/tests/test_particle_trajectories.py b/yt/data_objects/tests/test_particle_trajectories.py index 7c01380e8b1..d7f9f16073f 100644 --- a/yt/data_objects/tests/test_particle_trajectories.py +++ b/yt/data_objects/tests/test_particle_trajectories.py @@ -1,17 +1,15 @@ import glob import os + import numpy as np -from numpy.testing import \ - assert_raises +from numpy.testing import assert_raises from yt.config import ytcfg +from yt.data_objects.particle_filters import particle_filter from yt.data_objects.time_series import DatasetSeries -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - GenericArrayTest from yt.testing import fake_particle_ds +from yt.utilities.answer_testing.framework import GenericArrayTest, requires_ds from yt.utilities.exceptions import YTIllDefinedParticleData -from yt.data_objects.particle_filters import particle_filter def setup(): diff --git a/yt/data_objects/tests/test_pickle.py b/yt/data_objects/tests/test_pickle.py index b1b53a7b9fa..0a88c3bfcc1 100644 --- a/yt/data_objects/tests/test_pickle.py +++ b/yt/data_objects/tests/test_pickle.py @@ -1,8 +1,8 @@ -import pickle import os +import pickle import tempfile -from yt.testing \ - import fake_random_ds, assert_equal + +from yt.testing import assert_equal, fake_random_ds def setup(): diff --git a/yt/data_objects/tests/test_points.py b/yt/data_objects/tests/test_points.py index caacb5221fc..4077120c61a 100644 --- a/yt/data_objects/tests/test_points.py +++ b/yt/data_objects/tests/test_points.py @@ -1,7 +1,8 @@ import numpy as np + import yt +from yt.testing import assert_equal, fake_random_ds -from yt.testing import fake_random_ds, assert_equal def setup(): from yt.config import ytcfg diff --git a/yt/data_objects/tests/test_profiles.py b/yt/data_objects/tests/test_profiles.py index 2ca61f49d25..2342a46a336 100644 --- a/yt/data_objects/tests/test_profiles.py +++ b/yt/data_objects/tests/test_profiles.py @@ -1,24 +1,23 @@ -import numpy as np import os import shutil import tempfile import unittest -import yt -from yt.utilities.exceptions import \ - YTProfileDataShape +import numpy as np + +import yt from yt.data_objects.particle_filters import add_particle_filter -from yt.data_objects.profiles import Profile1D, Profile2D, Profile3D,\ - create_profile -from yt.testing import \ - assert_equal, \ - assert_raises,\ - assert_rel_equal, \ - fake_random_ds, \ - fake_sph_orientation_ds, \ - requires_module -from yt.utilities.exceptions import YTIllDefinedProfile -from yt.visualization.profile_plotter import ProfilePlot, PhasePlot +from yt.data_objects.profiles import Profile1D, Profile2D, Profile3D, create_profile +from yt.testing import ( + assert_equal, + assert_raises, + assert_rel_equal, + fake_random_ds, + fake_sph_orientation_ds, + requires_module, +) +from yt.utilities.exceptions import YTIllDefinedProfile, YTProfileDataShape +from yt.visualization.profile_plotter import PhasePlot, ProfilePlot _fields = ("density", "temperature", "dinosaurs", "tribbles") _units = ("g/cm**3", "K", "dyne", "erg") diff --git a/yt/data_objects/tests/test_projection.py b/yt/data_objects/tests/test_projection.py index b54fd3b8679..73a4e6969b9 100644 --- a/yt/data_objects/tests/test_projection.py +++ b/yt/data_objects/tests/test_projection.py @@ -1,13 +1,11 @@ -import numpy as np -from yt.testing import \ - fake_random_ds, \ - assert_equal, \ - assert_rel_equal, \ - fake_amr_ds -from yt.units.unit_object import Unit import os import tempfile +import numpy as np + +from yt.testing import assert_equal, assert_rel_equal, fake_amr_ds, fake_random_ds +from yt.units.unit_object import Unit + LENGTH_UNIT = 2.0 diff --git a/yt/data_objects/tests/test_rays.py b/yt/data_objects/tests/test_rays.py index 756d62e0429..6ef502e1ddf 100644 --- a/yt/data_objects/tests/test_rays.py +++ b/yt/data_objects/tests/test_rays.py @@ -1,14 +1,9 @@ import numpy as np -from yt import \ - load -from yt.testing import \ - fake_random_ds, \ - assert_equal, \ - assert_rel_equal, \ - requires_file -from yt.units.yt_array import \ - uconcatenate +from yt import load +from yt.testing import assert_equal, assert_rel_equal, fake_random_ds, requires_file +from yt.units.yt_array import uconcatenate + def test_ray(): for nproc in [1, 2, 4, 8]: diff --git a/yt/data_objects/tests/test_refinement.py b/yt/data_objects/tests/test_refinement.py index 38966f20a50..ca5a2010f90 100644 --- a/yt/data_objects/tests/test_refinement.py +++ b/yt/data_objects/tests/test_refinement.py @@ -1,9 +1,9 @@ -from yt.testing import \ - assert_array_equal, \ - assert_equal -import yt import numpy as np +import yt +from yt.testing import assert_array_equal, assert_equal + + def setup_fake_refby(): refine_by=np.array([5, 1, 1]) top_grid_dim = [100, 10, 2] diff --git a/yt/data_objects/tests/test_regions.py b/yt/data_objects/tests/test_regions.py index ef6d69e369b..557396abe60 100644 --- a/yt/data_objects/tests/test_regions.py +++ b/yt/data_objects/tests/test_regions.py @@ -1,9 +1,7 @@ -from yt.testing import \ - assert_array_equal, \ - fake_amr_ds, \ - fake_random_ds +from yt.testing import assert_array_equal, fake_amr_ds, fake_random_ds from yt.units import cm + def test_box_creation(): # test that creating a region with left and right edge diff --git a/yt/data_objects/tests/test_slice.py b/yt/data_objects/tests/test_slice.py index 8e8a2e71c87..e7e3866d36b 100644 --- a/yt/data_objects/tests/test_slice.py +++ b/yt/data_objects/tests/test_slice.py @@ -1,8 +1,9 @@ import os -import numpy as np import tempfile -from yt.testing import \ - fake_random_ds, assert_equal + +import numpy as np + +from yt.testing import assert_equal, fake_random_ds from yt.units.unit_object import Unit diff --git a/yt/data_objects/tests/test_sph_data_objects.py b/yt/data_objects/tests/test_sph_data_objects.py index 1ba56a70f35..a00d1b355b4 100644 --- a/yt/data_objects/tests/test_sph_data_objects.py +++ b/yt/data_objects/tests/test_sph_data_objects.py @@ -1,9 +1,8 @@ import numpy as np -from yt.testing import \ - assert_equal, \ - fake_sph_orientation_ds, fake_sph_grid_ds from yt import SlicePlot +from yt.testing import assert_equal, fake_sph_grid_ds, fake_sph_orientation_ds + def test_point(): ds = fake_sph_orientation_ds() @@ -322,4 +321,3 @@ def test_covering_grid_gather(): cg_dens = cg[field].to('g*cm**-3').d assert_equal(ag_dens, cg_dens) - diff --git a/yt/data_objects/tests/test_spheres.py b/yt/data_objects/tests/test_spheres.py index 293fd29e52d..216300800c3 100644 --- a/yt/data_objects/tests/test_spheres.py +++ b/yt/data_objects/tests/test_spheres.py @@ -2,9 +2,13 @@ from numpy.testing import assert_array_equal from yt.data_objects.profiles import create_profile -from yt.testing import fake_random_ds, assert_equal, periodicity_cases, \ - assert_raises, requires_module - +from yt.testing import ( + assert_equal, + assert_raises, + fake_random_ds, + periodicity_cases, + requires_module, +) from yt.utilities.exceptions import YTException diff --git a/yt/data_objects/tests/test_streamlines.py b/yt/data_objects/tests/test_streamlines.py index 06baedc8f50..880624d7895 100644 --- a/yt/data_objects/tests/test_streamlines.py +++ b/yt/data_objects/tests/test_streamlines.py @@ -1,11 +1,9 @@ import numpy as np -from yt.testing import \ - fake_random_ds, \ - assert_rel_equal, \ - assert_equal +from yt.testing import assert_equal, assert_rel_equal, fake_random_ds from yt.visualization.streamlines import Streamlines + def setup(): from yt.config import ytcfg ytcfg["yt","__withintesting"] = "True" diff --git a/yt/data_objects/tests/test_time_series.py b/yt/data_objects/tests/test_time_series.py index 6d073657fef..0db603bc74f 100644 --- a/yt/data_objects/tests/test_time_series.py +++ b/yt/data_objects/tests/test_time_series.py @@ -1,10 +1,11 @@ -from yt.data_objects.time_series import get_filenames_from_glob_pattern - -from pathlib import Path import os import tempfile +from pathlib import Path + +from yt.data_objects.time_series import get_filenames_from_glob_pattern from yt.testing import assert_raises + def test_pattern_expansion(): file_list = ["fake_data_file_{}".format(str(i).zfill(4)) for i in range(10)] diff --git a/yt/data_objects/time_series.py b/yt/data_objects/time_series.py index 2c24290e582..7e08f1fafc4 100644 --- a/yt/data_objects/time_series.py +++ b/yt/data_objects/time_series.py @@ -1,37 +1,33 @@ -import inspect import functools import glob -import numpy as np +import inspect import os import weakref - from functools import wraps -from yt.convenience import load +import numpy as np + from yt.config import ytcfg +from yt.convenience import load +from yt.data_objects.analyzer_objects import ( + AnalysisTask, + analysis_task_registry, + create_quantity_proxy, +) from yt.data_objects.data_containers import data_object_registry -from yt.data_objects.derived_quantities import \ - derived_quantity_registry -from yt.data_objects.analyzer_objects import \ - create_quantity_proxy, \ - analysis_task_registry, \ - AnalysisTask -from yt.data_objects.particle_trajectories import \ - ParticleTrajectories -from yt.funcs import \ - iterable, \ - ensure_list, \ - mylog, \ - issue_deprecation_warning +from yt.data_objects.derived_quantities import derived_quantity_registry +from yt.data_objects.particle_trajectories import ParticleTrajectories +from yt.funcs import ensure_list, issue_deprecation_warning, iterable, mylog from yt.units.yt_array import YTArray, YTQuantity -from yt.utilities.exceptions import \ - YTException, \ - YTOutputNotIdentified -from yt.utilities.parallel_tools.parallel_analysis_interface \ - import parallel_objects, parallel_root_only, communication_system -from yt.utilities.parameter_file_storage import \ - simulation_time_series_registry - +from yt.utilities.exceptions import YTException, YTOutputNotIdentified +from yt.utilities.parallel_tools.parallel_analysis_interface import ( + communication_system, + parallel_objects, + parallel_root_only, +) +from yt.utilities.parameter_file_storage import simulation_time_series_registry + + class AnalysisTaskProxy: def __init__(self, time_series): self.time_series = time_series diff --git a/yt/data_objects/unions.py b/yt/data_objects/unions.py index 2feabf58397..43d39c2bb4b 100644 --- a/yt/data_objects/unions.py +++ b/yt/data_objects/unions.py @@ -1,5 +1,6 @@ from yt.funcs import ensure_list + class Union: _union_type = "" def __init__(self, name, sub_types): diff --git a/yt/data_objects/unstructured_mesh.py b/yt/data_objects/unstructured_mesh.py index 636f8f40100..9df16c82941 100644 --- a/yt/data_objects/unstructured_mesh.py +++ b/yt/data_objects/unstructured_mesh.py @@ -1,14 +1,11 @@ import numpy as np +import yt.geometry.particle_deposit as particle_deposit +from yt.data_objects.data_containers import YTSelectionContainer from yt.funcs import mylog -from yt.utilities.exceptions import \ - YTParticleDepositionNotImplemented -from yt.utilities.lib.mesh_utilities import \ - fill_fcoords, fill_fwidths +from yt.utilities.exceptions import YTParticleDepositionNotImplemented +from yt.utilities.lib.mesh_utilities import fill_fcoords, fill_fwidths -from yt.data_objects.data_containers import \ - YTSelectionContainer -import yt.geometry.particle_deposit as particle_deposit class UnstructuredMesh(YTSelectionContainer): # This is a base class, not meant to be used directly. @@ -214,4 +211,3 @@ def select(self, selector, source, dest, offset): # Note: this likely will not work with vector fields. dest[offset:offset+count] = source.flat[mask] return count - diff --git a/yt/exthook.py b/yt/exthook.py index a1c18368eba..f4ea3dfd586 100644 --- a/yt/exthook.py +++ b/yt/exthook.py @@ -22,7 +22,6 @@ # This source code was originally in flask/exthook.py import os import sys -import os class ExtensionImporter: diff --git a/yt/fields/angular_momentum.py b/yt/fields/angular_momentum.py index b94ee50e0dd..277f43abfa3 100644 --- a/yt/fields/angular_momentum.py +++ b/yt/fields/angular_momentum.py @@ -1,17 +1,14 @@ import numpy as np -from .derived_field import \ - ValidateParameter +from yt.utilities.lib.misc_utilities import ( + obtain_position_vector, + obtain_relative_velocity_vector, +) -from .field_plugin_registry import \ - register_field_plugin +from .derived_field import ValidateParameter +from .field_plugin_registry import register_field_plugin +from .vector_operations import create_magnitude_field -from .vector_operations import \ - create_magnitude_field - -from yt.utilities.lib.misc_utilities import \ - obtain_position_vector, \ - obtain_relative_velocity_vector @register_field_plugin def setup_angular_momentum(registry, ftype = "gas", slice_info = None): diff --git a/yt/fields/api.py b/yt/fields/api.py index 0819b2ba558..8ec272cb8df 100644 --- a/yt/fields/api.py +++ b/yt/fields/api.py @@ -1,33 +1,27 @@ -from .field_plugin_registry import \ - register_field_plugin, \ - field_plugins - -from . import angular_momentum -from . import astro_fields -from . import cosmology_fields -from . import fluid_fields -from . import fluid_vector_fields -from . import magnetic_field -from . import geometric_fields -from . import particle_fields #from . import species_fields -from . import vector_operations -from . import local_fields -from . import my_plugin_fields - +from . import ( + angular_momentum, + astro_fields, + cosmology_fields, + fluid_fields, + fluid_vector_fields, + geometric_fields, + local_fields, + magnetic_field, + my_plugin_fields, + particle_fields, + vector_operations, +) +from .derived_field import ( + DerivedField, + ValidateDataField, + ValidateGridType, + ValidateParameter, + ValidateProperty, + ValidateSpatial, +) +from .field_detector import FieldDetector +from .field_info_container import FieldInfoContainer +from .field_plugin_registry import field_plugins, register_field_plugin from .local_fields import add_field, derived_field - - -from .derived_field import \ - DerivedField, \ - ValidateParameter, \ - ValidateDataField, \ - ValidateProperty, \ - ValidateSpatial, \ - ValidateGridType -from .field_detector import \ - FieldDetector -from .field_info_container import \ - FieldInfoContainer -from .xray_emission_fields import \ - add_xray_emissivity_field \ No newline at end of file +from .xray_emission_fields import add_xray_emissivity_field diff --git a/yt/fields/astro_fields.py b/yt/fields/astro_fields.py index b9f0bf43b0d..17807e488f3 100644 --- a/yt/fields/astro_fields.py +++ b/yt/fields/astro_fields.py @@ -1,9 +1,7 @@ import numpy as np -from .derived_field import \ - ValidateParameter -from .field_plugin_registry import \ - register_field_plugin +from .derived_field import ValidateParameter +from .field_plugin_registry import register_field_plugin @register_field_plugin diff --git a/yt/fields/cosmology_fields.py b/yt/fields/cosmology_fields.py index bfaa998b49e..90296cbeedc 100644 --- a/yt/fields/cosmology_fields.py +++ b/yt/fields/cosmology_fields.py @@ -1,10 +1,7 @@ -from .derived_field import \ - ValidateParameter -from .field_exceptions import \ - NeedsConfiguration, \ - NeedsParameter -from .field_plugin_registry import \ - register_field_plugin +from .derived_field import ValidateParameter +from .field_exceptions import NeedsConfiguration, NeedsParameter +from .field_plugin_registry import register_field_plugin + @register_field_plugin def setup_cosmology_fields(registry, ftype = "gas", slice_info = None): diff --git a/yt/fields/derived_field.py b/yt/fields/derived_field.py index 216d28b85da..5236f6bc651 100644 --- a/yt/fields/derived_field.py +++ b/yt/fields/derived_field.py @@ -3,23 +3,20 @@ import re import warnings -from yt.funcs import \ - ensure_list, \ - VisibleDeprecationWarning -from .field_exceptions import \ - NeedsGridType, \ - NeedsOriginalGrid, \ - NeedsDataField, \ - NeedsProperty, \ - NeedsParameter, \ - FieldUnitsError -from .field_detector import \ - FieldDetector -from yt.units.unit_object import \ - Unit import yt.units.dimensions as ytdims -from yt.utilities.exceptions import \ - YTFieldNotFound +from yt.funcs import VisibleDeprecationWarning, ensure_list +from yt.units.unit_object import Unit +from yt.utilities.exceptions import YTFieldNotFound + +from .field_detector import FieldDetector +from .field_exceptions import ( + FieldUnitsError, + NeedsDataField, + NeedsGridType, + NeedsOriginalGrid, + NeedsParameter, + NeedsProperty, +) def TranslationFunc(field_name): diff --git a/yt/fields/domain_context.py b/yt/fields/domain_context.py index 16d36577ba9..6a6b69e46d6 100644 --- a/yt/fields/domain_context.py +++ b/yt/fields/domain_context.py @@ -11,4 +11,3 @@ def __init__(cls, name, b, d): def __init__(self, ds): self.ds = ds - diff --git a/yt/fields/field_detector.py b/yt/fields/field_detector.py index 128aca67eab..9bf71d0f073 100644 --- a/yt/fields/field_detector.py +++ b/yt/fields/field_detector.py @@ -1,8 +1,10 @@ -import numpy as np from collections import defaultdict + +import numpy as np + from yt.units.yt_array import YTArray -from .field_exceptions import \ - NeedsGridType + +from .field_exceptions import NeedsGridType fp_units = { 'bulk_velocity' : 'cm/s', @@ -279,4 +281,3 @@ def fwidth(self): if not self.flat: fw.shape = (self.nd, self.nd, self.nd, 3) return self.ds.arr(fw, units = "code_length") - diff --git a/yt/fields/field_exceptions.py b/yt/fields/field_exceptions.py index c5cdef171f1..b2970803316 100644 --- a/yt/fields/field_exceptions.py +++ b/yt/fields/field_exceptions.py @@ -40,4 +40,3 @@ def __str__(self): class FieldUnitsError(Exception): pass - diff --git a/yt/fields/field_functions.py b/yt/fields/field_functions.py index cfbe7a283fe..e1f53dd52c5 100644 --- a/yt/fields/field_functions.py +++ b/yt/fields/field_functions.py @@ -1,7 +1,7 @@ import numpy as np -from yt.utilities.lib.misc_utilities import \ - obtain_position_vector +from yt.utilities.lib.misc_utilities import obtain_position_vector + def get_radius(data, field_prefix, ftype): unit_system = data.ds.unit_system diff --git a/yt/fields/field_info_container.py b/yt/fields/field_info_container.py index e3c63b06124..3ebbed2da43 100644 --- a/yt/fields/field_info_container.py +++ b/yt/fields/field_info_container.py @@ -1,27 +1,25 @@ -import numpy as np -from numbers import Number as numeric_type import warnings +from numbers import Number as numeric_type + +import numpy as np from yt.funcs import mylog, only_on_root -from yt.geometry.geometry_handler import \ - is_curvilinear -from yt.units.unit_object import Unit +from yt.geometry.geometry_handler import is_curvilinear from yt.units.dimensions import dimensionless -from .derived_field import \ - DerivedField, \ - NullFunc, \ - TranslationFunc -from yt.utilities.exceptions import \ - YTFieldNotFound -from .field_plugin_registry import \ - field_plugins -from .particle_fields import \ - add_union_field, \ - particle_deposition_functions, \ - particle_vector_functions, \ - particle_scalar_functions, \ - standard_particle_fields, \ - sph_whitelist_fields +from yt.units.unit_object import Unit +from yt.utilities.exceptions import YTFieldNotFound + +from .derived_field import DerivedField, NullFunc, TranslationFunc +from .field_plugin_registry import field_plugins +from .particle_fields import ( + add_union_field, + particle_deposition_functions, + particle_scalar_functions, + particle_vector_functions, + sph_whitelist_fields, + standard_particle_fields, +) + def tupleize(inp): if isinstance(inp, tuple): diff --git a/yt/fields/field_type_container.py b/yt/fields/field_type_container.py index 31eee8db606..3f61d5df636 100644 --- a/yt/fields/field_type_container.py +++ b/yt/fields/field_type_container.py @@ -2,11 +2,12 @@ A proxy object for field descriptors, usually living as ds.fields. """ -import weakref -import textwrap import inspect -from yt.fields.derived_field import \ - DerivedField +import textwrap +import weakref + +from yt.fields.derived_field import DerivedField + def _fill_values(values): value = '
' + \ diff --git a/yt/fields/fluid_fields.py b/yt/fields/fluid_fields.py index 0a213e43409..5f6b5903e59 100644 --- a/yt/fields/fluid_fields.py +++ b/yt/fields/fluid_fields.py @@ -1,29 +1,19 @@ import numpy as np +from yt.funcs import mylog +from yt.geometry.geometry_handler import is_curvilinear from yt.units.unit_object import Unit +from yt.utilities.chemical_formulas import default_mu +from yt.utilities.lib.misc_utilities import obtain_relative_velocity_vector -from .derived_field import \ - ValidateSpatial, \ - ValidateParameter - -from .field_plugin_registry import \ - register_field_plugin - -from yt.geometry.geometry_handler import \ - is_curvilinear - -from .vector_operations import \ - create_averaged_field, \ - create_magnitude_field, \ - create_vector_fields +from .derived_field import ValidateParameter, ValidateSpatial +from .field_plugin_registry import register_field_plugin +from .vector_operations import ( + create_averaged_field, + create_magnitude_field, + create_vector_fields, +) -from yt.utilities.chemical_formulas import \ - default_mu - -from yt.utilities.lib.misc_utilities import \ - obtain_relative_velocity_vector - -from yt.funcs import mylog @register_field_plugin def setup_fluid_fields(registry, ftype = "gas", slice_info = None): diff --git a/yt/fields/fluid_vector_fields.py b/yt/fields/fluid_vector_fields.py index 83b1adb180e..815977839a6 100644 --- a/yt/fields/fluid_vector_fields.py +++ b/yt/fields/fluid_vector_fields.py @@ -1,21 +1,12 @@ import numpy as np -from yt.fields.derived_field import \ - ValidateSpatial, \ - ValidateParameter +from yt.fields.derived_field import ValidateParameter, ValidateSpatial +from yt.funcs import just_one +from yt.geometry.geometry_handler import is_curvilinear -from .field_plugin_registry import \ - register_field_plugin +from .field_plugin_registry import register_field_plugin +from .vector_operations import create_magnitude_field, create_squared_field -from yt.funcs import \ - just_one - -from yt.geometry.geometry_handler import \ - is_curvilinear - -from .vector_operations import \ - create_magnitude_field, \ - create_squared_field @register_field_plugin def setup_fluid_vector_fields(registry, ftype = "gas", slice_info = None): diff --git a/yt/fields/geometric_fields.py b/yt/fields/geometric_fields.py index 3b8fa041fa3..5c638eaf1d1 100644 --- a/yt/fields/geometric_fields.py +++ b/yt/fields/geometric_fields.py @@ -1,23 +1,19 @@ import numpy as np -from .derived_field import \ - ValidateParameter, \ - ValidateSpatial +from yt.utilities.lib.geometry_utils import compute_morton +from yt.utilities.math_utils import ( + get_cyl_r, + get_cyl_theta, + get_cyl_z, + get_sph_phi, + get_sph_r, + get_sph_theta, +) + +from .derived_field import ValidateParameter, ValidateSpatial +from .field_functions import get_periodic_rvec, get_radius +from .field_plugin_registry import register_field_plugin -from .field_functions import \ - get_periodic_rvec, \ - get_radius - -from .field_plugin_registry import \ - register_field_plugin - -from yt.utilities.math_utils import \ - get_cyl_r, get_cyl_theta, \ - get_cyl_z, get_sph_r, \ - get_sph_theta, get_sph_phi - -from yt.utilities.lib.geometry_utils import \ - compute_morton @register_field_plugin def setup_geometric_fields(registry, ftype="gas", slice_info=None): diff --git a/yt/fields/interpolated_fields.py b/yt/fields/interpolated_fields.py index 28c08e1afc0..01fac1bee8f 100644 --- a/yt/fields/interpolated_fields.py +++ b/yt/fields/interpolated_fields.py @@ -1,9 +1,9 @@ from yt.fields.local_fields import add_field - -from yt.utilities.linear_interpolators import \ - UnilinearFieldInterpolator, \ - BilinearFieldInterpolator, \ - TrilinearFieldInterpolator +from yt.utilities.linear_interpolators import ( + BilinearFieldInterpolator, + TrilinearFieldInterpolator, + UnilinearFieldInterpolator, +) _int_class = {1: UnilinearFieldInterpolator, 2: BilinearFieldInterpolator, @@ -29,4 +29,3 @@ def _interpolated_field(field, data): function=_interpolated_field, units=units, validators=validators, particle_type=particle_type) - diff --git a/yt/fields/local_fields.py b/yt/fields/local_fields.py index 2a98b3e3c15..e26ff4da6a5 100644 --- a/yt/fields/local_fields.py +++ b/yt/fields/local_fields.py @@ -1,13 +1,10 @@ import warnings -from yt.utilities.logger import \ - ytLogger as mylog +from yt.utilities.logger import ytLogger as mylog -from .field_plugin_registry import \ - register_field_plugin +from .field_info_container import FieldInfoContainer +from .field_plugin_registry import register_field_plugin -from .field_info_container import \ - FieldInfoContainer class LocalFieldInfoContainer(FieldInfoContainer): def add_field(self, name, function=None, sampling_type=None, **kwargs): diff --git a/yt/fields/magnetic_field.py b/yt/fields/magnetic_field.py index d776a6929dc..0288b264d15 100644 --- a/yt/fields/magnetic_field.py +++ b/yt/fields/magnetic_field.py @@ -1,17 +1,12 @@ import numpy as np +from yt.fields.derived_field import ValidateParameter from yt.units import dimensions from yt.units.yt_array import ustack +from yt.utilities.math_utils import get_sph_phi_component, get_sph_theta_component -from yt.fields.derived_field import \ - ValidateParameter +from .field_plugin_registry import register_field_plugin -from .field_plugin_registry import \ - register_field_plugin - -from yt.utilities.math_utils import \ - get_sph_theta_component, \ - get_sph_phi_component @register_field_plugin def setup_magnetic_field_fields(registry, ftype="gas", slice_info=None): diff --git a/yt/fields/my_plugin_fields.py b/yt/fields/my_plugin_fields.py index 31e144e12e1..f3cd611777e 100644 --- a/yt/fields/my_plugin_fields.py +++ b/yt/fields/my_plugin_fields.py @@ -1,8 +1,5 @@ -from .field_plugin_registry import \ - register_field_plugin - -from .local_fields import \ - LocalFieldInfoContainer +from .field_plugin_registry import register_field_plugin +from .local_fields import LocalFieldInfoContainer # Empty FieldInfoContainer my_plugins_fields = LocalFieldInfoContainer(None, [], None) diff --git a/yt/fields/particle_fields.py b/yt/fields/particle_fields.py index 3f731614262..3244c2f716e 100644 --- a/yt/fields/particle_fields.py +++ b/yt/fields/particle_fields.py @@ -1,40 +1,30 @@ import numpy as np -from yt.fields.derived_field import \ - ValidateParameter, \ - ValidateSpatial - -from yt.fields.field_detector import \ - FieldDetector - -from yt.funcs import \ - issue_deprecation_warning - -from yt.units.yt_array import \ - uconcatenate, \ - ucross - -from yt.utilities.math_utils import \ - get_sph_r_component, \ - get_sph_theta_component, \ - get_sph_phi_component, \ - get_cyl_r_component, \ - get_cyl_z_component, \ - get_cyl_theta_component, \ - get_cyl_r, get_cyl_theta, \ - get_cyl_z, \ - get_sph_theta, get_sph_phi, \ - modify_reference_frame - -from yt.utilities.lib.misc_utilities import \ - obtain_relative_velocity_vector, \ - obtain_position_vector - -from .vector_operations import \ - create_magnitude_field - -from .field_functions import \ - get_radius +from yt.fields.derived_field import ValidateParameter, ValidateSpatial +from yt.fields.field_detector import FieldDetector +from yt.funcs import issue_deprecation_warning +from yt.units.yt_array import uconcatenate, ucross +from yt.utilities.lib.misc_utilities import ( + obtain_position_vector, + obtain_relative_velocity_vector, +) +from yt.utilities.math_utils import ( + get_cyl_r, + get_cyl_r_component, + get_cyl_theta, + get_cyl_theta_component, + get_cyl_z, + get_cyl_z_component, + get_sph_phi, + get_sph_phi_component, + get_sph_r_component, + get_sph_theta, + get_sph_theta_component, + modify_reference_frame, +) + +from .field_functions import get_radius +from .vector_operations import create_magnitude_field sph_whitelist_fields = ( 'density', diff --git a/yt/fields/species_fields.py b/yt/fields/species_fields.py index 5fb5d4dedf7..de69e0c83fb 100644 --- a/yt/fields/species_fields.py +++ b/yt/fields/species_fields.py @@ -1,19 +1,14 @@ -import numpy as np import re -from yt.fields.field_detector import \ - FieldDetector -from yt.frontends.sph.data_structures import \ - ParticleDataset -from yt.funcs import \ - issue_deprecation_warning -from yt.utilities.physical_ratios import \ - _primordial_mass_fraction -from yt.utilities.chemical_formulas import \ - ChemicalFormula -from .field_plugin_registry import \ - register_field_plugin +import numpy as np + +from yt.fields.field_detector import FieldDetector +from yt.frontends.sph.data_structures import ParticleDataset +from yt.funcs import issue_deprecation_warning +from yt.utilities.chemical_formulas import ChemicalFormula +from yt.utilities.physical_ratios import _primordial_mass_fraction +from .field_plugin_registry import register_field_plugin # See YTEP-0003 for details, but we want to ensure these fields are all # populated: diff --git a/yt/fields/tests/test_angular_momentum.py b/yt/fields/tests/test_angular_momentum.py index 0d52afbd589..90450c0f062 100644 --- a/yt/fields/tests/test_angular_momentum.py +++ b/yt/fields/tests/test_angular_momentum.py @@ -1,8 +1,7 @@ import numpy as np -from yt.testing import \ - assert_allclose_units, \ - fake_amr_ds +from yt.testing import assert_allclose_units, fake_amr_ds + def test_AM_value(): ds = fake_amr_ds(fields=("Density", "velocity_x", "velocity_y", "velocity_z"), length_unit=0.5) diff --git a/yt/fields/tests/test_field_access.py b/yt/fields/tests/test_field_access.py index d94e65daa28..2c275f1e7e9 100644 --- a/yt/fields/tests/test_field_access.py +++ b/yt/fields/tests/test_field_access.py @@ -1,12 +1,12 @@ -from yt.testing import fake_random_ds, assert_equal from yt.data_objects.profiles import create_profile -from yt.visualization.plot_window import \ - SlicePlot, \ - ProjectionPlot, \ - OffAxisProjectionPlot -from yt.visualization.profile_plotter import \ - ProfilePlot, \ - PhasePlot +from yt.testing import assert_equal, fake_random_ds +from yt.visualization.plot_window import ( + OffAxisProjectionPlot, + ProjectionPlot, + SlicePlot, +) +from yt.visualization.profile_plotter import PhasePlot, ProfilePlot + def test_field_access(): ds = fake_random_ds(16) diff --git a/yt/fields/tests/test_field_name_container.py b/yt/fields/tests/test_field_name_container.py index 0eddb7693d2..69dbc08bff9 100644 --- a/yt/fields/tests/test_field_name_container.py +++ b/yt/fields/tests/test_field_name_container.py @@ -1,7 +1,6 @@ -from yt import \ - load -from yt.testing import \ - requires_file +from yt import load +from yt.testing import requires_file + def do_field_type(ft): assert (dir(ft) == sorted(dir(ft))) diff --git a/yt/fields/tests/test_fields.py b/yt/fields/tests/test_fields.py index 3643c77477f..1af85a9383a 100644 --- a/yt/fields/tests/test_fields.py +++ b/yt/fields/tests/test_fields.py @@ -1,29 +1,27 @@ import numpy as np -from yt import \ - load -from yt.testing import \ - fake_amr_ds, \ - fake_random_ds, \ - fake_particle_ds, \ - assert_almost_equal, \ - assert_equal, \ - assert_array_almost_equal_nulp, \ - assert_array_equal, \ - assert_raises, \ - assert_allclose_units, \ - requires_file -from yt.utilities.cosmology import \ - Cosmology -from yt.frontends.stream.fields import \ - StreamFieldInfo -from yt.units.yt_array import \ - array_like_field, \ - YTArray, YTQuantity -from yt.utilities.exceptions import \ - YTFieldUnitError, \ - YTFieldUnitParseError, \ - YTDimensionalityError +from yt import load +from yt.frontends.stream.fields import StreamFieldInfo +from yt.testing import ( + assert_allclose_units, + assert_almost_equal, + assert_array_almost_equal_nulp, + assert_array_equal, + assert_equal, + assert_raises, + fake_amr_ds, + fake_particle_ds, + fake_random_ds, + requires_file, +) +from yt.units.yt_array import YTArray, YTQuantity, array_like_field +from yt.utilities.cosmology import Cosmology +from yt.utilities.exceptions import ( + YTDimensionalityError, + YTFieldUnitError, + YTFieldUnitParseError, +) + def get_params(ds): return dict( @@ -431,4 +429,3 @@ def test_ion_field_labels(): for f in fields: label = getattr(fobj, f).get_latex_display_name() assert_equal(label, pm_labels[f]) - diff --git a/yt/fields/tests/test_fields_plugins.py b/yt/fields/tests/test_fields_plugins.py index d59e78ea8b1..5b9f76268b3 100644 --- a/yt/fields/tests/test_fields_plugins.py +++ b/yt/fields/tests/test_fields_plugins.py @@ -1,11 +1,10 @@ import os import sys import unittest + import yt -from yt.config import ytcfg, CONFIG_DIR -from yt.testing import \ - assert_raises, \ - fake_random_ds +from yt.config import CONFIG_DIR, ytcfg +from yt.testing import assert_raises, fake_random_ds TEST_PLUGIN_FILE = ''' def _myfunc(field, data): diff --git a/yt/fields/tests/test_magnetic_fields.py b/yt/fields/tests/test_magnetic_fields.py index 56b3dbc66c7..e902d0adadb 100644 --- a/yt/fields/tests/test_magnetic_fields.py +++ b/yt/fields/tests/test_magnetic_fields.py @@ -1,7 +1,9 @@ import numpy as np -from yt.utilities.physical_constants import mu_0 -from yt.testing import assert_almost_equal + from yt.frontends.stream.api import load_uniform_grid +from yt.testing import assert_almost_equal +from yt.utilities.physical_constants import mu_0 + def setup(): from yt.config import ytcfg diff --git a/yt/fields/tests/test_particle_fields.py b/yt/fields/tests/test_particle_fields.py index 91885189aad..d3610c8522a 100644 --- a/yt/fields/tests/test_particle_fields.py +++ b/yt/fields/tests/test_particle_fields.py @@ -1,8 +1,5 @@ -from yt.testing import \ - assert_allclose_units, \ - requires_file -from yt.utilities.answer_testing.framework import \ - data_dir_load +from yt.testing import assert_allclose_units, requires_file +from yt.utilities.answer_testing.framework import data_dir_load g30 = "IsolatedGalaxy/galaxy0030/galaxy0030" @requires_file(g30) diff --git a/yt/fields/tests/test_species_fields.py b/yt/fields/tests/test_species_fields.py index 59ad4150c82..0a419b1f30b 100644 --- a/yt/fields/tests/test_species_fields.py +++ b/yt/fields/tests/test_species_fields.py @@ -1,11 +1,7 @@ -from yt.testing import requires_file, \ - assert_allclose_units, assert_equal -from yt.utilities.answer_testing.framework import \ - data_dir_load -from yt.utilities.physical_ratios import \ - _primordial_mass_fraction -from yt.utilities.chemical_formulas import \ - ChemicalFormula +from yt.testing import assert_allclose_units, assert_equal, requires_file +from yt.utilities.answer_testing.framework import data_dir_load +from yt.utilities.chemical_formulas import ChemicalFormula +from yt.utilities.physical_ratios import _primordial_mass_fraction sloshing = "GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0100" diff --git a/yt/fields/tests/test_sph_fields.py b/yt/fields/tests/test_sph_fields.py index d039c434cc7..55efabd25ce 100644 --- a/yt/fields/tests/test_sph_fields.py +++ b/yt/fields/tests/test_sph_fields.py @@ -1,10 +1,7 @@ -import yt - from collections import defaultdict -from yt.testing import \ - assert_array_almost_equal, \ - assert_equal, \ - requires_file + +import yt +from yt.testing import assert_array_almost_equal, assert_equal, requires_file isothermal_h5 = "IsothermalCollapse/snap_505.hdf5" isothermal_bin = "IsothermalCollapse/snap_505" diff --git a/yt/fields/tests/test_vector_fields.py b/yt/fields/tests/test_vector_fields.py index 75e41e1bfa7..f9fcae69ad1 100644 --- a/yt/fields/tests/test_vector_fields.py +++ b/yt/fields/tests/test_vector_fields.py @@ -1,12 +1,9 @@ import numpy as np -from yt.testing import \ - assert_allclose_units, \ - fake_random_ds, \ - requires_file -from yt.utilities.answer_testing.framework import \ - data_dir_load +from yt.testing import assert_allclose_units, fake_random_ds, requires_file from yt.units import cm, s +from yt.utilities.answer_testing.framework import data_dir_load + def random_unit_vector(prng): v = prng.random_sample(3) diff --git a/yt/fields/tests/test_xray_fields.py b/yt/fields/tests/test_xray_fields.py index 2401d385efa..9fb2d6045fe 100644 --- a/yt/fields/tests/test_xray_fields.py +++ b/yt/fields/tests/test_xray_fields.py @@ -1,8 +1,11 @@ -from yt.fields.xray_emission_fields import \ - add_xray_emissivity_field -from yt.utilities.answer_testing.framework import \ - requires_ds, can_run_ds, data_dir_load, \ - ProjectionValuesTest, FieldValuesTest +from yt.fields.xray_emission_fields import add_xray_emissivity_field +from yt.utilities.answer_testing.framework import ( + FieldValuesTest, + ProjectionValuesTest, + can_run_ds, + data_dir_load, + requires_ds, +) def setup(): diff --git a/yt/fields/vector_operations.py b/yt/fields/vector_operations.py index 98b2fdf0531..a82f41052d4 100644 --- a/yt/fields/vector_operations.py +++ b/yt/fields/vector_operations.py @@ -1,24 +1,19 @@ import numpy as np -from .derived_field import \ - ValidateParameter, \ - ValidateSpatial, \ - NeedsParameter - -from yt.utilities.math_utils import \ - get_sph_r_component, \ - get_sph_theta_component, \ - get_sph_phi_component, \ - get_cyl_r_component, \ - get_cyl_z_component, \ - get_cyl_theta_component - -from yt.funcs import just_one, iterable +from yt.funcs import iterable, just_one +from yt.geometry.geometry_handler import is_curvilinear +from yt.utilities.lib.misc_utilities import obtain_relative_velocity_vector +from yt.utilities.math_utils import ( + get_cyl_r_component, + get_cyl_theta_component, + get_cyl_z_component, + get_sph_phi_component, + get_sph_r_component, + get_sph_theta_component, +) -from yt.geometry.geometry_handler import \ - is_curvilinear +from .derived_field import NeedsParameter, ValidateParameter, ValidateSpatial -from yt.utilities.lib.misc_utilities import obtain_relative_velocity_vector def get_bulk(data, basename, unit): if data.has_field_parameter("bulk_%s" % basename): diff --git a/yt/fields/xray_emission_fields.py b/yt/fields/xray_emission_fields.py index a8c7d837a28..28b0084ea42 100644 --- a/yt/fields/xray_emission_fields.py +++ b/yt/fields/xray_emission_fields.py @@ -1,19 +1,18 @@ -from yt.utilities.on_demand_imports import _h5py as h5py -import numpy as np import os +import numpy as np + from yt.config import ytcfg from yt.fields.derived_field import DerivedField -from yt.funcs import \ - mylog, \ - only_on_root, \ - parse_h5_attr -from yt.utilities.exceptions import YTFieldNotFound -from yt.utilities.exceptions import YTException -from yt.utilities.linear_interpolators import \ - UnilinearFieldInterpolator, BilinearFieldInterpolator +from yt.funcs import mylog, only_on_root, parse_h5_attr from yt.units.yt_array import YTArray, YTQuantity from yt.utilities.cosmology import Cosmology +from yt.utilities.exceptions import YTException, YTFieldNotFound +from yt.utilities.linear_interpolators import ( + BilinearFieldInterpolator, + UnilinearFieldInterpolator, +) +from yt.utilities.on_demand_imports import _h5py as h5py data_version = {"cloudy": 2, "apec": 3} diff --git a/yt/frontends/_skeleton/__init__.py b/yt/frontends/_skeleton/__init__.py index c8a618b340d..82efc2971eb 100644 --- a/yt/frontends/_skeleton/__init__.py +++ b/yt/frontends/_skeleton/__init__.py @@ -4,4 +4,3 @@ """ - diff --git a/yt/frontends/_skeleton/api.py b/yt/frontends/_skeleton/api.py index fb890486926..1ed213e47b8 100644 --- a/yt/frontends/_skeleton/api.py +++ b/yt/frontends/_skeleton/api.py @@ -1,10 +1,3 @@ -from .data_structures import \ - SkeletonGrid, \ - SkeletonHierarchy, \ - SkeletonDataset - -from .fields import \ - SkeletonFieldInfo - -from .io import \ - SkeletonIOHandler +from .data_structures import SkeletonDataset, SkeletonGrid, SkeletonHierarchy +from .fields import SkeletonFieldInfo +from .io import SkeletonIOHandler diff --git a/yt/frontends/_skeleton/data_structures.py b/yt/frontends/_skeleton/data_structures.py index 60e6ebbec2f..cb295525677 100644 --- a/yt/frontends/_skeleton/data_structures.py +++ b/yt/frontends/_skeleton/data_structures.py @@ -1,13 +1,12 @@ import os -import numpy as np import weakref -from yt.data_objects.grid_patch import \ - AMRGridPatch -from yt.geometry.grid_geometry_handler import \ - GridIndex -from yt.data_objects.static_output import \ - Dataset +import numpy as np + +from yt.data_objects.grid_patch import AMRGridPatch +from yt.data_objects.static_output import Dataset +from yt.geometry.grid_geometry_handler import GridIndex + from .fields import SkeletonFieldInfo diff --git a/yt/frontends/_skeleton/fields.py b/yt/frontends/_skeleton/fields.py index 684bebc0dd6..8a95ef61fb8 100644 --- a/yt/frontends/_skeleton/fields.py +++ b/yt/frontends/_skeleton/fields.py @@ -1,5 +1,4 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer +from yt.fields.field_info_container import FieldInfoContainer # We need to specify which fields we might have in our dataset. The field info # container subclass here will define which fields it knows about. There are diff --git a/yt/frontends/_skeleton/io.py b/yt/frontends/_skeleton/io.py index 22a91c6b813..f1600163a35 100644 --- a/yt/frontends/_skeleton/io.py +++ b/yt/frontends/_skeleton/io.py @@ -1,5 +1,4 @@ -from yt.utilities.io_handler import \ - BaseIOHandler +from yt.utilities.io_handler import BaseIOHandler class SkeletonIOHandler(BaseIOHandler): diff --git a/yt/frontends/adaptahop/api.py b/yt/frontends/adaptahop/api.py index 6eeafac327b..85e84001ba1 100644 --- a/yt/frontends/adaptahop/api.py +++ b/yt/frontends/adaptahop/api.py @@ -14,13 +14,7 @@ # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- -from .data_structures import \ - AdaptaHOPDataset - -from .io import \ - IOHandlerAdaptaHOPBinary - -from .fields import \ - AdaptaHOPFieldInfo - from . import tests +from .data_structures import AdaptaHOPDataset +from .fields import AdaptaHOPFieldInfo +from .io import IOHandlerAdaptaHOPBinary diff --git a/yt/frontends/adaptahop/data_structures.py b/yt/frontends/adaptahop/data_structures.py index acd71163a76..ae788d960ed 100644 --- a/yt/frontends/adaptahop/data_structures.py +++ b/yt/frontends/adaptahop/data_structures.py @@ -14,26 +14,24 @@ # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- -import numpy as np -import stat import os import re +import stat -from yt.data_objects.data_containers import \ - YTSelectionContainer -from yt.data_objects.static_output import \ - Dataset -from yt.frontends.halo_catalog.data_structures import \ - HaloCatalogFile, HaloCatalogParticleIndex -from yt.funcs import \ - setdefaultattr -from yt.utilities.cython_fortran_utils import FortranFile +import numpy as np + +from yt.data_objects.data_containers import YTSelectionContainer +from yt.data_objects.static_output import Dataset +from yt.frontends.halo_catalog.data_structures import ( + HaloCatalogFile, + HaloCatalogParticleIndex, +) +from yt.funcs import setdefaultattr from yt.units import Mpc +from yt.utilities.cython_fortran_utils import FortranFile -from .definitions import \ - HEADER_ATTRIBUTES -from .fields import \ - AdaptaHOPFieldInfo +from .definitions import HEADER_ATTRIBUTES +from .fields import AdaptaHOPFieldInfo class AdaptaHOPDataset(Dataset): diff --git a/yt/frontends/adaptahop/fields.py b/yt/frontends/adaptahop/fields.py index 6c2bd71d46e..be2f6a932d8 100644 --- a/yt/frontends/adaptahop/fields.py +++ b/yt/frontends/adaptahop/fields.py @@ -14,8 +14,7 @@ # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- -from yt.fields.field_info_container import \ - FieldInfoContainer +from yt.fields.field_info_container import FieldInfoContainer m_units = "1e11 * Msun" r_units = "Mpc" diff --git a/yt/frontends/adaptahop/io.py b/yt/frontends/adaptahop/io.py index fd17aedd10f..d85a5241121 100644 --- a/yt/frontends/adaptahop/io.py +++ b/yt/frontends/adaptahop/io.py @@ -14,23 +14,18 @@ # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- +from operator import attrgetter + import numpy as np from yt.funcs import mylog - -from yt.utilities.exceptions import \ - YTDomainOverflow - -from yt.utilities.io_handler import \ - BaseIOHandler - -from yt.utilities.lib.geometry_utils import compute_morton from yt.utilities.cython_fortran_utils import FortranFile +from yt.utilities.exceptions import YTDomainOverflow +from yt.utilities.io_handler import BaseIOHandler +from yt.utilities.lib.geometry_utils import compute_morton -from operator import attrgetter +from .definitions import HALO_ATTRIBUTES, HEADER_ATTRIBUTES -from .definitions import \ - HEADER_ATTRIBUTES, HALO_ATTRIBUTES class IOHandlerAdaptaHOPBinary(BaseIOHandler): _dataset_type = "adaptahop_binary" diff --git a/yt/frontends/adaptahop/tests/test_outputs.py b/yt/frontends/adaptahop/tests/test_outputs.py index de84ae93e1c..e68541ad58e 100644 --- a/yt/frontends/adaptahop/tests/test_outputs.py +++ b/yt/frontends/adaptahop/tests/test_outputs.py @@ -15,11 +15,9 @@ import numpy as np -from yt.testing import requires_file -from yt.utilities.answer_testing.framework import \ - data_dir_load - from yt.frontends.adaptahop.data_structures import AdaptaHOPDataset +from yt.testing import requires_file +from yt.utilities.answer_testing.framework import data_dir_load r0 = "output_00080/info_00080.txt" r1 = "output_00080_halos/tree_bricks080" diff --git a/yt/frontends/ahf/__init__.py b/yt/frontends/ahf/__init__.py index 45cf0d77321..6dcd0757862 100644 --- a/yt/frontends/ahf/__init__.py +++ b/yt/frontends/ahf/__init__.py @@ -4,4 +4,3 @@ """ - diff --git a/yt/frontends/ahf/api.py b/yt/frontends/ahf/api.py index 2326c273921..d8b3e3b0d4c 100644 --- a/yt/frontends/ahf/api.py +++ b/yt/frontends/ahf/api.py @@ -1,8 +1,3 @@ -from .data_structures import \ - AHFHalosDataset - -from .fields import \ - AHFHalosFieldInfo - -from .io import \ - IOHandlerAHFHalos +from .data_structures import AHFHalosDataset +from .fields import AHFHalosFieldInfo +from .io import IOHandlerAHFHalos diff --git a/yt/frontends/ahf/data_structures.py b/yt/frontends/ahf/data_structures.py index 2ba725291a6..5e568efed0f 100644 --- a/yt/frontends/ahf/data_structures.py +++ b/yt/frontends/ahf/data_structures.py @@ -3,16 +3,11 @@ import numpy as np -from yt.data_objects.static_output import \ - Dataset -from yt.frontends.halo_catalog.data_structures import \ - HaloCatalogFile -from yt.funcs import \ - setdefaultattr -from yt.geometry.particle_geometry_handler import \ - ParticleIndex -from yt.utilities.cosmology import \ - Cosmology +from yt.data_objects.static_output import Dataset +from yt.frontends.halo_catalog.data_structures import HaloCatalogFile +from yt.funcs import setdefaultattr +from yt.geometry.particle_geometry_handler import ParticleIndex +from yt.utilities.cosmology import Cosmology from .fields import AHFHalosFieldInfo diff --git a/yt/frontends/ahf/fields.py b/yt/frontends/ahf/fields.py index 7277f140586..3b086c84eb6 100644 --- a/yt/frontends/ahf/fields.py +++ b/yt/frontends/ahf/fields.py @@ -1,5 +1,4 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer +from yt.fields.field_info_container import FieldInfoContainer m_units = 'Msun/h' p_units = 'kpccm/h' diff --git a/yt/frontends/ahf/io.py b/yt/frontends/ahf/io.py index 098ad52f76f..1561f1f1fb1 100644 --- a/yt/frontends/ahf/io.py +++ b/yt/frontends/ahf/io.py @@ -2,14 +2,10 @@ import numpy as np -from yt.funcs import \ - mylog -from yt.utilities.exceptions import \ - YTDomainOverflow -from yt.utilities.io_handler import \ - BaseIOHandler -from yt.utilities.lib.geometry_utils import \ - compute_morton +from yt.funcs import mylog +from yt.utilities.exceptions import YTDomainOverflow +from yt.utilities.io_handler import BaseIOHandler +from yt.utilities.lib.geometry_utils import compute_morton class IOHandlerAHFHalos(BaseIOHandler): diff --git a/yt/frontends/ahf/tests/test_outputs.py b/yt/frontends/ahf/tests/test_outputs.py index 7d3cdee61e5..dbec5febe4d 100644 --- a/yt/frontends/ahf/tests/test_outputs.py +++ b/yt/frontends/ahf/tests/test_outputs.py @@ -1,13 +1,12 @@ import os.path -from yt.testing import \ - assert_equal, \ - requires_file, \ - ParticleSelectionComparison -from yt.utilities.answer_testing.framework import \ - FieldValuesTest, \ - requires_ds, \ - data_dir_load + from yt.frontends.ahf.api import AHFHalosDataset +from yt.testing import ParticleSelectionComparison, assert_equal, requires_file +from yt.utilities.answer_testing.framework import ( + FieldValuesTest, + data_dir_load, + requires_ds, +) _fields = ('particle_position_x', 'particle_position_y', 'particle_position_z', 'particle_mass') diff --git a/yt/frontends/amrvac/__init__.py b/yt/frontends/amrvac/__init__.py index 1c69b8b9233..ec25700a0aa 100644 --- a/yt/frontends/amrvac/__init__.py +++ b/yt/frontends/amrvac/__init__.py @@ -15,6 +15,7 @@ from yt.utilities.on_demand_imports import _f90nml as f90nml + def read_amrvac_namelist(parfiles): """Read one or more parfiles, and return a unified f90nml.Namelist object. diff --git a/yt/frontends/amrvac/api.py b/yt/frontends/amrvac/api.py index 5d5f9afa897..cf42eff628f 100644 --- a/yt/frontends/amrvac/api.py +++ b/yt/frontends/amrvac/api.py @@ -13,13 +13,6 @@ # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- -from .data_structures import \ - AMRVACGrid, \ - AMRVACHierarchy, \ - AMRVACDataset - -from .fields import \ - AMRVACFieldInfo - -from .io import \ - AMRVACIOHandler +from .data_structures import AMRVACDataset, AMRVACGrid, AMRVACHierarchy +from .fields import AMRVACFieldInfo +from .io import AMRVACIOHandler diff --git a/yt/frontends/amrvac/data_structures.py b/yt/frontends/amrvac/data_structures.py index b7ec5369e37..befd6ffc3b8 100644 --- a/yt/frontends/amrvac/data_structures.py +++ b/yt/frontends/amrvac/data_structures.py @@ -15,26 +15,20 @@ import os import stat -import weakref import struct +import weakref import numpy as np -from yt.data_objects.grid_patch import \ - AMRGridPatch -from yt.geometry.grid_geometry_handler import \ - GridIndex -from yt.funcs import \ - mylog, \ - setdefaultattr -from yt.data_objects.static_output import \ - Dataset -from yt.utilities.physical_constants import \ - boltzmann_constant_cgs as kb_cgs +from yt.data_objects.grid_patch import AMRGridPatch +from yt.data_objects.static_output import Dataset +from yt.funcs import mylog, setdefaultattr +from yt.geometry.grid_geometry_handler import GridIndex +from yt.utilities.physical_constants import boltzmann_constant_cgs as kb_cgs -from .fields import AMRVACFieldInfo -from .datfile_utils import get_header, get_tree_info from . import read_amrvac_namelist +from .datfile_utils import get_header, get_tree_info +from .fields import AMRVACFieldInfo ALLOWED_UNIT_COMBINATIONS = [{'numberdensity_unit', 'temperature_unit', 'length_unit'}, {'mass_unit', 'temperature_unit', 'length_unit'}, diff --git a/yt/frontends/amrvac/datfile_utils.py b/yt/frontends/amrvac/datfile_utils.py index d1b3516f0b2..02b9fb783cc 100644 --- a/yt/frontends/amrvac/datfile_utils.py +++ b/yt/frontends/amrvac/datfile_utils.py @@ -1,4 +1,5 @@ import struct + import numpy as np # Size of basic types (in bytes) diff --git a/yt/frontends/amrvac/fields.py b/yt/frontends/amrvac/fields.py index cfbd7c3b355..98e866415eb 100644 --- a/yt/frontends/amrvac/fields.py +++ b/yt/frontends/amrvac/fields.py @@ -12,12 +12,13 @@ #----------------------------------------------------------------------------- import functools + import numpy as np -from yt.fields.field_info_container import \ - FieldInfoContainer + +from yt import mylog +from yt.fields.field_info_container import FieldInfoContainer from yt.fields.magnetic_field import setup_magnetic_field_aliases from yt.units import dimensions -from yt import mylog # We need to specify which fields we might have in our dataset. The field info # container subclass here will define which fields it knows about. There are diff --git a/yt/frontends/amrvac/io.py b/yt/frontends/amrvac/io.py index 74764cfd2e5..c916f148d95 100644 --- a/yt/frontends/amrvac/io.py +++ b/yt/frontends/amrvac/io.py @@ -13,10 +13,10 @@ # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- import numpy as np -from yt.utilities.io_handler import \ - BaseIOHandler -from yt.geometry.selection_routines import \ - GridSelector + +from yt.geometry.selection_routines import GridSelector +from yt.utilities.io_handler import BaseIOHandler + from .datfile_utils import get_single_block_field_data diff --git a/yt/frontends/amrvac/tests/test_outputs.py b/yt/frontends/amrvac/tests/test_outputs.py index 2ccad3ed614..08ca7fc401a 100644 --- a/yt/frontends/amrvac/tests/test_outputs.py +++ b/yt/frontends/amrvac/tests/test_outputs.py @@ -1,14 +1,14 @@ -import numpy as np # NOQA - -import yt # NOQA -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - data_dir_load, small_patch_amr -from yt.testing import requires_file, \ - assert_allclose_units, \ - assert_raises +import numpy as np # NOQA + +import yt # NOQA from yt.frontends.amrvac.api import AMRVACDataset, AMRVACGrid +from yt.testing import assert_allclose_units, assert_raises, requires_file from yt.units import YTQuantity +from yt.utilities.answer_testing.framework import ( + data_dir_load, + requires_ds, + small_patch_amr, +) blastwave_spherical_2D = "amrvac/bw_2d0000.dat" khi_cartesian_2D = "amrvac/kh_2d0000.dat" diff --git a/yt/frontends/amrvac/tests/test_read_amrvac_namelist.py b/yt/frontends/amrvac/tests/test_read_amrvac_namelist.py index 46364a89c83..fb41d33653f 100644 --- a/yt/frontends/amrvac/tests/test_read_amrvac_namelist.py +++ b/yt/frontends/amrvac/tests/test_read_amrvac_namelist.py @@ -1,8 +1,9 @@ -from os import path from copy import deepcopy +from os import path + +from yt.frontends.amrvac import read_amrvac_namelist from yt.testing import requires_module from yt.utilities.on_demand_imports import _f90nml as f90nml -from yt.frontends.amrvac import read_amrvac_namelist test_dir = path.dirname(path.abspath(__file__)) blast_wave_parfile = path.join(test_dir, "sample_parfiles/bw_3d.par") diff --git a/yt/frontends/api.py b/yt/frontends/api.py index 46d8967b5b2..6c334a1b6c2 100644 --- a/yt/frontends/api.py +++ b/yt/frontends/api.py @@ -1,4 +1,9 @@ -import sys, types, os, glob, time, importlib +import glob +import importlib +import os +import sys +import time +import types _frontends = [ 'adaptahop', diff --git a/yt/frontends/arepo/api.py b/yt/frontends/arepo/api.py index fdd4405e77f..5d92414c9af 100644 --- a/yt/frontends/arepo/api.py +++ b/yt/frontends/arepo/api.py @@ -1,8 +1,3 @@ -from .data_structures import \ - ArepoHDF5Dataset, \ - ArepoFieldInfo - -from .io import \ - IOHandlerArepoHDF5 - from . import tests +from .data_structures import ArepoFieldInfo, ArepoHDF5Dataset +from .io import IOHandlerArepoHDF5 diff --git a/yt/frontends/arepo/data_structures.py b/yt/frontends/arepo/data_structures.py index a9ea881a853..039d015ab60 100644 --- a/yt/frontends/arepo/data_structures.py +++ b/yt/frontends/arepo/data_structures.py @@ -1,11 +1,10 @@ +import numpy as np + from yt.frontends.gadget.api import GadgetHDF5Dataset from yt.funcs import mylog from yt.utilities.on_demand_imports import _h5py as h5py -from .fields import \ - ArepoFieldInfo - -import numpy as np +from .fields import ArepoFieldInfo class ArepoHDF5Dataset(GadgetHDF5Dataset): diff --git a/yt/frontends/arepo/fields.py b/yt/frontends/arepo/fields.py index fd43b69f57b..900f097d579 100644 --- a/yt/frontends/arepo/fields.py +++ b/yt/frontends/arepo/fields.py @@ -1,11 +1,7 @@ +from yt.fields.field_info_container import FieldInfoContainer +from yt.fields.magnetic_field import setup_magnetic_field_aliases +from yt.fields.species_fields import add_species_field_by_fraction, setup_species_fields from yt.frontends.gadget.api import GadgetFieldInfo -from yt.fields.magnetic_field import \ - setup_magnetic_field_aliases -from yt.fields.species_fields import \ - add_species_field_by_fraction, \ - setup_species_fields -from yt.fields.field_info_container import \ - FieldInfoContainer metal_elements = ["He", "C", "N", "O", "Ne", "Mg", "Si", "Fe"] diff --git a/yt/frontends/arepo/io.py b/yt/frontends/arepo/io.py index b0af0f90b83..0914e4625d1 100644 --- a/yt/frontends/arepo/io.py +++ b/yt/frontends/arepo/io.py @@ -1,7 +1,9 @@ -from yt.frontends.gadget.api import IOHandlerGadgetHDF5 import numpy as np + +from yt.frontends.gadget.api import IOHandlerGadgetHDF5 from yt.utilities.on_demand_imports import _h5py as h5py + class IOHandlerArepoHDF5(IOHandlerGadgetHDF5): _dataset_type = "arepo_hdf5" @@ -30,4 +32,3 @@ def _identify_fields(self, data_file): self)._identify_fields(data_file) fields.append(("PartType0", "smoothing_length")) return fields, _units - diff --git a/yt/frontends/arepo/tests/test_outputs.py b/yt/frontends/arepo/tests/test_outputs.py index 2dd2197880a..711b962cd39 100644 --- a/yt/frontends/arepo/tests/test_outputs.py +++ b/yt/frontends/arepo/tests/test_outputs.py @@ -1,12 +1,10 @@ import os import tempfile from collections import OrderedDict -from yt.testing import requires_file, ParticleSelectionComparison -from yt.utilities.answer_testing.framework import \ - data_dir_load, \ - requires_ds, \ - sph_answer + from yt.frontends.arepo.api import ArepoHDF5Dataset +from yt.testing import ParticleSelectionComparison, requires_file +from yt.utilities.answer_testing.framework import data_dir_load, requires_ds, sph_answer bullet_h5 = "ArepoBullet/snapshot_150.hdf5" tng59_h5 = "TNGHalo/halo_59.hdf5" diff --git a/yt/frontends/art/__init__.py b/yt/frontends/art/__init__.py index 8481d7b4d5f..551f529b794 100644 --- a/yt/frontends/art/__init__.py +++ b/yt/frontends/art/__init__.py @@ -4,4 +4,3 @@ """ - diff --git a/yt/frontends/art/api.py b/yt/frontends/art/api.py index fe112a4e86e..56a8778cd78 100644 --- a/yt/frontends/art/api.py +++ b/yt/frontends/art/api.py @@ -1,14 +1,10 @@ -from .data_structures import \ - ARTDomainFile,\ - ARTDomainSubset,\ - ARTIndex,\ - ARTDataset, \ - DarkMatterARTDataset - -from .fields import \ - ARTFieldInfo - -from .io import \ - IOHandlerART - from . import tests +from .data_structures import ( + ARTDataset, + ARTDomainFile, + ARTDomainSubset, + ARTIndex, + DarkMatterARTDataset, +) +from .fields import ARTFieldInfo +from .io import IOHandlerART diff --git a/yt/frontends/art/data_structures.py b/yt/frontends/art/data_structures.py index 039678466e3..781fb9452fe 100644 --- a/yt/frontends/art/data_structures.py +++ b/yt/frontends/art/data_structures.py @@ -1,44 +1,37 @@ import glob -import numpy as np import os import struct import weakref -from yt.geometry.oct_geometry_handler import \ - OctreeIndex -from yt.geometry.geometry_handler import \ - YTDataChunk -from yt.data_objects.static_output import \ - Dataset, ParticleFile -from yt.data_objects.octree_subset import \ - OctreeSubset -from yt.funcs import \ - mylog, \ - setdefaultattr -from yt.geometry.oct_container import \ - ARTOctreeContainer -from yt.frontends.art.definitions import \ - fluid_fields, \ - particle_fields, \ - filename_pattern, \ - particle_header_struct, \ - amr_header_struct, \ - dmparticle_header_struct, \ - constants, \ - seek_extras -from yt.frontends.art.fields import ARTFieldInfo -from yt.data_objects.particle_unions import \ - ParticleUnion -from yt.geometry.particle_geometry_handler import \ - ParticleIndex +import numpy as np import yt.utilities.fortran_utils as fpu -from yt.frontends.art.io import \ - _read_art_level_info, \ - _read_child_level, \ - _read_root_level, \ - b2t, \ - a2b +from yt.data_objects.octree_subset import OctreeSubset +from yt.data_objects.particle_unions import ParticleUnion +from yt.data_objects.static_output import Dataset, ParticleFile +from yt.frontends.art.definitions import ( + amr_header_struct, + constants, + dmparticle_header_struct, + filename_pattern, + fluid_fields, + particle_fields, + particle_header_struct, + seek_extras, +) +from yt.frontends.art.fields import ARTFieldInfo +from yt.frontends.art.io import ( + _read_art_level_info, + _read_child_level, + _read_root_level, + a2b, + b2t, +) +from yt.funcs import mylog, setdefaultattr +from yt.geometry.geometry_handler import YTDataChunk +from yt.geometry.oct_container import ARTOctreeContainer +from yt.geometry.oct_geometry_handler import OctreeIndex +from yt.geometry.particle_geometry_handler import ParticleIndex class ARTIndex(OctreeIndex): diff --git a/yt/frontends/art/fields.py b/yt/frontends/art/fields.py index 19712ab9493..1f5a3866b46 100644 --- a/yt/frontends/art/fields.py +++ b/yt/frontends/art/fields.py @@ -1,5 +1,4 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer +from yt.fields.field_info_container import FieldInfoContainer b_units = "code_magnetic" ra_units = "code_length / code_time**2" diff --git a/yt/frontends/art/io.py b/yt/frontends/art/io.py index 74b4f3f6688..1998dba752e 100644 --- a/yt/frontends/art/io.py +++ b/yt/frontends/art/io.py @@ -1,29 +1,26 @@ -import numpy as np import os import os.path import sys - from collections import defaultdict +import numpy as np + +from yt.frontends.art.definitions import ( + hydro_struct, + particle_fields, + particle_star_fields, + star_struct, +) +from yt.units.yt_array import YTArray, YTQuantity +from yt.utilities.fortran_utils import read_vector, skip +from yt.utilities.io_handler import BaseIOHandler +from yt.utilities.lib.geometry_utils import compute_morton +from yt.utilities.logger import ytLogger as mylog + if sys.version_info >= (3,0,0): long = int -from yt.frontends.art.definitions import \ - particle_star_fields, \ - particle_fields, \ - star_struct, \ - hydro_struct -from yt.utilities.io_handler import \ - BaseIOHandler -from yt.utilities.logger import ytLogger as mylog -from yt.utilities.lib.geometry_utils import compute_morton -from yt.utilities.fortran_utils import \ - read_vector, \ - skip -from yt.units.yt_array import \ - YTQuantity, \ - YTArray class IOHandlerART(BaseIOHandler): _dataset_type = "art" diff --git a/yt/frontends/art/tests/test_outputs.py b/yt/frontends/art/tests/test_outputs.py index db2f9ac82d2..1a768c36fc4 100644 --- a/yt/frontends/art/tests/test_outputs.py +++ b/yt/frontends/art/tests/test_outputs.py @@ -1,17 +1,18 @@ -from yt.testing import \ - requires_file, \ - assert_equal, \ - units_override_check, \ - assert_almost_equal, \ - ParticleSelectionComparison -from yt.units.yt_array import \ - YTQuantity -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - FieldValuesTest, \ - PixelizedProjectionValuesTest, \ - data_dir_load from yt.frontends.art.api import ARTDataset +from yt.testing import ( + ParticleSelectionComparison, + assert_almost_equal, + assert_equal, + requires_file, + units_override_check, +) +from yt.units.yt_array import YTQuantity +from yt.utilities.answer_testing.framework import ( + FieldValuesTest, + PixelizedProjectionValuesTest, + data_dir_load, + requires_ds, +) _fields = ( ("gas", "density"), diff --git a/yt/frontends/artio/__init__.py b/yt/frontends/artio/__init__.py index 17195075cf4..1812efd2c5c 100644 --- a/yt/frontends/artio/__init__.py +++ b/yt/frontends/artio/__init__.py @@ -5,4 +5,3 @@ """ - diff --git a/yt/frontends/artio/api.py b/yt/frontends/artio/api.py index 2b0cf57443f..2e80b33ca36 100644 --- a/yt/frontends/artio/api.py +++ b/yt/frontends/artio/api.py @@ -1,10 +1,4 @@ -from .data_structures import \ - ARTIODataset - -from .fields import \ - ARTIOFieldInfo - -from .io import \ - IOHandlerARTIO - from . import tests +from .data_structures import ARTIODataset +from .fields import ARTIOFieldInfo +from .io import IOHandlerARTIO diff --git a/yt/frontends/artio/data_structures.py b/yt/frontends/artio/data_structures.py index 144cc475785..eb42957c967 100644 --- a/yt/frontends/artio/data_structures.py +++ b/yt/frontends/artio/data_structures.py @@ -1,34 +1,25 @@ -import numpy as np import os import weakref - from collections import defaultdict -from yt.frontends.artio._artio_caller import \ - artio_is_valid, \ - artio_fileset, \ - ARTIOSFCRangeHandler -from yt.frontends.artio import _artio_caller -from yt.frontends.artio.fields import \ - ARTIOFieldInfo - -from yt.funcs import \ - mylog, \ - setdefaultattr -from yt.geometry.geometry_handler import \ - Index, \ - YTDataChunk +import numpy as np + import yt.geometry.particle_deposit as particle_deposit -from yt.data_objects.static_output import \ - Dataset -from yt.data_objects.octree_subset import \ - OctreeSubset -from yt.data_objects.field_data import \ - YTFieldData -from yt.utilities.exceptions import \ - YTParticleDepositionNotImplemented -from yt.data_objects.particle_unions import \ - ParticleUnion +from yt.data_objects.field_data import YTFieldData +from yt.data_objects.octree_subset import OctreeSubset +from yt.data_objects.particle_unions import ParticleUnion +from yt.data_objects.static_output import Dataset +from yt.frontends.artio import _artio_caller +from yt.frontends.artio._artio_caller import ( + ARTIOSFCRangeHandler, + artio_fileset, + artio_is_valid, +) +from yt.frontends.artio.fields import ARTIOFieldInfo +from yt.funcs import mylog, setdefaultattr +from yt.geometry.geometry_handler import Index, YTDataChunk +from yt.utilities.exceptions import YTParticleDepositionNotImplemented + class ARTIOOctreeSubset(OctreeSubset): _domain_offset = 0 diff --git a/yt/frontends/artio/fields.py b/yt/frontends/artio/fields.py index 2dff4d492ba..d9ec3eaa27c 100644 --- a/yt/frontends/artio/fields.py +++ b/yt/frontends/artio/fields.py @@ -1,12 +1,9 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer -from yt.units.yt_array import \ - YTArray -from yt.utilities.physical_constants import \ - boltzmann_constant_cgs, \ - amu_cgs import numpy as np +from yt.fields.field_info_container import FieldInfoContainer +from yt.units.yt_array import YTArray +from yt.utilities.physical_constants import amu_cgs, boltzmann_constant_cgs + b_units = "code_magnetic" ra_units = "code_length / code_time**2" rho_units = "code_mass / code_length**3" diff --git a/yt/frontends/artio/io.py b/yt/frontends/artio/io.py index 95cc6f9fead..6202ec963d4 100644 --- a/yt/frontends/artio/io.py +++ b/yt/frontends/artio/io.py @@ -1,7 +1,6 @@ import numpy as np -from yt.utilities.io_handler import \ - BaseIOHandler +from yt.utilities.io_handler import BaseIOHandler class IOHandlerARTIO(BaseIOHandler): diff --git a/yt/frontends/artio/tests/test_outputs.py b/yt/frontends/artio/tests/test_outputs.py index 12a68c141bb..c9eb1b21c0f 100644 --- a/yt/frontends/artio/tests/test_outputs.py +++ b/yt/frontends/artio/tests/test_outputs.py @@ -1,16 +1,18 @@ from yt.convenience import load -from yt.testing import \ - assert_equal, \ - assert_allclose_units, \ - requires_file, \ - units_override_check -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - data_dir_load, \ - PixelizedProjectionValuesTest, \ - FieldValuesTest, \ - create_obj from yt.frontends.artio.api import ARTIODataset +from yt.testing import ( + assert_allclose_units, + assert_equal, + requires_file, + units_override_check, +) +from yt.utilities.answer_testing.framework import ( + FieldValuesTest, + PixelizedProjectionValuesTest, + create_obj, + data_dir_load, + requires_ds, +) _fields = ("temperature", "density", "velocity_magnitude", ("deposit", "all_density"), ("deposit", "all_count")) diff --git a/yt/frontends/athena/api.py b/yt/frontends/athena/api.py index d6809d21dd2..f04bcab66a3 100644 --- a/yt/frontends/athena/api.py +++ b/yt/frontends/athena/api.py @@ -1,12 +1,4 @@ -from .data_structures import \ - AthenaGrid, \ - AthenaHierarchy, \ - AthenaDataset - -from .fields import \ - AthenaFieldInfo - -from .io import \ - IOHandlerAthena - from . import tests +from .data_structures import AthenaDataset, AthenaGrid, AthenaHierarchy +from .fields import AthenaFieldInfo +from .io import IOHandlerAthena diff --git a/yt/frontends/athena/data_structures.py b/yt/frontends/athena/data_structures.py index e1ac69646e7..105c95cad05 100644 --- a/yt/frontends/athena/data_structures.py +++ b/yt/frontends/athena/data_structures.py @@ -1,27 +1,19 @@ -import numpy as np import os import weakref -from yt.funcs import \ - mylog, \ - ensure_tuple, \ - sglob -from yt.data_objects.grid_patch import \ - AMRGridPatch -from yt.geometry.grid_geometry_handler import \ - GridIndex -from yt.data_objects.static_output import \ - Dataset -from yt.utilities.chemical_formulas import \ - default_mu -from yt.utilities.lib.misc_utilities import \ - get_box_grids_level -from yt.geometry.geometry_handler import \ - YTDataChunk +import numpy as np + +from yt.data_objects.grid_patch import AMRGridPatch +from yt.data_objects.static_output import Dataset +from yt.funcs import ensure_tuple, mylog, sglob +from yt.geometry.geometry_handler import YTDataChunk +from yt.geometry.grid_geometry_handler import GridIndex +from yt.utilities.chemical_formulas import default_mu +from yt.utilities.decompose import decompose_array, get_psize +from yt.utilities.lib.misc_utilities import get_box_grids_level from .fields import AthenaFieldInfo -from yt.utilities.decompose import \ - decompose_array, get_psize + def chk23(strin): return strin.encode('utf-8') diff --git a/yt/frontends/athena/definitions.py b/yt/frontends/athena/definitions.py index 307b63a9616..70a2797752a 100644 --- a/yt/frontends/athena/definitions.py +++ b/yt/frontends/athena/definitions.py @@ -4,4 +4,3 @@ """ - diff --git a/yt/frontends/athena/fields.py b/yt/frontends/athena/fields.py index a35c7b3d1a9..11c8efb440b 100644 --- a/yt/frontends/athena/fields.py +++ b/yt/frontends/athena/fields.py @@ -1,7 +1,5 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer -from yt.utilities.physical_constants import \ - kboltz, mh +from yt.fields.field_info_container import FieldInfoContainer +from yt.utilities.physical_constants import kboltz, mh b_units = "code_magnetic" pres_units = "code_pressure" diff --git a/yt/frontends/athena/io.py b/yt/frontends/athena/io.py index 6a510bf6839..90c2668c1a9 100644 --- a/yt/frontends/athena/io.py +++ b/yt/frontends/athena/io.py @@ -1,7 +1,8 @@ -from yt.utilities.io_handler import \ - BaseIOHandler import numpy as np + from yt.funcs import mylog +from yt.utilities.io_handler import BaseIOHandler + from .data_structures import chk23 float_size = {"float":np.dtype(">f4").itemsize, @@ -108,5 +109,3 @@ def get_read_table_offset(f): break line = f.readline() return read_table_offset - - diff --git a/yt/frontends/athena/tests/test_outputs.py b/yt/frontends/athena/tests/test_outputs.py index eda890eab86..b4379f8543e 100644 --- a/yt/frontends/athena/tests/test_outputs.py +++ b/yt/frontends/athena/tests/test_outputs.py @@ -1,16 +1,17 @@ -from yt.testing import \ - assert_equal, \ - requires_file, \ - assert_allclose_units, \ - disable_dataset_cache -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - small_patch_amr, \ - data_dir_load -from yt.frontends.athena.api import AthenaDataset -from yt.convenience import load - import yt.units as u +from yt.convenience import load +from yt.frontends.athena.api import AthenaDataset +from yt.testing import ( + assert_allclose_units, + assert_equal, + disable_dataset_cache, + requires_file, +) +from yt.utilities.answer_testing.framework import ( + data_dir_load, + requires_ds, + small_patch_amr, +) _fields_cloud = ("scalar[0]", "density", "total_energy") diff --git a/yt/frontends/athena_pp/api.py b/yt/frontends/athena_pp/api.py index 497dd4e2984..40b252b71a5 100644 --- a/yt/frontends/athena_pp/api.py +++ b/yt/frontends/athena_pp/api.py @@ -1,12 +1,4 @@ -from .data_structures import \ - AthenaPPGrid, \ - AthenaPPHierarchy, \ - AthenaPPDataset - -from .fields import \ - AthenaPPFieldInfo - -from .io import \ - IOHandlerAthenaPP - from . import tests +from .data_structures import AthenaPPDataset, AthenaPPGrid, AthenaPPHierarchy +from .fields import AthenaPPFieldInfo +from .io import IOHandlerAthenaPP diff --git a/yt/frontends/athena_pp/data_structures.py b/yt/frontends/athena_pp/data_structures.py index 03501b729ac..ca56f9c2dd1 100644 --- a/yt/frontends/athena_pp/data_structures.py +++ b/yt/frontends/athena_pp/data_structures.py @@ -1,28 +1,20 @@ -import numpy as np import os import weakref - -from yt.funcs import \ - mylog, get_pbar, \ - ensure_tuple -from yt.data_objects.grid_patch import \ - AMRGridPatch -from yt.geometry.grid_geometry_handler import \ - GridIndex -from yt.data_objects.static_output import \ - Dataset -from yt.geometry.geometry_handler import \ - YTDataChunk -from yt.utilities.file_handler import \ - HDF5FileHandler -from yt.geometry.unstructured_mesh_handler import \ - UnstructuredIndex -from yt.data_objects.unstructured_mesh import \ - SemiStructuredMesh from itertools import chain, product + +import numpy as np + +from yt.data_objects.grid_patch import AMRGridPatch +from yt.data_objects.static_output import Dataset +from yt.data_objects.unstructured_mesh import SemiStructuredMesh +from yt.funcs import ensure_tuple, get_pbar, mylog +from yt.geometry.geometry_handler import YTDataChunk +from yt.geometry.grid_geometry_handler import GridIndex +from yt.geometry.unstructured_mesh_handler import UnstructuredIndex +from yt.utilities.chemical_formulas import default_mu +from yt.utilities.file_handler import HDF5FileHandler + from .fields import AthenaPPFieldInfo -from yt.utilities.chemical_formulas import \ - default_mu geom_map = {"cartesian": "cartesian", "cylindrical": "cylindrical", diff --git a/yt/frontends/athena_pp/definitions.py b/yt/frontends/athena_pp/definitions.py index 307b63a9616..70a2797752a 100644 --- a/yt/frontends/athena_pp/definitions.py +++ b/yt/frontends/athena_pp/definitions.py @@ -4,4 +4,3 @@ """ - diff --git a/yt/frontends/athena_pp/fields.py b/yt/frontends/athena_pp/fields.py index 3d4003b676d..ff18f5641ed 100644 --- a/yt/frontends/athena_pp/fields.py +++ b/yt/frontends/athena_pp/fields.py @@ -1,7 +1,5 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer -from yt.utilities.physical_constants import \ - kboltz, mh +from yt.fields.field_info_container import FieldInfoContainer +from yt.utilities.physical_constants import kboltz, mh b_units = "code_magnetic" pres_units = "code_mass/(code_length*code_time**2)" diff --git a/yt/frontends/athena_pp/io.py b/yt/frontends/athena_pp/io.py index 88763e26421..fd06d427bd9 100644 --- a/yt/frontends/athena_pp/io.py +++ b/yt/frontends/athena_pp/io.py @@ -1,10 +1,11 @@ -import numpy as np from itertools import groupby -from yt.utilities.io_handler import \ - BaseIOHandler +import numpy as np + +from yt.utilities.io_handler import BaseIOHandler from yt.utilities.logger import ytLogger as mylog + # http://stackoverflow.com/questions/2361945/detecting-consecutive-integers-in-a-list def grid_sequences(grids): g_iter = sorted(grids, key = lambda g: g.id) @@ -82,4 +83,4 @@ def _read_chunk_data(self, chunk, fields): data = ds[fdi,start:end,:,:,:].transpose() for i, g in enumerate(gs): rv[g.id][field] = np.asarray(data[...,i], "=f8") - return rv \ No newline at end of file + return rv diff --git a/yt/frontends/athena_pp/tests/test_outputs.py b/yt/frontends/athena_pp/tests/test_outputs.py index d176cedde67..c83214fc554 100644 --- a/yt/frontends/athena_pp/tests/test_outputs.py +++ b/yt/frontends/athena_pp/tests/test_outputs.py @@ -1,16 +1,19 @@ import numpy as np -from yt.testing import \ - assert_equal, \ - requires_file, \ - units_override_check, \ - assert_allclose -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - small_patch_amr, \ - data_dir_load, \ - GenericArrayTest -from yt.frontends.athena_pp.api import AthenaPPDataset + from yt.convenience import load +from yt.frontends.athena_pp.api import AthenaPPDataset +from yt.testing import ( + assert_allclose, + assert_equal, + requires_file, + units_override_check, +) +from yt.utilities.answer_testing.framework import ( + GenericArrayTest, + data_dir_load, + requires_ds, + small_patch_amr, +) _fields_disk = ("density", "velocity_r") diff --git a/yt/frontends/boxlib/__init__.py b/yt/frontends/boxlib/__init__.py index 07fa1336903..a38372cd19a 100644 --- a/yt/frontends/boxlib/__init__.py +++ b/yt/frontends/boxlib/__init__.py @@ -4,4 +4,3 @@ """ - diff --git a/yt/frontends/boxlib/api.py b/yt/frontends/boxlib/api.py index 0ccf409e52c..b1bfd3c0aa8 100644 --- a/yt/frontends/boxlib/api.py +++ b/yt/frontends/boxlib/api.py @@ -1,24 +1,22 @@ -from .data_structures import \ - BoxlibGrid, \ - BoxlibHierarchy, \ - BoxlibDataset, \ - OrionHierarchy, \ - OrionDataset, \ - CastroDataset, \ - MaestroDataset, \ - NyxDataset, \ - NyxHierarchy, \ - WarpXDataset, \ - WarpXHierarchy - -from .fields import \ - BoxlibFieldInfo, \ - MaestroFieldInfo, \ - CastroFieldInfo, \ - NyxFieldInfo, \ - WarpXFieldInfo - -from .io import \ - IOHandlerBoxlib - from . import tests +from .data_structures import ( + BoxlibDataset, + BoxlibGrid, + BoxlibHierarchy, + CastroDataset, + MaestroDataset, + NyxDataset, + NyxHierarchy, + OrionDataset, + OrionHierarchy, + WarpXDataset, + WarpXHierarchy, +) +from .fields import ( + BoxlibFieldInfo, + CastroFieldInfo, + MaestroFieldInfo, + NyxFieldInfo, + WarpXFieldInfo, +) +from .io import IOHandlerBoxlib diff --git a/yt/frontends/boxlib/data_structures.py b/yt/frontends/boxlib/data_structures.py index 94b2adf3084..04ebb896338 100644 --- a/yt/frontends/boxlib/data_structures.py +++ b/yt/frontends/boxlib/data_structures.py @@ -1,34 +1,27 @@ +import glob import inspect import os import re from collections import namedtuple - from stat import ST_CTIME import numpy as np -import glob -from yt.funcs import \ - ensure_tuple, \ - mylog, \ - setdefaultattr from yt.data_objects.grid_patch import AMRGridPatch -from yt.geometry.grid_geometry_handler import GridIndex from yt.data_objects.static_output import Dataset - -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - parallel_root_only -from yt.utilities.lib.misc_utilities import \ - get_box_grids_level -from yt.utilities.io_handler import \ - io_registry - -from .fields import \ - BoxlibFieldInfo, \ - NyxFieldInfo, \ - MaestroFieldInfo, \ - CastroFieldInfo, \ - WarpXFieldInfo +from yt.funcs import ensure_tuple, mylog, setdefaultattr +from yt.geometry.grid_geometry_handler import GridIndex +from yt.utilities.io_handler import io_registry +from yt.utilities.lib.misc_utilities import get_box_grids_level +from yt.utilities.parallel_tools.parallel_analysis_interface import parallel_root_only + +from .fields import ( + BoxlibFieldInfo, + CastroFieldInfo, + MaestroFieldInfo, + NyxFieldInfo, + WarpXFieldInfo, +) # This is what we use to find scientific notation that might include d's # instead of e's. diff --git a/yt/frontends/boxlib/definitions.py b/yt/frontends/boxlib/definitions.py index aaceef492f9..f15247eef62 100644 --- a/yt/frontends/boxlib/definitions.py +++ b/yt/frontends/boxlib/definitions.py @@ -44,4 +44,3 @@ "comoving_OmM": "CosmologyOmegaMatterNow", "comoving_h": "CosmologyHubbleConstantNow" } - diff --git a/yt/frontends/boxlib/fields.py b/yt/frontends/boxlib/fields.py index 9ad5446708f..46027eb2d81 100644 --- a/yt/frontends/boxlib/fields.py +++ b/yt/frontends/boxlib/fields.py @@ -1,13 +1,11 @@ -import string import re +import string + import numpy as np -from yt.utilities.physical_constants import \ - boltzmann_constant_cgs, amu_cgs, c -from yt.fields.field_info_container import \ - FieldInfoContainer +from yt.fields.field_info_container import FieldInfoContainer from yt.units import YTQuantity - +from yt.utilities.physical_constants import amu_cgs, boltzmann_constant_cgs, c rho_units = "code_mass / code_length**3" mom_units = "code_mass / (code_time * code_length**2)" diff --git a/yt/frontends/boxlib/io.py b/yt/frontends/boxlib/io.py index d733bb259d1..9046ef16311 100644 --- a/yt/frontends/boxlib/io.py +++ b/yt/frontends/boxlib/io.py @@ -1,12 +1,13 @@ import os -import numpy as np from collections import defaultdict -from yt.utilities.io_handler import \ - BaseIOHandler -from yt.funcs import mylog +import numpy as np + from yt.frontends.chombo.io import parse_orion_sinks +from yt.funcs import mylog from yt.geometry.selection_routines import GridSelector +from yt.utilities.io_handler import BaseIOHandler + def _remove_raw(all_fields, raw_fields): centered_fields = set(all_fields) diff --git a/yt/frontends/boxlib/tests/test_outputs.py b/yt/frontends/boxlib/tests/test_outputs.py index d1fdcef1cff..48fcd1a8b14 100644 --- a/yt/frontends/boxlib/tests/test_outputs.py +++ b/yt/frontends/boxlib/tests/test_outputs.py @@ -1,19 +1,19 @@ -from yt.testing import \ - assert_equal, \ - requires_file, \ - units_override_check -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - small_patch_amr, \ - data_dir_load, \ - GridValuesTest -from yt.frontends.boxlib.api import \ - OrionDataset, \ - NyxDataset, \ - WarpXDataset, \ - CastroDataset, \ - MaestroDataset -import numpy as np +import numpy as np + +from yt.frontends.boxlib.api import ( + CastroDataset, + MaestroDataset, + NyxDataset, + OrionDataset, + WarpXDataset, +) +from yt.testing import assert_equal, requires_file, units_override_check +from yt.utilities.answer_testing.framework import ( + GridValuesTest, + data_dir_load, + requires_ds, + small_patch_amr, +) # We don't do anything needing ghost zone generation right now, because these # are non-periodic datasets. diff --git a/yt/frontends/chombo/api.py b/yt/frontends/chombo/api.py index 0edc141c133..4c4c514d630 100644 --- a/yt/frontends/chombo/api.py +++ b/yt/frontends/chombo/api.py @@ -1,23 +1,21 @@ -from .data_structures import \ - ChomboGrid, \ - ChomboHierarchy, \ - ChomboDataset, \ - Orion2Hierarchy, \ - Orion2Dataset, \ - ChomboPICHierarchy, \ - ChomboPICDataset, \ - PlutoHierarchy, \ - PlutoDataset - -from .fields import \ - ChomboFieldInfo, \ - Orion2FieldInfo, \ - ChomboPICFieldInfo1D, \ - ChomboPICFieldInfo2D, \ - ChomboPICFieldInfo3D, \ - PlutoFieldInfo - -from .io import \ - IOHandlerChomboHDF5 - from . import tests +from .data_structures import ( + ChomboDataset, + ChomboGrid, + ChomboHierarchy, + ChomboPICDataset, + ChomboPICHierarchy, + Orion2Dataset, + Orion2Hierarchy, + PlutoDataset, + PlutoHierarchy, +) +from .fields import ( + ChomboFieldInfo, + ChomboPICFieldInfo1D, + ChomboPICFieldInfo2D, + ChomboPICFieldInfo3D, + Orion2FieldInfo, + PlutoFieldInfo, +) +from .io import IOHandlerChomboHDF5 diff --git a/yt/frontends/chombo/data_structures.py b/yt/frontends/chombo/data_structures.py index d7b890f538e..0d5d6e151df 100644 --- a/yt/frontends/chombo/data_structures.py +++ b/yt/frontends/chombo/data_structures.py @@ -1,29 +1,26 @@ -from yt.utilities.on_demand_imports import _h5py as h5py -import re import os +import re import weakref + import numpy as np -from yt.funcs import \ - mylog, \ - setdefaultattr -from yt.data_objects.grid_patch import \ - AMRGridPatch -from yt.geometry.grid_geometry_handler import \ - GridIndex -from yt.data_objects.static_output import \ - Dataset -from yt.utilities.file_handler import \ - HDF5FileHandler, \ - warn_h5py -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - parallel_root_only -from yt.utilities.lib.misc_utilities import \ - get_box_grids_level - -from .fields import ChomboFieldInfo, Orion2FieldInfo, \ - ChomboPICFieldInfo1D, ChomboPICFieldInfo2D, ChomboPICFieldInfo3D, \ - PlutoFieldInfo +from yt.data_objects.grid_patch import AMRGridPatch +from yt.data_objects.static_output import Dataset +from yt.funcs import mylog, setdefaultattr +from yt.geometry.grid_geometry_handler import GridIndex +from yt.utilities.file_handler import HDF5FileHandler, warn_h5py +from yt.utilities.lib.misc_utilities import get_box_grids_level +from yt.utilities.on_demand_imports import _h5py as h5py +from yt.utilities.parallel_tools.parallel_analysis_interface import parallel_root_only + +from .fields import ( + ChomboFieldInfo, + ChomboPICFieldInfo1D, + ChomboPICFieldInfo2D, + ChomboPICFieldInfo3D, + Orion2FieldInfo, + PlutoFieldInfo, +) def is_chombo_hdf5(fn): diff --git a/yt/frontends/chombo/definitions.py b/yt/frontends/chombo/definitions.py index 8b137891791..e69de29bb2d 100644 --- a/yt/frontends/chombo/definitions.py +++ b/yt/frontends/chombo/definitions.py @@ -1 +0,0 @@ - diff --git a/yt/frontends/chombo/fields.py b/yt/frontends/chombo/fields.py index fadf3b72e96..e961803cd5f 100644 --- a/yt/frontends/chombo/fields.py +++ b/yt/frontends/chombo/fields.py @@ -1,11 +1,12 @@ import numpy as np -from yt.units.unit_object import Unit -from yt.fields.field_info_container import \ - FieldInfoContainer, \ - particle_deposition_functions, \ - particle_vector_functions, \ - standard_particle_fields +from yt.fields.field_info_container import ( + FieldInfoContainer, + particle_deposition_functions, + particle_vector_functions, + standard_particle_fields, +) +from yt.units.unit_object import Unit from yt.utilities.exceptions import YTFieldNotFound rho_units = "code_mass / code_length**3" diff --git a/yt/frontends/chombo/io.py b/yt/frontends/chombo/io.py index f4625f14c8c..244109264fc 100644 --- a/yt/frontends/chombo/io.py +++ b/yt/frontends/chombo/io.py @@ -1,11 +1,10 @@ import re + import numpy as np -from yt.geometry.selection_routines import \ - GridSelector -from yt.utilities.logger import \ - ytLogger as mylog -from yt.utilities.io_handler import \ - BaseIOHandler + +from yt.geometry.selection_routines import GridSelector +from yt.utilities.io_handler import BaseIOHandler +from yt.utilities.logger import ytLogger as mylog class IOHandlerChomboHDF5(BaseIOHandler): diff --git a/yt/frontends/chombo/tests/test_outputs.py b/yt/frontends/chombo/tests/test_outputs.py index da8e4353b85..6d292de178b 100644 --- a/yt/frontends/chombo/tests/test_outputs.py +++ b/yt/frontends/chombo/tests/test_outputs.py @@ -1,15 +1,10 @@ -from yt.testing import \ - requires_file, \ - assert_equal, \ - units_override_check -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - small_patch_amr, \ - data_dir_load -from yt.frontends.chombo.api import \ - ChomboDataset, \ - Orion2Dataset, \ - PlutoDataset +from yt.frontends.chombo.api import ChomboDataset, Orion2Dataset, PlutoDataset +from yt.testing import assert_equal, requires_file, units_override_check +from yt.utilities.answer_testing.framework import ( + data_dir_load, + requires_ds, + small_patch_amr, +) _fields = ("density", "velocity_magnitude", # "velocity_divergence", "magnetic_field_x") diff --git a/yt/frontends/eagle/api.py b/yt/frontends/eagle/api.py index e9ee31bb242..8490cc27028 100644 --- a/yt/frontends/eagle/api.py +++ b/yt/frontends/eagle/api.py @@ -1,11 +1,4 @@ -from .data_structures import \ - EagleDataset, \ - EagleNetworkDataset - -from .fields import \ - EagleNetworkFieldInfo - -from .io import \ - IOHandlerEagleNetwork - from . import tests +from .data_structures import EagleDataset, EagleNetworkDataset +from .fields import EagleNetworkFieldInfo +from .io import IOHandlerEagleNetwork diff --git a/yt/frontends/eagle/data_structures.py b/yt/frontends/eagle/data_structures.py index 2577bdd636f..e3848196629 100644 --- a/yt/frontends/eagle/data_structures.py +++ b/yt/frontends/eagle/data_structures.py @@ -1,14 +1,12 @@ -from yt.utilities.on_demand_imports import _h5py as h5py import numpy as np -from yt.frontends.gadget.data_structures import \ - GadgetHDF5Dataset -from yt.frontends.owls.fields import \ - OWLSFieldInfo import yt.units +from yt.frontends.gadget.data_structures import GadgetHDF5Dataset +from yt.frontends.owls.fields import OWLSFieldInfo +from yt.utilities.on_demand_imports import _h5py as h5py + +from .fields import EagleNetworkFieldInfo -from .fields import \ - EagleNetworkFieldInfo class EagleDataset(GadgetHDF5Dataset): _particle_mass_name = "Mass" diff --git a/yt/frontends/eagle/fields.py b/yt/frontends/eagle/fields.py index 0b11a4fad5d..c55964bffbe 100644 --- a/yt/frontends/eagle/fields.py +++ b/yt/frontends/eagle/fields.py @@ -1,10 +1,8 @@ -from yt.frontends.owls.fields import \ - OWLSFieldInfo +from yt.frontends.eagle.definitions import eaglenetwork_ion_lookup +from yt.frontends.owls.fields import OWLSFieldInfo from yt.units.yt_array import YTQuantity from yt.utilities.periodic_table import periodic_table -from yt.frontends.eagle.definitions import \ - eaglenetwork_ion_lookup class EagleNetworkFieldInfo(OWLSFieldInfo): diff --git a/yt/frontends/eagle/io.py b/yt/frontends/eagle/io.py index 1ed10ddcb63..757692bec30 100644 --- a/yt/frontends/eagle/io.py +++ b/yt/frontends/eagle/io.py @@ -1,5 +1,5 @@ -from yt.frontends.owls.io import \ - IOHandlerOWLS +from yt.frontends.owls.io import IOHandlerOWLS + class IOHandlerEagleNetwork(IOHandlerOWLS): _dataset_type = "eagle_network" diff --git a/yt/frontends/eagle/tests/test_outputs.py b/yt/frontends/eagle/tests/test_outputs.py index bdf1992cb15..f80aa0264a4 100644 --- a/yt/frontends/eagle/tests/test_outputs.py +++ b/yt/frontends/eagle/tests/test_outputs.py @@ -1,9 +1,6 @@ -from yt.testing import \ - requires_file, \ - ParticleSelectionComparison -from yt.utilities.answer_testing.framework import \ - data_dir_load from yt.frontends.eagle.api import EagleDataset +from yt.testing import ParticleSelectionComparison, requires_file +from yt.utilities.answer_testing.framework import data_dir_load s28 = "snapshot_028_z000p000/snap_028_z000p000.0.hdf5" @requires_file(s28) diff --git a/yt/frontends/enzo/answer_testing_support.py b/yt/frontends/enzo/answer_testing_support.py index 9dbc844f027..4f594bcc6aa 100644 --- a/yt/frontends/enzo/answer_testing_support.py +++ b/yt/frontends/enzo/answer_testing_support.py @@ -1,18 +1,19 @@ -import numpy as np import os - from functools import wraps +import numpy as np + from yt.config import ytcfg from yt.convenience import load from yt.testing import assert_allclose -from yt.utilities.answer_testing.framework import \ - AnswerTestingTest, \ - can_run_ds, \ - FieldValuesTest, \ - GridValuesTest, \ - ProjectionValuesTest, \ - temp_cwd +from yt.utilities.answer_testing.framework import ( + AnswerTestingTest, + FieldValuesTest, + GridValuesTest, + ProjectionValuesTest, + can_run_ds, + temp_cwd, +) class AssertWrapper: diff --git a/yt/frontends/enzo/api.py b/yt/frontends/enzo/api.py index b1349d43faa..ab24e3d54a8 100644 --- a/yt/frontends/enzo/api.py +++ b/yt/frontends/enzo/api.py @@ -1,24 +1,21 @@ -from .data_structures import \ - EnzoGrid, \ - EnzoGridInMemory, \ - EnzoHierarchy, \ - EnzoHierarchyInMemory, \ - EnzoHierarchy1D, \ - EnzoHierarchy2D, \ - EnzoDataset, \ - EnzoDatasetInMemory - -from .simulation_handling import \ - EnzoSimulation +from . import tests +from .data_structures import ( + EnzoDataset, + EnzoDatasetInMemory, + EnzoGrid, + EnzoGridInMemory, + EnzoHierarchy, + EnzoHierarchy1D, + EnzoHierarchy2D, + EnzoHierarchyInMemory, +) +from .fields import EnzoFieldInfo +from .io import ( + IOHandlerInMemory, + IOHandlerPacked1D, + IOHandlerPacked2D, + IOHandlerPackedHDF5, +) +from .simulation_handling import EnzoSimulation -from .fields import \ - EnzoFieldInfo add_enzo_field = EnzoFieldInfo.add_field - -from .io import \ - IOHandlerPackedHDF5, \ - IOHandlerInMemory, \ - IOHandlerPacked2D, \ - IOHandlerPacked1D - -from . import tests diff --git a/yt/frontends/enzo/data_structures.py b/yt/frontends/enzo/data_structures.py index 505d6e0fb69..e108d5d88f1 100644 --- a/yt/frontends/enzo/data_structures.py +++ b/yt/frontends/enzo/data_structures.py @@ -1,37 +1,24 @@ -from yt.utilities.on_demand_imports import _h5py as h5py import io -import weakref -import numpy as np import os +import re import string import time -import re - -from yt.utilities.on_demand_imports import \ - _libconf as libconf +import weakref from collections import defaultdict -from yt.frontends.enzo.misc import \ - cosmology_get_units -from yt.funcs import \ - ensure_list, \ - ensure_tuple, \ - get_pbar, \ - setdefaultattr -from yt.data_objects.grid_patch import \ - AMRGridPatch -from yt.geometry.grid_geometry_handler import \ - GridIndex -from yt.geometry.geometry_handler import \ - YTDataChunk -from yt.data_objects.static_output import \ - Dataset -from yt.fields.field_info_container import \ - NullFunc +import numpy as np + +from yt.data_objects.grid_patch import AMRGridPatch +from yt.data_objects.static_output import Dataset +from yt.fields.field_info_container import NullFunc +from yt.frontends.enzo.misc import cosmology_get_units +from yt.funcs import ensure_list, ensure_tuple, get_pbar, setdefaultattr +from yt.geometry.geometry_handler import YTDataChunk +from yt.geometry.grid_geometry_handler import GridIndex from yt.utilities.logger import ytLogger as mylog +from yt.utilities.on_demand_imports import _h5py as h5py, _libconf as libconf -from .fields import \ - EnzoFieldInfo +from .fields import EnzoFieldInfo class EnzoGrid(AMRGridPatch): diff --git a/yt/frontends/enzo/fields.py b/yt/frontends/enzo/fields.py index 1fc35263864..54bb0db36f1 100644 --- a/yt/frontends/enzo/fields.py +++ b/yt/frontends/enzo/fields.py @@ -1,9 +1,7 @@ import numpy as np -from yt.fields.field_info_container import \ - FieldInfoContainer -from yt.utilities.physical_constants import \ - me, \ - mp + +from yt.fields.field_info_container import FieldInfoContainer +from yt.utilities.physical_constants import me, mp b_units = "code_magnetic" e_units = "code_magnetic/c" diff --git a/yt/frontends/enzo/io.py b/yt/frontends/enzo/io.py index 04230028f6b..eae796f4178 100644 --- a/yt/frontends/enzo/io.py +++ b/yt/frontends/enzo/io.py @@ -1,10 +1,9 @@ -from yt.utilities.io_handler import \ - BaseIOHandler -from yt.utilities.logger import ytLogger as mylog -from yt.utilities.on_demand_imports import _h5py as h5py -from yt.geometry.selection_routines import GridSelector import numpy as np +from yt.geometry.selection_routines import GridSelector +from yt.utilities.io_handler import BaseIOHandler +from yt.utilities.logger import ytLogger as mylog +from yt.utilities.on_demand_imports import _h5py as h5py _convert_mass = ("particle_mass","mass") diff --git a/yt/frontends/enzo/misc.py b/yt/frontends/enzo/misc.py index 9d45fdd98f2..08f2753ef33 100644 --- a/yt/frontends/enzo/misc.py +++ b/yt/frontends/enzo/misc.py @@ -1,11 +1,13 @@ import numpy as np -from yt.utilities.physical_ratios import \ - boltzmann_constant_erg_per_K, \ - cm_per_mpc, \ - mass_hydrogen_grams, \ - newton_cgs, \ - rho_crit_g_cm3_h2 +from yt.utilities.physical_ratios import ( + boltzmann_constant_erg_per_K, + cm_per_mpc, + mass_hydrogen_grams, + newton_cgs, + rho_crit_g_cm3_h2, +) + def cosmology_get_units(hubble_constant, omega_matter, box_size, initial_redshift, current_redshift): diff --git a/yt/frontends/enzo/simulation_handling.py b/yt/frontends/enzo/simulation_handling.py index 3e4f4d2c43d..f044e838767 100644 --- a/yt/frontends/enzo/simulation_handling.py +++ b/yt/frontends/enzo/simulation_handling.py @@ -1,30 +1,23 @@ -import numpy as np import glob import os -from unyt import \ - dimensions, \ - unyt_array -from unyt.unit_registry import \ - UnitRegistry - -from yt.convenience import \ - load -from yt.funcs import \ - only_on_root -from yt.data_objects.time_series import \ - SimulationTimeSeries, DatasetSeries -from yt.utilities.cosmology import \ - Cosmology -from yt.utilities.exceptions import \ - InvalidSimulationTimeSeries, \ - MissingParameter, \ - NoStoppingCondition, \ - YTOutputNotIdentified -from yt.utilities.logger import ytLogger as \ - mylog -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - parallel_objects +import numpy as np +from unyt import dimensions, unyt_array +from unyt.unit_registry import UnitRegistry + +from yt.convenience import load +from yt.data_objects.time_series import DatasetSeries, SimulationTimeSeries +from yt.funcs import only_on_root +from yt.utilities.cosmology import Cosmology +from yt.utilities.exceptions import ( + InvalidSimulationTimeSeries, + MissingParameter, + NoStoppingCondition, + YTOutputNotIdentified, +) +from yt.utilities.logger import ytLogger as mylog +from yt.utilities.parallel_tools.parallel_analysis_interface import parallel_objects + class EnzoSimulation(SimulationTimeSeries): r""" diff --git a/yt/frontends/enzo/tests/test_outputs.py b/yt/frontends/enzo/tests/test_outputs.py index affe08d2b8a..f9653492593 100644 --- a/yt/frontends/enzo/tests/test_outputs.py +++ b/yt/frontends/enzo/tests/test_outputs.py @@ -1,21 +1,22 @@ import numpy as np -from yt.testing import \ - assert_almost_equal, \ - assert_equal, \ - requires_file, \ - units_override_check, \ - assert_array_equal, \ - assert_allclose_units -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - small_patch_amr, \ - big_patch_amr, \ - data_dir_load -from yt.visualization.plot_window import \ - SlicePlot from yt.frontends.enzo.api import EnzoDataset from yt.frontends.enzo.fields import NODAL_FLAGS +from yt.testing import ( + assert_allclose_units, + assert_almost_equal, + assert_array_equal, + assert_equal, + requires_file, + units_override_check, +) +from yt.utilities.answer_testing.framework import ( + big_patch_amr, + data_dir_load, + requires_ds, + small_patch_amr, +) +from yt.visualization.plot_window import SlicePlot _fields = ("temperature", "density", "velocity_magnitude", "velocity_divergence") diff --git a/yt/frontends/enzo_p/api.py b/yt/frontends/enzo_p/api.py index 76010d668d2..a5fdbfc873c 100644 --- a/yt/frontends/enzo_p/api.py +++ b/yt/frontends/enzo_p/api.py @@ -1,13 +1,6 @@ -from .data_structures import \ - EnzoPGrid, \ - EnzoPHierarchy, \ - EnzoPDataset +from . import tests +from .data_structures import EnzoPDataset, EnzoPGrid, EnzoPHierarchy +from .fields import EnzoPFieldInfo +from .io import EnzoPIOHandler -from .fields import \ - EnzoPFieldInfo add_enzop_field = EnzoPFieldInfo.add_field - -from .io import \ - EnzoPIOHandler - -from . import tests diff --git a/yt/frontends/enzo_p/data_structures.py b/yt/frontends/enzo_p/data_structures.py index 53c30ca4e87..fe42d284d4f 100644 --- a/yt/frontends/enzo_p/data_structures.py +++ b/yt/frontends/enzo_p/data_structures.py @@ -1,40 +1,28 @@ -from yt.utilities.on_demand_imports import \ - _h5py as h5py -from yt.utilities.on_demand_imports import \ - _libconf as libconf import io as io -import numpy as np import os import warnings -from yt.data_objects.grid_patch import \ - AMRGridPatch -from yt.data_objects.static_output import \ - Dataset -from yt.fields.field_info_container import \ - NullFunc -from yt.frontends.enzo.misc import \ - cosmology_get_units -from yt.funcs import \ - ensure_tuple, \ - get_pbar, \ - setdefaultattr -from yt.geometry.grid_geometry_handler import \ - GridIndex -from yt.utilities.cosmology import \ - Cosmology -from yt.utilities.logger import \ - ytLogger as mylog - -from yt.frontends.enzo_p.fields import \ - EnzoPFieldInfo -from yt.frontends.enzo_p.misc import \ - get_block_info, \ - get_child_index, \ - get_root_blocks, \ - get_root_block_id, \ - nested_dict_get, \ - is_parent +import numpy as np + +from yt.data_objects.grid_patch import AMRGridPatch +from yt.data_objects.static_output import Dataset +from yt.fields.field_info_container import NullFunc +from yt.frontends.enzo.misc import cosmology_get_units +from yt.frontends.enzo_p.fields import EnzoPFieldInfo +from yt.frontends.enzo_p.misc import ( + get_block_info, + get_child_index, + get_root_block_id, + get_root_blocks, + is_parent, + nested_dict_get, +) +from yt.funcs import ensure_tuple, get_pbar, setdefaultattr +from yt.geometry.grid_geometry_handler import GridIndex +from yt.utilities.cosmology import Cosmology +from yt.utilities.logger import ytLogger as mylog +from yt.utilities.on_demand_imports import _h5py as h5py, _libconf as libconf + class EnzoPGrid(AMRGridPatch): """ diff --git a/yt/frontends/enzo_p/fields.py b/yt/frontends/enzo_p/fields.py index 4b60830058a..57b18fceada 100644 --- a/yt/frontends/enzo_p/fields.py +++ b/yt/frontends/enzo_p/fields.py @@ -1,9 +1,6 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer -from yt.fields.particle_fields import \ - add_union_field -from yt.frontends.enzo_p.misc import \ - nested_dict_get +from yt.fields.field_info_container import FieldInfoContainer +from yt.fields.particle_fields import add_union_field +from yt.frontends.enzo_p.misc import nested_dict_get rho_units = "code_mass / code_length**3" vel_units = "code_velocity" diff --git a/yt/frontends/enzo_p/io.py b/yt/frontends/enzo_p/io.py index ec190190bb2..def63ff22c5 100644 --- a/yt/frontends/enzo_p/io.py +++ b/yt/frontends/enzo_p/io.py @@ -1,10 +1,9 @@ -from yt.utilities.exceptions import \ - YTException -from yt.utilities.io_handler import \ - BaseIOHandler -from yt.utilities.on_demand_imports import _h5py as h5py import numpy as np +from yt.utilities.exceptions import YTException +from yt.utilities.io_handler import BaseIOHandler +from yt.utilities.on_demand_imports import _h5py as h5py + _particle_position_names = {} class EnzoPIOHandler(BaseIOHandler): diff --git a/yt/frontends/enzo_p/misc.py b/yt/frontends/enzo_p/misc.py index 3392f4520ab..c2880bd2c10 100644 --- a/yt/frontends/enzo_p/misc.py +++ b/yt/frontends/enzo_p/misc.py @@ -1,7 +1,7 @@ import numpy as np -from yt.funcs import \ - ensure_tuple +from yt.funcs import ensure_tuple + def bdecode(block): """ diff --git a/yt/frontends/enzo_p/tests/test_misc.py b/yt/frontends/enzo_p/tests/test_misc.py index da6ec704f52..b3276405dcc 100644 --- a/yt/frontends/enzo_p/tests/test_misc.py +++ b/yt/frontends/enzo_p/tests/test_misc.py @@ -1,11 +1,13 @@ import numpy as np -from yt.frontends.enzo_p.misc import \ - get_block_info, \ - get_root_blocks, \ - get_root_block_id, \ - is_parent, \ - nested_dict_get +from yt.frontends.enzo_p.misc import ( + get_block_info, + get_root_block_id, + get_root_blocks, + is_parent, + nested_dict_get, +) + def get_random_block_string(max_n=64, random_state=None, level=None): if max_n == 1: diff --git a/yt/frontends/enzo_p/tests/test_outputs.py b/yt/frontends/enzo_p/tests/test_outputs.py index f9210c4fef3..370b77a0a6e 100644 --- a/yt/frontends/enzo_p/tests/test_outputs.py +++ b/yt/frontends/enzo_p/tests/test_outputs.py @@ -1,19 +1,15 @@ import numpy as np -from yt.utilities.on_demand_imports import \ - _h5py as h5py - -from yt.testing import \ - assert_equal, \ - requires_file, \ - assert_array_equal -from yt.utilities.answer_testing.framework import \ - create_obj, \ - data_dir_load, \ - requires_ds, \ - PixelizedProjectionValuesTest, \ - FieldValuesTest from yt.frontends.enzo_p.api import EnzoPDataset +from yt.testing import assert_array_equal, assert_equal, requires_file +from yt.utilities.answer_testing.framework import ( + FieldValuesTest, + PixelizedProjectionValuesTest, + create_obj, + data_dir_load, + requires_ds, +) +from yt.utilities.on_demand_imports import _h5py as h5py _fields = ("density", "total_energy", "velocity_x", "velocity_y") diff --git a/yt/frontends/exodus_ii/__init__.py b/yt/frontends/exodus_ii/__init__.py index aabf7b36d63..8e72fd8199b 100644 --- a/yt/frontends/exodus_ii/__init__.py +++ b/yt/frontends/exodus_ii/__init__.py @@ -4,4 +4,3 @@ """ - diff --git a/yt/frontends/exodus_ii/api.py b/yt/frontends/exodus_ii/api.py index ae0693f14ee..fcac8ddbad0 100644 --- a/yt/frontends/exodus_ii/api.py +++ b/yt/frontends/exodus_ii/api.py @@ -1,15 +1,9 @@ -from .data_structures import \ - ExodusIIUnstructuredMesh, \ - ExodusIIUnstructuredIndex, \ - ExodusIIDataset - -from .simulation_handling import \ - ExodusIISimulation - -from .fields import \ - ExodusIIFieldInfo - -from .io import \ - IOHandlerExodusII - from . import tests +from .data_structures import ( + ExodusIIDataset, + ExodusIIUnstructuredIndex, + ExodusIIUnstructuredMesh, +) +from .fields import ExodusIIFieldInfo +from .io import IOHandlerExodusII +from .simulation_handling import ExodusIISimulation diff --git a/yt/frontends/exodus_ii/data_structures.py b/yt/frontends/exodus_ii/data_structures.py index d7118fec595..4b2ba2b6f23 100644 --- a/yt/frontends/exodus_ii/data_structures.py +++ b/yt/frontends/exodus_ii/data_structures.py @@ -1,24 +1,15 @@ import numpy as np -from yt.funcs import \ - setdefaultattr -from yt.geometry.unstructured_mesh_handler import \ - UnstructuredIndex -from yt.data_objects.unstructured_mesh import \ - UnstructuredMesh -from yt.data_objects.static_output import \ - Dataset +from yt.data_objects.static_output import Dataset from yt.data_objects.unions import MeshUnion -from yt.utilities.file_handler import \ - NetCDF4FileHandler, \ - warn_netcdf +from yt.data_objects.unstructured_mesh import UnstructuredMesh +from yt.funcs import setdefaultattr +from yt.geometry.unstructured_mesh_handler import UnstructuredIndex +from yt.utilities.file_handler import NetCDF4FileHandler, warn_netcdf from yt.utilities.logger import ytLogger as mylog -from .fields import \ - ExodusIIFieldInfo -from .util import \ - load_info_records, \ - sanitize_string, \ - get_num_pseudo_dims + +from .fields import ExodusIIFieldInfo +from .util import get_num_pseudo_dims, load_info_records, sanitize_string class ExodusIIUnstructuredMesh(UnstructuredMesh): diff --git a/yt/frontends/exodus_ii/fields.py b/yt/frontends/exodus_ii/fields.py index 2797db48d06..a6a0b21e892 100644 --- a/yt/frontends/exodus_ii/fields.py +++ b/yt/frontends/exodus_ii/fields.py @@ -1,5 +1,4 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer +from yt.fields.field_info_container import FieldInfoContainer # We need to specify which fields we might have in our dataset. The field info # container subclass here will define which fields it knows about. There are diff --git a/yt/frontends/exodus_ii/io.py b/yt/frontends/exodus_ii/io.py index ffda8d31aa5..d26b735570b 100644 --- a/yt/frontends/exodus_ii/io.py +++ b/yt/frontends/exodus_ii/io.py @@ -1,8 +1,7 @@ import numpy as np -from yt.utilities.io_handler import \ - BaseIOHandler -from yt.utilities.file_handler import \ - NetCDF4FileHandler + +from yt.utilities.file_handler import NetCDF4FileHandler +from yt.utilities.io_handler import BaseIOHandler class IOHandlerExodusII(BaseIOHandler): diff --git a/yt/frontends/exodus_ii/simulation_handling.py b/yt/frontends/exodus_ii/simulation_handling.py index f8668290eb8..7a292f96478 100644 --- a/yt/frontends/exodus_ii/simulation_handling.py +++ b/yt/frontends/exodus_ii/simulation_handling.py @@ -1,19 +1,12 @@ import glob import os -from yt.convenience import \ - load -from yt.funcs import \ - only_on_root -from yt.utilities.exceptions import \ - YTOutputNotIdentified -from yt.utilities.logger import ytLogger as \ - mylog -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - parallel_objects -from yt.data_objects.time_series import \ - DatasetSeries, \ - RegisteredSimulationTimeSeries +from yt.convenience import load +from yt.data_objects.time_series import DatasetSeries, RegisteredSimulationTimeSeries +from yt.funcs import only_on_root +from yt.utilities.exceptions import YTOutputNotIdentified +from yt.utilities.logger import ytLogger as mylog +from yt.utilities.parallel_tools.parallel_analysis_interface import parallel_objects class ExodusIISimulation(DatasetSeries, metaclass = RegisteredSimulationTimeSeries): diff --git a/yt/frontends/exodus_ii/tests/test_outputs.py b/yt/frontends/exodus_ii/tests/test_outputs.py index 08504c217cb..21d74fbd277 100644 --- a/yt/frontends/exodus_ii/tests/test_outputs.py +++ b/yt/frontends/exodus_ii/tests/test_outputs.py @@ -1,12 +1,9 @@ -from yt.testing import \ - assert_equal, \ - assert_array_equal, \ - requires_file -from yt.utilities.answer_testing.framework import \ - data_dir_load, \ - requires_ds, \ - GenericArrayTest - +from yt.testing import assert_array_equal, assert_equal, requires_file +from yt.utilities.answer_testing.framework import ( + GenericArrayTest, + data_dir_load, + requires_ds, +) out = "ExodusII/out.e" diff --git a/yt/frontends/exodus_ii/util.py b/yt/frontends/exodus_ii/util.py index 07f3263b503..8880e814359 100644 --- a/yt/frontends/exodus_ii/util.py +++ b/yt/frontends/exodus_ii/util.py @@ -1,9 +1,10 @@ -import numpy as np -import sys +import re import string -from itertools import takewhile +import sys from collections import OrderedDict -import re +from itertools import takewhile + +import numpy as np _printable = set([ord(_) for _ in string.printable]) diff --git a/yt/frontends/fits/api.py b/yt/frontends/fits/api.py index 89013272a13..e5a5f7d9662 100644 --- a/yt/frontends/fits/api.py +++ b/yt/frontends/fits/api.py @@ -1,19 +1,13 @@ -from .data_structures import \ - FITSGrid, \ - FITSHierarchy, \ - FITSDataset, \ - SpectralCubeFITSHierarchy, \ - SpectralCubeFITSDataset, \ - SkyDataFITSDataset, \ - EventsFITSDataset - -from .fields import \ - FITSFieldInfo - -from .io import \ - IOHandlerFITS - -from .misc import \ - setup_counts_fields - from . import tests +from .data_structures import ( + EventsFITSDataset, + FITSDataset, + FITSGrid, + FITSHierarchy, + SkyDataFITSDataset, + SpectralCubeFITSDataset, + SpectralCubeFITSHierarchy, +) +from .fields import FITSFieldInfo +from .io import IOHandlerFITS +from .misc import setup_counts_fields diff --git a/yt/frontends/fits/data_structures.py b/yt/frontends/fits/data_structures.py index a2f0345343e..e879d75d33d 100644 --- a/yt/frontends/fits/data_structures.py +++ b/yt/frontends/fits/data_structures.py @@ -1,43 +1,29 @@ -import numpy as np -import numpy.core.defchararray as np_char import os import time import uuid -import weakref import warnings - +import weakref from collections import defaultdict +import numpy as np +import numpy.core.defchararray as np_char + from yt.config import ytcfg -from yt.funcs import \ - ensure_list, \ - mylog, \ - setdefaultattr -from yt.data_objects.grid_patch import \ - AMRGridPatch -from yt.geometry.grid_geometry_handler import \ - GridIndex -from yt.geometry.geometry_handler import \ - YTDataChunk -from yt.data_objects.static_output import \ - Dataset +from yt.data_objects.grid_patch import AMRGridPatch +from yt.data_objects.static_output import Dataset +from yt.funcs import ensure_list, issue_deprecation_warning, mylog, setdefaultattr +from yt.geometry.geometry_handler import YTDataChunk +from yt.geometry.grid_geometry_handler import GridIndex +from yt.units import dimensions +from yt.units.unit_lookup_table import default_unit_symbol_lut, unit_prefixes from yt.units.unit_object import UnitParseError from yt.units.yt_array import YTQuantity -from yt.utilities.file_handler import \ - FITSFileHandler -from yt.utilities.io_handler import \ - io_registry -from .fields import FITSFieldInfo, \ - WCSFITSFieldInfo, YTFITSFieldInfo -from yt.utilities.decompose import \ - decompose_array, get_psize -from yt.funcs import issue_deprecation_warning -from yt.units import dimensions -from yt.units.unit_lookup_table import \ - default_unit_symbol_lut, \ - unit_prefixes -from yt.utilities.on_demand_imports import \ - _astropy, NotAModule +from yt.utilities.decompose import decompose_array, get_psize +from yt.utilities.file_handler import FITSFileHandler +from yt.utilities.io_handler import io_registry +from yt.utilities.on_demand_imports import NotAModule, _astropy + +from .fields import FITSFieldInfo, WCSFITSFieldInfo, YTFITSFieldInfo lon_prefixes = ["X","RA","GLON","LINEAR"] lat_prefixes = ["Y","DEC","GLAT","LINEAR"] diff --git a/yt/frontends/fits/fields.py b/yt/frontends/fits/fields.py index 4e2e0980d2c..096e681f54c 100644 --- a/yt/frontends/fits/fields.py +++ b/yt/frontends/fits/fields.py @@ -1,5 +1,4 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer +from yt.fields.field_info_container import FieldInfoContainer class FITSFieldInfo(FieldInfoContainer): diff --git a/yt/frontends/fits/io.py b/yt/frontends/fits/io.py index d93fe1ae3f9..b0035c2951a 100644 --- a/yt/frontends/fits/io.py +++ b/yt/frontends/fits/io.py @@ -1,9 +1,9 @@ import numpy as np -from yt.utilities.io_handler import \ - BaseIOHandler +from yt.utilities.io_handler import BaseIOHandler from yt.utilities.logger import ytLogger as mylog + class IOHandlerFITS(BaseIOHandler): _particle_reader = False _dataset_type = "fits" diff --git a/yt/frontends/fits/misc.py b/yt/frontends/fits/misc.py index c6ac7f28ef9..ee8387fcbd6 100644 --- a/yt/frontends/fits/misc.py +++ b/yt/frontends/fits/misc.py @@ -1,12 +1,14 @@ -import numpy as np import base64 +import os +from io import BytesIO + +import numpy as np + from yt.fields.derived_field import ValidateSpatial -from yt.funcs import mylog, issue_deprecation_warning +from yt.funcs import issue_deprecation_warning, mylog +from yt.units.yt_array import YTArray, YTQuantity from yt.utilities.on_demand_imports import _astropy -from yt.units.yt_array import YTQuantity, YTArray -from io import BytesIO -import os def _make_counts(emin, emax): def _counts(field, data): diff --git a/yt/frontends/fits/tests/test_outputs.py b/yt/frontends/fits/tests/test_outputs.py index 6563b0fefe5..364f75f8c97 100644 --- a/yt/frontends/fits/tests/test_outputs.py +++ b/yt/frontends/fits/tests/test_outputs.py @@ -1,15 +1,16 @@ -from yt.testing import \ - assert_equal, \ - requires_file, \ - units_override_check -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - small_patch_amr, \ - data_dir_load -from ..data_structures import FITSDataset, \ - SpectralCubeFITSDataset, \ - SkyDataFITSDataset, \ - EventsFITSDataset +from yt.testing import assert_equal, requires_file, units_override_check +from yt.utilities.answer_testing.framework import ( + data_dir_load, + requires_ds, + small_patch_amr, +) + +from ..data_structures import ( + EventsFITSDataset, + FITSDataset, + SkyDataFITSDataset, + SpectralCubeFITSDataset, +) _fields_grs = ("temperature",) @@ -79,4 +80,3 @@ def test_EventsFITSDataset(): @requires_file(A2052) def test_SkyDataFITSDataset(): assert isinstance(data_dir_load(A2052), SkyDataFITSDataset) - diff --git a/yt/frontends/flash/__init__.py b/yt/frontends/flash/__init__.py index 40d9d41e9d6..df0a487c265 100644 --- a/yt/frontends/flash/__init__.py +++ b/yt/frontends/flash/__init__.py @@ -4,4 +4,3 @@ """ - diff --git a/yt/frontends/flash/api.py b/yt/frontends/flash/api.py index dacd64a284f..39f570487cd 100644 --- a/yt/frontends/flash/api.py +++ b/yt/frontends/flash/api.py @@ -1,14 +1,9 @@ -from .data_structures import \ - FLASHGrid, \ - FLASHHierarchy, \ - FLASHDataset, \ - FLASHParticleDataset - -from .fields import \ - FLASHFieldInfo - -from .io import \ - IOHandlerFLASH, \ - IOHandlerFLASHParticle - from . import tests +from .data_structures import ( + FLASHDataset, + FLASHGrid, + FLASHHierarchy, + FLASHParticleDataset, +) +from .fields import FLASHFieldInfo +from .io import IOHandlerFLASH, IOHandlerFLASHParticle diff --git a/yt/frontends/flash/data_structures.py b/yt/frontends/flash/data_structures.py index 24167d94f8d..4f6f3592b12 100644 --- a/yt/frontends/flash/data_structures.py +++ b/yt/frontends/flash/data_structures.py @@ -1,24 +1,16 @@ import os -import numpy as np import weakref -from yt.data_objects.grid_patch import \ - AMRGridPatch -from yt.data_objects.static_output import \ - Dataset, \ - ParticleFile, \ - validate_index_order -from yt.funcs import \ - mylog, \ - setdefaultattr -from yt.geometry.grid_geometry_handler import \ - GridIndex -from yt.geometry.particle_geometry_handler import \ - ParticleIndex -from yt.utilities.file_handler import \ - HDF5FileHandler, \ - warn_h5py +import numpy as np + +from yt.data_objects.grid_patch import AMRGridPatch +from yt.data_objects.static_output import Dataset, ParticleFile, validate_index_order +from yt.funcs import mylog, setdefaultattr +from yt.geometry.grid_geometry_handler import GridIndex +from yt.geometry.particle_geometry_handler import ParticleIndex +from yt.utilities.file_handler import HDF5FileHandler, warn_h5py from yt.utilities.physical_ratios import cm_per_mpc + from .fields import FLASHFieldInfo diff --git a/yt/frontends/flash/fields.py b/yt/frontends/flash/fields.py index 906a1c54f57..457c063d3fb 100644 --- a/yt/frontends/flash/fields.py +++ b/yt/frontends/flash/fields.py @@ -1,5 +1,4 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer +from yt.fields.field_info_container import FieldInfoContainer # Common fields in FLASH: (Thanks to John ZuHone for this list) # diff --git a/yt/frontends/flash/io.py b/yt/frontends/flash/io.py index e74f5adae7c..06c44a11e1c 100644 --- a/yt/frontends/flash/io.py +++ b/yt/frontends/flash/io.py @@ -1,11 +1,11 @@ -import numpy as np from itertools import groupby -from yt.utilities.io_handler import \ - BaseIOHandler +import numpy as np + from yt.geometry.selection_routines import AlwaysSelector -from yt.utilities.lib.geometry_utils import \ - compute_morton +from yt.utilities.io_handler import BaseIOHandler +from yt.utilities.lib.geometry_utils import compute_morton + # http://stackoverflow.com/questions/2361945/detecting-consecutive-integers-in-a-list def particle_sequences(grids): diff --git a/yt/frontends/flash/tests/test_outputs.py b/yt/frontends/flash/tests/test_outputs.py index ebd288273d9..0a62ed824fc 100644 --- a/yt/frontends/flash/tests/test_outputs.py +++ b/yt/frontends/flash/tests/test_outputs.py @@ -1,18 +1,21 @@ -import numpy as np -from yt.testing import \ - assert_equal, \ - requires_file, \ - units_override_check, \ - ParticleSelectionComparison -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - small_patch_amr, \ - data_dir_load, \ - nbody_answer -from yt.frontends.flash.api import FLASHDataset, \ - FLASHParticleDataset from collections import OrderedDict +import numpy as np + +from yt.frontends.flash.api import FLASHDataset, FLASHParticleDataset +from yt.testing import ( + ParticleSelectionComparison, + assert_equal, + requires_file, + units_override_check, +) +from yt.utilities.answer_testing.framework import ( + data_dir_load, + nbody_answer, + requires_ds, + small_patch_amr, +) + _fields = ("temperature", "density", "velocity_magnitude") sloshing = "GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0300" diff --git a/yt/frontends/gadget/api.py b/yt/frontends/gadget/api.py index 599324ae9ec..73e614c89a9 100644 --- a/yt/frontends/gadget/api.py +++ b/yt/frontends/gadget/api.py @@ -1,13 +1,4 @@ -from .data_structures import \ - GadgetDataset, \ - GadgetHDF5Dataset, \ - GadgetFieldInfo - -from .io import \ - IOHandlerGadgetBinary, \ - IOHandlerGadgetHDF5 - -from .simulation_handling import \ - GadgetSimulation - from . import tests +from .data_structures import GadgetDataset, GadgetFieldInfo, GadgetHDF5Dataset +from .io import IOHandlerGadgetBinary, IOHandlerGadgetHDF5 +from .simulation_handling import GadgetSimulation diff --git a/yt/frontends/gadget/data_structures.py b/yt/frontends/gadget/data_structures.py index 41268f2a7e5..f9cf58bdba1 100644 --- a/yt/frontends/gadget/data_structures.py +++ b/yt/frontends/gadget/data_structures.py @@ -1,29 +1,26 @@ -from yt.funcs import only_on_root -from yt.utilities.on_demand_imports import _h5py as h5py -import numpy as np +import os import stat import struct -import os -from yt.data_objects.static_output import \ - ParticleFile -from yt.frontends.sph.data_structures import \ - SPHDataset, \ - SPHParticleIndex +import numpy as np + +from yt.data_objects.static_output import ParticleFile +from yt.frontends.sph.data_structures import SPHDataset, SPHParticleIndex +from yt.funcs import only_on_root from yt.utilities.chemical_formulas import default_mu -from yt.utilities.cosmology import \ - Cosmology +from yt.utilities.cosmology import Cosmology from yt.utilities.fortran_utils import read_record from yt.utilities.logger import ytLogger as mylog +from yt.utilities.on_demand_imports import _h5py as h5py -from .definitions import \ - gadget_header_specs, \ - gadget_field_specs, \ - gadget_ptype_specs, \ - SNAP_FORMAT_2_OFFSET +from .definitions import ( + SNAP_FORMAT_2_OFFSET, + gadget_field_specs, + gadget_header_specs, + gadget_ptype_specs, +) +from .fields import GadgetFieldInfo -from .fields import \ - GadgetFieldInfo def _fix_unit_ordering(unit): if isinstance(unit[0], str): diff --git a/yt/frontends/gadget/fields.py b/yt/frontends/gadget/fields.py index a07db06bcfe..f315179949d 100644 --- a/yt/frontends/gadget/fields.py +++ b/yt/frontends/gadget/fields.py @@ -1,7 +1,6 @@ from yt.frontends.sph.fields import SPHFieldInfo -from yt.utilities.physical_constants import mp, kb -from yt.utilities.physical_ratios import \ - _primordial_mass_fraction +from yt.utilities.physical_constants import kb, mp +from yt.utilities.physical_ratios import _primordial_mass_fraction class GadgetFieldInfo(SPHFieldInfo): diff --git a/yt/frontends/gadget/io.py b/yt/frontends/gadget/io.py index 2b2ac4da678..60aa68b3f21 100644 --- a/yt/frontends/gadget/io.py +++ b/yt/frontends/gadget/io.py @@ -1,14 +1,12 @@ -import numpy as np import os -from yt.frontends.sph.io import \ - IOHandlerSPH +import numpy as np + +from yt.frontends.sph.io import IOHandlerSPH from yt.utilities.logger import ytLogger as mylog from yt.utilities.on_demand_imports import _h5py as h5py -from .definitions import \ - gadget_hdf5_ptypes, \ - SNAP_FORMAT_2_OFFSET +from .definitions import SNAP_FORMAT_2_OFFSET, gadget_hdf5_ptypes class IOHandlerGadgetHDF5(IOHandlerSPH): diff --git a/yt/frontends/gadget/simulation_handling.py b/yt/frontends/gadget/simulation_handling.py index f2de24db014..38d8e9b5a73 100644 --- a/yt/frontends/gadget/simulation_handling.py +++ b/yt/frontends/gadget/simulation_handling.py @@ -1,31 +1,23 @@ -import numpy as np import glob import os -from unyt import \ - dimensions, \ - unyt_array -from unyt.unit_registry import \ - UnitRegistry - -from yt.convenience import \ - load -from yt.funcs import \ - only_on_root -from yt.data_objects.time_series import \ - SimulationTimeSeries, DatasetSeries -from yt.utilities.cosmology import \ - Cosmology -from yt.utilities.exceptions import \ - InvalidSimulationTimeSeries, \ - MissingParameter, \ - NoStoppingCondition -from yt.utilities.exceptions import \ - YTOutputNotIdentified -from yt.utilities.logger import ytLogger as \ - mylog -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - parallel_objects +import numpy as np +from unyt import dimensions, unyt_array +from unyt.unit_registry import UnitRegistry + +from yt.convenience import load +from yt.data_objects.time_series import DatasetSeries, SimulationTimeSeries +from yt.funcs import only_on_root +from yt.utilities.cosmology import Cosmology +from yt.utilities.exceptions import ( + InvalidSimulationTimeSeries, + MissingParameter, + NoStoppingCondition, + YTOutputNotIdentified, +) +from yt.utilities.logger import ytLogger as mylog +from yt.utilities.parallel_tools.parallel_analysis_interface import parallel_objects + class GadgetSimulation(SimulationTimeSeries): r""" diff --git a/yt/frontends/gadget/testing.py b/yt/frontends/gadget/testing.py index bfdd9429ad1..e8c9906a524 100644 --- a/yt/frontends/gadget/testing.py +++ b/yt/frontends/gadget/testing.py @@ -1,16 +1,9 @@ import numpy as np -from .definitions import ( - gadget_field_specs, - gadget_ptype_specs, -) -from .data_structures import ( - GadgetBinaryHeader, - GadgetDataset, -) +from .data_structures import GadgetBinaryHeader, GadgetDataset +from .definitions import gadget_field_specs, gadget_ptype_specs from .io import IOHandlerGadgetBinary - vector_fields = dict(IOHandlerGadgetBinary._vector_fields) block_ids = { diff --git a/yt/frontends/gadget/tests/test_outputs.py b/yt/frontends/gadget/tests/test_outputs.py index d9007800ed9..6da03780fa7 100644 --- a/yt/frontends/gadget/tests/test_outputs.py +++ b/yt/frontends/gadget/tests/test_outputs.py @@ -1,18 +1,14 @@ -from collections import OrderedDict -from itertools import product import os import shutil import tempfile +from collections import OrderedDict +from itertools import product import yt -from yt.testing import requires_file, \ - ParticleSelectionComparison -from yt.utilities.answer_testing.framework import \ - data_dir_load, \ - requires_ds, \ - sph_answer -from yt.frontends.gadget.api import GadgetHDF5Dataset, GadgetDataset +from yt.frontends.gadget.api import GadgetDataset, GadgetHDF5Dataset from yt.frontends.gadget.testing import fake_gadget_binary +from yt.testing import ParticleSelectionComparison, requires_file +from yt.utilities.answer_testing.framework import data_dir_load, requires_ds, sph_answer isothermal_h5 = "IsothermalCollapse/snap_505.hdf5" isothermal_bin = "IsothermalCollapse/snap_505" @@ -127,4 +123,3 @@ def test_bigendian_field_access(): ds = data_dir_load(BE_Gadget) data = ds.all_data() data['Halo', 'Velocities'] - diff --git a/yt/frontends/gadget_fof/__init__.py b/yt/frontends/gadget_fof/__init__.py index 04ebe5cd2d7..46e4642cc5d 100644 --- a/yt/frontends/gadget_fof/__init__.py +++ b/yt/frontends/gadget_fof/__init__.py @@ -5,4 +5,3 @@ """ - diff --git a/yt/frontends/gadget_fof/api.py b/yt/frontends/gadget_fof/api.py index 465953f811c..02e041fa7a4 100644 --- a/yt/frontends/gadget_fof/api.py +++ b/yt/frontends/gadget_fof/api.py @@ -1,17 +1,11 @@ -from .data_structures import \ - GadgetFOFParticleIndex, \ - GadgetFOFHDF5File, \ - GadgetFOFDataset, \ - GadgetFOFHaloParticleIndex, \ - GadgetFOFHaloDataset, \ - GagdetFOFHaloContainer - -from .io import \ - IOHandlerGadgetFOFHDF5, \ - IOHandlerGadgetFOFHaloHDF5 - -from .fields import \ - GadgetFOFFieldInfo, \ - GadgetFOFHaloFieldInfo - from . import tests +from .data_structures import ( + GadgetFOFDataset, + GadgetFOFHaloDataset, + GadgetFOFHaloParticleIndex, + GadgetFOFHDF5File, + GadgetFOFParticleIndex, + GagdetFOFHaloContainer, +) +from .fields import GadgetFOFFieldInfo, GadgetFOFHaloFieldInfo +from .io import IOHandlerGadgetFOFHaloHDF5, IOHandlerGadgetFOFHDF5 diff --git a/yt/frontends/gadget_fof/data_structures.py b/yt/frontends/gadget_fof/data_structures.py index 26c3ff4bbed..ff75954d647 100644 --- a/yt/frontends/gadget_fof/data_structures.py +++ b/yt/frontends/gadget_fof/data_structures.py @@ -1,30 +1,21 @@ +import os +import weakref from collections import defaultdict from functools import partial -from yt.utilities.on_demand_imports import _h5py as h5py + import numpy as np -import os -import weakref -from yt.data_objects.data_containers import \ - YTSelectionContainer -from yt.data_objects.static_output import \ - ParticleDataset -from yt.frontends.gadget.data_structures import \ - _fix_unit_ordering -from yt.frontends.gadget_fof.fields import \ - GadgetFOFFieldInfo, \ - GadgetFOFHaloFieldInfo -from yt.frontends.halo_catalog.data_structures import \ - HaloCatalogFile -from yt.funcs import \ - only_on_root, \ - setdefaultattr -from yt.geometry.particle_geometry_handler import \ - ParticleIndex -from yt.utilities.cosmology import \ - Cosmology -from yt.utilities.logger import ytLogger as \ - mylog +from yt.data_objects.data_containers import YTSelectionContainer +from yt.data_objects.static_output import ParticleDataset +from yt.frontends.gadget.data_structures import _fix_unit_ordering +from yt.frontends.gadget_fof.fields import GadgetFOFFieldInfo, GadgetFOFHaloFieldInfo +from yt.frontends.halo_catalog.data_structures import HaloCatalogFile +from yt.funcs import only_on_root, setdefaultattr +from yt.geometry.particle_geometry_handler import ParticleIndex +from yt.utilities.cosmology import Cosmology +from yt.utilities.logger import ytLogger as mylog +from yt.utilities.on_demand_imports import _h5py as h5py + class GadgetFOFParticleIndex(ParticleIndex): def _calculate_particle_count(self): diff --git a/yt/frontends/gadget_fof/fields.py b/yt/frontends/gadget_fof/fields.py index 9535a83e9e9..454f620f77b 100644 --- a/yt/frontends/gadget_fof/fields.py +++ b/yt/frontends/gadget_fof/fields.py @@ -1,5 +1,4 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer +from yt.fields.field_info_container import FieldInfoContainer m_units = "code_mass" p_units = "code_length" diff --git a/yt/frontends/gadget_fof/io.py b/yt/frontends/gadget_fof/io.py index 213ac253343..6f734212e14 100644 --- a/yt/frontends/gadget_fof/io.py +++ b/yt/frontends/gadget_fof/io.py @@ -1,14 +1,13 @@ from collections import defaultdict -from yt.utilities.on_demand_imports import _h5py as h5py + import numpy as np from yt.funcs import mylog -from yt.utilities.exceptions import \ - YTDomainOverflow -from yt.utilities.io_handler import \ - BaseIOHandler -from yt.utilities.lib.geometry_utils import \ - compute_morton +from yt.utilities.exceptions import YTDomainOverflow +from yt.utilities.io_handler import BaseIOHandler +from yt.utilities.lib.geometry_utils import compute_morton +from yt.utilities.on_demand_imports import _h5py as h5py + class IOHandlerGadgetFOFHDF5(BaseIOHandler): _dataset_type = "gadget_fof_hdf5" diff --git a/yt/frontends/gadget_fof/tests/test_outputs.py b/yt/frontends/gadget_fof/tests/test_outputs.py index 8d82072f068..0a9445ed369 100644 --- a/yt/frontends/gadget_fof/tests/test_outputs.py +++ b/yt/frontends/gadget_fof/tests/test_outputs.py @@ -1,16 +1,17 @@ import numpy as np -from yt.frontends.gadget_fof.api import \ - GadgetFOFDataset -from yt.testing import \ - requires_file, \ - assert_equal, \ - assert_array_equal, \ - ParticleSelectionComparison -from yt.utilities.answer_testing.framework import \ - FieldValuesTest, \ - requires_ds, \ - data_dir_load +from yt.frontends.gadget_fof.api import GadgetFOFDataset +from yt.testing import ( + ParticleSelectionComparison, + assert_array_equal, + assert_equal, + requires_file, +) +from yt.utilities.answer_testing.framework import ( + FieldValuesTest, + data_dir_load, + requires_ds, +) _fields = ("particle_position_x", "particle_position_y", "particle_position_z", "particle_velocity_x", diff --git a/yt/frontends/gamer/__init__.py b/yt/frontends/gamer/__init__.py index 6761e2147af..9686aa19db2 100644 --- a/yt/frontends/gamer/__init__.py +++ b/yt/frontends/gamer/__init__.py @@ -4,4 +4,3 @@ """ - diff --git a/yt/frontends/gamer/api.py b/yt/frontends/gamer/api.py index 8c0724c80e5..8ad4e50d410 100644 --- a/yt/frontends/gamer/api.py +++ b/yt/frontends/gamer/api.py @@ -1,13 +1,6 @@ -from .data_structures import \ - GAMERGrid, \ - GAMERHierarchy, \ - GAMERDataset - -from .fields import \ - GAMERFieldInfo - -from .io import \ - IOHandlerGAMER +from .data_structures import GAMERDataset, GAMERGrid, GAMERHierarchy +from .fields import GAMERFieldInfo +from .io import IOHandlerGAMER ### NOT SUPPORTED YET #from . import tests diff --git a/yt/frontends/gamer/data_structures.py b/yt/frontends/gamer/data_structures.py index e629b23f3e2..9d91a9c2cb3 100644 --- a/yt/frontends/gamer/data_structures.py +++ b/yt/frontends/gamer/data_structures.py @@ -1,21 +1,16 @@ import os -import numpy as np import weakref -from yt.funcs import \ - mylog, \ - setdefaultattr -from yt.data_objects.grid_patch import \ - AMRGridPatch -from yt.geometry.grid_geometry_handler import \ - GridIndex -from yt.data_objects.static_output import \ - Dataset -from yt.utilities.file_handler import \ - HDF5FileHandler -from .fields import GAMERFieldInfo -from .definitions import geometry_parameters +import numpy as np +from yt.data_objects.grid_patch import AMRGridPatch +from yt.data_objects.static_output import Dataset +from yt.funcs import mylog, setdefaultattr +from yt.geometry.grid_geometry_handler import GridIndex +from yt.utilities.file_handler import HDF5FileHandler + +from .definitions import geometry_parameters +from .fields import GAMERFieldInfo class GAMERGrid(AMRGridPatch): diff --git a/yt/frontends/gamer/fields.py b/yt/frontends/gamer/fields.py index be330231f08..9e33f5b5e51 100644 --- a/yt/frontends/gamer/fields.py +++ b/yt/frontends/gamer/fields.py @@ -1,5 +1,5 @@ from yt.fields.field_info_container import FieldInfoContainer -from yt.utilities.physical_constants import mh, kb +from yt.utilities.physical_constants import kb, mh b_units = "code_magnetic" pre_units = "code_mass / (code_length*code_time**2)" diff --git a/yt/frontends/gamer/io.py b/yt/frontends/gamer/io.py index e2b6a9f218e..f2b9af02125 100644 --- a/yt/frontends/gamer/io.py +++ b/yt/frontends/gamer/io.py @@ -1,11 +1,10 @@ -import numpy as np from itertools import groupby -from yt.utilities.io_handler import \ - BaseIOHandler -from yt.utilities.logger import ytLogger as mylog -from yt.geometry.selection_routines import AlwaysSelector +import numpy as np +from yt.geometry.selection_routines import AlwaysSelector +from yt.utilities.io_handler import BaseIOHandler +from yt.utilities.logger import ytLogger as mylog #----------------------------------------------------------------------------- # GAMER shares a similar HDF5 format, and thus io.py as well, with FLASH diff --git a/yt/frontends/gamer/tests/test_outputs.py b/yt/frontends/gamer/tests/test_outputs.py index e28e8f6a0db..7ebb89c6a10 100644 --- a/yt/frontends/gamer/tests/test_outputs.py +++ b/yt/frontends/gamer/tests/test_outputs.py @@ -1,14 +1,10 @@ -from yt.testing import \ - assert_equal, \ - requires_file, \ - units_override_check -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - small_patch_amr, \ - data_dir_load from yt.frontends.gamer.api import GAMERDataset - - +from yt.testing import assert_equal, requires_file, units_override_check +from yt.utilities.answer_testing.framework import ( + data_dir_load, + requires_ds, + small_patch_amr, +) jet = "InteractingJets/jet_000002" _fields_jet = ("temperature", "density", "velocity_magnitude") diff --git a/yt/frontends/gdf/api.py b/yt/frontends/gdf/api.py index 99b4205d6f4..682c31a697a 100644 --- a/yt/frontends/gdf/api.py +++ b/yt/frontends/gdf/api.py @@ -1,13 +1,6 @@ -from .data_structures import \ - GDFGrid, \ - GDFHierarchy, \ - GDFDataset +from . import tests +from .data_structures import GDFDataset, GDFGrid, GDFHierarchy +from .fields import GDFFieldInfo +from .io import IOHandlerGDFHDF5 -from .fields import \ - GDFFieldInfo add_gdf_field = GDFFieldInfo.add_field - -from .io import \ - IOHandlerGDFHDF5 - -from . import tests diff --git a/yt/frontends/gdf/data_structures.py b/yt/frontends/gdf/data_structures.py index 9fb6b3a8614..5281f14ec29 100644 --- a/yt/frontends/gdf/data_structures.py +++ b/yt/frontends/gdf/data_structures.py @@ -1,30 +1,21 @@ -from yt.utilities.on_demand_imports import _h5py as h5py -import numpy as np -import weakref import os -from yt.funcs import \ - ensure_tuple, \ - just_one, \ - setdefaultattr -from yt.data_objects.grid_patch import \ - AMRGridPatch -from yt.geometry.grid_geometry_handler import \ - GridIndex -from yt.data_objects.static_output import \ - Dataset -from yt.units.dimensions import \ - dimensionless as sympy_one -from yt.units.unit_object import \ - Unit -from yt.units.unit_systems import \ - unit_system_registry -from yt.utilities.exceptions import \ - YTGDFUnknownGeometry -from yt.utilities.lib.misc_utilities import \ - get_box_grids_level +import weakref + +import numpy as np + +from yt.data_objects.grid_patch import AMRGridPatch +from yt.data_objects.static_output import Dataset +from yt.funcs import ensure_tuple, just_one, setdefaultattr +from yt.geometry.grid_geometry_handler import GridIndex +from yt.units.dimensions import dimensionless as sympy_one +from yt.units.unit_object import Unit +from yt.units.unit_systems import unit_system_registry +from yt.utilities.exceptions import YTGDFUnknownGeometry +from yt.utilities.lib.misc_utilities import get_box_grids_level from yt.utilities.logger import ytLogger as mylog -from .fields import GDFFieldInfo +from yt.utilities.on_demand_imports import _h5py as h5py +from .fields import GDFFieldInfo GEOMETRY_TRANS = { 0: "cartesian", diff --git a/yt/frontends/gdf/definitions.py b/yt/frontends/gdf/definitions.py index 307b63a9616..70a2797752a 100644 --- a/yt/frontends/gdf/definitions.py +++ b/yt/frontends/gdf/definitions.py @@ -4,4 +4,3 @@ """ - diff --git a/yt/frontends/gdf/fields.py b/yt/frontends/gdf/fields.py index de065bd4605..fdb5ce7270f 100644 --- a/yt/frontends/gdf/fields.py +++ b/yt/frontends/gdf/fields.py @@ -1,5 +1,4 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer +from yt.fields.field_info_container import FieldInfoContainer # The nice thing about GDF is that for the most part, everything is in CGS, # with potentially a scalar modification. diff --git a/yt/frontends/gdf/io.py b/yt/frontends/gdf/io.py index 7912d3be992..308ff566601 100644 --- a/yt/frontends/gdf/io.py +++ b/yt/frontends/gdf/io.py @@ -1,10 +1,9 @@ import numpy as np -from yt.utilities.on_demand_imports import _h5py as h5py -from yt.funcs import \ - mylog + +from yt.funcs import mylog from yt.geometry.selection_routines import GridSelector -from yt.utilities.io_handler import \ - BaseIOHandler +from yt.utilities.io_handler import BaseIOHandler +from yt.utilities.on_demand_imports import _h5py as h5py def _grid_dname(grid_id): diff --git a/yt/frontends/gdf/tests/test_outputs.py b/yt/frontends/gdf/tests/test_outputs.py index 649ca9e08ab..a20d530b3c8 100644 --- a/yt/frontends/gdf/tests/test_outputs.py +++ b/yt/frontends/gdf/tests/test_outputs.py @@ -1,12 +1,10 @@ -from yt.testing import \ - assert_equal, \ - requires_file, \ - units_override_check -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - small_patch_amr, \ - data_dir_load from yt.frontends.gdf.api import GDFDataset +from yt.testing import assert_equal, requires_file, units_override_check +from yt.utilities.answer_testing.framework import ( + data_dir_load, + requires_ds, + small_patch_amr, +) _fields = ("density", "velocity_x") diff --git a/yt/frontends/gizmo/api.py b/yt/frontends/gizmo/api.py index 1c2f1becf02..bad1f564a00 100644 --- a/yt/frontends/gizmo/api.py +++ b/yt/frontends/gizmo/api.py @@ -1,5 +1,2 @@ -from .data_structures import \ - GizmoDataset - -from .fields import \ - GizmoFieldInfo +from .data_structures import GizmoDataset +from .fields import GizmoFieldInfo diff --git a/yt/frontends/gizmo/data_structures.py b/yt/frontends/gizmo/data_structures.py index d4f4a22f59a..06c3f7da807 100644 --- a/yt/frontends/gizmo/data_structures.py +++ b/yt/frontends/gizmo/data_structures.py @@ -1,12 +1,9 @@ import os +from yt.frontends.gadget.data_structures import GadgetHDF5Dataset from yt.utilities.on_demand_imports import _h5py as h5py -from yt.frontends.gadget.data_structures import \ - GadgetHDF5Dataset - -from .fields import \ - GizmoFieldInfo +from .fields import GizmoFieldInfo class GizmoDataset(GadgetHDF5Dataset): diff --git a/yt/frontends/gizmo/fields.py b/yt/frontends/gizmo/fields.py index cb9d23b2c97..43e7fda39e8 100644 --- a/yt/frontends/gizmo/fields.py +++ b/yt/frontends/gizmo/fields.py @@ -1,14 +1,8 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer -from yt.fields.magnetic_field import \ - setup_magnetic_field_aliases -from yt.fields.species_fields import \ - add_species_field_by_density, \ - setup_species_fields -from yt.frontends.gadget.fields import \ - GadgetFieldInfo -from yt.frontends.sph.fields import \ - SPHFieldInfo +from yt.fields.field_info_container import FieldInfoContainer +from yt.fields.magnetic_field import setup_magnetic_field_aliases +from yt.fields.species_fields import add_species_field_by_density, setup_species_fields +from yt.frontends.gadget.fields import GadgetFieldInfo +from yt.frontends.sph.fields import SPHFieldInfo metal_elements = ["He", "C", "N", "O", "Ne", "Mg", "Si", "S", "Ca", "Fe"] diff --git a/yt/frontends/gizmo/tests/test_outputs.py b/yt/frontends/gizmo/tests/test_outputs.py index 043900ec29a..b20493d8dc6 100644 --- a/yt/frontends/gizmo/tests/test_outputs.py +++ b/yt/frontends/gizmo/tests/test_outputs.py @@ -1,14 +1,10 @@ from collections import OrderedDict import yt -from yt.testing import \ - requires_file -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - sph_answer from yt.frontends.gizmo.api import GizmoDataset from yt.frontends.gizmo.fields import metal_elements - +from yt.testing import requires_file +from yt.utilities.answer_testing.framework import requires_ds, sph_answer # This maps from field names to weight field names to use for projections fields = OrderedDict( diff --git a/yt/frontends/halo_catalog/__init__.py b/yt/frontends/halo_catalog/__init__.py index 04ebe5cd2d7..46e4642cc5d 100644 --- a/yt/frontends/halo_catalog/__init__.py +++ b/yt/frontends/halo_catalog/__init__.py @@ -5,4 +5,3 @@ """ - diff --git a/yt/frontends/halo_catalog/api.py b/yt/frontends/halo_catalog/api.py index e647bc11327..93deea97d16 100644 --- a/yt/frontends/halo_catalog/api.py +++ b/yt/frontends/halo_catalog/api.py @@ -1,8 +1,3 @@ -from .data_structures import \ - HaloCatalogDataset - -from .io import \ - IOHandlerHaloCatalogHDF5 - -from .fields import \ - HaloCatalogFieldInfo +from .data_structures import HaloCatalogDataset +from .fields import HaloCatalogFieldInfo +from .io import IOHandlerHaloCatalogHDF5 diff --git a/yt/frontends/halo_catalog/data_structures.py b/yt/frontends/halo_catalog/data_structures.py index a26f9f1f086..8e3abc1363c 100644 --- a/yt/frontends/halo_catalog/data_structures.py +++ b/yt/frontends/halo_catalog/data_structures.py @@ -1,18 +1,15 @@ -from yt.utilities.on_demand_imports import _h5py as h5py -import numpy as np import glob -from .fields import \ - HaloCatalogFieldInfo - -from yt.frontends.ytdata.data_structures import \ - SavedDataset -from yt.funcs import \ - parse_h5_attr -from yt.geometry.particle_geometry_handler import \ - ParticleIndex -from yt.data_objects.static_output import \ - ParticleFile +import numpy as np + +from yt.data_objects.static_output import ParticleFile +from yt.frontends.ytdata.data_structures import SavedDataset +from yt.funcs import parse_h5_attr +from yt.geometry.particle_geometry_handler import ParticleIndex +from yt.utilities.on_demand_imports import _h5py as h5py + +from .fields import HaloCatalogFieldInfo + class HaloCatalogParticleIndex(ParticleIndex): def _setup_filenames(self): diff --git a/yt/frontends/halo_catalog/fields.py b/yt/frontends/halo_catalog/fields.py index d25dc8f44cc..d0732f8cd9d 100644 --- a/yt/frontends/halo_catalog/fields.py +++ b/yt/frontends/halo_catalog/fields.py @@ -1,5 +1,4 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer +from yt.fields.field_info_container import FieldInfoContainer m_units = "g" p_units = "cm" diff --git a/yt/frontends/halo_catalog/io.py b/yt/frontends/halo_catalog/io.py index d16d5a1c703..4bc7821d61f 100644 --- a/yt/frontends/halo_catalog/io.py +++ b/yt/frontends/halo_catalog/io.py @@ -1,15 +1,11 @@ import numpy as np -from yt.funcs import \ - mylog, \ - parse_h5_attr -from yt.units.yt_array import \ - uvstack -from yt.utilities.on_demand_imports import _h5py as h5py +from yt.funcs import mylog, parse_h5_attr +from yt.units.yt_array import uvstack from yt.utilities.exceptions import YTDomainOverflow -from yt.utilities.io_handler import \ - BaseIOHandler +from yt.utilities.io_handler import BaseIOHandler from yt.utilities.lib.geometry_utils import compute_morton +from yt.utilities.on_demand_imports import _h5py as h5py class IOHandlerHaloCatalogHDF5(BaseIOHandler): diff --git a/yt/frontends/halo_catalog/tests/test_outputs.py b/yt/frontends/halo_catalog/tests/test_outputs.py index 3562812f0f2..e235be7765e 100644 --- a/yt/frontends/halo_catalog/tests/test_outputs.py +++ b/yt/frontends/halo_catalog/tests/test_outputs.py @@ -1,18 +1,11 @@ import numpy as np -from yt.convenience import \ - load as yt_load -from yt.frontends.halo_catalog.data_structures import \ - HaloCatalogDataset -from yt.frontends.ytdata.utilities import \ - save_as_dataset -from yt.testing import \ - assert_array_equal, \ - requires_module, \ - TempDirTest -from yt.units.yt_array import \ - YTArray, \ - YTQuantity +from yt.convenience import load as yt_load +from yt.frontends.halo_catalog.data_structures import HaloCatalogDataset +from yt.frontends.ytdata.utilities import save_as_dataset +from yt.testing import TempDirTest, assert_array_equal, requires_module +from yt.units.yt_array import YTArray, YTQuantity + def fake_halo_catalog(data): filename = "catalog.0.h5" diff --git a/yt/frontends/http_stream/api.py b/yt/frontends/http_stream/api.py index 554845f7414..bf1851777a6 100644 --- a/yt/frontends/http_stream/api.py +++ b/yt/frontends/http_stream/api.py @@ -1,5 +1,2 @@ -from .data_structures import \ - HTTPStreamDataset - -from .io import \ - IOHandlerHTTPStream +from .data_structures import HTTPStreamDataset +from .io import IOHandlerHTTPStream diff --git a/yt/frontends/http_stream/data_structures.py b/yt/frontends/http_stream/data_structures.py index 3eff4bc0cba..a0ccf776d7f 100644 --- a/yt/frontends/http_stream/data_structures.py +++ b/yt/frontends/http_stream/data_structures.py @@ -1,16 +1,13 @@ import json -import numpy as np import time -from yt.data_objects.static_output import \ - ParticleDataset, \ - ParticleFile -from yt.frontends.sph.fields import \ - SPHFieldInfo -from yt.funcs import \ - get_requests -from yt.geometry.particle_geometry_handler import \ - ParticleIndex +import numpy as np + +from yt.data_objects.static_output import ParticleDataset, ParticleFile +from yt.frontends.sph.fields import SPHFieldInfo +from yt.funcs import get_requests +from yt.geometry.particle_geometry_handler import ParticleIndex + class HTTPParticleFile(ParticleFile): pass diff --git a/yt/frontends/http_stream/io.py b/yt/frontends/http_stream/io.py index 8653d693cf6..c6533d1ca4c 100644 --- a/yt/frontends/http_stream/io.py +++ b/yt/frontends/http_stream/io.py @@ -1,12 +1,9 @@ import numpy as np -from yt.funcs import \ - get_requests, \ - mylog -from yt.utilities.io_handler import \ - BaseIOHandler -from yt.utilities.lib.geometry_utils import \ - compute_morton +from yt.funcs import get_requests, mylog +from yt.utilities.io_handler import BaseIOHandler +from yt.utilities.lib.geometry_utils import compute_morton + class IOHandlerHTTPStream(BaseIOHandler): _dataset_type = "http_particle_stream" diff --git a/yt/frontends/moab/__init__.py b/yt/frontends/moab/__init__.py index fcc280c5b40..3a67715b31b 100644 --- a/yt/frontends/moab/__init__.py +++ b/yt/frontends/moab/__init__.py @@ -4,4 +4,3 @@ """ - diff --git a/yt/frontends/moab/api.py b/yt/frontends/moab/api.py index eaf37635ec4..d932dbcf0e0 100644 --- a/yt/frontends/moab/api.py +++ b/yt/frontends/moab/api.py @@ -1,14 +1,9 @@ -from .data_structures import \ - MoabHex8Mesh, \ - MoabHex8Hierarchy, \ - MoabHex8Dataset, \ - PyneMoabHex8Dataset - -from .fields import \ - MoabFieldInfo, \ - PyneFieldInfo - -from .io import \ - IOHandlerMoabH5MHex8 - from . import tests +from .data_structures import ( + MoabHex8Dataset, + MoabHex8Hierarchy, + MoabHex8Mesh, + PyneMoabHex8Dataset, +) +from .fields import MoabFieldInfo, PyneFieldInfo +from .io import IOHandlerMoabH5MHex8 diff --git a/yt/frontends/moab/data_structures.py b/yt/frontends/moab/data_structures.py index 59b455d7ff7..3387ec54307 100644 --- a/yt/frontends/moab/data_structures.py +++ b/yt/frontends/moab/data_structures.py @@ -1,19 +1,18 @@ -from yt.utilities.on_demand_imports import _h5py as h5py import os -import numpy as np import weakref -from yt.data_objects.unstructured_mesh import \ - SemiStructuredMesh -from yt.funcs import \ - setdefaultattr -from yt.geometry.unstructured_mesh_handler import \ - UnstructuredIndex -from yt.data_objects.static_output import \ - Dataset + +import numpy as np + +from yt.data_objects.static_output import Dataset +from yt.data_objects.unstructured_mesh import SemiStructuredMesh +from yt.funcs import setdefaultattr +from yt.geometry.unstructured_mesh_handler import UnstructuredIndex from yt.utilities.file_handler import HDF5FileHandler +from yt.utilities.on_demand_imports import _h5py as h5py from .fields import MoabFieldInfo, PyneFieldInfo + class MoabHex8Mesh(SemiStructuredMesh): _connectivity_length = 8 _index_offset = 1 @@ -177,4 +176,3 @@ def _is_valid(self, *args, **kwargs): def __repr__(self): return self.basename.rsplit(".", 1)[0] - diff --git a/yt/frontends/moab/definitions.py b/yt/frontends/moab/definitions.py index 8b137891791..e69de29bb2d 100644 --- a/yt/frontends/moab/definitions.py +++ b/yt/frontends/moab/definitions.py @@ -1 +0,0 @@ - diff --git a/yt/frontends/moab/fields.py b/yt/frontends/moab/fields.py index 2a3190fc731..90cb53d7be3 100644 --- a/yt/frontends/moab/fields.py +++ b/yt/frontends/moab/fields.py @@ -1,5 +1,5 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer +from yt.fields.field_info_container import FieldInfoContainer + class MoabFieldInfo(FieldInfoContainer): pass diff --git a/yt/frontends/moab/io.py b/yt/frontends/moab/io.py index 3303b7fe851..12b883cc23e 100644 --- a/yt/frontends/moab/io.py +++ b/yt/frontends/moab/io.py @@ -1,4 +1,5 @@ import numpy as np + from yt.funcs import mylog from yt.utilities.io_handler import BaseIOHandler diff --git a/yt/frontends/moab/tests/test_c5.py b/yt/frontends/moab/tests/test_c5.py index 1c9d0b674a2..706cb203ce9 100644 --- a/yt/frontends/moab/tests/test_c5.py +++ b/yt/frontends/moab/tests/test_c5.py @@ -1,15 +1,17 @@ import numpy as np -from yt.testing import \ - assert_equal, \ - assert_almost_equal, \ - requires_file, \ - units_override_check -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - data_dir_load, \ - FieldValuesTest from yt.frontends.moab.api import MoabHex8Dataset +from yt.testing import ( + assert_almost_equal, + assert_equal, + requires_file, + units_override_check, +) +from yt.utilities.answer_testing.framework import ( + FieldValuesTest, + data_dir_load, + requires_ds, +) _fields = (("moab", "flux"), ) diff --git a/yt/frontends/open_pmd/__init__.py b/yt/frontends/open_pmd/__init__.py index 2c656b643d4..dcdf43a9dfd 100644 --- a/yt/frontends/open_pmd/__init__.py +++ b/yt/frontends/open_pmd/__init__.py @@ -4,4 +4,3 @@ """ - diff --git a/yt/frontends/open_pmd/api.py b/yt/frontends/open_pmd/api.py index cfb0979e774..851f7bb94b2 100644 --- a/yt/frontends/open_pmd/api.py +++ b/yt/frontends/open_pmd/api.py @@ -1,13 +1,4 @@ -from .data_structures import \ - OpenPMDDataset, \ - OpenPMDGrid, \ - OpenPMDHierarchy - -from .fields import \ - OpenPMDFieldInfo - -from .io import \ - IOHandlerOpenPMDHDF5 - -from . import \ - tests +from . import tests +from .data_structures import OpenPMDDataset, OpenPMDGrid, OpenPMDHierarchy +from .fields import OpenPMDFieldInfo +from .io import IOHandlerOpenPMDHDF5 diff --git a/yt/frontends/open_pmd/data_structures.py b/yt/frontends/open_pmd/data_structures.py index 2cd0e6d1d0e..d6556c3ef8a 100644 --- a/yt/frontends/open_pmd/data_structures.py +++ b/yt/frontends/open_pmd/data_structures.py @@ -1,23 +1,19 @@ from distutils.version import StrictVersion from functools import reduce from operator import mul -from os import \ - path, \ - listdir +from os import listdir, path from re import match import numpy as np + from yt.data_objects.grid_patch import AMRGridPatch from yt.data_objects.static_output import Dataset from yt.data_objects.time_series import DatasetSeries from yt.frontends.open_pmd.fields import OpenPMDFieldInfo -from yt.frontends.open_pmd.misc import \ - is_const_component, \ - get_component +from yt.frontends.open_pmd.misc import get_component, is_const_component from yt.funcs import setdefaultattr from yt.geometry.grid_geometry_handler import GridIndex -from yt.utilities.file_handler import HDF5FileHandler, \ - warn_h5py +from yt.utilities.file_handler import HDF5FileHandler, warn_h5py from yt.utilities.logger import ytLogger as mylog from yt.utilities.on_demand_imports import _h5py as h5 @@ -616,4 +612,3 @@ def _is_valid(self, *args, **kwargs): return False except (IOError, OSError, ImportError): return False - diff --git a/yt/frontends/open_pmd/fields.py b/yt/frontends/open_pmd/fields.py index 71a47ed2975..8f5f798dc64 100644 --- a/yt/frontends/open_pmd/fields.py +++ b/yt/frontends/open_pmd/fields.py @@ -2,15 +2,11 @@ from yt.fields.field_info_container import FieldInfoContainer from yt.fields.magnetic_field import setup_magnetic_field_aliases -from yt.frontends.open_pmd.misc import \ - parse_unit_dimension, \ - is_const_component +from yt.frontends.open_pmd.misc import is_const_component, parse_unit_dimension from yt.units.yt_array import YTQuantity from yt.utilities.logger import ytLogger as mylog from yt.utilities.on_demand_imports import _h5py as h5 -from yt.utilities.physical_constants import \ - speed_of_light, \ - mu_0 +from yt.utilities.physical_constants import mu_0, speed_of_light def setup_poynting_vector(self): diff --git a/yt/frontends/open_pmd/io.py b/yt/frontends/open_pmd/io.py index fdbc15f6e9f..39ac2c2ca71 100644 --- a/yt/frontends/open_pmd/io.py +++ b/yt/frontends/open_pmd/io.py @@ -2,9 +2,7 @@ import numpy as np -from yt.frontends.open_pmd.misc import \ - is_const_component, \ - get_component +from yt.frontends.open_pmd.misc import get_component, is_const_component from yt.geometry.selection_routines import GridSelector from yt.utilities.io_handler import BaseIOHandler diff --git a/yt/frontends/open_pmd/tests/test_outputs.py b/yt/frontends/open_pmd/tests/test_outputs.py index 1243f9ca40e..fdbd7f4ebc5 100644 --- a/yt/frontends/open_pmd/tests/test_outputs.py +++ b/yt/frontends/open_pmd/tests/test_outputs.py @@ -1,17 +1,17 @@ from itertools import product -from yt.frontends.open_pmd.data_structures import \ - OpenPMDDataset -from yt.testing import \ - assert_almost_equal, \ - assert_equal, \ - assert_array_equal, \ - requires_file -from yt.utilities.answer_testing.framework import \ - data_dir_load -from yt.convenience import load import numpy as np +from yt.convenience import load +from yt.frontends.open_pmd.data_structures import OpenPMDDataset +from yt.testing import ( + assert_almost_equal, + assert_array_equal, + assert_equal, + requires_file, +) +from yt.utilities.answer_testing.framework import data_dir_load + twoD = "example-2d/hdf5/data00000100.h5" threeD = "example-3d/hdf5/data00000100.h5" noFields = "no_fields/data00000400.h5" @@ -156,4 +156,3 @@ def test_groupBased_out(): assert ds.current_time <= 1.6499999999999998e-12 * np.ones_like(ds.current_time) assert_almost_equal(ds.domain_right_edge - ds.domain_left_edge, domain_width) - diff --git a/yt/frontends/owls/api.py b/yt/frontends/owls/api.py index 2f0b6f38b6b..1819e844da4 100644 --- a/yt/frontends/owls/api.py +++ b/yt/frontends/owls/api.py @@ -1,13 +1,5 @@ -from .data_structures import \ - OWLSDataset - -from .fields import \ - OWLSFieldInfo - -from .io import \ - IOHandlerOWLS - -from .simulation_handling import \ - OWLSSimulation - from . import tests +from .data_structures import OWLSDataset +from .fields import OWLSFieldInfo +from .io import IOHandlerOWLS +from .simulation_handling import OWLSSimulation diff --git a/yt/frontends/owls/data_structures.py b/yt/frontends/owls/data_structures.py index d0300635d97..fc57a8541f8 100644 --- a/yt/frontends/owls/data_structures.py +++ b/yt/frontends/owls/data_structures.py @@ -1,15 +1,12 @@ import os +import yt.units +from yt.frontends.gadget.data_structures import GadgetHDF5Dataset +from yt.utilities.definitions import sec_conversion from yt.utilities.on_demand_imports import _h5py as h5py -import yt.units -from yt.frontends.gadget.data_structures import \ - GadgetHDF5Dataset -from yt.utilities.definitions import \ - sec_conversion +from .fields import OWLSFieldInfo -from .fields import \ - OWLSFieldInfo class OWLSDataset(GadgetHDF5Dataset): _particle_mass_name = "Mass" diff --git a/yt/frontends/owls/fields.py b/yt/frontends/owls/fields.py index 12601415797..eff036d32ef 100644 --- a/yt/frontends/owls/fields.py +++ b/yt/frontends/owls/fields.py @@ -1,15 +1,16 @@ import os + import numpy as np -from . import owls_ion_tables as oit -from yt.funcs import \ - mylog, download_file from yt.config import ytcfg -from yt.fields.species_fields import \ - add_species_field_by_fraction, \ - add_species_field_by_density -from yt.frontends.sph.fields import \ - SPHFieldInfo +from yt.fields.species_fields import ( + add_species_field_by_density, + add_species_field_by_fraction, +) +from yt.frontends.sph.fields import SPHFieldInfo +from yt.funcs import download_file, mylog + +from . import owls_ion_tables as oit def _get_ion_mass_frac(ion, ftype, itab, data): diff --git a/yt/frontends/owls/io.py b/yt/frontends/owls/io.py index dde0eacfbe5..18ce699c1bd 100644 --- a/yt/frontends/owls/io.py +++ b/yt/frontends/owls/io.py @@ -1,5 +1,5 @@ -from yt.frontends.gadget.io import \ - IOHandlerGadgetHDF5 +from yt.frontends.gadget.io import IOHandlerGadgetHDF5 + class IOHandlerOWLS(IOHandlerGadgetHDF5): _dataset_type = "OWLS" diff --git a/yt/frontends/owls/owls_ion_tables.py b/yt/frontends/owls/owls_ion_tables.py index b13473c289b..19d3a749010 100644 --- a/yt/frontends/owls/owls_ion_tables.py +++ b/yt/frontends/owls/owls_ion_tables.py @@ -1,7 +1,6 @@ -from yt.utilities.on_demand_imports import _h5py as h5py import numpy as np - +from yt.utilities.on_demand_imports import _h5py as h5py def h5rd(fname, path, dtype=None): diff --git a/yt/frontends/owls/simulation_handling.py b/yt/frontends/owls/simulation_handling.py index 76ed28a9b30..a84fa68b660 100644 --- a/yt/frontends/owls/simulation_handling.py +++ b/yt/frontends/owls/simulation_handling.py @@ -1,7 +1,7 @@ import os -from yt.frontends.gadget.simulation_handling import \ - GadgetSimulation +from yt.frontends.gadget.simulation_handling import GadgetSimulation + class OWLSSimulation(GadgetSimulation): r""" diff --git a/yt/frontends/owls/tests/test_outputs.py b/yt/frontends/owls/tests/test_outputs.py index 78595ce2f10..acbd43bbc9c 100644 --- a/yt/frontends/owls/tests/test_outputs.py +++ b/yt/frontends/owls/tests/test_outputs.py @@ -1,14 +1,9 @@ from collections import OrderedDict -from yt.testing import \ - requires_file, \ - ParticleSelectionComparison -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - data_dir_load, \ - sph_answer -from yt.frontends.owls.api import OWLSDataset from yt.data_objects.particle_filters import add_particle_filter +from yt.frontends.owls.api import OWLSDataset +from yt.testing import ParticleSelectionComparison, requires_file +from yt.utilities.answer_testing.framework import data_dir_load, requires_ds, sph_answer os33 = "snapshot_033/snap_033.0.hdf5" @@ -52,4 +47,3 @@ def cold_gas(pfilter, data): mask = (ad['PartType0','Temperature'] <= 1e5) assert ad['PartType0','Temperature'][mask].shape == ad['gas_cold','Temperature'].shape - diff --git a/yt/frontends/owls_subfind/__init__.py b/yt/frontends/owls_subfind/__init__.py index 04ebe5cd2d7..46e4642cc5d 100644 --- a/yt/frontends/owls_subfind/__init__.py +++ b/yt/frontends/owls_subfind/__init__.py @@ -5,4 +5,3 @@ """ - diff --git a/yt/frontends/owls_subfind/api.py b/yt/frontends/owls_subfind/api.py index 7168df707bf..035e2c44c0a 100644 --- a/yt/frontends/owls_subfind/api.py +++ b/yt/frontends/owls_subfind/api.py @@ -1,10 +1,4 @@ -from .data_structures import \ - OWLSSubfindDataset - -from .io import \ - IOHandlerOWLSSubfindHDF5 - -from .fields import \ - OWLSSubfindFieldInfo - from . import tests +from .data_structures import OWLSSubfindDataset +from .fields import OWLSSubfindFieldInfo +from .io import IOHandlerOWLSSubfindHDF5 diff --git a/yt/frontends/owls_subfind/data_structures.py b/yt/frontends/owls_subfind/data_structures.py index ea471cc5878..5b3dbd9fe59 100644 --- a/yt/frontends/owls_subfind/data_structures.py +++ b/yt/frontends/owls_subfind/data_structures.py @@ -1,26 +1,19 @@ -from collections import defaultdict -from yt.utilities.on_demand_imports import _h5py as h5py -import numpy as np import glob import os +from collections import defaultdict + +import numpy as np + +from yt.data_objects.static_output import ParticleDataset, ParticleFile +from yt.frontends.gadget.data_structures import _fix_unit_ordering +from yt.funcs import only_on_root, setdefaultattr +from yt.geometry.particle_geometry_handler import ParticleIndex +from yt.utilities.exceptions import YTException +from yt.utilities.logger import ytLogger as mylog +from yt.utilities.on_demand_imports import _h5py as h5py + +from .fields import OWLSSubfindFieldInfo -from .fields import \ - OWLSSubfindFieldInfo - -from yt.funcs import \ - only_on_root, \ - setdefaultattr -from yt.utilities.exceptions import \ - YTException -from yt.utilities.logger import ytLogger as \ - mylog -from yt.geometry.particle_geometry_handler import \ - ParticleIndex -from yt.data_objects.static_output import \ - ParticleDataset, \ - ParticleFile -from yt.frontends.gadget.data_structures import \ - _fix_unit_ordering class OWLSSubfindParticleIndex(ParticleIndex): def __init__(self, ds, dataset_type): diff --git a/yt/frontends/owls_subfind/fields.py b/yt/frontends/owls_subfind/fields.py index a41904a8784..18f4a2d8a66 100644 --- a/yt/frontends/owls_subfind/fields.py +++ b/yt/frontends/owls_subfind/fields.py @@ -1,5 +1,4 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer +from yt.fields.field_info_container import FieldInfoContainer m_units = "code_mass" mdot_units = "code_mass / code_time" diff --git a/yt/frontends/owls_subfind/io.py b/yt/frontends/owls_subfind/io.py index e30e6244884..6ad547d7648 100644 --- a/yt/frontends/owls_subfind/io.py +++ b/yt/frontends/owls_subfind/io.py @@ -1,13 +1,11 @@ -from yt.utilities.on_demand_imports import _h5py as h5py import numpy as np -from yt.utilities.exceptions import YTDomainOverflow from yt.funcs import mylog - -from yt.utilities.io_handler import \ - BaseIOHandler - +from yt.utilities.exceptions import YTDomainOverflow +from yt.utilities.io_handler import BaseIOHandler from yt.utilities.lib.geometry_utils import compute_morton +from yt.utilities.on_demand_imports import _h5py as h5py + class IOHandlerOWLSSubfindHDF5(BaseIOHandler): _dataset_type = "subfind_hdf5" diff --git a/yt/frontends/owls_subfind/tests/test_outputs.py b/yt/frontends/owls_subfind/tests/test_outputs.py index 323a06e5e39..52c010971a1 100644 --- a/yt/frontends/owls_subfind/tests/test_outputs.py +++ b/yt/frontends/owls_subfind/tests/test_outputs.py @@ -1,10 +1,12 @@ import os.path -from yt.testing import \ - assert_equal -from yt.utilities.answer_testing.framework import \ - FieldValuesTest, \ - requires_ds, \ - data_dir_load + +from yt.testing import assert_equal +from yt.utilities.answer_testing.framework import ( + FieldValuesTest, + data_dir_load, + requires_ds, +) + # from yt.frontends.owls_subfind.api import OWLSSubfindDataset _fields = ("particle_position_x", "particle_position_y", diff --git a/yt/frontends/ramses/__init__.py b/yt/frontends/ramses/__init__.py index 1d8841fe239..8016231f3eb 100644 --- a/yt/frontends/ramses/__init__.py +++ b/yt/frontends/ramses/__init__.py @@ -4,4 +4,3 @@ """ - diff --git a/yt/frontends/ramses/api.py b/yt/frontends/ramses/api.py index b47602b931f..fa20c992924 100644 --- a/yt/frontends/ramses/api.py +++ b/yt/frontends/ramses/api.py @@ -1,13 +1,5 @@ -from .data_structures import \ - RAMSESDataset - -from .fields import \ - RAMSESFieldInfo - -from .io import \ - IOHandlerRAMSES - -from .definitions import \ - field_aliases - from . import tests +from .data_structures import RAMSESDataset +from .definitions import field_aliases +from .fields import RAMSESFieldInfo +from .io import IOHandlerRAMSES diff --git a/yt/frontends/ramses/data_structures.py b/yt/frontends/ramses/data_structures.py index bf1d016f57b..f38c8b8830e 100644 --- a/yt/frontends/ramses/data_structures.py +++ b/yt/frontends/ramses/data_structures.py @@ -1,39 +1,30 @@ import os -import numpy as np import weakref from collections import defaultdict from glob import glob -from yt.funcs import \ - mylog, \ - setdefaultattr -from yt.geometry.oct_geometry_handler import \ - OctreeIndex -from yt.geometry.geometry_handler import \ - YTDataChunk -from yt.data_objects.static_output import \ - Dataset -from yt.data_objects.octree_subset import \ - OctreeSubset -from yt.data_objects.particle_filters import add_particle_filter +import numpy as np -from yt.utilities.physical_constants import mp, kb +from yt.arraytypes import blankRecordArray +from yt.data_objects.octree_subset import OctreeSubset +from yt.data_objects.particle_filters import add_particle_filter +from yt.data_objects.static_output import Dataset +from yt.funcs import mylog, setdefaultattr +from yt.geometry.geometry_handler import YTDataChunk +from yt.geometry.oct_container import RAMSESOctreeContainer +from yt.geometry.oct_geometry_handler import OctreeIndex +from yt.utilities.cython_fortran_utils import FortranFile as fpu +from yt.utilities.lib.cosmology_time import friedman from yt.utilities.on_demand_imports import _f90nml as f90nml -from .definitions import ramses_header, field_aliases, particle_families -from .fields import \ - RAMSESFieldInfo, _X +from yt.utilities.physical_constants import kb, mp + +from .definitions import field_aliases, particle_families, ramses_header +from .field_handlers import get_field_handlers +from .fields import _X, RAMSESFieldInfo from .hilbert import get_cpu_list +from .io_utils import fill_hydro, read_amr from .particle_handlers import get_particle_handlers -from .field_handlers import get_field_handlers -from yt.utilities.cython_fortran_utils import FortranFile as fpu -from yt.geometry.oct_container import \ - RAMSESOctreeContainer -from yt.arraytypes import blankRecordArray - -from yt.utilities.lib.cosmology_time import \ - friedman -from .io_utils import read_amr, fill_hydro class RAMSESDomainFile: _last_mask = None diff --git a/yt/frontends/ramses/definitions.py b/yt/frontends/ramses/definitions.py index 71871bc47f9..5f5fa118b58 100644 --- a/yt/frontends/ramses/definitions.py +++ b/yt/frontends/ramses/definitions.py @@ -1,7 +1,9 @@ # These functions are RAMSES-specific +import re + from yt.config import ytcfg from yt.funcs import mylog -import re + def ramses_header(hvals): header = ( ('ncpu', 1, 'i'), diff --git a/yt/frontends/ramses/field_handlers.py b/yt/frontends/ramses/field_handlers.py index 4e9e70919b4..162cc4ca53b 100644 --- a/yt/frontends/ramses/field_handlers.py +++ b/yt/frontends/ramses/field_handlers.py @@ -1,8 +1,9 @@ -import os -from yt.utilities.cython_fortran_utils import FortranFile import glob -from yt.funcs import mylog +import os + from yt.config import ytcfg +from yt.funcs import mylog +from yt.utilities.cython_fortran_utils import FortranFile from .io import _read_fluid_file_descriptor from .io_utils import read_offset diff --git a/yt/frontends/ramses/fields.py b/yt/frontends/ramses/fields.py index c73efc70047..fa1d32c41da 100644 --- a/yt/frontends/ramses/fields.py +++ b/yt/frontends/ramses/fields.py @@ -1,27 +1,22 @@ import os + import numpy as np from yt import units -from yt.fields.field_detector import \ - FieldDetector -from yt.fields.field_info_container import \ - FieldInfoContainer -from yt.frontends.ramses.io import \ - convert_ramses_ages -from yt.funcs import \ - issue_deprecation_warning -from yt.utilities.physical_constants import \ - boltzmann_constant_cgs, \ - mass_hydrogen_cgs, \ - mh -from yt.utilities.linear_interpolators import \ - BilinearFieldInterpolator +from yt.fields.field_detector import FieldDetector +from yt.fields.field_info_container import FieldInfoContainer +from yt.frontends.ramses.io import convert_ramses_ages +from yt.funcs import issue_deprecation_warning, mylog from yt.utilities.cython_fortran_utils import FortranFile -from .field_handlers import RTFieldFileHandler +from yt.utilities.linear_interpolators import BilinearFieldInterpolator +from yt.utilities.physical_constants import ( + boltzmann_constant_cgs, + mass_hydrogen_cgs, + mh, + mp, +) -from yt.utilities.physical_constants import \ - mp -from yt.funcs import mylog +from .field_handlers import RTFieldFileHandler b_units = "code_magnetic" ra_units = "code_length / code_time**2" diff --git a/yt/frontends/ramses/hilbert.py b/yt/frontends/ramses/hilbert.py index 9d58d416e7d..68ed6294d64 100644 --- a/yt/frontends/ramses/hilbert.py +++ b/yt/frontends/ramses/hilbert.py @@ -1,5 +1,6 @@ import numpy as np + def hilbert3d(X, bit_length): '''Compute the order using Hilbert indexing. diff --git a/yt/frontends/ramses/io.py b/yt/frontends/ramses/io.py index 696e566bcd8..0bd2ec78e42 100644 --- a/yt/frontends/ramses/io.py +++ b/yt/frontends/ramses/io.py @@ -1,14 +1,19 @@ from collections import defaultdict + import numpy as np -from yt.utilities.io_handler import \ - BaseIOHandler +from yt.utilities.cython_fortran_utils import FortranFile +from yt.utilities.exceptions import ( + YTFieldTypeNotFound, + YTFileNotParseable, + YTParticleOutputFormatNotImplemented, +) +from yt.utilities.io_handler import BaseIOHandler from yt.utilities.logger import ytLogger as mylog from yt.utilities.physical_ratios import cm_per_km, cm_per_mpc -from yt.utilities.cython_fortran_utils import FortranFile -from yt.utilities.exceptions import YTFieldTypeNotFound, YTParticleOutputFormatNotImplemented, \ - YTFileNotParseable -from .definitions import VERSION_RE, VAR_DESC_RE + +from .definitions import VAR_DESC_RE, VERSION_RE + def convert_ramses_ages(ds, conformal_ages): tf = ds.t_frw diff --git a/yt/frontends/ramses/particle_handlers.py b/yt/frontends/ramses/particle_handlers.py index 0cc1c3154cd..36e45921c84 100644 --- a/yt/frontends/ramses/particle_handlers.py +++ b/yt/frontends/ramses/particle_handlers.py @@ -1,7 +1,8 @@ import os -from yt.utilities.cython_fortran_utils import FortranFile -from yt.funcs import mylog + from yt.config import ytcfg +from yt.funcs import mylog +from yt.utilities.cython_fortran_utils import FortranFile from .io import _read_part_file_descriptor diff --git a/yt/frontends/ramses/tests/test_hilbert.py b/yt/frontends/ramses/tests/test_hilbert.py index dac95279d84..b4bc6f4cb55 100644 --- a/yt/frontends/ramses/tests/test_hilbert.py +++ b/yt/frontends/ramses/tests/test_hilbert.py @@ -1,9 +1,9 @@ -from yt.frontends.ramses.hilbert import get_cpu_list, hilbert3d -from yt.testing import \ - assert_equal, \ - requires_file import numpy as np + import yt +from yt.frontends.ramses.hilbert import get_cpu_list, hilbert3d +from yt.testing import assert_equal, requires_file + def test_hilbert3d(): # 8 different cases, checked against RAMSES' own implementation diff --git a/yt/frontends/ramses/tests/test_outputs.py b/yt/frontends/ramses/tests/test_outputs.py index 49437691b47..c6e8db3200f 100644 --- a/yt/frontends/ramses/tests/test_outputs.py +++ b/yt/frontends/ramses/tests/test_outputs.py @@ -1,22 +1,26 @@ -from yt.testing import \ - assert_equal, \ - requires_file, \ - units_override_check, \ - requires_module -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - data_dir_load, \ - PixelizedProjectionValuesTest, \ - FieldValuesTest, \ - create_obj -from yt.utilities.on_demand_imports import _f90nml as f90nml -from yt.frontends.ramses.api import RAMSESDataset -from yt.config import ytcfg -from yt.frontends.ramses.field_handlers import DETECTED_FIELDS, HydroFieldFileHandler import os -import yt + import numpy as np +import yt +from yt.config import ytcfg +from yt.frontends.ramses.api import RAMSESDataset +from yt.frontends.ramses.field_handlers import DETECTED_FIELDS, HydroFieldFileHandler +from yt.testing import ( + assert_equal, + requires_file, + requires_module, + units_override_check, +) +from yt.utilities.answer_testing.framework import ( + FieldValuesTest, + PixelizedProjectionValuesTest, + create_obj, + data_dir_load, + requires_ds, +) +from yt.utilities.on_demand_imports import _f90nml as f90nml + _fields = ("temperature", "density", "velocity_magnitude") output_00080 = "output_00080/info_00080.txt" diff --git a/yt/frontends/rockstar/__init__.py b/yt/frontends/rockstar/__init__.py index ff6a8d86064..c1b25fc798f 100644 --- a/yt/frontends/rockstar/__init__.py +++ b/yt/frontends/rockstar/__init__.py @@ -5,4 +5,3 @@ """ - diff --git a/yt/frontends/rockstar/api.py b/yt/frontends/rockstar/api.py index f5bf766246d..94204007e97 100644 --- a/yt/frontends/rockstar/api.py +++ b/yt/frontends/rockstar/api.py @@ -1,10 +1,4 @@ -from .data_structures import \ - RockstarDataset - -from .io import \ - IOHandlerRockstarBinary - -from .fields import \ - RockstarFieldInfo - from . import tests +from .data_structures import RockstarDataset +from .fields import RockstarFieldInfo +from .io import IOHandlerRockstarBinary diff --git a/yt/frontends/rockstar/data_structures.py b/yt/frontends/rockstar/data_structures.py index 7daa1231178..a57ba578aa2 100644 --- a/yt/frontends/rockstar/data_structures.py +++ b/yt/frontends/rockstar/data_structures.py @@ -1,23 +1,18 @@ -import numpy as np import glob import os -from .fields import \ - RockstarFieldInfo - -from yt.data_objects.static_output import \ - ParticleDataset -from yt.frontends.halo_catalog.data_structures import \ - HaloCatalogFile -from yt.funcs import \ - setdefaultattr -from yt.geometry.particle_geometry_handler import \ - ParticleIndex -from yt.utilities.cosmology import Cosmology +import numpy as np + import yt.utilities.fortran_utils as fpu +from yt.data_objects.static_output import ParticleDataset +from yt.frontends.halo_catalog.data_structures import HaloCatalogFile +from yt.funcs import setdefaultattr +from yt.geometry.particle_geometry_handler import ParticleIndex +from yt.utilities.cosmology import Cosmology + +from .definitions import header_dt +from .fields import RockstarFieldInfo -from .definitions import \ - header_dt class RockstarBinaryFile(HaloCatalogFile): def __init__(self, ds, io, filename, file_id, range): diff --git a/yt/frontends/rockstar/fields.py b/yt/frontends/rockstar/fields.py index 5f5eb074c14..3b7483af842 100644 --- a/yt/frontends/rockstar/fields.py +++ b/yt/frontends/rockstar/fields.py @@ -1,5 +1,4 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer +from yt.fields.field_info_container import FieldInfoContainer m_units = "Msun / h" # Msun / h p_units = "Mpccm / h" # Mpc / h comoving diff --git a/yt/frontends/rockstar/io.py b/yt/frontends/rockstar/io.py index a8a4c14d2b4..fb49bc77cf3 100644 --- a/yt/frontends/rockstar/io.py +++ b/yt/frontends/rockstar/io.py @@ -1,16 +1,14 @@ -import numpy as np import os -from yt.funcs import mylog - -from yt.utilities.exceptions import \ - YTDomainOverflow +import numpy as np -from yt.utilities.io_handler import \ - BaseIOHandler +from yt.funcs import mylog +from yt.utilities.exceptions import YTDomainOverflow +from yt.utilities.io_handler import BaseIOHandler +from yt.utilities.lib.geometry_utils import compute_morton from .definitions import halo_dts -from yt.utilities.lib.geometry_utils import compute_morton + class IOHandlerRockstarBinary(BaseIOHandler): _dataset_type = "rockstar_binary" diff --git a/yt/frontends/rockstar/tests/test_outputs.py b/yt/frontends/rockstar/tests/test_outputs.py index e73f08d9e64..ca0cbbbe913 100644 --- a/yt/frontends/rockstar/tests/test_outputs.py +++ b/yt/frontends/rockstar/tests/test_outputs.py @@ -1,13 +1,12 @@ import os.path -from yt.testing import \ - assert_equal, \ - requires_file, \ - ParticleSelectionComparison -from yt.utilities.answer_testing.framework import \ - FieldValuesTest, \ - requires_ds, \ - data_dir_load + from yt.frontends.rockstar.api import RockstarDataset +from yt.testing import ParticleSelectionComparison, assert_equal, requires_file +from yt.utilities.answer_testing.framework import ( + FieldValuesTest, + data_dir_load, + requires_ds, +) _fields = ("particle_position_x", "particle_position_y", "particle_position_z", "particle_mass") diff --git a/yt/frontends/sdf/__init__.py b/yt/frontends/sdf/__init__.py index 0b0b7c6914e..ccdc42900c5 100644 --- a/yt/frontends/sdf/__init__.py +++ b/yt/frontends/sdf/__init__.py @@ -5,4 +5,3 @@ """ - diff --git a/yt/frontends/sdf/api.py b/yt/frontends/sdf/api.py index cb431dd2289..a072588e740 100644 --- a/yt/frontends/sdf/api.py +++ b/yt/frontends/sdf/api.py @@ -1,8 +1,3 @@ -from .data_structures import \ - SDFDataset - -from .io import \ - IOHandlerSDF - -from .fields import \ - SDFFieldInfo +from .data_structures import SDFDataset +from .fields import SDFFieldInfo +from .io import IOHandlerSDF diff --git a/yt/frontends/sdf/data_structures.py b/yt/frontends/sdf/data_structures.py index 50ee7dc9daa..fa7a16f7fe9 100644 --- a/yt/frontends/sdf/data_structures.py +++ b/yt/frontends/sdf/data_structures.py @@ -1,24 +1,18 @@ -import numpy as np +import contextlib import os import sys -import contextlib +import numpy as np + +from yt.data_objects.static_output import ParticleDataset, ParticleFile +from yt.funcs import get_requests, setdefaultattr +from yt.geometry.particle_geometry_handler import ParticleIndex from yt.utilities.logger import ytLogger as mylog -from yt.geometry.particle_geometry_handler import \ - ParticleIndex -from yt.data_objects.static_output import \ - ParticleDataset, \ - ParticleFile -from yt.funcs import \ - get_requests, \ - setdefaultattr -from .fields import \ - SDFFieldInfo -from yt.utilities.sdf import \ - SDFRead,\ - SDFIndex,\ - HTTPSDFRead +from yt.utilities.sdf import HTTPSDFRead, SDFIndex, SDFRead + +from .fields import SDFFieldInfo + @contextlib.contextmanager def safeopen(*args, **kwargs): diff --git a/yt/frontends/sdf/fields.py b/yt/frontends/sdf/fields.py index 2abd0fbe167..bd72c2d0c73 100644 --- a/yt/frontends/sdf/fields.py +++ b/yt/frontends/sdf/fields.py @@ -1,5 +1,4 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer +from yt.fields.field_info_container import FieldInfoContainer class SDFFieldInfo(FieldInfoContainer): @@ -39,5 +38,3 @@ def __init__(self, ds, field_list): (mnf, ('code_mass', ['particle_mass'], None)), ) super(SDFFieldInfo, self).__init__(ds, field_list) - - diff --git a/yt/frontends/sdf/io.py b/yt/frontends/sdf/io.py index b1944b3a425..8bbd32c9278 100644 --- a/yt/frontends/sdf/io.py +++ b/yt/frontends/sdf/io.py @@ -1,10 +1,8 @@ import numpy as np -from yt.utilities.io_handler import \ - BaseIOHandler - from yt.funcs import mylog from yt.utilities.exceptions import YTDomainOverflow +from yt.utilities.io_handler import BaseIOHandler from yt.utilities.lib.geometry_utils import compute_morton CHUNKSIZE = 32**3 @@ -243,4 +241,3 @@ def _identify_fields(self, data_file): class IOHandlerSIndexHTTPSDF(IOHandlerSIndexSDF): _dataset_type = "midx_http_sdf_particles" - diff --git a/yt/frontends/sdf/tests/test_outputs.py b/yt/frontends/sdf/tests/test_outputs.py index 24f0497ef69..7b0e1507826 100644 --- a/yt/frontends/sdf/tests/test_outputs.py +++ b/yt/frontends/sdf/tests/test_outputs.py @@ -1,11 +1,11 @@ -import numpy as np import socket import urllib -from yt.testing import assert_equal + +import numpy as np + from yt.frontends.sdf.api import SDFDataset +from yt.testing import assert_equal, requires_module from yt.visualization.api import ProjectionPlot -from yt.testing import requires_module - _fields = (('deposit', 'all_cic')) slac_scivis_data = "http://darksky.slac.stanford.edu/scivis2015/data/ds14_scivis_0128/ds14_scivis_0128_e4_dt04_1.0000" diff --git a/yt/frontends/sph/__init__.py b/yt/frontends/sph/__init__.py index 377e37fa8ab..a31bfb84985 100644 --- a/yt/frontends/sph/__init__.py +++ b/yt/frontends/sph/__init__.py @@ -5,4 +5,3 @@ """ - diff --git a/yt/frontends/sph/api.py b/yt/frontends/sph/api.py index 8177a1f3f08..d82a2cdab29 100644 --- a/yt/frontends/sph/api.py +++ b/yt/frontends/sph/api.py @@ -5,4 +5,3 @@ """ - diff --git a/yt/frontends/sph/data_structures.py b/yt/frontends/sph/data_structures.py index b2d420b43a2..45df2fc2a1d 100644 --- a/yt/frontends/sph/data_structures.py +++ b/yt/frontends/sph/data_structures.py @@ -1,12 +1,11 @@ -import numpy as np import os -from yt.data_objects.static_output import \ - ParticleDataset -from yt.funcs import \ - mylog -from yt.geometry.particle_geometry_handler import \ - ParticleIndex +import numpy as np + +from yt.data_objects.static_output import ParticleDataset +from yt.funcs import mylog +from yt.geometry.particle_geometry_handler import ParticleIndex + class SPHDataset(ParticleDataset): default_kernel_name = "cubic" diff --git a/yt/frontends/sph/fields.py b/yt/frontends/sph/fields.py index 3bbeb7a3c36..eb8d97defd3 100644 --- a/yt/frontends/sph/fields.py +++ b/yt/frontends/sph/fields.py @@ -1,7 +1,6 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer -from yt.fields.species_fields import \ - setup_species_fields +from yt.fields.field_info_container import FieldInfoContainer +from yt.fields.species_fields import setup_species_fields + class SPHFieldInfo(FieldInfoContainer): known_other_fields = () diff --git a/yt/frontends/sph/io.py b/yt/frontends/sph/io.py index 644dbafb9e3..cc16536bfaa 100644 --- a/yt/frontends/sph/io.py +++ b/yt/frontends/sph/io.py @@ -5,8 +5,8 @@ """ -from yt.utilities.io_handler import \ - BaseIOHandler +from yt.utilities.io_handler import BaseIOHandler + class IOHandlerSPH(BaseIOHandler): """IOHandler implementation specifically for SPH data diff --git a/yt/frontends/stream/api.py b/yt/frontends/stream/api.py index 5b751ee8bc1..c4441a726f8 100644 --- a/yt/frontends/stream/api.py +++ b/yt/frontends/stream/api.py @@ -1,23 +1,17 @@ -from .data_structures import \ - StreamGrid, \ - StreamHierarchy, \ - StreamDataset, \ - StreamHandler, \ - load_uniform_grid, \ - load_amr_grids, \ - load_particles, \ - load_hexahedral_mesh, \ - hexahedral_connectivity, \ - load_octree, \ - refine_amr, \ - load_unstructured_mesh - -from .fields import \ - StreamFieldInfo - -from .io import \ - IOHandlerStream - -from . import tests - -from . import sample_data +from . import sample_data, tests +from .data_structures import ( + StreamDataset, + StreamGrid, + StreamHandler, + StreamHierarchy, + hexahedral_connectivity, + load_amr_grids, + load_hexahedral_mesh, + load_octree, + load_particles, + load_uniform_grid, + load_unstructured_mesh, + refine_amr, +) +from .fields import StreamFieldInfo +from .io import IOHandlerStream diff --git a/yt/frontends/stream/data_structures.py b/yt/frontends/stream/data_structures.py index 5ff99498595..444b8c99e22 100644 --- a/yt/frontends/stream/data_structures.py +++ b/yt/frontends/stream/data_structures.py @@ -1,75 +1,48 @@ import os import time -import weakref -import numpy as np import uuid -from itertools import \ - chain, \ - product, \ - repeat +import weakref from collections import defaultdict - +from itertools import chain, product, repeat from numbers import Number as numeric_type -from yt.utilities.lib.cykdtree import PyKDTree -from yt.funcs import \ - iterable, \ - ensure_list, \ - issue_deprecation_warning +import numpy as np + +from yt.data_objects.field_data import YTFieldData +from yt.data_objects.grid_patch import AMRGridPatch +from yt.data_objects.octree_subset import OctreeSubset +from yt.data_objects.particle_unions import ParticleUnion +from yt.data_objects.static_output import Dataset, ParticleFile +from yt.data_objects.unions import MeshUnion +from yt.data_objects.unstructured_mesh import SemiStructuredMesh, UnstructuredMesh +from yt.frontends.exodus_ii.util import get_num_pseudo_dims +from yt.frontends.sph.data_structures import SPHParticleIndex +from yt.funcs import ensure_list, issue_deprecation_warning, iterable +from yt.geometry.geometry_handler import YTDataChunk +from yt.geometry.grid_container import GridTree, MatchPointsToGrids +from yt.geometry.grid_geometry_handler import GridIndex +from yt.geometry.oct_container import OctreeContainer +from yt.geometry.oct_geometry_handler import OctreeIndex +from yt.geometry.unstructured_mesh_handler import UnstructuredIndex +from yt.units.yt_array import YTQuantity, uconcatenate +from yt.utilities.decompose import decompose_array, get_psize +from yt.utilities.exceptions import ( + YTIllDefinedAMR, + YTInconsistentGridFieldShape, + YTInconsistentGridFieldShapeGridDims, + YTInconsistentParticleFieldShape, +) +from yt.utilities.flagging_methods import FlaggingGrid from yt.utilities.io_handler import io_registry -from yt.data_objects.field_data import \ - YTFieldData -from yt.data_objects.particle_unions import \ - ParticleUnion -from yt.data_objects.grid_patch import \ - AMRGridPatch -from yt.data_objects.static_output import \ - ParticleFile -from yt.frontends.sph.data_structures import \ - SPHParticleIndex -from yt.geometry.geometry_handler import \ - YTDataChunk -from yt.geometry.grid_geometry_handler import \ - GridIndex -from yt.data_objects.octree_subset import \ - OctreeSubset -from yt.geometry.oct_geometry_handler import \ - OctreeIndex -from yt.geometry.oct_container import \ - OctreeContainer -from yt.geometry.unstructured_mesh_handler import \ - UnstructuredIndex -from yt.data_objects.static_output import \ - Dataset +from yt.utilities.lib.cykdtree import PyKDTree +from yt.utilities.lib.misc_utilities import get_box_grids_level +from yt.utilities.lib.particle_kdtree_tools import ( + estimate_density, + generate_smoothing_length, +) from yt.utilities.logger import ytLogger as mylog -from yt.utilities.lib.misc_utilities import \ - get_box_grids_level -from yt.utilities.lib.particle_kdtree_tools import \ - generate_smoothing_length, \ - estimate_density -from yt.geometry.grid_container import \ - GridTree, \ - MatchPointsToGrids -from yt.utilities.decompose import \ - decompose_array, get_psize -from yt.utilities.exceptions import \ - YTIllDefinedAMR, \ - YTInconsistentGridFieldShape, \ - YTInconsistentParticleFieldShape, \ - YTInconsistentGridFieldShapeGridDims -from yt.units.yt_array import \ - YTQuantity, \ - uconcatenate -from yt.utilities.flagging_methods import \ - FlaggingGrid -from yt.data_objects.unstructured_mesh import \ - SemiStructuredMesh, \ - UnstructuredMesh -from .fields import \ - StreamFieldInfo -from yt.frontends.exodus_ii.util import \ - get_num_pseudo_dims -from yt.data_objects.unions import MeshUnion + +from .fields import StreamFieldInfo class StreamGrid(AMRGridPatch): diff --git a/yt/frontends/stream/fields.py b/yt/frontends/stream/fields.py index 8c43a8027e1..cffeb150352 100644 --- a/yt/frontends/stream/fields.py +++ b/yt/frontends/stream/fields.py @@ -1,5 +1,4 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer +from yt.fields.field_info_container import FieldInfoContainer class StreamFieldInfo(FieldInfoContainer): diff --git a/yt/frontends/stream/io.py b/yt/frontends/stream/io.py index 70717a4d142..0f5b72c45e6 100644 --- a/yt/frontends/stream/io.py +++ b/yt/frontends/stream/io.py @@ -1,9 +1,9 @@ import numpy as np -from yt.utilities.io_handler import \ - BaseIOHandler -from yt.utilities.logger import ytLogger as mylog from yt.utilities.exceptions import YTDomainOverflow +from yt.utilities.io_handler import BaseIOHandler +from yt.utilities.logger import ytLogger as mylog + class IOHandlerStream(BaseIOHandler): @@ -286,4 +286,3 @@ def _read_fluid_selection(self, chunks, selector, fields, size): ind += g.select(selector, ds, rv[field], ind) # caches rv[field] = rv[field][:ind] return rv - diff --git a/yt/frontends/stream/tests/test_outputs.py b/yt/frontends/stream/tests/test_outputs.py index a3c561aaceb..3b3e1fdad1b 100644 --- a/yt/frontends/stream/tests/test_outputs.py +++ b/yt/frontends/stream/tests/test_outputs.py @@ -1,20 +1,20 @@ -import numpy as np import os import shutil import tempfile import unittest -from yt.frontends.stream.data_structures import load_uniform_grid, \ - load_particles -from yt.testing import \ - assert_equal, \ - assert_raises +import numpy as np + from yt.convenience import load -from yt.utilities.exceptions import \ - YTOutputNotIdentified, \ - YTInconsistentGridFieldShape, \ - YTInconsistentParticleFieldShape, \ - YTInconsistentGridFieldShapeGridDims +from yt.frontends.stream.data_structures import load_particles, load_uniform_grid +from yt.testing import assert_equal, assert_raises +from yt.utilities.exceptions import ( + YTInconsistentGridFieldShape, + YTInconsistentGridFieldShapeGridDims, + YTInconsistentParticleFieldShape, + YTOutputNotIdentified, +) + class TestEmptyLoad(unittest.TestCase): diff --git a/yt/frontends/stream/tests/test_stream_amrgrids.py b/yt/frontends/stream/tests/test_stream_amrgrids.py index 798a02b41dc..ff8d3a84bbd 100644 --- a/yt/frontends/stream/tests/test_stream_amrgrids.py +++ b/yt/frontends/stream/tests/test_stream_amrgrids.py @@ -1,11 +1,9 @@ import numpy as np -from yt.utilities.exceptions import \ - YTIllDefinedAMR, \ - YTIntDomainOverflow - -from yt import load_amr_grids, ProjectionPlot +from yt import ProjectionPlot, load_amr_grids from yt.testing import assert_raises +from yt.utilities.exceptions import YTIllDefinedAMR, YTIntDomainOverflow + def test_qt_overflow(): grid_data = [] diff --git a/yt/frontends/stream/tests/test_stream_hexahedral.py b/yt/frontends/stream/tests/test_stream_hexahedral.py index 4816139a730..1365dd68f21 100644 --- a/yt/frontends/stream/tests/test_stream_hexahedral.py +++ b/yt/frontends/stream/tests/test_stream_hexahedral.py @@ -1,12 +1,10 @@ import numpy as np -from yt.frontends.stream.api import \ - load_hexahedral_mesh -from yt.frontends.stream.data_structures import \ - hexahedral_connectivity -from yt.testing import \ - assert_almost_equal, \ - assert_equal + from yt import SlicePlot +from yt.frontends.stream.api import load_hexahedral_mesh +from yt.frontends.stream.data_structures import hexahedral_connectivity +from yt.testing import assert_almost_equal, assert_equal + # Field information def test_stream_hexahedral() : diff --git a/yt/frontends/stream/tests/test_stream_octree.py b/yt/frontends/stream/tests/test_stream_octree.py index 0f88a1821dc..a4cbd2a4056 100644 --- a/yt/frontends/stream/tests/test_stream_octree.py +++ b/yt/frontends/stream/tests/test_stream_octree.py @@ -1,6 +1,7 @@ -import yt import numpy as np +import yt + OCT_MASK_LIST = [8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, diff --git a/yt/frontends/stream/tests/test_stream_particles.py b/yt/frontends/stream/tests/test_stream_particles.py index cfc5336eebe..8bb4c874df5 100644 --- a/yt/frontends/stream/tests/test_stream_particles.py +++ b/yt/frontends/stream/tests/test_stream_particles.py @@ -1,15 +1,14 @@ import numpy as np -from yt.testing import \ - assert_equal, \ - fake_particle_ds, \ - fake_sph_orientation_ds -from yt.frontends.stream.api import load_uniform_grid, \ - refine_amr, \ - load_amr_grids, \ - load_particles -import yt.utilities.initial_conditions as ic import yt.utilities.flagging_methods as fm +import yt.utilities.initial_conditions as ic +from yt.frontends.stream.api import ( + load_amr_grids, + load_particles, + load_uniform_grid, + refine_amr, +) +from yt.testing import assert_equal, fake_particle_ds, fake_sph_orientation_ds # Field information diff --git a/yt/frontends/stream/tests/test_stream_unstructured.py b/yt/frontends/stream/tests/test_stream_unstructured.py index 5feecedc60c..8e3bee46dc2 100644 --- a/yt/frontends/stream/tests/test_stream_unstructured.py +++ b/yt/frontends/stream/tests/test_stream_unstructured.py @@ -1,6 +1,7 @@ import numpy as np -from yt import load_unstructured_mesh, SlicePlot +from yt import SlicePlot, load_unstructured_mesh + def test_multi_mesh(): coordsMulti = np.array([[0.0, 0.0], diff --git a/yt/frontends/stream/tests/test_update_data.py b/yt/frontends/stream/tests/test_update_data.py index 195031ab9f4..eb58a440a9c 100644 --- a/yt/frontends/stream/tests/test_update_data.py +++ b/yt/frontends/stream/tests/test_update_data.py @@ -1,8 +1,8 @@ import numpy as np -from yt.testing import \ - fake_particle_ds, \ - fake_random_ds + from yt.data_objects.profiles import create_profile +from yt.testing import fake_particle_ds, fake_random_ds + def test_update_data_grid(): ds = fake_random_ds(64, nprocs=8) diff --git a/yt/frontends/swift/api.py b/yt/frontends/swift/api.py index 960d56cdf62..607c3e6787d 100644 --- a/yt/frontends/swift/api.py +++ b/yt/frontends/swift/api.py @@ -1,10 +1,5 @@ -from .data_structures import \ - SwiftDataset - -from yt.frontends.sph.fields import \ - SPHFieldInfo - -from .io import \ - IOHandlerSwift +from yt.frontends.sph.fields import SPHFieldInfo from . import tests +from .data_structures import SwiftDataset +from .io import IOHandlerSwift diff --git a/yt/frontends/swift/data_structures.py b/yt/frontends/swift/data_structures.py index d56360dc157..47917407d59 100644 --- a/yt/frontends/swift/data_structures.py +++ b/yt/frontends/swift/data_structures.py @@ -1,15 +1,14 @@ -import numpy as np -from yt.utilities.on_demand_imports import _h5py as h5py from uuid import uuid4 -from yt.utilities.logger import ytLogger as mylog -from yt.frontends.sph.data_structures import \ - SPHDataset, \ - SPHParticleIndex +import numpy as np + +from yt.data_objects.static_output import ParticleFile +from yt.frontends.sph.data_structures import SPHDataset, SPHParticleIndex from yt.frontends.sph.fields import SPHFieldInfo -from yt.data_objects.static_output import \ - ParticleFile from yt.funcs import only_on_root +from yt.utilities.logger import ytLogger as mylog +from yt.utilities.on_demand_imports import _h5py as h5py + class SwiftDataset(SPHDataset): _index_class = SPHParticleIndex diff --git a/yt/frontends/swift/io.py b/yt/frontends/swift/io.py index 54a529d85d6..401f84b07e2 100644 --- a/yt/frontends/swift/io.py +++ b/yt/frontends/swift/io.py @@ -1,8 +1,8 @@ -from yt.utilities.on_demand_imports import _h5py as h5py import numpy as np -from yt.frontends.sph.io import \ - IOHandlerSPH +from yt.frontends.sph.io import IOHandlerSPH +from yt.utilities.on_demand_imports import _h5py as h5py + class IOHandlerSwift(IOHandlerSPH): _dataset_type = "swift" diff --git a/yt/frontends/swift/tests/test_outputs.py b/yt/frontends/swift/tests/test_outputs.py index a358e97b411..e0a8846a009 100644 --- a/yt/frontends/swift/tests/test_outputs.py +++ b/yt/frontends/swift/tests/test_outputs.py @@ -1,10 +1,8 @@ -from yt import load - import numpy as np -from yt.testing import requires_file +from yt import load from yt.frontends.swift.api import SwiftDataset -from yt.testing import assert_almost_equal, ParticleSelectionComparison +from yt.testing import ParticleSelectionComparison, assert_almost_equal, requires_file from yt.utilities.on_demand_imports import _h5py as h5py keplerian_ring = "KeplerianRing/keplerian_ring_0020.hdf5" diff --git a/yt/frontends/tipsy/api.py b/yt/frontends/tipsy/api.py index a0fd0ad2986..58fe586cf18 100644 --- a/yt/frontends/tipsy/api.py +++ b/yt/frontends/tipsy/api.py @@ -1,10 +1,4 @@ -from .data_structures import \ - TipsyDataset - -from .fields import \ - TipsyFieldInfo - -from .io import \ - IOHandlerTipsyBinary - from . import tests +from .data_structures import TipsyDataset +from .fields import TipsyFieldInfo +from .io import IOHandlerTipsyBinary diff --git a/yt/frontends/tipsy/data_structures.py b/yt/frontends/tipsy/data_structures.py index fac6addd0b7..77d3e9c757c 100644 --- a/yt/frontends/tipsy/data_structures.py +++ b/yt/frontends/tipsy/data_structures.py @@ -1,25 +1,19 @@ -import numpy as np -import struct import glob import os +import struct +import sys -from yt.frontends.sph.data_structures import \ - SPHDataset, \ - SPHParticleIndex +import numpy as np + +from yt.data_objects.static_output import ParticleFile +from yt.frontends.sph.data_structures import SPHDataset, SPHParticleIndex from yt.funcs import deprecate -from yt.data_objects.static_output import \ - ParticleFile -from yt.utilities.cosmology import \ - Cosmology -from yt.utilities.physical_constants import \ - G -from yt.utilities.physical_ratios import \ - cm_per_kpc - -from .fields import \ - TipsyFieldInfo +from yt.utilities.cosmology import Cosmology +from yt.utilities.physical_constants import G +from yt.utilities.physical_ratios import cm_per_kpc + +from .fields import TipsyFieldInfo -import sys if sys.version_info > (3,): long = int diff --git a/yt/frontends/tipsy/fields.py b/yt/frontends/tipsy/fields.py index 2cfd0c04a20..35aa54ac6b9 100644 --- a/yt/frontends/tipsy/fields.py +++ b/yt/frontends/tipsy/fields.py @@ -1,5 +1,6 @@ from yt.frontends.sph.fields import SPHFieldInfo + class TipsyFieldInfo(SPHFieldInfo): known_particle_fields = SPHFieldInfo.known_particle_fields + \ (("smoothing_length", ("code_length", [], None)),) diff --git a/yt/frontends/tipsy/io.py b/yt/frontends/tipsy/io.py index 11dcceffce8..dce5d2f1c77 100644 --- a/yt/frontends/tipsy/io.py +++ b/yt/frontends/tipsy/io.py @@ -1,19 +1,15 @@ import glob -import numpy as np -from numpy.lib.recfunctions import append_fields import os import struct -from yt.geometry.particle_geometry_handler import \ - CHUNKSIZE -from yt.frontends.sph.io import \ - IOHandlerSPH -from yt.frontends.tipsy.definitions import \ - npart_mapping -from yt.utilities.lib.particle_kdtree_tools import \ - generate_smoothing_length -from yt.utilities.logger import ytLogger as \ - mylog +import numpy as np +from numpy.lib.recfunctions import append_fields + +from yt.frontends.sph.io import IOHandlerSPH +from yt.frontends.tipsy.definitions import npart_mapping +from yt.geometry.particle_geometry_handler import CHUNKSIZE +from yt.utilities.lib.particle_kdtree_tools import generate_smoothing_length +from yt.utilities.logger import ytLogger as mylog class IOHandlerTipsyBinary(IOHandlerSPH): diff --git a/yt/frontends/tipsy/tests/test_outputs.py b/yt/frontends/tipsy/tests/test_outputs.py index 146615c8cd0..0a7979c5624 100644 --- a/yt/frontends/tipsy/tests/test_outputs.py +++ b/yt/frontends/tipsy/tests/test_outputs.py @@ -1,14 +1,13 @@ from collections import OrderedDict -from yt.testing import \ - requires_file, \ - ParticleSelectionComparison -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - data_dir_load, \ - sph_answer, \ - nbody_answer from yt.frontends.tipsy.api import TipsyDataset +from yt.testing import ParticleSelectionComparison, requires_file +from yt.utilities.answer_testing.framework import ( + data_dir_load, + nbody_answer, + requires_ds, + sph_answer, +) _fields = OrderedDict( [ diff --git a/yt/frontends/ytdata/__init__.py b/yt/frontends/ytdata/__init__.py index 7cccc849a5c..5189c98ee97 100644 --- a/yt/frontends/ytdata/__init__.py +++ b/yt/frontends/ytdata/__init__.py @@ -5,4 +5,3 @@ """ - diff --git a/yt/frontends/ytdata/api.py b/yt/frontends/ytdata/api.py index a7fdf936854..28fdb04a96d 100644 --- a/yt/frontends/ytdata/api.py +++ b/yt/frontends/ytdata/api.py @@ -1,27 +1,22 @@ -from .data_structures import \ - YTDataContainerDataset, \ - YTSpatialPlotDataset, \ - YTGridDataset, \ - YTGridHierarchy, \ - YTGrid, \ - YTNonspatialDataset, \ - YTNonspatialHierarchy, \ - YTNonspatialGrid, \ - YTProfileDataset, \ - YTClumpContainer, \ - YTClumpTreeDataset - -from .io import \ - IOHandlerYTDataContainerHDF5, \ - IOHandlerYTGridHDF5, \ - IOHandlerYTSpatialPlotHDF5, \ - IOHandlerYTNonspatialhdf5 - -from .fields import \ - YTDataContainerFieldInfo, \ - YTGridFieldInfo - -from .utilities import \ - save_as_dataset - from . import tests +from .data_structures import ( + YTClumpContainer, + YTClumpTreeDataset, + YTDataContainerDataset, + YTGrid, + YTGridDataset, + YTGridHierarchy, + YTNonspatialDataset, + YTNonspatialGrid, + YTNonspatialHierarchy, + YTProfileDataset, + YTSpatialPlotDataset, +) +from .fields import YTDataContainerFieldInfo, YTGridFieldInfo +from .io import ( + IOHandlerYTDataContainerHDF5, + IOHandlerYTGridHDF5, + IOHandlerYTNonspatialhdf5, + IOHandlerYTSpatialPlotHDF5, +) +from .utilities import save_as_dataset diff --git a/yt/frontends/ytdata/data_structures.py b/yt/frontends/ytdata/data_structures.py index 88b91f4f0cc..f4785ecdd24 100644 --- a/yt/frontends/ytdata/data_structures.py +++ b/yt/frontends/ytdata/data_structures.py @@ -1,55 +1,33 @@ -from collections import \ - defaultdict -from numbers import \ - Number as numeric_type -import numpy as np import os import weakref +from collections import defaultdict +from numbers import Number as numeric_type + +import numpy as np -from .fields import \ - YTDataContainerFieldInfo, \ - YTGridFieldInfo - -from yt.data_objects.grid_patch import \ - AMRGridPatch -from yt.data_objects.particle_unions import \ - ParticleUnion -from yt.data_objects.profiles import \ - Profile1DFromDataset, \ - Profile2DFromDataset, \ - Profile3DFromDataset -from yt.data_objects.static_output import \ - Dataset, \ - ParticleFile, \ - validate_index_order -from yt.funcs import \ - is_root, \ - parse_h5_attr -from yt.geometry.grid_geometry_handler import \ - GridIndex -from yt.geometry.particle_geometry_handler import \ - ParticleIndex -from yt.units import \ - dimensions -from yt.units.unit_registry import \ - UnitRegistry -from yt.units.yt_array import \ - uconcatenate, \ - YTQuantity -from yt.utilities.logger import \ - ytLogger as mylog -from yt.utilities.exceptions import \ - YTFieldTypeNotFound -from yt.utilities.on_demand_imports import \ - _h5py as h5py -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - parallel_root_only -from yt.utilities.tree_container import \ - TreeContainer -from yt.fields.field_exceptions import \ - NeedsGridType -from yt.data_objects.data_containers import \ - GenerationInProgress +from yt.data_objects.data_containers import GenerationInProgress +from yt.data_objects.grid_patch import AMRGridPatch +from yt.data_objects.particle_unions import ParticleUnion +from yt.data_objects.profiles import ( + Profile1DFromDataset, + Profile2DFromDataset, + Profile3DFromDataset, +) +from yt.data_objects.static_output import Dataset, ParticleFile, validate_index_order +from yt.fields.field_exceptions import NeedsGridType +from yt.funcs import is_root, parse_h5_attr +from yt.geometry.grid_geometry_handler import GridIndex +from yt.geometry.particle_geometry_handler import ParticleIndex +from yt.units import dimensions +from yt.units.unit_registry import UnitRegistry +from yt.units.yt_array import YTQuantity, uconcatenate +from yt.utilities.exceptions import YTFieldTypeNotFound +from yt.utilities.logger import ytLogger as mylog +from yt.utilities.on_demand_imports import _h5py as h5py +from yt.utilities.parallel_tools.parallel_analysis_interface import parallel_root_only +from yt.utilities.tree_container import TreeContainer + +from .fields import YTDataContainerFieldInfo, YTGridFieldInfo _grid_data_containers = ["arbitrary_grid", "covering_grid", diff --git a/yt/frontends/ytdata/fields.py b/yt/frontends/ytdata/fields.py index 2ecb400e2ed..9d7116d3c43 100644 --- a/yt/frontends/ytdata/fields.py +++ b/yt/frontends/ytdata/fields.py @@ -1,6 +1,5 @@ -from yt.fields.field_info_container import \ - FieldInfoContainer +from yt.fields.field_info_container import FieldInfoContainer m_units = "g" p_units = "cm" diff --git a/yt/frontends/ytdata/io.py b/yt/frontends/ytdata/io.py index 2ad30b9ef3d..5c1076cc6f0 100644 --- a/yt/frontends/ytdata/io.py +++ b/yt/frontends/ytdata/io.py @@ -1,20 +1,13 @@ import numpy as np -from yt.funcs import \ - mylog, \ - parse_h5_attr -from yt.geometry.selection_routines import \ - GridSelector -from yt.units.yt_array import \ - uvstack -from yt.utilities.exceptions import \ - YTDomainOverflow -from yt.utilities.io_handler import \ - BaseIOHandler -from yt.utilities.lib.geometry_utils import \ - compute_morton -from yt.utilities.on_demand_imports import \ - _h5py as h5py +from yt.funcs import mylog, parse_h5_attr +from yt.geometry.selection_routines import GridSelector +from yt.units.yt_array import uvstack +from yt.utilities.exceptions import YTDomainOverflow +from yt.utilities.io_handler import BaseIOHandler +from yt.utilities.lib.geometry_utils import compute_morton +from yt.utilities.on_demand_imports import _h5py as h5py + class IOHandlerYTNonspatialhdf5(BaseIOHandler): _dataset_type = "ytnonspatialhdf5" diff --git a/yt/frontends/ytdata/tests/test_old_outputs.py b/yt/frontends/ytdata/tests/test_old_outputs.py index 60c384ffdb6..55ee895ea60 100644 --- a/yt/frontends/ytdata/tests/test_old_outputs.py +++ b/yt/frontends/ytdata/tests/test_old_outputs.py @@ -13,38 +13,35 @@ # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- -from yt.data_objects.api import \ - create_profile -from yt.frontends.ytdata.api import \ - YTDataContainerDataset, \ - YTSpatialPlotDataset, \ - YTGridDataset, \ - YTNonspatialDataset, \ - YTProfileDataset -from yt.frontends.ytdata.tests.test_outputs import \ - compare_unit_attributes, \ - YTDataFieldTest -from yt.testing import \ - assert_allclose_units, \ - assert_array_equal, \ - assert_fname, \ - requires_file, \ - requires_module -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - data_dir_load -from yt.units.yt_array import \ - YTArray -from yt.visualization.plot_window import \ - SlicePlot, \ - ProjectionPlot -from yt.visualization.profile_plotter import \ - ProfilePlot, \ - PhasePlot -import numpy as np -import tempfile import os import shutil +import tempfile + +import numpy as np + +from yt.data_objects.api import create_profile +from yt.frontends.ytdata.api import ( + YTDataContainerDataset, + YTGridDataset, + YTNonspatialDataset, + YTProfileDataset, + YTSpatialPlotDataset, +) +from yt.frontends.ytdata.tests.test_outputs import ( + YTDataFieldTest, + compare_unit_attributes, +) +from yt.testing import ( + assert_allclose_units, + assert_array_equal, + assert_fname, + requires_file, + requires_module, +) +from yt.units.yt_array import YTArray +from yt.utilities.answer_testing.framework import data_dir_load, requires_ds +from yt.visualization.plot_window import ProjectionPlot, SlicePlot +from yt.visualization.profile_plotter import PhasePlot, ProfilePlot enzotiny = "enzo_tiny_cosmology/DD0046/DD0046" ytdata_dir = "ytdata_test" diff --git a/yt/frontends/ytdata/tests/test_outputs.py b/yt/frontends/ytdata/tests/test_outputs.py index 311720d1b4e..f536f542995 100644 --- a/yt/frontends/ytdata/tests/test_outputs.py +++ b/yt/frontends/ytdata/tests/test_outputs.py @@ -1,38 +1,36 @@ -from yt.convenience import \ - load -from yt.data_objects.api import \ - create_profile -from yt.frontends.ytdata.api import \ - YTDataContainerDataset, \ - YTSpatialPlotDataset, \ - YTGridDataset, \ - YTNonspatialDataset, \ - YTProfileDataset, \ - save_as_dataset -from yt.testing import \ - assert_array_equal, \ - assert_allclose_units, \ - assert_equal, \ - assert_fname, \ - fake_random_ds, \ - requires_module -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - data_dir_load, \ - AnswerTestingTest -from yt.units.yt_array import \ - YTArray, \ - YTQuantity -from yt.visualization.plot_window import \ - SlicePlot, \ - ProjectionPlot -from yt.visualization.profile_plotter import \ - ProfilePlot, \ - PhasePlot -import numpy as np -import tempfile import os import shutil +import tempfile + +import numpy as np + +from yt.convenience import load +from yt.data_objects.api import create_profile +from yt.frontends.ytdata.api import ( + YTDataContainerDataset, + YTGridDataset, + YTNonspatialDataset, + YTProfileDataset, + YTSpatialPlotDataset, + save_as_dataset, +) +from yt.testing import ( + assert_allclose_units, + assert_array_equal, + assert_equal, + assert_fname, + fake_random_ds, + requires_module, +) +from yt.units.yt_array import YTArray, YTQuantity +from yt.utilities.answer_testing.framework import ( + AnswerTestingTest, + data_dir_load, + requires_ds, +) +from yt.visualization.plot_window import ProjectionPlot, SlicePlot +from yt.visualization.profile_plotter import PhasePlot, ProfilePlot + def make_tempdir(): if int(os.environ.get('GENERATE_YTDATA', 0)): diff --git a/yt/frontends/ytdata/utilities.py b/yt/frontends/ytdata/utilities.py index c72e464ed70..e92a05fb07d 100644 --- a/yt/frontends/ytdata/utilities.py +++ b/yt/frontends/ytdata/utilities.py @@ -1,9 +1,7 @@ -from yt.units.yt_array import \ - YTArray -from yt.utilities.logger import \ - ytLogger as mylog -from yt.utilities.on_demand_imports import \ - _h5py as h5py +from yt.units.yt_array import YTArray +from yt.utilities.logger import ytLogger as mylog +from yt.utilities.on_demand_imports import _h5py as h5py + def save_as_dataset(ds, filename, data, field_types=None, extra_attrs=None): diff --git a/yt/funcs.py b/yt/funcs.py index 31ecf4122a8..fa3a7c826d7 100644 --- a/yt/funcs.py +++ b/yt/funcs.py @@ -1,35 +1,35 @@ -import errno +import base64 import builtins +import contextlib import copy -import time +import errno +import getpass +import glob import inspect -import traceback -import sys -import pdb +import itertools import os +import pdb import re -import contextlib -import warnings import struct import subprocess -import numpy as np -import itertools -import base64 -import numpy -import matplotlib -import getpass -import glob -from math import floor, ceil +import sys +import time +import traceback +import urllib.parse +import urllib.request +import warnings +from functools import wraps +from math import ceil, floor from numbers import Number as numeric_type -import urllib.request -import urllib.parse -from yt.utilities.logger import ytLogger as mylog -from yt.utilities.lru_cache import lru_cache -from yt.utilities.exceptions import YTInvalidWidthError +import matplotlib +import numpy as np + from yt.extern.tqdm import tqdm from yt.units import YTArray, YTQuantity -from functools import wraps +from yt.utilities.exceptions import YTInvalidWidthError +from yt.utilities.logger import ytLogger as mylog +from yt.utilities.lru_cache import lru_cache # Some functions for handling sequences and other types diff --git a/yt/geometry/api.py b/yt/geometry/api.py index 4adeee23510..4c001731bdf 100644 --- a/yt/geometry/api.py +++ b/yt/geometry/api.py @@ -1,5 +1,2 @@ -from .geometry_handler import \ - Index - -from .grid_geometry_handler import \ - GridIndex +from .geometry_handler import Index +from .grid_geometry_handler import GridIndex diff --git a/yt/geometry/coordinates/api.py b/yt/geometry/coordinates/api.py index 5a3c0f9c6b9..153c397dcf5 100644 --- a/yt/geometry/coordinates/api.py +++ b/yt/geometry/coordinates/api.py @@ -1,17 +1,10 @@ -from .coordinate_handler import \ - CoordinateHandler - -from .cartesian_coordinates import \ - CartesianCoordinateHandler -from .polar_coordinates import \ - PolarCoordinateHandler -from .cylindrical_coordinates import \ - CylindricalCoordinateHandler -from .spherical_coordinates import \ - SphericalCoordinateHandler -from .geographic_coordinates import \ - GeographicCoordinateHandler, \ - InternalGeographicCoordinateHandler -from .spec_cube_coordinates import \ - SpectralCubeCoordinateHandler - +from .cartesian_coordinates import CartesianCoordinateHandler +from .coordinate_handler import CoordinateHandler +from .cylindrical_coordinates import CylindricalCoordinateHandler +from .geographic_coordinates import ( + GeographicCoordinateHandler, + InternalGeographicCoordinateHandler, +) +from .polar_coordinates import PolarCoordinateHandler +from .spec_cube_coordinates import SpectralCubeCoordinateHandler +from .spherical_coordinates import SphericalCoordinateHandler diff --git a/yt/geometry/coordinates/cartesian_coordinates.py b/yt/geometry/coordinates/cartesian_coordinates.py index 40e3364e780..eba9067bfb5 100644 --- a/yt/geometry/coordinates/cartesian_coordinates.py +++ b/yt/geometry/coordinates/cartesian_coordinates.py @@ -1,24 +1,28 @@ import numpy as np -from .coordinate_handler import \ - CoordinateHandler, \ - _get_coord_fields, \ - _get_vert_fields, \ - cartesian_to_cylindrical, \ - cylindrical_to_cartesian -from yt.funcs import mylog -from yt.units.yt_array import uvstack, YTArray -from yt.utilities.lib.pixelization_routines import \ - pixelize_element_mesh, pixelize_off_axis_cartesian, \ - pixelize_cartesian, \ - pixelize_cartesian_nodal, \ - pixelize_sph_kernel_slice, \ - pixelize_sph_kernel_projection, \ - pixelize_element_mesh_line, \ - interpolate_sph_grid_gather, \ - normalization_2d_utility + from yt.data_objects.unstructured_mesh import SemiStructuredMesh +from yt.funcs import mylog +from yt.units.yt_array import YTArray, uconcatenate, uvstack +from yt.utilities.lib.pixelization_routines import ( + interpolate_sph_grid_gather, + normalization_2d_utility, + pixelize_cartesian, + pixelize_cartesian_nodal, + pixelize_element_mesh, + pixelize_element_mesh_line, + pixelize_off_axis_cartesian, + pixelize_sph_kernel_projection, + pixelize_sph_kernel_slice, +) from yt.utilities.nodal_data_utils import get_nodal_data -from yt.units.yt_array import uconcatenate + +from .coordinate_handler import ( + CoordinateHandler, + _get_coord_fields, + _get_vert_fields, + cartesian_to_cylindrical, + cylindrical_to_cartesian, +) def _sample_ray(ray, npoints, field): diff --git a/yt/geometry/coordinates/coordinate_handler.py b/yt/geometry/coordinates/coordinate_handler.py index d5521e804ac..0e9f2754b2c 100644 --- a/yt/geometry/coordinates/coordinate_handler.py +++ b/yt/geometry/coordinates/coordinate_handler.py @@ -1,16 +1,12 @@ -import numpy as np import weakref from numbers import Number -from yt.funcs import \ - validate_width_tuple, \ - fix_unitary, \ - iterable -from yt.units.yt_array import \ - YTArray, YTQuantity -from yt.utilities.exceptions import \ - YTCoordinateNotImplemented, \ - YTInvalidWidthError +import numpy as np + +from yt.funcs import fix_unitary, iterable, validate_width_tuple +from yt.units.yt_array import YTArray, YTQuantity +from yt.utilities.exceptions import YTCoordinateNotImplemented, YTInvalidWidthError + def _unknown_coord(field, data): raise YTCoordinateNotImplemented diff --git a/yt/geometry/coordinates/cylindrical_coordinates.py b/yt/geometry/coordinates/cylindrical_coordinates.py index ac5471fa07f..ed5adbd4402 100644 --- a/yt/geometry/coordinates/cylindrical_coordinates.py +++ b/yt/geometry/coordinates/cylindrical_coordinates.py @@ -1,12 +1,15 @@ import numpy as np -from .coordinate_handler import \ - CoordinateHandler, \ - _unknown_coord, \ - _get_coord_fields, \ - cylindrical_to_cartesian, \ - cartesian_to_cylindrical -from yt.utilities.lib.pixelization_routines import \ - pixelize_cartesian, pixelize_cylinder + +from yt.utilities.lib.pixelization_routines import pixelize_cartesian, pixelize_cylinder + +from .coordinate_handler import ( + CoordinateHandler, + _get_coord_fields, + _unknown_coord, + cartesian_to_cylindrical, + cylindrical_to_cartesian, +) + # # Cylindrical fields # diff --git a/yt/geometry/coordinates/geographic_coordinates.py b/yt/geometry/coordinates/geographic_coordinates.py index 0413d7d3ebe..60f2ea9eddf 100644 --- a/yt/geometry/coordinates/geographic_coordinates.py +++ b/yt/geometry/coordinates/geographic_coordinates.py @@ -1,10 +1,9 @@ import numpy as np -from .coordinate_handler import \ - CoordinateHandler, \ - _unknown_coord, \ - _get_coord_fields -from yt.utilities.lib.pixelization_routines import \ - pixelize_cylinder, pixelize_cartesian + +from yt.utilities.lib.pixelization_routines import pixelize_cartesian, pixelize_cylinder + +from .coordinate_handler import CoordinateHandler, _get_coord_fields, _unknown_coord + class GeographicCoordinateHandler(CoordinateHandler): radial_axis = "altitude" @@ -492,4 +491,3 @@ def sanitize_width(self, axis, width, depth): outermost = factor * self.ds.domain_left_edge[ri] + offset width = [outermost, 2.0*outermost] return width - diff --git a/yt/geometry/coordinates/spec_cube_coordinates.py b/yt/geometry/coordinates/spec_cube_coordinates.py index c162cdab079..45ba3070880 100644 --- a/yt/geometry/coordinates/spec_cube_coordinates.py +++ b/yt/geometry/coordinates/spec_cube_coordinates.py @@ -1,7 +1,6 @@ -from .cartesian_coordinates import \ - CartesianCoordinateHandler -from .coordinate_handler import \ - _get_coord_fields +from .cartesian_coordinates import CartesianCoordinateHandler +from .coordinate_handler import _get_coord_fields + class SpectralCubeCoordinateHandler(CartesianCoordinateHandler): name = "spectral_cube" @@ -100,4 +99,3 @@ def convert_from_cylindrical(self, coord): @property def image_axis_name(self): return self._image_axis_name - diff --git a/yt/geometry/coordinates/spherical_coordinates.py b/yt/geometry/coordinates/spherical_coordinates.py index c8e4498b205..867dc251c66 100644 --- a/yt/geometry/coordinates/spherical_coordinates.py +++ b/yt/geometry/coordinates/spherical_coordinates.py @@ -1,10 +1,9 @@ import numpy as np -from .coordinate_handler import \ - CoordinateHandler, \ - _unknown_coord, \ - _get_coord_fields -from yt.utilities.lib.pixelization_routines import \ - pixelize_cylinder, pixelize_aitoff + +from yt.utilities.lib.pixelization_routines import pixelize_aitoff, pixelize_cylinder + +from .coordinate_handler import CoordinateHandler, _get_coord_fields, _unknown_coord + class SphericalCoordinateHandler(CoordinateHandler): name = "spherical" @@ -286,4 +285,3 @@ def _sanity_check(self): v2 = dd.quantities.total_quantity("cell_volume") print("Actual volume is %0.16e" % (v2)) print("Relative difference: %0.16e" % (np.abs(v2-v1)/(v2+v1))) - diff --git a/yt/geometry/coordinates/tests/test_axial_pixelization.py b/yt/geometry/coordinates/tests/test_axial_pixelization.py index 81c9186091a..fac56abe26f 100644 --- a/yt/geometry/coordinates/tests/test_axial_pixelization.py +++ b/yt/geometry/coordinates/tests/test_axial_pixelization.py @@ -1,7 +1,6 @@ -from yt.testing import \ - fake_amr_ds, _geom_transforms -from yt.utilities.answer_testing.framework import \ - AxialPixelizationTest +from yt.testing import _geom_transforms, fake_amr_ds +from yt.utilities.answer_testing.framework import AxialPixelizationTest + def test_axial_pixelization(): for geom in sorted(_geom_transforms): diff --git a/yt/geometry/coordinates/tests/test_cartesian_coordinates.py b/yt/geometry/coordinates/tests/test_cartesian_coordinates.py index 5fe43cb20f1..805e9b26cfa 100644 --- a/yt/geometry/coordinates/tests/test_cartesian_coordinates.py +++ b/yt/geometry/coordinates/tests/test_cartesian_coordinates.py @@ -2,9 +2,7 @@ import numpy as np -from yt.testing import \ - fake_amr_ds, \ - assert_equal +from yt.testing import assert_equal, fake_amr_ds # Our canonical tests are that we can access all of our fields and we can # compute our volume correctly. diff --git a/yt/geometry/coordinates/tests/test_cylindrical_coordinates.py b/yt/geometry/coordinates/tests/test_cylindrical_coordinates.py index 4983526b784..fdfec6c3825 100644 --- a/yt/geometry/coordinates/tests/test_cylindrical_coordinates.py +++ b/yt/geometry/coordinates/tests/test_cylindrical_coordinates.py @@ -2,14 +2,9 @@ import numpy as np -from yt.testing import \ - fake_amr_ds, \ - assert_equal, \ - assert_almost_equal, \ - add_noise_fields - -from yt.utilities.answer_testing.framework import GenericImageTest from yt import SlicePlot +from yt.testing import add_noise_fields, assert_almost_equal, assert_equal, fake_amr_ds +from yt.utilities.answer_testing.framework import GenericImageTest # Our canonical tests are that we can access all of our fields and we can # compute our volume correctly. diff --git a/yt/geometry/coordinates/tests/test_geographic_coordinates.py b/yt/geometry/coordinates/tests/test_geographic_coordinates.py index 7b71dd35753..46a574914bc 100644 --- a/yt/geometry/coordinates/tests/test_geographic_coordinates.py +++ b/yt/geometry/coordinates/tests/test_geographic_coordinates.py @@ -2,10 +2,7 @@ import numpy as np -from yt.testing import \ - fake_amr_ds, \ - assert_equal, \ - assert_rel_equal +from yt.testing import assert_equal, assert_rel_equal, fake_amr_ds # Our canonical tests are that we can access all of our fields and we can # compute our volume correctly. diff --git a/yt/geometry/coordinates/tests/test_polar_coordinates.py b/yt/geometry/coordinates/tests/test_polar_coordinates.py index 5356f7b9adb..97f1738995f 100644 --- a/yt/geometry/coordinates/tests/test_polar_coordinates.py +++ b/yt/geometry/coordinates/tests/test_polar_coordinates.py @@ -3,10 +3,7 @@ import numpy as np -from yt.testing import \ - fake_amr_ds, \ - assert_equal, \ - assert_almost_equal +from yt.testing import assert_almost_equal, assert_equal, fake_amr_ds # Our canonical tests are that we can access all of our fields and we can # compute our volume correctly. diff --git a/yt/geometry/coordinates/tests/test_spherical_coordinates.py b/yt/geometry/coordinates/tests/test_spherical_coordinates.py index aa15db698ca..9947669cded 100644 --- a/yt/geometry/coordinates/tests/test_spherical_coordinates.py +++ b/yt/geometry/coordinates/tests/test_spherical_coordinates.py @@ -2,10 +2,7 @@ import numpy as np -from yt.testing import \ - fake_amr_ds, \ - assert_equal, \ - assert_almost_equal +from yt.testing import assert_almost_equal, assert_equal, fake_amr_ds # Our canonical tests are that we can access all of our fields and we can # compute our volume correctly. diff --git a/yt/geometry/geometry_handler.py b/yt/geometry/geometry_handler.py index 56dae3313dd..3e267c24f6e 100644 --- a/yt/geometry/geometry_handler.py +++ b/yt/geometry/geometry_handler.py @@ -1,18 +1,21 @@ import os import pickle import weakref -from yt.utilities.on_demand_imports import _h5py as h5py + import numpy as np from yt.config import ytcfg from yt.funcs import iterable -from yt.units.yt_array import \ - YTArray, uconcatenate +from yt.units.yt_array import YTArray, uconcatenate +from yt.utilities.exceptions import YTFieldNotFound from yt.utilities.io_handler import io_registry from yt.utilities.logger import ytLogger as mylog -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - ParallelAnalysisInterface, parallel_root_only -from yt.utilities.exceptions import YTFieldNotFound +from yt.utilities.on_demand_imports import _h5py as h5py +from yt.utilities.parallel_tools.parallel_analysis_interface import ( + ParallelAnalysisInterface, + parallel_root_only, +) + class Index(ParallelAnalysisInterface): """The base index class""" @@ -433,4 +436,4 @@ def is_curvilinear(geo): if geo in ["polar", "cylindrical", "spherical"]: return True else: - return False \ No newline at end of file + return False diff --git a/yt/geometry/grid_geometry_handler.py b/yt/geometry/grid_geometry_handler.py index f176e124e4f..04e823e0417 100644 --- a/yt/geometry/grid_geometry_handler.py +++ b/yt/geometry/grid_geometry_handler.py @@ -1,21 +1,19 @@ -from yt.utilities.on_demand_imports import _h5py as h5py -import numpy as np import weakref - from collections import defaultdict +import numpy as np + from yt.arraytypes import blankRecordArray from yt.config import ytcfg from yt.fields.derived_field import ValidateSpatial from yt.fields.field_detector import FieldDetector -from yt.funcs import \ - ensure_list, ensure_numpy_array -from yt.geometry.geometry_handler import \ - Index, YTDataChunk, ChunkDataCache +from yt.funcs import ensure_list, ensure_numpy_array +from yt.geometry.geometry_handler import ChunkDataCache, Index, YTDataChunk from yt.utilities.definitions import MAXLEVEL from yt.utilities.logger import ytLogger as mylog -from .grid_container import \ - GridTree, MatchPointsToGrids +from yt.utilities.on_demand_imports import _h5py as h5py + +from .grid_container import GridTree, MatchPointsToGrids class GridIndex(Index): diff --git a/yt/geometry/object_finding_mixin.py b/yt/geometry/object_finding_mixin.py index 8941ba17fd6..1492a1006e4 100644 --- a/yt/geometry/object_finding_mixin.py +++ b/yt/geometry/object_finding_mixin.py @@ -1,17 +1,12 @@ import numpy as np from yt.config import ytcfg -from yt.funcs import \ - mylog, ensure_numpy_array, \ - ensure_list -from yt.utilities.lib.misc_utilities import \ - get_box_grids_below_level -from yt.geometry.grid_container import \ - MatchPointsToGrids, \ - GridTree -from yt.utilities.physical_ratios import \ - HUGE +from yt.funcs import ensure_list, ensure_numpy_array, mylog +from yt.geometry.grid_container import GridTree, MatchPointsToGrids from yt.utilities.exceptions import YTTooParallel +from yt.utilities.lib.misc_utilities import get_box_grids_below_level +from yt.utilities.physical_ratios import HUGE + class ObjectFindingMixin : diff --git a/yt/geometry/oct_geometry_handler.py b/yt/geometry/oct_geometry_handler.py index 7289f7f87d6..4f97a50967b 100644 --- a/yt/geometry/oct_geometry_handler.py +++ b/yt/geometry/oct_geometry_handler.py @@ -1,7 +1,8 @@ import numpy as np -from yt.utilities.logger import ytLogger as mylog -from yt.geometry.geometry_handler import Index + from yt.fields.field_detector import FieldDetector +from yt.geometry.geometry_handler import Index +from yt.utilities.logger import ytLogger as mylog class OctreeIndex(Index): @@ -99,4 +100,3 @@ def _mesh_sampling_particle_field(field, data): sampling_type="particle", units=units, take_log=take_log) - diff --git a/yt/geometry/particle_geometry_handler.py b/yt/geometry/particle_geometry_handler.py index 197a32e0a19..79d57c2617e 100644 --- a/yt/geometry/particle_geometry_handler.py +++ b/yt/geometry/particle_geometry_handler.py @@ -1,20 +1,17 @@ import collections import errno -import numpy as np import os -import weakref import struct +import weakref + +import numpy as np -from yt.funcs import \ - get_pbar, \ - only_on_root -from yt.utilities.logger import ytLogger as mylog -from yt.geometry.geometry_handler import \ - Index, \ - YTDataChunk -from yt.geometry.particle_oct_container import ParticleBitmap from yt.data_objects.particle_container import ParticleContainer +from yt.funcs import get_pbar, only_on_root +from yt.geometry.geometry_handler import Index, YTDataChunk +from yt.geometry.particle_oct_container import ParticleBitmap from yt.utilities.lib.fnv_hash import fnv_hash +from yt.utilities.logger import ytLogger as mylog CHUNKSIZE = 64**3 diff --git a/yt/geometry/tests/fake_octree.py b/yt/geometry/tests/fake_octree.py index 5622d018688..058a926427c 100644 --- a/yt/geometry/tests/fake_octree.py +++ b/yt/geometry/tests/fake_octree.py @@ -1,7 +1,8 @@ -from yt.geometry.fake_octree import create_fake_octree -from yt.geometry.oct_container import RAMSESOctreeContainer, ParticleOctreeContainer import numpy as np +from yt.geometry.fake_octree import create_fake_octree +from yt.geometry.oct_container import ParticleOctreeContainer, RAMSESOctreeContainer + nocts= 3 max_level = 12 dn = 2 diff --git a/yt/geometry/tests/test_grid_container.py b/yt/geometry/tests/test_grid_container.py index a8dd8f653cf..d5d67990888 100644 --- a/yt/geometry/tests/test_grid_container.py +++ b/yt/geometry/tests/test_grid_container.py @@ -1,10 +1,9 @@ -import numpy as np import random -from yt.testing import \ - assert_equal, assert_raises -from yt.frontends.stream.api import \ - load_amr_grids +import numpy as np + +from yt.frontends.stream.api import load_amr_grids +from yt.testing import assert_equal, assert_raises def setup_test_ds(): diff --git a/yt/geometry/tests/test_neighbor_search.py b/yt/geometry/tests/test_neighbor_search.py index 191ae3db1d8..d3abd71aa6d 100644 --- a/yt/geometry/tests/test_neighbor_search.py +++ b/yt/geometry/tests/test_neighbor_search.py @@ -1,11 +1,7 @@ import numpy as np -from yt.fields.particle_fields import \ - add_nearest_neighbor_field -from yt.testing import \ - fake_particle_ds, \ - assert_equal, \ - assert_array_almost_equal +from yt.fields.particle_fields import add_nearest_neighbor_field +from yt.testing import assert_array_almost_equal, assert_equal, fake_particle_ds def test_neighbor_search(): diff --git a/yt/geometry/tests/test_particle_deposit.py b/yt/geometry/tests/test_particle_deposit.py index 840660221db..7e333c03a5b 100644 --- a/yt/geometry/tests/test_particle_deposit.py +++ b/yt/geometry/tests/test_particle_deposit.py @@ -1,14 +1,9 @@ -from yt.utilities.exceptions import \ - YTBoundsDefinitionError - -from yt.convenience import \ - load -from yt.testing import \ - fake_random_ds, \ - requires_file -from numpy.testing import \ - assert_raises, assert_array_less, assert_allclose +from numpy.testing import assert_allclose, assert_array_less, assert_raises + import yt +from yt.convenience import load +from yt.testing import fake_random_ds, requires_file +from yt.utilities.exceptions import YTBoundsDefinitionError def test_cic_deposit(): diff --git a/yt/geometry/tests/test_particle_octree.py b/yt/geometry/tests/test_particle_octree.py index 0e193c845b5..0b337effc83 100644 --- a/yt/geometry/tests/test_particle_octree.py +++ b/yt/geometry/tests/test_particle_octree.py @@ -1,24 +1,21 @@ -import numpy as np import os -from yt.geometry.particle_oct_container import \ - ParticleOctreeContainer, \ - ParticleBitmap +import numpy as np + +import yt.units.dimensions as dimensions from yt.geometry.oct_container import _ORDER_MAX +from yt.geometry.particle_oct_container import ParticleBitmap, ParticleOctreeContainer from yt.geometry.selection_routines import RegionSelector -from yt.testing import \ - assert_equal, \ - assert_true, \ - assert_array_equal +from yt.testing import assert_array_equal, assert_equal, assert_true from yt.units.unit_registry import UnitRegistry from yt.units.yt_array import YTArray -from yt.utilities.lib.geometry_utils import get_morton_indices, \ - get_morton_points, \ - get_hilbert_points, \ - get_hilbert_indices - -import yt.units.dimensions as dimensions +from yt.utilities.lib.geometry_utils import ( + get_hilbert_indices, + get_hilbert_points, + get_morton_indices, + get_morton_points, +) NPART = 32**3 DLE = np.array([0.0, 0.0, 0.0]) diff --git a/yt/geometry/unstructured_mesh_handler.py b/yt/geometry/unstructured_mesh_handler.py index 82110885f67..35ece25a147 100644 --- a/yt/geometry/unstructured_mesh_handler.py +++ b/yt/geometry/unstructured_mesh_handler.py @@ -1,10 +1,12 @@ -import numpy as np import os import weakref -from yt.utilities.logger import ytLogger as mylog +import numpy as np + from yt.geometry.geometry_handler import Index, YTDataChunk from yt.utilities.lib.mesh_utilities import smallest_fwidth +from yt.utilities.logger import ytLogger as mylog + class UnstructuredIndex(Index): """The Index subclass for unstructured and hexahedral mesh datasets. """ diff --git a/yt/mods.py b/yt/mods.py index 53b24bfeffe..000a7d990b8 100644 --- a/yt/mods.py +++ b/yt/mods.py @@ -3,7 +3,6 @@ # import os -from yt import * # This next item will handle most of the actual startup procedures, but it will # also attempt to parse the command line and set up the global state of various @@ -11,11 +10,13 @@ # provided as a convenience for users who wish to parse arguments in scripts. # https://mail.python.org/archives/list/yt-dev@python.org/thread/L6AQPJ3OIMJC5SNKVM7CJG32YVQZRJWA/ import yt.startup_tasks as __startup_tasks +from yt import * +from yt.config import ytcfg, ytcfg_defaults +from yt.utilities.logger import level as __level + unparsed_args = __startup_tasks.unparsed_args -from yt.config import ytcfg, ytcfg_defaults -from yt.utilities.logger import level as __level if __level >= int(ytcfg_defaults["loglevel"]): # This won't get displayed. mylog.debug("Turning off NumPy error reporting") diff --git a/yt/pmods.py b/yt/pmods.py index 282722dd3fb..131f2fa1f13 100644 --- a/yt/pmods.py +++ b/yt/pmods.py @@ -193,10 +193,11 @@ def bcast(obj=None,root=0): """ -import sys +import builtins import imp +import sys import types -import builtins + from mpi4py import MPI diff --git a/yt/startup_tasks.py b/yt/startup_tasks.py index 649d52becf0..f8bb92719b8 100644 --- a/yt/startup_tasks.py +++ b/yt/startup_tasks.py @@ -2,16 +2,17 @@ import argparse import os -import sys import signal +import sys from yt.config import ytcfg -from yt.funcs import \ - mylog, \ - signal_print_traceback, \ - signal_ipython, \ - paste_traceback, \ - paste_traceback_detailed +from yt.funcs import ( + mylog, + paste_traceback, + paste_traceback_detailed, + signal_ipython, + signal_print_traceback, +) from yt.utilities import rpdb exe_name = os.path.basename(sys.executable) diff --git a/yt/testing.py b/yt/testing.py index 2b64b1fec45..89e6a249498 100644 --- a/yt/testing.py +++ b/yt/testing.py @@ -1,16 +1,24 @@ -import hashlib -import matplotlib -import pickle -import itertools as it -import numpy as np import functools +import hashlib import importlib +import itertools as it import os +import pickle import shutil import tempfile import unittest -from yt.funcs import iterable + +import matplotlib +import numpy as np +from numpy.random import RandomState +from unyt.exceptions import UnitOperationError + +import yt from yt.config import ytcfg +from yt.convenience import load +from yt.funcs import iterable +from yt.units.yt_array import YTArray, YTQuantity + # we import this in a weird way from numpy.testing to avoid triggering # flake8 errors from the unused imports. These test functions are imported # elsewhere in yt from here so we want them to be imported here. @@ -20,11 +28,6 @@ from numpy.testing import assert_string_equal # NOQA isort:skip from numpy.testing import assert_array_almost_equal_nulp # NOQA isort:skip from numpy.testing import assert_allclose, assert_raises # NOQA isort:skip -from numpy.random import RandomState -from yt.convenience import load -from yt.units.yt_array import YTArray, YTQuantity -from unyt.exceptions import UnitOperationError -import yt ANSWER_TEST_TAG = "answer_test" # Expose assert_true and assert_less_equal from unittest.TestCase diff --git a/yt/tests/test_load_from_path.py b/yt/tests/test_load_from_path.py index 86272e03491..a9b36e60c61 100644 --- a/yt/tests/test_load_from_path.py +++ b/yt/tests/test_load_from_path.py @@ -1,8 +1,10 @@ import os from sys import version_info -from yt.convenience import _sanitize_load_args + import pytest +from yt.convenience import _sanitize_load_args + PY36 = version_info >= (3, 6) if PY36: diff --git a/yt/tests/test_testing.py b/yt/tests/test_testing.py index aeab7f5ddc8..cc26240d0e6 100644 --- a/yt/tests/test_testing.py +++ b/yt/tests/test_testing.py @@ -2,8 +2,8 @@ import numpy as np import pytest -from yt.testing import assert_equal, requires_backend import yt +from yt.testing import assert_equal, requires_backend def test_requires_backend(): diff --git a/yt/units/__init__.py b/yt/units/__init__.py index d98507c5d54..a1d0b84b5ff 100644 --- a/yt/units/__init__.py +++ b/yt/units/__init__.py @@ -1,6 +1,3 @@ -from yt.units.physical_constants import * -from yt.units.unit_symbols import * -from yt.utilities.exceptions import YTArrayTooLargeToDisplay from unyt.array import ( loadtxt, savetxt, @@ -10,22 +7,26 @@ uhstack, uintersect1d, unorm, + unyt_array, + unyt_quantity, ustack, uunion1d, uvstack, - unyt_array, - unyt_quantity, ) from unyt.unit_object import Unit, define_unit # NOQA: F401 from unyt.unit_registry import UnitRegistry # NOQA: Ffg401 from unyt.unit_systems import UnitSystem # NOQA: F401 +from yt.units.physical_constants import * +from yt.units.physical_constants import _ConstantContainer +from yt.units.unit_symbols import * +from yt.units.unit_symbols import _SymbolContainer +from yt.utilities.exceptions import YTArrayTooLargeToDisplay + YTArray = unyt_array YTQuantity = unyt_quantity -from yt.units.unit_symbols import _SymbolContainer -from yt.units.physical_constants import _ConstantContainer class UnitContainer: """A container for units and constants to associate with a dataset @@ -111,4 +112,3 @@ def _value_updater(change): def _wrap_display_ytarray(arr): from IPython.core.display import display display(display_ytarray(arr)) - diff --git a/yt/units/physical_constants.py b/yt/units/physical_constants.py index a0e62962787..10ddb4c2457 100644 --- a/yt/units/physical_constants.py +++ b/yt/units/physical_constants.py @@ -1,7 +1,8 @@ -from yt.units.unit_registry import default_unit_registry from unyt.array import unyt_quantity from unyt.unit_systems import add_constants +from yt.units.unit_registry import default_unit_registry + add_constants(globals(), registry=default_unit_registry) class _ConstantContainer: diff --git a/yt/units/tests/test_magnetic_code_units.py b/yt/units/tests/test_magnetic_code_units.py index b335a35951b..148c28f2aa6 100644 --- a/yt/units/tests/test_magnetic_code_units.py +++ b/yt/units/tests/test_magnetic_code_units.py @@ -1,7 +1,9 @@ import numpy as np + from yt.frontends.stream.api import load_uniform_grid from yt.testing import assert_allclose + def test_magnetic_code_units(): sqrt4pi = np.sqrt(4.0*np.pi) diff --git a/yt/units/unit_registry.py b/yt/units/unit_registry.py index 89ff3cdfa61..24b8888dd04 100644 --- a/yt/units/unit_registry.py +++ b/yt/units/unit_registry.py @@ -1,5 +1,5 @@ -from unyt.unit_registry import * from unyt.dimensions import dimensionless +from unyt.unit_registry import * default_unit_registry = UnitRegistry(unit_system='cgs') diff --git a/yt/units/unit_symbols.py b/yt/units/unit_symbols.py index 8e86e76273a..75366e4ddcf 100644 --- a/yt/units/unit_symbols.py +++ b/yt/units/unit_symbols.py @@ -1,7 +1,8 @@ -from yt.units.unit_registry import default_unit_registry from unyt.unit_object import Unit from unyt.unit_systems import add_symbols +from yt.units.unit_registry import default_unit_registry + add_symbols(globals(), registry=default_unit_registry) class _SymbolContainer: @@ -46,4 +47,3 @@ def __getattr__(self, item): raise AttributeError(item) self._cache[item] = ret return ret - diff --git a/yt/units/unit_systems.py b/yt/units/unit_systems.py index 184a05c2f3c..94db6c00ba5 100644 --- a/yt/units/unit_systems.py +++ b/yt/units/unit_systems.py @@ -1,5 +1,6 @@ from unyt.unit_systems import * + def create_code_unit_system(unit_registry, current_mks_unit=None): code_unit_system = UnitSystem(unit_registry.unit_system_id, "code_length", "code_mass", "code_time", "code_temperature", diff --git a/yt/units/yt_array.py b/yt/units/yt_array.py index d26b52c4faf..b5a65be316d 100644 --- a/yt/units/yt_array.py +++ b/yt/units/yt_array.py @@ -1,6 +1,8 @@ from unyt.array import * -from yt.units import YTArray, YTQuantity + from yt.funcs import array_like_field +from yt.units import YTArray, YTQuantity + def display_ytarray(arr): r""" diff --git a/yt/utilities/amr_kdtree/__init__.py b/yt/utilities/amr_kdtree/__init__.py index 06cde376cf3..a8f6ee350cb 100644 --- a/yt/utilities/amr_kdtree/__init__.py +++ b/yt/utilities/amr_kdtree/__init__.py @@ -2,4 +2,3 @@ Initialize amr_kdtree """ - diff --git a/yt/utilities/amr_kdtree/amr_kdtools.py b/yt/utilities/amr_kdtree/amr_kdtools.py index 78e7a53de14..9064ee7603a 100644 --- a/yt/utilities/amr_kdtree/amr_kdtools.py +++ b/yt/utilities/amr_kdtree/amr_kdtools.py @@ -1,4 +1,5 @@ import numpy as np + from yt.funcs import mylog diff --git a/yt/utilities/amr_kdtree/amr_kdtree.py b/yt/utilities/amr_kdtree/amr_kdtree.py index 4ba78eb133c..a23e6ff2c74 100644 --- a/yt/utilities/amr_kdtree/amr_kdtree.py +++ b/yt/utilities/amr_kdtree/amr_kdtree.py @@ -1,20 +1,21 @@ import operator + import numpy as np -from yt.funcs import \ - iterable, \ - mylog -from yt.utilities.on_demand_imports import _h5py as h5py -from yt.utilities.amr_kdtree.amr_kdtools import \ - receive_and_reduce, \ - send_to_parent, \ - scatter_image +from yt.funcs import iterable, mylog +from yt.geometry.grid_geometry_handler import GridIndex +from yt.utilities.amr_kdtree.amr_kdtools import ( + receive_and_reduce, + scatter_image, + send_to_parent, +) from yt.utilities.lib.amr_kdtools import Node -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - ParallelAnalysisInterface from yt.utilities.lib.partitioned_grid import PartitionedGrid from yt.utilities.math_utils import periodic_position -from yt.geometry.grid_geometry_handler import GridIndex +from yt.utilities.on_demand_imports import _h5py as h5py +from yt.utilities.parallel_tools.parallel_analysis_interface import ( + ParallelAnalysisInterface, +) steps = np.array([[-1, -1, -1], [-1, -1, 0], [-1, -1, 1], [-1, 0, -1], [-1, 0, 0], [-1, 0, 1], diff --git a/yt/utilities/answer_testing/__init__.py b/yt/utilities/answer_testing/__init__.py index 81c61259ce7..a486d483f56 100644 --- a/yt/utilities/answer_testing/__init__.py +++ b/yt/utilities/answer_testing/__init__.py @@ -4,4 +4,3 @@ """ - diff --git a/yt/utilities/answer_testing/answer_tests.py b/yt/utilities/answer_testing/answer_tests.py index 5a888a0640f..d85133f5bf1 100644 --- a/yt/utilities/answer_testing/answer_tests.py +++ b/yt/utilities/answer_testing/answer_tests.py @@ -2,16 +2,17 @@ Title: answer_tests.py Purpose: Contains answer tests that are used by yt's various frontends """ +import hashlib import os import tempfile -import hashlib import matplotlib.image as mpimg import numpy as np -from . import utils import yt.visualization.plot_window as pw +from . import utils + def grid_hierarchy(ds): result = {} diff --git a/yt/utilities/answer_testing/api.py b/yt/utilities/answer_testing/api.py index 536df4d5171..e5900babeb4 100644 --- a/yt/utilities/answer_testing/api.py +++ b/yt/utilities/answer_testing/api.py @@ -1,2 +1 @@ from yt.utilities.answer_testing.framework import AnswerTesting - diff --git a/yt/utilities/answer_testing/framework.py b/yt/utilities/answer_testing/framework.py index 56464fa76eb..9e9cbbd3332 100644 --- a/yt/utilities/answer_testing/framework.py +++ b/yt/utilities/answer_testing/framework.py @@ -2,47 +2,47 @@ Title: framework.py Purpose: Contains answer tests that are used by yt's various frontends """ +import contextlib +import glob +import hashlib import logging -import numpy as np import os -import time -import hashlib -import contextlib -import sys import pickle -import urllib import shelve -import zlib +import sys import tempfile -import glob - +import time +import urllib +import zlib from collections import defaultdict +import matplotlib.image as mpimg +import numpy as np from matplotlib.testing.compare import compare_images from nose.plugins import Plugin -from yt.funcs import \ - get_pbar -from yt.testing import \ - assert_equal, \ - assert_allclose_units, \ - assert_rel_equal, \ - assert_almost_equal -from yt.convenience import load, simulation + +import yt.visualization.particle_plots as particle_plots +import yt.visualization.plot_window as pw +import yt.visualization.profile_plotter as profile_plotter from yt.config import ytcfg +from yt.convenience import load, simulation from yt.data_objects.static_output import Dataset from yt.data_objects.time_series import SimulationTimeSeries -from yt.utilities.exceptions import \ - YTNoOldAnswer, \ - YTCloudError, \ - YTOutputNotIdentified, \ - YTNoAnswerNameSpecified -from yt.utilities.logger import disable_stream_logging +from yt.funcs import get_pbar +from yt.testing import ( + assert_allclose_units, + assert_almost_equal, + assert_equal, + assert_rel_equal, +) from yt.utilities.command_line import get_yt_version - -import matplotlib.image as mpimg -import yt.visualization.plot_window as pw -import yt.visualization.particle_plots as particle_plots -import yt.visualization.profile_plotter as profile_plotter +from yt.utilities.exceptions import ( + YTCloudError, + YTNoAnswerNameSpecified, + YTNoOldAnswer, + YTOutputNotIdentified, +) +from yt.utilities.logger import disable_stream_logging mylog = logging.getLogger('nose.plugins.answer-testing') run_big_data = False diff --git a/yt/utilities/answer_testing/level_sets_tests.py b/yt/utilities/answer_testing/level_sets_tests.py index 652627d67a8..40fd7f4ad81 100644 --- a/yt/utilities/answer_testing/level_sets_tests.py +++ b/yt/utilities/answer_testing/level_sets_tests.py @@ -1,9 +1,8 @@ import numpy as np -from yt.testing import \ - assert_equal -from yt.utilities.answer_testing.framework import \ - AnswerTestingTest +from yt.testing import assert_equal +from yt.utilities.answer_testing.framework import AnswerTestingTest + class ExtractConnectedSetsTest(AnswerTestingTest): _type_name = "ExtractConnectedSets" diff --git a/yt/utilities/answer_testing/utils.py b/yt/utilities/answer_testing/utils.py index 8851cf8daf2..e3380846b2a 100644 --- a/yt/utilities/answer_testing/utils.py +++ b/yt/utilities/answer_testing/utils.py @@ -12,19 +12,16 @@ import pytest import yaml +import yt.visualization.particle_plots as particle_plots +import yt.visualization.plot_window as pw +import yt.visualization.profile_plotter as profile_plotter from yt.config import ytcfg from yt.convenience import load, simulation from yt.data_objects.selection_data_containers import YTRegion from yt.data_objects.static_output import Dataset from yt.frontends.ytdata.api import save_as_dataset -from yt.units.yt_array import \ - YTArray, \ - YTQuantity -from yt.utilities.exceptions import \ - YTOutputNotIdentified -import yt.visualization.particle_plots as particle_plots -import yt.visualization.plot_window as pw -import yt.visualization.profile_plotter as profile_plotter +from yt.units.yt_array import YTArray, YTQuantity +from yt.utilities.exceptions import YTOutputNotIdentified from yt.visualization.volume_rendering.scene import Scene diff --git a/yt/utilities/api.py b/yt/utilities/api.py index 7c097dfc5f5..66de06ca695 100644 --- a/yt/utilities/api.py +++ b/yt/utilities/api.py @@ -4,4 +4,3 @@ """ - diff --git a/yt/utilities/chemical_formulas.py b/yt/utilities/chemical_formulas.py index 4f199ae6c8d..63dc2ea6f0e 100644 --- a/yt/utilities/chemical_formulas.py +++ b/yt/utilities/chemical_formulas.py @@ -1,4 +1,5 @@ import re + from .periodic_table import periodic_table from .physical_ratios import _primordial_mass_fraction diff --git a/yt/utilities/command_line.py b/yt/utilities/command_line.py index a664e044ffa..6dd5a02ece0 100644 --- a/yt/utilities/command_line.py +++ b/yt/utilities/command_line.py @@ -1,40 +1,44 @@ import argparse import base64 import getpass -import numpy as np +import json import os -import sys +import pprint import subprocess +import sys import tempfile -import json -import pprint import textwrap - -from yt.config import ytcfg, CURRENT_CONFIG_FILE -ytcfg["yt","__command_line"] = "True" -from yt.startup_tasks import parser, subparsers -from yt.funcs import \ - ensure_dir, \ - ensure_list, \ - get_hg_or_git_version, \ - get_yt_version, \ - mylog, \ - ensure_dir_exists, \ - update_hg_or_git, \ - enable_plugins, \ - download_file import urllib import urllib.request from urllib.parse import urlparse -from yt.extern.tqdm import tqdm + +import numpy as np + +from yt.config import CURRENT_CONFIG_FILE, ytcfg from yt.convenience import load -from yt.visualization.plot_window import \ - SlicePlot, \ - ProjectionPlot -from yt.utilities.metadata import get_metadata +from yt.extern.tqdm import tqdm +from yt.funcs import ( + download_file, + enable_plugins, + ensure_dir, + ensure_dir_exists, + ensure_list, + get_hg_or_git_version, + get_yt_version, + mylog, + update_hg_or_git, +) +from yt.startup_tasks import parser, subparsers from yt.utilities.configure import set_config -from yt.utilities.exceptions import \ - YTOutputNotIdentified, YTFieldNotParseable, YTCommandRequiresModule +from yt.utilities.exceptions import ( + YTCommandRequiresModule, + YTFieldNotParseable, + YTOutputNotIdentified, +) +from yt.utilities.metadata import get_metadata +from yt.visualization.plot_window import ProjectionPlot, SlicePlot + +ytcfg["yt","__command_line"] = "True" # loading field plugins for backward compatibility, since this module # used to do "from yt.mods import *" diff --git a/yt/utilities/configure.py b/yt/utilities/configure.py index 8fbd8ba5aed..423e1848714 100644 --- a/yt/utilities/configure.py +++ b/yt/utilities/configure.py @@ -1,9 +1,10 @@ +import argparse +import configparser import os import shutil import sys -import argparse -from yt.config import CURRENT_CONFIG_FILE, _OLD_CONFIG_FILE, YTConfigParser -import configparser + +from yt.config import _OLD_CONFIG_FILE, CURRENT_CONFIG_FILE, YTConfigParser CONFIG = YTConfigParser() CONFIG.read([CURRENT_CONFIG_FILE]) diff --git a/yt/utilities/cosmology.py b/yt/utilities/cosmology.py index 4287a4904e3..f4e6923a9e0 100644 --- a/yt/utilities/cosmology.py +++ b/yt/utilities/cosmology.py @@ -1,20 +1,17 @@ import functools + import numpy as np -from yt.funcs import \ - issue_deprecation_warning +from yt.funcs import issue_deprecation_warning from yt.units import dimensions -from yt.units.unit_registry import \ - UnitRegistry -from yt.units.unit_object import \ - Unit -from yt.units.yt_array import \ - YTArray, \ - YTQuantity - -from yt.utilities.physical_constants import \ - gravitational_constant_cgs as G, \ - speed_of_light_cgs +from yt.units.unit_object import Unit +from yt.units.unit_registry import UnitRegistry +from yt.units.yt_array import YTArray, YTQuantity +from yt.utilities.physical_constants import ( + gravitational_constant_cgs as G, + speed_of_light_cgs, +) + class Cosmology: r""" diff --git a/yt/utilities/definitions.py b/yt/utilities/definitions.py index 76ff06878e6..af2f39749bf 100644 --- a/yt/utilities/definitions.py +++ b/yt/utilities/definitions.py @@ -1,7 +1,17 @@ -from .physical_ratios import \ - mpc_per_mpc, kpc_per_mpc, pc_per_mpc, au_per_mpc, rsun_per_mpc, \ - miles_per_mpc, km_per_mpc, cm_per_mpc, sec_per_Gyr, sec_per_Myr, \ - sec_per_year, sec_per_day +from .physical_ratios import ( + au_per_mpc, + cm_per_mpc, + km_per_mpc, + kpc_per_mpc, + miles_per_mpc, + mpc_per_mpc, + pc_per_mpc, + rsun_per_mpc, + sec_per_day, + sec_per_Gyr, + sec_per_Myr, + sec_per_year, +) # The number of levels we expect to have at most MAXLEVEL=48 diff --git a/yt/utilities/exceptions.py b/yt/utilities/exceptions.py index 7761e6e5b99..514fe8049ed 100644 --- a/yt/utilities/exceptions.py +++ b/yt/utilities/exceptions.py @@ -4,6 +4,7 @@ from unyt.exceptions import UnitOperationError + class YTException(Exception): def __init__(self, message = None, ds = None): Exception.__init__(self, message) diff --git a/yt/utilities/file_handler.py b/yt/utilities/file_handler.py index 462e9fd60f3..39badcf0cc3 100644 --- a/yt/utilities/file_handler.py +++ b/yt/utilities/file_handler.py @@ -1,7 +1,7 @@ -from yt.utilities.on_demand_imports import _h5py as h5py -from yt.utilities.on_demand_imports import NotAModule from contextlib import contextmanager +from yt.utilities.on_demand_imports import NotAModule, _h5py as h5py + def valid_hdf5_signature(fn): signature = b'\x89HDF\r\n\x1a\n' diff --git a/yt/utilities/fits_image.py b/yt/utilities/fits_image.py index 6e7d8e8b443..df001abd8b6 100644 --- a/yt/utilities/fits_image.py +++ b/yt/utilities/fits_image.py @@ -1,9 +1,12 @@ from yt.funcs import issue_deprecation_warning +from yt.visualization.fits_image import ( + FITSImageData, + FITSOffAxisProjection, + FITSOffAxisSlice, + FITSProjection, + FITSSlice, +) issue_deprecation_warning("The fits_image classes have been moved to yt.visualization " "and can be imported from yt directly. yt.utilities.fits_image " "is deprecated.") - -from yt.visualization.fits_image import \ - FITSImageData, FITSSlice, FITSProjection, \ - FITSOffAxisSlice, FITSOffAxisProjection \ No newline at end of file diff --git a/yt/utilities/flagging_methods.py b/yt/utilities/flagging_methods.py index 1689ccaafa8..8bfc47ca70b 100644 --- a/yt/utilities/flagging_methods.py +++ b/yt/utilities/flagging_methods.py @@ -1,4 +1,5 @@ -import numpy as np # For modern purposes +import numpy as np # For modern purposes + from yt.utilities.lib.misc_utilities import grow_flagging_field flagging_method_registry = {} diff --git a/yt/utilities/fortran_utils.py b/yt/utilities/fortran_utils.py index c727274a503..465dfd28839 100644 --- a/yt/utilities/fortran_utils.py +++ b/yt/utilities/fortran_utils.py @@ -1,6 +1,7 @@ +import os import struct + import numpy as np -import os # This may not be the correct way to do this. We should investigate what NumPy # does. diff --git a/yt/utilities/grid_data_format/conversion/__init__.py b/yt/utilities/grid_data_format/conversion/__init__.py index 92bf27bc04a..d844769a3d8 100644 --- a/yt/utilities/grid_data_format/conversion/__init__.py +++ b/yt/utilities/grid_data_format/conversion/__init__.py @@ -1,2 +1,2 @@ from .conversion_abc import Converter -from .conversion_athena import AthenaDistributedConverter, AthenaConverter +from .conversion_athena import AthenaConverter, AthenaDistributedConverter diff --git a/yt/utilities/grid_data_format/conversion/conversion_athena.py b/yt/utilities/grid_data_format/conversion/conversion_athena.py index 52ef280786b..89ed9a3d6ce 100644 --- a/yt/utilities/grid_data_format/conversion/conversion_athena.py +++ b/yt/utilities/grid_data_format/conversion/conversion_athena.py @@ -1,7 +1,9 @@ +from glob import glob + import numpy as np + from yt.utilities.grid_data_format.conversion.conversion_abc import Converter from yt.utilities.on_demand_imports import _h5py as h5 -from glob import glob translation_dict = {} translation_dict['density'] = 'density' @@ -481,4 +483,3 @@ def convert(self): # fn = '%s.%04i'%(n[0],int(n[1])) # grid = read_grid(fn+'.vtk') # write_to_hdf5(fn+'.gdf',grid) - diff --git a/yt/utilities/grid_data_format/scripts/convert_distributed_athena.py b/yt/utilities/grid_data_format/scripts/convert_distributed_athena.py index d32f066dc3d..b7f084a3b73 100644 --- a/yt/utilities/grid_data_format/scripts/convert_distributed_athena.py +++ b/yt/utilities/grid_data_format/scripts/convert_distributed_athena.py @@ -1,5 +1,7 @@ -from grid_data_format import AthenaDistributedConverter import sys + +from grid_data_format import AthenaDistributedConverter + # Assumes that last input is the basename for the athena dataset. # i.e. kh_3d_mhd_hlld_128_beta5000_sub_tanhd.0030 basename = sys.argv[-1] @@ -19,4 +21,3 @@ # converter = AthenaDistributedConverter(basename, field_conversions=code_to_cgs) # converter.convert() - diff --git a/yt/utilities/grid_data_format/scripts/convert_single_athena.py b/yt/utilities/grid_data_format/scripts/convert_single_athena.py index 7a9ca9609e4..0156b106020 100644 --- a/yt/utilities/grid_data_format/scripts/convert_single_athena.py +++ b/yt/utilities/grid_data_format/scripts/convert_single_athena.py @@ -1,5 +1,7 @@ -from grid_data_format import AthenaConverter import sys + +from grid_data_format import AthenaConverter + # Assumes that last input is the basename for the athena dataset. # i.e. kh_3d_mhd_hlld_128_beta5000_sub_tanhd.0030 basename = sys.argv[-1] @@ -19,5 +21,3 @@ # converter = AthenaDistributedConverter(basename, field_conversions=code_to_cgs) # converter.convert() - - diff --git a/yt/utilities/grid_data_format/tests/test_writer.py b/yt/utilities/grid_data_format/tests/test_writer.py index 2950e17906b..49a2e2f1654 100644 --- a/yt/utilities/grid_data_format/tests/test_writer.py +++ b/yt/utilities/grid_data_format/tests/test_writer.py @@ -1,17 +1,12 @@ -import tempfile -import shutil import os +import shutil +import tempfile + +from yt.frontends.gdf.data_structures import GDFDataset +from yt.mods import load +from yt.testing import assert_equal, fake_random_ds, requires_module +from yt.utilities.grid_data_format.writer import write_to_gdf from yt.utilities.on_demand_imports import _h5py as h5 -from yt.testing import \ - fake_random_ds, \ - assert_equal, \ - requires_module -from yt.utilities.grid_data_format.writer import \ - write_to_gdf -from yt.frontends.gdf.data_structures import \ - GDFDataset -from yt.mods import \ - load TEST_AUTHOR = "yt test runner" TEST_COMMENT = "Testing write_to_gdf" diff --git a/yt/utilities/grid_data_format/writer.py b/yt/utilities/grid_data_format/writer.py index 309b463c4f5..73fd424c41d 100644 --- a/yt/utilities/grid_data_format/writer.py +++ b/yt/utilities/grid_data_format/writer.py @@ -1,15 +1,17 @@ import os import sys -from yt.utilities.on_demand_imports import _h5py as h5py -import numpy as np from contextlib import contextmanager +import numpy as np + from yt import __version__ as yt_version -from yt.utilities.exceptions import YTGDFAlreadyExists from yt.funcs import ensure_list, issue_deprecation_warning -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - parallel_objects, \ - communication_system +from yt.utilities.exceptions import YTGDFAlreadyExists +from yt.utilities.on_demand_imports import _h5py as h5py +from yt.utilities.parallel_tools.parallel_analysis_interface import ( + communication_system, + parallel_objects, +) def write_to_gdf(ds, gdf_path, fields=None, diff --git a/yt/utilities/initial_conditions.py b/yt/utilities/initial_conditions.py index 259e5b05100..a76ddd006b8 100644 --- a/yt/utilities/initial_conditions.py +++ b/yt/utilities/initial_conditions.py @@ -1,5 +1,6 @@ import numpy as np + class FluidOperator: def apply(self, ds): for g in ds.index.grids: self(g) diff --git a/yt/utilities/io_handler.py b/yt/utilities/io_handler.py index 420db5cc5bc..3214fa9f789 100644 --- a/yt/utilities/io_handler.py +++ b/yt/utilities/io_handler.py @@ -1,12 +1,12 @@ +import os from collections import defaultdict from contextlib import contextmanager -import os -from yt.utilities.on_demand_imports import _h5py as h5py import numpy as np -from yt.utilities.lru_cache import \ - local_lru_cache, _make_key + from yt.geometry.selection_routines import GridSelector +from yt.utilities.lru_cache import _make_key, local_lru_cache +from yt.utilities.on_demand_imports import _h5py as h5py io_registry = {} diff --git a/yt/utilities/lib/api.py b/yt/utilities/lib/api.py index ea60c087c08..19b2bd368a8 100644 --- a/yt/utilities/lib/api.py +++ b/yt/utilities/lib/api.py @@ -1,15 +1,15 @@ -from .grid_traversal import * -from .particle_mesh_operations import * +from .basic_octree import * +from .contour_finding import * from .depth_first_octree import * from .fortran_reader import * +from .grid_traversal import * +from .image_utilities import * from .interpolators import * +from .line_integral_convolution import * +from .marching_cubes import * +from .mesh_utilities import * from .misc_utilities import * -from .basic_octree import * -from .image_utilities import * +from .particle_mesh_operations import * from .points_in_volume import * from .quad_tree import * -from .marching_cubes import * from .write_array import * -from .mesh_utilities import * -from .contour_finding import * -from .line_integral_convolution import * diff --git a/yt/utilities/lib/cykdtree/__init__.py b/yt/utilities/lib/cykdtree/__init__.py index 675daffbbfb..2c9c9bc245a 100644 --- a/yt/utilities/lib/cykdtree/__init__.py +++ b/yt/utilities/lib/cykdtree/__init__.py @@ -1,5 +1,6 @@ -from yt.utilities.lib.cykdtree.kdtree import PyKDTree, PyNode # NOQA from yt.utilities.lib.cykdtree import plot # NOQA +from yt.utilities.lib.cykdtree.kdtree import PyKDTree, PyNode # NOQA + def make_tree(pts, **kwargs): r"""Build a KD-tree for a set of points. diff --git a/yt/utilities/lib/cykdtree/plot.py b/yt/utilities/lib/cykdtree/plot.py index 069b8b31b14..5bd5cf40835 100644 --- a/yt/utilities/lib/cykdtree/plot.py +++ b/yt/utilities/lib/cykdtree/plot.py @@ -1,5 +1,6 @@ import numpy as np + def _plot2D_root(seg, pts=None, txt=None, plotfile=None, point_kw={}, box_kw={}, axs=None, subplot_kw={}, gridspec_kw={}, fig_kw={}, save_kw={}, title=None, xlabel='x', ylabel='y', label_kw={}): diff --git a/yt/utilities/lib/cykdtree/tests/__init__.py b/yt/utilities/lib/cykdtree/tests/__init__.py index 450a1912a45..8a048d5e231 100644 --- a/yt/utilities/lib/cykdtree/tests/__init__.py +++ b/yt/utilities/lib/cykdtree/tests/__init__.py @@ -1,12 +1,13 @@ -from datetime import datetime import cProfile +import itertools import pstats +import sys import time -from subprocess import Popen, PIPE -from nose.tools import nottest +from datetime import datetime +from subprocess import PIPE, Popen + import numpy as np -import itertools -import sys +from nose.tools import nottest def assert_less_equal(x, y): diff --git a/yt/utilities/lib/cykdtree/tests/scaling.py b/yt/utilities/lib/cykdtree/tests/scaling.py index 0213c0cf74e..d5d1881edb3 100644 --- a/yt/utilities/lib/cykdtree/tests/scaling.py +++ b/yt/utilities/lib/cykdtree/tests/scaling.py @@ -1,9 +1,11 @@ r"""Routines for tracking the scaling of the triangulation routines.""" -import numpy as np -import time -import os import cProfile +import os import pstats +import time + +import numpy as np + from yt.utilities.lib.cykdtree.tests import run_test diff --git a/yt/utilities/lib/cykdtree/tests/test_kdtree.py b/yt/utilities/lib/cykdtree/tests/test_kdtree.py index 9a0445578f2..b397315934c 100644 --- a/yt/utilities/lib/cykdtree/tests/test_kdtree.py +++ b/yt/utilities/lib/cykdtree/tests/test_kdtree.py @@ -1,12 +1,14 @@ -import numpy as np -import time import tempfile +import time + +import numpy as np from nose.tools import assert_raises + import yt.utilities.lib.cykdtree as cykdtree from yt.utilities.lib.cykdtree.tests import ( - parametrize, make_points, make_points_neighbors, + parametrize, ) diff --git a/yt/utilities/lib/cykdtree/tests/test_plot.py b/yt/utilities/lib/cykdtree/tests/test_plot.py index 29e7f6b8e39..4fed890023a 100644 --- a/yt/utilities/lib/cykdtree/tests/test_plot.py +++ b/yt/utilities/lib/cykdtree/tests/test_plot.py @@ -1,6 +1,7 @@ import os -from yt.utilities.lib.cykdtree.plot import plot2D_serial + from yt.utilities.lib.cykdtree.kdtree import PyKDTree +from yt.utilities.lib.cykdtree.plot import plot2D_serial from yt.utilities.lib.cykdtree.tests import make_points diff --git a/yt/utilities/lib/cykdtree/tests/test_utils.py b/yt/utilities/lib/cykdtree/tests/test_utils.py index 91f0f173d2f..23c99b200c9 100644 --- a/yt/utilities/lib/cykdtree/tests/test_utils.py +++ b/yt/utilities/lib/cykdtree/tests/test_utils.py @@ -1,7 +1,9 @@ import numpy as np from nose.tools import assert_equal -from yt.utilities.lib.cykdtree.tests import parametrize, assert_less_equal + from yt.utilities.lib.cykdtree import utils +from yt.utilities.lib.cykdtree.tests import assert_less_equal, parametrize + def test_max_pts(): pts = np.arange(5*3).reshape((5, 3)).astype('float64') diff --git a/yt/utilities/lib/tests/test_allocation_container.py b/yt/utilities/lib/tests/test_allocation_container.py index bcf52b068b0..51ed93ceb4c 100644 --- a/yt/utilities/lib/tests/test_allocation_container.py +++ b/yt/utilities/lib/tests/test_allocation_container.py @@ -1,7 +1,6 @@ -from yt.testing import \ - assert_array_equal, assert_equal -from yt.utilities.lib.allocation_container import \ - BitmaskPool +from yt.testing import assert_array_equal, assert_equal +from yt.utilities.lib.allocation_container import BitmaskPool + def test_bitmask_pool(): bmp = BitmaskPool() diff --git a/yt/utilities/lib/tests/test_alt_ray_tracers.py b/yt/utilities/lib/tests/test_alt_ray_tracers.py index ef7a9882c93..5b9dfd16d0f 100644 --- a/yt/utilities/lib/tests/test_alt_ray_tracers.py +++ b/yt/utilities/lib/tests/test_alt_ray_tracers.py @@ -1,13 +1,8 @@ """Tests for non-cartesian ray tracers.""" import numpy as np -from yt.testing import \ - assert_true, \ - amrspace, \ - assert_less_equal, \ - assert_equal - -from yt.utilities.lib.alt_ray_tracers import cylindrical_ray_trace, _cyl2cart +from yt.testing import amrspace, assert_equal, assert_less_equal, assert_true +from yt.utilities.lib.alt_ray_tracers import _cyl2cart, cylindrical_ray_trace left_grid = right_grid = amr_levels = center_grid = data = None diff --git a/yt/utilities/lib/tests/test_bitarray.py b/yt/utilities/lib/tests/test_bitarray.py index 067ebeb1c7b..39dedfb0feb 100644 --- a/yt/utilities/lib/tests/test_bitarray.py +++ b/yt/utilities/lib/tests/test_bitarray.py @@ -1,7 +1,8 @@ import numpy as np import yt.utilities.lib.bitarray as ba -from yt.testing import assert_equal, assert_array_equal +from yt.testing import assert_array_equal, assert_equal + def test_inout_bitarray(): # Check that we can do it for bitarrays that are funny-shaped diff --git a/yt/utilities/lib/tests/test_bounding_volume_hierarchy.py b/yt/utilities/lib/tests/test_bounding_volume_hierarchy.py index be3e4770dbc..436fee8957b 100644 --- a/yt/utilities/lib/tests/test_bounding_volume_hierarchy.py +++ b/yt/utilities/lib/tests/test_bounding_volume_hierarchy.py @@ -1,9 +1,9 @@ -import yt import numpy as np -from yt.utilities.lib.bounding_volume_hierarchy import BVH, \ - test_ray_trace -from yt.visualization.volume_rendering.api import Camera, Scene + +import yt from yt.testing import requires_file +from yt.utilities.lib.bounding_volume_hierarchy import BVH, test_ray_trace +from yt.visualization.volume_rendering.api import Camera, Scene def get_rays(camera): diff --git a/yt/utilities/lib/tests/test_element_mappings.py b/yt/utilities/lib/tests/test_element_mappings.py index 55b583e7d44..7e0e6fedda8 100644 --- a/yt/utilities/lib/tests/test_element_mappings.py +++ b/yt/utilities/lib/tests/test_element_mappings.py @@ -1,17 +1,19 @@ import numpy as np + from yt.testing import assert_almost_equal -from yt.utilities.lib.element_mappings import \ - test_tetra_sampler, \ - test_hex_sampler, \ - test_tri_sampler, \ - test_quad_sampler, \ - test_quad2_sampler, \ - test_hex20_sampler, \ - test_wedge_sampler, \ - test_tri2_sampler, \ - test_tet2_sampler, \ - test_linear1D_sampler +from yt.utilities.lib.element_mappings import ( + test_hex20_sampler, + test_hex_sampler, + test_linear1D_sampler, + test_quad2_sampler, + test_quad_sampler, + test_tet2_sampler, + test_tetra_sampler, + test_tri2_sampler, + test_tri_sampler, + test_wedge_sampler, +) def check_all_vertices(sampler, vertices, field_values): diff --git a/yt/utilities/lib/tests/test_fill_region.py b/yt/utilities/lib/tests/test_fill_region.py index 4a5ac8095dc..d42f598b8c3 100644 --- a/yt/utilities/lib/tests/test_fill_region.py +++ b/yt/utilities/lib/tests/test_fill_region.py @@ -30,4 +30,3 @@ def test_fill_region(): for r in range(level + 1): for o, i in zip(output_fields, v): assert_equal( o[r::rf,r::rf,r::rf], i) - diff --git a/yt/utilities/lib/tests/test_geometry_utils.py b/yt/utilities/lib/tests/test_geometry_utils.py index e9cec61f348..b97f53762f6 100644 --- a/yt/utilities/lib/tests/test_geometry_utils.py +++ b/yt/utilities/lib/tests/test_geometry_utils.py @@ -1,14 +1,16 @@ import numpy as np -from yt.testing import \ - fake_random_ds, \ - assert_array_equal, \ - assert_array_less, \ - assert_equal, \ - assert_raises -from yt.utilities.lib.misc_utilities import \ - obtain_position_vector, \ - obtain_relative_velocity_vector +from yt.testing import ( + assert_array_equal, + assert_array_less, + assert_equal, + assert_raises, + fake_random_ds, +) +from yt.utilities.lib.misc_utilities import ( + obtain_position_vector, + obtain_relative_velocity_vector, +) _fields = ("density", "velocity_x", "velocity_y", "velocity_z") diff --git a/yt/utilities/lib/tests/test_nn.py b/yt/utilities/lib/tests/test_nn.py index 5c0b0833e0a..6165f6fee43 100644 --- a/yt/utilities/lib/tests/test_nn.py +++ b/yt/utilities/lib/tests/test_nn.py @@ -1,11 +1,12 @@ import numpy as np -from yt.utilities.lib.bounded_priority_queue import \ - validate, \ - validate_pid, \ - validate_nblist - from yt.testing import assert_array_equal +from yt.utilities.lib.bounded_priority_queue import ( + validate, + validate_nblist, + validate_pid, +) + # These test functions use utility functions in # yt.utilities.lib.bounded_priority_queue diff --git a/yt/utilities/lib/tests/test_ragged_arrays.py b/yt/utilities/lib/tests/test_ragged_arrays.py index 0e263fe373b..810dc5d8266 100644 --- a/yt/utilities/lib/tests/test_ragged_arrays.py +++ b/yt/utilities/lib/tests/test_ragged_arrays.py @@ -1,10 +1,7 @@ import numpy as np +from yt.testing import assert_equal, assert_rel_equal from yt.utilities.lib.ragged_arrays import index_unop -from yt.testing import \ - assert_equal, \ - assert_rel_equal - operations = ((np.sum, "sum"), (np.prod, "prod"), diff --git a/yt/utilities/lib/tests/test_sample.py b/yt/utilities/lib/tests/test_sample.py index c871936519b..a21bc1b81ee 100644 --- a/yt/utilities/lib/tests/test_sample.py +++ b/yt/utilities/lib/tests/test_sample.py @@ -1,8 +1,8 @@ import numpy as np -from yt.utilities.lib.particle_mesh_operations import \ - CICSample_3 from yt.testing import assert_allclose +from yt.utilities.lib.particle_mesh_operations import CICSample_3 + def setup(): pass diff --git a/yt/utilities/linear_interpolators.py b/yt/utilities/linear_interpolators.py index edc54faeead..a6f7633c861 100644 --- a/yt/utilities/linear_interpolators.py +++ b/yt/utilities/linear_interpolators.py @@ -1,7 +1,8 @@ import numpy as np -from yt.funcs import mylog import yt.utilities.lib.interpolators as lib +from yt.funcs import mylog + class UnilinearFieldInterpolator: def __init__(self, table, boundaries, field_names, truncate=False): diff --git a/yt/utilities/load_sample.py b/yt/utilities/load_sample.py index 23c0c79871d..b09f87e7fea 100644 --- a/yt/utilities/load_sample.py +++ b/yt/utilities/load_sample.py @@ -6,11 +6,13 @@ """ import os + import yt.utilities.sample_data as sd -from yt.funcs import mylog from yt.convenience import load +from yt.funcs import mylog from yt.utilities.on_demand_imports import _pooch as pch + def load_sample(name=None, specific_file=None, pbar=True): """ Load sample data with yt. Simple wrapper around yt.load to include fetching diff --git a/yt/utilities/lodgeit.py b/yt/utilities/lodgeit.py index 5c6ac6b7b06..4c56f5deb6b 100644 --- a/yt/utilities/lodgeit.py +++ b/yt/utilities/lodgeit.py @@ -30,6 +30,7 @@ import os import sys from optparse import OptionParser + if sys.version_info >= (3,0,0): unicode = str diff --git a/yt/utilities/logger.py b/yt/utilities/logger.py index ad2aaf3395f..846884f5651 100644 --- a/yt/utilities/logger.py +++ b/yt/utilities/logger.py @@ -1,5 +1,6 @@ import logging import sys + from yt.config import ytcfg # This next bit is grabbed from: diff --git a/yt/utilities/lru_cache.py b/yt/utilities/lru_cache.py index a2bb1e599e6..4106ee4c0ef 100644 --- a/yt/utilities/lru_cache.py +++ b/yt/utilities/lru_cache.py @@ -1,5 +1,4 @@ import sys - from collections import namedtuple from functools import update_wrapper from threading import RLock diff --git a/yt/utilities/math_utils.py b/yt/utilities/math_utils.py index b8867a6fc2e..129771803e3 100644 --- a/yt/utilities/math_utils.py +++ b/yt/utilities/math_utils.py @@ -1,7 +1,8 @@ -import numpy as np import math -from yt.units.yt_array import \ - YTArray + +import numpy as np + +from yt.units.yt_array import YTArray prec_accum = { np.int: np.int64, diff --git a/yt/utilities/mesh_code_generation.py b/yt/utilities/mesh_code_generation.py index e51fdc99356..8ae25ac9fe9 100644 --- a/yt/utilities/mesh_code_generation.py +++ b/yt/utilities/mesh_code_generation.py @@ -1,11 +1,5 @@ -from sympy import \ - symarray, \ - diff, \ - ccode, \ - Matrix, \ - MatrixSymbol import yaml - +from sympy import Matrix, MatrixSymbol, ccode, diff, symarray # define some templates used below fun_signature = '''cdef void %s(double* fx, diff --git a/yt/utilities/minimal_representation.py b/yt/utilities/minimal_representation.py index cffcbeffc87..14820568ae2 100644 --- a/yt/utilities/minimal_representation.py +++ b/yt/utilities/minimal_representation.py @@ -1,22 +1,20 @@ -import numpy as np import abc import json -import sys -from yt.utilities.on_demand_imports import _h5py as h5 import os -from uuid import uuid4 -import urllib import pickle +import sys +import urllib from tempfile import TemporaryFile +from uuid import uuid4 + +import numpy as np + from yt.config import ytcfg -from yt.funcs import \ - iterable, get_pbar, compare_dicts -from yt.utilities.exceptions import \ - YTHubRegisterError +from yt.funcs import compare_dicts, get_pbar, iterable +from yt.units.yt_array import YTArray, YTQuantity +from yt.utilities.exceptions import YTHubRegisterError from yt.utilities.logger import ytLogger as mylog -from yt.units.yt_array import \ - YTArray, \ - YTQuantity +from yt.utilities.on_demand_imports import _h5py as h5 if sys.version_info < (3, 0): from .poster.streaminghttp import register_openers diff --git a/yt/utilities/nodal_data_utils.py b/yt/utilities/nodal_data_utils.py index eeec6310743..d7506953a5e 100644 --- a/yt/utilities/nodal_data_utils.py +++ b/yt/utilities/nodal_data_utils.py @@ -1,4 +1,4 @@ -import numpy as np +import numpy as np _index_map = np.array([[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1], diff --git a/yt/utilities/on_demand_imports.py b/yt/utilities/on_demand_imports.py index 47360584b3f..08234e9c3c3 100644 --- a/yt/utilities/on_demand_imports.py +++ b/yt/utilities/on_demand_imports.py @@ -1,6 +1,8 @@ -from pkg_resources import parse_version import sys +from pkg_resources import parse_version + + class NotAModule: """ A class to implement an informative error message that will be outputted if diff --git a/yt/utilities/operator_registry.py b/yt/utilities/operator_registry.py index c262a7eb835..f60027e488a 100644 --- a/yt/utilities/operator_registry.py +++ b/yt/utilities/operator_registry.py @@ -1,5 +1,6 @@ import copy + class OperatorRegistry(dict): def find(self, op, *args, **kwargs): if isinstance(op, str): diff --git a/yt/utilities/orientation.py b/yt/utilities/orientation.py index 62893ee3e91..f5798262379 100644 --- a/yt/utilities/orientation.py +++ b/yt/utilities/orientation.py @@ -4,6 +4,7 @@ from yt.units.yt_array import YTArray from yt.utilities.exceptions import YTException + def _aligned(a, b): aligned_component = np.abs(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)) return np.isclose(aligned_component, 1.0, 1.0e-13) diff --git a/yt/utilities/parallel_tools/__init__.py b/yt/utilities/parallel_tools/__init__.py index ad451d69e99..4a3abab14ea 100644 --- a/yt/utilities/parallel_tools/__init__.py +++ b/yt/utilities/parallel_tools/__init__.py @@ -4,4 +4,3 @@ """ - diff --git a/yt/utilities/parallel_tools/controller_system.py b/yt/utilities/parallel_tools/controller_system.py index 9db54044611..a937a2f093a 100644 --- a/yt/utilities/parallel_tools/controller_system.py +++ b/yt/utilities/parallel_tools/controller_system.py @@ -1,7 +1,8 @@ -from .parallel_analysis_interface import \ - ProcessorPool from abc import abstractmethod +from .parallel_analysis_interface import ProcessorPool + + class WorkSplitter: def __init__(self, controller, group1, group2): self.group1 = group1 diff --git a/yt/utilities/parallel_tools/io_runner.py b/yt/utilities/parallel_tools/io_runner.py index e67568be1a7..c25e3e5084d 100644 --- a/yt/utilities/parallel_tools/io_runner.py +++ b/yt/utilities/parallel_tools/io_runner.py @@ -1,10 +1,12 @@ +import time +from contextlib import contextmanager + import numpy as np -from yt.utilities.logger import ytLogger as mylog -from .parallel_analysis_interface import \ - ProcessorPool, parallel_objects + from yt.utilities.io_handler import BaseIOHandler -from contextlib import contextmanager -import time +from yt.utilities.logger import ytLogger as mylog + +from .parallel_analysis_interface import ProcessorPool, parallel_objects try: from .parallel_analysis_interface import MPI @@ -169,5 +171,3 @@ def gq(ds): return dd.quantities["TotalQuantity"]("CellMassMsun") q = io_nodes("DD0087/DD0087", 8, 24, gq) mylog.info(q) - - diff --git a/yt/utilities/parallel_tools/parallel_analysis_interface.py b/yt/utilities/parallel_tools/parallel_analysis_interface.py index 61178d0b8f8..9b609ced29d 100644 --- a/yt/utilities/parallel_tools/parallel_analysis_interface.py +++ b/yt/utilities/parallel_tools/parallel_analysis_interface.py @@ -1,23 +1,21 @@ -from io import StringIO import itertools import logging -import numpy as np -import sys import os +import sys import traceback from functools import wraps +from io import StringIO -from yt.funcs import \ - ensure_list, iterable +import numpy as np +import yt.utilities.logger from yt.config import ytcfg from yt.data_objects.image_array import ImageArray -import yt.utilities.logger -from yt.utilities.lib.quad_tree import \ - QuadTree, merge_quadtrees -from yt.units.yt_array import YTArray +from yt.funcs import ensure_list, iterable from yt.units.unit_registry import UnitRegistry +from yt.units.yt_array import YTArray from yt.utilities.exceptions import YTNoDataInObjectError +from yt.utilities.lib.quad_tree import QuadTree, merge_quadtrees from yt.utilities.logger import ytLogger as mylog # We default to *no* parallelism unless it gets turned on, in which case this diff --git a/yt/utilities/parallel_tools/task_queue.py b/yt/utilities/parallel_tools/task_queue.py index 0c8260814a5..8b580f636bc 100644 --- a/yt/utilities/parallel_tools/task_queue.py +++ b/yt/utilities/parallel_tools/task_queue.py @@ -1,11 +1,13 @@ import numpy as np from yt.funcs import mylog -from .parallel_analysis_interface import \ - communication_system, \ - _get_comm, \ - parallel_capable, \ - ResultsStorage + +from .parallel_analysis_interface import ( + ResultsStorage, + _get_comm, + communication_system, + parallel_capable, +) messages = dict( task = dict(msg = 'next'), diff --git a/yt/utilities/parameter_file_storage.py b/yt/utilities/parameter_file_storage.py index 616fe495b7d..34ca70d5bf2 100644 --- a/yt/utilities/parameter_file_storage.py +++ b/yt/utilities/parameter_file_storage.py @@ -3,10 +3,10 @@ from itertools import islice from yt.config import ytcfg -from yt.funcs import \ - mylog -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - parallel_simple_proxy +from yt.funcs import mylog +from yt.utilities.parallel_tools.parallel_analysis_interface import ( + parallel_simple_proxy, +) output_type_registry = {} simulation_time_series_registry = {} diff --git a/yt/utilities/particle_generator.py b/yt/utilities/particle_generator.py index 7e407c73137..07fdaf46c4a 100644 --- a/yt/utilities/particle_generator.py +++ b/yt/utilities/particle_generator.py @@ -1,8 +1,9 @@ import numpy as np -from yt.utilities.lib.particle_mesh_operations import \ - CICSample_3 + from yt.funcs import get_pbar, issue_deprecation_warning from yt.units.yt_array import uconcatenate +from yt.utilities.lib.particle_mesh_operations import CICSample_3 + class ParticleGenerator: @@ -409,4 +410,3 @@ def __init__(self, ds, data_source, num_particles, field_list, z = uconcatenate(all_z) self._setup_particles(x, y, z) - diff --git a/yt/utilities/performance_counters.py b/yt/utilities/performance_counters.py index 86ded71c5d5..538bbaf42ad 100644 --- a/yt/utilities/performance_counters.py +++ b/yt/utilities/performance_counters.py @@ -1,6 +1,5 @@ import atexit import time - from bisect import insort from collections import defaultdict from datetime import datetime as dt @@ -9,6 +8,7 @@ from yt.config import ytcfg from yt.funcs import mylog + class PerformanceCounters: _shared_state = {} def __new__(cls, *args, **kwargs): diff --git a/yt/utilities/periodic_table.py b/yt/utilities/periodic_table.py index b25a6395cc0..3d1ebeab4dd 100644 --- a/yt/utilities/periodic_table.py +++ b/yt/utilities/periodic_table.py @@ -1,6 +1,7 @@ -import numpy as np import numbers +import numpy as np + _elements = ( (1, 1.0079400000, "Hydrogen", "H"), (2, 4.0026020000, "Helium", "He"), diff --git a/yt/utilities/physical_constants.py b/yt/utilities/physical_constants.py index aaa0cbdfaa3..a6fcb5c0fb7 100644 --- a/yt/utilities/physical_constants.py +++ b/yt/utilities/physical_constants.py @@ -1,30 +1,31 @@ from math import pi -from yt.utilities.physical_ratios import \ - mass_electron_grams, \ - amu_grams, \ - mass_hydrogen_grams, \ - speed_of_light_cm_per_s, \ - boltzmann_constant_erg_per_K, \ - mass_sun_grams, \ - mass_jupiter_grams, \ - mass_mercury_grams, \ - mass_venus_grams, \ - mass_earth_grams, \ - mass_mars_grams, \ - mass_saturn_grams, \ - mass_uranus_grams, \ - mass_neptune_grams, \ - planck_mass_grams, \ - planck_length_cm, \ - planck_time_s, \ - planck_energy_erg, \ - planck_charge_esu, \ - planck_temperature_K, \ - standard_gravity_cm_per_s2, \ - newton_cgs, \ - planck_cgs from yt.units.yt_array import YTQuantity +from yt.utilities.physical_ratios import ( + amu_grams, + boltzmann_constant_erg_per_K, + mass_earth_grams, + mass_electron_grams, + mass_hydrogen_grams, + mass_jupiter_grams, + mass_mars_grams, + mass_mercury_grams, + mass_neptune_grams, + mass_saturn_grams, + mass_sun_grams, + mass_uranus_grams, + mass_venus_grams, + newton_cgs, + planck_cgs, + planck_charge_esu, + planck_energy_erg, + planck_length_cm, + planck_mass_grams, + planck_temperature_K, + planck_time_s, + speed_of_light_cm_per_s, + standard_gravity_cm_per_s2, +) mass_electron_cgs = YTQuantity(mass_electron_grams, 'g') mass_electron = mass_electron_cgs @@ -137,4 +138,3 @@ # Misc standard_gravity_cgs = YTQuantity(standard_gravity_cm_per_s2, "cm/s**2") standard_gravity = standard_gravity_cgs - diff --git a/yt/utilities/physical_ratios.py b/yt/utilities/physical_ratios.py index ee446c07fd9..976e95d5d5d 100644 --- a/yt/utilities/physical_ratios.py +++ b/yt/utilities/physical_ratios.py @@ -1,4 +1,5 @@ import numpy as np + # # Physical Constants and Units Conversion Factors # diff --git a/yt/utilities/png_writer.py b/yt/utilities/png_writer.py index 8513a28e35f..836ae5beb03 100644 --- a/yt/utilities/png_writer.py +++ b/yt/utilities/png_writer.py @@ -1,6 +1,7 @@ +from io import BytesIO + import matplotlib._png as _png -from io import BytesIO def call_png_write_png(buffer, width, height, fileobj, dpi): _png.write_png(buffer, fileobj, dpi) diff --git a/yt/utilities/poster/__init__.py b/yt/utilities/poster/__init__.py index 7748064e3e4..d01b5de2a29 100644 --- a/yt/utilities/poster/__init__.py +++ b/yt/utilities/poster/__init__.py @@ -27,7 +27,6 @@ New in version 0.6.""" -from . import streaminghttp -from . import encode +from . import encode, streaminghttp version = (0, 8, 1) # Thanks JP! diff --git a/yt/utilities/poster/encode.py b/yt/utilities/poster/encode.py index 4c47fcb5c52..159945ab755 100644 --- a/yt/utilities/poster/encode.py +++ b/yt/utilities/poster/encode.py @@ -21,8 +21,11 @@ def gen_boundary(): bits = random.getrandbits(160) return sha.new(str(bits)).hexdigest() -import re, os, mimetypes +import mimetypes +import os +import re import urllib + try: from email.header import Header except ImportError: diff --git a/yt/utilities/poster/streaminghttp.py b/yt/utilities/poster/streaminghttp.py index 21571c1dbf8..0f5920406e0 100644 --- a/yt/utilities/poster/streaminghttp.py +++ b/yt/utilities/poster/streaminghttp.py @@ -28,9 +28,10 @@ import http.client as http_client -import urllib import socket import sys +import urllib + def request_has_data(req): if sys.version_info >= (3,0,0): diff --git a/yt/utilities/rpdb.py b/yt/utilities/rpdb.py index 50a534c03d2..8e72f668f75 100644 --- a/yt/utilities/rpdb.py +++ b/yt/utilities/rpdb.py @@ -1,14 +1,16 @@ import cmd import pdb +import signal import socket import sys -from io import StringIO import traceback -import signal -from xmlrpc.server import SimpleXMLRPCServer +from io import StringIO from xmlrpc.client import ServerProxy +from xmlrpc.server import SimpleXMLRPCServer + from yt.config import ytcfg + class PdbXMLRPCServer(SimpleXMLRPCServer): """ shutdown-enabled XMLRPCServer from diff --git a/yt/utilities/sample_data.py b/yt/utilities/sample_data.py index ac6da707669..3b567f84c0e 100644 --- a/yt/utilities/sample_data.py +++ b/yt/utilities/sample_data.py @@ -3,13 +3,13 @@ Purpose: Contains functions used for automatic downloading and loading of sample data that is not already present locally. """ -import pkg_resources import json import os -from yt.utilities.on_demand_imports import _pooch as pch +import pkg_resources from yt.config import ytcfg +from yt.utilities.on_demand_imports import _pooch as pch ## The format of the data registry json: ## diff --git a/yt/utilities/sdf.py b/yt/utilities/sdf.py index 8b20a972b17..39cbf29be8b 100644 --- a/yt/utilities/sdf.py +++ b/yt/utilities/sdf.py @@ -1,9 +1,11 @@ -from io import StringIO import os +from io import StringIO + import numpy as np from yt.funcs import mylog + def get_thingking_deps(): try: from thingking.httpmmap import HTTPArray diff --git a/yt/utilities/tests/test_amr_kdtree.py b/yt/utilities/tests/test_amr_kdtree.py index 88d3ed45fda..883752d3b3f 100644 --- a/yt/utilities/tests/test_amr_kdtree.py +++ b/yt/utilities/tests/test_amr_kdtree.py @@ -1,10 +1,12 @@ -from yt.utilities.amr_kdtree.api import AMRKDTree -import yt.utilities.initial_conditions as ic +import itertools + +import numpy as np + import yt.utilities.flagging_methods as fm +import yt.utilities.initial_conditions as ic from yt.frontends.stream.api import load_uniform_grid, refine_amr -from yt.testing import assert_equal, assert_almost_equal, fake_amr_ds -import numpy as np -import itertools +from yt.testing import assert_almost_equal, assert_equal, fake_amr_ds +from yt.utilities.amr_kdtree.api import AMRKDTree def test_amr_kdtree_coverage(): diff --git a/yt/utilities/tests/test_chemical_formulas.py b/yt/utilities/tests/test_chemical_formulas.py index 8dd00526d22..9cb68d0baae 100644 --- a/yt/utilities/tests/test_chemical_formulas.py +++ b/yt/utilities/tests/test_chemical_formulas.py @@ -1,4 +1,4 @@ -from yt.testing import assert_equal, assert_allclose +from yt.testing import assert_allclose, assert_equal from yt.utilities.chemical_formulas import ChemicalFormula, default_mu from yt.utilities.periodic_table import periodic_table diff --git a/yt/utilities/tests/test_config.py b/yt/utilities/tests/test_config.py index 5caecd684b2..f8bcda43f72 100644 --- a/yt/utilities/tests/test_config.py +++ b/yt/utilities/tests/test_config.py @@ -1,6 +1,15 @@ import contextlib import os import sys +import unittest +from configparser import NoOptionError +from io import StringIO + +import yt.config +import yt.utilities.command_line +from yt.config import _OLD_CONFIG_FILE, CONFIG_DIR, CURRENT_CONFIG_FILE, YTConfigParser +from yt.fields.tests.test_fields_plugins import TEST_PLUGIN_FILE + if sys.version_info.major < 3: try: import mock @@ -8,14 +17,6 @@ mock = None else: import unittest.mock as mock -import unittest -import yt.utilities.command_line -import yt.config -from yt.config import \ - CURRENT_CONFIG_FILE, _OLD_CONFIG_FILE, CONFIG_DIR, YTConfigParser -from io import StringIO -from configparser import NoOptionError -from yt.fields.tests.test_fields_plugins import TEST_PLUGIN_FILE _TEST_PLUGIN = '_test_plugin.py' _DUMMY_CFG = ['[yt]', 'loglevel = 49', 'pluginfilename = ' + _TEST_PLUGIN] diff --git a/yt/utilities/tests/test_coordinate_conversions.py b/yt/utilities/tests/test_coordinate_conversions.py index a90571507fe..9f244e36a47 100644 --- a/yt/utilities/tests/test_coordinate_conversions.py +++ b/yt/utilities/tests/test_coordinate_conversions.py @@ -1,16 +1,20 @@ import numpy as np from yt.testing import assert_array_almost_equal -from yt.utilities.math_utils import \ - get_sph_r_component, \ - get_sph_theta_component, \ - get_sph_phi_component, \ - get_cyl_r_component, \ - get_cyl_z_component, \ - get_cyl_theta_component, \ - get_cyl_r, get_cyl_theta, \ - get_cyl_z, get_sph_r, \ - get_sph_theta, get_sph_phi +from yt.utilities.math_utils import ( + get_cyl_r, + get_cyl_r_component, + get_cyl_theta, + get_cyl_theta_component, + get_cyl_z, + get_cyl_z_component, + get_sph_phi, + get_sph_phi_component, + get_sph_r, + get_sph_r_component, + get_sph_theta, + get_sph_theta_component, +) # Randomly generated coordinates in the domain [[-1,1],[-1,1],-1,1]] coords = np.array([[-0.41503037, -0.22102472, -0.55774212], diff --git a/yt/utilities/tests/test_cosmology.py b/yt/utilities/tests/test_cosmology.py index 224d7500485..b8c69b513ad 100644 --- a/yt/utilities/tests/test_cosmology.py +++ b/yt/utilities/tests/test_cosmology.py @@ -1,20 +1,18 @@ -import numpy as np import os -from yt.utilities.on_demand_imports import \ - _yaml as yaml -from yt.testing import \ - assert_almost_equal, \ - assert_rel_equal, \ - assert_equal, \ - requires_file, \ - requires_module -from yt.units.yt_array import \ - YTArray, \ - YTQuantity -from yt.utilities.answer_testing.framework import \ - data_dir_load -from yt.utilities.cosmology import \ - Cosmology + +import numpy as np + +from yt.testing import ( + assert_almost_equal, + assert_equal, + assert_rel_equal, + requires_file, + requires_module, +) +from yt.units.yt_array import YTArray, YTQuantity +from yt.utilities.answer_testing.framework import data_dir_load +from yt.utilities.cosmology import Cosmology +from yt.utilities.on_demand_imports import _yaml as yaml local_dir = os.path.dirname(os.path.abspath(__file__)) diff --git a/yt/utilities/tests/test_decompose.py b/yt/utilities/tests/test_decompose.py index 2ad83192442..1c45fe2b2ba 100644 --- a/yt/utilities/tests/test_decompose.py +++ b/yt/utilities/tests/test_decompose.py @@ -1,6 +1,7 @@ -from yt.testing import assert_array_equal, assert_almost_equal import numpy as np + import yt.utilities.decompose as dec +from yt.testing import assert_almost_equal, assert_array_equal def setup(): diff --git a/yt/utilities/tests/test_hierarchy_inspection.py b/yt/utilities/tests/test_hierarchy_inspection.py index c343abb229d..a1883a0a93d 100644 --- a/yt/utilities/tests/test_hierarchy_inspection.py +++ b/yt/utilities/tests/test_hierarchy_inspection.py @@ -5,7 +5,8 @@ @author: stuart """ -from .. hierarchy_inspection import find_lowest_subclasses +from ..hierarchy_inspection import find_lowest_subclasses + class level1: pass diff --git a/yt/utilities/tests/test_interpolators.py b/yt/utilities/tests/test_interpolators.py index 4f10dc0d98c..4ab219c5194 100644 --- a/yt/utilities/tests/test_interpolators.py +++ b/yt/utilities/tests/test_interpolators.py @@ -1,13 +1,11 @@ import warnings + import numpy as np -from yt.testing import \ - assert_array_equal, \ - assert_array_almost_equal, \ - fake_random_ds import yt.utilities.linear_interpolators as lin -from yt.utilities.lib.interpolators import \ - ghost_zone_interpolate +from yt.testing import assert_array_almost_equal, assert_array_equal, fake_random_ds +from yt.utilities.lib.interpolators import ghost_zone_interpolate + def setup(): pass diff --git a/yt/utilities/tests/test_load_sample.py b/yt/utilities/tests/test_load_sample.py index 66de0ad946f..192e3d649fa 100644 --- a/yt/utilities/tests/test_load_sample.py +++ b/yt/utilities/tests/test_load_sample.py @@ -30,4 +30,3 @@ def test_name_validator(): assert_equal(fileext, expected_answers["fileext"]) assert_equal(bname, expected_answers["basename"]) assert_equal(ext, expected_answers["extension"]) - diff --git a/yt/utilities/tests/test_minimal_representation.py b/yt/utilities/tests/test_minimal_representation.py index 49bef305f01..e42d32388ed 100644 --- a/yt/utilities/tests/test_minimal_representation.py +++ b/yt/utilities/tests/test_minimal_representation.py @@ -1,8 +1,8 @@ import os.path + import yt from yt.config import ytcfg -from yt.testing import \ - assert_equal, requires_file, assert_raises +from yt.testing import assert_equal, assert_raises, requires_file G30 = "IsolatedGalaxy/galaxy0030/galaxy0030" diff --git a/yt/utilities/tests/test_particle_generator.py b/yt/utilities/tests/test_particle_generator.py index 40aa56efc6b..314c1ee4fbe 100644 --- a/yt/utilities/tests/test_particle_generator.py +++ b/yt/utilities/tests/test_particle_generator.py @@ -1,15 +1,16 @@ import numpy as np -from yt.testing import \ - assert_almost_equal, \ - assert_equal -from yt.utilities.particle_generator import \ - WithDensityParticleGenerator, \ - LatticeParticleGenerator, \ - FromListParticleGenerator -from yt.frontends.stream.api import load_uniform_grid, refine_amr -import yt.utilities.initial_conditions as ic + import yt.utilities.flagging_methods as fm +import yt.utilities.initial_conditions as ic +from yt.frontends.stream.api import load_uniform_grid, refine_amr +from yt.testing import assert_almost_equal, assert_equal from yt.units.yt_array import uconcatenate +from yt.utilities.particle_generator import ( + FromListParticleGenerator, + LatticeParticleGenerator, + WithDensityParticleGenerator, +) + def test_particle_generator(): # First generate our dataset @@ -137,4 +138,3 @@ def new_indices(): del fields del dens del temp - diff --git a/yt/utilities/tests/test_periodic_table.py b/yt/utilities/tests/test_periodic_table.py index 96613dac164..fe7e8770229 100644 --- a/yt/utilities/tests/test_periodic_table.py +++ b/yt/utilities/tests/test_periodic_table.py @@ -1,6 +1,7 @@ from yt.testing import assert_equal from yt.utilities.periodic_table import _elements, periodic_table + def test_element_accuracy(): for num, w, name, sym in _elements: e0 = periodic_table[num] diff --git a/yt/utilities/tests/test_periodicity.py b/yt/utilities/tests/test_periodicity.py index bfb6b1c4b63..ddf3dc987ba 100644 --- a/yt/utilities/tests/test_periodicity.py +++ b/yt/utilities/tests/test_periodicity.py @@ -1,10 +1,9 @@ import numpy as np -from yt.testing import \ - fake_random_ds, \ - assert_almost_equal +from yt.testing import assert_almost_equal, fake_random_ds from yt.utilities.math_utils import euclidean_dist, periodic_dist + def setup(): from yt.config import ytcfg ytcfg["yt","__withintesting"] = "True" diff --git a/yt/utilities/tests/test_selectors.py b/yt/utilities/tests/test_selectors.py index 61c058de71f..4f570358bf2 100644 --- a/yt/utilities/tests/test_selectors.py +++ b/yt/utilities/tests/test_selectors.py @@ -1,6 +1,6 @@ import numpy as np -from yt.testing import \ - fake_random_ds, assert_equal, assert_array_less + +from yt.testing import assert_array_less, assert_equal, fake_random_ds from yt.utilities.math_utils import periodic_dist diff --git a/yt/visualization/__init__.py b/yt/visualization/__init__.py index 938c0f5ff08..4a35d386919 100644 --- a/yt/visualization/__init__.py +++ b/yt/visualization/__init__.py @@ -9,4 +9,3 @@ """ - diff --git a/yt/visualization/_colormap_data.py b/yt/visualization/_colormap_data.py index 3a4e68601b8..d5fc2c87cd2 100644 --- a/yt/visualization/_colormap_data.py +++ b/yt/visualization/_colormap_data.py @@ -2,6 +2,7 @@ import numpy as np from numpy import array + color_map_luts = {} diff --git a/yt/visualization/_mpl_imports.py b/yt/visualization/_mpl_imports.py index 71b87a2053b..ea8eeb873fa 100644 --- a/yt/visualization/_mpl_imports.py +++ b/yt/visualization/_mpl_imports.py @@ -1,14 +1,7 @@ import matplotlib -matplotlib.rc('contour', negative_linestyle='solid') - -from matplotlib.backends.backend_agg import \ - FigureCanvasAgg - -from matplotlib.backends.backend_pdf import \ - FigureCanvasPdf +from matplotlib.backends.backend_agg import FigureCanvasAgg +from matplotlib.backends.backend_pdf import FigureCanvasPdf +from matplotlib.backends.backend_ps import FigureCanvasPS +from matplotlib.backends.backend_svg import FigureCanvasSVG -from matplotlib.backends.backend_ps import \ - FigureCanvasPS - -from matplotlib.backends.backend_svg import \ - FigureCanvasSVG +matplotlib.rc('contour', negative_linestyle='solid') diff --git a/yt/visualization/api.py b/yt/visualization/api.py index 442d71181aa..c4fc33d84e0 100644 --- a/yt/visualization/api.py +++ b/yt/visualization/api.py @@ -1,57 +1,37 @@ -from .color_maps import \ - add_colormap, \ - show_colormaps, \ - make_colormap - -from .particle_plots import \ - ParticleProjectionPlot, \ - ParticlePhasePlot, \ - ParticlePlot - -from .fixed_resolution import \ - FixedResolutionBuffer, \ - ObliqueFixedResolutionBuffer, \ - ParticleImageBuffer - -from .image_writer import \ - multi_image_composite, \ - write_bitmap, \ - write_image, \ - map_to_colors, \ - splat_points, \ - apply_colormap, \ - scale_image, \ - write_projection - -from .plot_modifications import \ - PlotCallback, \ - callback_registry - -from .streamlines import \ - Streamlines - -from .plot_window import \ - SlicePlot, \ - AxisAlignedSlicePlot, \ - OffAxisSlicePlot, \ - ProjectionPlot, \ - OffAxisProjectionPlot, \ - plot_2d - -from .line_plot import \ - LinePlot, \ - LineBuffer - -from .profile_plotter import \ - ProfilePlot, \ - PhasePlot - -from .base_plot_types import \ - get_multi_plot - -from .fits_image import \ - FITSImageData, \ - FITSSlice, \ - FITSOffAxisSlice, \ - FITSProjection, \ - FITSOffAxisProjection +from .base_plot_types import get_multi_plot +from .color_maps import add_colormap, make_colormap, show_colormaps +from .fits_image import ( + FITSImageData, + FITSOffAxisProjection, + FITSOffAxisSlice, + FITSProjection, + FITSSlice, +) +from .fixed_resolution import ( + FixedResolutionBuffer, + ObliqueFixedResolutionBuffer, + ParticleImageBuffer, +) +from .image_writer import ( + apply_colormap, + map_to_colors, + multi_image_composite, + scale_image, + splat_points, + write_bitmap, + write_image, + write_projection, +) +from .line_plot import LineBuffer, LinePlot +from .particle_plots import ParticlePhasePlot, ParticlePlot, ParticleProjectionPlot +from .plot_modifications import PlotCallback, callback_registry +from .plot_window import ( + AxisAlignedSlicePlot, + OffAxisProjectionPlot, + OffAxisSlicePlot, + ProjectionPlot, + SlicePlot, + plot_2d, +) +from .profile_plotter import PhasePlot, ProfilePlot +from .streamlines import Streamlines diff --git a/yt/visualization/base_plot_types.py b/yt/visualization/base_plot_types.py index 07bc37fde35..2270069ee96 100644 --- a/yt/visualization/base_plot_types.py +++ b/yt/visualization/base_plot_types.py @@ -1,17 +1,17 @@ -import matplotlib -import numpy as np - from distutils.version import LooseVersion from io import BytesIO -from yt.funcs import \ - get_image_suffix, \ - mylog, \ - iterable, \ - get_brewer_cmap, \ - matplotlib_style_context, \ - get_interactivity +import matplotlib +import numpy as np +from yt.funcs import ( + get_brewer_cmap, + get_image_suffix, + get_interactivity, + iterable, + matplotlib_style_context, + mylog, +) backend_dict = {'GTK': ['backend_gtk', 'FigureCanvasGTK', 'FigureManagerGTK'], diff --git a/yt/visualization/color_maps.py b/yt/visualization/color_maps.py index e3a70aac24d..00e27cad9d1 100644 --- a/yt/visualization/color_maps.py +++ b/yt/visualization/color_maps.py @@ -1,7 +1,7 @@ +import matplotlib.cm as mcm +import matplotlib.colors as cc import numpy as np -import matplotlib.colors as cc -import matplotlib.cm as mcm from . import _colormap_data as _cm try: diff --git a/yt/visualization/eps_writer.py b/yt/visualization/eps_writer.py index 11bcdaccd42..bc7af378f8f 100644 --- a/yt/visualization/eps_writer.py +++ b/yt/visualization/eps_writer.py @@ -1,16 +1,17 @@ -import pyx +import matplotlib.pyplot as plt import numpy as np from matplotlib import cm -import matplotlib.pyplot as plt -from yt.config import \ - ytcfg +import pyx +from yt.config import ytcfg +from yt.funcs import issue_deprecation_warning +from yt.units.unit_object import Unit +from yt.units.yt_array import YTQuantity from yt.utilities.logger import ytLogger as mylog + from .plot_window import PlotWindow from .profile_plotter import PhasePlot, ProfilePlot -from yt.units.yt_array import YTQuantity -from yt.units.unit_object import Unit -from yt.funcs import issue_deprecation_warning + def convert_frac_to_tex(string): frac_pos = string.find(r'\frac') @@ -1366,4 +1367,3 @@ def return_colormap(cmap=None, label="", range=(0,1), log=False): if cmap is None: cmap = ytcfg.get("yt", "default_colormap") return {'cmap': cmap, 'name': label, 'range': range, 'log': log} - diff --git a/yt/visualization/fits_image.py b/yt/visualization/fits_image.py index e73567d70c9..14fc9c2204b 100644 --- a/yt/visualization/fits_image.py +++ b/yt/visualization/fits_image.py @@ -1,23 +1,22 @@ -import numpy as np -from itertools import count -from yt.fields.derived_field import DerivedField -from yt.funcs import mylog, iterable, fix_axis, ensure_list, \ - issue_deprecation_warning -from yt.visualization.fixed_resolution import FixedResolutionBuffer -from yt.data_objects.image_array import ImageArray -from yt.data_objects.construction_data_containers import YTCoveringGrid -from yt.utilities.on_demand_imports import _astropy -from yt.units.yt_array import YTQuantity, YTArray -from yt.units.unit_object import Unit -from yt.units import dimensions -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - parallel_root_only -from yt.visualization.volume_rendering.off_axis_projection import \ - off_axis_projection import re import sys +from itertools import count from numbers import Number as numeric_type +import numpy as np + +from yt.data_objects.construction_data_containers import YTCoveringGrid +from yt.data_objects.image_array import ImageArray +from yt.fields.derived_field import DerivedField +from yt.funcs import ensure_list, fix_axis, issue_deprecation_warning, iterable, mylog +from yt.units import dimensions +from yt.units.unit_object import Unit +from yt.units.yt_array import YTArray, YTQuantity +from yt.utilities.on_demand_imports import _astropy +from yt.utilities.parallel_tools.parallel_analysis_interface import parallel_root_only +from yt.visualization.fixed_resolution import FixedResolutionBuffer +from yt.visualization.volume_rendering.off_axis_projection import off_axis_projection + class UnitfulHDU: def __init__(self, hdu): diff --git a/yt/visualization/fixed_resolution.py b/yt/visualization/fixed_resolution.py index b16bd8f8b19..3388b01f053 100644 --- a/yt/visualization/fixed_resolution.py +++ b/yt/visualization/fixed_resolution.py @@ -1,23 +1,25 @@ -from yt.frontends.ytdata.utilities import \ - save_as_dataset -from yt.funcs import \ - get_output_filename, \ - mylog, \ - ensure_list, \ - deprecate, \ - issue_deprecation_warning -from .volume_rendering.api import off_axis_projection -from .fixed_resolution_filters import apply_filter, filter_registry +import types +import weakref + +import numpy as np + from yt.data_objects.image_array import ImageArray -from yt.utilities.lib.pixelization_routines import \ - pixelize_cylinder +from yt.frontends.stream.api import load_uniform_grid +from yt.frontends.ytdata.utilities import save_as_dataset +from yt.funcs import ( + deprecate, + ensure_list, + get_output_filename, + issue_deprecation_warning, + mylog, +) from yt.utilities.lib.api import add_points_to_greyscale_image +from yt.utilities.lib.pixelization_routines import pixelize_cylinder from yt.utilities.on_demand_imports import _h5py as h5py -from yt.frontends.stream.api import load_uniform_grid -import numpy as np -import weakref -import types +from .fixed_resolution_filters import apply_filter, filter_registry +from .volume_rendering.api import off_axis_projection + class FixedResolutionBuffer: r""" diff --git a/yt/visualization/fixed_resolution_filters.py b/yt/visualization/fixed_resolution_filters.py index 801b6f776de..3cf98728672 100644 --- a/yt/visualization/fixed_resolution_filters.py +++ b/yt/visualization/fixed_resolution_filters.py @@ -1,6 +1,7 @@ -import numpy as np from functools import wraps +import numpy as np + filter_registry = {} diff --git a/yt/visualization/image_writer.py b/yt/visualization/image_writer.py index c36f3303a3a..1fccf921dc4 100644 --- a/yt/visualization/image_writer.py +++ b/yt/visualization/image_writer.py @@ -1,18 +1,16 @@ +import builtins + import numpy as np -from yt.config import \ - ytcfg -from yt.funcs import \ - mylog, \ - get_image_suffix, \ - get_brewer_cmap +import yt.utilities.lib.image_utilities as au +import yt.utilities.png_writer as pw +from yt.config import ytcfg +from yt.funcs import get_brewer_cmap, get_image_suffix, mylog from yt.units.yt_array import YTQuantity from yt.utilities.exceptions import YTNotInsideNotebook -from .color_maps import mcm + from . import _colormap_data as cmd -import yt.utilities.lib.image_utilities as au -import yt.utilities.png_writer as pw -import builtins +from .color_maps import mcm def scale_image(image, mi=None, ma=None): @@ -441,4 +439,3 @@ def display_in_notebook(image, max_val=None): ) else: raise YTNotInsideNotebook - diff --git a/yt/visualization/line_plot.py b/yt/visualization/line_plot.py index dbe91b07c9b..1814107f0f3 100644 --- a/yt/visualization/line_plot.py +++ b/yt/visualization/line_plot.py @@ -1,21 +1,19 @@ +from collections import defaultdict + import numpy as np -from collections import defaultdict -from yt.funcs import \ - iterable, \ - mylog -from yt.units.unit_object import \ - Unit -from yt.units.yt_array import \ - YTArray -from yt.visualization.base_plot_types import \ - PlotMPL -from yt.visualization.plot_container import \ - PlotContainer, \ - PlotDictionary, \ - log_transform, \ - linear_transform, \ - invalidate_plot +from yt.funcs import iterable, mylog +from yt.units.unit_object import Unit +from yt.units.yt_array import YTArray +from yt.visualization.base_plot_types import PlotMPL +from yt.visualization.plot_container import ( + PlotContainer, + PlotDictionary, + invalidate_plot, + linear_transform, + log_transform, +) + class LineBuffer: r""" diff --git a/yt/visualization/mapserver/pannable_map.py b/yt/visualization/mapserver/pannable_map.py index 73fe2b24382..77b82d06c0f 100644 --- a/yt/visualization/mapserver/pannable_map.py +++ b/yt/visualization/mapserver/pannable_map.py @@ -1,14 +1,13 @@ import os -import numpy as np - from functools import wraps -from yt.visualization.image_writer import apply_colormap -from yt.visualization.fixed_resolution import FixedResolutionBuffer -from yt.utilities.lib.misc_utilities import get_color_bounds -from yt.utilities.png_writer import write_png_to_string +import numpy as np import bottle +from yt.utilities.lib.misc_utilities import get_color_bounds +from yt.utilities.png_writer import write_png_to_string +from yt.visualization.fixed_resolution import FixedResolutionBuffer +from yt.visualization.image_writer import apply_colormap local_dir = os.path.dirname(__file__) diff --git a/yt/visualization/particle_plots.py b/yt/visualization/particle_plots.py index 3aa7a6e1351..c0b07d5bdbd 100644 --- a/yt/visualization/particle_plots.py +++ b/yt/visualization/particle_plots.py @@ -1,19 +1,12 @@ import numpy as np -from yt.visualization.fixed_resolution import \ - ParticleImageBuffer -from yt.funcs import \ - ensure_list, \ - fix_axis +from yt.data_objects.profiles import create_profile +from yt.funcs import ensure_list, fix_axis from yt.units.yt_array import YTArray -from .plot_window import \ - get_axes_unit, \ - get_window_parameters, \ - PWViewerMPL -from yt.data_objects.profiles import \ - create_profile -from yt.visualization.profile_plotter import \ - PhasePlot +from yt.visualization.fixed_resolution import ParticleImageBuffer +from yt.visualization.profile_plotter import PhasePlot + +from .plot_window import PWViewerMPL, get_axes_unit, get_window_parameters class ParticleAxisAlignedDummyDataSource: diff --git a/yt/visualization/plot_container.py b/yt/visualization/plot_container.py index 853a952cb3d..732021e9966 100644 --- a/yt/visualization/plot_container.py +++ b/yt/visualization/plot_container.py @@ -1,33 +1,27 @@ -import builtins -from yt.funcs import mylog -from yt.units import YTQuantity - import base64 -import numpy as np -import matplotlib +import builtins import os - from collections import defaultdict from functools import wraps -from yt.config import \ - ytcfg -from yt.data_objects.time_series import \ - DatasetSeries -from yt.funcs import \ - get_image_suffix, \ - iterable, \ - ensure_dir, \ - ensure_list, \ - issue_deprecation_warning -from yt.units.unit_object import \ - Unit -from yt.utilities.definitions import \ - formatted_length_unit_names -from yt.utilities.exceptions import \ - YTNotInsideNotebook -from yt.visualization.color_maps import \ - yt_colormaps +import matplotlib +import numpy as np + +from yt.config import ytcfg +from yt.data_objects.time_series import DatasetSeries +from yt.funcs import ( + ensure_dir, + ensure_list, + get_image_suffix, + issue_deprecation_warning, + iterable, + mylog, +) +from yt.units import YTQuantity +from yt.units.unit_object import Unit +from yt.utilities.definitions import formatted_length_unit_names +from yt.utilities.exceptions import YTNotInsideNotebook +from yt.visualization.color_maps import yt_colormaps latex_prefixes = { "u": r"\mu", diff --git a/yt/visualization/plot_modifications.py b/yt/visualization/plot_modifications.py index 84e16430bcf..a9b4c93ccd9 100644 --- a/yt/visualization/plot_modifications.py +++ b/yt/visualization/plot_modifications.py @@ -1,48 +1,35 @@ +import re import warnings +from functools import wraps +from numbers import Number import matplotlib import numpy as np -import re - -from functools import wraps -from numbers import Number - -from yt.data_objects.level_sets.clump_handling import \ - Clump -from yt.frontends.ytdata.data_structures import \ - YTClumpContainer +from yt.data_objects.data_containers import YTDataContainer +from yt.data_objects.level_sets.clump_handling import Clump from yt.data_objects.selection_data_containers import YTCutRegion -from yt.data_objects.data_containers import \ - YTDataContainer -from yt.data_objects.static_output import \ - Dataset -from yt.funcs import \ - iterable, \ - mylog, \ - validate_width_tuple -from yt.geometry.geometry_handler import \ - is_curvilinear +from yt.data_objects.static_output import Dataset +from yt.frontends.ytdata.data_structures import YTClumpContainer +from yt.funcs import iterable, mylog, validate_width_tuple +from yt.geometry.geometry_handler import is_curvilinear +from yt.geometry.unstructured_mesh_handler import UnstructuredIndex from yt.units import dimensions -from yt.units.yt_array import YTQuantity, YTArray, uhstack from yt.units.unit_object import Unit -from yt.visualization.image_writer import apply_colormap +from yt.units.yt_array import YTArray, YTQuantity, uhstack +from yt.utilities.exceptions import YTDataTypeUnsupported from yt.utilities.lib.geometry_utils import triangle_plane_intersect -from yt.utilities.lib.pixelization_routines import \ - pixelize_off_axis_cartesian, \ - pixelize_cartesian -from yt.utilities.lib.line_integral_convolution import \ - line_integral_convolution_2d -from yt.geometry.unstructured_mesh_handler import UnstructuredIndex +from yt.utilities.lib.line_integral_convolution import line_integral_convolution_2d from yt.utilities.lib.mesh_triangulation import triangulate_indices -from yt.utilities.exceptions import \ - YTDataTypeUnsupported -from yt.utilities.math_utils import \ - periodic_ray -from yt.utilities.on_demand_imports import \ - NotAModule +from yt.utilities.lib.pixelization_routines import ( + pixelize_cartesian, + pixelize_off_axis_cartesian, +) +from yt.utilities.math_utils import periodic_ray +from yt.utilities.on_demand_imports import NotAModule +from yt.visualization.image_writer import apply_colormap callback_registry = {} diff --git a/yt/visualization/plot_window.py b/yt/visualization/plot_window.py index 59f2a6feb74..073deeae957 100644 --- a/yt/visualization/plot_window.py +++ b/yt/visualization/plot_window.py @@ -1,53 +1,56 @@ -import numpy as np -import matplotlib -import types import sys - +import types from collections import defaultdict from distutils.version import LooseVersion from numbers import Number -from .base_plot_types import \ - ImagePlotMPL -from .fixed_resolution import \ - FixedResolutionBuffer, \ - OffAxisProjectionFixedResolutionBuffer -from .plot_modifications import callback_registry -from .plot_container import \ - ImagePlotContainer, \ - log_transform, linear_transform, symlog_transform, \ - get_log_minorticks, get_symlog_minorticks, \ - invalidate_data, invalidate_plot, invalidate_figure, \ - apply_callback -from .base_plot_types import CallbackWrapper - -from yt.data_objects.image_array import \ - ImageArray -from yt.frontends.ytdata.data_structures import \ - YTSpatialPlotDataset -from yt.funcs import \ - mylog, iterable, ensure_list, \ - fix_axis, fix_unitary, obj_length, \ - issue_deprecation_warning -from yt.units.unit_object import \ - Unit -from yt.units.unit_registry import \ - UnitParseError -from yt.units.yt_array import \ - YTArray, YTQuantity -from yt.utilities.math_utils import \ - ortho_find -from yt.utilities.orientation import \ - Orientation -from yt.utilities.exceptions import \ - YTCannotParseUnitDisplayName, \ - YTPlotCallbackError, \ - YTDataTypeUnsupported, \ - YTInvalidFieldType, \ - YTUnitNotRecognized +import matplotlib +import numpy as np from unyt.exceptions import UnitConversionError +from yt.data_objects.image_array import ImageArray +from yt.frontends.ytdata.data_structures import YTSpatialPlotDataset +from yt.funcs import ( + ensure_list, + fix_axis, + fix_unitary, + issue_deprecation_warning, + iterable, + mylog, + obj_length, +) +from yt.units.unit_object import Unit +from yt.units.unit_registry import UnitParseError +from yt.units.yt_array import YTArray, YTQuantity +from yt.utilities.exceptions import ( + YTCannotParseUnitDisplayName, + YTDataTypeUnsupported, + YTInvalidFieldType, + YTPlotCallbackError, + YTUnitNotRecognized, +) +from yt.utilities.math_utils import ortho_find +from yt.utilities.orientation import Orientation + +from .base_plot_types import CallbackWrapper, ImagePlotMPL +from .fixed_resolution import ( + FixedResolutionBuffer, + OffAxisProjectionFixedResolutionBuffer, +) from .geo_plot_utils import get_mpl_transform +from .plot_container import ( + ImagePlotContainer, + apply_callback, + get_log_minorticks, + get_symlog_minorticks, + invalidate_data, + invalidate_figure, + invalidate_plot, + linear_transform, + log_transform, + symlog_transform, +) +from .plot_modifications import callback_registry MPL_VERSION = LooseVersion(matplotlib.__version__) diff --git a/yt/visualization/profile_plotter.py b/yt/visualization/profile_plotter.py index a18140c9be7..33f1ed3984f 100644 --- a/yt/visualization/profile_plotter.py +++ b/yt/visualization/profile_plotter.py @@ -1,35 +1,30 @@ +import base64 import builtins +import os from collections import OrderedDict from distutils.version import LooseVersion -import base64 -import os from functools import wraps import matplotlib import numpy as np -from .base_plot_types import \ - PlotMPL, ImagePlotMPL -from .plot_container import \ - ImagePlotContainer, \ - log_transform, linear_transform, get_log_minorticks, \ - validate_plot, invalidate_plot -from yt.data_objects.profiles import \ - create_profile, sanitize_field_tuple_keys -from yt.data_objects.static_output import \ - Dataset -from yt.data_objects.data_containers import \ - YTSelectionContainer -from yt.frontends.ytdata.data_structures import \ - YTProfileDataset -from yt.utilities.exceptions import \ - YTNotInsideNotebook +from yt.data_objects.data_containers import YTSelectionContainer +from yt.data_objects.profiles import create_profile, sanitize_field_tuple_keys +from yt.data_objects.static_output import Dataset +from yt.frontends.ytdata.data_structures import YTProfileDataset +from yt.funcs import ensure_list, get_image_suffix, iterable, matplotlib_style_context +from yt.utilities.exceptions import YTNotInsideNotebook from yt.utilities.logger import ytLogger as mylog -from yt.funcs import \ - ensure_list, \ - get_image_suffix, \ - matplotlib_style_context, \ - iterable + +from .base_plot_types import ImagePlotMPL, PlotMPL +from .plot_container import ( + ImagePlotContainer, + get_log_minorticks, + invalidate_plot, + linear_transform, + log_transform, + validate_plot, +) MPL_VERSION = LooseVersion(matplotlib.__version__) diff --git a/yt/visualization/streamlines.py b/yt/visualization/streamlines.py index acd6872a36c..97246e078ff 100644 --- a/yt/visualization/streamlines.py +++ b/yt/visualization/streamlines.py @@ -1,10 +1,14 @@ import numpy as np + from yt.data_objects.construction_data_containers import YTStreamline from yt.funcs import get_pbar from yt.units.yt_array import YTArray -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - ParallelAnalysisInterface, parallel_passthrough from yt.utilities.amr_kdtree.api import AMRKDTree +from yt.utilities.parallel_tools.parallel_analysis_interface import ( + ParallelAnalysisInterface, + parallel_passthrough, +) + def sanitize_length(length, ds): # Ensure that lengths passed in with units are returned as code_length diff --git a/yt/visualization/tests/test_callbacks.py b/yt/visualization/tests/test_callbacks.py index 26d8441e8a7..4c8daf1ca46 100644 --- a/yt/visualization/tests/test_callbacks.py +++ b/yt/visualization/tests/test_callbacks.py @@ -1,29 +1,24 @@ -import tempfile +import contextlib import shutil -from numpy.testing import \ - assert_raises, \ - assert_array_equal - -from yt.config import \ - ytcfg -from yt.testing import \ - fake_amr_ds, \ - fake_random_ds, \ - fake_tetrahedral_ds, \ - fake_hexahedral_ds, \ - assert_fname, \ - requires_file +import tempfile + +from numpy.testing import assert_array_equal, assert_raises + import yt.units as u -from yt.utilities.exceptions import \ - YTPlotCallbackError, \ - YTDataTypeUnsupported -from yt.visualization.api import \ - SlicePlot, ProjectionPlot, OffAxisSlicePlot +from yt.config import ytcfg from yt.convenience import load +from yt.testing import ( + assert_fname, + fake_amr_ds, + fake_hexahedral_ds, + fake_random_ds, + fake_tetrahedral_ds, + requires_file, +) +from yt.utilities.exceptions import YTDataTypeUnsupported, YTPlotCallbackError +from yt.visualization.api import OffAxisSlicePlot, ProjectionPlot, SlicePlot from yt.visualization.plot_container import accepts_all_fields -import contextlib - # These are a very simple set of tests that verify that each callback is or is # not working. They only check that it functions without an error; they do not # check that it is providing correct results. diff --git a/yt/visualization/tests/test_color_maps.py b/yt/visualization/tests/test_color_maps.py index c83bd0987ff..6b072f8a802 100644 --- a/yt/visualization/tests/test_color_maps.py +++ b/yt/visualization/tests/test_color_maps.py @@ -6,8 +6,8 @@ import numpy as np from nose.tools import assert_raises -from yt import show_colormaps, make_colormap -from yt.testing import assert_equal, assert_almost_equal, requires_backend +from yt import make_colormap, show_colormaps +from yt.testing import assert_almost_equal, assert_equal, requires_backend class TestColorMaps(unittest.TestCase): diff --git a/yt/visualization/tests/test_export_frb.py b/yt/visualization/tests/test_export_frb.py index 61c2ab68768..03a054bf6ae 100644 --- a/yt/visualization/tests/test_export_frb.py +++ b/yt/visualization/tests/test_export_frb.py @@ -1,7 +1,7 @@ import numpy as np -from yt.testing import \ - fake_random_ds, assert_equal, \ - assert_allclose_units + +from yt.testing import assert_allclose_units, assert_equal, fake_random_ds + def setup(): """Test specific setup.""" diff --git a/yt/visualization/tests/test_fits_image.py b/yt/visualization/tests/test_fits_image.py index 487306d0363..1e43696240b 100644 --- a/yt/visualization/tests/test_fits_image.py +++ b/yt/visualization/tests/test_fits_image.py @@ -1,19 +1,21 @@ -import tempfile import os import shutil -from yt.testing import fake_random_ds, requires_module +import tempfile + +from numpy.testing import assert_allclose, assert_equal + from yt.convenience import load -from numpy.testing import \ - assert_equal, \ - assert_allclose +from yt.testing import fake_random_ds, requires_module from yt.utilities.on_demand_imports import _astropy -from yt.visualization.fits_image import \ - FITSImageData, FITSProjection, \ - FITSSlice, FITSOffAxisSlice, \ - FITSOffAxisProjection, \ - assert_same_wcs -from yt.visualization.volume_rendering.off_axis_projection import \ - off_axis_projection +from yt.visualization.fits_image import ( + FITSImageData, + FITSOffAxisProjection, + FITSOffAxisSlice, + FITSProjection, + FITSSlice, + assert_same_wcs, +) +from yt.visualization.volume_rendering.off_axis_projection import off_axis_projection @requires_module("astropy") diff --git a/yt/visualization/tests/test_geo_projections.py b/yt/visualization/tests/test_geo_projections.py index f1808ebf59b..d55b4588a4f 100644 --- a/yt/visualization/tests/test_geo_projections.py +++ b/yt/visualization/tests/test_geo_projections.py @@ -1,13 +1,12 @@ +import unittest + from nose.plugins.attrib import attr import yt -import unittest -from yt.testing import \ - ANSWER_TEST_TAG, \ - fake_amr_ds, \ - requires_module +from yt.testing import ANSWER_TEST_TAG, fake_amr_ds, requires_module from yt.utilities.answer_testing.framework import GenericImageTest -from yt.visualization.geo_plot_utils import transform_list, get_mpl_transform +from yt.visualization.geo_plot_utils import get_mpl_transform, transform_list + def setup(): """Test specific setup.""" @@ -146,4 +145,3 @@ def test_projection_setup(self): assert self.ds.coordinates.data_transform[axis] is None assert self.slc._projection is None assert self.slc._transform is None - diff --git a/yt/visualization/tests/test_image_writer.py b/yt/visualization/tests/test_image_writer.py index 3fa6b6c2849..305fc983eb5 100644 --- a/yt/visualization/tests/test_image_writer.py +++ b/yt/visualization/tests/test_image_writer.py @@ -6,9 +6,14 @@ import numpy as np from nose.tools import assert_raises -from yt.testing import fake_random_ds, assert_equal -from yt.visualization.image_writer import multi_image_composite, splat_points, \ - write_bitmap, apply_colormap, strip_colormap_data +from yt.testing import assert_equal, fake_random_ds +from yt.visualization.image_writer import ( + apply_colormap, + multi_image_composite, + splat_points, + strip_colormap_data, + write_bitmap, +) class TestImageWriter(unittest.TestCase): diff --git a/yt/visualization/tests/test_line_plots.py b/yt/visualization/tests/test_line_plots.py index df719566f3c..be28bba039c 100644 --- a/yt/visualization/tests/test_line_plots.py +++ b/yt/visualization/tests/test_line_plots.py @@ -2,10 +2,11 @@ from nose.tools import assert_raises import yt -from yt.testing import assert_equal, fake_random_ds, ANSWER_TEST_TAG +from yt.testing import ANSWER_TEST_TAG, assert_equal, fake_random_ds from yt.utilities.answer_testing.framework import GenericImageTest from yt.visualization.line_plot import _validate_point + def setup(): """Test specific setup.""" from yt.config import ytcfg diff --git a/yt/visualization/tests/test_mesh_slices.py b/yt/visualization/tests/test_mesh_slices.py index 9c96b61c6be..c79b7a209d8 100644 --- a/yt/visualization/tests/test_mesh_slices.py +++ b/yt/visualization/tests/test_mesh_slices.py @@ -2,8 +2,13 @@ from nose.plugins.attrib import attr import yt -from yt.testing import ANSWER_TEST_TAG, fake_amr_ds, fake_tetrahedral_ds, \ - fake_hexahedral_ds, small_fake_hexahedral_ds +from yt.testing import ( + ANSWER_TEST_TAG, + fake_amr_ds, + fake_hexahedral_ds, + fake_tetrahedral_ds, + small_fake_hexahedral_ds, +) from yt.utilities.answer_testing.framework import GenericImageTest from yt.utilities.lib.geometry_utils import triangle_plane_intersect from yt.utilities.lib.mesh_triangulation import triangulate_indices diff --git a/yt/visualization/tests/test_offaxisprojection.py b/yt/visualization/tests/test_offaxisprojection.py index 59ee958b0e8..d1d6f12b9ad 100644 --- a/yt/visualization/tests/test_offaxisprojection.py +++ b/yt/visualization/tests/test_offaxisprojection.py @@ -3,16 +3,17 @@ import tempfile import unittest +from yt.testing import ( + assert_equal, + assert_fname, + expand_keywords, + fake_octree_ds, + fake_random_ds, +) +from yt.visualization.api import OffAxisProjectionPlot, OffAxisSlicePlot from yt.visualization.image_writer import write_projection -from yt.testing import \ - assert_equal, \ - assert_fname, \ - expand_keywords, \ - fake_octree_ds, \ - fake_random_ds from yt.visualization.volume_rendering.api import off_axis_projection -from yt.visualization.api import OffAxisProjectionPlot, \ - OffAxisSlicePlot + class TestOffAxisProjection(unittest.TestCase): @classmethod diff --git a/yt/visualization/tests/test_particle_plot.py b/yt/visualization/tests/test_particle_plot.py index 872b1bb9b90..1da5d9f4c36 100644 --- a/yt/visualization/tests/test_particle_plot.py +++ b/yt/visualization/tests/test_particle_plot.py @@ -1,31 +1,30 @@ import os -import tempfile import shutil +import tempfile import unittest import numpy as np -from yt.data_objects.profiles import create_profile -from yt.visualization.tests.test_plotwindow import \ - WIDTH_SPECS, ATTR_ARGS from yt.convenience import load from yt.data_objects.particle_filters import add_particle_filter -from yt.testing import \ - fake_particle_ds, \ - assert_array_almost_equal, \ - requires_file, \ - assert_allclose, \ - assert_fname -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - data_dir_load, \ - PlotWindowAttributeTest, \ - PhasePlotAttributeTest -from yt.visualization.api import \ - ParticlePlot, \ - ParticleProjectionPlot, \ - ParticlePhasePlot +from yt.data_objects.profiles import create_profile +from yt.testing import ( + assert_allclose, + assert_array_almost_equal, + assert_fname, + fake_particle_ds, + requires_file, +) from yt.units.yt_array import YTArray +from yt.utilities.answer_testing.framework import ( + PhasePlotAttributeTest, + PlotWindowAttributeTest, + data_dir_load, + requires_ds, +) +from yt.visualization.api import ParticlePhasePlot, ParticlePlot, ParticleProjectionPlot +from yt.visualization.tests.test_plotwindow import ATTR_ARGS, WIDTH_SPECS + def setup(): """Test specific setup.""" diff --git a/yt/visualization/tests/test_plotwindow.py b/yt/visualization/tests/test_plotwindow.py index c237c9c3b29..c54c1ffa0ac 100644 --- a/yt/visualization/tests/test_plotwindow.py +++ b/yt/visualization/tests/test_plotwindow.py @@ -1,30 +1,43 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -import matplotlib -import numpy as np import os import shutil import tempfile import unittest - +from collections import OrderedDict from distutils.version import LooseVersion + +import matplotlib +import numpy as np from nose.tools import assert_true -from yt.testing import \ - requires_file, \ - fake_random_ds, assert_equal, assert_rel_equal, assert_array_equal, \ - assert_array_almost_equal, assert_raises, assert_fname -from yt.utilities.answer_testing.framework import \ - requires_ds, data_dir_load, PlotWindowAttributeTest -from yt.utilities.exceptions import \ - YTInvalidFieldType -from yt.visualization.api import \ - SlicePlot, ProjectionPlot, OffAxisSlicePlot, OffAxisProjectionPlot, \ - plot_2d -from yt.units.yt_array import YTArray, YTQuantity -from yt.units import kboltz from yt.frontends.stream.api import load_uniform_grid -from collections import OrderedDict +from yt.testing import ( + assert_array_almost_equal, + assert_array_equal, + assert_equal, + assert_fname, + assert_raises, + assert_rel_equal, + fake_random_ds, + requires_file, +) +from yt.units import kboltz +from yt.units.yt_array import YTArray, YTQuantity +from yt.utilities.answer_testing.framework import ( + PlotWindowAttributeTest, + data_dir_load, + requires_ds, +) +from yt.utilities.exceptions import YTInvalidFieldType +from yt.visualization.api import ( + OffAxisProjectionPlot, + OffAxisSlicePlot, + ProjectionPlot, + SlicePlot, + plot_2d, +) + def setup(): """Test specific setup.""" diff --git a/yt/visualization/tests/test_profile_plots.py b/yt/visualization/tests/test_profile_plots.py index 9f68ad932f4..d216e98dadf 100644 --- a/yt/visualization/tests/test_profile_plots.py +++ b/yt/visualization/tests/test_profile_plots.py @@ -1,18 +1,23 @@ import os -import tempfile import shutil +import tempfile import unittest -import yt + from nose.plugins.attrib import attr + +import yt from yt.data_objects.profiles import create_profile -from yt.testing import \ - fake_random_ds, \ - assert_array_almost_equal, \ - assert_allclose_units, ANSWER_TEST_TAG -from yt.visualization.profile_plotter import \ - ProfilePlot, PhasePlot -from yt.utilities.answer_testing.framework import \ - PhasePlotAttributeTest, GenericImageTest +from yt.testing import ( + ANSWER_TEST_TAG, + assert_allclose_units, + assert_array_almost_equal, + fake_random_ds, +) +from yt.utilities.answer_testing.framework import ( + GenericImageTest, + PhasePlotAttributeTest, +) +from yt.visualization.profile_plotter import PhasePlot, ProfilePlot ATTR_ARGS = {"annotate_text": [(((5e-29, 5e7), "Hello YT"), {}), (((5e-29, 5e7), "Hello YT"), {'color': 'b'})], @@ -277,7 +282,3 @@ def test_phaseplot_showhide_colorbar_axes(): plot.show_axes() with tempfile.NamedTemporaryFile(suffix='png') as f4: plot.save(f4.name) - - - - diff --git a/yt/visualization/tests/test_raw_field_slices.py b/yt/visualization/tests/test_raw_field_slices.py index 891d416433d..1aeea2edf1a 100644 --- a/yt/visualization/tests/test_raw_field_slices.py +++ b/yt/visualization/tests/test_raw_field_slices.py @@ -1,8 +1,9 @@ import yt -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - data_dir_load, \ - GenericImageTest +from yt.utilities.answer_testing.framework import ( + GenericImageTest, + data_dir_load, + requires_ds, +) def setup(): @@ -38,4 +39,3 @@ def test_raw_field_slices(): ds = data_dir_load(raw_fields) for field in _raw_field_names: yield compare(ds, field, "answers_raw_%s" % field[1]) - diff --git a/yt/visualization/tests/test_splat.py b/yt/visualization/tests/test_splat.py index 131ba2e25cd..2b5531e80a4 100644 --- a/yt/visualization/tests/test_splat.py +++ b/yt/visualization/tests/test_splat.py @@ -1,11 +1,12 @@ import os import os.path -import tempfile import shutil +import tempfile + import numpy as np + import yt -from yt.testing import \ - assert_equal +from yt.testing import assert_equal from yt.utilities.lib.api import add_rgba_points_to_image diff --git a/yt/visualization/volume_rendering/__init__.py b/yt/visualization/volume_rendering/__init__.py index ee2b9899dde..d2b74ec8e56 100644 --- a/yt/visualization/volume_rendering/__init__.py +++ b/yt/visualization/volume_rendering/__init__.py @@ -4,4 +4,3 @@ """ - diff --git a/yt/visualization/volume_rendering/api.py b/yt/visualization/volume_rendering/api.py index 21f9f4ee19a..fcc98be62c6 100644 --- a/yt/visualization/volume_rendering/api.py +++ b/yt/visualization/volume_rendering/api.py @@ -1,17 +1,25 @@ -from .transfer_functions import TransferFunction, ColorTransferFunction, \ - PlanckTransferFunction, \ - MultiVariateTransferFunction, \ - ProjectionTransferFunction -from .image_handling import export_rgba, import_rgba, \ - plot_channel, plot_rgb - from .camera import Camera -from .transfer_function_helper import TransferFunctionHelper -from .volume_rendering import volume_render, create_scene +from .image_handling import export_rgba, import_rgba, plot_channel, plot_rgb +from .interactive_vr_helpers import interactive_render from .off_axis_projection import off_axis_projection +from .render_source import ( + BoxSource, + CoordinateVectorSource, + GridSource, + LineSource, + MeshSource, + OpaqueSource, + PointSource, + VolumeSource, +) from .scene import Scene -from .render_source import VolumeSource, OpaqueSource, LineSource, \ - BoxSource, PointSource, CoordinateVectorSource, GridSource, \ - MeshSource +from .transfer_function_helper import TransferFunctionHelper +from .transfer_functions import ( + ColorTransferFunction, + MultiVariateTransferFunction, + PlanckTransferFunction, + ProjectionTransferFunction, + TransferFunction, +) +from .volume_rendering import create_scene, volume_render from .zbuffer_array import ZBuffer -from .interactive_vr_helpers import interactive_render diff --git a/yt/visualization/volume_rendering/blenders.py b/yt/visualization/volume_rendering/blenders.py index 23f512e72db..bd13fdede3a 100644 --- a/yt/visualization/volume_rendering/blenders.py +++ b/yt/visualization/volume_rendering/blenders.py @@ -1,5 +1,6 @@ import numpy as np + def enhance(im, stdval=6.0, just_alpha=True): if just_alpha: nz = im[im>0.0] @@ -25,4 +26,3 @@ def enhance_rgba(im, stdval=6.0): im.rescale(amax=amax, cmax=cmax, inline=True) np.clip(im, 0.0, 1.0, im) - diff --git a/yt/visualization/volume_rendering/camera.py b/yt/visualization/volume_rendering/camera.py index adfac3cbbe9..037831e1aa8 100644 --- a/yt/visualization/volume_rendering/camera.py +++ b/yt/visualization/volume_rendering/camera.py @@ -1,16 +1,16 @@ -from yt.funcs import iterable, ensure_numpy_array -from yt.utilities.orientation import Orientation -from yt.units.yt_array import \ - YTArray, \ - YTQuantity +import weakref +from numbers import Number as numeric_type + +import numpy as np + +from yt.funcs import ensure_numpy_array, iterable +from yt.units.yt_array import YTArray, YTQuantity from yt.utilities.math_utils import get_rotation_matrix +from yt.utilities.orientation import Orientation + +from .lens import Lens, lenses from .utils import data_source_or_all -from .lens import \ - lenses, \ - Lens -import numpy as np -from numbers import Number as numeric_type -import weakref + def _sanitize_camera_property_units(value, scene): if iterable(value): diff --git a/yt/visualization/volume_rendering/camera_path.py b/yt/visualization/volume_rendering/camera_path.py index aeee7f940d9..eda7504e173 100644 --- a/yt/visualization/volume_rendering/camera_path.py +++ b/yt/visualization/volume_rendering/camera_path.py @@ -1,7 +1,10 @@ import random + import numpy as np + from yt.visualization.volume_rendering.create_spline import create_spline + class Keyframes: def __init__(self, x, y, z=None, north_vectors=None, up_vectors=None, times=None, niter=50000, init_temp=10.0, alpha=0.999, @@ -313,4 +316,3 @@ def write_path(self, filename="path.dat"): self.path["up_vectors"][i,0], self.path["up_vectors"][i,1], self.path["up_vectors"][i,2])) fp.close() - diff --git a/yt/visualization/volume_rendering/create_spline.py b/yt/visualization/volume_rendering/create_spline.py index 7f7315892f4..22f8128578e 100644 --- a/yt/visualization/volume_rendering/create_spline.py +++ b/yt/visualization/volume_rendering/create_spline.py @@ -1,6 +1,8 @@ -import numpy as np import sys +import numpy as np + + def create_spline(old_x, old_y, new_x, tension=0.5, sorted=False): """ Inputs: @@ -48,4 +50,3 @@ def create_spline(old_x, old_y, new_x, tension=0.5, sorted=False): result[i] = b0 * old_y[im2[i]] + b1 * old_y[im1[i]] + \ b2 * old_y[ind[i]] + b3 * old_y[ip1[i]] return result - diff --git a/yt/visualization/volume_rendering/glfw_inputhook.py b/yt/visualization/volume_rendering/glfw_inputhook.py index 52d37405b51..da4c4a6b6ec 100644 --- a/yt/visualization/volume_rendering/glfw_inputhook.py +++ b/yt/visualization/volume_rendering/glfw_inputhook.py @@ -27,6 +27,8 @@ import sys import time +from IPython.lib.inputhook import InputHookBase, inputhook_manager + #----------------------------------------------------------------------------- # Platform-dependent imports and functions #----------------------------------------------------------------------------- @@ -84,7 +86,6 @@ def inputhook_glfw(): return 0 return inputhook_glfw -from IPython.lib.inputhook import inputhook_manager, InputHookBase @inputhook_manager.register('glfw') class GLFWInputHook(InputHookBase): diff --git a/yt/visualization/volume_rendering/image_handling.py b/yt/visualization/volume_rendering/image_handling.py index c9e9a5b7166..45c38b887d1 100644 --- a/yt/visualization/volume_rendering/image_handling.py +++ b/yt/visualization/volume_rendering/image_handling.py @@ -1,7 +1,8 @@ -from yt.utilities.on_demand_imports import _h5py as h5py import numpy as np from yt.funcs import mylog +from yt.utilities.on_demand_imports import _h5py as h5py + def export_rgba(image, fn, h5=True, fits=False, ): """ diff --git a/yt/visualization/volume_rendering/input_events.py b/yt/visualization/volume_rendering/input_events.py index 541de61e5cc..6bf75d66e75 100644 --- a/yt/visualization/volume_rendering/input_events.py +++ b/yt/visualization/volume_rendering/input_events.py @@ -1,14 +1,14 @@ # This is a part of the experimental Interactive Data Visualization +import random from collections import defaultdict, namedtuple -from yt.utilities.math_utils import \ - get_perspective_matrix, \ - get_orthographic_matrix -import OpenGL.GL as GL -import cyglfw3 as glfw -import numpy as np + import matplotlib.cm as cm -import random +import numpy as np + +import cyglfw3 as glfw +import OpenGL.GL as GL +from yt.utilities.math_utils import get_orthographic_matrix, get_perspective_matrix event_registry = {} diff --git a/yt/visualization/volume_rendering/interactive_loop.py b/yt/visualization/volume_rendering/interactive_loop.py index 8163b9c690e..1742e109150 100644 --- a/yt/visualization/volume_rendering/interactive_loop.py +++ b/yt/visualization/volume_rendering/interactive_loop.py @@ -2,12 +2,14 @@ import os -import cyglfw3 as glfw import numpy as np + +import cyglfw3 as glfw import OpenGL.GL as GL +from yt import write_bitmap + from .input_events import EventCollection, MouseRotation -from yt import write_bitmap class EGLRenderingContext: '''Rendering context using EGL (experimental) diff --git a/yt/visualization/volume_rendering/interactive_vr.py b/yt/visualization/volume_rendering/interactive_vr.py index 95a09327902..dd65a16e227 100644 --- a/yt/visualization/volume_rendering/interactive_vr.py +++ b/yt/visualization/volume_rendering/interactive_vr.py @@ -1,23 +1,25 @@ # This is a part of the experimental Interactive Data Visualization -import OpenGL.GL as GL +import ctypes from collections import OrderedDict + import matplotlib.cm as cm import numpy as np -import ctypes -from yt.config import \ - ytcfg -from yt.utilities.math_utils import \ - get_translate_matrix, \ - get_scale_matrix, \ - get_lookat_matrix, \ - get_perspective_matrix, \ - quaternion_mult, \ - quaternion_to_rotation_matrix, \ - rotation_matrix_to_quaternion +import OpenGL.GL as GL +from yt.config import ytcfg from yt.utilities.lib.mesh_triangulation import triangulate_mesh -from .shader_objects import known_shaders, ShaderProgram +from yt.utilities.math_utils import ( + get_lookat_matrix, + get_perspective_matrix, + get_scale_matrix, + get_translate_matrix, + quaternion_mult, + quaternion_to_rotation_matrix, + rotation_matrix_to_quaternion, +) + +from .shader_objects import ShaderProgram, known_shaders bbox_vertices = np.array( [[ 0., 0., 0., 1.], diff --git a/yt/visualization/volume_rendering/interactive_vr_helpers.py b/yt/visualization/volume_rendering/interactive_vr_helpers.py index f2985d46207..6cce1766680 100644 --- a/yt/visualization/volume_rendering/interactive_vr_helpers.py +++ b/yt/visualization/volume_rendering/interactive_vr_helpers.py @@ -1,10 +1,12 @@ # This part of the experimental Interactive Data Visualization import numpy as np -from yt.funcs import mylog + from yt.data_objects.static_output import Dataset +from yt.funcs import mylog from yt.utilities.exceptions import YTSceneFieldNotFound + def _render_opengl(data_source, field=None, window_size=None, cam_position=None, cam_focus=None): '''High level wrapper for Interactive Data Visualization diff --git a/yt/visualization/volume_rendering/lens.py b/yt/visualization/volume_rendering/lens.py index 1d9de3a1ad2..a074f6f8a16 100644 --- a/yt/visualization/volume_rendering/lens.py +++ b/yt/visualization/volume_rendering/lens.py @@ -1,13 +1,13 @@ -from yt.funcs import mylog -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - ParallelAnalysisInterface -from yt.data_objects.image_array import ImageArray -from yt.units.yt_array import unorm, uvstack, uhstack -from yt.utilities.math_utils import get_rotation_matrix import numpy as np -from yt.utilities.lib.grid_traversal import \ - arr_fisheye_vectors +from yt.data_objects.image_array import ImageArray +from yt.funcs import mylog +from yt.units.yt_array import uhstack, unorm, uvstack +from yt.utilities.lib.grid_traversal import arr_fisheye_vectors +from yt.utilities.math_utils import get_rotation_matrix +from yt.utilities.parallel_tools.parallel_analysis_interface import ( + ParallelAnalysisInterface, +) class Lens(ParallelAnalysisInterface): diff --git a/yt/visualization/volume_rendering/off_axis_projection.py b/yt/visualization/volume_rendering/off_axis_projection.py index 8327579f04c..501fd828404 100644 --- a/yt/visualization/volume_rendering/off_axis_projection.py +++ b/yt/visualization/volume_rendering/off_axis_projection.py @@ -1,17 +1,19 @@ -from .scene import Scene +import numpy as np + +from yt.data_objects.api import ImageArray +from yt.funcs import iterable, mylog +from yt.units.unit_object import Unit +from yt.utilities.lib.partitioned_grid import PartitionedGrid +from yt.utilities.lib.pixelization_routines import ( + normalization_2d_utility, + off_axis_projection_SPH, +) + from .render_source import VolumeSource +from .scene import Scene from .transfer_functions import ProjectionTransferFunction from .utils import data_source_or_all -from yt.funcs import mylog, iterable -from yt.utilities.lib.partitioned_grid import \ - PartitionedGrid -from yt.units.unit_object import Unit -from yt.data_objects.api import ImageArray -from yt.utilities.lib.pixelization_routines import \ - off_axis_projection_SPH, \ - normalization_2d_utility -import numpy as np def off_axis_projection(data_source, center, normal_vector, diff --git a/yt/visualization/volume_rendering/old_camera.py b/yt/visualization/volume_rendering/old_camera.py index eb92cf4f865..01c84613d1e 100644 --- a/yt/visualization/volume_rendering/old_camera.py +++ b/yt/visualization/volume_rendering/old_camera.py @@ -1,37 +1,40 @@ import builtins -import numpy as np - -from yt.config import \ - ytcfg -from yt.funcs import \ - iterable, mylog, get_pbar, \ - get_num_threads, ensure_numpy_array -from yt.units.yt_array import YTArray -from yt.utilities.exceptions import YTNotInsideNotebook from copy import deepcopy -from .transfer_functions import ProjectionTransferFunction - -from yt.utilities.lib.grid_traversal import \ - pixelize_healpix, arr_fisheye_vectors, arr_pix2vec_nest -from yt.utilities.lib.partitioned_grid import \ - PartitionedGrid -from yt.utilities.lib.image_samplers import \ - ProjectionSampler, VolumeRenderSampler, \ - LightSourceRenderSampler, InterpolatedProjectionSampler -from yt.utilities.lib.misc_utilities import \ - lines +import numpy as np -from yt.utilities.math_utils import get_rotation_matrix -from yt.utilities.orientation import Orientation +from yt.config import ytcfg from yt.data_objects.api import ImageArray -from yt.visualization.image_writer import write_bitmap, write_image, apply_colormap from yt.data_objects.data_containers import data_object_registry -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - ParallelAnalysisInterface, parallel_objects +from yt.funcs import ensure_numpy_array, get_num_threads, get_pbar, iterable, mylog +from yt.units.yt_array import YTArray from yt.utilities.amr_kdtree.api import AMRKDTree +from yt.utilities.exceptions import YTNotInsideNotebook +from yt.utilities.lib.grid_traversal import ( + arr_fisheye_vectors, + arr_pix2vec_nest, + pixelize_healpix, +) +from yt.utilities.lib.image_samplers import ( + InterpolatedProjectionSampler, + LightSourceRenderSampler, + ProjectionSampler, + VolumeRenderSampler, +) +from yt.utilities.lib.misc_utilities import lines +from yt.utilities.lib.partitioned_grid import PartitionedGrid +from yt.utilities.math_utils import get_rotation_matrix +from yt.utilities.orientation import Orientation +from yt.utilities.parallel_tools.parallel_analysis_interface import ( + ParallelAnalysisInterface, + parallel_objects, +) +from yt.visualization.image_writer import apply_colormap, write_bitmap, write_image from yt.visualization.volume_rendering.blenders import enhance_rgba +from .transfer_functions import ProjectionTransferFunction + + def get_corners(le, re): return np.array([ [le[0], le[1], le[2]], @@ -2207,4 +2210,3 @@ def off_axis_projection(ds, center, normal_vector, width, resolution, north_vector=north_vector, method=method) image = projcam.snapshot() return image[:,:] - diff --git a/yt/visualization/volume_rendering/render_source.py b/yt/visualization/volume_rendering/render_source.py index de7a6277944..91c4564dd59 100644 --- a/yt/visualization/volume_rendering/render_source.py +++ b/yt/visualization/volume_rendering/render_source.py @@ -1,25 +1,35 @@ -import numpy as np from functools import wraps -from yt.config import \ - ytcfg -from yt.funcs import mylog, ensure_numpy_array, iterable -from yt.utilities.parallel_tools.parallel_analysis_interface import \ - ParallelAnalysisInterface + +import numpy as np + +from yt.config import ytcfg +from yt.data_objects.image_array import ImageArray +from yt.funcs import ensure_numpy_array, iterable, mylog from yt.utilities.amr_kdtree.api import AMRKDTree -from .transfer_function_helper import TransferFunctionHelper -from .transfer_functions import TransferFunction, \ - ProjectionTransferFunction, ColorTransferFunction -from .utils import new_volume_render_sampler, data_source_or_all, \ - get_corners, new_projection_sampler, new_mesh_sampler, \ - new_interpolated_projection_sampler from yt.utilities.lib.bounding_volume_hierarchy import BVH +from yt.utilities.lib.misc_utilities import zlines, zpoints +from yt.utilities.on_demand_imports import NotAModule +from yt.utilities.parallel_tools.parallel_analysis_interface import ( + ParallelAnalysisInterface, +) from yt.visualization.image_writer import apply_colormap -from yt.data_objects.image_array import ImageArray + +from .transfer_function_helper import TransferFunctionHelper +from .transfer_functions import ( + ColorTransferFunction, + ProjectionTransferFunction, + TransferFunction, +) +from .utils import ( + data_source_or_all, + get_corners, + new_interpolated_projection_sampler, + new_mesh_sampler, + new_projection_sampler, + new_volume_render_sampler, +) from .zbuffer_array import ZBuffer -from yt.utilities.lib.misc_utilities import \ - zlines, zpoints -from yt.utilities.on_demand_imports import NotAModule try: from yt.utilities.lib import mesh_traversal # Catch ValueError in case size of objects in Cython change diff --git a/yt/visualization/volume_rendering/scene.py b/yt/visualization/volume_rendering/scene.py index 35597e973db..aba1cae949e 100644 --- a/yt/visualization/volume_rendering/scene.py +++ b/yt/visualization/volume_rendering/scene.py @@ -1,31 +1,31 @@ +import builtins import functools -import numpy as np from collections import OrderedDict -from yt.config import \ - ytcfg -from yt.funcs import mylog, get_image_suffix -from yt.units.dimensions import \ - length -from yt.units.unit_registry import \ - UnitRegistry -from yt.units.yt_array import \ - YTQuantity, \ - YTArray + +import numpy as np + +from yt.config import ytcfg +from yt.funcs import get_image_suffix, mylog +from yt.units.dimensions import length +from yt.units.unit_registry import UnitRegistry +from yt.units.yt_array import YTArray, YTQuantity +from yt.utilities.exceptions import YTNotInsideNotebook + from .camera import Camera -from .render_source import \ - OpaqueSource, \ - BoxSource, \ - CoordinateVectorSource, \ - GridSource, \ - RenderSource, \ - MeshSource, \ - VolumeSource, \ - PointSource, \ - LineSource +from .render_source import ( + BoxSource, + CoordinateVectorSource, + GridSource, + LineSource, + MeshSource, + OpaqueSource, + PointSource, + RenderSource, + VolumeSource, +) from .zbuffer_array import ZBuffer -import builtins -from yt.utilities.exceptions import YTNotInsideNotebook + class Scene: diff --git a/yt/visualization/volume_rendering/shader_objects.py b/yt/visualization/volume_rendering/shader_objects.py index 0ce6fa736a0..f50d61c519c 100644 --- a/yt/visualization/volume_rendering/shader_objects.py +++ b/yt/visualization/volume_rendering/shader_objects.py @@ -1,14 +1,16 @@ # This is a part of the experimental Interactive Data Visualization -import os -import OpenGL.GL as GL import contextlib +import os from collections import OrderedDict -from yt.utilities.exceptions import \ - YTInvalidShaderType, \ - YTUnknownUniformKind, \ - YTUnknownUniformSize + +import OpenGL.GL as GL from yt.units.yt_array import YTQuantity +from yt.utilities.exceptions import ( + YTInvalidShaderType, + YTUnknownUniformKind, + YTUnknownUniformSize, +) known_shaders = {} diff --git a/yt/visualization/volume_rendering/tests/test_camera_attributes.py b/yt/visualization/volume_rendering/tests/test_camera_attributes.py index 3c12e504a29..c4ffc6b8385 100644 --- a/yt/visualization/volume_rendering/tests/test_camera_attributes.py +++ b/yt/visualization/volume_rendering/tests/test_camera_attributes.py @@ -1,13 +1,8 @@ import numpy as np -import yt.units as u - -from yt.testing import \ - assert_almost_equal, \ - assert_equal, \ - fake_random_ds -from yt.visualization.volume_rendering.api import \ - Scene +import yt.units as u +from yt.testing import assert_almost_equal, assert_equal, fake_random_ds +from yt.visualization.volume_rendering.api import Scene valid_lens_types = [ 'plane-parallel', diff --git a/yt/visualization/volume_rendering/tests/test_composite.py b/yt/visualization/volume_rendering/tests/test_composite.py index 2f673565d79..98167295224 100644 --- a/yt/visualization/volume_rendering/tests/test_composite.py +++ b/yt/visualization/volume_rendering/tests/test_composite.py @@ -1,16 +1,19 @@ import os -import tempfile import shutil -from yt.testing import fake_random_ds -from yt.visualization.volume_rendering.api import \ - Scene, \ - VolumeSource, \ - LineSource, \ - BoxSource -from yt.data_objects.api import ImageArray -import numpy as np +import tempfile from unittest import TestCase +import numpy as np + +from yt.data_objects.api import ImageArray +from yt.testing import fake_random_ds +from yt.visualization.volume_rendering.api import ( + BoxSource, + LineSource, + Scene, + VolumeSource, +) + def setup(): """Test specific setup.""" diff --git a/yt/visualization/volume_rendering/tests/test_lenses.py b/yt/visualization/volume_rendering/tests/test_lenses.py index 35719147247..62a001a208a 100644 --- a/yt/visualization/volume_rendering/tests/test_lenses.py +++ b/yt/visualization/volume_rendering/tests/test_lenses.py @@ -1,10 +1,13 @@ import os -import tempfile import shutil +import tempfile +from unittest import TestCase + +import numpy as np + from yt.testing import fake_random_ds from yt.visualization.volume_rendering.api import Scene, VolumeSource -import numpy as np -from unittest import TestCase + def setup(): """Test specific setup.""" diff --git a/yt/visualization/volume_rendering/tests/test_mesh_render.py b/yt/visualization/volume_rendering/tests/test_mesh_render.py index e3885b75dc2..a139ce05268 100644 --- a/yt/visualization/volume_rendering/tests/test_mesh_render.py +++ b/yt/visualization/volume_rendering/tests/test_mesh_render.py @@ -1,18 +1,19 @@ from nose.plugins.attrib import attr -from yt.testing import \ - fake_tetrahedral_ds, \ - fake_hexahedral_ds, \ - requires_module, ANSWER_TEST_TAG -from yt.utilities.answer_testing.framework import \ - requires_ds, \ - data_dir_load, \ - GenericImageTest -from yt.visualization.volume_rendering.api import \ - MeshSource, \ - Scene, \ - create_scene -from yt.config import \ - ytcfg + +from yt.config import ytcfg +from yt.testing import ( + ANSWER_TEST_TAG, + fake_hexahedral_ds, + fake_tetrahedral_ds, + requires_module, +) +from yt.utilities.answer_testing.framework import ( + GenericImageTest, + data_dir_load, + requires_ds, +) +from yt.visualization.volume_rendering.api import MeshSource, Scene, create_scene + def compare(ds, im, test_prefix, test_name=None, decimals=12): def mesh_render_image_func(filename_prefix): diff --git a/yt/visualization/volume_rendering/tests/test_off_axis_SPH.py b/yt/visualization/volume_rendering/tests/test_off_axis_SPH.py index 62df69a66b7..5dcd9ed66d1 100644 --- a/yt/visualization/volume_rendering/tests/test_off_axis_SPH.py +++ b/yt/visualization/volume_rendering/tests/test_off_axis_SPH.py @@ -1,13 +1,9 @@ -from yt.visualization.volume_rendering import \ - off_axis_projection as OffAP -from yt.testing import \ - fake_sph_orientation_ds, \ - assert_almost_equal, \ - requires_module -from yt.utilities.lib.pixelization_routines import \ - pixelize_sph_kernel_projection import numpy as np + +from yt.testing import assert_almost_equal, fake_sph_orientation_ds, requires_module +from yt.utilities.lib.pixelization_routines import pixelize_sph_kernel_projection from yt.utilities.on_demand_imports import _scipy +from yt.visualization.volume_rendering import off_axis_projection as OffAP spatial = _scipy.spatial ndimage = _scipy.ndimage diff --git a/yt/visualization/volume_rendering/tests/test_points.py b/yt/visualization/volume_rendering/tests/test_points.py index c81744ad2dc..05b7d1099e6 100644 --- a/yt/visualization/volume_rendering/tests/test_points.py +++ b/yt/visualization/volume_rendering/tests/test_points.py @@ -1,14 +1,13 @@ import os -import tempfile import shutil -from yt.testing import fake_random_ds -from yt.visualization.volume_rendering.api import \ - Scene, \ - VolumeSource, \ - PointSource -import numpy as np +import tempfile from unittest import TestCase +import numpy as np + +from yt.testing import fake_random_ds +from yt.visualization.volume_rendering.api import PointSource, Scene, VolumeSource + def setup(): """Test specific setup.""" diff --git a/yt/visualization/volume_rendering/tests/test_scene.py b/yt/visualization/volume_rendering/tests/test_scene.py index 8228a8c0f7b..5ad52c068f0 100644 --- a/yt/visualization/volume_rendering/tests/test_scene.py +++ b/yt/visualization/volume_rendering/tests/test_scene.py @@ -1,17 +1,17 @@ import os -import tempfile import shutil -from yt.testing import \ - fake_random_ds, \ - assert_fname, \ - fake_vr_orientation_test_ds -from yt.visualization.volume_rendering.api import \ - create_scene, \ - volume_render, \ - VolumeSource -import numpy as np +import tempfile from unittest import TestCase +import numpy as np + +from yt.testing import assert_fname, fake_random_ds, fake_vr_orientation_test_ds +from yt.visualization.volume_rendering.api import ( + VolumeSource, + create_scene, + volume_render, +) + def setup(): """Test specific setup.""" diff --git a/yt/visualization/volume_rendering/tests/test_sigma_clip.py b/yt/visualization/volume_rendering/tests/test_sigma_clip.py index 99cb1b9cb02..ceac5046511 100644 --- a/yt/visualization/volume_rendering/tests/test_sigma_clip.py +++ b/yt/visualization/volume_rendering/tests/test_sigma_clip.py @@ -1,9 +1,11 @@ import os -import tempfile import shutil +import tempfile +from unittest import TestCase + import yt from yt.testing import fake_random_ds -from unittest import TestCase + def setup(): """Test specific setup.""" diff --git a/yt/visualization/volume_rendering/tests/test_simple_vr.py b/yt/visualization/volume_rendering/tests/test_simple_vr.py index 319b36f279c..7e733612af9 100644 --- a/yt/visualization/volume_rendering/tests/test_simple_vr.py +++ b/yt/visualization/volume_rendering/tests/test_simple_vr.py @@ -1,9 +1,10 @@ import os -import tempfile import shutil +import tempfile +from unittest import TestCase + import yt from yt.testing import fake_random_ds -from unittest import TestCase def setup(): diff --git a/yt/visualization/volume_rendering/tests/test_varia.py b/yt/visualization/volume_rendering/tests/test_varia.py index 2d75926a34c..9bdfdb0a533 100644 --- a/yt/visualization/volume_rendering/tests/test_varia.py +++ b/yt/visualization/volume_rendering/tests/test_varia.py @@ -1,14 +1,15 @@ import os -import tempfile import shutil +import tempfile +from unittest import TestCase + import numpy as np import yt -from yt.testing import \ - fake_random_ds +from yt.testing import fake_random_ds from yt.visualization.volume_rendering.render_source import VolumeSource from yt.visualization.volume_rendering.scene import Scene -from unittest import TestCase + def setup(): """Test specific setup.""" diff --git a/yt/visualization/volume_rendering/tests/test_vr_cameras.py b/yt/visualization/volume_rendering/tests/test_vr_cameras.py index fc7992cf970..74e59dba5c9 100644 --- a/yt/visualization/volume_rendering/tests/test_vr_cameras.py +++ b/yt/visualization/volume_rendering/tests/test_vr_cameras.py @@ -1,18 +1,24 @@ import os import os.path -import tempfile import shutil -from yt.testing import \ - fake_random_ds, \ - assert_fname -import numpy as np -from yt.visualization.volume_rendering.old_camera import \ - PerspectiveCamera, StereoPairCamera, InteractiveCamera, ProjectionCamera, \ - FisheyeCamera -from yt.visualization.volume_rendering.api import ColorTransferFunction, \ - ProjectionTransferFunction +import tempfile from unittest import TestCase +import numpy as np + +from yt.testing import assert_fname, fake_random_ds +from yt.visualization.volume_rendering.api import ( + ColorTransferFunction, + ProjectionTransferFunction, +) +from yt.visualization.volume_rendering.old_camera import ( + FisheyeCamera, + InteractiveCamera, + PerspectiveCamera, + ProjectionCamera, + StereoPairCamera, +) + def setup(): """Test specific setup.""" diff --git a/yt/visualization/volume_rendering/tests/test_vr_orientation.py b/yt/visualization/volume_rendering/tests/test_vr_orientation.py index c6e923f6437..95ef45ea518 100644 --- a/yt/visualization/volume_rendering/tests/test_vr_orientation.py +++ b/yt/visualization/volume_rendering/tests/test_vr_orientation.py @@ -1,15 +1,18 @@ import numpy as np from nose.plugins.attrib import attr + from yt.testing import ANSWER_TEST_TAG, fake_vr_orientation_test_ds -from yt.utilities.answer_testing.framework import \ - VRImageComparisonTest, \ - GenericImageTest -from yt.visualization.volume_rendering.api import \ - Scene, \ - VolumeSource, \ - ColorTransferFunction, \ - off_axis_projection +from yt.utilities.answer_testing.framework import ( + GenericImageTest, + VRImageComparisonTest, +) +from yt.visualization.volume_rendering.api import ( + ColorTransferFunction, + Scene, + VolumeSource, + off_axis_projection, +) @attr(ANSWER_TEST_TAG) diff --git a/yt/visualization/volume_rendering/tests/test_zbuff.py b/yt/visualization/volume_rendering/tests/test_zbuff.py index c51cc698348..35b1da152d5 100644 --- a/yt/visualization/volume_rendering/tests/test_zbuff.py +++ b/yt/visualization/volume_rendering/tests/test_zbuff.py @@ -1,16 +1,18 @@ import os -import tempfile import shutil -from yt.testing import fake_random_ds -from yt.visualization.volume_rendering.api import \ - Scene, \ - ZBuffer, \ - VolumeSource, \ - OpaqueSource -from yt.testing import assert_almost_equal -import numpy as np +import tempfile from unittest import TestCase +import numpy as np + +from yt.testing import assert_almost_equal, fake_random_ds +from yt.visualization.volume_rendering.api import ( + OpaqueSource, + Scene, + VolumeSource, + ZBuffer, +) + def setup(): """Test specific setup.""" diff --git a/yt/visualization/volume_rendering/transfer_function_helper.py b/yt/visualization/volume_rendering/transfer_function_helper.py index 78504e4682d..e04614480f2 100644 --- a/yt/visualization/volume_rendering/transfer_function_helper.py +++ b/yt/visualization/volume_rendering/transfer_function_helper.py @@ -1,13 +1,12 @@ +from distutils.version import LooseVersion +from io import BytesIO + import matplotlib import numpy as np -from distutils.version import LooseVersion - -from yt.funcs import mylog from yt.data_objects.profiles import create_profile -from yt.visualization.volume_rendering.transfer_functions import \ - ColorTransferFunction -from io import BytesIO +from yt.funcs import mylog +from yt.visualization.volume_rendering.transfer_functions import ColorTransferFunction class TransferFunctionHelper: diff --git a/yt/visualization/volume_rendering/transfer_functions.py b/yt/visualization/volume_rendering/transfer_functions.py index 64e280cf1b8..2752a1a00c2 100644 --- a/yt/visualization/volume_rendering/transfer_functions.py +++ b/yt/visualization/volume_rendering/transfer_functions.py @@ -1,11 +1,9 @@ import numpy as np from matplotlib.cm import get_cmap -from yt.funcs import \ - mylog, ensure_list +from yt.funcs import ensure_list, mylog +from yt.utilities.physical_constants import clight, hcgs, kboltz -from yt.utilities.physical_constants import \ - clight, hcgs, kboltz class TransferFunction: r"""A transfer function governs the transmission of emission and diff --git a/yt/visualization/volume_rendering/utils.py b/yt/visualization/volume_rendering/utils.py index 29ea21e0818..f57348dd911 100644 --- a/yt/visualization/volume_rendering/utils.py +++ b/yt/visualization/volume_rendering/utils.py @@ -1,12 +1,15 @@ import numpy as np -from yt.data_objects.data_containers import \ - YTSelectionContainer3D + +from yt.data_objects.data_containers import YTSelectionContainer3D from yt.data_objects.static_output import Dataset from yt.utilities.lib import bounding_volume_hierarchy -from yt.utilities.lib.image_samplers import \ - VolumeRenderSampler, InterpolatedProjectionSampler, ProjectionSampler - +from yt.utilities.lib.image_samplers import ( + InterpolatedProjectionSampler, + ProjectionSampler, + VolumeRenderSampler, +) from yt.utilities.on_demand_imports import NotAModule + try: from yt.utilities.lib import mesh_traversal # Catch ValueError in case size of objects in Cython change @@ -143,4 +146,3 @@ def ensure_code_unit_params(params): if hasattr(bounds[0], 'units'): params['bounds'] = tuple(b.in_units('code_length').d for b in bounds) return params - diff --git a/yt/visualization/volume_rendering/volume_rendering.py b/yt/visualization/volume_rendering/volume_rendering.py index b91d1e4a672..4af759e0f6c 100644 --- a/yt/visualization/volume_rendering/volume_rendering.py +++ b/yt/visualization/volume_rendering/volume_rendering.py @@ -1,11 +1,11 @@ -from .scene import Scene -from .render_source import VolumeSource, \ - MeshSource -from .utils import data_source_or_all from yt.funcs import mylog from yt.utilities.exceptions import YTSceneFieldNotFound +from .render_source import MeshSource, VolumeSource +from .scene import Scene +from .utils import data_source_or_all + def create_scene(data_source, field=None, lens_type='plane-parallel'): r""" Set up a scene object with sensible defaults for use in volume