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

Nullable traits and default value (WIP) #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bluescarni
Copy link
Contributor

A small extension that enables numtraits to be nullable (i.e., None can be assigned to a trait) and to be constructed with a default value.

if (default is None and nullable) or default is not None:
super(NumericalTrait, self).__init__(default_value=default)
else:
super(NumericalTrait, self).__init__()
Copy link
Owner

Choose a reason for hiding this comment

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

What does the default_value argument default to? Can you have just one super call and adapt the value of default appropriately?

@SylvainCorlay
Copy link

The base trait_type has a allow_none property, which should already do what you are trying to do.

@bluescarni
Copy link
Contributor Author

@SylvainCorlay right, I was not sure it was part of the public API. I am reimplementing the functionality to take advantage of that.

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