# Path: cellpy/log.py
# def setup_logging(
#     default_json_path=None,
#     default_level=None,
#     env_key="LOG_CFG",
#     custom_log_dir=None,
#     reset_big_log=False,
#     max_size=5_000_000,
#     testing=False,
# ):
# 
# Path: cellpy/exceptions.py
# class NullData(Error):
#     """Raised when required data is missing (e.g. voltage = None or summary_frames are missing)"""
# 
#     pass
# 
# Path: cellpy/utils/ica.py
# class Converter:
#     def __init__(
#         self,
#         capacity=None,
#         voltage=None,
#         points_pr_split=10,
#         max_points=None,
#         voltage_resolution=None,
#         capacity_resolution=None,
#         minimum_splits=3,
#         interpolation_method="linear",
#         increment_method="diff",
#         pre_smoothing=False,
#         smoothing=False,
#         post_smoothing=True,
#         normalize=True,
#         normalizing_factor=None,
#         normalizing_roof=None,
#         savgol_filter_window_divisor_default=50,
#         savgol_filter_window_order=3,
#         voltage_fwhm=0.01,
#         gaussian_order=0,
#         gaussian_mode="reflect",
#         gaussian_cval=0.0,
#         gaussian_truncate=4.0,
#     ):
#     def __str__(self):
#     def set_data(self, capacity, voltage=None, capacity_label="q", voltage_label="v"):
#     def inspect_data(self, capacity=None, voltage=None, err_est=False, diff_est=False):
#     def pre_process_data(self):
#     def increment_data(self):
#     def post_process_data(
#         self, voltage=None, incremental_capacity=None, voltage_step=None
#     ):
# def value_bounds(x):
# def index_bounds(x):
# def dqdv_cycle(cycle, splitter=True, **kwargs):
# def dqdv_cycles(cycles, not_merged=False, **kwargs):
# def dqdv(
#     voltage,
#     capacity,
#     voltage_resolution=None,
#     capacity_resolution=None,
#     voltage_fwhm=0.01,
#     pre_smoothing=True,
#     diff_smoothing=False,
#     post_smoothing=True,
#     post_normalization=True,
#     interpolation_method=None,
#     gaussian_order=None,
#     gaussian_mode=None,
#     gaussian_cval=None,
#     gaussian_truncate=None,
#     points_pr_split=None,
#     savgol_filter_window_divisor_default=None,
#     savgol_filter_window_order=None,
#     max_points=None,
#     **kwargs,
# ):
# def dqdv_frames(cell, split=False, tidy=True, **kwargs):
# def _constrained_dq_dv_using_dataframes(capacity, minimum_v, maximum_v, **kwargs):
# def _make_ica_charge_curves(cycles_dfs, cycle_numbers, minimum_v, maximum_v, **kwargs):
# def _dqdv_combinded_frame(cell, tidy=True, **kwargs):
# def _dqdv_split_frames(
#     cell,
#     tidy=False,
#     trim_taper_steps=None,
#     steps_to_skip=None,
#     steptable=None,
#     max_cycle_number=None,
#     **kwargs,
# ):
# def _check_class_ica():
# def _get_a_cell_to_play_with():
# def _check_if_works():


import logging
import pandas as pd
import pytest
from cellpy import log
from cellpy.exceptions import NullData
from cellpy.utils import ica
def converter(dataset):
    q, v = dataset.get_ccap(1)
    o = ica.Converter()
    o.set_data(q, v)
    return o


def test_ica_converter(dataset):
    # warnings.simplefilter("error", FutureWarning)
    list_of_cycles = dataset.get_cycle_numbers()
    number_of_cycles = len(list_of_cycles)
    logging.debug(f"you have {number_of_cycles} cycles")
    cycle = 5
    logging.debug(f"looking at cycle {cycle}")
    capacity, voltage = dataset.get_ccap(cycle)
    converter = ica.Converter()
    converter.set_data(capacity, voltage)
    converter.inspect_data()
    converter.pre_process_data()
    converter.increment_data()
    converter.post_process_data()


@pytest.mark.xfail(raises=TypeError)
def test_none_data():
    ica.dqdv(None, None)


@pytest.mark.xfail(raises=NullData)
def test_short_data():

# Path: cellpy/log.py
# def setup_logging(
#     default_json_path=None,
#     default_level=None,
#     env_key="LOG_CFG",
#     custom_log_dir=None,
#     reset_big_log=False,
#     max_size=5_000_000,
#     testing=False,
# ):
# 
# Path: cellpy/exceptions.py
# class NullData(Error):
#     """Raised when required data is missing (e.g. voltage = None or summary_frames are missing)"""
# 
#     pass
# 
# Path: cellpy/utils/ica.py
# class Converter:
#     def __init__(
#         self,
#         capacity=None,
#         voltage=None,
#         points_pr_split=10,
#         max_points=None,
#         voltage_resolution=None,
#         capacity_resolution=None,
#         minimum_splits=3,
#         interpolation_method="linear",
#         increment_method="diff",
#         pre_smoothing=False,
#         smoothing=False,
#         post_smoothing=True,
#         normalize=True,
#         normalizing_factor=None,
#         normalizing_roof=None,
#         savgol_filter_window_divisor_default=50,
#         savgol_filter_window_order=3,
#         voltage_fwhm=0.01,
#         gaussian_order=0,
#         gaussian_mode="reflect",
#         gaussian_cval=0.0,
#         gaussian_truncate=4.0,
#     ):
#     def __str__(self):
#     def set_data(self, capacity, voltage=None, capacity_label="q", voltage_label="v"):
#     def inspect_data(self, capacity=None, voltage=None, err_est=False, diff_est=False):
#     def pre_process_data(self):
#     def increment_data(self):
#     def post_process_data(
#         self, voltage=None, incremental_capacity=None, voltage_step=None
#     ):
# def value_bounds(x):
# def index_bounds(x):
# def dqdv_cycle(cycle, splitter=True, **kwargs):
# def dqdv_cycles(cycles, not_merged=False, **kwargs):
# def dqdv(
#     voltage,
#     capacity,
#     voltage_resolution=None,
#     capacity_resolution=None,
#     voltage_fwhm=0.01,
#     pre_smoothing=True,
#     diff_smoothing=False,
#     post_smoothing=True,
#     post_normalization=True,
#     interpolation_method=None,
#     gaussian_order=None,
#     gaussian_mode=None,
#     gaussian_cval=None,
#     gaussian_truncate=None,
#     points_pr_split=None,
#     savgol_filter_window_divisor_default=None,
#     savgol_filter_window_order=None,
#     max_points=None,
#     **kwargs,
# ):
# def dqdv_frames(cell, split=False, tidy=True, **kwargs):
# def _constrained_dq_dv_using_dataframes(capacity, minimum_v, maximum_v, **kwargs):
# def _make_ica_charge_curves(cycles_dfs, cycle_numbers, minimum_v, maximum_v, **kwargs):
# def _dqdv_combinded_frame(cell, tidy=True, **kwargs):
# def _dqdv_split_frames(
#     cell,
#     tidy=False,
#     trim_taper_steps=None,
#     steps_to_skip=None,
#     steptable=None,
#     max_cycle_number=None,
#     **kwargs,
# ):
# def _check_class_ica():
# def _get_a_cell_to_play_with():
# def _check_if_works():


# Path: tests/test_ica.py
import logging
import pandas as pd
import pytest
from cellpy import log
from cellpy.exceptions import NullData
from cellpy.utils import ica

def converter(dataset):
    q, v = dataset.get_ccap(1)
    o = ica.Converter()
    o.set_data(q, v)
    return o


def test_ica_converter(dataset):
    # warnings.simplefilter("error", FutureWarning)
    list_of_cycles = dataset.get_cycle_numbers()
    number_of_cycles = len(list_of_cycles)
    logging.debug(f"you have {number_of_cycles} cycles")
    cycle = 5
    logging.debug(f"looking at cycle {cycle}")
    capacity, voltage = dataset.get_ccap(cycle)
    converter = ica.Converter()
    converter.set_data(capacity, voltage)
    converter.inspect_data()
    converter.pre_process_data()
    converter.increment_data()
    converter.post_process_data()


@pytest.mark.xfail(raises=TypeError)
def test_none_data():
    ica.dqdv(None, None)


@pytest.mark.xfail(raises=NullData)
def test_short_data():

    ica.dqdv(pd.Series(), pd.Series())