Skip to content

Commit

Permalink
add debug (#570)
Browse files Browse the repository at this point in the history
* fix plotting and warning

---------

Co-authored-by: 88d52bdba0366127fffca9dfa93895 <tuan.tran@datanest.vn>
  • Loading branch information
88d52bdba0366127fffca9dfa93895 and 88d52bdba0366127fffca9dfa93895 committed Dec 6, 2023
1 parent 4495242 commit d588285
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pypfopt/cla.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def _compute_lambda(self, covarF_inv, covarFB, meanF, wB, i, bi):
if c == 0: # pragma: no cover
return None, None
# 2) bi
if type(bi) == list:
if isinstance(bi, list):
bi = self._compute_bi(c, bi)
# 3) Lambda
if wB is None:
Expand Down
2 changes: 1 addition & 1 deletion pypfopt/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def plot_dendrogram(hrp, ax=None, show_tickers=True, **kwargs):

if hrp.clusters is None:
warnings.warn(
"hrp param has not been optimized. Attempting optimization.",
"hrp param has not been optimized. Attempting optimization.",
RuntimeWarning,
)
hrp.optimize()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_efficient_frontier.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ def test_efficient_risk_market_neutral_L2_reg():


def test_efficient_risk_market_neutral_warning():
ef = setup_efficient_frontier()
ef = setup_efficient_frontier(solver=cp.ECOS)
with pytest.warns(RuntimeWarning) as w:
ef.efficient_risk(0.19, market_neutral=True)
assert len(w) == 1
Expand Down Expand Up @@ -1183,7 +1183,7 @@ def test_efficient_return_market_neutral_unbounded():

def test_efficient_return_market_neutral_warning():
# This fails
ef = setup_efficient_frontier()
ef = setup_efficient_frontier(solver=cp.ECOS)
with pytest.warns(RuntimeWarning) as w:
ef.efficient_return(0.25, market_neutral=True)
assert len(w) == 1
Expand Down
4 changes: 2 additions & 2 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ def test_dendrogram_plot():
hrp = HRPOpt(returns)
with pytest.warns(RuntimeWarning) as w:
ax = plotting.plot_dendrogram(hrp, show_tickers=False, showfig=False)
assert len(w) == 1
assert len(w) <= 2 # the second is FutureWarning if exists
assert (
str(w[0].message)
== "hrp param has not been optimized. Attempting optimization."
== "hrp param has not been optimized. Attempting optimization."
)
assert len(ax.findobj()) > 60
assert type(ax.findobj()[0]) == matplotlib.collections.LineCollection
Expand Down

0 comments on commit d588285

Please sign in to comment.