|
3 | 3 | import tempfile
|
4 | 4 | import unittest
|
5 | 5 |
|
| 6 | +import numpy as np |
6 | 7 | import pytest
|
7 | 8 |
|
8 | 9 | import yt
|
9 |
| -from yt.testing import assert_allclose_units, fake_random_ds |
| 10 | +from yt.testing import assert_allclose_units, fake_random_ds, fake_random_sph_ds |
10 | 11 | from yt.visualization.api import PhasePlot
|
11 | 12 |
|
12 | 13 |
|
@@ -66,6 +67,49 @@ def test_phaseplot_set_ylim(self):
|
66 | 67 | return p.plots["gas", "mass"].figure
|
67 | 68 |
|
68 | 69 |
|
| 70 | +class TestPhasePlotParticleAPI: |
| 71 | + @classmethod |
| 72 | + def setup_class(cls): |
| 73 | + bbox = np.array([[-1.0, 3.0], [1.0, 5.2], [-1.0, 3.0]]) |
| 74 | + cls.ds = fake_random_sph_ds(50, bbox) |
| 75 | + |
| 76 | + def get_plot(self): |
| 77 | + return PhasePlot( |
| 78 | + self.ds, ("gas", "density"), ("gas", "density"), ("gas", "mass") |
| 79 | + ) |
| 80 | + |
| 81 | + @pytest.mark.parametrize("kwargs", [{}, {"color": "b"}]) |
| 82 | + def test_phaseplot_annotate_text(self, kwargs): |
| 83 | + p = self.get_plot() |
| 84 | + p.annotate_text(1e-4, 1e-2, "Test text annotation", **kwargs) |
| 85 | + p.render() |
| 86 | + |
| 87 | + def test_phaseplot_set_title(self): |
| 88 | + p = self.get_plot() |
| 89 | + p.annotate_title("Test Title") |
| 90 | + p.render() |
| 91 | + |
| 92 | + def test_phaseplot_set_log(self): |
| 93 | + p = self.get_plot() |
| 94 | + p.set_log(("gas", "mass"), False) |
| 95 | + p.render() |
| 96 | + |
| 97 | + def test_phaseplot_set_unit(self): |
| 98 | + p = self.get_plot() |
| 99 | + p.set_unit(("gas", "mass"), "Msun") |
| 100 | + p.render() |
| 101 | + |
| 102 | + def test_phaseplot_set_xlim(self): |
| 103 | + p = self.get_plot() |
| 104 | + p.set_xlim(1e-3, 1e0) |
| 105 | + p.render() |
| 106 | + |
| 107 | + def test_phaseplot_set_ylim(self): |
| 108 | + p = self.get_plot() |
| 109 | + p.set_ylim(1e-2, 1e0) |
| 110 | + p.render() |
| 111 | + |
| 112 | + |
69 | 113 | def test_set_units():
|
70 | 114 | fields = ("density", "temperature")
|
71 | 115 | units = (
|
|
0 commit comments