mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-08-01 19:24:18 -07:00
Adding tests to ensure proper calculations (#1871)
* just testing that the boolean is preserved on gha * checking drop tracts works * adding a check to the agvalue calculation for nri * updated with error messages
This commit is contained in:
parent
b0b7ff0eec
commit
5201f9e457
4 changed files with 209 additions and 0 deletions
|
@ -153,6 +153,27 @@ class NationalRiskIndexETL(ExtractTransformLoad):
|
|||
lower=self.AGRIVALUE_LOWER_BOUND
|
||||
)
|
||||
|
||||
## Check that this clip worked -- that the only place the value has changed is when the clip took effect
|
||||
base_expectation = (
|
||||
disaster_agriculture_sum_series
|
||||
/ df_nri[self.AGRICULTURAL_VALUE_INPUT_FIELD_NAME]
|
||||
)
|
||||
assert (
|
||||
df_nri[
|
||||
df_nri[self.EXPECTED_AGRICULTURE_LOSS_RATE_FIELD_NAME]
|
||||
!= base_expectation
|
||||
][self.AGRICULTURAL_VALUE_INPUT_FIELD_NAME].max()
|
||||
<= self.AGRIVALUE_LOWER_BOUND
|
||||
), (
|
||||
"Clipping the agrivalue did not work. There are places where the value doesn't "
|
||||
+ "match an unclipped ratio, even where the agrivalue is above the lower bound!"
|
||||
)
|
||||
|
||||
assert (
|
||||
df_nri[self.EXPECTED_AGRICULTURE_LOSS_RATE_FIELD_NAME]
|
||||
!= base_expectation
|
||||
).sum() > 0, "Clipping the agrivalue did nothing!"
|
||||
|
||||
# This produces a boolean that is True in the case of non-zero agricultural value
|
||||
df_nri[self.CONTAINS_AGRIVALUE] = (
|
||||
df_nri[self.AGRICULTURAL_VALUE_INPUT_FIELD_NAME] > 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue