From f6634c8279730566fe4ca320e31024c3d33a3782 Mon Sep 17 00:00:00 2001 From: iamgiddyaboutgit Date: Mon, 11 Dec 2023 21:03:31 -0500 Subject: [PATCH] handle desertification --- src/sim_world_functions.py | 12 +++++++----- src/sim_world_functions_test.py | 10 +++++++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/sim_world_functions.py b/src/sim_world_functions.py index 4ffd987..c4c8111 100755 --- a/src/sim_world_functions.py +++ b/src/sim_world_functions.py @@ -104,9 +104,11 @@ def stoch_pro_lin( return s -def prior_biome_before_desertification(rng:np.random.Generator): +def prior_biomes_before_desertification(n, rng:np.random.Generator): """Returns the prior biome. + Args: + n: int. The number of prior biomes wanted. Returns: str. Indicates what the biome was historically. """ @@ -118,9 +120,9 @@ def prior_biome_before_desertification(rng:np.random.Generator): "Montane Grasslands & Shrublands", "Temperate Broadleaf & Mixed Forests" ] - past_biome = rng.choice( + past_biomes = rng.choice( a=other_biome_choices, - size=1 - )[0] + size=n + ).tolist() - return past_biome + return past_biomes diff --git a/src/sim_world_functions_test.py b/src/sim_world_functions_test.py index 106005f..4645fba 100755 --- a/src/sim_world_functions_test.py +++ b/src/sim_world_functions_test.py @@ -6,6 +6,7 @@ import numpy as np +rng = np.random.default_rng() # print( # swf.stoch_pro_lin( # x_0=0, @@ -23,4 +24,11 @@ # x=np.linspace(0, 1, 50), # b=-6 # ) -# ) \ No newline at end of file +# ) + +print( + swf.prior_biomes_before_desertification( + 6, + rng + ) +) \ No newline at end of file