def third2oct(levels, axis=None):
    
    levels = np.array(levels)
    axis = axis if axis is not None else levels.ndim - 1
    
    try:
        assert(levels.shape[axis]%3 == 0)
    except AssertionError:    
        raise ValueError("Wrong shape.")
    shape = list(levels.shape)
    shape[axis] = shape[axis] // 3
    shape.insert(axis+1, 3)
    levels = np.reshape(levels, shape)
    return np.squeeze(acoustics.decibel.dbsum(levels, axis=axis+1))
Test generator
dataset/ETHPy150Open python-acoustics/python-acoustics/acoustics/bands.py/third2oct--crossover with--dataset/ETHPy150Open NervanaSystems/neon/neon/backends/tests/test_compound_optree.py/pytest_generate_tests