-
Notifications
You must be signed in to change notification settings - Fork 9
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
Group internal attributes in canopy into data classes #341
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #341 +/- ##
===========================================
- Coverage 95.29% 94.95% -0.34%
===========================================
Files 28 34 +6
Lines 1720 2577 +857
===========================================
+ Hits 1639 2447 +808
- Misses 81 130 +49 ☔ View full report in Codecov by Sentry. |
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.
seems reasonable to me
@j-emberton I'm just looking at #314 and that alternative arrangement of calculating everything within self.cohort_data = CohortCanopyData(...)
self.community_data = self.cohort_data.community_data This is mostly because it won't leave the I could define those attrs with a default or get the pandas exporter to check that each exported attribute actually exists on an instance, but it seems easier just to go with that alternative. Any reasons not to? I've pushed the updated implementation here and the specific changes are: a82c6ea...0ba5f11 |
Yeah I can't see any reason not to do this. Happy for you to keep going. |
Description
This PR revises the internal structure of the
Canopy
class, grouping the attributes under two new dataclasses:CohortCanopyData
andCommunityCanopyData
, which use__post_init__
methods to populate the attributes. This:(n_heights, n_cohorts)
, community is just(n_heights,)
)Canopy._calculate_canopy
by bundling cohort and community calculations. This is something that @j-emberton requested in PR Revise and document functionality of canopy and crown #328.The calculation order here goes:
The first iteration had:
CohortCanopyData
,CommunityCanopyData
and thenCohortCanopyData.allocate_fapar
method, but that leaves some canopy attributes hanging until the allocation method is called. The code now generates theCommunityCanopyData
withinCohortCanopyData
so it all happens in a single pass. WithinCanopy
the community data is moved up into a top level attribute for ease of access.Fixes #337
Type of change
Key checklist
pre-commit
checks:$ pre-commit run -a
$ poetry run pytest
Further checks