Пример #1
0
def test_2_components_uses():
    palette = Palette(one=Sample1, two=Sample2)

    uses = palette.uses()
    uses.sort()
    assert_list_equal(
        ['air__temperature', 'deposition__rate', 'surface__elevation'], uses)
Пример #2
0
def test_2_components_provides():
    palette = Palette(one=Sample1, two=Sample2)

    provides = palette.provides()
    provides.sort()
    assert ["air__temperature", "deposition__rate",
            "surface__elevation"] == provides
Пример #3
0
    def test_find_providers(self):
        palette = Palette(sample=Sample1)

        providers = palette.find_provider('air__temperature')
        self.assertEqual(providers, [])

        providers = palette.find_provider('deposition__rate')
        self.assertEqual(providers, ['sample'])
Пример #4
0
def test_1_component_find_providers():
    palette = Palette(sample=Sample1)

    providers = palette.find_provider("air__temperature")
    assert providers == []

    providers = palette.find_provider("deposition__rate")
    assert providers == ["sample"]
Пример #5
0
def test_1_component_find_providers():
    palette = Palette(sample=Sample1)

    providers = palette.find_provider('air__temperature')
    assert_equal(providers, [])

    providers = palette.find_provider('deposition__rate')
    assert_equal(providers, ['sample'])
Пример #6
0
def test_2_components_find_connections():
    palette = Palette(one=Sample1, two=Sample2)

    connections = {
        "one": {"deposition__rate": ["two"]},
        "two": {"air__temperature": ["one"], "surface__elevation": ["one"]},
    }
    assert connections == palette.find_connections()
Пример #7
0
def test_2_components_find_providers():
    palette = Palette(one=Sample1, two=Sample2)

    providers = palette.find_provider('air__temperature')
    assert_list_equal(['two'], providers)

    providers = palette.find_provider('deposition__rate')
    assert_equal(['one'], providers)
Пример #8
0
def test_2_components_provides():
    palette = Palette(one=Sample1, two=Sample2)

    provides = palette.provides()
    provides.sort()
    assert_list_equal(['air__temperature',
                       'deposition__rate',
                       'surface__elevation'], provides)
Пример #9
0
    def test_provides(self):
        palette = Palette(one=Sample1, two=Sample2)

        provides = palette.provides()
        provides.sort()
        self.assertListEqual(
            ['air__temperature', 'deposition__rate', 'surface__elevation'],
            provides)
Пример #10
0
    def test_find_providers(self):
        palette = Palette(sample=Sample1)

        providers = palette.find_provider('air__temperature')
        self.assertEqual(providers, [])

        providers = palette.find_provider('deposition__rate')
        self.assertEqual(providers, ['sample'])
Пример #11
0
    def test_provides(self):
        palette = Palette(one=Sample1, two=Sample2)

        provides = palette.provides()
        provides.sort()
        self.assertListEqual(['air__temperature',
                              'deposition__rate',
                              'surface__elevation'], provides)
Пример #12
0
    def test_find_providers(self):
        palette = Palette(one=Sample1, two=Sample2)

        providers = palette.find_provider('air__temperature')
        self.assertListEqual(['two'], providers)

        providers = palette.find_provider('deposition__rate')
        self.assertEqual(['one'], providers)
Пример #13
0
    def test_find_providers(self):
        palette = Palette(one=Sample1, two=Sample2)

        providers = palette.find_provider('air__temperature')
        self.assertListEqual(['two'], providers)

        providers = palette.find_provider('deposition__rate')
        self.assertEqual(['one'], providers)
Пример #14
0
def test_2_components_find_providers():
    palette = Palette(one=Sample1, two=Sample2)

    providers = palette.find_provider("air__temperature")
    assert ["two"] == providers

    providers = palette.find_provider("deposition__rate")
    assert ["one"] == providers
Пример #15
0
def test_2_components_find_providers():
    palette = Palette(one=Sample1, two=Sample2)

    providers = palette.find_provider("air__temperature")
    assert ["two"] == providers

    providers = palette.find_provider("deposition__rate")
    assert ["one"] == providers
Пример #16
0
def test_1_component_find_providers():
    palette = Palette(sample=Sample1)

    providers = palette.find_provider("air__temperature")
    assert providers == []

    providers = palette.find_provider("deposition__rate")
    assert providers == ["sample"]
Пример #17
0
    def test_find_connections(self):
        palette = Palette(one=Sample1, two=Sample2)

        connections = {
            'one': {'deposition__rate': ['two']},
            'two': {'air__temperature': ['one'],
                    'surface__elevation': ['one']},
        }
        self.assertDictEqual(connections, palette.find_connections())
Пример #18
0
def test_2_components_find_connections():
    palette = Palette(one=Sample1, two=Sample2)

    connections = {
        'one': {'deposition__rate': ['two']},
        'two': {'air__temperature': ['one'],
                'surface__elevation': ['one']},
    }
    assert_dict_equal(connections, palette.find_connections())
Пример #19
0
def test_1_component_dict_interface():
    palette = Palette(sample=Sample1)

    assert dict(sample=Sample1) == palette
    assert len(palette) == 1
    assert list(palette.keys()) == ["sample"]
    assert list(palette.values()) == [Sample1]

    items = list(palette.items())
    assert ("sample", Sample1) == items[0]
Пример #20
0
    def test_dict_interface(self):
        palette = Palette(sample=Sample1)

        self.assertDictEqual(dict(sample=Sample1), palette)
        self.assertEqual(len(palette), 1)
        self.assertEqual(palette.keys(), ['sample'])
        self.assertEqual(palette.values(), [Sample1])

        items = palette.items()
        self.assertTupleEqual(('sample', Sample1), items[0])
Пример #21
0
def test_1_component_dict_interface():
    palette = Palette(sample=Sample1)

    assert_dict_equal(dict(sample=Sample1), palette)
    assert_equal(len(palette), 1)
    assert_equal(palette.keys(), ['sample'])
    assert_equal(palette.values(), [Sample1])

    items = palette.items()
    assert_tuple_equal(('sample', Sample1), items[0])
Пример #22
0
def test_1_component_dict_interface():
    palette = Palette(sample=Sample1)

    assert dict(sample=Sample1) == palette
    assert len(palette) == 1
    assert list(palette.keys()) == ["sample"]
    assert list(palette.values()) == [Sample1]

    items = list(palette.items())
    assert ("sample", Sample1) == items[0]
Пример #23
0
    def test_dict_interface(self):
        palette = Palette(sample=Sample1)

        self.assertDictEqual(dict(sample=Sample1), palette)
        self.assertEqual(len(palette), 1)
        self.assertEqual(palette.keys(), ['sample'])
        self.assertEqual(palette.values(), [Sample1])

        items = palette.items()
        self.assertTupleEqual(('sample', Sample1), items[0])
Пример #24
0
    def test_find_connections(self):
        palette = Palette(one=Sample1, two=Sample2)

        connections = {
            'one': {
                'deposition__rate': ['two']
            },
            'two': {
                'air__temperature': ['one'],
                'surface__elevation': ['one']
            },
        }
        self.assertDictEqual(connections, palette.find_connections())
Пример #25
0
def test_2_components_find_connections():
    palette = Palette(one=Sample1, two=Sample2)

    connections = {
        "one": {
            "deposition__rate": ["two"]
        },
        "two": {
            "air__temperature": ["one"],
            "surface__elevation": ["one"]
        },
    }
    assert connections == palette.find_connections()
Пример #26
0
def test_2_components_dict_interface():
    palette = Palette(one=Sample1, two=Sample2)

    assert_dict_equal(dict(one=Sample1, two=Sample2), palette)
    assert_equal(len(palette), 2)

    keys = palette.keys()
    keys.sort()
    assert_list_equal(['one', 'two'], keys)

    values = palette.values()
    assert_equal(2, len(values))
    assert_true(Sample1 in values and Sample2 in values)

    items = palette.items()
    items.sort()
    assert_equal(2, len(items))
    assert_tuple_equal(('one', Sample1), items[0])
    assert_tuple_equal(('two', Sample2), items[1])
Пример #27
0
def test_2_components_dict_interface():
    palette = Palette(one=Sample1, two=Sample2)

    assert dict(one=Sample1, two=Sample2) == palette
    assert len(palette) == 2

    keys = list(palette.keys())
    keys.sort()
    assert ["one", "two"] == keys

    values = palette.values()
    assert 2 == len(values)
    assert Sample1 in values and Sample2 in values

    items = list(palette.items())
    items.sort()
    assert 2 == len(items)
    assert ("one", Sample1) == items[0]
    assert ("two", Sample2) == items[1]
Пример #28
0
def test_2_components_dict_interface():
    palette = Palette(one=Sample1, two=Sample2)

    assert dict(one=Sample1, two=Sample2) == palette
    assert len(palette) == 2

    keys = list(palette.keys())
    keys.sort()
    assert ["one", "two"] == keys

    values = palette.values()
    assert 2 == len(values)
    assert Sample1 in values and Sample2 in values

    items = list(palette.items())
    items.sort()
    assert 2 == len(items)
    assert ("one", Sample1) == items[0]
    assert ("two", Sample2) == items[1]
Пример #29
0
    def test_dict_interface(self):
        palette = Palette(one=Sample1, two=Sample2)

        self.assertDictEqual(dict(one=Sample1, two=Sample2), palette)
        self.assertEqual(len(palette), 2)

        keys = palette.keys()
        keys.sort()
        self.assertListEqual(['one', 'two'], keys)

        values = palette.values()
        self.assertEqual(2, len(values))
        self.assertTrue(Sample1 in values and Sample2 in values)

        items = palette.items()
        items.sort()
        self.assertEqual(2, len(items))
        self.assertTupleEqual(('one', Sample1), items[0])
        self.assertTupleEqual(('two', Sample2), items[1])
Пример #30
0
    def test_dict_interface(self):
        palette = Palette(one=Sample1, two=Sample2)

        self.assertDictEqual(dict(one=Sample1, two=Sample2), palette)
        self.assertEqual(len(palette), 2)

        keys = palette.keys()
        keys.sort()
        self.assertListEqual(['one', 'two'], keys)

        values = palette.values()
        self.assertEqual(2, len(values))
        self.assertTrue(Sample1 in values and Sample2 in values)

        items = palette.items()
        items.sort()
        self.assertEqual(2, len(items))
        self.assertTupleEqual(('one', Sample1), items[0])
        self.assertTupleEqual(('two', Sample2), items[1])
Пример #31
0
def test_empty_palette():
    """Create a palette without components."""
    palette = Palette()

    assert len(palette) == 0
    assert list(palette.list()) == []
    assert list(palette.keys()) == []
    assert palette.uses() == []
    assert palette.provides() == []

    providers = palette.find_provider("air__temperature")
    assert providers == []

    users = palette.find_user("air__temperature")
    assert users == []

    connections = palette.find_connections()
    assert connections == {}
Пример #32
0
def test_empty_palette():
    """Create a palette without components."""
    palette = Palette()

    assert_equal(len(palette), 0)
    assert_equal(list(palette.list()), [])
    assert_equal(list(palette.keys()), [])
    assert_equal(palette.uses(), [])
    assert_equal(palette.provides(), [])

    providers = palette.find_provider('air__temperature')
    assert_equal(providers, [])

    users = palette.find_user('air__temperature')
    assert_equal(users, [])

    connections = palette.find_connections()
    assert_dict_equal(connections, {})
Пример #33
0
def test_empty_palette():
    """Create a palette without components."""
    palette = Palette()

    assert len(palette) == 0
    assert list(palette.list()) == []
    assert list(palette.keys()) == []
    assert palette.uses() == []
    assert palette.provides() == []

    providers = palette.find_provider("air__temperature")
    assert providers == []

    users = palette.find_user("air__temperature")
    assert users == []

    connections = palette.find_connections()
    assert connections == {}
Пример #34
0
    def test_provides(self):
        palette = Palette(sample=Sample1)

        provides = palette.provides()
        provides.sort()
        self.assertEqual(['deposition__rate'], provides)
Пример #35
0
    def test_uses(self):
        palette = Palette(sample=Sample1)

        uses = palette.uses()
        uses.sort()
        self.assertEqual(['air__temperature', 'surface__elevation'], uses)
Пример #36
0
    def test_list(self):
        palette = Palette(sample=Sample1)

        self.assertEqual(['sample'], palette.list())
