Пример #1
0
def test_type_checking_int_to_float_coersion():
    """It's possible to make 'float' Point from 'int' values"""

    src = [[0.0, 1, 2], array([0, 1, 2])]  # list with 'int' values  # array of 'int' type

    for s in src:
        p = Point(coordarray=s, coordtype=float)
        assert_almost_equal(p.toarray(), array([0.0, 1.0, 2.0], dtype=float64))
Пример #2
0
def test_type_checking_int_to_float_coersion():
    """It's possible to make 'float' Point from 'int' values"""

    src = [
        [0.0, 1, 2],  # list with 'int' values
        array([0, 1, 2])  # array of 'int' type
    ]

    for s in src:
        p = Point(coordarray=s, coordtype=float)
        assert_almost_equal(p.toarray(), array([0.0, 1.0, 2.0], dtype=float64))
Пример #3
0
def test_nonchar_coordnames():
    """Non-char coordnames are converted to strings"""
    p = Point({"coorddict": {11: 1.0, 100: -1.0}})
    assert_almost_equal(p.toarray(), array([-1.0, 1.0], dtype=float64))
    assert p.coordnames == ["100", "11"]
Пример #4
0
def test_dict_with_array_values():
    """Arrays are truncated to first element"""
    p = Point({"x": array([1.0]), "y": array([-1.0, 2.0])})
    assert_almost_equal(p.toarray(), array([1.0, -1.0], dtype=float64))
Пример #5
0
def test_named_dict():
    """Create Point from dict with 'coorddict' key"""
    p = Point({"coorddict": {"x": -1.0, "y": 1.0}})
    assert_almost_equal(p.toarray(), array([-1.0, 1.0], dtype=float64))
    assert p.coordnames == ["x", "y"]
Пример #6
0
def test_named_argument():
    """Create Point from name/value dict as a named argument"""
    p = Point(coorddict={"x": 1.0, "y": -1.0})
    assert_almost_equal(p.toarray(), array([1.0, -1.0], dtype=float64))
    assert p.coordnames == ["x", "y"]
Пример #7
0
def test_nonchar_coordnames():
    """Non-char coordnames are converted to strings"""
    p = Point({'coorddict': {11: 1.0, 100: -1.0}})
    assert_almost_equal(p.toarray(), array([-1.0, 1.0], dtype=float64))
    assert p.coordnames == ['100', '11']
Пример #8
0
def test_dict_with_array_values():
    """Arrays are truncated to first element"""
    p = Point({'x': array([1.0]), 'y': array([-1.0, 2.0])})
    assert_almost_equal(p.toarray(), array([1.0, -1.0], dtype=float64))
Пример #9
0
def test_named_dict():
    """Create Point from dict with 'coorddict' key"""
    p = Point({'coorddict': {'x': -1.0, 'y': 1.0}})
    assert_almost_equal(p.toarray(), array([-1.0, 1.0], dtype=float64))
    assert p.coordnames == ['x', 'y']
Пример #10
0
def test_named_argument():
    """Create Point from name/value dict as a named argument"""
    p = Point(coorddict={'x': 1.0, 'y': -1.0})
    assert_almost_equal(p.toarray(), array([1.0, -1.0], dtype=float64))
    assert p.coordnames == ['x', 'y']