def test_arrow_callback():
    with _cleanup_fname() as prefix:
        ax = 'z'
        vector = [1.0, 1.0, 1.0]
        ds = fake_amr_ds(fields=("density", ))
        p = ProjectionPlot(ds, ax, "density")
        p.annotate_arrow([0.5, 0.5, 0.5])
        yield assert_fname, p.save(prefix)[0]
        p = SlicePlot(ds, ax, "density")
        p.annotate_arrow([0.5, 0.5, 0.5])
        yield assert_fname, p.save(prefix)[0]
        p = OffAxisSlicePlot(ds, vector, "density")
        p.annotate_arrow([0.5, 0.5, 0.5])
        yield assert_fname, p.save(prefix)[0]
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", "density")
        p.annotate_arrow([0.5, 0.5], coord_system='axis', length=0.05)
        p.save(prefix)
def test_arrow_callback():
    with _cleanup_fname() as prefix:
        ax = 'z'
        vector = [1.0,1.0,1.0]
        ds = fake_amr_ds(fields = ("density",))
        p = ProjectionPlot(ds, ax, "density")
        p.annotate_arrow([0.5,0.5,0.5])
        yield assert_fname, p.save(prefix)[0]
        p = SlicePlot(ds, ax, "density")
        p.annotate_arrow([0.5,0.5,0.5])
        yield assert_fname, p.save(prefix)[0]
        p = OffAxisSlicePlot(ds, vector, "density")
        p.annotate_arrow([0.5,0.5,0.5])
        yield assert_fname, p.save(prefix)[0]
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", "density")
        p.annotate_arrow([0.5,0.5], coord_system='axis', length=0.05)
        p.save(prefix)
示例#3
0
def test_arrow_callback():
    with _cleanup_fname() as prefix:
        ax = 'z'
        vector = [1.0, 1.0, 1.0]
        ds = fake_amr_ds(fields=("density", ))
        p = ProjectionPlot(ds, ax, "density")
        p.annotate_arrow([0.5, 0.5, 0.5])
        assert_fname(p.save(prefix)[0])
        p = SlicePlot(ds, ax, "density")
        p.annotate_arrow([0.5, 0.5, 0.5])
        assert_fname(p.save(prefix)[0])
        p = OffAxisSlicePlot(ds, vector, "density")
        p.annotate_arrow([0.5, 0.5, 0.5])
        assert_fname(p.save(prefix)[0])
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", "density")
        p.annotate_arrow([0.5, 0.5], coord_system='axis', length=0.05)
        p.annotate_arrow([[0.5, 0.6], [0.5, 0.6], [0.5, 0.6]],
                         coord_system='data',
                         length=0.05)
        p.annotate_arrow([[0.5, 0.6, 0.8], [0.5, 0.6, 0.8], [0.5, 0.6, 0.8]],
                         coord_system='data',
                         length=0.05)
        p.annotate_arrow([[0.5, 0.6, 0.8], [0.5, 0.6, 0.8]],
                         coord_system='axis',
                         length=0.05)
        p.annotate_arrow([[0.5, 0.6, 0.8], [0.5, 0.6, 0.8]],
                         coord_system='figure',
                         length=0.05)
        p.annotate_arrow([[0.5, 0.6, 0.8], [0.5, 0.6, 0.8]],
                         coord_system='plot',
                         length=0.05)
        p.save(prefix)

    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields=("density", ), geometry="spherical")
        p = ProjectionPlot(ds, "r", "density")
        p.annotate_arrow([0.5, 0.5, 0.5])
        assert_raises(YTDataTypeUnsupported, p.save, prefix)
        p = ProjectionPlot(ds, "r", "density")
        p.annotate_arrow([0.5, 0.5], coord_system="axis")
        assert_fname(p.save(prefix)[0])
示例#4
0
def test_arrow_callback():
    with _cleanup_fname() as prefix:
        ax = "z"
        vector = [1.0, 1.0, 1.0]
        ds = fake_amr_ds(fields=("density",), units=("g/cm**3",))
        p = ProjectionPlot(ds, ax, ("gas", "density"))
        p.annotate_arrow([0.5, 0.5, 0.5])
        assert_fname(p.save(prefix)[0])
        p = SlicePlot(ds, ax, ("gas", "density"))
        p.annotate_arrow([0.5, 0.5, 0.5])
        assert_fname(p.save(prefix)[0])
        p = OffAxisSlicePlot(ds, vector, ("gas", "density"))
        p.annotate_arrow([0.5, 0.5, 0.5])
        assert_fname(p.save(prefix)[0])
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", ("gas", "density"))
        p.annotate_arrow([0.5, 0.5], coord_system="axis", length=0.05)
        p.annotate_arrow(
            [[0.5, 0.6], [0.5, 0.6], [0.5, 0.6]], coord_system="data", length=0.05
        )
        p.annotate_arrow(
            [[0.5, 0.6, 0.8], [0.5, 0.6, 0.8], [0.5, 0.6, 0.8]],
            coord_system="data",
            length=0.05,
        )
        p.annotate_arrow(
            [[0.5, 0.6, 0.8], [0.5, 0.6, 0.8]], coord_system="axis", length=0.05
        )
        p.annotate_arrow(
            [[0.5, 0.6, 0.8], [0.5, 0.6, 0.8]], coord_system="figure", length=0.05
        )
        p.annotate_arrow(
            [[0.5, 0.6, 0.8], [0.5, 0.6, 0.8]], coord_system="plot", length=0.05
        )
        p.save(prefix)
        check_axis_manipulation(p, prefix)

    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields=("density",), units=("g/cm**3",), geometry="spherical")
        p = ProjectionPlot(ds, "r", ("gas", "density"))
        assert_raises(YTDataTypeUnsupported, p.annotate_arrow, [0.5, 0.5, 0.5])
        p.annotate_arrow([0.5, 0.5], coord_system="axis")
        assert_fname(p.save(prefix)[0])