def test_slicing_not_touching_original(time, signal): record = ECGRecord.from_np_array("100", time, signal, ["I", "II", "III"]) record_sliced = record[0:1] assert len(record) == 6 record_sliced = record[0:2] assert len(record) == 6 record_sliced = record[1:3] assert len(record) == 6 record_sliced = record[1] assert len(record) == 6
def test_slicing(time, signal): record = ECGRecord.from_np_array("100", time, signal, ["I", "II", "III"]) record_sliced = record[0:1] assert record_sliced.time == time[0:1] for i, s in enumerate(signal): assert record_sliced._signals[i] == s[0:1]
def test_get_lead_notfound(time, signal): record = ECGRecord.from_np_array("100", time, signal, ["I", "II", "III"]) assert record.get_lead("MLII") is None
def test_get_lead(time, signal): record = ECGRecord.from_np_array("100", time, signal, ["I", "II", "III"]) assert np.array_equal(record.get_lead("I")[:], [1, 2, 3, 4, 5, 6]) assert np.array_equal(record.get_lead("II")[:], [5, 6, 7, 8, 9, 10]) assert np.array_equal(record.get_lead("III")[:], [10, 20, 30, 40, 50, 60])
def test_repr(time, signal): record = ECGRecord.from_np_array("100", time, signal, ["I", "II", "III"]) assert record.__repr__() == f"Record 100: ['I', 'II', 'III']"
def test_from_numpy_array_inconsistent_signal_name(time, signal): with pytest.raises(ValueError): ECGRecord.from_np_array("record_100", time, signal, ["II"])
def test_from_numpy_array(time, signal): record = ECGRecord.from_np_array("record_100", time, signal, ["I", "II", "III"]) assert len(record) == len(time)
def test_from_numpy_array_bad_signal_shape(time, signal): with pytest.raises(ValueError): ECGRecord.from_np_array("record_100", time, signal, ["II"])
def test_p_signal_shape(time, signal): record = ECGRecord.from_np_array("100", time, signal, ["I", "II", "III"]) assert np.array_equal(record.p_signal.shape, (3, 6))