Exemplo n.º 1
0
def test_getitem():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)

    assert_dict_equal(dict(), fields['node'])
    assert_raises(GroupError, lambda k: fields[k], 'cell')
    assert_raises(KeyError, lambda k: fields[k], 'cell')
Exemplo n.º 2
0
def test_getitem():
    fields = ModelDataFields()
    fields.new_field_location("node", 12)

    assert_dict_equal(dict(), fields["node"])
    assert_raises(GroupError, lambda k: fields[k], "cell")
    assert_raises(KeyError, lambda k: fields[k], "cell")
Exemplo n.º 3
0
def test_getitem():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)

    assert_dict_equal(dict(), fields['node'])
    assert_raises(GroupError, lambda k: fields[k], 'cell')
    assert_raises(KeyError, lambda k: fields[k], 'cell')
Exemplo n.º 4
0
def test_at_attribute():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)

    assert_dict_equal(dict(), fields.at_node)
    assert_raises(AttributeError, lambda: fields.at_cell)

    fields.add_ones('node', 'z')
    assert_array_equal(np.ones(12), fields.at_node['z'])
Exemplo n.º 5
0
    def test_getitem(self):
        fields = ModelDataFields()
        fields.new_field_location('node', 12)

        self.assertDictEqual(dict(), fields['node'])
        with self.assertRaises(GroupError):
            fields['cell']
        with self.assertRaises(KeyError):
            fields['cell']
Exemplo n.º 6
0
def test_add_multiple_groups():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)
    fields.new_field_location('cell', 2)
    fields.new_field_location('face', 7)
    fields.new_field_location('link', 7)
    assert_set_equal(set(['node', 'cell', 'face', 'link']), fields.groups)
Exemplo n.º 7
0
def test_add_ones_return_value():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)
    fields.new_field_location('cell', 2)

    rtn_value = fields.add_ones('node', 'z')
    assert_array_equal(rtn_value, np.ones(12))
    assert_is(rtn_value, fields['node']['z'])
    assert_is(rtn_value, fields.field_values('node', 'z'))

    rtn_value = fields.add_ones('cell', 'z')
    assert_array_equal(rtn_value, np.ones(2))
    assert_is(rtn_value, fields['cell']['z'])
    assert_is(rtn_value, fields.field_values('cell', 'z'))
Exemplo n.º 8
0
def test_ones():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)
    fields.new_field_location('cell', 2)

    value_array = fields.ones('node')
    assert_array_equal(np.ones(12), value_array)

    value_array = fields.ones('cell')
    assert_array_equal(np.ones(2), value_array)
Exemplo n.º 9
0
def test_add_ones_return_value():
    fields = ModelDataFields()
    fields.new_field_location("node", 12)
    fields.new_field_location("cell", 2)

    rtn_value = fields.add_ones("node", "z")
    assert_array_equal(rtn_value, np.ones(12))
    assert_is(rtn_value, fields["node"]["z"])
    assert_is(rtn_value, fields.field_values("node", "z"))

    rtn_value = fields.add_ones("cell", "z")
    assert_array_equal(rtn_value, np.ones(2))
    assert_is(rtn_value, fields["cell"]["z"])
    assert_is(rtn_value, fields.field_values("cell", "z"))
Exemplo n.º 10
0
def test_add_multiple_groups():
    fields = ModelDataFields()
    fields.new_field_location("node", 12)
    fields.new_field_location("cell", 2)
    fields.new_field_location("face", 7)
    fields.new_field_location("link", 7)
    assert_set_equal(set(["node", "cell", "face", "link"]), fields.groups)
Exemplo n.º 11
0
def test_add_multiple_groups():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)
    fields.new_field_location('cell', 2)
    fields.new_field_location('face', 7)
    fields.new_field_location('link', 7)
    assert_set_equal(set(['node', 'cell', 'face', 'link']), fields.groups)
Exemplo n.º 12
0
def test_delete_field():
    fields = ModelDataFields()
    fields.new_field_location("link", 17)

    assert_dict_equal(dict(), fields.at_link)
    assert_raises(AttributeError, lambda: fields.at_node)

    fields.add_zeros("link", "vals")
    assert_array_equal(np.zeros(17), fields.at_link["vals"])

    assert_raises(KeyError, lambda: fields.delete_field("node", "vals"))
    fields.delete_field("link", "vals")
    assert_raises(KeyError, lambda: fields.field_units("link", "vals"))
    assert_raises(KeyError, lambda: fields.at_link["vals"])
Exemplo n.º 13
0
def test_add_ones_return_value():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)
    fields.new_field_location('cell', 2)

    rtn_value = fields.add_ones('node', 'z')
    assert_array_equal(rtn_value, np.ones(12))
    assert_is(rtn_value, fields['node']['z'])
    assert_is(rtn_value, fields.field_values('node', 'z'))

    rtn_value = fields.add_ones('cell', 'z')
    assert_array_equal(rtn_value, np.ones(2))
    assert_is(rtn_value, fields['cell']['z'])
    assert_is(rtn_value, fields.field_values('cell', 'z'))
