Skip to content

use numpy.isin for compat with v1/2#225

Merged
tshead2 merged 1 commit intosandialabs:mainfrom
eaton-lab:numpy2-isin
Mar 13, 2026
Merged

use numpy.isin for compat with v1/2#225
tshead2 merged 1 commit intosandialabs:mainfrom
eaton-lab:numpy2-isin

Conversation

@eaton-lab
Copy link
Contributor

@eaton-lab eaton-lab commented Feb 28, 2026

Fix NumPy 2 compatibility in graph shared-layout path (replace numpy.in1d with numpy.isin)

This is the behave test failure message:

    Scenario: Render subgraph with shared layout                                   # features/graph-
  visualization.feature:41
      Given a graph and a subgraph                                                 # features/steps/graph-
  visualization.py:91
      Then the subgraph can be rendered with the graph layout                      # features/steps/graph-
  visualization.py:97
        Traceback (most recent call last):
          File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/behave/model.py", line
  1991, in run
            match.run(runner.context)
          File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/behave/matchers.py",
  line 105, in run
            self.func(context, *args, **kwargs)
          File "features/steps/graph-visualization.py", line 112, in step_impl
            mark = axes.graph(
                   ^^^^^^^^^^^
          File "/home/runner/work/toyplot/toyplot/toyplot/coordinates.py", line 1834, in graph
            layout = toyplot.layout.graph(a, b, c, olayout=olayout, layout=layout, vcoordinates=vcoordinates)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "/home/runner/work/toyplot/toyplot/toyplot/layout.py", line 289, in graph
            oindices = numpy.in1d(olayout.vids, vids, assume_unique=True)
                       ^^^^^^^^^^
          File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/numpy/__init__.py", line
  792, in __getattr__
            raise AttributeError(f"module {__name__!r} has no attribute {attr!r}")
        AttributeError: module 'numpy' has no attribute 'in1d'

      And the figure should match the graph-shared-layout-subgraph reference image # None

    Scenario: Render graph with shared layout                                   # features/graph-
  visualization.feature:46
      Given a graph and a subgraph                                              # features/steps/graph-
  visualization.py:91
      Then the graph can be rendered with the subgraph layout                   # features/steps/graph-
  visualization.py:122
        Traceback (most recent call last):
          File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/behave/model.py", line
  1991, in run
            match.run(runner.context)
          File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/behave/matchers.py",
  line 105, in run
            self.func(context, *args, **kwargs)
          File "features/steps/graph-visualization.py", line 137, in step_impl
            mark = axes.graph(
                   ^^^^^^^^^^^
          File "/home/runner/work/toyplot/toyplot/toyplot/coordinates.py", line 1834, in graph
            layout = toyplot.layout.graph(a, b, c, olayout=olayout, layout=layout, vcoordinates=vcoordinates)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "/home/runner/work/toyplot/toyplot/toyplot/layout.py", line 289, in graph
            oindices = numpy.in1d(olayout.vids, vids, assume_unique=True)
                       ^^^^^^^^^^
          File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/numpy/__init__.py", line
  792, in __getattr__
            raise AttributeError(f"module {__name__!r} has no attribute {attr!r}")
        AttributeError: module 'numpy' has no attribute 'in1d'

      And the figure should match the graph-shared-layout-graph reference image # None

@coveralls
Copy link

Coverage Status

coverage: 94.119%. remained the same
when pulling 17154bc on eaton-lab:numpy2-isin
into f71796a on sandialabs:main.

1 similar comment
@coveralls
Copy link

Coverage Status

coverage: 94.119%. remained the same
when pulling 17154bc on eaton-lab:numpy2-isin
into f71796a on sandialabs:main.

@tshead2 tshead2 merged commit 9e003be into sandialabs:main Mar 13, 2026
9 of 10 checks passed
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 this pull request may close these issues.

3 participants