Esempio n. 1
0
def test_analysis_stage():
    examples = [['peaks', 'strain fit', False],
                ['strain', 'strain fit', False],
                ['stress', 'strain fit', False],
                ['stress', 'stress fit', False],
                ['peaks', 'peaks', True],
                ['strain fit', 'strain fit', True],
                ['strain fit', 'strain', True],
                ['stress fit', 'strain', True]]

    for example in examples:
        current, required = example[0], example[1]
        try:
            cp.analysis_state_comparison(current, required)
            valid = True
        except AssertionError:
            valid = False
        answer = example[2]
        error = '{} v {} - {} ({})'.format(current, required, valid, answer)
        assert valid == answer, error
Esempio n. 2
0
def none_merge(data, current_state, required_state, axis=-1):
    """ Merge data if present/exists else return None

    Args:
        data (list): List of ndarrays
        current_state (str): Current state for comparison
        required_state (str): Required state for comparison
        axis (int): Axis for data concatenation

    Returns:
        ndarray: Merged data (or None)
    """
    try:
        analysis_state_comparison(current_state, required_state)
        assert not any([d is None for d in data]), 'Invalid data (None types)'
        if axis is None:
            merged_data = np.append(*data)
        else:
            reshaped_data = [d.reshape(axis, *d.shape[axis:]) for d in data]
            merged_data = np.concatenate(reshaped_data)
        return merged_data
    except AssertionError:
        return None
Esempio n. 3
0
File: merge.py Progetto: casimp/pyxe
def none_merge(data, current_state, required_state, axis=-1):
    """ Merge data if present/exists else return None

    Args:
        data (list): List of ndarrays
        current_state (str): Current state for comparison
        required_state (str): Required state for comparison
        axis (int): Axis for data concatenation

    Returns:
        ndarray: Merged data (or None)
    """
    try:
        analysis_state_comparison(current_state, required_state)
        assert not any([d is None for d in data]), 'Invalid data (None types)'
        if axis is None:
            merged_data = np.append(*data)
        else:
            reshaped_data = [d.reshape(axis, *d.shape[axis:]) for d in data]
            merged_data = np.concatenate(reshaped_data)
        return merged_data
    except AssertionError:
        return None