Skip to content

Commit 60abc14

Browse files
authored
Merge pull request #5088 from chummels/fix-phase
BUG: Removing code that removes field type in set_title()
2 parents dfaab05 + 7f27f86 commit 60abc14

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

yt/visualization/profile_plotter.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,8 +1319,6 @@ def annotate_title(self, title):
13191319
13201320
"""
13211321
for f in self._profile.field_data:
1322-
if isinstance(f, tuple):
1323-
f = f[1]
13241322
self.plot_title[self.data_source._determine_fields(f)[0]] = title
13251323
return self
13261324

yt/visualization/tests/test_profile_plots.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import tempfile
44
import unittest
55

6+
import numpy as np
67
import pytest
78

89
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
1011
from yt.visualization.api import PhasePlot
1112

1213

@@ -66,6 +67,49 @@ def test_phaseplot_set_ylim(self):
6667
return p.plots["gas", "mass"].figure
6768

6869

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+
69113
def test_set_units():
70114
fields = ("density", "temperature")
71115
units = (

0 commit comments

Comments
 (0)