Skip to content

Commit

Permalink
fix: comply to new stricter api in fake_random_ds
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Sep 12, 2020
1 parent eb96cc3 commit 5b6fcd5
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 27 deletions.
2 changes: 1 addition & 1 deletion yt/data_objects/tests/test_center_squeeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def test_center_squeeze():

# create and test amr, random and particle data
check_single_ds(fake_amr_ds(fields=("Density",)))
check_single_ds(fake_random_ds(16, fields=("Density",)))
check_single_ds(fake_random_ds(16, fields=("Density",), units=("g/cm**3",)))
check_single_ds(fake_particle_ds(npart=100))


Expand Down
4 changes: 1 addition & 3 deletions yt/data_objects/tests/test_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ def test_clone_sphere():
# parameters.

# Get the first sphere
ds = fake_random_ds(
16, fields=("density", "velocity_x", "velocity_y", "velocity_z")
)
ds = fake_random_ds(16)
sp0 = ds.sphere(ds.domain_center, 0.25)

assert_equal(list(sp0.keys()), [])
Expand Down
14 changes: 5 additions & 9 deletions yt/data_objects/tests/test_derived_quantities.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ def setup():

def test_extrema():
for nprocs in [1, 2, 4, 8]:
ds = fake_random_ds(
16,
nprocs=nprocs,
fields=("density", "velocity_x", "velocity_y", "velocity_z"),
)
ds = fake_random_ds(16, nprocs=nprocs)
for sp in [ds.sphere("c", (0.25, "unitary")), ds.r[0.5, :, :]]:
mi, ma = sp.quantities["Extrema"]("density")
assert_equal(mi, np.nanmin(sp["density"]))
Expand All @@ -43,7 +39,7 @@ def test_extrema():

def test_average():
for nprocs in [1, 2, 4, 8]:
ds = fake_random_ds(16, nprocs=nprocs, fields=("density",))
ds = fake_random_ds(16, nprocs=nprocs, fields=("density",), units=("g/cm**3",))
for ad in [ds.all_data(), ds.r[0.5, :, :]]:

my_mean = ad.quantities["WeightedAverageQuantity"]("density", "ones")
Expand All @@ -56,7 +52,7 @@ def test_average():

def test_variance():
for nprocs in [1, 2, 4, 8]:
ds = fake_random_ds(16, nprocs=nprocs, fields=("density",))
ds = fake_random_ds(16, nprocs=nprocs, fields=("density",), units=("g/cm**3",))
for ad in [ds.all_data(), ds.r[0.5, :, :]]:

my_std, my_mean = ad.quantities["WeightedVariance"]("density", "ones")
Expand All @@ -75,7 +71,7 @@ def test_variance():

def test_max_location():
for nprocs in [1, 2, 4, 8]:
ds = fake_random_ds(16, nprocs=nprocs, fields=("density",))
ds = fake_random_ds(16, nprocs=nprocs, fields=("density",), units=("g/cm**3",))
for ad in [ds.all_data(), ds.r[0.5, :, :]]:

mv, x, y, z = ad.quantities.max_location(("gas", "density"))
Expand All @@ -91,7 +87,7 @@ def test_max_location():

def test_min_location():
for nprocs in [1, 2, 4, 8]:
ds = fake_random_ds(16, nprocs=nprocs, fields=("density",))
ds = fake_random_ds(16, nprocs=nprocs, fields=("density",), units=("g/cm**3",))
for ad in [ds.all_data(), ds.r[0.5, :, :]]:

mv, x, y, z = ad.quantities.min_location(("gas", "density"))
Expand Down
4 changes: 3 additions & 1 deletion yt/data_objects/tests/test_numpy_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def test_mean_sum_integrate():
if nprocs == -1:
ds = fake_amr_ds(fields=("density",), particles=20)
else:
ds = fake_random_ds(32, nprocs=nprocs, fields=("density",), particles=20)
ds = fake_random_ds(
32, nprocs=nprocs, fields=("density",), units=("g/cm**3",), particles=20
)
ad = ds.all_data()

# Sums
Expand Down
4 changes: 3 additions & 1 deletion yt/data_objects/tests/test_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def test_slice(pf):


def test_slice_over_edges():
ds = fake_random_ds(64, nprocs=8, fields=["density"], negative=[False])
ds = fake_random_ds(
64, nprocs=8, fields=["density"], units=["g/cm**3"], negative=[False]
)
slc = ds.slice(0, 0.0)
slc["density"]
slc = ds.slice(1, 0.5)
Expand Down
4 changes: 1 addition & 3 deletions yt/data_objects/tests/test_spheres.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ def test_domain_sphere():
# parameters.

# Get the first sphere
ds = fake_random_ds(
16, fields=("density", "velocity_x", "velocity_y", "velocity_z")
)
ds = fake_random_ds(16)
sp0 = ds.sphere(ds.domain_center, 0.25)

# Compute the bulk velocity from the cells in this sphere
Expand Down
10 changes: 2 additions & 8 deletions yt/utilities/lib/tests/test_geometry_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
obtain_relative_velocity_vector,
)

_fields = ("density", "velocity_x", "velocity_y", "velocity_z")

# TODO: error compact/spread bits for incorrect size
# TODO: test msdb for [0,0], [1,1], [2,2] etc.

Expand Down Expand Up @@ -953,9 +951,7 @@ def test_knn_direct(seed=1):


def test_obtain_position_vector():
ds = fake_random_ds(
64, nprocs=8, fields=_fields, negative=[False, True, True, True]
)
ds = fake_random_ds(64, nprocs=8, negative=[False, True, True, True])

dd = ds.sphere((0.5, 0.5, 0.5), 0.2)

Expand All @@ -969,9 +965,7 @@ def test_obtain_position_vector():


def test_obtain_relative_velocity_vector():
ds = fake_random_ds(
64, nprocs=8, fields=_fields, negative=[False, True, True, True]
)
ds = fake_random_ds(64, nprocs=8, negative=[False, True, True, True])

dd = ds.all_data()

Expand Down
2 changes: 1 addition & 1 deletion yt/visualization/volume_rendering/tests/test_lenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def setUp(self):
self.curdir, self.tmpdir = None, None

self.field = ("gas", "density")
self.ds = fake_random_ds(32, fields=self.field)
self.ds = fake_random_ds(32, fields=self.field, units=("g/cm**3",))
self.ds.index

def tearDown(self):
Expand Down

0 comments on commit 5b6fcd5

Please sign in to comment.