Skip to content

Commit

Permalink
add a NotImplementedError and catch _that_ instaead of waiting for un…
Browse files Browse the repository at this point in the history
…yt to raise a UnitConversionError. This fixes the following test: yt/data_objects/tests/test_covering_grid.py::test_smoothed_covering_grid_2d_dataset
  • Loading branch information
neutrinoceros committed Aug 14, 2020
1 parent dc9088c commit 4b9fa35
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions yt/fields/field_info_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
standard_particle_fields,
)

# from unyt.exceptions import UnitConversionError


def tupleize(inp):
if isinstance(inp, tuple):
Expand Down Expand Up @@ -486,6 +484,9 @@ def check_derived_fields(self, fields_to_check=None):
# underlying issues locally.
fd = fi.get_dependencies(ds=self.ds)
except (
# this one I added on purpose as a catch for stuff
# that was revealed to be unsupported
NotImplementedError,
# Yt errors
# those are probably fine (but should be checked)
YTFieldNotFound,
Expand Down
1 change: 1 addition & 0 deletions yt/fields/vector_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ def _tangential_over_magnitude(field, data):
data[ftype, f"tangential_{basename}"]
/ data[ftype, f"{basename}_magnitude"]
)

return np.abs(tr)

registry.add_field(
Expand Down
9 changes: 6 additions & 3 deletions yt/utilities/lib/misc_utilities.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,14 @@ def obtain_relative_velocity_vector(
cdef np.ndarray[np.float64_t, ndim=3] vzg
cdef np.ndarray[np.float64_t, ndim=4] rvg
cdef np.float64_t bv[3]
cdef int i, j, k
cdef int i, j, k, dim

units = data[field_names[0]].units
bulk_vector = data.get_field_parameter(bulk_vector).to(units)
if len(data[field_names[0]].shape) == 1:
dim = len(data[field_names[0]].shape) == 1
if dim == 2:
raise NotImplementedError
if dim == 1:
# One dimensional data
vxf = data[field_names[0]].astype("float64")
vyf = data[field_names[1]].astype("float64")
Expand All @@ -652,7 +655,7 @@ def obtain_relative_velocity_vector(
rvf[1, i] = vyf[i] - bv[1]
rvf[2, i] = vzf[i] - bv[2]
return rvf
else:
elif dim == 3:
# Three dimensional data
vxg = data[field_names[0]].astype("float64")
vyg = data[field_names[1]].astype("float64")
Expand Down

0 comments on commit 4b9fa35

Please sign in to comment.