def _check_permutations_on_data(self, tens, data):
        import numpy

        if isinstance(tens, TensorHead):
            rank = tens.rank
            generators = tens.symmetry.generators
        elif isinstance(tens, Tensor):
            rank = tens.rank
            generators = tens.components[0].symmetry.generators
        elif isinstance(tens, TensorIndexType):
            rank = tens.metric.rank
            generators = tens.metric.symmetry.generators

        # Every generator is a permutation, check that by permuting the array
        # by that permutation, the array will be the same, except for a
        # possible sign change if the permutation admits it.
        for gener in generators:
            sign_change = +1 if (gener(rank) == rank) else -1
            data_swapped = data
            last_data = data
            permute_axes = list(map(gener, list(range(rank))))
            # the order of a permutation is the number of times to get the
            # identity by applying that permutation.
            for i in range(gener.order()-1):
                data_swapped = numpy.transpose(data_swapped, permute_axes)
                # if any value in the difference array is non-zero, raise an error:
                if (last_data - sign_change*data_swapped).any():
                    raise ValueError("Component data symmetry structure error")
                last_data = data_swapped
dataset/ETHPy150Open sympy/sympy/sympy/tensor/tensor.py/_TensorDataLazyEvaluator._check_permutations_on_data/original