[yt-dev] Issue #950: get_smallest_appropriate_unit is defined twice (yt_analysis/yt)

John ZuHone issues-reply at bitbucket.org
Mon Dec 8 00:06:35 PST 2014


New issue 950: get_smallest_appropriate_unit is defined twice
https://bitbucket.org/yt_analysis/yt/issue/950/get_smallest_appropriate_unit-is-defined

John ZuHone:

`get_smallest_appropriate_unit` is defined as a method of `Dataset`, but there is also a version of it in `yt.visualization.plot_modifications`. Worse yet, the answers don't agree. I ran the following script:


```
#!python

import yt
from yt.visualization.plot_modifications import get_smallest_appropriate_unit

parameters = {"length_unit":(1.0,"Mpc"), 
              "time_unit":(1.0,"Myr"),
              "mass_unit":(1.0e14,"Msun")}

ds = yt.load("MHDSloshing/virgo_low_res.0054.vtk", parameters=parameters)

print "domain width = ", ds.domain_width[0].in_units("Mpc")
print "from Dataset method = ", ds.get_smallest_appropriate_unit(ds.domain_width[0])
print "from plot_modifications = ", get_smallest_appropriate_unit(ds, ds.domain_width[0])

```
which gives:


```
#!

domain width =  4.0 Mpc
from Dataset method =  pc
from plot_modifications =  Mpc

```

I have seen other bizarre behavior of this nature as well. We should remove this duplication, in favor of the version in `plot_modifications`, since it seems to give the more sensible result. I can work on a PR. 

Responsible: jzuhone



More information about the yt-dev mailing list