Skip to content

Commit

Permalink
update HISTORY.rst and improve total_time_at_voltage_level (renamed)
Browse files Browse the repository at this point in the history
  • Loading branch information
jepegit committed Dec 26, 2023
1 parent d4a1346 commit 32bb6e8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
17 changes: 12 additions & 5 deletions cellpy/readers/cellreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4827,7 +4827,11 @@ def has_no_partial_duplicates(self, subset="data_point"):
return not self.data.raw.duplicated(subset=subset).any()

def total_time_at_voltage_level(
self, cycles=None, voltage_limit=0.5, sampling_unit="S", at="low",
self,
cycles=None,
voltage_limit=0.5,
sampling_unit="S",
at="low",
):
"""Experimental method for getting the total time spent at low / high voltage.
Expand All @@ -4851,9 +4855,11 @@ def total_time_at_voltage_level(

if sampling_unit not in ["S"]:
logging.critical("Only 'S' (seconds) has been tested so far.")
logging.critical(f"It might work with sampling_unit='{sampling_unit}'"
f"however, the result you get is probably in {sampling_unit} and not"
f"seconds.")
logging.critical(
f"It might work with sampling_unit='{sampling_unit}'"
f"however, the result you get is probably in {sampling_unit} and not"
f"seconds."
)

date_time_hdr = "date_time"
cycle_index_hdr = "cycle_index"
Expand Down Expand Up @@ -4892,7 +4898,8 @@ def total_time_at_voltage_level(
v.loc[v[voltage_hdr] > voltage_limit, "is_at_target"] = 1
elif at == "between":
v.loc[
(v[voltage_hdr] > voltage_limit[0]) & (v[voltage_hdr] < voltage_limit[1]),
(v[voltage_hdr] > voltage_limit[0])
& (v[voltage_hdr] < voltage_limit[1]),
"is_at_target",
] = 1
else:
Expand Down
20 changes: 9 additions & 11 deletions tests/test_cellpy_method_integrity.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,23 @@ def neware_csv_cell(parameters):

@pytest.fixture
def maccor_txt_cell(parameters):
return get(
filename=parameters.mcc_file_path, instrument="maccor_txt", testing=True
)
return get(filename=parameters.mcc_file_path, instrument="maccor_txt", testing=True)


@pytest.fixture
def pec_txt_cell(parameters):
return get(
filename=parameters.pec_file_path, instrument="pec_csv", testing=True
)
return get(filename=parameters.pec_file_path, instrument="pec_csv", testing=True)


@pytest.fixture
def custom_cell(parameters):
file_name = parameters.custom_file_paths
instrument_file = parameters.custom_instrument_definitions_file
return get(
filename=file_name, instrument="custom", instrument_file=instrument_file, testing=True
filename=file_name,
instrument="custom",
instrument_file=instrument_file,
testing=True,
)


Expand Down Expand Up @@ -138,8 +137,7 @@ def test_other_raw_cells(
"cellpy_cell_v5",
"cellpy_cell_v6",
"neware_cellpy_cell",
]
],
)
def test_total_time_at_low_voltage_from_cellpy_cells(_c, request):
c = request.getfixturevalue(_c)
Expand All @@ -157,7 +155,7 @@ def test_total_time_at_low_voltage_from_cellpy_cells(_c, request):
"arbin_res_cell2",
"arbin_res_cell3",
"arbin_res_cell4",
]
],
)
def test_total_time_at_low_voltage_from_raw(_c, request):
c = request.getfixturevalue(_c)
Expand All @@ -182,7 +180,7 @@ def test_total_time_at_low_voltage_from_raw(_c, request):
"_c",
[
"pec_txt_cell",
]
],
)
def test_total_time_at_low_voltage_from_other_raw(_c, request):
c = request.getfixturevalue(_c)
Expand Down
3 changes: 0 additions & 3 deletions tests/test_neware.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,3 @@ def test_get_neware_from_h5(neware_cell):
assert len(neware_cell.data.summary) == 4
t = neware_cell.total_time_at_voltage_level()
print(f"total time at low voltage: {t} seconds")



0 comments on commit 32bb6e8

Please sign in to comment.