3. Discussion: how can we break out the context map generation? #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Right now, the context map generation logic is in the Walker constructor. This works but is ugly and not very extensible. How could we solve this?
Exercise instructions:
Go to the notebook
walker/Step_3_break_out_the_context_map_initializationand follow the instructions. Comment here what you think the solution could look like. Also feel free to comment on other group's suggestions.Make sure to include your suggested code snippet(s)
The import statement would be like this:
So we have a new module called context_map that contains a function to create a new context_map. This function would take as argument the type of context_map, for example "hill".
Finally, the Walker class takes a context_map object instead of map_type='hills':
we wouldn't need to import any library for the Walker class
just two, map_type and the size of the map
def context_map (map_type, size)
if map_type == 'a':
map = map_a(size)
elif map_type == 'b':
map = map_b(size)
return map
def map_a(size):
cont_map = np.ones((size, size))
return cont_map
def map_b(size):
...
Inside the Walker class:
def map_type_flat(self):
...
def map_type_hills(self):
...
def map_type_labrynth(self):
...
Outside the Walker class:
walker1 = Walker(self...)
walker1.map_type_flat() # For example
The problem is when we use _compute_next_step_probability().
Maybe raise and error when the map isn't set up.
a) we have to separate each type of map into 3 pieces or methods in a new .py file and after that we can callable by importing. Nevertheless, it is necessary to establish their corresponding parameter to avoid errors.
1
We proposse to exclude the function create_context_map(), and create a new script named initial_context_map.py in the same folder, in the colab file we need to add from initial_context_map import create_context_map
2
In this new scrip, write a new claas, def class(self, size, shape_type):
self.size=size
self.shape_type = shape_type
3
It's no neccesary to use map_type, and keep size because of the random wlaker