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

Support Python 3.11 #744

Closed
khaeru opened this issue May 20, 2023 · 1 comment · Fixed by #747
Closed

Support Python 3.11 #744

khaeru opened this issue May 20, 2023 · 1 comment · Fixed by #747

Comments

@khaeru
Copy link
Contributor

khaeru commented May 20, 2023

In the test suite for iiasa/message_ix, we see the following error with Python 3.11 in a test that uses pyam.IamDataFrame.plot():

/tmp/ipykernel_8873/3284970234.py in ?()
      1 get_ipython().run_line_magic('matplotlib', 'inline')
      2 
----> 3 (df.filter(model="Westeros Electrified", scenario="baseline", region="Westeros").plot())

/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/pyam/plotting.py in ?(self, kind, *args, **kwargs)
    103     def __call__(self, kind="line", *args, **kwargs):
--> 104         return getattr(self, kind)(**kwargs)

/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/pyam/plotting.py in ?(self, **kwargs)
    106     def line(self, **kwargs):
--> 107         return line(self._parent, **kwargs)

/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/pyam/plotting.py in ?(df, x, y, order, legend, title, color, marker, linestyle, fill_between, final_ranges, rm_legend_label, ax, cmap, **kwargs)
   1051     # pop label to avoid multiple values for plot-kwarg
   1052     label = kwargs.pop("label", None)
   1053 
   1054     # plot data, keeping track of which legend labels to apply
-> 1055     for col, data in df.iteritems():
   1056         # handle case where columns are not strings or only have 1 dimension
   1057         col = list(map(str, to_list(col)))
   1058         pargs = {}

/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/pandas/core/generic.py in ?(self, name)
   5985             and name not in self._accessors
   5986             and self._info_axis._can_hold_identifiers_and_holds_name(name)
   5987         ):
   5988             return self[name]
-> 5989         return object.__getattribute__(self, name)

AttributeError: 'DataFrame' object has no attribute 'iteritems'

I notice that python_requires = >=3.7, <3.11 was set in setup.cfg, apparently in #654: https://github.com/IAMconsortium/pyam/blame/947d8c4df2dcb362baed6e1274d63a24142ba067/setup.cfg#L22

This is low urgency: we can simply caution message_ix users with Python 3.11 to avoid using this feature of pyam or to use Python 3.10 instead. I open the issue mainly so we can track the reason for xfailing tests in message_ix.

khaeru added a commit to iiasa/message_ix that referenced this issue May 20, 2023
Mark westeros_report tutorial xfail on Python 3.11.
@danielhuppmann
Copy link
Member

This issue does not seem to be directly related to Python 3.11, or at least there is not test for the feature - see #745. Can you point me to the file where this error originates?

khaeru added a commit to iiasa/message_ix that referenced this issue Sep 1, 2023
glatterf42 pushed a commit to iiasa/message_ix that referenced this issue Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants