Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_load_phantom_snap():
"""Testing reading Phantom HDF5 snapshots."""
# Read from pathlib.Path
snap = plonk.load_snap(TEST_FILE)
snap.close_file()
# Read from str
snap = plonk.load_snap(str(TEST_FILE))
snap.close_file()
# Not exists
with pytest.raises(FileNotFoundError):
plonk.load_snap('does_not_exist.h5')
def test_initialization():
"""Test plot function."""
snap = plonk.load_snap(TEST_FILE)
plonk.visualize.plot(
snap=snap,
quantity='density',
x='x',
y='y',
extent=(-150, 150, -150, 150),
norm='linear',
cmap='gist_heat',
number_of_pixels=(512, 512),
)
def test_profile():
"""Test Profile."""
snap = plonk.load_snap(TEST_FILE)
snap.extra_quantities()
p = plonk.analysis.Profile(snap)
for key in (
'angular_momentum_magnitude',
'angular_momentum_x',
'density',
'mass',
'number',
'radius',
'scale_height',
'size',
'smoothing_length',
'sound_speed',
):
p[key]
df = p.to_dataframe()
def test_read_properties_from_phantom():
"""Testing reading Phantom HDF5 snapshot properties."""
snap = plonk.load_snap(TEST_FILE)
for key, value in properties.items():
if isinstance(snap.properties[key], plonk.units.Quantity):
snap_value = snap.properties[key].magnitude
else:
snap_value = snap.properties[key]
np.testing.assert_allclose(snap_value, value)
snap.close_file()
def test_load_phantom_snap():
"""Testing reading Phantom HDF5 snapshots."""
# Read from pathlib.Path
snap = plonk.load_snap(TEST_FILE)
snap.close_file()
# Read from str
snap = plonk.load_snap(str(TEST_FILE))
snap.close_file()
# Not exists
with pytest.raises(FileNotFoundError):
plonk.load_snap('does_not_exist.h5')
def test_load_phantom_snap():
"""Testing reading Phantom HDF5 snapshots."""
# Read from pathlib.Path
snap = plonk.load_snap(TEST_FILE)
snap.close_file()
# Read from str
snap = plonk.load_snap(str(TEST_FILE))
snap.close_file()
# Not exists
with pytest.raises(FileNotFoundError):
plonk.load_snap('does_not_exist.h5')
def test_read_particle_arrays_from_phantom():
"""Testing reading Phantom HDF5 snapshot particle arrays."""
snap = plonk.load_snap(TEST_FILE)
for array in mean_array_values.keys():
np.testing.assert_allclose(
snap[array_name_map[array]].mean(), mean_array_values[array]
)
snap.close_file()