Skip to content

Commit

Permalink
fixed a few tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rwijtvliet committed Nov 11, 2024
1 parent c0181d2 commit 65e7eea
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
3 changes: 1 addition & 2 deletions portfolyo/core/pfline/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def pfl_as_string(
lines.extend(shared_text.index_info(pfl.index))
if isinstance(pfl, classes.NestedPfLine):
lines.extend(_children_info(pfl))
cols = pfl.kind.available
if flatten:
lines.extend(shared_text.dataheader(cols_and_units))
lines.extend([""])
Expand All @@ -117,7 +116,7 @@ def pfl_as_string(
lines.extend(
[spaces + txtline for txtline in shared_text.dataheader(cols_and_units)]
)
lines.extend(nestedtree("(this pfline)", pfl, cols, num_of_ts))
lines.extend(nestedtree("(this pfline)", pfl, cols_and_units, num_of_ts))
txt = "\n".join(lines)
return txt if color else shared_text.remove_color(txt)

Expand Down
11 changes: 9 additions & 2 deletions portfolyo/core/pfstate/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ def pfs_as_string(pfs: PfState, num_of_ts: int, color: bool) -> str:
lines.extend(
[spaces + txtline for txtline in shared_text.dataheader(cols_and_units)]
)
lines.extend(pfline_text.nestedtree("offtake", pfs.offtakevolume, "wq", num_of_ts))
lines.extend(pfline_text.nestedtree("pnl_cost", pfs.pnl_cost, "wqpr", num_of_ts))
volume_cols_and_units = {c: cols_and_units[c] for c in ["w", "q"]}
lines.extend(
pfline_text.nestedtree(
"offtake", pfs.offtakevolume, volume_cols_and_units, num_of_ts
)
)
lines.extend(
pfline_text.nestedtree("pnl_cost", pfs.pnl_cost, cols_and_units, num_of_ts)
)
txt = "\n".join(lines)
return txt if color else shared_text.remove_color(txt)

Expand Down
16 changes: 8 additions & 8 deletions tests/core/pfline/test_interop.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import pandas as pd
import pytest
from pint import DimensionalityError, UndefinedUnitError
from pint import DimensionalityError
from utils import id_fn # relative to /tests

from portfolyo.core.pfline import interop as io
Expand Down Expand Up @@ -91,12 +91,12 @@
# B) Cannot create InterOp-object: no key, invalid unit.
(
Q_(4.5, "MWh/Eur"),
UndefinedUnitError,
ValueError,
None,
),
(
s1.astype("pint[Wh/MEur]"),
UndefinedUnitError,
ValueError,
None,
),
# C) Cannot create InterOp-object: key(s) with at least one missing unit.
Expand Down Expand Up @@ -203,17 +203,17 @@
# D) Cannot create InterOp-object: key(s) with at least one incompatible unit.
(
{"w": Q_(90.0, "MWh")},
AttributeError,
DimensionalityError,
None,
),
(
pd.Series({"w": Q_(90.0, "MWh")}),
AttributeError,
DimensionalityError,
None,
),
(
pd.Series({"w": 90}).astype("pint[MWh]"),
AttributeError,
DimensionalityError,
None,
),
(
Expand All @@ -228,12 +228,12 @@
),
(
{"p": Q_(90.0, "MWh")},
AttributeError,
DimensionalityError,
None,
),
(
pd.Series({"p": Q_(90.0, "MWh")}),
AttributeError,
DimensionalityError,
None,
),
(
Expand Down
2 changes: 1 addition & 1 deletion tests/tools/test_right.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def do_test_index(ts, freq, tz, expected_ts_right, periods):
pd.Timestamp(expected_ts_right, tz=tz), freq=freq, periods=periods, name="right"
)
testing.assert_index_equal(result, expected)
tools.standardize.assert_index_standardized(result, __right=True)
testing.assert_index_standardized(result)


def do_test_stamp(ts, freq, tz, expected_ts_right):
Expand Down

0 comments on commit 65e7eea

Please sign in to comment.