Skip to content

Commit

Permalink
Changed format so it fits numpydoc
Browse files Browse the repository at this point in the history
  • Loading branch information
Divasco committed Aug 25, 2024
1 parent d288bcd commit aea0545
Show file tree
Hide file tree
Showing 22 changed files with 222 additions and 165 deletions.
4 changes: 1 addition & 3 deletions garpar/core/_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ def coerce_expected_returns(self, expected_returns, kw, asarray=True):
"""
if isinstance(expected_returns, str):
kw = {} if kw is None else kw
expected_returns = self._pf.ereturns(
expected_returns.lower(), **kw
)
expected_returns = self._pf.ereturns(expected_returns.lower(), **kw)
return np.asarray(expected_returns) if asarray else expected_returns

def coerce_weights(self, weights, asarray=True):
Expand Down
14 changes: 5 additions & 9 deletions garpar/core/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Portfolio:
Accessor for utility-related operations.
diversification : DiversificationAccessor
Accessor for diversification-related operations.
Methods
-------
__attrs_post_init__()
Expand Down Expand Up @@ -143,9 +143,7 @@ class Portfolio:
_prices_df = attr.ib(validator=vldt.instance_of(pd.DataFrame))
_weights = attr.ib(converter=_as_float_array)
_entropy = attr.ib(converter=_as_float_array)
_window_size = attr.ib(
converter=lambda v: (None if pd.isna(v) else int(v))
)
_window_size = attr.ib(converter=lambda v: (None if pd.isna(v) else int(v)))
_metadata = attr.ib(factory=dict, converter=lambda d: Bunch("metadata", d))

# accessors
Expand Down Expand Up @@ -198,7 +196,7 @@ class Portfolio:

def __attrs_post_init__(self):
"""Initialize additional attributes and performs validation.
Raises
------
ValueError
Expand Down Expand Up @@ -462,7 +460,7 @@ def shape(self):

# UTILS ===================================================================
def copy(
self,
self,
*,
prices=None,
weights=None,
Expand Down Expand Up @@ -503,9 +501,7 @@ def copy(
self._window_size if window_size is None else window_size
)

new_metadata = (
self._metadata.to_dict() if preserve_old_metadata else {}
)
new_metadata = self._metadata.to_dict() if preserve_old_metadata else {}
new_metadata.update(metadata)

new_pf = self.from_dfkws(
Expand Down
2 changes: 1 addition & 1 deletion garpar/core/prices_acc.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def mad(self, skipna=True):
----------
skipna : bool, default True
Exclude NA/null values when computing the result.
Returns
-------
Series
Expand Down
6 changes: 2 additions & 4 deletions garpar/datasets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class PortfolioMakerABC(mabc.ModelABC):

def __init_subclass__(cls):
"""Ensure that the make_portfolio method in subclasses conforms to _MKPORT_SIGNATURE.
Raises
------
TypeError
Expand Down Expand Up @@ -321,9 +321,7 @@ def _make_stock(
DataFrame containing the stock prices for each day.
"""
# determinamos que dia se pierde y que dia se gana
loss_sequence = self._make_loss_sequence(
days, loss_probability, random
)
loss_sequence = self._make_loss_sequence(days, loss_probability, random)

# fijamos el primer precio como el precio orginal
current_price = initial_price
Expand Down
Loading

0 comments on commit aea0545

Please sign in to comment.