# Path: modred/vectors.py
# class VecHandle(object):
# class VecHandleInMemory(VecHandle):
# class VecHandleArrayText(VecHandle):
# class VecHandlePickle(VecHandle):
# class InnerProductTrapz(object):
# class Vector(object):
#     def __init__(self, base_vec_handle=None, scale=None):
#     def get(self):
#     def put(self, vec):
#     def _get(self):
#     def _put(self, vec):
#     def __scale_vec(self, vec):
#     def __init__(self, vec=None, base_vec_handle=None, scale=None):
#     def _get(self):
#     def _put(self, vec):
#     def __eq__(self, other):
#     def __init__(
#         self, vec_path, base_vec_handle=None, scale=None, is_complex=False):
#     def _get(self):
#     def _put(self, vec):
#     def __eq__(self, other):
#     def __init__(self, vec_path, base_vec_handle=None, scale=None):
#     def _get(self):
#     def _put(self, vec):
#     def __eq__(self, other):
# def inner_product_array_uniform(vec1, vec2):
#     def __init__(self, *grids):
#     def __call__(self, vec1, vec2):
#     def inner_product(self, vec1, vec2):
#     def __init__(self):
#     def __add__(self, other):
#     def __mul__(self, scalar):
#     def __rmul__(self, scalar):
#     def __lmul__(self, scalar):
#     def __sub__(self, other):
#         IP = vec1.conj() * vec2
#             IP = np.trapz(IP, x=grid)
# 
# Path: modred/parallel.py
# def get_hostname():
# def get_node_ID():
# def get_num_nodes():
# def get_num_MPI_workers():
# def get_rank():
# def get_num_procs():
# def is_distributed():
# def is_rank_zero():
# def barrier():
# def print_from_rank_zero(msg, output_channel='stdout'):
# def call_from_rank_zero(func, *args, **kwargs):
# def bcast(vals):
# def call_and_bcast(func, *args, **kwargs):
# def find_assignments(tasks, task_weights=None):
# def check_for_empty_tasks(task_assignments):


import unittest
import os
import numpy as np
from os.path import join
from shutil import rmtree
from modred import vectors as vcs, parallel
                np.testing.assert_equal(vec_handle.get(), vec_true)

                # Test __eq__ operator
                vec_handle1 = VecHandle('a')
                vec_handle2 = VecHandle('a')
                vec_handle3 = VecHandle('aa')
                vec_handle4 = VecHandle('b')
                self.assertEqual(vec_handle1, vec_handle1)
                self.assertEqual(vec_handle1, vec_handle2)
                self.assertNotEqual(vec_handle1, vec_handle3)
                self.assertNotEqual(vec_handle1, vec_handle4)


    #@unittest.skip('Testing something else.')
    def test_IP_trapz(self):
        """Test trapezoidal rule inner product for 2nd-order convergence"""
        # Known inner product of x ** 2 + 1.2 * y ** 2 and x ** 2 over interval
        # -1 < x < 1 and -2 < y < 2.
        ip_true = 5.8666666
        ip_error = []
        num_points_list = [20, 100]
        for num_points in num_points_list:
            x_grid = np.cos(np.linspace(0, np.pi, num_points))[::-1]
            y_grid = 2*np.cos(np.linspace(0, np.pi, num_points+1))[::-1]

            # Notice order is reversed. This gives dimensions [nx, ny]
            # instead of [ny, nx]. See np.meshgrid documentation.
            Y, X = np.meshgrid(y_grid, x_grid)
            v1 = X ** 2 + 1.2 * Y ** 2
            v2 = X ** 2

# Path: modred/vectors.py
# class VecHandle(object):
# class VecHandleInMemory(VecHandle):
# class VecHandleArrayText(VecHandle):
# class VecHandlePickle(VecHandle):
# class InnerProductTrapz(object):
# class Vector(object):
#     def __init__(self, base_vec_handle=None, scale=None):
#     def get(self):
#     def put(self, vec):
#     def _get(self):
#     def _put(self, vec):
#     def __scale_vec(self, vec):
#     def __init__(self, vec=None, base_vec_handle=None, scale=None):
#     def _get(self):
#     def _put(self, vec):
#     def __eq__(self, other):
#     def __init__(
#         self, vec_path, base_vec_handle=None, scale=None, is_complex=False):
#     def _get(self):
#     def _put(self, vec):
#     def __eq__(self, other):
#     def __init__(self, vec_path, base_vec_handle=None, scale=None):
#     def _get(self):
#     def _put(self, vec):
#     def __eq__(self, other):
# def inner_product_array_uniform(vec1, vec2):
#     def __init__(self, *grids):
#     def __call__(self, vec1, vec2):
#     def inner_product(self, vec1, vec2):
#     def __init__(self):
#     def __add__(self, other):
#     def __mul__(self, scalar):
#     def __rmul__(self, scalar):
#     def __lmul__(self, scalar):
#     def __sub__(self, other):
#         IP = vec1.conj() * vec2
#             IP = np.trapz(IP, x=grid)
# 
# Path: modred/parallel.py
# def get_hostname():
# def get_node_ID():
# def get_num_nodes():
# def get_num_MPI_workers():
# def get_rank():
# def get_num_procs():
# def is_distributed():
# def is_rank_zero():
# def barrier():
# def print_from_rank_zero(msg, output_channel='stdout'):
# def call_from_rank_zero(func, *args, **kwargs):
# def bcast(vals):
# def call_and_bcast(func, *args, **kwargs):
# def find_assignments(tasks, task_weights=None):
# def check_for_empty_tasks(task_assignments):


# Path: modred/tests/testvectors.py
import unittest
import os
import numpy as np
from os.path import join
from shutil import rmtree
from modred import vectors as vcs, parallel

                np.testing.assert_equal(vec_handle.get(), vec_true)

                # Test __eq__ operator
                vec_handle1 = VecHandle('a')
                vec_handle2 = VecHandle('a')
                vec_handle3 = VecHandle('aa')
                vec_handle4 = VecHandle('b')
                self.assertEqual(vec_handle1, vec_handle1)
                self.assertEqual(vec_handle1, vec_handle2)
                self.assertNotEqual(vec_handle1, vec_handle3)
                self.assertNotEqual(vec_handle1, vec_handle4)


    #@unittest.skip('Testing something else.')
    def test_IP_trapz(self):
        """Test trapezoidal rule inner product for 2nd-order convergence"""
        # Known inner product of x ** 2 + 1.2 * y ** 2 and x ** 2 over interval
        # -1 < x < 1 and -2 < y < 2.
        ip_true = 5.8666666
        ip_error = []
        num_points_list = [20, 100]
        for num_points in num_points_list:
            x_grid = np.cos(np.linspace(0, np.pi, num_points))[::-1]
            y_grid = 2*np.cos(np.linspace(0, np.pi, num_points+1))[::-1]

            # Notice order is reversed. This gives dimensions [nx, ny]
            # instead of [ny, nx]. See np.meshgrid documentation.
            Y, X = np.meshgrid(y_grid, x_grid)
            v1 = X ** 2 + 1.2 * Y ** 2
            v2 = X ** 2

            ip_comp = vcs.InnerProductTrapz(x_grid, y_grid)(v1, v2)