def change_angles(method, theta, tol=1e-10):
    """ Function used by all angle conversion functions (from_x_to_x_pi(...))"""
    try:
        theta_new = np.zeros(theta.shape)
        for i, thet in enumerate(theta):
            try:
                # theta is vector
                theta_new[i] = method(thet, tol)
            except:
                # theta is matrix
                for j, th in enumerate(thet):
                    try:
                        theta_new[i, j] = method(th, tol)
                    except:
                        # theta is tensor
                        for k, t in enumerate(th):
                            theta_new[i, j, k] = method(t, tol)
        return theta_new
    except:
        return method(theta, tol)
def change_angles ( method , theta , tol = 1e-10 ) : try : theta_new = np . zeros ( theta . shape ) for i , thet in enumerate ( theta ) : try : theta_new [ i ] = method ( thet , tol ) except : for j , th in enumerate ( thet ) : try : theta_new [ i , j ] = method ( th , tol ) except : for k , t in enumerate ( th ) : theta_new [ i , j , k ] = method ( t , tol ) return theta_new except : return method ( theta , tol )
Function used by all angle conversion functions (from_x_to_x_pi(...))