Skip to content

Remove auto_cast_uint, cast_unsigned, and modify fix_dtype#3982

Merged
alejoe91 merged 4 commits into
SpikeInterface:mainfrom
alejoe91:remove-cast-unsigned
Jun 12, 2025
Merged

Remove auto_cast_uint, cast_unsigned, and modify fix_dtype#3982
alejoe91 merged 4 commits into
SpikeInterface:mainfrom
alejoe91:remove-cast-unsigned

Conversation

@alejoe91
Copy link
Copy Markdown
Member

Fixes #1815

@alejoe91 alejoe91 requested a review from h-mayorquin June 11, 2025 14:20
@alejoe91 alejoe91 added core Changes to core module preprocessing Related to preprocessing module labels Jun 11, 2025
@alejoe91 alejoe91 added this to the 0.103.0 milestone Jun 11, 2025
Copy link
Copy Markdown
Collaborator

@h-mayorquin h-mayorquin left a comment

Choose a reason for hiding this comment

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

I strongly agree with this but shouldn't we do some type of deprecation first? so we don't break the code of people who use positional arguments.

@alejoe91
Copy link
Copy Markdown
Member Author

It was already deprecated. And since next release it's going to be minor I think it's ok to introduce a minor API change. Honwstly I don't think anyone is using cast_unsigned and autocast_unsigned_to_signed

@samuelgarcia
Copy link
Copy Markdown
Member

We should have a clear doc on this.

if auto_cast_uint:
cast_unsigned = determine_cast_unsigned(recording, dtype)
warning_message = (
"auto_cast_uint is deprecated and will be removed in 0.103. Use the `unsigned_to_signed` function instead."
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems like a clear enough deprecation to me :)

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.

I meant in get_traces.

Copy link
Copy Markdown
Member

@zm711 zm711 left a comment

Choose a reason for hiding this comment

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

The one thing I

# if uint --> force int
if dtype.kind == "u":
dtype = np.dtype(dtype.str.replace("u", "i"))
raise ValueError(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would consider making this just a little clearer. I think users would want to know why they aren't supported. So I would recommend adding an additional sentence that says:

"unsigned types are not supported due to **"

I'm just trying to think about what to say? inconsistent behavior in the library? Or to flip it and say that ints and floats perform better.

The issue we are referencing has someone who is saying "I want to use unsigned" so I think we should at least say even in short form why they should not. I agree that maybe some sort of documentation we can point to that explains this or GitHub issue referenced would at least let the users know the real reason why they can't. Especially since this is a change in behavior.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure. We can say that scopy functions don't work well with unsigned ;)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@zm711 better?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Missed this but yeah that looks good to me :)

@h-mayorquin
Copy link
Copy Markdown
Collaborator

It was already deprecated. And since next release it's going to be minor I think it's ok to introduce a minor API change. Honwstly I don't think anyone is using cast_unsigned and autocast_unsigned_to_signed

This makes sense. Then by all means, I have been wishing to get rid of this for a while : )

Copy link
Copy Markdown
Collaborator

@h-mayorquin h-mayorquin left a comment

Choose a reason for hiding this comment

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

Great!

@alejoe91 alejoe91 merged commit fcf2284 into SpikeInterface:main Jun 12, 2025
15 checks passed
@alejoe91 alejoe91 deleted the remove-cast-unsigned branch March 20, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes to core module preprocessing Related to preprocessing module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate cast_unsigned as an argument of core functions?

4 participants