Skip to content

Commit

Permalink
debugging coverage tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qnguyen345 committed Aug 19, 2024
1 parent 37ded43 commit 36fdfeb
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions pvanalytics/tests/quality/test_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,23 @@ def simple_diff_energy_series():


@pytest.fixture
def avg_diff_energy_series():
def alt_cumulative_series():
"""
The differenced pandas energy series using averaged difference method.
A cumulative energy series.
"""
diff_data = energy_df["ac_energy_inv_16425"].diff()
avg_diff_series = 0.5 * (diff_data.shift(-1) + diff_data)
return pd.Series(data=avg_diff_series)
cumulative_series = pd.Series([1.5, 1, 2, 5, 8])
return cumulative_series


@pytest.fixture
def alt_avg_diff_series():
"""
The average differene energy series.
"""
cumulative_series = pd.Series([1.5, 1, 2, 5, 8])
avg_diff_series = 0.5 * \
(cumulative_series.diff().shift(-1) + cumulative_series.diff())
return pd.Series(avg_diff_series)


def test_cumulative_energy_simple_diff_check_true(cumulative_series):
Expand Down Expand Up @@ -123,17 +133,15 @@ def test_convert_cumulative_with_simple_diff(cumulative_series,
assert_series_equal(simple_diff_result, simple_diff_energy_series)


def test_convert_cumulative_with_avg_diff():
def test_convert_cumulative_with_avg_diff(alt_cumulative_series,
alt_avg_diff_series):
"""
Tests convert_cumulative_energy for cumulative series.
Test returns the corrected differenced series via avgerage differencing.
Test returns the corrected differenced series via average differencing.
"""
cumulative_series = pd.Series([1.5, 1, 2, 5, 8])
avg_diff_series = 0.5 * \
(cumulative_series.diff().shift(-1) + cumulative_series.diff())
simple_diff_result = energy.convert_cumulative_energy(
energy_series=cumulative_series, system_self_consumption=0.0)
assert_series_equal(simple_diff_result, avg_diff_series)
energy_series=alt_cumulative_series, system_self_consumption=0.0)
assert_series_equal(simple_diff_result, alt_avg_diff_series)


def test_convert_noncumulative(noncumulative_series):
Expand Down

0 comments on commit 36fdfeb

Please sign in to comment.