Skip to content

Commit

Permalink
Merge branch 'main' into open-compressed-files
Browse files Browse the repository at this point in the history
  • Loading branch information
cphyc authored Sep 7, 2021
2 parents 723bdb5 + 0f57663 commit 2542744
Show file tree
Hide file tree
Showing 30 changed files with 490 additions and 480 deletions.
1 change: 1 addition & 0 deletions .github/workflows/bleeding-edge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
schedule:
# run this every day at 3 am UTC
- cron: '0 3 * * *'
workflow_dispatch:

jobs:
build:
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ repos:
- id: no-commit-to-branch
args: [--branch, main]
- repo: https://github.com/asottile/pyupgrade
rev: v2.23.0
rev: v2.25.0
hooks:
- id: pyupgrade
args: [--py36-plus]
- repo: https://github.com/psf/black
rev: 21.7b0
rev: 21.8b0
hooks:
- id: black
language_version: python3
- repo: https://github.com/PyCQA/isort
rev: '5.9.2'
rev: '5.9.3'
hooks:
- id: isort
name: isort (python)
Expand All @@ -55,10 +55,10 @@ repos:
flake8-2020==1.6.0,
]
- repo: https://github.com/asottile/blacken-docs
rev: v1.10.0
rev: v1.11.0
hooks:
- id: blacken-docs
additional_dependencies: [black==20.8b1]
additional_dependencies: [black==21.8b0]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ can be found on [the project's website](https://yt-project.org/docs/dev/installi
yt is designed to provide meaningful analysis of data. We have some Quickstart
example notebooks in the repository:

* [Introduction](doc/source/quickstart/1\)_Introduction.ipynb)
* [Data Inspection](doc/source/quickstart/2\)_Data_Inspection.ipynb)
* [Simple Visualization](doc/source/quickstart/3\)_Simple_Visualization.ipynb)
* [Data Objects and Time Series](doc/source/quickstart/4\)_Data_Objects_and_Time_Series.ipynb)
* [Derived Fields and Profiles](doc/source/quickstart/5\)_Derived_Fields_and_Profiles.ipynb)
* [Volume Rendering](doc/source/quickstart/6\)_Volume_Rendering.ipynb)
* [Introduction](https://github.com/yt-project/yt/tree/main/doc/source/quickstart/1\)_Introduction.ipynb)
* [Data Inspection](https://github.com/yt-project/yt/tree/main/doc/source/quickstart/2\)_Data_Inspection.ipynb)
* [Simple Visualization](https://github.com/yt-project/yt/tree/main/doc/source/quickstart/3\)_Simple_Visualization.ipynb)
* [Data Objects and Time Series](https://github.com/yt-project/yt/tree/main/doc/source/quickstart/4\)_Data_Objects_and_Time_Series.ipynb)
* [Derived Fields and Profiles](https://github.com/yt-project/yt/tree/main/doc/source/quickstart/5\)_Derived_Fields_and_Profiles.ipynb)
* [Volume Rendering](https://github.com/yt-project/yt/tree/main/doc/source/quickstart/6\)_Volume_Rendering.ipynb)

If you'd like to try these online, you can visit our [yt Hub](https://hub.yt/)
and run a notebook next to some of our example data.
Expand Down
1 change: 1 addition & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@
"trident": ("https://trident.readthedocs.io/en/latest/", None),
"yt_astro_analysis": ("https://yt-astro-analysis.readthedocs.io/en/latest/", None),
"yt_attic": ("https://yt-attic.readthedocs.io/en/latest/", None),
"pytest": ("https://docs.pytest.org/en/stable", None),
}

if not on_rtd:
Expand Down
620 changes: 263 additions & 357 deletions doc/source/developing/testing.rst

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/source/examining/Loading_Generic_Array_Data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
},
"outputs": [],
"source": [
"data = {k:(v.value,u) for (k,v), u in zip(f.items(),units)}\n",
"data = {k:(v[()],u) for (k,v), u in zip(f.items(),units)}\n",
"bbox = np.array([[-0.5, 0.5], [-0.5, 0.5], [-0.5, 0.5]])"
]
},
Expand Down
4 changes: 2 additions & 2 deletions doc/source/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ or pip, and we will *assume* that you do so in an isolated environment.
Also note that each yt release supports a limited range of Python versions.
Here's a summary for most recent releases

+------------+------------+----------------------------------+
+------------+------------+----------------+-----------------+
| yt release | Python 2.7 | Python3 min | Python3 max |
+============+============+================+=================+
| 4.1.x | no | 3.7 (expected) | 3.10 (expected) |
Expand Down Expand Up @@ -120,7 +120,7 @@ yt as by appending ``[full]`` to the target name when calling pip, i.e.,
Testing Your Installation
+++++++++++++++++++++++++

To test to make sure everything is installed properly, try running yt at
To make sure everything is installed properly, try running yt at
the command line:

.. code-block:: bash
Expand Down
2 changes: 1 addition & 1 deletion nose_unit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ nologcapture=1
verbosity=2
where=yt
with-timer=1
ignore-files=(test_load_errors.py|test_load_sample.py|test_commons.py|test_ambiguous_fields.py|test_field_access_pytest.py|test_save.py|test_load_archive.py)
ignore-files=(test_load_errors.py|test_load_sample.py|test_commons.py|test_ambiguous_fields.py|test_field_access_pytest.py|test_save.py|test_load_archive.py|test_line_annotation_unit.py|test_eps_writer.py)
exclude-test=yt.frontends.gdf.tests.test_outputs.TestGDF
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ full =
astropy>=4.0.1,<5.0.0
f90nml>=1.1.2
fastcache~=1.0.2
firefly-vis>=2.0.0
firefly-vis>=2.0.0,<2.0.3 #https://github.com/ageller/Firefly/issues/62
glueviz~=0.13.3
h5py>=3.1.0,<4.0.0
libconf~=1.0.1
Expand Down
2 changes: 2 additions & 0 deletions tests/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,12 @@ other_tests:
- '--ignore=test_outputs_pytest'
- '--ignore-files=test_load_errors.py'
- '--ignore-files=test_commons.py'
- '--ignore-files=test_line_annotation_unit.py'
- '--ignore-files=test_load_sample.py'
- '--ignore-files=test_load_archive.py'
- '--ignore-files=test_field_access_pytest.py'
- '--ignore-files=test_ambiguous_fields.py'
- '--ignore-files=test_eps_writer.py'
- "--ignore-files=test_save.py"
- '--exclude-test=yt.frontends.gdf.tests.test_outputs.TestGDF'
cookbook:
Expand Down
16 changes: 11 additions & 5 deletions yt/data_objects/construction_data_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,12 +648,19 @@ def __init__(
self.right_edge = self.left_edge + self.ActiveDimensions * self.dds
self._num_ghost_zones = num_ghost_zones
self._use_pbar = use_pbar
self.global_startindex = np.rint(
(self.left_edge - self.ds.domain_left_edge) / self.dds
).astype("int64")
self.global_startindex = (
np.rint((self.left_edge - self.ds.domain_left_edge) / self.dds).astype(
"int64"
)
+ self.ds.domain_offset
)
self._setup_data_source()
self.get_data(fields)

def get_global_startindex(self):
r"""Get the global start index of the covering grid."""
return self.global_startindex

def to_xarray(self, fields=None):
r"""Export this fixed-resolution object to an xarray Dataset
Expand Down Expand Up @@ -1405,8 +1412,7 @@ def _fill_fields(self, fields):
warnings.warn(
"Something went wrong during field computation. "
"This is likely due to missing ghost-zones support "
"in class %s",
self.ds.__class__,
f"in class {type(self.ds)}",
category=RuntimeWarning,
)
mylog.debug("Caught %d runtime errors.", runtime_errors_count)
Expand Down
3 changes: 3 additions & 0 deletions yt/data_objects/static_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ class Dataset(abc.ABC):
domain_left_edge = MutableAttribute(True)
domain_right_edge = MutableAttribute(True)
domain_dimensions = MutableAttribute(True)
# the point in index space "domain_left_edge" doesn't necessarily
# map to (0, 0, 0)
domain_offset = np.zeros(3, dtype="int64")
_periodicity = MutableAttribute()
_force_periodicity = False

Expand Down
28 changes: 22 additions & 6 deletions yt/frontends/athena/data_structures.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import re
import weakref

import numpy as np
Expand Down Expand Up @@ -632,12 +633,27 @@ def _parse_parameter_file(self):

@classmethod
def _is_valid(cls, filename, *args, **kwargs):
try:
if "vtk" in filename:
return True
except Exception:
pass
return False
if not filename.endswith(".vtk"):
return False

with open(filename, "rb") as fh:
if not re.match(b"# vtk DataFile Version \\d\\.\\d\n", fh.readline(256)):
return False
if (
re.search(
b"at time= .*, level= \\d, domain= \\d\n",
fh.readline(256),
)
is None
):
# vtk Dumps headers start with either "CONSERVED vars" or "PRIMITIVE vars",
# while vtk output headers start with "Really cool Athena data", but
# we will consider this an implementation detail and not attempt to
# match it exactly here.
# See Athena's user guide for reference
# https://princetonuniversity.github.io/Athena-Cversion/AthenaDocsUGbtk
return False
return True

@property
def _skip_cache(self):
Expand Down
15 changes: 2 additions & 13 deletions yt/frontends/boxlib/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,19 +743,7 @@ def _parse_cparams(self):
param, vals = (s.strip() for s in line.split("="))
except ValueError:
continue
if param == "amr.n_cell":
vals = self.domain_dimensions = np.array(vals.split(), dtype="int32")

# For 1D and 2D simulations in BoxLib usually only the relevant
# dimensions have a specified number of zones, but yt requires
# domain_dimensions to have three elements, with 1 in the additional
# slots if we're not in 3D, so append them as necessary.

if self.dimensionality == 1:
vals = self.domain_dimensions = np.array([vals[0], 1, 1])
elif self.dimensionality == 2:
vals = self.domain_dimensions = np.array([vals[0], vals[1], 1])
elif param == "amr.ref_ratio":
if param == "amr.ref_ratio":
vals = self.refine_by = int(vals[0])
elif param == "Prob.lo_bc":
vals = tuple(p == "1" for p in vals.split())
Expand Down Expand Up @@ -881,6 +869,7 @@ def _parse_header_file(self):
stop = np.array(root_space[1].split(","), dtype="int64")
dd = np.ones(3, dtype="int64")
dd[: self.dimensionality] = stop - start + 1
self.domain_offset[: self.dimensionality] = start
self.domain_dimensions = dd

# Skip timesteps per level
Expand Down
47 changes: 0 additions & 47 deletions yt/frontends/boxlib/definitions.py
Original file line number Diff line number Diff line change
@@ -1,47 +0,0 @@
# TODO: get rid of enzo parameters we do not need
parameterDict = {
"CosmologyCurrentRedshift": float,
"CosmologyComovingBoxSize": float,
"CosmologyOmegaMatterNow": float,
"CosmologyOmegaLambdaNow": float,
"CosmologyHubbleConstantNow": float,
"CosmologyInitialRedshift": float,
"DualEnergyFormalismEta1": float,
"DualEnergyFormalismEta2": float,
"MetaDataString": str,
"HydroMethod": int,
"DualEnergyFormalism": int,
"InitialTime": float,
"ComovingCoordinates": int,
"DensityUnits": float,
"LengthUnits": float,
"LengthUnit": float,
"TemperatureUnits": float,
"TimeUnits": float,
"GravitationalConstant": float,
"Gamma": float,
"MultiSpecies": int,
"CompilerPrecision": str,
"CurrentTimeIdentifier": int,
"RefineBy": int,
"BoundaryConditionName": str,
"TopGridRank": int,
"TopGridDimensions": int,
"EOSSoundSpeed": float,
"EOSType": int,
"NumberOfParticleAttributes": int,
}


# converts the Orion inputs file name to the Enzo/yt name expected
# throughout the code. key is Orion name, value is Enzo/yt equivalent
orion2enzoDict = {
"amr.n_cell": "TopGridDimensions",
"materials.gamma": "Gamma",
"amr.ref_ratio": "RefineBy",
"castro.use_comoving": "ComovingCoordinates",
"castro.redshift_in": "CosmologyInitialRedshift",
"comoving_OmL": "CosmologyOmegaLambdaNow",
"comoving_OmM": "CosmologyOmegaMatterNow",
"comoving_h": "CosmologyHubbleConstantNow",
}
33 changes: 22 additions & 11 deletions yt/geometry/coordinates/coordinate_handler.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import abc
import weakref
from numbers import Number

Expand Down Expand Up @@ -61,47 +62,56 @@ def validate_sequence_width(width, ds, unit=None):
)


class CoordinateHandler:
class CoordinateHandler(abc.ABC):
name = None

def __init__(self, ds, ordering):
self.ds = weakref.proxy(ds)
self.axis_order = ordering

@abc.abstractmethod
def setup_fields(self):
# This should return field definitions for x, y, z, r, theta, phi
raise NotImplementedError
pass

@abc.abstractmethod
def pixelize(self, dimension, data_source, field, bounds, size, antialias=True):
# This should *actually* be a pixelize call, not just returning the
# pixelizer
raise NotImplementedError
pass

@abc.abstractmethod
def pixelize_line(self, field, start_point, end_point, npoints):
raise NotImplementedError
pass

def distance(self, start, end):
p1 = self.convert_to_cartesian(start)
p2 = self.convert_to_cartesian(end)
return np.sqrt(((p1 - p2) ** 2.0).sum())

@abc.abstractmethod
def convert_from_cartesian(self, coord):
raise NotImplementedError
pass

@abc.abstractmethod
def convert_to_cartesian(self, coord):
raise NotImplementedError
pass

@abc.abstractmethod
def convert_to_cylindrical(self, coord):
raise NotImplementedError
pass

@abc.abstractmethod
def convert_from_cylindrical(self, coord):
raise NotImplementedError
pass

@abc.abstractmethod
def convert_to_spherical(self, coord):
raise NotImplementedError
pass

@abc.abstractmethod
def convert_from_spherical(self, coord):
raise NotImplementedError
pass

_data_projection = None

Expand Down Expand Up @@ -194,8 +204,9 @@ def y_axis(self):
return ya

@property
@abc.abstractproperty
def period(self):
raise NotImplementedError
pass

def sanitize_depth(self, depth):
if is_sequence(depth):
Expand Down
3 changes: 3 additions & 0 deletions yt/geometry/coordinates/cylindrical_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ def pixelize(
# Pixelizing along a cylindrical surface is a bit tricky
raise NotImplementedError

def pixelize_line(self, field, start_point, end_point, npoints):
raise NotImplementedError

def _ortho_pixelize(
self, data_source, field, bounds, size, antialias, dim, periodic
):
Expand Down
3 changes: 3 additions & 0 deletions yt/geometry/coordinates/geographic_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ def pixelize(
else:
raise NotImplementedError

def pixelize_line(self, field, start_point, end_point, npoints):
raise NotImplementedError

def _ortho_pixelize(
self, data_source, field, bounds, size, antialias, dimension, periodic
):
Expand Down
3 changes: 3 additions & 0 deletions yt/geometry/coordinates/spherical_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ def pixelize(
else:
raise NotImplementedError

def pixelize_line(self, field, start_point, end_point, npoints):
raise NotImplementedError

def _ortho_pixelize(
self, data_source, field, bounds, size, antialias, dim, periodic
):
Expand Down
Loading

0 comments on commit 2542744

Please sign in to comment.