Exemplo n.º 14
0
def test_ones():
    fields = ModelDataFields()
    fields.new_field_location("node", 12)
    fields.new_field_location("cell", 2)

    value_array = fields.ones("node")
    assert_array_equal(np.ones(12), value_array)

    value_array = fields.ones("cell")
    assert_array_equal(np.ones(2), value_array)
Exemplo n.º 15
0
def test_ones():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)
    fields.new_field_location('cell', 2)

    value_array = fields.ones('node')
    assert_array_equal(np.ones(12), value_array)

    value_array = fields.ones('cell')
    assert_array_equal(np.ones(2), value_array)
Exemplo n.º 16
0
def test_at_attribute():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)

    assert_dict_equal(dict(), fields.at_node)
    assert_raises(AttributeError, lambda: fields.at_cell)

    fields.add_ones('node', 'z')
    assert_array_equal(np.ones(12), fields.at_node['z'])
Exemplo n.º 17
0
    def test_at_attribute(self):
        fields = ModelDataFields()
        fields.new_field_location('node', 12)

        self.assertDictEqual(dict(), fields.at_node)
        with self.assertRaises(AttributeError):
            fields.at_cell

        fields.add_ones('node', 'z')
        assert_array_equal(np.ones(12), fields.at_node['z'])
Exemplo n.º 18
0
def test_has_group():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)

    assert_true(fields.has_group('node'))
    assert_false(fields.has_group('cell'))
Exemplo n.º 19
0
def test_add_existing_group():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)
    assert_raises(ValueError, fields.new_field_location, 'node', 24)
Exemplo n.º 20
0
def test_new_field_location():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)
    assert_set_equal(set(['node']), fields.groups)
Exemplo n.º 21
0
def test_add_ones():
    fields = ModelDataFields()
    fields.new_field_location("node", 12)
    fields.new_field_location("cell", 2)

    fields.add_ones("node", "z")
    assert_array_equal(np.ones(12), fields["node"]["z"])
    assert_array_equal(np.ones(12), fields.field_values("node", "z"))

    fields.add_ones("cell", "z")
    assert_array_equal(np.ones(2), fields["cell"]["z"])
    assert_array_equal(np.ones(2), fields.field_values("cell", "z"))
Exemplo n.º 22
0
def test_add_ones():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)
    fields.new_field_location('cell', 2)

    fields.add_ones('node', 'z')
    assert_array_equal(np.ones(12), fields['node']['z'])
    assert_array_equal(np.ones(12), fields.field_values('node', 'z'))

    fields.add_ones('cell', 'z')
    assert_array_equal(np.ones(2), fields['cell']['z'])
    assert_array_equal(np.ones(2), fields.field_values('cell', 'z'))
Exemplo n.º 23
0
 def test_init(self):
     fields = ModelDataFields()
     self.assertSetEqual(set(), fields.groups)
Exemplo n.º 24
0
 def test_new_field_location(self):
     fields = ModelDataFields()
     fields.new_field_location('node', 12)
     self.assertSetEqual(set(['node']), fields.groups)
Exemplo n.º 25
0
 def test_add_existing_group(self):
     fields = ModelDataFields()
     fields.new_field_location('node', 12)
     with self.assertRaises(ValueError):
         fields.new_field_location('node', 24)
Exemplo n.º 26
0
    def test_has_group(self):
        fields = ModelDataFields()
        fields.new_field_location('node', 12)

        self.assertTrue(fields.has_group('node'))
        self.assertFalse(fields.has_group('cell'))
Exemplo n.º 27
0
def test_add_ones():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)
    fields.new_field_location('cell', 2)

    fields.add_ones('node', 'z')
    assert_array_equal(np.ones(12), fields['node']['z'])
    assert_array_equal(np.ones(12), fields.field_values('node', 'z'))

    fields.add_ones('cell', 'z')
    assert_array_equal(np.ones(2), fields['cell']['z'])
    assert_array_equal(np.ones(2), fields.field_values('cell', 'z'))
Exemplo n.º 28
0
def test_init():
    fields = ModelDataFields()
    assert_set_equal(set(), fields.groups)
Exemplo n.º 29
0
def test_new_field_location():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)
    assert_set_equal(set(['node']), fields.groups)
Exemplo n.º 30
0
def test_add_existing_group():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)
    assert_raises(ValueError, fields.new_field_location, 'node', 24)
Exemplo n.º 31
0
def test_has_group():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)

    assert_true(fields.has_group('node'))
    assert_false(fields.has_group('cell'))
Exemplo n.º 32
0
def test_has_group():
    fields = ModelDataFields()
    fields.new_field_location("node", 12)

    assert_true(fields.has_group("node"))
    assert_false(fields.has_group("cell"))