-
Notifications
You must be signed in to change notification settings - Fork 8
Remove temporary allocations #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -420,8 +420,8 @@ def metabolism(self,day): | |
| # Update Substrates pools with dead enzymes | ||
| DeadEnz_df = pd.concat( | ||
| [Enzyme_Loss, | ||
| Enzyme_Loss.mul(self.Enz_Attrib['N_cost'].tolist()*self.gridsize,axis=0), | ||
| Enzyme_Loss.mul(self.Enz_Attrib['P_cost'].tolist()*self.gridsize,axis=0)], | ||
| Enzyme_Loss.mul(np.repeat(self.Enz_Attrib['N_cost'].values, self.gridsize), axis=0), | ||
| Enzyme_Loss.mul(np.repeat(self.Enz_Attrib['P_cost'].values, self.gridsize), axis=0)], | ||
| axis=1 | ||
| ) | ||
| DeadEnz_df.index = [np.arange(self.gridsize).repeat(self.n_enzymes), DeadEnz_df.index] # create a multi-index | ||
|
|
@@ -713,5 +713,5 @@ def reinitialization(self,initialization,microbes_pp,output,mode,pulse,*args): | |
| # last: assign microbes to each grid box randomly based on prior densities | ||
| choose_taxa = np.zeros((self.n_taxa,self.gridsize), dtype='int8') | ||
| for i in range(self.n_taxa): | ||
| choose_taxa[i,:] = np.random.choice([1,0], self.gridsize, replace=True, p=[frequencies[i], 1-frequencies[i]]) | ||
| choose_taxa[i,:] = np.random.binomial(1, frequencies[i], self.gridsize) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I changed the numbers back to "float32" this sampling started failing saying that the probabilities do not sum to 1.0. I presume they must be converted to "float64" before getting summed inside I have changed the sampling to |
||
| self.Microbes.loc[np.ravel(choose_taxa,order='F')==0] = np.float32(0) # NOTE order='F' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| """Test(s) to use with pytest-profiling to identify bottlenecks in the code.""" | ||
| import pytest | ||
|
|
||
| @pytest.mark.profiling | ||
| def test_profiling(monkeypatch): | ||
|
|
||
| # Define the command line arguments | ||
| import sys | ||
| argv = ['dementpy.py', 'grassland', 'output', '20250402', 'scrubland'] | ||
| monkeypatch.setattr(sys, 'argv', argv) | ||
|
|
||
| # Move to subfolder so input and output folders will be correct | ||
| import os | ||
| os.chdir('src') | ||
|
|
||
| # Run dementpy | ||
| import dementpy | ||
| dementpy.main() |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'float64' was appearing here.
tolistmethod would return a list of Python'sfloats, which are double precision.