def test_walk(self):
        arena = Arena()
        arena.instantiate(Sample1, 'one')
        arena.instantiate(Sample2, 'two')

        arena.connect('one', 'two', 'air__temperature')
        arena.connect('one', 'two', 'surface__elevation')
        arena.connect('two', 'one', 'deposition__rate')

        tree = arena.walk('one')
        self.assertListEqual(['one', 'two'], tree)
示例#2
0
def test_arena_walk():
    arena = Arena()
    arena.instantiate(Sample1, "one")
    arena.instantiate(Sample2, "two")

    arena.connect("one", "two", "air__temperature")
    arena.connect("one", "two", "surface__elevation")
    arena.connect("two", "one", "deposition__rate")

    tree = arena.walk("one")
    assert ["one", "two"] == tree
示例#3
0
def test_arena_walk():
    arena = Arena()
    arena.instantiate(Sample1, 'one')
    arena.instantiate(Sample2, 'two')

    arena.connect('one', 'two', 'air__temperature')
    arena.connect('one', 'two', 'surface__elevation')
    arena.connect('two', 'one', 'deposition__rate')

    tree = arena.walk('one')
    assert_list_equal(['one', 'two'], tree)
示例#4
0
def test_arena_walk():
    arena = Arena()
    arena.instantiate(Sample1, "one")
    arena.instantiate(Sample2, "two")

    arena.connect("one", "two", "air__temperature")
    arena.connect("one", "two", "surface__elevation")
    arena.connect("two", "one", "deposition__rate")

    tree = arena.walk("one")
    assert ["one", "two"] == tree
    def test_connect(self):
        arena = Arena()
        arena.instantiate(Sample1, 'one')
        arena.instantiate(Sample2, 'two')

        arena.connect('one', 'two', 'air__temperature')
        arena.connect('one', 'two', 'surface__elevation')
        arena.connect('two', 'one', 'deposition__rate')

        dz = arena['one'].get_value('deposition__rate')
        t = arena['two'].get_value('air__temperature')
        z = arena['two'].get_value('surface__elevation')
示例#6
0
def test_arena_connect():
    arena = Arena()
    arena.instantiate(Sample1, 'one')
    arena.instantiate(Sample2, 'two')

    arena.connect('one', 'two', 'air__temperature')
    arena.connect('one', 'two', 'surface__elevation')
    arena.connect('two', 'one', 'deposition__rate')

    dz = arena['one'].get_value('deposition__rate')
    t = arena['two'].get_value('air__temperature')
    z = arena['two'].get_value('surface__elevation')
示例#7
0
def test_arena_connect():
    arena = Arena()
    arena.instantiate(Sample1, "one")
    arena.instantiate(Sample2, "two")

    arena.connect("one", "two", "air__temperature")
    arena.connect("one", "two", "surface__elevation")
    arena.connect("two", "one", "deposition__rate")

    dz = arena["one"].get_value("deposition__rate")
    t = arena["two"].get_value("air__temperature")
    z = arena["two"].get_value("surface__elevation")
示例#8
0
def test_arena_connect():
    arena = Arena()
    arena.instantiate(Sample1, "one")
    arena.instantiate(Sample2, "two")

    arena.connect("one", "two", "air__temperature")
    arena.connect("one", "two", "surface__elevation")
    arena.connect("two", "one", "deposition__rate")

    arena["one"].get_value("deposition__rate")
    arena["two"].get_value("air__temperature")
    arena["two"].get_value("surface__elevation")
    def test_instantiate(self):
        arena = Arena()
        self.assertDictEqual(dict(), arena)

        arena.instantiate(Sample1, 'one')
        self.assertEqual(1, len(arena))
        self.assertTrue('one' in arena)
        self.assertTrue(isinstance(arena['one'], Sample1))

        arena.instantiate(Sample2, 'two')
        self.assertEqual(2, len(arena))
        self.assertTrue('one' in arena and 'two' in arena)
        self.assertTrue(isinstance(arena['one'], Sample1))
        self.assertTrue(isinstance(arena['two'], Sample2))
示例#10
0
def test_arena_instantiate():
    arena = Arena()
    assert_dict_equal(dict(), arena)

    arena.instantiate(Sample1, 'one')
    assert_equal(1, len(arena))
    assert_true('one' in arena)
    assert_true(isinstance(arena['one'], Sample1))

    arena.instantiate(Sample2, 'two')
    assert_equal(2, len(arena))
    assert_true('one' in arena and 'two' in arena)
    assert_true(isinstance(arena['one'], Sample1))
    assert_true(isinstance(arena['two'], Sample2))
示例#11
0
    def test_instantiate(self):
        arena = Arena()
        self.assertDictEqual(dict(), arena)

        arena.instantiate(Sample1, 'one')
        self.assertEqual(1, len(arena))
        self.assertTrue('one' in arena)
        self.assertTrue(isinstance(arena['one'], Sample1))

        arena.instantiate(Sample2, 'two')
        self.assertEqual(2, len(arena))
        self.assertTrue('one' in arena and 'two' in arena)
        self.assertTrue(isinstance(arena['one'], Sample1))
        self.assertTrue(isinstance(arena['two'], Sample2))
示例#12
0
def test_arena_instantiate():
    arena = Arena()
    assert dict() == arena

    arena.instantiate(Sample1, "one")
    assert 1 == len(arena)
    assert "one" in arena
    assert isinstance(arena["one"], Sample1)

    arena.instantiate(Sample2, "two")
    assert 2 == len(arena)
    assert "one" in arena and "two" in arena
    assert isinstance(arena["one"], Sample1)
    assert isinstance(arena["two"], Sample2)
示例#13
0
def test_arena_instantiate():
    arena = Arena()
    assert dict() == arena

    arena.instantiate(Sample1, "one")
    assert 1 == len(arena)
    assert "one" in arena
    assert isinstance(arena["one"], Sample1)

    arena.instantiate(Sample2, "two")
    assert 2 == len(arena)
    assert "one" in arena and "two" in arena
    assert isinstance(arena["one"], Sample1)
    assert isinstance(arena["two"], Sample2)
示例#14
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())
示例#15
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())