Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing code that removes field type in set_title() #5088

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions yt/visualization/profile_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1319,8 +1319,6 @@ def annotate_title(self, title):

"""
for f in self._profile.field_data:
if isinstance(f, tuple):
f = f[1]
self.plot_title[self.data_source._determine_fields(f)[0]] = title
return self

Expand Down
58 changes: 57 additions & 1 deletion yt/visualization/tests/test_profile_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import tempfile
import unittest

import numpy as np
import pytest

import yt
from yt.testing import assert_allclose_units, fake_random_ds
from yt.testing import assert_allclose_units, fake_random_ds, fake_random_sph_ds
from yt.visualization.api import PhasePlot


Expand Down Expand Up @@ -66,6 +67,61 @@ def test_phaseplot_set_ylim(self):
return p.plots["gas", "mass"].figure


class TestPhasePlotParticleAPI:
@classmethod
def setup_class(cls):
bbox = np.array([[-1.0, 3.0], [1.0, 5.2], [-1.0, 3.0]])
cls.ds = fake_random_sph_ds(50, bbox)

def get_plot(self):
return PhasePlot(
self.ds, ("gas", "density"), ("gas", "density"), ("gas", "mass")
)

@pytest.mark.parametrize("kwargs", [{}, {"color": "b"}])
@pytest.mark.mpl_image_compare
def test_phaseplot_annotate_text(self, kwargs):
p = self.get_plot()
p.annotate_text(1e-4, 1e-2, "Test text annotation", **kwargs)
p.render()
return p.plots["gas", "mass"].figure

@pytest.mark.mpl_image_compare
def test_phaseplot_set_title(self):
p = self.get_plot()
p.annotate_title("Test Title")
p.render()
return p.plots["gas", "mass"].figure

@pytest.mark.mpl_image_compare
def test_phaseplot_set_log(self):
p = self.get_plot()
p.set_log(("gas", "mass"), False)
p.render()
return p.plots["gas", "mass"].figure

@pytest.mark.mpl_image_compare
def test_phaseplot_set_unit(self):
p = self.get_plot()
p.set_unit(("gas", "mass"), "Msun")
p.render()
return p.plots["gas", "mass"].figure

@pytest.mark.mpl_image_compare
def test_phaseplot_set_xlim(self):
p = self.get_plot()
p.set_xlim(1e-3, 1e0)
p.render()
return p.plots["gas", "mass"].figure

@pytest.mark.mpl_image_compare
def test_phaseplot_set_ylim(self):
p = self.get_plot()
p.set_ylim(1e-2, 1e0)
p.render()
return p.plots["gas", "mass"].figure


def test_set_units():
fields = ("density", "temperature")
units = (
Expand Down
Loading