示例#1
0
def test_grids_callback():
    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields=("density", ), units=("g/cm**3", ))
        for ax in "xyz":
            p = ProjectionPlot(ds, ax, "density")
            p.annotate_grids()
            assert_fname(p.save(prefix)[0])
            p = ProjectionPlot(ds, ax, "density", weight_field="density")
            p.annotate_grids()
            assert_fname(p.save(prefix)[0])
            p = SlicePlot(ds, ax, "density")
            p.annotate_grids()
            assert_fname(p.save(prefix)[0])
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", "density")
        p.annotate_grids(
            alpha=0.7,
            min_pix=10,
            min_pix_ids=30,
            draw_ids=True,
            id_loc="upper right",
            periodic=False,
            min_level=2,
            max_level=3,
            cmap="gist_stern",
        )
        p.save(prefix)

    with _cleanup_fname() as prefix:
        ds = load(cyl_2d)
        slc = SlicePlot(ds, "theta", "density")
        slc.annotate_grids()
        assert_fname(slc.save(prefix)[0])

    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields=("density", ),
                         units=("g/cm**3", ),
                         geometry="spherical")
        p = SlicePlot(ds, "r", "density")
        p.annotate_grids(
            alpha=0.7,
            min_pix=10,
            min_pix_ids=30,
            draw_ids=True,
            id_loc="upper right",
            periodic=False,
            min_level=2,
            max_level=3,
            cmap="gist_stern",
        )
        assert_raises(YTDataTypeUnsupported, p.save, prefix)
def test_grids_callback():
    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields = ("density",))
        for ax in 'xyz':
            p = ProjectionPlot(ds, ax, "density")
            p.annotate_grids()
            yield assert_fname, p.save(prefix)[0]
            p = ProjectionPlot(ds, ax, "density", weight_field="density")
            p.annotate_grids()
            yield assert_fname, p.save(prefix)[0]
            p = SlicePlot(ds, ax, "density")
            p.annotate_grids()
            yield assert_fname, p.save(prefix)[0]
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", "density")
        p.annotate_grids(alpha=0.7, min_pix=10, min_pix_ids=30,
            draw_ids=True, periodic=False, min_level=2,
            max_level=3, cmap="gist_stern")
        p.save(prefix)
示例#3
0
def test_grids_callback():
    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields=("density", ))
        for ax in 'xyz':
            p = ProjectionPlot(ds, ax, "density")
            p.annotate_grids()
            yield assert_fname, p.save(prefix)[0]
            p = ProjectionPlot(ds, ax, "density", weight_field="density")
            p.annotate_grids()
            yield assert_fname, p.save(prefix)[0]
            p = SlicePlot(ds, ax, "density")
            p.annotate_grids()
            yield assert_fname, p.save(prefix)[0]
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", "density")
        p.annotate_grids(alpha=0.7,
                         min_pix=10,
                         min_pix_ids=30,
                         draw_ids=True,
                         periodic=False,
                         min_level=2,
                         max_level=3,
                         cmap="gist_stern")
        p.save(prefix)