11from pathlib import Path
22
33import pytest
4- from navani .echem import echem_file_loader
5-
6- from pydatalab .apps .echem .utils import (
7- compute_gpcl_differential ,
8- filter_df_by_cycle_index ,
9- reduce_echem_cycle_sampling ,
10- )
114
125
136@pytest .fixture
147def echem_dataframe ():
158 """Yields example echem data as a dataframe."""
9+ from navani .echem import echem_file_loader
10+
1611 df = echem_file_loader (
1712 Path (__file__ )
1813 .parent .joinpath (
@@ -38,15 +33,27 @@ def echem_dataframe():
3833
3934@pytest .fixture
4035def reduced_echem_dataframe (echem_dataframe ):
36+ from pydatalab .apps .echem .utils import (
37+ reduce_echem_cycle_sampling ,
38+ )
39+
4140 return reduce_echem_cycle_sampling (echem_dataframe , 100 )
4241
4342
4443@pytest .fixture
4544def reduced_and_filtered_echem_dataframe (reduced_echem_dataframe ):
45+ from pydatalab .apps .echem .utils import (
46+ filter_df_by_cycle_index ,
47+ )
48+
4649 return filter_df_by_cycle_index (reduced_echem_dataframe )
4750
4851
4952def test_reduce_size (echem_dataframe ):
53+ from pydatalab .apps .echem .utils import (
54+ reduce_echem_cycle_sampling ,
55+ )
56+
5057 original_size = echem_dataframe .shape [0 ]
5158 for size in (1 , 10 , int (0.5 * len (echem_dataframe )), len (echem_dataframe )):
5259 number_of_cycles = echem_dataframe ["half cycle" ].nunique ()
@@ -57,6 +64,10 @@ def test_reduce_size(echem_dataframe):
5764
5865
5966def test_compute_gpcl_differential (reduced_and_filtered_echem_dataframe ):
67+ from pydatalab .apps .echem .utils import (
68+ compute_gpcl_differential ,
69+ )
70+
6071 df = reduced_and_filtered_echem_dataframe
6172
6273 dqdv_results = compute_gpcl_differential (df )
@@ -67,13 +78,20 @@ def test_compute_gpcl_differential(reduced_and_filtered_echem_dataframe):
6778
6879
6980def test_filter_df_by_cycle_index (reduced_echem_dataframe ):
81+ from pydatalab .apps .echem .utils import (
82+ filter_df_by_cycle_index ,
83+ )
84+
7085 cycle_lists = ([1 , 2 , 3 ], [4.0 , 6.0 , 10.0 ], [- 1 , 5 , 2 ])
7186 for cycle_list in cycle_lists :
7287 filtered_df = filter_df_by_cycle_index (reduced_echem_dataframe , cycle_list )
7388 assert {int (i ) for i in filtered_df ["full cycle" ]}.issubset ({int (i ) for i in cycle_list })
7489
7590
7691def test_plot (reduced_echem_dataframe ):
92+ from pydatalab .apps .echem .utils import (
93+ compute_gpcl_differential ,
94+ )
7795 from pydatalab .bokeh_plots import double_axes_echem_plot
7896
7997 layout = double_axes_echem_plot (reduced_echem_dataframe )
0 commit comments