Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 15 additions & 42 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,22 @@ name: Continuous Integration

on:
push:
branches:
- '*'
tags:
- '*'
pull_request:

jobs:
tests:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: Python 3.6
os: ubuntu-20.04
python: '3.6'
- name: Python 3.7
os: ubuntu-20.04
python: '3.7'
- name: Python 3.8
os: ubuntu-20.04
python: '3.8'
- name: Python 3.9
os: ubuntu-20.04
python: '3.9'
- name: Python 3.10
os: ubuntu-20.04
python: '3.10'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: 'true'
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install HDF5 and MPI
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt-get install libhdf5-serial-dev libmpich-dev
- name: Install tox
run: pip install tox
- name: Run tests
run: tox -e test-bitlevel
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
with:
libraries: |
apt:
- libhdf5-serial-dev
- libmpich-dev
envs: |
- linux: py37-test-bitlevel
runs-on: ubuntu-20.04
- linux: py38-test-bitlevel
runs-on: ubuntu-20.04
- linux: py39-test-bitlevel
runs-on: ubuntu-20.04
- linux: py310-test-bitlevel
runs-on: ubuntu-20.04
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
hyperion/_version.py
hyperion/data/*
build
docs/_build
Expand All @@ -15,4 +16,5 @@ build_cmake
.vscode
dist
Hyperion.egg-info

*.so
pip-wheel-metadata
2 changes: 1 addition & 1 deletion docs/tutorials/tutorial_quantities_yt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ where ``pf`` is a ``StaticOutput`` yt object! This can then be used as a
normal dataset in yt. For example, we can easily make projections of density
and temperature along the y-axis::

from yt.mods import ProjectionPlot
from yt import ProjectionPlot

prj = ProjectionPlot(pf, 'y', ['density', 'temperature'],
center=[0.0, 0.0, 0.0])
Expand Down
16 changes: 8 additions & 8 deletions hyperion/densities/ulrich_envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def delta_neg(r, q):
rho = np.sqrt(-q.real ** 3)
theta = np.arccos(r.real / rho)

s = (rho ** (1. / 3.) * np.cos(theta / 3.)).astype(np.complex)
s = (rho ** (1. / 3.) * np.cos(theta / 3.)).astype(complex)
s.imag = rho ** (1. / 3.) * np.sin(theta / 3.)

t = (rho ** (1. / 3.) * np.cos(-theta / 3.)).astype(np.complex)
t = (rho ** (1. / 3.) * np.cos(-theta / 3.)).astype(complex)
t.imag = rho ** (1. / 3.) * np.sin(-theta / 3.)

return s, t
Expand All @@ -49,8 +49,8 @@ def cubic(c, d):
Solve x**3 + c * x + d = 0
'''

c = c.astype(np.complex)
d = d.astype(np.complex)
c = c.astype(complex)
d = d.astype(complex)

q = c / 3.
r = - d / 2.
Expand All @@ -59,8 +59,8 @@ def cubic(c, d):

pos = delta >= 0.

s = np.zeros(c.shape, dtype=np.complex)
t = np.zeros(c.shape, dtype=np.complex)
s = np.zeros(c.shape, dtype=complex)
t = np.zeros(c.shape, dtype=complex)

if np.sum(pos) > 0:
s[pos], t[pos] = delta_pos(r[pos], delta[pos])
Expand All @@ -69,8 +69,8 @@ def cubic(c, d):
s[~pos], t[~pos] = delta_neg(r[~pos], q[~pos])

x1 = s + t
x2 = - (s + t) / 2. + np.sqrt(3.) / 2. * (s - t) * np.complex(0., 1.)
x3 = - (s + t) / 2. - np.sqrt(3.) / 2. * (s - t) * np.complex(0., 1.)
x2 = - (s + t) / 2. + np.sqrt(3.) / 2. * (s - t) * complex(0., 1.)
x3 = - (s + t) / 2. - np.sqrt(3.) / 2. * (s - t) * complex(0., 1.)

return x1, x2, x3

Expand Down
6 changes: 3 additions & 3 deletions hyperion/dust/emissivities.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ def hash(self):
h = hashlib.md5()
h.update(str(self.is_lte).encode('utf-8'))
h.update(self.var_name.encode('utf-8'))
h.update(self.var.tostring())
h.update(self.nu.tostring())
h.update(self.jnu.tostring())
h.update(self.var.tobytes())
h.update(self.nu.tobytes())
h.update(self.jnu.tobytes())
return h.hexdigest()

def __setattr__(self, attribute, value):
Expand Down
16 changes: 8 additions & 8 deletions hyperion/dust/mean_opacities.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ def plot(self, figure, subplot):

def hash(self):
h = hashlib.md5()
h.update(self.temperature.tostring())
h.update(self.specific_energy.tostring())
h.update(self.chi_planck.tostring())
h.update(self.kappa_planck.tostring())
h.update(self.chi_inv_planck.tostring())
h.update(self.kappa_inv_planck.tostring())
h.update(self.chi_rosseland.tostring())
h.update(self.kappa_rosseland.tostring())
h.update(self.temperature.tobytes())
h.update(self.specific_energy.tobytes())
h.update(self.chi_planck.tobytes())
h.update(self.kappa_planck.tobytes())
h.update(self.chi_inv_planck.tobytes())
h.update(self.kappa_inv_planck.tobytes())
h.update(self.chi_rosseland.tobytes())
h.update(self.kappa_rosseland.tobytes())
return h.hexdigest()
16 changes: 8 additions & 8 deletions hyperion/dust/optical_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,14 @@ def plot(self, figure, subplots):

def hash(self):
h = hashlib.md5()
h.update(self.nu.tostring())
h.update(self.chi.tostring())
h.update(self.albedo.tostring())
h.update(self.mu.tostring())
h.update(self.P1.tostring())
h.update(self.P2.tostring())
h.update(self.P3.tostring())
h.update(self.P4.tostring())
h.update(self.nu.tobytes())
h.update(self.chi.tobytes())
h.update(self.albedo.tobytes())
h.update(self.mu.tobytes())
h.update(self.P1.tobytes())
h.update(self.P2.tobytes())
h.update(self.P3.tobytes())
h.update(self.P4.tobytes())
return h.hexdigest()

def __setattr__(self, attribute, value):
Expand Down
2 changes: 1 addition & 1 deletion hyperion/grid/amr_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ def from_yt(cls, ds, quantity_mapping={}):
>>> ds = load('DD0010/moving7_0010')
>>> def _dust_density(field, data):
... return data[('gas', 'density')].in_units('g/cm**3') * 0.01
>>> ds.add_field(('gas', 'dust_density'), function=_dust_density, units='g/cm**3')
>>> ds.add_field(('gas', 'dust_density'), function=_dust_density, units='g/cm**3', sampling_type='cell')

>>> amr = AMRGrid.from_yt(ds, quantity_mapping={'density':('gas', 'dust_density')})
"""
Expand Down
6 changes: 3 additions & 3 deletions hyperion/grid/cartesian_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ def write_single_array(self, group, name, array, copy=True, absolute_paths=False

def get_geometry_id(self):
geo_hash = hashlib.md5()
geo_hash.update(self.x_wall.tostring())
geo_hash.update(self.y_wall.tostring())
geo_hash.update(self.z_wall.tostring())
geo_hash.update(self.x_wall.tobytes())
geo_hash.update(self.y_wall.tobytes())
geo_hash.update(self.z_wall.tobytes())
return geo_hash.hexdigest()

def __getitem__(self, item):
Expand Down
6 changes: 3 additions & 3 deletions hyperion/grid/cylindrical_polar_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,9 @@ def write_single_array(self, group, name, array, copy=True, absolute_paths=False

def get_geometry_id(self):
geo_hash = hashlib.md5()
geo_hash.update(self.w_wall.tostring())
geo_hash.update(self.z_wall.tostring())
geo_hash.update(self.p_wall.tostring())
geo_hash.update(self.w_wall.tobytes())
geo_hash.update(self.z_wall.tobytes())
geo_hash.update(self.p_wall.tobytes())
return geo_hash.hexdigest()

def __getitem__(self, item):
Expand Down
6 changes: 3 additions & 3 deletions hyperion/grid/octree_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def refined(self, value):

def _validate(self, value):

value_hash = hashlib.md5(value.tostring()).hexdigest()
value_hash = hashlib.md5(value.tobytes()).hexdigest()

if value_hash in self._validate_cache:
return value
Expand All @@ -205,7 +205,7 @@ def _validate(self, value):

# Check that refined array reduces to a single False if removing all
# levels of refinement.
refined_str = value.tostring()
refined_str = value.tobytes()
previous = ''
while True:
refined_str = refined_str.replace(b'\x01\x00\x00\x00\x00\x00\x00\x00\x00', b'\x00')
Expand Down Expand Up @@ -491,7 +491,7 @@ def get_geometry_id(self):
geo_hash.update(struct.pack('>d', self.dx))
geo_hash.update(struct.pack('>d', self.dy))
geo_hash.update(struct.pack('>d', self.dz))
geo_hash.update(self.refined.tostring())
geo_hash.update(self.refined.tobytes())
return geo_hash.hexdigest()

def __getitem__(self, item):
Expand Down
6 changes: 3 additions & 3 deletions hyperion/grid/spherical_polar_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,9 @@ def write_single_array(self, group, name, array, copy=True, absolute_paths=False

def get_geometry_id(self):
geo_hash = hashlib.md5()
geo_hash.update(self.r_wall.tostring())
geo_hash.update(self.t_wall.tostring())
geo_hash.update(self.p_wall.tostring())
geo_hash.update(self.r_wall.tobytes())
geo_hash.update(self.t_wall.tobytes())
geo_hash.update(self.p_wall.tobytes())
return geo_hash.hexdigest()

def __getitem__(self, item):
Expand Down
8 changes: 4 additions & 4 deletions hyperion/grid/tests/test_yt.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def setup_method(self, method):
@pytest.mark.parametrize(('grid_type'), ALL_GRID_TYPES)
def test_to_yt(self, tmpdir, grid_type):

from yt.mods import ProjectionPlot
from yt import ProjectionPlot

g = self.grid[grid_type]
g['density'] = []
Expand All @@ -101,7 +101,7 @@ def test_from_yt(tmpdir):
def _dust_density(field, data):
return data["density"].in_units('g/cm**3') * 0.01

ds.add_field(("gas", "dust_density"), function=_dust_density, units='g/cm**3')
ds.add_field(("gas", "dust_density"), function=_dust_density, units='g/cm**3', sampling_type='cell')

amr = AMRGrid.from_yt(ds, quantity_mapping={'density': ('gas', 'dust_density')})

Expand Down Expand Up @@ -147,7 +147,7 @@ def test_axis_ordering_cartesian():
g['density'] = []
g['density'].append(density)

from yt.mods import ProjectionPlot, SlicePlot
from yt import ProjectionPlot, SlicePlot

pf = g.to_yt()

Expand Down Expand Up @@ -177,7 +177,7 @@ def test_axis_ordering_amr():
grid.quantities['density'] = []
grid.quantities['density'].append(np.arange(grid.nz)[:, None, None] * np.ones((grid.nz, grid.ny, grid.nx)))

from yt.mods import ProjectionPlot, SlicePlot
from yt import ProjectionPlot, SlicePlot

pf = g.to_yt()

Expand Down
6 changes: 3 additions & 3 deletions hyperion/grid/voronoi_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,9 @@ def write_single_array(self, group, name, array, copy=True, absolute_paths=False
def get_geometry_id(self):
# The grid is uniquely defined by the points and the bounds
geo_hash = hashlib.md5()
geo_hash.update(self.x.tostring())
geo_hash.update(self.y.tostring())
geo_hash.update(self.z.tostring())
geo_hash.update(self.x.tobytes())
geo_hash.update(self.y.tobytes())
geo_hash.update(self.z.tobytes())
geo_hash.update(struct.pack('>d', self.xmin))
geo_hash.update(struct.pack('>d', self.xmax))
geo_hash.update(struct.pack('>d', self.ymin))
Expand Down
8 changes: 4 additions & 4 deletions hyperion/grid/yt3_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def amr_grid_to_yt_stream(levels, dust_id=0):

bbox = np.array([[xmin, xmax], [ymin, ymax], [zmin, zmax]])

from yt.mods import load_amr_grids
from yt import load_amr_grids

spf = load_amr_grids(grid_data, domain_dimensions, bbox=bbox,
geometry=('cartesian', ('x', 'y', 'z')))
Expand Down Expand Up @@ -154,7 +154,7 @@ def octree_grid_to_yt_stream(grid, dust_id=0):
zmin = grid.z - grid.dz
zmax = grid.z + grid.dz

from yt.mods import load_octree
from yt import load_octree

quantities = {}
for field in grid.quantities:
Expand Down Expand Up @@ -183,7 +183,7 @@ def cartesian_grid_to_yt_stream(grid, xmin, xmax, ymin, ymax, zmin, zmax, dust_i
data[field] = grid.quantities[field][dust_id].transpose(), ''

# Load cartesian grid into yt
from yt.mods import load_uniform_grid
from yt import load_uniform_grid
spf = load_uniform_grid(data=data,
domain_dimensions=np.array(grid.shape[::-1], dtype=np.int32),
bbox=np.array([(xmin, xmax), (ymin, ymax), (zmin, zmax)]),
Expand Down Expand Up @@ -240,7 +240,7 @@ def yt_dataset_to_amr_grid(ds, quantity_mapping={}):
>>> ds = load('DD0010/moving7_0010')
>>> def _dust_density(field, data):
... return data[('gas', 'density')].in_units('g/cm**3') * 0.01
>>> ds.add_field(('gas', 'dust_density'), function=_dust_density, units='g/cm**3')
>>> ds.add_field(('gas', 'dust_density'), function=_dust_density, units='g/cm**3', sampling_type='cell')

>>> amr = yt_dataset_to_amr_grid(ds, quantity_mapping={'density':('gas', 'dust_density')})
"""
Expand Down
Binary file modified hyperion/model/tests/data/test_pascucci.tau=0.1.rtout
Binary file not shown.
Binary file modified hyperion/model/tests/data/test_pascucci.tau=1.rtout
Binary file not shown.
Binary file modified hyperion/model/tests/data/test_pascucci.tau=10.rtout
Binary file not shown.
Binary file modified hyperion/model/tests/data/test_pascucci.tau=100.rtout
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified hyperion/model/tests/data/test_pinte_images.tau=1000.rtout
Binary file not shown.
Binary file modified hyperion/model/tests/data/test_pinte_images.tau=10000.rtout
Binary file not shown.
Binary file modified hyperion/model/tests/data/test_pinte_images.tau=100000.rtout
Binary file not shown.
Binary file modified hyperion/model/tests/data/test_pinte_images.tau=1000000.rtout
Binary file not shown.
Binary file modified hyperion/model/tests/data/test_pinte_seds.tau=1000.rtout
Binary file not shown.
Binary file modified hyperion/model/tests/data/test_pinte_seds.tau=10000.rtout
Binary file not shown.
Binary file modified hyperion/model/tests/data/test_pinte_seds.tau=100000.rtout
Binary file not shown.
Binary file modified hyperion/model/tests/data/test_pinte_seds.tau=1000000.rtout
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion hyperion/model/tests/test_amr_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def test_shadowing_regression(tmpdir):
m.write(tmpdir.join(random_id()).strpath)
mo = m.run(tmpdir.join(random_id()).strpath)

from yt.mods import SlicePlot
from yt import SlicePlot

g = mo.get_quantities()

Expand Down
8 changes: 4 additions & 4 deletions hyperion/util/interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def interp1d_fast(x, y, xval):
if x.dtype != float or y.dtype != float:
x, y = x.astype(float), y.astype(float)
if np.isscalar(xval):
return interp1d_linear_scalar(x, y, np.float(xval))
return interp1d_linear_scalar(x, y, float(xval))
else:
if xval.ndim > 1:
return interp1d_linear_array(x, y, xval.flatten()).reshape(xval.shape)
Expand All @@ -74,7 +74,7 @@ def interp1d_fast_loglog(x, y, xval):
if x.dtype != float or y.dtype != float:
x, y = x.astype(float), y.astype(float)
if np.isscalar(xval):
return interp1d_loglog_scalar(x, y, np.float(xval))
return interp1d_loglog_scalar(x, y, float(xval))
else:
if xval.ndim > 1:
return interp1d_loglog_array(x, y, xval.flatten()).reshape(xval.shape)
Expand All @@ -90,7 +90,7 @@ def interp1d_fast_linlog(x, y, xval):
if x.dtype != float or y.dtype != float:
x, y = x.astype(float), y.astype(float)
if np.isscalar(xval):
return interp1d_linlog_scalar(x, y, np.float(xval))
return interp1d_linlog_scalar(x, y, float(xval))
else:
if xval.ndim > 1:
return interp1d_linlog_array(x, y, xval.flatten()).reshape(xval.shape)
Expand All @@ -106,7 +106,7 @@ def interp1d_fast_loglin(x, y, xval):
if x.dtype != float or y.dtype != float:
x, y = x.astype(float), y.astype(float)
if np.isscalar(xval):
return interp1d_loglin_scalar(x, y, np.float(xval))
return interp1d_loglin_scalar(x, y, float(xval))
else:
if xval.ndim > 1:
return interp1d_loglin_array(x, y, xval.flatten()).reshape(xval.shape)
Expand Down
Loading