def test_update_from_dict(self): gmap = GnomeMap() json_ = {'map_bounds': [(-10, 10), (10, 10), (10, -10), (-10, -10)]} assert np.all(gmap.map_bounds != json_['map_bounds']) gmap.update_from_dict(json_) assert np.all(gmap.map_bounds == json_['map_bounds'])
def test_resurface_airborne_elements(): positions = np.array( ((1, 2, 0.), (3, 4, 1.), (-3, 4, -1.), (3, 4, 0.1), (3, 4, 0.1)), dtype=np.float64) spill = {'next_positions': positions} m = GnomeMap() m.resurface_airborne_elements(spill) assert spill['next_positions'][:, 2].min() == 0.
def test_on_map_array(self): """ a little bit more complex tests and test of arrays of points """ # a concave map boundary map_bounds = ((-40.0, 50.0), (-40.0, 58.0), (-30.0, 58.0), (-35.0, 53.0), (-30.0, 50.0)) gmap = GnomeMap(map_bounds=map_bounds) points = ((-35, 55, 0.), (-45, 55, 0.)) result = gmap.on_map(points) # some points on the map: assert np.array_equal(result, (True, False))
def test_on_map(self): gmap = GnomeMap() assert gmap.on_map((0., 0., 0.)) is True # too big latitude print gmap.on_map((0., 91.0, 0.)) assert gmap.on_map((0., 91.0, 0.)) is False # too small latitude assert gmap.on_map((0., -91.0, 0.)) is False # too big langitude assert gmap.on_map((0., 361.0, 0.)) is False # too small langitude assert gmap.on_map((0., -361.0, 0.)) is False
def test_allowable_spill_position(self): gmap = GnomeMap() assert gmap.allowable_spill_position((18.0, -87.0, 0.)) is True assert gmap.allowable_spill_position((370.0, -87.0, 0.)) is False
def test_in_water(self): gmap = GnomeMap() assert gmap.in_water((18.0, -87.0, 0.)) assert gmap.in_water((370.0, -87.0, 0.)) is False
def test_on_land(self): gmap = GnomeMap() assert gmap.on_land((18.0, -87.0, 0.)) is False
def get_gnomemap(): return GnomeMap(map_bounds=((10, 10), (15, 10), (15, 15), (10, 15)), spillable_area=((11, 11), (14, 11), (14, 14), (11, 14)), land_polys=None, name="Test Map for TideflatMap")