Python traitlets.config.Configurable() Examples

The following are 2 code examples of traitlets.config.Configurable(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module traitlets.config , or try the search function .
Example #1
Source File: test_config.py    From phy with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_load_config(config):

    assert load_config() is not None

    class MyConfigurable(Configurable):
        my_var = Float(0.0, config=True)

    assert MyConfigurable().my_var == 0.0

    c = load_config(config)
    assert c.MyConfigurable.my_var == 1.0

    # Create a new MyConfigurable instance.
    configurable = MyConfigurable()
    assert configurable.my_var == 0.0

    # Load the config object.
    configurable.update_config(c)
    assert configurable.my_var == 1.0 
Example #2
Source File: nbconvertapp.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _classes_default(self):
        classes = [NbConvertBase]
        for pkg in (exporters, preprocessors, writers, postprocessors):
            for name in dir(pkg):
                cls = getattr(pkg, name)
                if isinstance(cls, type) and issubclass(cls, Configurable):
                    classes.append(cls)
        
        return classes