fix show indices (#4604)

This commit is contained in:
montezdesousa
2023-03-28 15:38:37 +01:00
committed by GitHub
parent 2b6bbca775
commit 73f6184800
2 changed files with 5 additions and 15 deletions

View File

@@ -4,7 +4,7 @@ __docformat__ = "numpy"
import logging
import os
from typing import Optional, Tuple, Union
from typing import Optional, Union
import pandas as pd
@@ -34,7 +34,7 @@ def show_indices(
export: str = "",
sheet_name: Optional[str] = None,
limit: int = 10,
) -> Union[pd.DataFrame, Tuple[pd.DataFrame, OpenBBFigure]]:
) -> Union[pd.DataFrame, OpenBBFigure]:
"""Load (and show) the selected indices over time [Source: Yahoo Finance]
Parameters
----------
@@ -107,8 +107,6 @@ def show_indices(
if len(indices) < 2:
fig.update_layout(title=f"{' - '.join(new_title)}", yaxis=dict(side="right"))
fig.show(external=external_axes)
if raw:
# was a -iloc so we need to flip the index as we use head
indices_data = indices_data.sort_index(ascending=False)
@@ -131,10 +129,7 @@ def show_indices(
fig,
)
if (output := indices_data) is not None and external_axes:
output = (indices_data, fig.show(external=external_axes))
return output
return fig.show(external=external_axes)
@log_start_end(log=logger)

View File

@@ -1,7 +1,6 @@
# IMPORTATION STANDARD
# IMPORTATION THIRDPARTY
import pandas as pd
import pytest
import yfinance
@@ -45,12 +44,10 @@ def test_show_indices(
return yf_download(*args, **kwargs)
mocker.patch("yfinance.download", side_effect=mock_yf_download)
result_df = yfinance_view.show_indices(
yfinance_view.show_indices(
indices, interval, start_date, end_date, column, returns, store
)
assert isinstance(result_df, pd.DataFrame)
@pytest.mark.skip
@pytest.mark.vcr
@@ -78,12 +75,10 @@ def test_show_indices_returns(
return yf_download(*args, **kwargs)
mocker.patch("yfinance.download", side_effect=mock_yf_download)
result_df = yfinance_view.show_indices(
yfinance_view.show_indices(
indices, interval, start_date, end_date, column, returns, store
)
assert isinstance(result_df, pd.DataFrame)
@pytest.mark.vcr
@pytest.mark.record_stdout