def test_ufuncs():
    jp.set_context_dtype('float64')
    shapes = [(1, 1), (1, 2), (2, 2), (2, 3), (2, 3, 4)]
    ops = ['+', '-', '/', '*']  # TODO: investigate issue with **
    for op in ops:
        for shape in shapes:
            _test_ufunc(op, shape)
            _test_ufunc_inplace(op, shape)
示例#2
0
def test_ufuncs():
    jp.set_context_dtype('float64')
    shapes = [(1, 1), (1, 2), (2, 2), (2, 3), (2, 3, 4)]
    ops = ['+', '-', '/', '*']  # TODO: investigate issue with **
    for op in ops:
        for shape in shapes:
            _test_ufunc(op, shape)
            _test_ufunc_inplace(op, shape)
示例#3
0
def test_conversion_64():
    jp.set_context_dtype('float64')
    shapes = [(1, 1), (2, 1), (1, 2), (32, 12), (100, 32, 16)]
    for shape in shapes:
        x_np = np.random.random(shape)
        x_jp = jp.array(x_np)
        x_np += np.random.random(shape)
        x_jp = x_jp.numpy()

        assert_allclose(x_jp, x_np)
def test_conversion_64():
    jp.set_context_dtype('float64')
    shapes = [(1, 1), (2, 1), (1, 2), (32, 12), (100, 32, 16)]
    for shape in shapes:
        x_np = np.random.random(shape)
        x_jp = jp.array(x_np)
        x_np += np.random.random(shape)
        x_jp = x_jp.numpy()

        assert_allclose(x_jp, x_np)
def test_reshape():
    jp.set_context_dtype('float64')

    shapes = [[(2, 3), (6, 1)], [(1, 2, 3), (3, 2)], [(3, 2, 1), (2, -1)],
              [(3, 1, 2), (-1, 3, 1)]]

    for shape1, shape2 in shapes:
        x_np = np.random.random(shape1)
        y_np = np.reshape(x_np, shape2)

        x_jp = jp.array(x_np)
        y_jp = jp.reshape(x_jp, shape2)

        assert y_jp.shape == y_np.shape
示例#6
0
def test_broadcast():
    jp.set_context_dtype('float64')
    shapes = [
        [(2, 3), (3, )],
        [(2, 3, 4), (3, 4)],
        [(2, 3), (1, 1)],
        [(2, 3), (1, 1, 1)]
    ]

    ops = ['+', '-', '*', '/']
    for op in ops:
        for shape in shapes:
            _test_ufunc(op, *shape)
            _test_ufunc(op, *reversed(shape))
            if len(shape[0]) > len(shape[1]):
                _test_ufunc_inplace(op, *shape)
def test_reshape():
    jp.set_context_dtype('float64')

    shapes = [
        [(2, 3), (6, 1)],
        [(1, 2, 3), (3, 2)],
        [(3, 2, 1), (2, -1)],
        [(3, 1, 2), (-1, 3, 1)]
    ]

    for shape1, shape2 in shapes:
        x_np = np.random.random(shape1)
        y_np = np.reshape(x_np, shape2)

        x_jp = jp.array(x_np)
        y_jp = jp.reshape(x_jp, shape2)

        assert y_jp.shape == y_np.shape
示例#8
0
from keras2tf import keras_to_tf
from numpy.testing import assert_allclose
import os
import jumpy as jp
import numpy as np
import tensorflow as tf
import click
import time
import keras
import shutil
from pb2txt import pb2txt
import json

jp.set_context_dtype('float32')

current_dir = os.path.dirname(os.path.abspath(__file__))
models_dir = os.path.join(current_dir, 'models')
output_dir = os.path.join(current_dir, 'output')

if not os.path.isdir(output_dir):
    os.mkdir(output_dir)


def _replace_none(shape):
    return [x if x is not None else 32 for x in shape]


def _replace_special_chars(x):
    y = ''
    for c in x:
        if not ((c >= 'A' and c <= 'Z') or (c >= 'a' and c <= 'z') or
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
################################################################################


import pytest

import jumpy as jp
import numpy as np

jp.set_context_dtype('float64')

def test_array_creation():
    a = jp.zeros((32, 10))
    assert int(jp.sum(a)) == 0
    a = jp.ones((32, 12))
    assert int(jp.sum(a)) == 32 * 12


if __name__ == '__main__':
    pytest.main([__file__])