External testing found that attempting to compute categorical metrics using contingency tables with zero-valued components resulted in a ZeroDivision error. This behavior was undesirable for downstream users and inconsistent with the behavior of other packages used by hydrotools. This update introduces conversion of contingency table components to numpy.float64 scalars. This has the advantage of inheriting all of the numpy built-in value checking, including raising a RuntimeWarning in the event of division by zero, instead of raising an error.
Additions
convert_mapping_values is a new method used to convert dict-like objects to numpy DTypeLike values.
Removals
None
Changes
Categorical methods all start by calling convert_mapping_values on the input contingency table.
Testing
Explicit tests with null or zero-valued contingency table components
Adding test scenarios for null or zero-valued continuous metrics
convert_mapping_values is specifically tested using a pandas.Series
Notes
None
Todos
None
Checklist
[x] PR has an informative and human-readable title
[x] PR is well outlined and documented. See #12 for an example
[x] Changes are limited to a single goal (no scope creep)
[x] Code can be automatically merged (no conflicts)
External testing found that attempting to compute categorical metrics using contingency tables with zero-valued components resulted in a
ZeroDivision
error. This behavior was undesirable for downstream users and inconsistent with the behavior of other packages used byhydrotools
. This update introduces conversion of contingency table components tonumpy.float64
scalars. This has the advantage of inheriting all of thenumpy
built-in value checking, including raising aRuntimeWarning
in the event of division by zero, instead of raising an error.Additions
convert_mapping_values
is a new method used to convert dict-like objects to numpyDTypeLike
values.Removals
Changes
convert_mapping_values
on the input contingency table.Testing
convert_mapping_values
is specifically tested using apandas.Series
Notes
Todos
Checklist