Skip to content

Commit

Permalink
fixup: move type definitions to an internal _typing module
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Oct 11, 2021
1 parent 9029122 commit 1a3baf6
Show file tree
Hide file tree
Showing 23 changed files with 47 additions and 27 deletions.
4 changes: 4 additions & 0 deletions yt/_typing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from typing import List, Optional, Tuple

FieldDescT = Tuple[str, Tuple[str, List[str], Optional[str]]]
KnownFieldsT = Tuple[FieldDescT, ...]
8 changes: 2 additions & 6 deletions yt/fields/field_info_container.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from collections import defaultdict
from numbers import Number as numeric_type
from typing import List, Optional, Tuple
from typing import Optional, Tuple

import numpy as np
from unyt.exceptions import UnitConversionError

from yt._maintenance.deprecation import issue_deprecation_warning
from yt._typing import KnownFieldsT
from yt.fields.field_exceptions import NeedsConfiguration
from yt.funcs import mylog, only_on_root
from yt.geometry.geometry_handler import is_curvilinear
Expand Down Expand Up @@ -40,11 +41,6 @@ def tupleize(inp):
)


# TODO: move to a _typing module
FieldDescT = Tuple[str, Tuple[str, List[str], Optional[str]]]
KnownFieldsT = Tuple[FieldDescT, ...]


class FieldInfoContainer(dict):
"""
This is a generic field container. It contains a list of potential derived
Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/adaptahop/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"""
from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
from yt.fields.field_info_container import FieldInfoContainer

m_units = "1e11 * Msun"
r_units = "Mpc"
Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/ahf/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
from yt.fields.field_info_container import FieldInfoContainer

m_units = "Msun/h"
p_units = "kpccm/h"
Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/art/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
from yt.fields.field_info_container import FieldInfoContainer

b_units = "code_magnetic"
ra_units = "code_length / code_time**2"
Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/artio/fields.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np

from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
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

Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/athena/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
from yt.fields.field_info_container import FieldInfoContainer
from yt.utilities.physical_constants import kboltz, mh

b_units = "code_magnetic"
Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/athena_pp/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
from yt.fields.field_info_container import FieldInfoContainer
from yt.utilities.physical_constants import kboltz, mh

b_units = "code_magnetic"
Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/boxlib/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

import numpy as np

from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
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

Expand Down
2 changes: 1 addition & 1 deletion yt/frontends/chombo/fields.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy as np

from yt._typing import KnownFieldsT
from yt.fields.field_info_container import (
FieldInfoContainer,
KnownFieldsT,
particle_deposition_functions,
particle_vector_functions,
standard_particle_fields,
Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/enzo/fields.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np

from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
from yt.fields.field_info_container import FieldInfoContainer
from yt.utilities.physical_constants import me, mp

b_units = "code_magnetic"
Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/enzo_e/fields.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np

from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
from yt.fields.field_info_container import FieldInfoContainer
from yt.fields.magnetic_field import setup_magnetic_field_aliases
from yt.fields.particle_fields import add_union_field
from yt.frontends.enzo_e.misc import nested_dict_get
Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/fits/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
from yt.fields.field_info_container import FieldInfoContainer


class FITSFieldInfo(FieldInfoContainer):
Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/flash/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
from yt.fields.field_info_container import FieldInfoContainer

# Common fields in FLASH: (Thanks to John ZuHone for this list)
#
Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/gadget_fof/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
from yt.fields.field_info_container import FieldInfoContainer

m_units = "code_mass"
p_units = "code_length"
Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/gamer/fields.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np

from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
from yt.fields.field_info_container import FieldInfoContainer

b_units = "code_magnetic"
pre_units = "code_mass / (code_length*code_time**2)"
Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/gizmo/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
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
Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/halo_catalog/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
from yt.fields.field_info_container import FieldInfoContainer

m_units = "g"
p_units = "cm"
Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/owls_subfind/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
from yt.fields.field_info_container import FieldInfoContainer

m_units = "code_mass"
mdot_units = "code_mass / code_time"
Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/ramses/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import numpy as np

from yt import units
from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
from yt.fields.field_info_container import FieldInfoContainer
from yt.frontends.ramses.io import convert_ramses_ages
from yt.utilities.cython_fortran_utils import FortranFile
from yt.utilities.linear_interpolators import BilinearFieldInterpolator
Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/rockstar/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
from yt.fields.field_info_container import FieldInfoContainer

m_units = "Msun / h" # Msun / h
p_units = "Mpccm / h" # Mpc / h comoving
Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/sph/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
from yt.fields.field_info_container import FieldInfoContainer
from yt.fields.species_fields import setup_species_fields


Expand Down
3 changes: 2 additions & 1 deletion yt/frontends/stream/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from yt.fields.field_info_container import FieldInfoContainer, KnownFieldsT
from yt._typing import KnownFieldsT
from yt.fields.field_info_container import FieldInfoContainer


class StreamFieldInfo(FieldInfoContainer):
Expand Down

0 comments on commit 1a3baf6

Please sign in to comment.