Skip to content

Commit

Permalink
using ones_like, random seed
Browse files Browse the repository at this point in the history
  • Loading branch information
jzuhone committed Jul 13, 2023
1 parent bb5d5b4 commit 0a548b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions doc/source/examining/Loading_Generic_Array_Data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,10 @@
"arr = prng.random(size=(64, 64, 64))\n",
"data = {\n",
" \"density\": (arr, \"g/cm**3\"),\n",
" \"H_p0_fraction\": (0.37 * np.ones(arr.shape), \"dimensionless\"),\n",
" \"H_p1_fraction\": (0.37 * np.ones(arr.shape), \"dimensionless\"),\n",
" \"He_fraction\": (0.24 * np.ones(arr.shape), \"dimensionless\"),\n",
" \"CO_fraction\": (0.02 * np.ones(arr.shape), \"dimensionless\"),\n",
" \"H_p0_fraction\": (0.37 * np.ones_like(arr), \"dimensionless\"),\n",
" \"H_p1_fraction\": (0.37 * np.ones_like(arr), \"dimensionless\"),\n",
" \"He_fraction\": (0.24 * np.ones_like(arr), \"dimensionless\"),\n",
" \"CO_fraction\": (0.02 * np.ones_like(arr), \"dimensionless\"),\n",
"}\n",
"bbox = np.array([[-1.5, 1.5], [-1.5, 1.5], [-1.5, 1.5]])\n",
"ds = yt.load_uniform_grid(data, arr.shape, length_unit=\"Mpc\", bbox=bbox, nprocs=64)\n",
Expand Down
11 changes: 6 additions & 5 deletions yt/frontends/stream/tests/test_stream_species.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@


def test_stream_species():
arr = np.random.uniform(size=(32, 32, 32))
prng = np.random.default_rng(seed=42)
arr = prng.uniform(size=(32, 32, 32))

data = {
"density": (arr, "g/cm**3"),
"H_p0_fraction": (0.37 * np.ones(arr.shape), "dimensionless"),
"H_p1_fraction": (0.37 * np.ones(arr.shape), "dimensionless"),
"He_fraction": (0.24 * np.ones(arr.shape), "dimensionless"),
"CO_fraction": (0.02 * np.ones(arr.shape), "dimensionless"),
"H_p0_fraction": (0.37 * np.ones_like(arr), "dimensionless"),
"H_p1_fraction": (0.37 * np.ones_like(arr), "dimensionless"),
"He_fraction": (0.24 * np.ones_like(arr), "dimensionless"),
"CO_fraction": (0.02 * np.ones_like(arr), "dimensionless"),
}
bbox = np.array([[-1.5, 1.5], [-1.5, 1.5], [-1.5, 1.5]])
ds = load_uniform_grid(data, arr.shape, length_unit="Mpc", bbox=bbox, nprocs=64)
Expand Down

0 comments on commit 0a548b9

Please sign in to comment.