Skip to content

Commit fe3b1d2

Browse files
author
88d52bdba0366127fffca9dfa93895
committed
isort; edit workflow
1 parent 4865958 commit fe3b1d2

30 files changed

+102
-75
lines changed

.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
max-line-length = 88
3+
extend-ignore = E203

.github/workflows/main.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
14
name: pytest
5+
26
on:
3-
pull_request:
4-
push:
5-
branches:
6-
- master
7+
push:
8+
branches: [ "master" ]
9+
pull_request:
10+
branches: [ "master" ]
711

812
jobs:
913
pytest:
@@ -28,7 +32,16 @@ jobs:
2832
- name: Install dependencies
2933
run: |
3034
pip install -r requirements.txt
35+
pip install pytest isort black flake8
3136
- name: Test with pytest
3237
run: |
33-
pip install pytest
34-
pytest ./tests
38+
pytest ./tests
39+
- name: Check with isort
40+
run: |
41+
isort --check --diff .
42+
- name: Check with black
43+
run: |
44+
black --check --diff .
45+
- name: Check with flake8
46+
run: |
47+
flake8 --show-source --statistics .

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.git
12
*.pyc
23
.idea
34
build

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# All configuration values have a default; values that are commented out
1414
# serve to show the default.
1515

16-
import sys
1716
import os
17+
import sys
1818

1919
# If extensions (or modules to document with autodoc) are in another directory,
2020
# add these directories to sys.path here. If the directory is relative to the

example/examples.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
import pandas as pd
2-
import numpy as np
31
import cvxpy as cp
4-
from pypfopt import risk_models
5-
from pypfopt import expected_returns
6-
from pypfopt import EfficientFrontier
7-
from pypfopt import objective_functions
8-
from pypfopt.discrete_allocation import DiscreteAllocation, get_latest_prices
9-
from pypfopt import HRPOpt
10-
from pypfopt import CLA
11-
from pypfopt import black_litterman
12-
from pypfopt import BlackLittermanModel
13-
from pypfopt import plotting
2+
import numpy as np
3+
import pandas as pd
144

5+
from pypfopt import (
6+
CLA,
7+
BlackLittermanModel,
8+
EfficientFrontier,
9+
HRPOpt,
10+
black_litterman,
11+
expected_returns,
12+
objective_functions,
13+
plotting,
14+
risk_models,
15+
)
16+
from pypfopt.discrete_allocation import DiscreteAllocation, get_latest_prices
1517

1618
# Reading in the data; preparing expected returns and a risk model
1719
df = pd.read_csv("tests/resources/stock_prices.csv", parse_dates=True, index_col="date")

pypfopt/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
from .black_litterman import (
2+
BlackLittermanModel,
23
market_implied_prior_returns,
34
market_implied_risk_aversion,
4-
BlackLittermanModel,
55
)
66
from .cla import CLA
7-
from .discrete_allocation import get_latest_prices, DiscreteAllocation
7+
from .discrete_allocation import DiscreteAllocation, get_latest_prices
88
from .efficient_frontier import (
9+
EfficientCDaR,
10+
EfficientCVaR,
911
EfficientFrontier,
1012
EfficientSemivariance,
11-
EfficientCVaR,
12-
EfficientCDaR,
1313
)
1414
from .hierarchical_portfolio import HRPOpt
1515
from .risk_models import CovarianceShrinkage
1616

17-
1817
__version__ = "1.5.4"
1918

2019
__all__ = [

pypfopt/base_optimizer.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@
1313
from collections.abc import Iterable
1414
from typing import List
1515

16+
import cvxpy as cp
1617
import numpy as np
1718
import pandas as pd
18-
import cvxpy as cp
1919
import scipy.optimize as sco
2020

21-
from . import objective_functions
22-
from . import exceptions
21+
from . import exceptions, objective_functions
2322

2423

2524
class BaseOptimizer:

pypfopt/black_litterman.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
"""
99
import sys
1010
import warnings
11+
1112
import numpy as np
1213
import pandas as pd
14+
1315
from . import base_optimizer
1416

1517

pypfopt/cla.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import numpy as np
88
import pandas as pd
9+
910
from . import base_optimizer
1011

1112

pypfopt/efficient_frontier/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
which generate optimal portfolios for various possible objective functions and parameters.
44
"""
55

6-
from .efficient_frontier import EfficientFrontier
6+
from .efficient_cdar import EfficientCDaR
77
from .efficient_cvar import EfficientCVaR
8+
from .efficient_frontier import EfficientFrontier
89
from .efficient_semivariance import EfficientSemivariance
9-
from .efficient_cdar import EfficientCDaR
10-
1110

1211
__all__ = [
1312
"EfficientFrontier",

0 commit comments

Comments
 (0)