Repository navigation
Accept NumPy scalars in integer and string properties - #5828
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
RaphaelFakhri
force-pushed
the
fix-numpy-scalar-validators
branch
from
October 19, 2026 07:46
1a6e654 to
ee5cb34
Compare
Contributor
|
Thanks for the update. I'll review and follow up. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue
Closes #5827
Description of change
Integer properties now accept NumPy integer scalars, and non-strict string properties now accept any number, including NumPy scalars.
IntegerValidatorchecksnumbers.Integralinstead ofint, andStringValidatorchecksnumbers.Numberinstead of(int, float), which matches howNumberValidatoralready validates numbers.Demo
Before:
ValueError: Invalid value of type 'numpy.int64' received for the 'name' property of scatterAfter:
['2020', '2021'] 5. The figure serializes the same with thejsonandorjsonengines ("name":"2020","nticks":5).Testing strategy
The existing integer and string validator tests now include NumPy scalars: scalar acceptance, acceptance within min/max bounds, rejection outside min/max bounds, a list of NumPy integers for
array_okproperties, and NumPy integer andfloat32conversion to strings. Out-of-range NumPy integers are still rejected.Additional information (optional)
Strings, booleans,
NaNand infinite values are validated as before:numbers.Integralexcludes floats, and the string check still runs before the number check.Guidelines