@@ -122,7 +122,7 @@ def test_default_ef_plot():
122122def test_ef_plot_utility ():
123123 plt .figure ()
124124 ef = setup_efficient_frontier ()
125- delta_range = np .arange (0.001 , 100 , 1 )
125+ delta_range = np .arange (0.001 , 50 , 1 )
126126 ax = plotting .plot_efficient_frontier (
127127 ef , ef_param = "utility" , ef_param_range = delta_range , showfig = False
128128 )
@@ -134,15 +134,15 @@ def test_ef_plot_utility():
134134def test_ef_plot_errors ():
135135 plt .figure ()
136136 ef = setup_efficient_frontier ()
137- delta_range = np .arange (0.001 , 100 , 1 )
137+ delta_range = np .arange (0.001 , 50 , 1 )
138138 # Test invalid ef_param
139139 with pytest .raises (NotImplementedError ):
140- ax = plotting .plot_efficient_frontier (
140+ plotting .plot_efficient_frontier (
141141 ef , ef_param = "blah" , ef_param_range = delta_range , showfig = False
142142 )
143143 # Test invalid optimizer
144144 with pytest .raises (NotImplementedError ):
145- ax = plotting .plot_efficient_frontier (
145+ plotting .plot_efficient_frontier (
146146 None , ef_param_range = delta_range , showfig = False
147147 )
148148 plt .clf ()
@@ -156,7 +156,7 @@ def test_ef_plot_risk():
156156 min_risk = ef .portfolio_performance ()[1 ]
157157
158158 ef = setup_efficient_frontier ()
159- risk_range = np .linspace (min_risk + 0.05 , 0.5 , 50 )
159+ risk_range = np .linspace (min_risk + 0.05 , 0.5 , 30 )
160160 ax = plotting .plot_efficient_frontier (
161161 ef , ef_param = "risk" , ef_param_range = risk_range , showfig = False
162162 )
@@ -168,10 +168,9 @@ def test_ef_plot_risk():
168168def test_ef_plot_return ():
169169 plt .figure ()
170170 ef = setup_efficient_frontier ()
171- # FIXME: Internally _max_return() is used, which uses a solver so can have numerical differences to the inputs.
172- # hence the epsilon here
171+ # Internally _max_return() is used, so subtract epsilon
173172 max_ret = ef .expected_returns .max () - 0.0001
174- return_range = np .linspace (0 , max_ret , 50 )
173+ return_range = np .linspace (0 , max_ret , 30 )
175174 ax = plotting .plot_efficient_frontier (
176175 ef , ef_param = "return" , ef_param_range = return_range , showfig = False
177176 )
@@ -185,7 +184,7 @@ def test_ef_plot_utility_short():
185184 ef = EfficientFrontier (
186185 * setup_efficient_frontier (data_only = True ), weight_bounds = (None , None )
187186 )
188- delta_range = np .linspace (0.001 , 20 , 100 )
187+ delta_range = np .linspace (0.001 , 20 , 50 )
189188 ax = plotting .plot_efficient_frontier (
190189 ef , ef_param = "utility" , ef_param_range = delta_range , showfig = False
191190 )
@@ -201,7 +200,7 @@ def test_constrained_ef_plot_utility():
201200 ef .add_constraint (lambda w : w [2 ] == 0.15 )
202201 ef .add_constraint (lambda w : w [3 ] + w [4 ] <= 0.10 )
203202
204- delta_range = np .linspace (0.001 , 20 , 100 )
203+ delta_range = np .linspace (0.001 , 20 , 50 )
205204 ax = plotting .plot_efficient_frontier (
206205 ef , ef_param = "utility" , ef_param_range = delta_range , showfig = False
207206 )
@@ -221,7 +220,7 @@ def test_constrained_ef_plot_risk():
221220 ef .add_constraint (lambda w : w [3 ] + w [4 ] <= 0.10 )
222221
223222 # 100 portfolios with risks between 0.10 and 0.30
224- risk_range = np .linspace (0.157 , 0.40 , 100 )
223+ risk_range = np .linspace (0.157 , 0.40 , 50 )
225224 ax = plotting .plot_efficient_frontier (
226225 ef , ef_param = "risk" , ef_param_range = risk_range , show_assets = True , showfig = False
227226 )
0 commit comments