Skip to content

Commit

Permalink
comments and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MM1nd committed Sep 30, 2017
1 parent 197c4ca commit 6bec78d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
9 changes: 0 additions & 9 deletions tests/simulation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@
from worldengine.model.world import World, Size, GenerationParameters

class TestSimulation(unittest.TestCase):


# The hydrology simulation indirectly calls the global rng.
# We want different implementations of _watermap
# and internally called functions (especially random_land)
# to show the same rng behaviour and not contamine the state of the global rng
# should anyone else happen to rely on it.
# This does only test that watermap leaves the rng in the state that the
# original implementation would have left it in and that a very small sample
# of results is the same as the original results.
Expand All @@ -26,7 +20,6 @@ class TestSimulation(unittest.TestCase):
# have a finer grained picture.

def test_watermap_rng_stabilty(self):

seed=12345
numpy.random.seed(seed)

Expand Down Expand Up @@ -58,7 +51,6 @@ def test_watermap_rng_stabilty(self):


def test_watermap_does_not_break_with_no_land(self):

seed=12345
numpy.random.seed(seed)

Expand All @@ -73,7 +65,6 @@ def test_watermap_does_not_break_with_no_land(self):


def test_random_land_returns_only_land(self):

size = Size(100,90)

ocean = numpy.fromfunction(lambda y, x: y>=x, (size.height, size.width))
Expand Down
1 change: 0 additions & 1 deletion worldengine/model/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ def contains(self, pos):
#

def random_land(self, num_samples=1):

if self.layers['ocean'].data.all():
return None, None # return invalid indices if there is no land at all

Expand Down
6 changes: 6 additions & 0 deletions worldengine/simulations/hydrology.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ def droplet(world, pos, q, _watermap):

_watermap_data = numpy.zeros((world.height, world.width), dtype=float)

# This indirectly calls the global rng.
# We want different implementations of _watermap
# and internally called functions (especially random_land)
# to show the same rng behaviour and not contamine the state of the global rng
# should anyone else happen to rely on it.

land_sample = world.random_land(n)

if land_sample[0] is not None:
Expand Down

0 comments on commit 6bec78d

Please sign in to comment.