Commit 2c68a32c authored by Rémi Huguet's avatar Rémi Huguet
Browse files

fix: High order combination preprocesses accepts frame_1 default value.

parent 3e0a76d2
Loading
Loading
Loading
Loading
Loading
+22 −7
Original line number Diff line number Diff line
@@ -47,7 +47,22 @@ def _combination(operation, frame_1, frame_2=None, mode='full', distance=None):


class Difference:
    def __new__(cls, frame_1, frame_2=None, mode='full', distance=None):
    """Difference combination preprocess for High Order analysis.

    Args:
        frame_1 (slice or iterable, default=...): first traces frame that will be taken.
        frame_2 (slice or iterable, default=None): second optionnal traces frame that will be taken.
        mode (str, default='full'): Combination mode between `'full'` and `'same'` values.
            In `'same'` mode, each point of `frame_1` will be combined with its corresponding point in `frame_2`.
            The two frames needs to be provided and of the same length when using this mode.
            In `'full'` mode, each point of `frame_1` is combined with full `frame_2` if it provided,
            otherwise with the frame between the current point position in `frame_1` and the end of the frame if `distance` is None,
            else with a subframe starting at the current point position in `frame_1` and of size equals to `distance`.
        dist (integer, default=None): size of the frame to combine with each point of `frame_1`. This parameter is not available if `frame_2` is provided.

    """

    def __new__(cls, frame_1=..., frame_2=None, mode='full', distance=None):
        return _combination(
            _difference, frame_1=frame_1, frame_2=frame_2, mode=mode, distance=distance
        )
@@ -57,7 +72,7 @@ class Product:
    """Product combination preprocess for High Order analysis.

    Args:
        frame_1 (slice or iterable): first traces frame that will be taken.
        frame_1 (slice or iterable, default=...): first traces frame that will be taken.
        frame_2 (slice or iterable, default=None): second optionnal traces frame that will be taken.
        mode (str, default='full'): Combination mode between `'full'` and `'same'` values.
            In `'same'` mode, each point of `frame_1` will be combined with its corresponding point in `frame_2`.
@@ -69,7 +84,7 @@ class Product:

    """

    def __new__(cls, frame_1, frame_2=None, mode='full', distance=None):
    def __new__(cls, frame_1=..., frame_2=None, mode='full', distance=None):
        return _combination(
            _product, frame_1=frame_1, frame_2=frame_2, mode=mode, distance=distance
        )
@@ -79,7 +94,7 @@ class CenteredProduct(Product):
    """Centered prodiuct combination preprocess for High Order analysis.

    Args:
        frame_1 (slice or iterable): first traces frame that will be taken.
        frame_1 (slice or iterable, default=...): first traces frame that will be taken.
        frame_2 (slice or iterable, default=None): second optionnal traces frame that will be taken.
        mode (str, default='full'): Combination mode between `'full'` and `'same'` values.
            In `'same'` mode, each point of `frame_1` will be combined with its corresponding point in `frame_2`.
@@ -91,7 +106,7 @@ class CenteredProduct(Product):
        mean (numpy.ndarray, default=None): a mean array with compatible size with traces. If it None, the mean of provided traces is computed.
    """

    def __new__(cls, frame_1, frame_2=None, mode='full', distance=None, mean=None):
    def __new__(cls, frame_1=..., frame_2=None, mode='full', distance=None, mean=None):
        return _centered(
            _combination(
                _product, frame_1=frame_1, frame_2=frame_2, mode=mode, distance=distance
@@ -102,7 +117,7 @@ class AbsoluteDifference:
    """Absolute difference combination preprocess for High Order analysis.

    Args:
        frame_1 (slice or iterable): first traces frame that will be taken.
        frame_1 (slice or iterable, default=...): first traces frame that will be taken.
        frame_2 (slice or iterable, default=None): second optionnal traces frame that will be taken.
        mode (str, default='full'): Combination mode between `'full'` and `'same'` values.
            In `'same'` mode, each point of `frame_1` will be combined with its corresponding point in `frame_2`.
@@ -114,7 +129,7 @@ class AbsoluteDifference:

    """

    def __new__(cls, frame_1, frame_2=None, mode='full', distance=None):
    def __new__(cls, frame_1=..., frame_2=None, mode='full', distance=None):
        return _absolute(
            _combination(_difference, frame_1=frame_1, frame_2=frame_2, mode=mode, distance=distance)
        )
+5 −0
Original line number Diff line number Diff line
@@ -13,6 +13,11 @@ def traces():
    return _read('absolute_difference_input.npz')


def test_absolute_difference_with_no_frame(traces):
    result = scared.preprocesses.high_order.AbsoluteDifference()(traces)
    assert (500, 20100) == result.shape


def test_absolute_difference_with_one_frame_and_default_values(traces):
    expected = _read('absolute_difference_result.npz')
    frame = slice(None, 50)
+5 −0
Original line number Diff line number Diff line
@@ -13,6 +13,11 @@ def traces():
    return _read('centered_product_input.npz')


def test_centered_product_with_no_frame(traces):
    result = scared.preprocesses.high_order.CenteredProduct()(traces)
    assert (500, 20100) == result.shape


def test_centered_product_with_one_frame_and_default_values(traces):
    expected = _read('centered_product_result.npz')
    frame = slice(None, 50)
+5 −0
Original line number Diff line number Diff line
@@ -13,6 +13,11 @@ def traces():
    return _read('difference_input.npz')


def test_difference_with_no_frame(traces):
    result = scared.preprocesses.high_order.Difference()(traces)
    assert (500, 20100) == result.shape


def test_difference_with_one_frame_and_default_values(traces):
    expected = _read('difference_result.npz')
    frame = slice(None, 50)
+5 −0
Original line number Diff line number Diff line
@@ -13,6 +13,11 @@ def traces():
    return _read('product_input.npz')


def test_product_with_no_frame(traces):
    result = scared.preprocesses.high_order.Product()(traces)
    assert (500, 20100) == result.shape


def test_product_with_one_frame_and_default_values(traces):
    expected = _read('product_result.npz')
    frame = slice(None, 50)