def test_where_to_add_values_link_bc(four_by_four_raster, at, link_bc): if at == "link": where = _where_to_add_values(four_by_four_raster, at, link_bc) assert len(where) == four_by_four_raster.number_of_links elif at == "node": with pytest.raises(ValueError): _where_to_add_values(four_by_four_raster, at, link_bc) else: with pytest.raises(AttributeError): _where_to_add_values(four_by_four_raster, at, link_bc)
def test_where_to_add_values_link_bc(four_by_four_raster, at, link_bc): if at == "link": where = _where_to_add_values(four_by_four_raster, at, link_bc) assert len(where) == four_by_four_raster.number_of_links elif at == "node": with pytest.raises(ValueError): _where_to_add_values(four_by_four_raster, at, link_bc) else: with pytest.raises(AttributeError): _where_to_add_values(four_by_four_raster, at, link_bc)
def test_where_to_add_values_where_is_somewhere(four_by_four_raster, at): where = np.random.randint(0, 2, size=four_by_four_raster.size(at), dtype=bool) assert np.all( _where_to_add_values(four_by_four_raster, at, where) == where)
def test_where_to_add_values_with_bad_at(four_by_four_raster): with pytest.raises(GroupError): _where_to_add_values(four_by_four_raster, "not-a-place", None)
def test_where_to_add_values_wrong_size(four_by_four_raster, at): where = np.full(four_by_four_raster.size(at) - 1, False) with pytest.raises(ValueError): _where_to_add_values(four_by_four_raster, at, where)
def test_where_to_add_values_where_is_somewhere(four_by_four_raster, at): where = np.random.randint(0, 2, size=four_by_four_raster.size(at), dtype=bool) assert np.all(_where_to_add_values(four_by_four_raster, at, where) == where)
def test_where_to_add_values_where_is_nowhere(four_by_four_raster, at): where = np.full(four_by_four_raster.size(at), False) assert np.all(_where_to_add_values(four_by_four_raster, at, where) == where)
def test_where_to_add_values_where_is_none(four_by_four_raster, at): where = _where_to_add_values(four_by_four_raster, at, None) assert np.all(where == np.full(four_by_four_raster.size(at), True))
def test_where_to_add_values_with_bad_at(four_by_four_raster): with pytest.raises(GroupError): _where_to_add_values(four_by_four_raster, "not-a-place", None)
def test_where_to_add_values_wrong_size(four_by_four_raster, at): where = np.full(four_by_four_raster.size(at) - 1, False) with pytest.raises(ValueError): _where_to_add_values(four_by_four_raster, at, where)
def test_where_to_add_values_where_is_nowhere(four_by_four_raster, at): where = np.full(four_by_four_raster.size(at), False) assert np.all( _where_to_add_values(four_by_four_raster, at, where) == where)
def test_where_to_add_values_where_is_none(four_by_four_raster, at): where = _where_to_add_values(four_by_four_raster, at, None) assert np.all(where == np.full(four_by_four_raster.size(at), True))