Skip to content

Fix catmull curve call crashing with numpy>=2.4.0 - #125

Merged
Liam-DeVoe merged 2 commits into
llllllllll:masterfrom
Stedoss:fix-catmull-numpy
Jan 31, 2026
Merged

Liam-DeVoe merged 2 commits into
llllllllll:masterfrom
Stedoss:fix-catmull-numpy

Conversation

@Stedoss

@Stedoss Stedoss commented Jan 23, 2026

Copy link
Copy Markdown
Contributor

As discussed on discord. I don't think this causes any behaviour changes, but my knowledge of numpy floats -> python primative floats isn't really great - we can add the cast back if required.

Example map: https://osu.ppy.sh/beatmapsets/17148#osu/65670

With:

=> pip list | rg numpy
numpy              2.4.1

Before:

Python 3.13.3 (tags/v3.13.3:6280bb5, Apr  8 2025, 14:47:33) [MSC v.1943 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from slider import Beatmap
>>> bm = Beatmap.from_path("path/to/the/osu/file/xxdbxx - Cherokee (xierbaliti) [MX]\.osu")
>>> bm.hit_objects()
Traceback (most recent call last):
  File "<python-input-3>", line 1, in <module>
    bm.hit_objects()
    ~~~~~~~~~~~~~~^^
  File "C:\Users\Stedos\Development\osu\slider\slider\beatmap.py", line 2049, in hit_objects
    hit_objects = resolve_stacking_method(hit_objects, ar, cs)
  File "C:\Users\Stedos\Development\osu\slider\slider\beatmap.py", line 2116, in _resolve_stacking
    and distance(ob_n.curve(1), ob_i.position) < stack_dist
                 ~~~~~~~~~~^^^
  File "C:\Users\Stedos\Development\osu\slider\slider\curve.py", line 445, in __call__
    px = float(px)
TypeError: only 0-dimensional arrays can be converted to Python scalars

After:

Python 3.13.3 (tags/v3.13.3:6280bb5, Apr  8 2025, 14:47:33) [MSC v.1943 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from slider import Beatmap
>>> bm = Beatmap.from_path("path/to/the/osu/file/xxdbxx - Cherokee (xierbaliti) [MX]\.osu")
>>> bm.hit_objects()
(<Slider: Position(x=432.0, y=192.0), 257ms>, ...)

Comment thread slider/curve.py Outdated
Comment on lines +445 to +446
px = px[0]
py = py[0]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something to keep in mind is that this returns a numpy float instead of a python float. Not sure if this has an impact, just wanted to mention it.
afaik .item() returns a regular float type

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes this would be a breaking change, Position should hold normal floats

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Liam-DeVoe
Liam-DeVoe merged commit c179ec7 into llllllllll:master Jan 31, 2026
6 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