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

Create All Default Values With Generators #332

Merged
merged 1 commit into from
Nov 1, 2016

Conversation

rmorshea
Copy link
Contributor

@rmorshea rmorshea commented Oct 21, 2016

Closes #256

note: all default values (including those defined in trait constructors) are now cross validated

class MyInt(Int):
    def make_dynamic_default(self):
        if self.default_value != 0:
            return self.default_value
        else:
            return 10

class A(HasTraits):
    i = MyInt()

class B(A):
    i = MyInt(20)

class C(B):
    @default('i')
    def _i_default(self):
        return 30

grandparent = super(B, C)
parent = super(C, C)
child = C

c = C()

print(
    grandparent._trait_default_generators['i'](c),
    parent._trait_default_generators['i'](c),
    child._trait_default_generators['i'](c)
)
10, 20, 30

@rmorshea rmorshea force-pushed the refactor_defaults branch 4 times, most recently from e6f8390 to 9e8419c Compare October 21, 2016 07:43
@rmorshea rmorshea changed the title [WIP] Refactor Defaults Create All Default Values With Generators Oct 21, 2016
@minrk minrk merged commit 5a49dda into ipython:master Nov 1, 2016
@minrk minrk added this to the 5.0 milestone Nov 1, 2016
rmorshea added a commit to rmorshea/notebook that referenced this pull request Nov 2, 2016
takluyver added a commit to jupyter/notebook that referenced this pull request Nov 2, 2016
@rmorshea
Copy link
Contributor Author

rmorshea commented Nov 3, 2016

Default cross-validation exposes exploits in notebook via #342 as detailed in #315

@SylvainCorlay
Copy link
Member

SylvainCorlay commented Feb 14, 2017

@rmorshea this is the PR that breaks widgets (cf #363 ). Can you try instantiating e.g. an IntSlider ?

@SylvainCorlay
Copy link
Member

cc @minrk

@rmorshea rmorshea mentioned this pull request Jun 6, 2017
@minrk minrk mentioned this pull request Aug 8, 2017
@Carreau Carreau added 5.0-re-review Need to re-review for potential API impact changes. 5.0-major Major change in 5.0 need proper documentation labels Jun 4, 2020
@Carreau Carreau removed the 5.0-re-review Need to re-review for potential API impact changes. label Jun 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.0-major Major change in 5.0 need proper documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

how to extend dynamic defaults with super
4 participants