Skip to content

Commit

Permalink
Fix tests and update coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jvivian committed Dec 7, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 6a07645 commit b61c887
Showing 3 changed files with 117 additions and 103 deletions.
Binary file modified .coverage
Binary file not shown.
209 changes: 111 additions & 98 deletions coverage.xml
Original file line number Diff line number Diff line change
@@ -1,153 +1,139 @@
<?xml version="1.0" ?>
<coverage version="7.3.1" timestamp="1701394738940" lines-valid="159" lines-covered="121" line-rate="0.761" branches-valid="54" branches-covered="41" branch-rate="0.7593" complexity="0">
<coverage version="7.3.1" timestamp="1701986374806" lines-valid="162" lines-covered="144" line-rate="0.8889" branches-valid="54" branches-covered="49" branch-rate="0.9074" complexity="0">
<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.3.1 -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
<sources>
<source>/home/jvivian/covid19-drDFM/covid19_drdfm</source>
<source>/Users/jvivian/Library/CloudStorage/GoogleDrive-jtvivian@gmail.com/My Drive/projects/covid19-drDFM/covid19_drdfm</source>
</sources>
<packages>
<package name="." line-rate="0.761" branch-rate="0.7593" complexity="0">
<package name="." line-rate="0.8889" branch-rate="0.9074" complexity="0">
<classes>
<class name="cli.py" filename="cli.py" complexity="0" line-rate="1" branch-rate="1">
<methods/>
<lines>
<line number="12" hits="1"/>
<line number="14" hits="1"/>
<line number="16" hits="1"/>
<line number="13" hits="1"/>
<line number="15" hits="1"/>
<line number="17" hits="1"/>
<line number="19" hits="1"/>
<line number="22" hits="1"/>
<line number="25" hits="1"/>
<line number="28" hits="1"/>
<line number="18" hits="1"/>
<line number="20" hits="1"/>
<line number="23" hits="1"/>
<line number="26" hits="1"/>
<line number="29" hits="1"/>
<line number="31" hits="1"/>
<line number="33" hits="1"/>
<line number="30" hits="1"/>
<line number="32" hits="1"/>
<line number="34" hits="1"/>
<line number="37" hits="1"/>
<line number="35" hits="1"/>
<line number="38" hits="1"/>
<line number="42" hits="1"/>
<line number="39" hits="1"/>
<line number="43" hits="1"/>
<line number="44" hits="1"/>
<line number="45" hits="1"/>
<line number="46" hits="1"/>
<line number="47" hits="1"/>
</lines>
</class>
<class name="constants.py" filename="constants.py" complexity="0" line-rate="1" branch-rate="1">
<methods/>
<lines>
<line number="1" hits="1"/>
<line number="56" hits="1"/>
<line number="113" hits="1"/>
<line number="128" hits="1"/>
<line number="147" hits="1"/>
</lines>
</class>
<class name="dfm.py" filename="dfm.py" complexity="0" line-rate="0.5957" branch-rate="0.5">
<class name="dfm.py" filename="dfm.py" complexity="0" line-rate="0.9118" branch-rate="0.7917">
<methods/>
<lines>
<line number="2" hits="1"/>
<line number="7" hits="1"/>
<line number="8" hits="1"/>
<line number="10" hits="1"/>
<line number="11" hits="1"/>
<line number="12" hits="1"/>
<line number="13" hits="1"/>
<line number="14" hits="1"/>
<line number="16" hits="1"/>
<line number="19" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="15" hits="1"/>
<line number="18" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="19" hits="1"/>
<line number="20" hits="1"/>
<line number="21" hits="1"/>
<line number="22" hits="1"/>
<line number="26" hits="1"/>
<line number="28" hits="1"/>
<line number="31" hits="1"/>
<line number="41" hits="1"/>
<line number="43" hits="1"/>
<line number="44" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="25" hits="1"/>
<line number="27" hits="1"/>
<line number="30" hits="1"/>
<line number="40" hits="1"/>
<line number="42" hits="1"/>
<line number="43" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="44" hits="1"/>
<line number="45" hits="1"/>
<line number="46" hits="1"/>
<line number="47" hits="1"/>
<line number="48" hits="1"/>
<line number="51" hits="1"/>
<line number="49" hits="1"/>
<line number="58" hits="1"/>
<line number="59" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="60" hits="1"/>
<line number="62" hits="1"/>
<line number="61" hits="1"/>
<line number="62" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="63" hits="1"/>
<line number="65" hits="1"/>
<line number="68" hits="1"/>
<line number="69" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="70" hits="1"/>
<line number="71" hits="1"/>
<line number="72" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="73" hits="1"/>
<line number="75" hits="1"/>
<line number="76" hits="1"/>
<line number="79" hits="1"/>
<line number="66" hits="1"/>
<line number="69" hits="1"/>
<line number="81" hits="1"/>
<line number="82" hits="1"/>
<line number="84" hits="1"/>
<line number="85" hits="1"/>
<line number="86" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="88" hits="1" branch="true" condition-coverage="50% (1/2)" missing-branches="89"/>
<line number="89" hits="0"/>
<line number="90" hits="0"/>
<line number="92" hits="1"/>
<line number="93" hits="1"/>
<line number="94" hits="1"/>
<line number="95" hits="1"/>
<line number="97" hits="1"/>
<line number="98" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="99" hits="1"/>
<line number="100" hits="1"/>
<line number="96" hits="0"/>
<line number="97" hits="0" branch="true" condition-coverage="0% (0/2)" missing-branches="98,99"/>
<line number="98" hits="0"/>
<line number="99" hits="0"/>
<line number="101" hits="1"/>
<line number="102" hits="1"/>
<line number="103" hits="1"/>
<line number="104" hits="1"/>
<line number="105" hits="1" branch="true" condition-coverage="50% (1/2)" missing-branches="106"/>
<line number="106" hits="0"/>
<line number="107" hits="1"/>
<line number="108" hits="1"/>
<line number="109" hits="0"/>
<line number="110" hits="0"/>
<line number="111" hits="1"/>
<line number="112" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="105" hits="1"/>
<line number="113" hits="1"/>
<line number="114" hits="1"/>
<line number="115" hits="0"/>
<line number="117" hits="0"/>
<line number="118" hits="0" branch="true" condition-coverage="0% (0/2)" missing-branches="119,120"/>
<line number="119" hits="0"/>
<line number="120" hits="0" branch="true" condition-coverage="0% (0/2)" missing-branches="121,122"/>
<line number="121" hits="0"/>
<line number="122" hits="0"/>
<line number="125" hits="1"/>
<line number="138" hits="0"/>
<line number="142" hits="0"/>
<line number="144" hits="0"/>
<line number="145" hits="0"/>
<line number="146" hits="0"/>
<line number="149" hits="0"/>
<line number="150" hits="0"/>
<line number="151" hits="0"/>
<line number="152" hits="0"/>
<line number="153" hits="0"/>
<line number="154" hits="0"/>
<line number="155" hits="0" branch="true" condition-coverage="0% (0/2)" missing-branches="156,157"/>
<line number="156" hits="0"/>
<line number="157" hits="0"/>
<line number="158" hits="0"/>
<line number="159" hits="0"/>
<line number="160" hits="0"/>
<line number="161" hits="0"/>
<line number="162" hits="0" branch="true" condition-coverage="0% (0/2)" missing-branches="163,164"/>
<line number="163" hits="0"/>
<line number="164" hits="0"/>
<line number="165" hits="0"/>
<line number="167" hits="0"/>
<line number="168" hits="0" branch="true" condition-coverage="0% (0/2)" missing-branches="169,170"/>
<line number="169" hits="0"/>
<line number="170" hits="0" branch="true" condition-coverage="0% (0/2)" missing-branches="171,172"/>
<line number="171" hits="0"/>
<line number="172" hits="0"/>
<line number="115" hits="1"/>
<line number="116" hits="1"/>
<line number="117" hits="1"/>
<line number="118" hits="1"/>
<line number="121" hits="1"/>
<line number="131" hits="1" branch="true" condition-coverage="50% (1/2)" missing-branches="136"/>
<line number="132" hits="1"/>
<line number="133" hits="1"/>
<line number="135" hits="1"/>
<line number="136" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="137" hits="1"/>
<line number="138" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="139" hits="1"/>
<line number="140" hits="1"/>
<line number="141" hits="1" branch="true" condition-coverage="50% (1/2)" missing-branches="exit"/>
<line number="142" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="143" hits="1"/>
</lines>
</class>
<class name="processing.py" filename="processing.py" complexity="0" line-rate="1" branch-rate="1">
<methods/>
<lines>
<line number="9" hits="1"/>
<line number="10" hits="1"/>
<line number="11" hits="1"/>
<line number="12" hits="1"/>
<line number="14" hits="1"/>
<line number="15" hits="1"/>
<line number="16" hits="1"/>
<line number="17" hits="1"/>
<line number="18" hits="1"/>
<line number="19" hits="1"/>
<line number="20" hits="1"/>
<line number="22" hits="1"/>
<line number="28" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="29" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="30" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="31" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="23" hits="1"/>
<line number="26" hits="1"/>
<line number="32" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="33" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="34" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="35" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="55" hits="1"/>
<line number="57" hits="1"/>
<line number="58" hits="1" branch="true" condition-coverage="100% (2/2)"/>
@@ -164,7 +150,7 @@
<line number="87" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="98" hits="1"/>
<line number="107" hits="1"/>
<line number="108" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="108" hits="1"/>
<line number="109" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="110" hits="1"/>
<line number="111" hits="1"/>
@@ -178,8 +164,35 @@
<line number="129" hits="1"/>
<line number="132" hits="1"/>
<line number="141" hits="1"/>
<line number="196" hits="1"/>
<line number="198" hits="1"/>
<line number="144" hits="1"/>
<line number="157" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="159" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="161" hits="1"/>
<line number="162" hits="1"/>
<line number="165" hits="1"/>
<line number="174" hits="1"/>
<line number="176" hits="1"/>
<line number="178" hits="1"/>
<line number="179" hits="1"/>
<line number="180" hits="1"/>
<line number="181" hits="1"/>
</lines>
</class>
<class name="scm.py" filename="scm.py" complexity="0" line-rate="0" branch-rate="1">
<methods/>
<lines>
<line number="1" hits="0"/>
<line number="3" hits="0"/>
<line number="4" hits="0"/>
<line number="5" hits="0"/>
<line number="8" hits="0"/>
<line number="9" hits="0"/>
<line number="13" hits="0"/>
<line number="14" hits="0"/>
<line number="16" hits="0"/>
<line number="17" hits="0"/>
<line number="18" hits="0"/>
<line number="21" hits="0"/>
</lines>
</class>
</classes>
11 changes: 6 additions & 5 deletions tests/test_processing.py
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import pandas as pd
import pytest

