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

Interpolate_1d does not function with Type Error ( tuple indices must be integers or slices, not tuple) #998

Closed
sunchaoatmo opened this issue Jan 30, 2019 · 12 comments
Assignees
Labels
Area: Calc Pertains to calculations Type: Bug Something is not working like it should
Milestone

Comments

@sunchaoatmo
Copy link

sunchaoatmo commented Jan 30, 2019

Bugs

  1 #!/usr/bin/env python
  2 import numpy as np
  3 import metpy.interpolate
  4 x_log = np.array([1e3, 1e4, 1e5, 1e6])
  5 y_log = np.log(x_log) * 2 + 3
  6 x_interp = np.array([5e3, 5e4, 5e5])
  7 print(metpy.interpolate.log_interpolate_1d(x_interp, x_log, y_log))
  • Problem description: the code can not run with the error message as follow:
    Traceback (most recent call last):
    File "./test.py", line 7, in
    print(metpy.interpolate.log_interpolate_1d(x_interp, x_log, y_log))
    File "/Users/chaosun/anaconda3/lib/python3.7/site-packages/metpy/xarray.py", line 436, in wrapper
    return func(*args, **kwargs)
    File "/Users/chaosun/anaconda3/lib/python3.7/site-packages/pint/registry_helpers.py", line 194, in wrapper
    result = func(*new_values, **kw)
    File "/Users/chaosun/anaconda3/lib/python3.7/site-packages/metpy/interpolate/one_dimension.py", line 228, in log_interpolate_1d
    return interpolate_1d(log_x, log_xp, *args, axis=axis, fill_value=fill_value)
    File "/Users/chaosun/anaconda3/lib/python3.7/site-packages/metpy/xarray.py", line 436, in wrapper
    return func(*args, **kwargs)
    File "/Users/chaosun/anaconda3/lib/python3.7/site-packages/pint/registry_helpers.py", line 194, in wrapper
    result = func(*new_values, **kw)
    File "/Users/chaosun/anaconda3/lib/python3.7/site-packages/metpy/interpolate/one_dimension.py", line 119, in interpolate_1d
    variables = [arr[sorter] for arr in args]
    File "/Users/chaosun/anaconda3/lib/python3.7/site-packages/metpy/interpolate/one_dimension.py", line 119, in
    variables = [arr[sorter] for arr in args]
    TypeError: tuple indices must be integers or slices, not tuple

  • Versions:

    • We tested 3.7.1, 3.6.8, 2.7.15
    • Platform Mac and Linux (Cheyenne CISL supercomputer )
    • metpy version: 0.10.0 0.9.0 0.8.0
@sunchaoatmo sunchaoatmo changed the title -Code sample: The official website sample as follow: -Code sample: The official website sample as follow: Jan 30, 2019
@sunchaoatmo sunchaoatmo changed the title -Code sample: The official website sample as follow: -Bug in interpolate_1d TypeError Jan 30, 2019
@sunchaoatmo sunchaoatmo changed the title -Bug in interpolate_1d TypeError Interpolate_1d does not function Jan 30, 2019
@sunchaoatmo sunchaoatmo changed the title Interpolate_1d does not function Interpolate_1d does not function with Type Error ( tuple indices must be integers or slices, not tuple) Jan 30, 2019
@dopplershift
Copy link
Member

So the problem is caused by pint 0.9. As a work-around for now, I'd suggest installing pint 0.8.1.

@dopplershift dopplershift self-assigned this Jan 30, 2019
@dopplershift dopplershift added Area: Calc Pertains to calculations Type: Bug Something is not working like it should labels Jan 30, 2019
@MethaneRain
Copy link

MethaneRain commented Feb 8, 2019

I'm experiencing the same problem with mpcalc.isentropic_interpolation as of recently as well. Would downgrading the pint work, or should I open a new issue for my specific issue?

@jrleeman
Copy link
Contributor

jrleeman commented Feb 8, 2019

Pint 0.9 fundamentally breaks a lot of things, so I'd roll to 0.8.1

@MethaneRain
Copy link

What would be the best way to do that, through conda or pip?

@jrleeman
Copy link
Contributor

jrleeman commented Feb 8, 2019

I lean to conda, so conda install pint=0.8.1

@MethaneRain
Copy link

MethaneRain commented Feb 8, 2019

I downgraded pint but unfortunately I'm now running into a different issue when trying to pull data from the GFS via thredds and ncss...

metpy_fix_issue3

metpy_fix_issue2

metpy_fix_issue

Curious if anyone else has succeeded in downgrading with no errors

Edit

Looks like something with netcdf4 library changed from downgrade?

metpy_fix_issue4

@dopplershift
Copy link
Member

That’s weird. Could try conda update netcdf4

@MethaneRain
Copy link

MethaneRain commented Feb 9, 2019

I remembered I messed around with NCL and pygrib around the time of pint upgrade to 0.9. So went back in time and got back to originally having 0.8.1 before NCL/pygrib, then upgraded to 0.9, got the error again. This time going back to 0.8.1 w/o NCL or pygrib I was able to successfully run off 0.8.1 without any troubles from netcdf4.

So I'm good, and have my isentropes again.

Thanks as always for the pointers!

@jbellier
Copy link

I have started yesterday to use Metpy, and the current default installation (as of May 29 2019) installs pint=0.9. I was trying to use the function storm_relative_helicity() but got the same Type Error ( tuple indices must be integers or slices, not tuple). It took me a while to figure out that it came from the pint version.

I don't know if solving this issue is planned, but in the meantime I would suggest to update the descriptions of the impacted functions so that we know we have to use pint=0.8.1.

By the way, conda install pint=0.8.1 does not work anymore, I had to download manually the version from the release history of pint.

@dopplershift
Copy link
Member

We’ll have a fix in the next release, sorry that that’s been lagging so long. Does this work to install pint: conda install -c conda-forge pint?

@jbellier
Copy link

Well, conda install -c conda-forge pint does run on my console, but it has actually not installed pint (which I had previously uninstalled), I don't really understand why...

As I said my solution was pip install Pint-0.8.1.tar.gz with Pint-0.8.1.tar.gz downloaded here.

@zbruick
Copy link
Contributor

zbruick commented Jul 18, 2019

Pint functionality was fixed by #1087. Closing, but if there are still issues this can be reopened.

@zbruick zbruick closed this as completed Jul 18, 2019
@dopplershift dopplershift added this to the 0.10.1 milestone Jul 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Calc Pertains to calculations Type: Bug Something is not working like it should
Projects
None yet
Development

No branches or pull requests

6 participants