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

PhasePlot set_title() fails on ambiguous fields even when fully specified #5087

Open
chummels opened this issue Dec 19, 2024 · 0 comments
Open
Assignees
Labels

Comments

@chummels
Copy link
Member

Bug report

Bug summary

Plot annotation set_title() fails when the associated PhasePlot has a field which may be ambiguous, even if you specify the full field name.

Code for reproduction

import yt
ds = yt.load_sample('FIRE_M12i_ref11')
p = yt.PhasePlot(ds, ('gas', 'density'), ('gas', 'temperature'), [('gas', 'z')], weight_field=None)
p.annotate_title('test')
p.save()

Notice that the z field is fully specified as ('gas', 'z'), but yt gets unhappy because there are other z fields.

Actual outcome

Traceback (most recent call last):
  File "/Users/chummels/scratch/test_phase.py", line 4, in <module>
    p.annotate_title('test')
  File "/Users/chummels/src/yt/yt/visualization/_commons.py", line 112, in newfunc
    retv = f(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chummels/src/yt/yt/visualization/profile_plotter.py", line 1324, in annotate_title
    self.plot_title[self.data_source._determine_fields(f)[0]] = title
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chummels/src/yt/yt/data_objects/data_containers.py", line 1471, in _determine_fields
    finfo = self.ds._get_field_info(field)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chummels/src/yt/yt/data_objects/static_output.py", line 1001, in _get_field_info
    raise ValueError(
ValueError: The requested field name 'z' is ambiguous and corresponds to any one of the following field types:
 ['index', 'gas', 'PartType0']
Please specify the requested field as an explicit tuple (<ftype>, <fname>).

Expected outcome

It should just work and generate a PhasePlot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant