[yt-dev] [yt_analysis/yt] Hardcoded values are used in several places in the code (issue #557)
Kacper Kowalik
issues-reply at bitbucket.org
Tue Apr 30 07:49:22 PDT 2013
New issue 557: Hardcoded values are used in several places in the code
https://bitbucket.org/yt_analysis/yt/issue/557/hardcoded-values-are-used-in-several
Kacper Kowalik:
Several physical constants are defined across multiple places in the code. As an example:
```
#!bash
$ grep '1\.98' -r
analysis_modules/halo_finding/halo_objects.py: #Jc = 1.98892e33/pf['mpchcm']*1e5
analysis_modules/halo_profiler/multi_halo_profiler.py: Msun2g = 1.989e33
utilities/units.py: "Msun": (1.98892e33, mass),
utilities/tests/test_units.py: msun_cgs = 1.98892e33
utilities/tests/test_units.py: Msun_cgs = 1.98892e33
utilities/physical_constants.py:mass_sun_cgs = 1.98841586e33 # g
frontends/nyx/fields.py: return (1/1.989e33)
frontends/nyx/data_structures.py: self.units["particle_mass"] = 1.989e33
frontends/flash/fields.py: return 1.0/1.989e33
frontends/art/data_structures.py: cf["Mass"] = aM0 * 1.98892e33
frontends/castro/fields.py: return 1.0 / 1.989e33
frontends/castro/data_structures.py: self.units['particle_mass'] = 1.989e33 ### TODO: Make a global solar mass def
frontends/enzo/fields.py: return data.convert("Density")*((data.convert("cm")**3.0)/1.989e33)
frontends/ramses/fields.py: return data.convert("Density")*((data.convert("cm")**3.0)/1.989e33)
data_objects/universal_fields.py: (3/(4*3.1415926535897931))**(0.5) / 1.989e33
data_objects/derived_quantities.py: spin = J * E / (M*1.989e33*G)
```
Instead constants should be imported from `yt.physical_constants` everywhere for the sake of consistency.
Responsible: xarthisius
More information about the yt-dev
mailing list