Skip to content

Animal Foragin Debug - Cumulative prey densities and handling time#1401

Merged
TaranRallings merged 8 commits intodevelopfrom
1317-animal---fix-missing-prey-mass-call-in-h_i_j
Mar 4, 2026
Merged

Animal Foragin Debug - Cumulative prey densities and handling time#1401
TaranRallings merged 8 commits intodevelopfrom
1317-animal---fix-missing-prey-mass-call-in-h_i_j

Conversation

@TaranRallings
Copy link
Copy Markdown
Collaborator

Description

This PR fixes some bugs in the animal foraging system.

  • H_i_j (handling time calculator) was keying off predator mass instead of prey mass
  • cumulative prey density was not being calculated or used

H_i_j, now correctly uses prey mass in the calculation.
The cohort method calculate_total_handling_time_for_predation, now correctly sums over available prey for determining density.

Fixes #1317

Type of change

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist

  • Make sure you've run the pre-commit checks: $ pre-commit run -a
  • All tests pass: $ poetry run pytest

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works
  • Relevant documentation reviewed and updated

@TaranRallings TaranRallings linked an issue Mar 3, 2026 that may be closed by this pull request
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.84%. Comparing base (8a26398) to head (4962fea).
⚠️ Report is 45 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1401      +/-   ##
===========================================
- Coverage    94.85%   94.84%   -0.01%     
===========================================
  Files           71       71              
  Lines         7387     7455      +68     
===========================================
+ Hits          7007     7071      +64     
- Misses         380      384       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@dalonsoa dalonsoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks correct - obviously, no idea about the science.

Having said that, having variables that include subindices (i, j) is very confusing. It feels they should be 2D arrays and not variable of function names. They are not informative of what they represent. what is i? and j? I know that was not implemented in this PR, but I have just seen it, so thought mentioning it.

@TaranRallings
Copy link
Copy Markdown
Collaborator Author

Having said that, having variables that include subindices (i, j) is very confusing. It feels they should be 2D arrays and not variable of function names. They are not informative of what they represent. what is i? and j? I know that was not implemented in this PR, but I have just seen it, so thought mentioning it.

Totally agree. A round of naming updates is on my to-do list for exactly that reason. The names they have currently are there to make it easy to compare to the paper they are drawn from. In the fairly near future I'll be changing them all.

@TaranRallings TaranRallings merged commit ab1ab4d into develop Mar 4, 2026
13 checks passed
@TaranRallings TaranRallings deleted the 1317-animal---fix-missing-prey-mass-call-in-h_i_j branch March 4, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Animal - Fix missing prey mass call in H_i_j

3 participants