Пример #37
0
    def test_uses(self):
        palette = Palette(sample=Sample1)

        uses = palette.uses()
        uses.sort()
        self.assertEqual(['air__temperature', 'surface__elevation'], uses)
Пример #38
0
    def test_create(self):
        palette = Palette(sample=Sample1)

        self.assertEqual(len(palette), 1)
Пример #39
0
    def test_find_connections(self):
        palette = Palette(sample=Sample1)

        with self.assertRaises(NoProvidersError):
            connections = palette.find_connections()
Пример #40
0
    def test_create(self):
        palette = Palette(one=Sample1, two=Sample2)

        self.assertEqual(len(palette), 2)
Пример #41
0
class Framework(object):
    """
    A framework for connecting and running component from The Landlab.
    """
    def __init__(self):
        self._palette = Palette(**load_landlab_components())
        self._arena = Arena()

    def instantiate(self, name):
        """
        Instantiate a component called *name* from the palette and move it to
        the arena.
        """
        try:
            self._arena.instantiate(self._palette.get(name), name)
        except KeyError:
            pass

    def remove(self, name):
        """
        Remove a component called *name* from the arena.
        """
        try:
            self._arena.remove(name)
        except KeyError:
            pass

    def list_palette(self):
        """
        Get a list of names of the components in the palette.
        """
        return self._palette.list()

    def list_arena(self):
        """
        Get a list of names of the components in the arena.
        """
        return self._arena.list()

    def arena_uses(self):
        """
        Get a list of variable names that components in the arena use.
        """
        return self._arena.uses()

    def arena_provides(self):
        """
        Get a list of variable names that components in the arena provide.
        """
        return self._arena.provides()

    def palette_uses(self):
        """
        Get a list of variable names that components in the palette use.
        """
        return self._palette.uses()

    def palette_provides(self):
        """
        Get a list of variable names that components in the palette provide.
        """
        return self._palette.provides()

    def __repr__(self):
        return 'Framework(%s)' % ', '.join(self._palette.keys())
Пример #42
0
    def test_provides(self):
        palette = Palette(sample=Sample1)

        provides = palette.provides()
        provides.sort()
        self.assertEqual(['deposition__rate'], provides)
Пример #43
0
    def test_find_users(self):
        palette = Palette(sample=Sample1)

        users = palette.find_user('air__temperature')
        self.assertEqual(users, ['sample'])
Пример #44
0
def test_1_component_find_users():
    palette = Palette(sample=Sample1)

    users = palette.find_user('air__temperature')
    assert_equal(users, ['sample'])
Пример #45
0
    def test_find_users(self):
        palette = Palette(sample=Sample1)

        users = palette.find_user('air__temperature')
        self.assertEqual(users, ['sample'])
Пример #46
0
def test_1_component_provides():
    palette = Palette(sample=Sample1)

    provides = palette.provides()
    provides.sort()
    assert_equal(['deposition__rate'], provides)
Пример #47
0
def test_1_component_uses():
    palette = Palette(sample=Sample1)

    uses = palette.uses()
    uses.sort()
    assert_equal(['air__temperature', 'surface__elevation'], uses)
Пример #48
0
def test_1_component_list():
    palette = Palette(sample=Sample1)

    assert_equal(['sample'], palette.list())
Пример #49
0
    def test_find_connections(self):
        palette = Palette(sample=Sample1)

        with self.assertRaises(NoProvidersError):
            connections = palette.find_connections()
Пример #50
0
    def test_find_users(self):
        palette = Palette(one=Sample1, two=Sample2)

        users = palette.find_user('air__temperature')
        self.assertListEqual(['one'], users)
Пример #51
0
    def test_list(self):
        palette = Palette(sample=Sample1)

        self.assertEqual(['sample'], palette.list())
Пример #52
0
def test_2_components_find_users():
    palette = Palette(one=Sample1, two=Sample2)

    users = palette.find_user('air__temperature')
    assert_list_equal(['one'], users)
Пример #53
0
 def __init__(self):
     self._palette = Palette(**load_landlab_components())
     self._arena = Arena()
Пример #54
0
def test_2_components_list():
    palette = Palette(one=Sample1, two=Sample2)

    list = palette.list()
    list.sort()
    assert_list_equal(['one', 'two'], list)