2bda7e5dd9e0b232caca4a71b08bc7ccf8661a7d,pypfopt/efficient_frontier.py,EfficientFrontier,max_sharpe,#EfficientFrontier#Any#,155
Before Change
]
// Rebuild original constraints with scaling factor
for raw_constr in self._additional_constraints_raw:
self._constraints.append(raw_constr(self._w / k))
// Sharpe ratio is invariant w.r.t scaled weights, so we must
// replace infinities and negative infinities
// new_lower_bound = np.nan_to_num(self._lower_bounds, neginf=-1)
// new_upper_bound = np.nan_to_num(self._upper_bounds, posinf=1)
After Change
new_constraints = []
// Must rebuild the constraints
for constr in self._constraints:
if isinstance(constr, cp.constraints.nonpos.Inequality):
// Either the first or second item is the expression
if isinstance(
constr.args[0], cp.expressions.constants.constant.Constant
):
new_constraints.append(constr.args[1] >= constr.args[0] * k)
else:
new_constraints.append(constr.args[0] <= constr.args[1] * k)
elif isinstance(constr, cp.constraints.zero.Equality):
new_constraints.append(constr.args[0] == constr.args[1] * k)
else:
raise TypeError(
"Please check that your constraints are in a suitable format"
)
// Transformed max_sharpe convex problem:
self._constraints = [
(self.expected_returns - risk_free_rate).T * self._w == 1,
cp.sum(self._w) == k,
k >= 0,
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 5
Instances Project Name: robertmartin8/PyPortfolioOpt
Commit Name: 2bda7e5dd9e0b232caca4a71b08bc7ccf8661a7d
Time: 2020-04-28
Author: martin.robertandrew@gmail.com
File Name: pypfopt/efficient_frontier.py
Class Name: EfficientFrontier
Method Name: max_sharpe
Project Name: daavoo/pyntcloud
Commit Name: 2d2a5f4ebe7cac71062f0be54f3272dc0a6af690
Time: 2016-11-03
Author: daviddelaiglesiacastro@gmail.com
File Name: pyntcloud/structures/voxelgrid.py
Class Name: VoxelGrid
Method Name: __init__
Project Name: tyarkoni/pliers
Commit Name: 005968dcfbd2a8f70d8ea3957c8abba60a12492d
Time: 2018-05-15
Author: quinten.mcnamara@gmail.com
File Name: pliers/filters/video.py
Class Name: FrameSamplingFilter
Method Name: _filter