MCPcopy
hub / github.com/facebookresearch/nevergrad / test_infnan

Function test_infnan

nevergrad/optimization/test_optimizerlib.py:205–250  ·  view source on GitHub ↗
(name: str)

Source from the content-addressed store, hash-verified

203@pytest.mark.parametrize("name", short_registry) # type: ignore
204@testing.suppress_nevergrad_warnings() # hides bad loss
205def test_infnan(name: str) -> None:
206 if any(x in name for x in ["SMAC", "BO", "AX"]) and os.environ.get("CIRCLECI", False):
207 raise SkipTest("too slow for CircleCI!")
208 if "Force" in name:
209 raise SkipTest("Forced methods not tested for infnan")
210
211 def doint(s): # Converting a string into an int.
212 return 7 + sum([ord(c) * i for i, c in enumerate(s)])
213
214 if doint(name) % 5 > 0:
215 raise SkipTest("too many tests for CircleCI!")
216
217 optim_cls = registry[name]
218 optim = optim_cls(parametrization=2, budget=70)
219 if not (
220 any(
221 x in name
222 for x in [
223 "EDA",
224 "EMNA",
225 "Stupid",
226 "NEWUOA",
227 "Large",
228 "Fmin2",
229 "NLOPT",
230 "TBPSA",
231 "SMAC",
232 "BO",
233 "Noisy",
234 "Chain",
235 "chain", # TODO: remove when possible
236 ]
237 )
238 ):
239 recom = optim.minimize(buggy_function)
240 result = buggy_function(recom.value)
241 if result < 2.0:
242 return
243 assert ( # The "bad" algorithms, most of them originating in CMA's recommendation rule.
244 any(x == name for x in ["WidePSO", "SPSA", "NGOptBase", "Shiwa", "NGO"])
245 or isinstance(optim, (optlib.Portfolio, optlib._CMA, optlib.recaster.SequentialRecastOptimizer))
246 or "NGOpt" in name
247 or "HS" in name
248 or "Adapti" in name
249 or "MetaModelDiagonalCMA" in name
250 )
251
252
253@skip_win_perf # type: ignore

Callers

nothing calls this directly

Calls 4

buggy_functionFunction · 0.85
getMethod · 0.80
dointFunction · 0.70
minimizeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…