The package currently has no tests. Every refactor in the modernization tiers (#41, #42, #43) is risky without them, and users keep hitting correctness questions (#8, #19, #21, #23, #25, #38, #39) that we can't answer decisively without reproducible fixtures.
Goals
- Lock in current behavior before we refactor, so we can prove "no behavior change" commits.
- Cover the known numerical pitfalls so correctness regressions are caught automatically.
- Run in CI on every PR.
Scope
Infrastructure
Fixtures
Unit tests
Integration / golden tests
Property tests (hypothesis)
Edge cases from open issues
Acceptance
pytest runs clean locally and in CI.
- Coverage ≥ 80% on
ecomplexity/.
- Regression test catches at least one of the known open bugs (used as a red-green check).
The package currently has no tests. Every refactor in the modernization tiers (#41, #42, #43) is risky without them, and users keep hitting correctness questions (#8, #19, #21, #23, #25, #38, #39) that we can't answer decisively without reproducible fixtures.
Goals
Scope
Infrastructure
pytest,pytest-cov, andhypothesis(for property tests) as a[test]extra.tests/directory layout;conftest.pywith fixtures.Fixtures
mainon a real sample (e.g. a subset of SITC 2-digit) and snapshot the output dataframe. Compare to tolerance on every PR.Unit tests
calculate_rca— verify against hand-computed values on the synthetic fixture.calculate_rpop— including the zero-population edge case (RPOP - Handling zeros in diversity / ubiquity #22).calculate_mcp— discrete thresholding,presence_test="both"behavior, and manual-MCP validation error atComplexityData.py:158-164.calc_discrete_proximity/calc_continuous_proximity— including whether diagonal should be zero (Proximity matrix diagonal should be set to 0 #38).calc_densitywith and withoutknn; regression test for the integer-output bug (Using knn option gives integer density outputs #35).calc_eci_pci— eigenvector sign convention, NaN reinsertion for zero-diversity rows, normalization formula (PCI calculation. #19, Possible mistake in the code of ecomplexity.py #23, PCI normalization using wrong mean and standard deviation. #25).calc_coi_cog.Integration / golden tests
ecomplexity()end-to-end on the synthetic fixture; assert column set, dtypes, and values to tolerance.Property tests (hypothesis)
asymmetric=Falseand has values in [0, 1].Edge cases from open issues
knnoption should return floats, not ints.Acceptance
pytestruns clean locally and in CI.ecomplexity/.