Skip to content

[BUG]: create_violin() failure with numpy==2.4.0: TypeError: percentile() got an unexpected keyword argument 'interpolation' #5461

Closed

Description

@mgorny

Description

The TestViolin.test_violin_fig reveals that the create_violin() function is failing against numpy==2.4.0. It passes after downgrading to <2.4.0.

========================================================= test session starts =========================================================
platform linux -- Python 3.12.12, pytest-9.0.2, pluggy-1.6.0
rootdir: /tmp/plotly.py
configfile: pyproject.toml
plugins: anyio-4.12.1, typeguard-4.4.4, timeout-2.4.0
collected 1 item                                                                                                                      

tests/test_optional/test_figure_factory/test_figure_factory.py F                                                                [100%]

============================================================== FAILURES ===============================================================
_____________________________________________________ TestViolin.test_violin_fig ______________________________________________________

self = <tests.test_optional.test_figure_factory.test_figure_factory.TestViolin testMethod=test_violin_fig>

    def test_violin_fig(self):
        # check: test violin fig matches expected fig
    
>       test_violin = ff.create_violin(data=[1, 2])
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/test_optional/test_figure_factory/test_figure_factory.py:2313: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
plotly/figure_factory/_violin.py:603: in create_violin
    plot_data, plot_xrange = violinplot(
plotly/figure_factory/_violin.py:163: in violinplot
    vals_min = calc_stats(vals)["min"]
               ^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

data = array([1., 2.])

    def calc_stats(data):
        """
        Calculate statistics for use in violin plot.
        """
        x = np.asarray(data, float)
        vals_min = np.min(x)
        vals_max = np.max(x)
>       q2 = np.percentile(x, 50, interpolation="linear")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E       TypeError: percentile() got an unexpected keyword argument 'interpolation'

plotly/figure_factory/_violin.py:20: TypeError
======================================================= short test summary info =======================================================
FAILED tests/test_optional/test_figure_factory/test_figure_factory.py::TestViolin::test_violin_fig - TypeError: percentile() got an unexpected keyword argument 'interpolation'
========================================================== 1 failed in 2.99s ==========================================================

Steps to reproduce

uv venv -p 3.12
uv pip install -e .[dev]
.venv/bin/pytest tests/test_optional/test_figure_factory/test_figure_factory.py::TestViolin::test_violin_fig

Activity

  1. changed the title [-][BUG]: `create_violin()` failure with `numpy==2.24.0`[/-] [+][BUG]: `create_violin()` failure with `numpy==2.24.0`: `TypeError: percentile() got an unexpected keyword argument 'interpolation'`[/+] on Jan 8, 2026
  2. robertclaus commented on Jan 14, 2026

    @robertclaus

    @mgorny thank you for calling this out. Is this currently blocking you?

    We absolutely welcome pull requests for issues like this!

  3. changed the title [-][BUG]: `create_violin()` failure with `numpy==2.24.0`: `TypeError: percentile() got an unexpected keyword argument 'interpolation'`[/-] [+][BUG]: `create_violin()` failure with `numpy==2.4.0`: `TypeError: percentile() got an unexpected keyword argument 'interpolation'`[/+] on Jan 14, 2026
  4. mgorny commented on Jan 14, 2026

    @mgorny
    ContributorAuthor

    Not really, I've just skipped the failing tests in Gentoo for now.

  5. AJSTYLE-lab commented on Jan 15, 2026

    @AJSTYLE-lab

    Hi 👋
    I’m interested in working on this issue and would be happy to submit a fix for the numpy==2.4.0 incompatibility in create_violin().

    If no one is currently working on it, I’ll start investigating and open a PR soon. Please let me know if there are any preferences or related context I should be aware of before proceeding.

    Thanks!

  6. AJSTYLE-lab commented on Jan 15, 2026

    @AJSTYLE-lab

    I found this issue interesting so I have started working on it.

  7. added a commit that references this issue on Feb 14, 2026
    21c28da
  8. added 2 commits that reference this issue on Mar 13, 2026
    132a7e8
    2d122fd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething broken

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions