def arithmetic_statmesh_setup(self): self.statmesh_1 = StatMesh(structured_coords=[[-1,0,1],[-1,0,1],[0,1]], structured=True) volumes1 = list(self.statmesh_1.structured_iterate_hex("xyz")) volumes2 = list(self.statmesh_1.structured_iterate_hex("xyz")) flux_tag = self.statmesh_1.mesh.createTag("flux", 1, float) error_tag = self.statmesh_1.mesh.createTag("flux_error", 1, float) flux_data = [1.0, 2.0, 3.0, 4.0] error_data = [0.1, 0.2, 0.3, 0.4] flux_tag[volumes1] = flux_data error_tag[volumes2] = error_data self.statmesh_2 = StatMesh(structured_coords=[[-1,0,1],[-1,0,1],[0,1]], structured=True) volumes1 = list(self.statmesh_2.structured_iterate_hex("xyz")) volumes2 = list(self.statmesh_2.structured_iterate_hex("xyz")) flux_tag = self.statmesh_2.mesh.createTag("flux", 1, float) error_tag = self.statmesh_2.mesh.createTag("flux_error", 1, float) flux_data = [1.1, 2.2, 3.3, 4.4] error_data = [0.1, 0.2, 0.3, 0.4] flux_tag[volumes1] = flux_data error_tag[volumes2] = error_data
def arithmetic_statmesh_setup(self): self.statmesh_1 = StatMesh(structured_coords=[[-1, 0, 1], [-1, 0, 1], [0, 1]], structured=True) volumes1 = list(self.statmesh_1.structured_iterate_hex("xyz")) volumes2 = list(self.statmesh_1.structured_iterate_hex("xyz")) flux_tag = self.statmesh_1.mesh.tag_get_handle("flux", 1, types.MB_TYPE_DOUBLE, types.MB_TAG_DENSE, create_if_missing=True) error_tag = self.statmesh_1.mesh.tag_get_handle("flux_rel_error", 1, types.MB_TYPE_DOUBLE, types.MB_TAG_DENSE, create_if_missing=True) flux_data = [1.0, 2.0, 3.0, 4.0] error_data = [0.1, 0.2, 0.3, 0.4] self.statmesh_1.mesh.tag_set_data(flux_tag, volumes1, flux_data) self.statmesh_1.mesh.tag_set_data(error_tag, volumes2, error_data) self.statmesh_2 = StatMesh(structured_coords=[[-1, 0, 1], [-1, 0, 1], [0, 1]], structured=True) volumes1 = list(self.statmesh_2.structured_iterate_hex("xyz")) volumes2 = list(self.statmesh_2.structured_iterate_hex("xyz")) flux_tag = self.statmesh_2.mesh.tag_get_handle("flux", 1, types.MB_TYPE_DOUBLE, types.MB_TAG_DENSE, create_if_missing=True) error_tag = self.statmesh_2.mesh.tag_get_handle("flux_rel_error", 1, types.MB_TYPE_DOUBLE, types.MB_TAG_DENSE, create_if_missing=True) flux_data = [1.1, 2.2, 3.3, 4.4] error_data = [0.1, 0.2, 0.3, 0.4] self.statmesh_2.mesh.tag_set_data(flux_tag, volumes1, flux_data) self.statmesh_2.mesh.tag_set_data(error_tag, volumes2, error_data)
def arithmetic_statmesh_setup(self): self.statmesh_1 = StatMesh(structured_coords=[[-1, 0, 1], [-1, 0, 1], [0, 1]], structured=True) volumes1 = list(self.statmesh_1.structured_iterate_hex("xyz")) volumes2 = list(self.statmesh_1.structured_iterate_hex("xyz")) flux_tag = self.statmesh_1.mesh.createTag("flux", 1, float) error_tag = self.statmesh_1.mesh.createTag("flux_error", 1, float) flux_data = [1.0, 2.0, 3.0, 4.0] error_data = [0.1, 0.2, 0.3, 0.4] flux_tag[volumes1] = flux_data error_tag[volumes2] = error_data self.statmesh_2 = StatMesh(structured_coords=[[-1, 0, 1], [-1, 0, 1], [0, 1]], structured=True) volumes1 = list(self.statmesh_2.structured_iterate_hex("xyz")) volumes2 = list(self.statmesh_2.structured_iterate_hex("xyz")) flux_tag = self.statmesh_2.mesh.createTag("flux", 1, float) error_tag = self.statmesh_2.mesh.createTag("flux_error", 1, float) flux_data = [1.1, 2.2, 3.3, 4.4] error_data = [0.1, 0.2, 0.3, 0.4] flux_tag[volumes1] = flux_data error_tag[volumes2] = error_data
class TestArithmetic(): def arithmetic_mesh_setup(self): self.mesh_1 = Mesh(structured_coords=[[-1, 0, 1], [-1, 0, 1], [0, 1]], structured=True) volumes1 = list(self.mesh_1.structured_iterate_hex("xyz")) volumes2 = list(self.mesh_1.structured_iterate_hex("xyz")) flux_tag = self.mesh_1.mesh.tag_get_handle("flux", 1, types.MB_TYPE_DOUBLE, types.MB_TAG_DENSE, create_if_missing=True) flux_data = [1.0, 2.0, 3.0, 4.0] self.mesh_1.mesh.tag_set_data(flux_tag, volumes1, flux_data) self.mesh_2 = Mesh(structured_coords=[[-1, 0, 1], [-1, 0, 1], [0, 1]], structured=True) volumes1 = list(self.mesh_2.structured_iterate_hex("xyz")) volumes2 = list(self.mesh_2.structured_iterate_hex("xyz")) flux_tag = self.mesh_2.mesh.tag_get_handle("flux", 1, types.MB_TYPE_DOUBLE, types.MB_TAG_DENSE, create_if_missing=True) flux_data = [1.1, 2.2, 3.3, 4.4] self.mesh_2.mesh.tag_set_data(flux_tag, volumes1, flux_data) def arithmetic_statmesh_setup(self): self.statmesh_1 = StatMesh(structured_coords=[[-1, 0, 1], [-1, 0, 1], [0, 1]], structured=True) volumes1 = list(self.statmesh_1.structured_iterate_hex("xyz")) volumes2 = list(self.statmesh_1.structured_iterate_hex("xyz")) flux_tag = self.statmesh_1.mesh.tag_get_handle("flux", 1, types.MB_TYPE_DOUBLE, types.MB_TAG_DENSE, create_if_missing=True) error_tag = self.statmesh_1.mesh.tag_get_handle("flux_rel_error", 1, types.MB_TYPE_DOUBLE, types.MB_TAG_DENSE, create_if_missing=True) flux_data = [1.0, 2.0, 3.0, 4.0] error_data = [0.1, 0.2, 0.3, 0.4] self.statmesh_1.mesh.tag_set_data(flux_tag, volumes1, flux_data) self.statmesh_1.mesh.tag_set_data(error_tag, volumes2, error_data) self.statmesh_2 = StatMesh(structured_coords=[[-1, 0, 1], [-1, 0, 1], [0, 1]], structured=True) volumes1 = list(self.statmesh_2.structured_iterate_hex("xyz")) volumes2 = list(self.statmesh_2.structured_iterate_hex("xyz")) flux_tag = self.statmesh_2.mesh.tag_get_handle("flux", 1, types.MB_TYPE_DOUBLE, types.MB_TAG_DENSE, create_if_missing=True) error_tag = self.statmesh_2.mesh.tag_get_handle("flux_rel_error", 1, types.MB_TYPE_DOUBLE, types.MB_TAG_DENSE, create_if_missing=True) flux_data = [1.1, 2.2, 3.3, 4.4] error_data = [0.1, 0.2, 0.3, 0.4] self.statmesh_2.mesh.tag_set_data(flux_tag, volumes1, flux_data) self.statmesh_2.mesh.tag_set_data(error_tag, volumes2, error_data) def test_add_mesh(self): self.arithmetic_mesh_setup() self.mesh_1 += self.mesh_2 exp_res = [2.1, 4.2, 6.3, 8.4] flux_tag = self.mesh_1.mesh.tag_get_handle("flux") obs_res = [ self.mesh_1.mesh.tag_get_data(flux_tag, vol, flat=True)[0] for vol in self.mesh_1.structured_iterate_hex("xyz") ] assert_array_almost_equal(exp_res, obs_res) def test_subtract_mesh(self): self.arithmetic_mesh_setup() self.mesh_1 -= self.mesh_2 exp_res = [-0.1, -0.2, -0.3, -0.4] flux_tag = self.mesh_1.mesh.tag_get_handle("flux") obs_res = [ self.mesh_1.mesh.tag_get_data(flux_tag, vol, flat=True)[0] for vol in self.mesh_1.structured_iterate_hex("xyz") ] assert_array_almost_equal(exp_res, obs_res) def test_multiply_mesh(self): self.arithmetic_mesh_setup() self.mesh_1 *= self.mesh_2 exp_res = [1.1, 4.4, 9.9, 17.6] flux_tag = self.mesh_1.mesh.tag_get_handle("flux") obs_res = [ self.mesh_1.mesh.tag_get_data(flux_tag, vol, flat=True)[0] for vol in self.mesh_1.structured_iterate_hex("xyz") ] assert_array_almost_equal(exp_res, obs_res) def test_divide_mesh(self): self.arithmetic_mesh_setup() self.mesh_1 /= self.mesh_2 exp_res = [0.9090909091, 0.9090909091, 0.9090909091, 0.9090909091] flux_tag = self.mesh_1.mesh.tag_get_handle("flux") obs_res = [ self.mesh_1.mesh.tag_get_data(flux_tag, vol, flat=True)[0] for vol in self.mesh_1.structured_iterate_hex("xyz") ] assert_array_almost_equal(exp_res, obs_res) def test_add_statmesh(self): self.arithmetic_statmesh_setup() self.statmesh_1 += self.statmesh_2 exp_res = [2.1, 4.2, 6.3, 8.4] exp_err = [ 0.070790803558659549, 0.1415816071173191, 0.21237241067597862, 0.28316321423463819 ] flux_tag = self.statmesh_1.mesh.tag_get_handle("flux") obs_res = [ self.statmesh_1.mesh.tag_get_data(flux_tag, vol, flat=True)[0] for vol in self.statmesh_1.structured_iterate_hex("xyz") ] flux_err_tag = self.statmesh_1.mesh.tag_get_handle("flux_rel_error") obs_err = [ self.statmesh_1.mesh.tag_get_data(flux_err_tag, vol, flat=True)[0] for vol in self.statmesh_1.structured_iterate_hex("xyz") ] assert_array_almost_equal(exp_res, obs_res) assert_array_almost_equal(exp_err, obs_err) def test_subtract_statmesh(self): self.arithmetic_statmesh_setup() self.statmesh_1 -= self.statmesh_2 exp_res = [-0.1, -0.2, -0.3, -0.4] exp_err = [-1.4866068747, -2.9732137495, -4.4598206242, -5.9464274989] flux_tag = self.statmesh_1.mesh.tag_get_handle("flux") obs_res = [ self.statmesh_1.mesh.tag_get_data(flux_tag, vol, flat=True)[0] for vol in self.statmesh_1.structured_iterate_hex("xyz") ] flux_err_tag = self.statmesh_1.mesh.tag_get_handle("flux_rel_error") obs_err = [ self.statmesh_1.mesh.tag_get_data(flux_err_tag, vol, flat=True)[0] for vol in self.statmesh_1.structured_iterate_hex("xyz") ] assert_array_almost_equal(exp_res, obs_res) assert_array_almost_equal(exp_err, obs_err) def test_multiply_statmesh(self): self.arithmetic_statmesh_setup() self.statmesh_1 *= self.statmesh_2 exp_res = [1.1, 4.4, 9.9, 17.6] exp_err = [ 0.1414213562, 0.2828427125, 0.4242640687, 0.5656854249, ] flux_tag = self.statmesh_1.mesh.tag_get_handle("flux") obs_res = [ self.statmesh_1.mesh.tag_get_data(flux_tag, vol, flat=True)[0] for vol in self.statmesh_1.structured_iterate_hex("xyz") ] flux_err_tag = self.statmesh_1.mesh.tag_get_handle("flux_rel_error") obs_err = [ self.statmesh_1.mesh.tag_get_data(flux_err_tag, vol, flat=True)[0] for vol in self.statmesh_1.structured_iterate_hex("xyz") ] assert_array_almost_equal(exp_res, obs_res) assert_array_almost_equal(exp_err, obs_err) def test_divide_statmesh(self): self.arithmetic_statmesh_setup() self.statmesh_1 /= self.statmesh_2 exp_res = [0.9090909091, 0.9090909091, 0.9090909091, 0.9090909091] exp_err = [0.1414213562, 0.2828427125, 0.4242640687, 0.5656854249] flux_tag = self.statmesh_1.mesh.tag_get_handle("flux") obs_res = [ self.statmesh_1.mesh.tag_get_data(flux_tag, vol, flat=True)[0] for vol in self.statmesh_1.structured_iterate_hex("xyz") ] flux_err_tag = self.statmesh_1.mesh.tag_get_handle("flux_rel_error") obs_err = [ self.statmesh_1.mesh.tag_get_data(flux_err_tag, vol, flat=True)[0] for vol in self.statmesh_1.structured_iterate_hex("xyz") ] assert_array_almost_equal(exp_res, obs_res) assert_array_almost_equal(exp_err, obs_err)
class TestArithmetic(): def arithmetic_mesh_setup(self): self.mesh_1 = Mesh(structured_coords=[[-1,0,1],[-1,0,1],[0,1]], structured=True) volumes1 = list(self.mesh_1.structured_iterate_hex("xyz")) volumes2 = list(self.mesh_1.structured_iterate_hex("xyz")) flux_tag = self.mesh_1.mesh.createTag("flux", 1, float) flux_data = [1.0, 2.0, 3.0, 4.0] flux_tag[volumes1] = flux_data self.mesh_2 = Mesh(structured_coords=[[-1,0,1],[-1,0,1],[0,1]], structured=True) volumes1 = list(self.mesh_2.structured_iterate_hex("xyz")) volumes2 = list(self.mesh_2.structured_iterate_hex("xyz")) flux_tag = self.mesh_2.mesh.createTag("flux", 1, float) flux_data = [1.1, 2.2, 3.3, 4.4] flux_tag[volumes1] = flux_data def arithmetic_statmesh_setup(self): self.statmesh_1 = StatMesh(structured_coords=[[-1,0,1],[-1,0,1],[0,1]], structured=True) volumes1 = list(self.statmesh_1.structured_iterate_hex("xyz")) volumes2 = list(self.statmesh_1.structured_iterate_hex("xyz")) flux_tag = self.statmesh_1.mesh.createTag("flux", 1, float) error_tag = self.statmesh_1.mesh.createTag("flux_error", 1, float) flux_data = [1.0, 2.0, 3.0, 4.0] error_data = [0.1, 0.2, 0.3, 0.4] flux_tag[volumes1] = flux_data error_tag[volumes2] = error_data self.statmesh_2 = StatMesh(structured_coords=[[-1,0,1],[-1,0,1],[0,1]], structured=True) volumes1 = list(self.statmesh_2.structured_iterate_hex("xyz")) volumes2 = list(self.statmesh_2.structured_iterate_hex("xyz")) flux_tag = self.statmesh_2.mesh.createTag("flux", 1, float) error_tag = self.statmesh_2.mesh.createTag("flux_error", 1, float) flux_data = [1.1, 2.2, 3.3, 4.4] error_data = [0.1, 0.2, 0.3, 0.4] flux_tag[volumes1] = flux_data error_tag[volumes2] = error_data def test_add_mesh(self): self.arithmetic_mesh_setup() self.mesh_1 += self.mesh_2 exp_res = [2.1, 4.2, 6.3, 8.4] obs_res = [self.mesh_1.mesh.getTagHandle("flux")[vol] for vol in self.mesh_1.structured_iterate_hex("xyz")] assert_array_almost_equal(exp_res, obs_res) def test_subtract_mesh(self): self.arithmetic_mesh_setup() self.mesh_1 -= self.mesh_2 exp_res = [-0.1, -0.2, -0.3, -0.4] obs_res = [self.mesh_1.mesh.getTagHandle("flux")[vol] for vol in self.mesh_1.structured_iterate_hex("xyz")] assert_array_almost_equal(exp_res, obs_res) def test_multiply_mesh(self): self.arithmetic_mesh_setup() self.mesh_1 *= self.mesh_2 exp_res = [1.1, 4.4, 9.9, 17.6] obs_res = [self.mesh_1.mesh.getTagHandle("flux")[vol] for vol in self.mesh_1.structured_iterate_hex("xyz")] assert_array_almost_equal(exp_res, obs_res) def test_divide_mesh(self): self.arithmetic_mesh_setup() self.mesh_1 /= self.mesh_2 exp_res = [0.9090909091, 0.9090909091, 0.9090909091, 0.9090909091] obs_res = [self.mesh_1.mesh.getTagHandle("flux")[vol] for vol in self.mesh_1.structured_iterate_hex("xyz")] assert_array_almost_equal(exp_res, obs_res) def test_add_statmesh(self): self.arithmetic_statmesh_setup() self.statmesh_1 += self.statmesh_2 exp_res = [2.1, 4.2, 6.3, 8.4] exp_err = [0.070790803558659549, 0.1415816071173191, 0.21237241067597862, 0.28316321423463819] obs_res = [self.statmesh_1.mesh.getTagHandle("flux")[vol] for vol in self.statmesh_1.structured_iterate_hex("xyz")] obs_err = [self.statmesh_1.mesh.getTagHandle("flux_error")[vol] for vol in self.statmesh_1.structured_iterate_hex("xyz")] assert_array_almost_equal(exp_res, obs_res) assert_array_almost_equal(exp_err, obs_err) def test_subtract_statmesh(self): self.arithmetic_statmesh_setup() self.statmesh_1 -= self.statmesh_2 exp_res = [-0.1, -0.2, -0.3, -0.4] exp_err = [-1.4866068747, -2.9732137495, -4.4598206242, -5.9464274989] obs_res = [self.statmesh_1.mesh.getTagHandle("flux")[vol] for vol in self.statmesh_1.structured_iterate_hex("xyz")] obs_err = [self.statmesh_1.mesh.getTagHandle("flux_error")[vol] for vol in self.statmesh_1.structured_iterate_hex("xyz")] assert_array_almost_equal(exp_res, obs_res) assert_array_almost_equal(exp_err, obs_err) def test_multiply_statmesh(self): self.arithmetic_statmesh_setup() self.statmesh_1 *= self.statmesh_2 exp_res = [1.1, 4.4, 9.9, 17.6] exp_err = [0.1414213562, 0.2828427125, 0.4242640687, 0.5656854249,] obs_res = [self.statmesh_1.mesh.getTagHandle("flux")[vol] for vol in self.statmesh_1.structured_iterate_hex("xyz")] obs_err = [self.statmesh_1.mesh.getTagHandle("flux_error")[vol] for vol in self.statmesh_1.structured_iterate_hex("xyz")] assert_array_almost_equal(exp_res, obs_res) assert_array_almost_equal(exp_err, obs_err) def test_divide_statmesh(self): self.arithmetic_statmesh_setup() self.statmesh_1 /= self.statmesh_2 exp_res = [0.9090909091, 0.9090909091, 0.9090909091, 0.9090909091] exp_err = [0.1414213562, 0.2828427125, 0.4242640687, 0.5656854249] obs_res = [self.statmesh_1.mesh.getTagHandle("flux")[vol] for vol in self.statmesh_1.structured_iterate_hex("xyz")] obs_err = [self.statmesh_1.mesh.getTagHandle("flux_error")[vol] for vol in self.statmesh_1.structured_iterate_hex("xyz")] assert_array_almost_equal(exp_res, obs_res) assert_array_almost_equal(exp_err, obs_err)
class TestArithmetic(): def arithmetic_mesh_setup(self): self.mesh_1 = Mesh(structured_coords=[[-1, 0, 1], [-1, 0, 1], [0, 1]], structured=True) volumes1 = list(self.mesh_1.structured_iterate_hex("xyz")) volumes2 = list(self.mesh_1.structured_iterate_hex("xyz")) flux_tag = self.mesh_1.mesh.createTag("flux", 1, float) flux_data = [1.0, 2.0, 3.0, 4.0] flux_tag[volumes1] = flux_data self.mesh_2 = Mesh(structured_coords=[[-1, 0, 1], [-1, 0, 1], [0, 1]], structured=True) volumes1 = list(self.mesh_2.structured_iterate_hex("xyz")) volumes2 = list(self.mesh_2.structured_iterate_hex("xyz")) flux_tag = self.mesh_2.mesh.createTag("flux", 1, float) flux_data = [1.1, 2.2, 3.3, 4.4] flux_tag[volumes1] = flux_data def arithmetic_statmesh_setup(self): self.statmesh_1 = StatMesh(structured_coords=[[-1, 0, 1], [-1, 0, 1], [0, 1]], structured=True) volumes1 = list(self.statmesh_1.structured_iterate_hex("xyz")) volumes2 = list(self.statmesh_1.structured_iterate_hex("xyz")) flux_tag = self.statmesh_1.mesh.createTag("flux", 1, float) error_tag = self.statmesh_1.mesh.createTag("flux_error", 1, float) flux_data = [1.0, 2.0, 3.0, 4.0] error_data = [0.1, 0.2, 0.3, 0.4] flux_tag[volumes1] = flux_data error_tag[volumes2] = error_data self.statmesh_2 = StatMesh(structured_coords=[[-1, 0, 1], [-1, 0, 1], [0, 1]], structured=True) volumes1 = list(self.statmesh_2.structured_iterate_hex("xyz")) volumes2 = list(self.statmesh_2.structured_iterate_hex("xyz")) flux_tag = self.statmesh_2.mesh.createTag("flux", 1, float) error_tag = self.statmesh_2.mesh.createTag("flux_error", 1, float) flux_data = [1.1, 2.2, 3.3, 4.4] error_data = [0.1, 0.2, 0.3, 0.4] flux_tag[volumes1] = flux_data error_tag[volumes2] = error_data def test_add_mesh(self): self.arithmetic_mesh_setup() self.mesh_1 += self.mesh_2 exp_res = [2.1, 4.2, 6.3, 8.4] obs_res = [ self.mesh_1.mesh.getTagHandle("flux")[vol] for vol in self.mesh_1.structured_iterate_hex("xyz") ] assert_array_almost_equal(exp_res, obs_res) def test_subtract_mesh(self): self.arithmetic_mesh_setup() self.mesh_1 -= self.mesh_2 exp_res = [-0.1, -0.2, -0.3, -0.4] obs_res = [ self.mesh_1.mesh.getTagHandle("flux")[vol] for vol in self.mesh_1.structured_iterate_hex("xyz") ] assert_array_almost_equal(exp_res, obs_res) def test_multiply_mesh(self): self.arithmetic_mesh_setup() self.mesh_1 *= self.mesh_2 exp_res = [1.1, 4.4, 9.9, 17.6] obs_res = [ self.mesh_1.mesh.getTagHandle("flux")[vol] for vol in self.mesh_1.structured_iterate_hex("xyz") ] assert_array_almost_equal(exp_res, obs_res) def test_divide_mesh(self): self.arithmetic_mesh_setup() self.mesh_1 /= self.mesh_2 exp_res = [0.9090909091, 0.9090909091, 0.9090909091, 0.9090909091] obs_res = [ self.mesh_1.mesh.getTagHandle("flux")[vol] for vol in self.mesh_1.structured_iterate_hex("xyz") ] assert_array_almost_equal(exp_res, obs_res) def test_add_statmesh(self): self.arithmetic_statmesh_setup() self.statmesh_1 += self.statmesh_2 exp_res = [2.1, 4.2, 6.3, 8.4] exp_err = [ 0.070790803558659549, 0.1415816071173191, 0.21237241067597862, 0.28316321423463819 ] obs_res = [ self.statmesh_1.mesh.getTagHandle("flux")[vol] for vol in self.statmesh_1.structured_iterate_hex("xyz") ] obs_err = [ self.statmesh_1.mesh.getTagHandle("flux_error")[vol] for vol in self.statmesh_1.structured_iterate_hex("xyz") ] assert_array_almost_equal(exp_res, obs_res) assert_array_almost_equal(exp_err, obs_err) def test_subtract_statmesh(self): self.arithmetic_statmesh_setup() self.statmesh_1 -= self.statmesh_2 exp_res = [-0.1, -0.2, -0.3, -0.4] exp_err = [-1.4866068747, -2.9732137495, -4.4598206242, -5.9464274989] obs_res = [ self.statmesh_1.mesh.getTagHandle("flux")[vol] for vol in self.statmesh_1.structured_iterate_hex("xyz") ] obs_err = [ self.statmesh_1.mesh.getTagHandle("flux_error")[vol] for vol in self.statmesh_1.structured_iterate_hex("xyz") ] assert_array_almost_equal(exp_res, obs_res) assert_array_almost_equal(exp_err, obs_err) def test_multiply_statmesh(self): self.arithmetic_statmesh_setup() self.statmesh_1 *= self.statmesh_2 exp_res = [1.1, 4.4, 9.9, 17.6] exp_err = [ 0.1414213562, 0.2828427125, 0.4242640687, 0.5656854249, ] obs_res = [ self.statmesh_1.mesh.getTagHandle("flux")[vol] for vol in self.statmesh_1.structured_iterate_hex("xyz") ] obs_err = [ self.statmesh_1.mesh.getTagHandle("flux_error")[vol] for vol in self.statmesh_1.structured_iterate_hex("xyz") ] assert_array_almost_equal(exp_res, obs_res) assert_array_almost_equal(exp_err, obs_err) def test_divide_statmesh(self): self.arithmetic_statmesh_setup() self.statmesh_1 /= self.statmesh_2 exp_res = [0.9090909091, 0.9090909091, 0.9090909091, 0.9090909091] exp_err = [0.1414213562, 0.2828427125, 0.4242640687, 0.5656854249] obs_res = [ self.statmesh_1.mesh.getTagHandle("flux")[vol] for vol in self.statmesh_1.structured_iterate_hex("xyz") ] obs_err = [ self.statmesh_1.mesh.getTagHandle("flux_error")[vol] for vol in self.statmesh_1.structured_iterate_hex("xyz") ] assert_array_almost_equal(exp_res, obs_res) assert_array_almost_equal(exp_err, obs_err)