Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored master branch #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Sep 30, 2022

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

Comment on lines -2 to +7
tickers_str = ""
t_number = len(tickers_list)
for i, ticker in enumerate(tickers_list):
tickers_str += f"{ticker}," if i + 1 < t_number else ticker
tickers_str = "".join(
f"{ticker}," if i + 1 < t_number else ticker
for i, ticker in enumerate(tickers_list)
)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function create_link refactored with the following changes:

div = html.Div(
return html.Div(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function create_copy_link_div refactored with the following changes:

Comment on lines -50 to -54
info_table = dash_table.DataTable(
return dash_table.DataTable(
data=info_list,
style_data={"whiteSpace": "normal", "height": "auto"},
)
return info_table
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_info refactored with the following changes:

Comment on lines -35 to +42
page = dbc.Container(
return dbc.Container(
[
dbc.Row(
[
dbc.Col(card_controls(tickers, first_date, last_date, ccy), lg=7),
dbc.Col(
card_controls(tickers, first_date, last_date, ccy),
lg=7,
),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function layout refactored with the following changes:

Comment on lines -134 to +136
real = False if plot_type == "cagr" else True
real = plot_type != "cagr"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_al_figure refactored with the following changes:

Comment on lines -299 to +307
is_correct_number = number in range(0, settings.MC_MAX) and isinstance(number, int)
is_correct_number = number in range(settings.MC_MAX) and isinstance(
number, int
)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function check_validity_monte_carlo refactored with the following changes:

Comment on lines -33 to +40
page = dbc.Container(
return dbc.Container(
[
dbc.Row(
[
dbc.Col(card_controls(tickers, first_date, last_date, ccy), lg=5),
dbc.Col(
card_controls(tickers, first_date, last_date, ccy),
lg=5,
),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function layout refactored with the following changes:

Comment on lines -142 to +144
real = False if plot_type == "cagr" else True
real = plot_type != "cagr"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_pf_figure refactored with the following changes:

Comment on lines -39 to +65
# tickers_list = get_tickers_list(tickers)
card = dbc.Card(
return dbc.Card(
dbc.CardBody(
[
html.H5("Investment Portfolio", className="card-title"),
html.Div(
[
dbc.Row([
dbc.Col(html.Label("Tickers")),
dbc.Col(html.Label("Weights"))
]),
dbc.Row(
[
dbc.Col(html.Label("Tickers")),
dbc.Col(html.Label("Weights")),
]
),
html.Div(id='dynamic-container', children=[]),
dbc.Row([
dbc.Col(dbc.Button("Add Asset", id="dynamic-add-filter", n_clicks=0)),
dbc.Col(html.Div(id="pf-portfolio-weights-sum"))
]),

dbc.Row(
[
dbc.Col(
dbc.Button(
"Add Asset",
id="dynamic-add-filter",
n_clicks=0,
)
),
dbc.Col(
html.Div(id="pf-portfolio-weights-sum")
),
]
),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function card_controls refactored with the following changes:

This removes the following comments ( why? ):

# tickers_list = get_tickers_list(tickers)
#     # copy link to clipboard button
# dbc.Row(
#         button_id="pf-copy-link-button",
#     create_copy_link_div(
#     ),
#         card_name="asset list",
#         location_id="pf-url",
# ),
#         hidden_div_with_url_id="pf-show-url",

not_allocated_weight = 100 - weights_sum if 100 - weights_sum > 0 else 0
not_allocated_weight = 100 - weights_sum if weights_sum < 100 else 0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function generate_chart refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Sep 30, 2022

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.51%.

Quality metrics Before After Change
Complexity 3.59 ⭐ 3.25 ⭐ -0.34 👍
Method Length 135.30 😞 134.30 😞 -1.00 👍
Working memory 8.96 🙂 8.90 🙂 -0.06 👍
Quality 63.02% 🙂 63.53% 🙂 0.51% 👍
Other metrics Before After Change
Lines 1579 1629 50
Changed files Quality Before Quality After Quality Change
common/create_link.py 67.43% 🙂 65.49% 🙂 -1.94% 👎
common/html_elements/copy_link_div.py 75.35% ⭐ 78.22% ⭐ 2.87% 👍
common/html_elements/info_dash_table.py 70.23% 🙂 70.72% 🙂 0.49% 👍
pages/compare/compare.py 53.55% 🙂 54.85% 🙂 1.30% 👍
pages/compare/cards_compare/asset_list_controls.py 75.40% ⭐ 77.14% ⭐ 1.74% 👍
pages/efficient_frontier/frontier.py 51.47% 🙂 51.06% 🙂 -0.41% 👎
pages/efficient_frontier/cards_efficient_frontier/ef_controls.py 78.12% ⭐ 79.96% ⭐ 1.84% 👍
pages/portfolio/portfolio.py 52.69% 🙂 54.01% 🙂 1.32% 👍
pages/portfolio/cards_portfolio/portfolio_controls.py 78.98% ⭐ 79.88% ⭐ 0.90% 👍
pages/portfolio/cards_portfolio/portfolio_info.py 70.53% 🙂 70.65% 🙂 0.12% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
pages/efficient_frontier/frontier.py make_ef_figure 8 ⭐ 434 ⛔ 13 😞 37.63% 😞 Try splitting into smaller methods. Extract out complex expressions
pages/compare/compare.py get_al_figure 9 🙂 237 ⛔ 11 😞 45.29% 😞 Try splitting into smaller methods. Extract out complex expressions
pages/portfolio/portfolio.py get_pf_figure 9 🙂 237 ⛔ 11 😞 45.29% 😞 Try splitting into smaller methods. Extract out complex expressions
pages/portfolio/portfolio.py update_graf_portfolio 0 ⭐ 234 ⛔ 15 😞 48.27% 😞 Try splitting into smaller methods. Extract out complex expressions
pages/efficient_frontier/frontier.py update_ef_cards 1 ⭐ 221 ⛔ 12 😞 52.31% 🙂 Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants