def test_clip(): ## 1D waveforms w1 = Waveform([[1., 2., 3.]], array([8., 6., 1.])) assert_waveform_almost_equal(w1.clip(2, 3), Waveform([[2., 3.]], array([6., 1.]))) assert_waveform_almost_equal( w1.clip(1.5, 3), Waveform([[1.5, 2., 3.]], array([7., 6., 1.]))) assert_waveform_almost_equal( w1.clip(1., 2.5), Waveform([[1., 2., 2.5]], array([8., 6., 3.5]))) ## 2D waveforms w = Waveform([[2, 5], [2, 3, 4, 5]], array([[3, 9, 7, 6], [4, 6, 6, 3]]), xlabels=('x1', 'x2'), xunits=('V', 'V'), ylabel='i', yunit='A') assert_waveform_almost_equal( w.clip(3, 4), Waveform([[2, 5], [3, 4]], array([[9, 7], [6, 6]]), xlabels=('x1', 'x2'), xunits=('V', 'V'), ylabel='i', yunit='A')) w = Waveform([[2., 5.], [2., 3., 4.]], array([[3., 9., 7.], [4., 6., 6.]]), xlabels=('x1', 'x2'), xunits=('V', 'V'), ylabel='i', yunit='A') ## Clip at non-existing x-value from left and right assert_waveform_almost_equal( w.clip(2.5, 3.5), Waveform([[2, 5], [2.5, 3, 3.5]], array([[6, 9, 8], [5, 6, 6]]), xlabels=('x1', 'x2'), xunits=('V', 'V'), ylabel='i', yunit='A')) ## Clip at non-existing x-value from left and right assert_waveform_almost_equal( w.clip(2.5, 3.5, axis=0), Waveform([[2.5, 3.5], [2., 3., 4.]], array([[3.166667, 8.5, 6.833333], [3.5, 7.5, 6.5]]), xlabels=('x1', 'x2'), xunits=('V', 'V'), ylabel='i', yunit='A'))
def test_clip(): ## 1D waveforms w1 = Waveform([[1.,2.,3.]], array([8., 6., 1.])) assert_waveform_almost_equal(w1.clip(2,3), Waveform([[ 2., 3.]], array([ 6., 1.]))) assert_waveform_almost_equal(w1.clip(1.5, 3), Waveform([[ 1.5, 2., 3.]],array([ 7., 6., 1.]))) assert_waveform_almost_equal(w1.clip(1., 2.5), Waveform([[ 1., 2., 2.5]],array([ 8., 6., 3.5]))) ## 2D waveforms w = Waveform([[2,5],[2,3,4,5]], array([[3,9,7,6], [4,6,6,3]]), xlabels = ('x1','x2'), xunits = ('V', 'V'), ylabel = 'i', yunit = 'A') assert_waveform_almost_equal(w.clip(3, 4), Waveform([[2,5],[3,4]], array([[9,7], [6,6]]), xlabels = ('x1','x2'), xunits = ('V', 'V'), ylabel = 'i', yunit = 'A')) w = Waveform([[2.,5.],[2.,3.,4.]], array([[3.,9.,7.], [4.,6.,6.]]), xlabels = ('x1','x2'), xunits = ('V', 'V'), ylabel = 'i', yunit = 'A') ## Clip at non-existing x-value from left and right assert_waveform_almost_equal(w.clip(2.5, 3.5), Waveform([[2,5],[2.5,3,3.5]], array([[6,9,8], [5,6,6]]), xlabels = ('x1','x2'), xunits = ('V', 'V'), ylabel = 'i', yunit = 'A')) ## Clip at non-existing x-value from left and right assert_waveform_almost_equal(w.clip(2.5, 3.5, axis=0), Waveform([[2.5,3.5],[2.,3.,4.]], array([[3.166667, 8.5, 6.833333], [3.5, 7.5, 6.5]]), xlabels = ('x1','x2'), xunits = ('V', 'V'), ylabel = 'i', yunit = 'A'))