Exemplo n.º 1
0
def test_SpiceCellSliceInts():
    testVals = [1, 2, 3]
    testCell = stypes.SPICEINT_CELL(5)
    spice.appndi(testVals, testCell)
    assert testCell[0] == testVals[0]
    assert testCell[1] == testVals[1]
    assert testCell[2] == testVals[2]
    assert testCell[-1] == testVals[-1]
    assert testCell[-2] == testVals[-2]
    assert testCell[-3] == testVals[-3]
    assert testCell[0:1] == testVals[0:1]
    assert testCell[1:2] == testVals[1:2]
    assert testCell[2:3] == testVals[2:3]
    assert testCell[0:2] == testVals[0:2]
    assert testCell[0:3] == testVals[0:3]
    assert testCell[0:5] == testVals[0:5]
    assert testCell[::2] == testVals[::2]
    assert testCell[5:10] == testVals[5:10]
    assert testCell[::-1] == testVals[::-1]
    assert testCell[::-2] == testVals[::-2]
    assert testCell[2:-1] == testVals[2:-1]
Exemplo n.º 2
0
def test_SpiceCellSliceInts():
    test_vals = [1, 2, 3]
    test_cell = stypes.SPICEINT_CELL(5)
    spice.appndi(test_vals, test_cell)
    assert test_cell[0] == test_vals[0]
    assert test_cell[1] == test_vals[1]
    assert test_cell[2] == test_vals[2]
    assert test_cell[-1] == test_vals[-1]
    assert test_cell[-2] == test_vals[-2]
    assert test_cell[-3] == test_vals[-3]
    assert test_cell[0:1] == test_vals[0:1]
    assert test_cell[1:2] == test_vals[1:2]
    assert test_cell[2:3] == test_vals[2:3]
    assert test_cell[0:2] == test_vals[0:2]
    assert test_cell[0:3] == test_vals[0:3]
    assert test_cell[0:5] == test_vals[0:5]
    assert test_cell[::2] == test_vals[::2]
    assert test_cell[5:10] == test_vals[5:10]
    assert test_cell[::-1] == test_vals[::-1]
    assert test_cell[::-2] == test_vals[::-2]
    assert test_cell[2:-1] == test_vals[2:-1]
Exemplo n.º 3
0
def test_spicecell_equality():
    c1 = stypes.Cell_Int(8)
    spice.appndi([1, 2, 3], c1)
    c2 = stypes.Cell_Int(8)
    spice.appndi([1, 2, 3], c2)
    c3 = stypes.Cell_Int(8)
    spice.appndi([1, 2, 4], c3)
    c4 = stypes.Cell_Int(8)
    spice.appndi([1, 2, 3, 3], c4)
    assert c1 != 1
    assert c1 == c2
    assert c1 != c3
    c3 = spice.valid(3, 3, c3)
    assert c3.isSet
    assert not c4.isSet
    assert c1 != c4
Exemplo n.º 4
0
def test_SpiceCell():
    test_cell = stypes.SPICEINT_CELL(8)
    spice.appndi(1, test_cell)
    spice.appndi(2, test_cell)
    spice.appndi(3, test_cell)
    assert [x for x in test_cell] == [1, 2, 3]
    assert len(test_cell) == 3
    assert 1 in test_cell
    assert 2 in test_cell
    assert 3 in test_cell
    assert 4 not in test_cell
    with pytest.raises(TypeError):
        test_cell.__getitem__("a")
    with pytest.raises(IndexError):
        test_cell.__getitem__(3)
    assert str(test_cell).startswith("<SpiceCell")
Exemplo n.º 5
0
def test_SpiceCell():
    testCell = stypes.SPICEINT_CELL(8)
    spice.appndi(1, testCell)
    spice.appndi(2, testCell)
    spice.appndi(3, testCell)
    assert [x for x in testCell] == [1, 2, 3]
    assert len(testCell) == 3
    assert 1 in testCell
    assert 2 in testCell
    assert 3 in testCell
    assert 4 not in testCell
    with pytest.raises(TypeError):
        testCell.__getitem__('a')
    with pytest.raises(IndexError):
        testCell.__getitem__(3)
    assert str(testCell).startswith("<SpiceCell")
Exemplo n.º 6
0
def test_cell_equality():
    cell = stypes.Cell_Int(8)
    assert cell == []
    spice.appndi(1, cell)
    spice.appndi(2, cell)
    spice.appndi(3, cell)
    assert not cell == []
    assert not cell == [1]
    assert not cell == [1, 2]
    assert cell == [1, 2, 3]
    assert not cell == [1, 2, 3, 4]
    celld = stypes.Cell_Double(8)
    spice.appndd(1.1, celld)
    spice.appndd(2.2, celld)
    spice.appndd(3.3, celld)
    assert celld == [1.1, 2.2, 3.3]
    assert not celld == cell
Exemplo n.º 7
0
def test_cell_equality():
    cell = stypes.Cell_Int(8)
    assert cell == []
    spice.appndi(1, cell)
    spice.appndi(2, cell)
    spice.appndi(3, cell)
    assert not cell == []
    assert not cell == [1]
    assert not cell == [1, 2]
    assert cell == [1, 2, 3]
    assert not cell == [1, 2, 3, 4]
    celld = stypes.Cell_Double(8)
    spice.appndd(1.1, celld)
    spice.appndd(2.2, celld)
    spice.appndd(3.3, celld)
    assert celld == [1.1, 2.2, 3.3]
    assert not celld == cell
Exemplo n.º 8
0
def test_Cell_Int():
    cell = stypes.Cell_Int(8)
    spice.appndi(1, cell)
    spice.appndi(2, cell)
    spice.appndi(3, cell)
    assert [x for x in cell] == [1, 2, 3]
Exemplo n.º 9
0
def test_Cell_Int():
    cell = stypes.Cell_Int(8)
    spice.appndi(1, cell)
    spice.appndi(2, cell)
    spice.appndi(3, cell)
    assert [x for x in cell] == [1,2,3]