def test_where_status_with_patches(four_by_four_raster): with pytest.raises(AttributeError): constant( four_by_four_raster, "values", "patch", where=four_by_four_raster.BC_NODE_IS_CORE, )
def test_multiple_status_node(four_by_four_raster): four_by_four_raster.set_closed_boundaries_at_grid_edges(True, True, False, False) vals = constant( four_by_four_raster, "values", "node", where=[CORE_NODE, CLOSED_BOUNDARY], value=10.0, ) true_array = np.array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 10.0, 10.0, 10.0, 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, ] ) assert_array_equal(vals, true_array)
def test_multiple_status_node(four_by_four_raster): four_by_four_raster.set_closed_boundaries_at_grid_edges( True, True, False, False) vals = constant( four_by_four_raster, "values", "node", where=[ four_by_four_raster.BC_NODE_IS_CORE, four_by_four_raster.BC_NODE_IS_CLOSED, ], value=10.0, ) true_array = np.array([ 0.0, 0.0, 0.0, 0.0, 0.0, 10.0, 10.0, 10.0, 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, ]) assert_array_equal(vals, true_array)
def test_multiple_status_node(four_by_four_raster): four_by_four_raster.set_closed_boundaries_at_grid_edges(True, True, False, False) vals = constant( four_by_four_raster, "values", "node", where=[CORE_NODE, CLOSED_BOUNDARY], constant=10., ) true_array = np.array( [0., 0., 0., 0., 0., 10., 10., 10., 0., 10., 10., 10., 10., 10., 10., 10.] ) assert_array_equal(vals, true_array)
def test_where_status_with_patches(four_by_four_raster): with pytest.raises(AttributeError): constant(four_by_four_raster, "values", "patch", where=CORE_NODE)
def test_bad_grid_element_name(four_by_four_raster): with pytest.raises(KeyError): constant(four_by_four_raster, "some_flux", "not_a_grid_element", value=1.0)