Skip to content

Commit

Permalink
Merge pull request yt-project#3156 from neutrinoceros/cosmo_int
Browse files Browse the repository at this point in the history
fix: typing for Dataset.cosmological_simulation
  • Loading branch information
munkm authored Mar 29, 2021
2 parents 441ed61 + ed3ae3f commit b64e4c6
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 63 deletions.
7 changes: 4 additions & 3 deletions yt/fields/field_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ class fake_dataset(defaultdict):
# required attrs
ds = fake_dataset(lambda: 1)
ds["Massarr"] = np.ones(6)
ds.current_redshift = (
ds.omega_lambda
) = ds.omega_matter = ds.cosmological_simulation = 0.0
ds.current_redshift = 0.0
ds.omega_lambda = 0.0
ds.omega_matter = 0.0
ds.cosmological_simulation = 0
ds.gamma = 5.0 / 3.0
ds.hubble_constant = 0.7
ds.domain_left_edge = np.zeros(3, "float64")
Expand Down
10 changes: 5 additions & 5 deletions yt/frontends/athena/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,11 @@ def _parse_parameter_file(self):
]
self.nvtk = len(gridlistread) + 1

self.current_redshift = (
self.omega_lambda
) = (
self.omega_matter
) = self.hubble_constant = self.cosmological_simulation = 0.0
self.current_redshift = 0.0
self.omega_lambda = 0.0
self.omega_matter = 0.0
self.hubble_constant = 0.0
self.cosmological_simulation = 0
self.parameters["Time"] = self.current_time # Hardcode time conversion for now.
self.parameters[
"HydroMethod"
Expand Down
10 changes: 5 additions & 5 deletions yt/frontends/athena_pp/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,11 @@ def _parse_parameter_file(self):
else:
self.gamma = 5.0 / 3.0

self.current_redshift = (
self.omega_lambda
) = (
self.omega_matter
) = self.hubble_constant = self.cosmological_simulation = 0.0
self.current_redshift = 0.0
self.omega_lambda = 0.0
self.omega_matter = 0.0
self.hubble_constant = 0.0
self.cosmological_simulation = 0
self.parameters["Time"] = self.current_time # Hardcode time conversion for now.
self.parameters[
"HydroMethod"
Expand Down
10 changes: 5 additions & 5 deletions yt/frontends/boxlib/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,11 +782,11 @@ def _parse_cparams(self):
a_file.close()
self.current_redshift = 1 / float(line) - 1
else:
self.current_redshift = (
self.omega_lambda
) = (
self.omega_matter
) = self.hubble_constant = self.cosmological_simulation = 0.0
self.current_redshift = 0.0
self.omega_lambda = 0.0
self.omega_matter = 0.0
self.hubble_constant = 0.0
self.cosmological_simulation = 0

def _parse_fparams(self):
"""
Expand Down
30 changes: 15 additions & 15 deletions yt/frontends/enzo/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,11 +805,11 @@ def _parse_enzo3_parameter_file(self, f):
self.omega_matter = cosmo["OmegaMatterNow"]
self.hubble_constant = cosmo["HubbleConstantNow"]
else:
self.current_redshift = (
self.omega_lambda
) = (
self.omega_matter
) = self.hubble_constant = self.cosmological_simulation = 0.0
self.current_redshift = 0.0
self.omega_lambda = 0.0
self.omega_matter = 0.0
self.hubble_constant = 0.0
self.cosmological_simulation = 0
self.particle_types = ["DarkMatter"] + phys["ActiveParticles"][
"ActiveParticlesEnabled"
]
Expand Down Expand Up @@ -906,11 +906,11 @@ def _parse_enzo2_parameter_file(self, f):
)
self.hubble_constant = self.parameters["CosmologyHubbleConstantNow"]
else:
self.current_redshift = (
self.omega_lambda
) = (
self.omega_matter
) = self.hubble_constant = self.cosmological_simulation = 0.0
self.current_redshift = 0.0
self.omega_lambda = 0.0
self.omega_matter = 0.0
self.hubble_constant = 0.0
self.cosmological_simulation = 0
self.particle_types = []
self.current_time = self.parameters["InitialTime"]
if (
Expand Down Expand Up @@ -1055,11 +1055,11 @@ def _parse_parameter_file(self):
self.omega_matter = self.parameters["CosmologyOmegaMatterNow"]
self.hubble_constant = self.parameters["CosmologyHubbleConstantNow"]
else:
self.current_redshift = (
self.omega_lambda
) = (
self.omega_matter
) = self.hubble_constant = self.cosmological_simulation = 0.0
self.current_redshift = 0.0
self.omega_lambda = 0.0
self.omega_matter = 0.0
self.hubble_constant = 0.0
self.cosmological_simulation = 0

def _obtain_enzo(self):
import enzo
Expand Down
10 changes: 5 additions & 5 deletions yt/frontends/fits/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,11 @@ def _parse_parameter_file(self):

# For now we'll ignore these
self._periodicity = (False,) * 3
self.current_redshift = (
self.omega_lambda
) = (
self.omega_matter
) = self.hubble_constant = self.cosmological_simulation = 0.0
self.current_redshift = 0.0
self.omega_lambda = 0.0
self.omega_matter = 0.0
self.hubble_constant = 0.0
self.cosmological_simulation = 0

self._determine_nprocs()

Expand Down
10 changes: 5 additions & 5 deletions yt/frontends/flash/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,11 @@ def _parse_parameter_file(self):
self.hubble_constant = self.parameters["hubbleconstant"]
self.hubble_constant *= cm_per_mpc * 1.0e-5 * 1.0e-2 # convert to 'h'
except Exception:
self.current_redshift = (
self.omega_lambda
) = (
self.omega_matter
) = self.hubble_constant = self.cosmological_simulation = 0.0
self.current_redshift = 0.0
self.omega_lambda = 0.0
self.omega_matter = 0.0
self.hubble_constant = 0.0
self.cosmological_simulation = 0

@classmethod
def _is_valid(cls, filename, *args, **kwargs):
Expand Down
10 changes: 5 additions & 5 deletions yt/frontends/gdf/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,11 @@ def _parse_parameter_file(self):
self.omega_matter = sp["omega_matter"]
self.hubble_constant = sp["hubble_constant"]
else:
self.current_redshift = (
self.omega_lambda
) = (
self.omega_matter
) = self.hubble_constant = self.cosmological_simulation = 0.0
self.current_redshift = 0.0
self.omega_lambda = 0.0
self.omega_matter = 0.0
self.hubble_constant = 0.0
self.cosmological_simulation = 0
self.parameters["Time"] = 1.0 # Hardcode time conversion for now.
# Hardcode for now until field staggering is supported.
self.parameters["HydroMethod"] = 0
Expand Down
20 changes: 10 additions & 10 deletions yt/frontends/moab/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ def _parse_parameter_file(self):
self.unique_identifier = self.parameter_filename
self.cosmological_simulation = False
self.num_ghost_zones = 0
self.current_redshift = (
self.omega_lambda
) = (
self.omega_matter
) = self.hubble_constant = self.cosmological_simulation = 0.0
self.current_redshift = 0.0
self.omega_lambda = 0.0
self.omega_matter = 0.0
self.hubble_constant = 0.0
self.cosmological_simulation = 0

@classmethod
def _is_valid(cls, filename, *args, **kwargs):
Expand Down Expand Up @@ -190,11 +190,11 @@ def _parse_parameter_file(self):
self.unique_identifier = self.parameter_filename
self.cosmological_simulation = False
self.num_ghost_zones = 0
self.current_redshift = (
self.omega_lambda
) = (
self.omega_matter
) = self.hubble_constant = self.cosmological_simulation = 0.0
self.current_redshift = 0.0
self.omega_lambda = 0.0
self.omega_matter = 0.0
self.hubble_constant = 0.0
self.cosmological_simulation = 0

@classmethod
def _is_valid(cls, filename, *args, **kwargs):
Expand Down
10 changes: 5 additions & 5 deletions yt/frontends/stream/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,11 @@ def _parse_parameter_file(self):
self.omega_matter = self.stream_handler.omega_matter
self.hubble_constant = self.stream_handler.hubble_constant
else:
self.current_redshift = (
self.omega_lambda
) = (
self.omega_matter
) = self.hubble_constant = self.cosmological_simulation = 0.0
self.current_redshift = 0.0
self.omega_lambda = 0.0
self.omega_matter = 0.0
self.hubble_constant = 0.0
self.cosmological_simulation = 0

def _set_units(self):
self.field_units = self.stream_handler.field_units
Expand Down

0 comments on commit b64e4c6

Please sign in to comment.