from covid19_drdfm.constants import NAME_MAP
from covid19_drdfm.processing import (
DATA_DIR,
ROOT_DIR,
@@ -34,8 +35,8 @@ def test_get_govt_fund_dist():
assert int(sum(govt_fund) + 0.00001) == 1, "Distribution must sum to 1"


def test_adjust_inflation(sample_data):
input_df = sample_data.copy()
def test_adjust_inflation(raw_data):
input_df = raw_data.copy()
output_df = adjust_inflation(input_df)
assert input_df.Demand_1.iloc[0] < output_df.Demand_1.iloc[0]

@@ -45,9 +46,9 @@ def test_adjust_pandemic_response(sample_data):
#! Note - this is testing functionality, but is used per-state not on whole df
out = adjust_pandemic_response(input_df)
df = get_df()
responses = [f"Pandemic_Response_{x}" for x in [13, 14, 15]]
responses = [NAME_MAP[f"Pandemic_Response_{x}"] for x in [13, 14, 15]]
for r in responses:
assert df[r].sum() == out[r].sum()
assert int(df[r].sum()) == int(out[r].sum())


def test_fix_datetime(raw_data):
@@ -58,7 +59,7 @@ def test_fix_datetime(raw_data):

def test_run():
df = get_df()
expected_columns = ["State", "Supply_1", "Demand_1", "Pandemic_Response_13", "Time"]
expected_columns = ["State", "GDP", "Deaths1"]
assert all(col in df.columns for col in expected_columns)


0 comments on commit b61c887

Please sign in to comment.