FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[ENH]: Which array libraries should Matplotlib support (and test support for)? · Issue #22645 · matplotlib/matplotlib · GitHub

Repository navigation

[ENH]: Which array libraries should Matplotlib support (and test support for)? #22645

Open

Description

Problem

Related to e.g. #16402 #21036 #22560

We currently explicitly support numpy and pandas. What other array libraries are of interest to support natively (as in users can just feed an array and Matplotlib handles the conversion)? Should we test for them? (There seems to be a decision that only pandas will be tested for: #19574 (comment) )

Some alternatives:

Proposed solution

I think it can make sense to have a test that tests with "all" dependencies. It may not have to be executed on all platforms and all Python versions, but it will at least give some idea if things still work and when they break.

That is maybe not the same thing that we guarantee that these will always work.

cupy relies on GPUs so it is not clear if it is possible to test that.

We should also probably add something to the documentation about which are supported (and not). (Maybe there is, primarily looked at the code...)

Activity

  1. story645 commented on Mar 14, 2022

    Member

    I think natively anything that supports .to_numpy() & agree it might be worth adding xarray to the tests

    Broadly this intersects w/ my dissertation work & the NASA RSE work, but basically as far as I can tell the idea is if we can revamp the API enough to decouple the data bits from the artist/drawing bits, then external packages can write adapters against a data interface API. This allows external libraries to define what support means on their terms.

  2. QuLogic commented on Mar 15, 2022

    Member

    Is there not a NumPy standard compatibility NEP we can say we follow?

  3. story645 commented on Mar 15, 2022

    Member
  4. timhoffm commented on Mar 18, 2022

    Member

    For completeness, we should add h5py datasets to the above list.

    Their way of converting to numpy is dataset[()] (and deprecated: dataset.value), none of which we currently use AFAIK. Still, h5py datasets work because their API is enough numpy-like 😲 .

  5. tacaswell commented on Mar 18, 2022

    Member

    with h5py dataset slicing we have a bunch of tests which are "do h5py and numpy slice exactly the same" so it is very very close to numpy.

  6. timhoffm commented on Mar 18, 2022

    Member

    Good to know. OTOH I don’t think we’re slicing in Matplotlib, so I assume we‘re relying on other numpy-like aspects.

  7. sa- commented on Mar 20, 2022

    polars

    Maybe pyarrow (instead of polars specifically), then it would make matplotlib easier to use for anyone in the Arrow ecosystem, even from other languages that are doing interop with python

  8. oscargus commented on Mar 20, 2022

    MemberAuthor

    I didn't really get the relation between pyarrow and polars (just did a quick search), but it seems like both support to_numpy. With #22560 this is more consistently used and should improve things.

    Can make sense to add a test for both though and I added it to the list (as well as h5py).

  9. jklymak commented on Mar 21, 2022

    Member

    I guess I view this as the other way around - we are not guaranteeing compatibility with anything except numpy. However, as a courtesy, we will take results of your to_numpy and try and do the right thing with it. If you don't provide to_numpy or their to_numpy is broken, that is the other library's bug. Pandas falls into a grey area where we have tried to bend over backwards for them because it is so well-used, but that has entailed a moderately large maintenance burden. I don't think we want to add to it by testing the to_numpy implementations of more libraries?

  10. sa- commented on Mar 21, 2022

    the relation between pyarrow and polars

    Good question - apache arrow is a memory model, so it just tells you what the data should look like in memory but it doesn't provide any functions to manipulate the data. Polars uses apache arrow as its memory model and provides methods to transform data.

    One of the motivations for using Arrow is passing data around in a zero-copy way between libraries or even between languages. For example calling polars_df.to_arrow() will not create a copy of the data, instead it will return an object of type pyarrow.Table that points to the same data in memory.

    Hope this helps and thank you for considering to support these libs.

  11. oscargus commented on Mar 21, 2022

    MemberAuthor

    The conclusion we came to was to add tests for "all" libraries, but only install them in the weekly event testing the newest version of numpy etc. (And not claim compatibility beyond that "if it has a to_numpy you are quite likely to be able to plot something, if not run the right function yourself".)

    - name: Install the nightly dependencies
    # Only install the nightly dependencies during the scheduled event
    if: ${{ github.event_name == 'schedule' && matrix.name-suffix != '(Minimum Versions)' }}
    run: |
    python -m pip install -i https://pypi.anaconda.org/scipy-wheels-nightly/simple --upgrade numpy pandas
    # Turn all warnings to errors, except ignore the distutils deprecations and the find_spec warning
    cat >> pytest.ini << EOF
    filterwarnings =
    error
    ignore:.*distutils:DeprecationWarning
    ignore:DynamicImporter.find_spec\(\) not found; falling back to find_module\(\):ImportWarning
    EOF

    In this way, we can get a heads up in case something breaks.

  12. tacaswell commented on Mar 22, 2022

    Member

    We probably should put some floor on usage (polar has like 4k downloads from pypi a day, pandas has 2-3M, xarray hase 20-40k, and we have 500k-1M) before we worry about testing it.

  13. timhoffm commented on Feb 12, 2025

    Member

    Compatibility in the ecosystem has evolved. IMHO we should try to accept everything that follows the array API standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL