Skip to content

Commit

Permalink
Moved migration in celltype class
Browse files Browse the repository at this point in the history
  • Loading branch information
vsnupoudel committed Jun 18, 2020
1 parent 7fc3e07 commit d9201df
Show file tree
Hide file tree
Showing 47 changed files with 148 additions and 15,104 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
recursive-include examples *.py *.ipynb
recursive-include tests *.py
File renamed without changes.
14 changes: 10 additions & 4 deletions biosim/animal.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@


class Animal:
"""
This is the class level documentation
:return None
"""
_params = {}

@classmethod
Expand All @@ -15,6 +19,12 @@ def set_parameters(cls, params):
cls._params.update(params)

def __init__(self, age=0, weight=None):
"""
This is for the init function
:param age: age
:param weight: wt
:return
"""
self.age = age
birth_weight = np.random.normal(self._params['w_birth'], self._params['sigma_birth'])
# print(birth_weight)
Expand Down Expand Up @@ -171,9 +181,5 @@ def hunts(self, herb_sorted_list ):

return dead_herb_list

if __name__ == "__main__":
h = Herbivore(weight = 50)
print(h.__class__.__name__)
# print( list( set(h) - set([]) ) )


24 changes: 24 additions & 0 deletions biosim/celltype.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,30 @@ def make_animals_age(self):
for anim in self.carn_list:
anim.get_older()

def migration_prepare(self): # to be called once for all cell at the beginning
for anim in self.herb_list + self.carn_list:
anim.has_migrated = False

def migration_master(self, object_matrix):
if not isinstance(self, Water):
adjacent_cells = self.adjacent_cells( object_matrix)
dict_of_migrants = self.emigrants_list(adjacent_cells)

for migrating_cell, values in dict_of_migrants.items():
if not isinstance(migrating_cell, Water) and values:
migrating_cell.add_immigrants(values)
self.remove_emigrants(values)

def adjacent_cells(self, object_matrix):
x = self.row
y = self.col
adjacent_cells = []
for i in (-1, 1):
adjacent_cells.append(object_matrix[x + i][y])
adjacent_cells.append(object_matrix[x][y + i])

return adjacent_cells

def emigrants_list(self, adjacent_cells): #takes in adjacent cells
dct = {}
listofanim = [anim for anim in self.carn_list + self.herb_list if anim.migrates() and
Expand Down
20 changes: 0 additions & 20 deletions biosim/docs/Makefile

This file was deleted.

Binary file removed biosim/docs/_build/doctrees/biosim_docu.doctree
Binary file not shown.
Binary file removed biosim/docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file removed biosim/docs/_build/doctrees/index.doctree
Binary file not shown.
4 changes: 0 additions & 4 deletions biosim/docs/_build/html/.buildinfo

This file was deleted.

9 changes: 0 additions & 9 deletions biosim/docs/_build/html/_sources/biosim_docu.rst.txt

This file was deleted.

18 changes: 0 additions & 18 deletions biosim/docs/_build/html/_sources/index.rst.txt

This file was deleted.

Loading

0 comments on commit d9201df

Please sign in to comment.