Exemplo n.º 1
0
 def __init__(self,
              axis,
              coords,
              ds=None,
              field_parameters=None,
              data_source=None):
     validate_axis(ds, axis)
     validate_iterable(coords)
     for c in coords:
         validate_float(c)
     validate_object(ds, Dataset)
     validate_object(field_parameters, dict)
     validate_object(data_source, YTSelectionContainer)
     super(YTOrthoRay, self).__init__(ds, field_parameters, data_source)
     self.axis = fix_axis(axis, self.ds)
     xax = self.ds.coordinates.x_axis[self.axis]
     yax = self.ds.coordinates.y_axis[self.axis]
     self.px_ax = xax
     self.py_ax = yax
     # Even though we may not be using x,y,z we use them here.
     self.px_dx = 'd%s' % ('xyz'[self.px_ax])
     self.py_dx = 'd%s' % ('xyz'[self.py_ax])
     # Convert coordinates to code length.
     if isinstance(coords[0], YTQuantity):
         self.px = self.ds.quan(coords[0]).to("code_length")
     else:
         self.px = self.ds.quan(coords[0], "code_length")
     if isinstance(coords[1], YTQuantity):
         self.py = self.ds.quan(coords[1]).to("code_length")
     else:
         self.py = self.ds.quan(coords[1], "code_length")
     self.sort_by = 'xyz'[self.axis]
Exemplo n.º 2
0
def test_validate_axis():
    validate_axis(None, 0)
    validate_axis(None, "X")

    ds = fake_amr_ds(geometry="cylindrical")
    ds.slice("Theta", 0.25)

    with assert_raises(TypeError) as ex:
        # default geometry is cartesian
        ds = fake_amr_ds()
        ds.slice("r", 0.25)
    desired = ("Expected axis of int or char type (can be "
               "[0, 'x', 'X', 1, 'y', 'Y', 2, 'z', 'Z']), received 'r'.")
    assert_equal(str(ex.exception)[:40], desired[:40])
Exemplo n.º 3
0
 def __init__(
     self, axis, coord, center=None, ds=None, field_parameters=None, data_source=None
 ):
     validate_axis(ds, axis)
     validate_float(coord)
     # center is an optional parameter
     if center is not None:
         validate_center(center)
     validate_object(ds, Dataset)
     validate_object(field_parameters, dict)
     validate_object(data_source, YTSelectionContainer)
     YTSelectionContainer2D.__init__(self, axis, ds, field_parameters, data_source)
     self._set_center(center)
     self.coord = coord