File tree Expand file tree Collapse file tree 3 files changed +23
-6
lines changed Expand file tree Collapse file tree 3 files changed +23
-6
lines changed Original file line number Diff line number Diff line change 1+ from itertools import chain
2+
13import numpy as np
2- import pandas as pd
3- from pandas .testing import assert_series_equal
44
55from adaptive import AverageLearner1D
66from adaptive .tests .test_learners import (
1111
1212
1313def almost_equal_dicts (a , b ):
14- assert_series_equal (pd .Series (sorted (a .items ())), pd .Series (sorted (b .items ())))
14+ assert a .keys () == b .keys ()
15+ for k , v1 in a .items ():
16+ v2 = b [k ]
17+ if (
18+ v1 is None
19+ or v2 is None
20+ or isinstance (v1 , (tuple , list ))
21+ and any (x is None for x in chain (v1 , v2 ))
22+ ):
23+ assert v1 == v2
24+ else :
25+ try :
26+ np .testing .assert_almost_equal (v1 , v2 )
27+ except TypeError :
28+ raise AssertionError (f"{ v1 } != { v2 } " )
1529
1630
1731def test_tell_many_at_point ():
1832 f = generate_random_parametrization (noisy_peak )
1933 learner = AverageLearner1D (f , bounds = (- 2 , 2 ))
20- control = AverageLearner1D ( f , bounds = ( - 2 , 2 ) )
34+ control = learner . new ( )
2135 learner ._recompute_losses_factor = 1
2236 control ._recompute_losses_factor = 1
2337 simple_run (learner , 100 )
Original file line number Diff line number Diff line change 1212
1313import flaky
1414import numpy as np
15- import pandas
1615import pytest
1716import scipy .spatial
1817
2827 LearnerND ,
2928 SequenceLearner ,
3029)
30+ from adaptive .learner .learner1D import with_pandas
3131from adaptive .runner import simple
3232
3333try :
@@ -708,6 +708,7 @@ def wrapper(*args, **kwargs):
708708 return wrapper
709709
710710
711+ @pytest .mark .skipif (not with_pandas , reason = "pandas is not installed" )
711712@run_with (
712713 Learner1D ,
713714 Learner2D ,
@@ -719,6 +720,8 @@ def wrapper(*args, **kwargs):
719720 with_all_loss_functions = False ,
720721)
721722def test_to_dataframe (learner_type , f , learner_kwargs ):
723+ import pandas
724+
722725 if learner_type is LearnerND :
723726 kw = {"point_names" : tuple ("xyz" )[: len (learner_kwargs ["bounds" ])]}
724727 else :
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ def get_version_and_cmdclass(package_name):
4242 "holoviews>=1.9.1" ,
4343 "ipywidgets" ,
4444 "bokeh" ,
45+ "pandas" ,
4546 "matplotlib" ,
4647 "plotly" ,
4748 ],
@@ -52,7 +53,6 @@ def get_version_and_cmdclass(package_name):
5253 "pytest-randomly" ,
5354 "pytest-timeout" ,
5455 "pre_commit" ,
55- "pandas" ,
5656 "typeguard" ,
5757 ],
5858 "other" : [
You can’t perform that action at this time.
0 commit comments