Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array should not force allow_None=True #583

Closed
jbednar opened this issue Dec 15, 2021 · 0 comments · Fixed by #726
Closed

Array should not force allow_None=True #583

jbednar opened this issue Dec 15, 2021 · 0 comments · Fixed by #726
Labels
type-bug Bug report
Milestone

Comments

@jbednar
Copy link
Member

jbednar commented Dec 15, 2021

As mentioned by @jlstevens in #582 , it's odd that an Array parameter forces allow_None to True:

class Array(ClassSelector):
    """
    Parameter whose value is a numpy array.
    """

    def __init__(self, default=None, **params):
        from numpy import ndarray
        super(Array, self).__init__(ndarray, allow_None=True, default=default, **params)

I'm guessing that the original reason for that was to make the code able to work when NumPy is not available, but because we always assume allow_None to be True if the default is None, here having a None default should be sufficient already, without forcing all Array instances to allow None. Fixing this will be a breaking change, since any user of Array that does want to allow None will now have to supply that flag explicitly, but it seems the right thing to do.

@jbednar jbednar added type-bug Bug report TRIAGE User-submitted issue that hasn't been triaged yet. labels Dec 15, 2021
@MridulS MridulS added this to the 2.0 milestone Feb 7, 2022
@maximlt maximlt removed the TRIAGE User-submitted issue that hasn't been triaged yet. label Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants