Can't extract from arviz

I copy/pasted code from arviz.extract — ArviZ dev documentation but the arviz.extract() method won’t work for me, what am I missing?

Here’s a public colab notebook that reproduces the problem: Google Colab

And here is the code and the error message:

import arviz as az
idata = az.load_arviz_data("centered_eight")
az.extract(idata)

AttributeError                            Traceback (most recent call last)

<ipython-input-3-206300e3e907> in <module>
      2 import arviz as az
      3 idata = az.load_arviz_data("centered_eight")
----> 4 az.extract(idata)

AttributeError: module 'arviz' has no attribute 'extract'

You are looking at the docs for the development version of ArviZ, hence the

title on your page and the dev flag on the navbar, right of the logo:

image

On GitHub pages only the docs for one version are hosted, and we are moving to readthedocs and a custom domain to host multiple versions (which explains the red banner). There you can see that arviz.extract appears on the /latest/ slug: arviz.extract — ArviZ dev documentation, but doesn’t on the /stable/ one: https://python.arviz.org/en/stable/api/generated/arviz.extract.html. It was added on GitHub very recently and we haven’t made any release yet.

If you want to already use arviz.extract you need to install the development version for ArviZ or wait ~1 month for the next release.

1 Like

Thanks for the explanation!

This means that extract() is not possible to use on colab, since the required version of xarray (0.21) requires python 3.8 and colab uses python 3.7. Since you (or the arviz developers) write that latest version of arviz requires only 3.6, have you/they considered this indirect dependency on python 3.8? Installation guide — ArviZ dev documentation

That is definitely not the case. Can you share the link to the page that says so so we can update it?

As a general rule, ArviZ and most packages of the ecosystem (not only xarray but numpy, scipy, matplotlib, pandas…) follow NEP 29 — Recommend Python and NumPy version support as a community policy standard — NumPy Enhancement Proposals and its draft extension Scientific Python - SPEC 0 — Minimum Supported Versions.

The indirect requirement on minimum 3.8 is not good though (until october) we probably messed up calculating back which releases of the depemdencies to cut. If you can check, can you submit a PR? I think the next release will be before october so it should still support 3.7

The link is in the very post you replied to, the installation guide

This commit is v 0.21, Add release notes for v0.21.0 (#6203) · pydata/xarray@8a885c1 · GitHub and I tried to install it on colab with

!pip install --upgrade scipy pandas xarray-einstats
!pip install git+https://github.com/pydata/xarray@8a885c1891f84536a3b4a15c03a61bfa132d180f
!pip install git+https://github.com/arviz-devs/arviz

Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Requirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (1.7.3)
Requirement already satisfied: pandas in /usr/local/lib/python3.7/dist-packages (1.3.5)
Requirement already satisfied: xarray-einstats in /usr/local/lib/python3.7/dist-packages (0.2.2)
Requirement already satisfied: numpy<1.23.0,>=1.16.5 in /usr/local/lib/python3.7/dist-packages (from scipy) (1.21.6)
Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.7/dist-packages (from pandas) (2.8.2)
Requirement already satisfied: pytz>=2017.3 in /usr/local/lib/python3.7/dist-packages (from pandas) (2022.1)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/dist-packages (from python-dateutil>=2.7.3->pandas) (1.15.0)
Requirement already satisfied: xarray>=0.20 in /usr/local/lib/python3.7/dist-packages (from xarray-einstats) (0.20.2)
Requirement already satisfied: typing-extensions>=3.7 in /usr/local/lib/python3.7/dist-packages (from xarray>=0.20->xarray-einstats) (4.1.1)
Requirement already satisfied: importlib-metadata in /usr/local/lib/python3.7/dist-packages (from xarray>=0.20->xarray-einstats) (4.12.0)
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.7/dist-packages (from importlib-metadata->xarray>=0.20->xarray-einstats) (3.8.1)
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Collecting git+https://github.com/pydata/xarray@8a885c1891f84536a3b4a15c03a61bfa132d180f
  Cloning https://github.com/pydata/xarray (to revision 8a885c1891f84536a3b4a15c03a61bfa132d180f) to /tmp/pip-req-build-s9j9aalv
  Running command git clone -q https://github.com/pydata/xarray /tmp/pip-req-build-s9j9aalv
  Running command git rev-parse -q --verify 'sha^8a885c1891f84536a3b4a15c03a61bfa132d180f'
  Running command git fetch -q https://github.com/pydata/xarray 8a885c1891f84536a3b4a15c03a61bfa132d180f
  Running command git checkout -q 8a885c1891f84536a3b4a15c03a61bfa132d180f
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Requirement already satisfied: numpy>=1.18 in /usr/local/lib/python3.7/dist-packages (from xarray==0.21.0) (1.21.6)
Requirement already satisfied: pandas>=1.1 in /usr/local/lib/python3.7/dist-packages (from xarray==0.21.0) (1.3.5)
ERROR: Package 'xarray' requires a different Python: 3.7.13 not in '>=3.8'

I looked into this to open a PR and fix it, but I didn’t check the reference correctly. The quoted text is all wrong. It is Python 3.8 the oldest one that should be supported now and starting October new releases will support 3.9+ only. From the SPEC I linked:

From the looks of it, things will continue to work on colab, but it won’t be possible to use the latest versions for any of the scientific python/pydata packages.

1 Like

I have sent a PR to fix the docs though: Fix minimum required python and mention nep+spec by OriolAbril · Pull Request #2097 · arviz-devs/arviz · GitHub

1 Like