コード例 #1
0
 def test_NtTable(self):
     print()
     nColumns = random.randint(3, 10)
     dim = random.randint(10, 100)
     print('Using {} columns of size: {}'.format(nColumns, dim))
     maxInt = int(math.fabs(TestUtility.getRandomInt()))
     print('Using Max Int for array element: {}'.format(maxInt))
     ntTable = NtTable(nColumns, INT)
     labels = []
     columns = []
     for i in range(0, nColumns):
         labels.append('Col%d' % (i + 1))
         columns.append(
             list(
                 np.random.randint(-maxInt,
                                   maxInt,
                                   size=dim,
                                   dtype=np.int32)))
         ntTable.setColumn(i, columns[i])
     ntTable.setLabels(labels)
     TestUtility.assertListEquality(ntTable['labels'], labels)
     for i in range(0, nColumns):
         a1 = ntTable.getColumn(i)
         a2 = columns[i]
         TestUtility.assertListEquality(a1, a2)
コード例 #2
0
ファイル: testChannelPut.py プロジェクト: epics-base/pvaPy
 def testPutULong_ULong(self):
     print()
     value = TestUtility.getRandomULong()
     c = TestUtility.getULongChannel()
     c.putULong(value)
     value2 = c.get().getPyObject()
     print('Testing equality: %d == %d' % (value2, value))
     assert (value == value2)
コード例 #3
0
 def test_Boolean(self):
     value = TestUtility.getRandomBoolean()
     pv = PvObject({'v': BOOLEAN}, {'v': value})
     assert (pv['v'] == value)
     value = TestUtility.getRandomBoolean()
     pv['v'] = value
     assert (pv['v'] == value)
     value = TestUtility.getRandomBoolean()
     pv.setBoolean(value)
     assert (pv.getBoolean() == value)
コード例 #4
0
 def test_String(self):
     value = TestUtility.getRandomString()
     pv = PvObject({'v': STRING}, {'v': value})
     assert (pv['v'] == value)
     value = TestUtility.getRandomString()
     pv['v'] = value
     assert (pv['v'] == value)
     value = TestUtility.getRandomString()
     pv.setString(value)
     assert (pv.getString() == value)
コード例 #5
0
 def test_UByte(self):
     value = TestUtility.getRandomUByte()
     pv = PvObject({'v': UBYTE}, {'v': value})
     assert (pv['v'] == value)
     value = TestUtility.getRandomUByte()
     pv['v'] = value
     assert (pv['v'] == value)
     value = TestUtility.getRandomUByte()
     pv.setUByte(value)
     assert (pv.getUByte() == value)
コード例 #6
0
 def test_UShort(self):
     value = TestUtility.getRandomUShort()
     pv = PvObject({'v': USHORT}, {'v': value})
     assert (pv['v'] == value)
     value = TestUtility.getRandomUShort()
     pv['v'] = value
     assert (pv['v'] == value)
     value = TestUtility.getRandomUShort()
     pv.setUShort(value)
     assert (pv.getUShort() == value)
コード例 #7
0
 def test_ULong(self):
     value = TestUtility.getRandomULong()
     pv = PvObject({'v': ULONG}, {'v': value})
     assert (pv['v'] == value)
     value = TestUtility.getRandomULong()
     pv['v'] = value
     assert (pv['v'] == value)
     value = TestUtility.getRandomULong()
     pv.setULong(value)
     assert (pv.getULong() == value)
コード例 #8
0
 def test_Int(self):
     value = TestUtility.getRandomInt()
     pv = PvObject({'v': INT}, {'v': value})
     assert (pv['v'] == value)
     value = TestUtility.getRandomInt()
     pv['v'] = value
     assert (pv['v'] == value)
     value = TestUtility.getRandomInt()
     pv.setInt(value)
     assert (pv.getInt() == value)
コード例 #9
0
ファイル: testChannelPut.py プロジェクト: epics-base/pvaPy
 def testPut_ULong(self):
     print()
     # put(ulong) will be mapped to put(long) in python,
     # resulting in overflow errors;
     # simply use positive long for this test
     value = TestUtility.getRandomPositiveLong()
     c = TestUtility.getULongChannel()
     print('Test value: %d' % (value))
     c.put(value)
     value2 = c.get().getPyObject()
     print('Testing equality: %d == %d' % (value2, value))
     assert (value == value2)
コード例 #10
0
 def test_Float(self):
     value = TestUtility.getRandomFloat()
     pv = PvObject({'v': FLOAT}, {'v': value})
     TestUtility.assertFloatEquality(pv['v'], value)
     value = TestUtility.getRandomFloat()
     pv['v'] = value
     TestUtility.assertFloatEquality(pv['v'], value)
     value = TestUtility.getRandomFloat()
     pv.setFloat(value)
     TestUtility.assertFloatEquality(pv.getFloat(), value)
コード例 #11
0
 def test_Double(self):
     value = TestUtility.getRandomDouble()
     pv = PvObject({'v': DOUBLE}, {'v': value})
     TestUtility.assertDoubleEquality(pv['v'], value)
     value = TestUtility.getRandomDouble()
     pv['v'] = value
     TestUtility.assertDoubleEquality(pv['v'], value)
     value = TestUtility.getRandomDouble()
     pv.setDouble(value)
     TestUtility.assertDoubleEquality(pv.getDouble(), value)
コード例 #12
0
    def test_VariantUnion(self):
        value = TestUtility.getRandomInt()
        pv = PvObject({'v': ()}, {'v': PvInt(value)})
        u = pv['v'][0]
        assert (u['value'] == value)

        value = TestUtility.getRandomString()
        pv['v'] = PvString(value)
        u = pv['v'][0]
        assert (u['value'] == value)

        value = TestUtility.getRandomFloat()
        pv.setUnion(PvFloat(value))
        u = pv['v'][0]
        TestUtility.assertFloatEquality(u['value'], value)
コード例 #13
0
 def test_NtNdArray(self):
     print()
     timeStamp = TestUtility.getTimeStamp()
     id = random.randint(0, 100000)
     nx = 1024
     ny = 1024
     nda = NtNdArray()
     nda['uniqueId'] = id
     dims = [
         PvDimension(nx, 0, nx, 1, False),
         PvDimension(ny, 0, ny, 1, False)
     ]
     nda['codec'] = PvCodec('pvapyc', PvInt(14))
     nda['dimension'] = dims
     nda['descriptor'] = 'PvaPy Simulated Image'
     nda['compressedSize'] = nx * ny
     nda['uncompressedSize'] = nx * ny
     nda['timeStamp'] = timeStamp
     nda['dataTimeStamp'] = timeStamp
     attrs = [NtAttribute('ColorMode', PvInt(0))]
     nda['attribute'] = attrs
     value = np.random.randint(0, 256, size=nx * ny, dtype=np.uint8)
     nda['value'] = {'ubyteValue': value}
     value2 = nda['value'][0]['ubyteValue']
     print('Comparing image arrays {} to {}'.format(value2, value))
     assert (np.array_equiv(value, value2))
コード例 #14
0
    def test_StructureArray(self):
        STRUCTURE = {
            's': STRING,
            'i': INT,
            'ru': ({
                'i': INT,
                'd': DOUBLE,
                's': STRING
            }, ),
            'vu': (),
            'st': {
                'i': INT,
                'd': DOUBLE,
                's': STRING
            },
        }
        size = TestUtility.getRandomListSize()
        pv = PvObject({'v': [STRUCTURE]})
        structureList = []
        for i in range(0, size):
            pv2 = PvObject(STRUCTURE)
            value = TestUtility.getRandomString()
            pv2['s'] = value

            value = TestUtility.getRandomInt()
            pv2['i'] = value

            value = TestUtility.getRandomInt()
            unionPv = PvObject({'i': INT}, {'i': value})
            pv2['ru'] = unionPv

            value = TestUtility.getRandomString()
            pv2['vu'] = PvString(value)

            value = TestUtility.getRandomInt()
            pv2['st.i'] = value
            value = TestUtility.getRandomString()
            pv2['st.s'] = value
            value = TestUtility.getRandomDouble()
            pv2['st.d'] = value

            structureList.append(pv2)
        pv['v'] = structureList

        sa = pv['v']
        for i in range(0, size):
            pv2 = sa[i]
            assert (pv2['s'] == structureList[i]['s'])
            assert (pv2['i'] == structureList[i]['i'])
            ru = pv2['ru'][0]
            assert (ru['i'] == structureList[i]['ru'][0]['i'])
            vu = pv2['vu'][0]
            assert (vu['value'] == structureList[i]['vu'][0]['value'])
            assert (pv2['st']['i'] == structureList[i]['st.i'])
            assert (pv2['st']['s'] == structureList[i]['st.s'])
            assert (pv2['st']['d'] == structureList[i]['st.d'])
コード例 #15
0
    def test_VariantUnionArray(self):
        size = TestUtility.getRandomListSize()
        pv = PvObject({'v': [()]})
        unionList = []
        for i in range(0, size):
            value = TestUtility.getRandomInt()
            unionList.append(PvInt(value))

        pv['v'] = unionList
        ul = pv['v']
        for i in range(0, size):
            uli = ul[i][0]
            assert (uli['value'] == unionList[i]['value'])

        unionList.reverse()
        pv.setUnionArray(unionList)
        ul = pv.getUnionArray()
        for i in range(0, size):
            uli = ul[i]
            assert (uli['value'] == unionList[i]['value'])
コード例 #16
0
    def test_ScalarArray(self):
        value = TestUtility.getRandomInt()
        size = TestUtility.getRandomListSize()
        valueList = [value] * size
        pv = PvObject({'vl': [INT]}, {'vl': valueList})
        vl = pv['vl']
        assert (len(vl) == len(valueList))
        assert (vl[0] == valueList[0])
        assert (vl[-1] == valueList[-1])

        value = TestUtility.getRandomInt()
        size = TestUtility.getRandomListSize()
        valueList = [value] * size
        pv['vl'] = valueList
        vl = pv['vl']
        assert (len(vl) == len(valueList))
        assert (vl[0] == valueList[0])
        assert (vl[-1] == valueList[-1])

        value = TestUtility.getRandomInt()
        size = TestUtility.getRandomListSize()
        valueList = [value] * size
        pv.setScalarArray(valueList)
        vl = pv.getScalarArray()
        assert (len(vl) == len(valueList))
        assert (vl[0] == valueList[0])
        assert (vl[-1] == valueList[-1])
コード例 #17
0
    def test_RestrictedUnion(self):
        value = TestUtility.getRandomInt()
        unionPv = PvObject({'i': INT}, {'i': value})
        pv = PvObject({'v': ({
            'i': INT,
            'f': FLOAT,
            's': STRING
        }, )}, {'v': unionPv})
        u = pv['v'][0]
        assert (u['i'] == value)

        value = TestUtility.getRandomString()
        unionPv = PvObject({'s': STRING}, {'s': value})
        pv['v'] = unionPv
        u = pv['v'][0]
        assert (u['s'] == value)

        value = TestUtility.getRandomFloat()
        unionPv = PvObject({'f': FLOAT}, {'f': value})
        pv.setUnion(unionPv)
        u = pv['v'][0]
        TestUtility.assertFloatEquality(u['f'], value)
コード例 #18
0
    def test_Structure(self):
        pv = PvObject({
            's': STRING,
            'i': INT,
            'ru': ({
                'i': INT,
                'd': DOUBLE,
                's': STRING
            }, ),
            'vu': (),
            'st': {
                'i': INT,
                'd': DOUBLE,
                's': STRING
            },
        })
        value = TestUtility.getRandomString()
        pv['s'] = value
        assert (pv['s'] == value)

        value = TestUtility.getRandomInt()
        pv['i'] = value
        assert (pv['i'] == value)

        value = TestUtility.getRandomInt()
        unionPv = PvObject({'i': INT}, {'i': value})
        pv['ru'] = unionPv
        u = pv['ru'][0]
        assert (u['i'] == value)

        value = TestUtility.getRandomString()
        pv['vu'] = PvString(value)
        u = pv['vu'][0]
        assert (u['value'] == value)

        value = TestUtility.getRandomInt()
        pv['st.i'] = value
        assert (pv['st.i'] == value)
コード例 #19
0
    def testPut_IntDouble(self):
        iv = TestUtility.getRandomInt()
        ic = TestUtility.getIntChannel()

        dv = TestUtility.getRandomDouble()
        dc = TestUtility.getDoubleChannel()

        mc = MultiChannel([ic.getName(), dc.getName()])
        mc.put([PvInt(iv), PvDouble(dv)])
        pv = mc.get()
        iv2 = pv['value'][0][0]['value']
        assert (iv2 == iv)
        dv2 = pv['value'][1][0]['value']
        TestUtility.assertDoubleEquality(dv, dv2)
コード例 #20
0
    def test_RestrictedUnionArray(self):
        size = TestUtility.getRandomListSize()
        pv = PvObject({'v': [({'i': INT, 's': STRING, 'd': DOUBLE}, )]})
        unionList = []
        for i in range(0, size):
            if i % 3 == 0:
                value = TestUtility.getRandomInt()
                unionList.append(PvObject({'i': INT}, {'i': value}))
            elif i % 3 == 1:
                value = TestUtility.getRandomString()
                unionList.append(PvObject({'s': STRING}, {'s': value}))
            else:
                value = TestUtility.getRandomDouble()
                unionList.append(PvObject({'d': DOUBLE}, {'d': value}))

        pv['v'] = unionList
        ul = pv['v']
        for i in range(0, size):
            uli = ul[i][0]
            if 'i' in uli:
                assert (uli['i'] == unionList[i]['i'])
            elif 's' in uli:
                assert (uli['s'] == unionList[i]['s'])
            else:
                TestUtility.assertDoubleEquality(uli['d'], unionList[i]['d'])

        unionList.reverse()
        pv.setUnionArray(unionList)
        ul = pv['v']
        for i in range(0, size):
            uli = ul[i][0]
            if 'i' in uli:
                assert (uli['i'] == unionList[i]['i'])
            elif 's' in uli:
                assert (uli['s'] == unionList[i]['s'])
            else:
                TestUtility.assertDoubleEquality(uli['d'], unionList[i]['d'])
コード例 #21
0
ファイル: testChannelPut.py プロジェクト: pheest/pvaPy
 def testPutShort_Short(self):
     value = TestUtility.getRandomShort()
     c = TestUtility.getShortChannel()
     c.putShort(value)
     value2 = c.get().getPyObject()
     assert(value == value2)
コード例 #22
0
ファイル: testChannelPut.py プロジェクト: epics-base/pvaPy
 def testPut_PvLong(self):
     value = TestUtility.getRandomLong()
     c = TestUtility.getLongChannel()
     c.put(PvLong(value))
     value2 = c.get().getPyObject()
     assert (value == value2)
コード例 #23
0
ファイル: testChannelPut.py プロジェクト: epics-base/pvaPy
 def testPutUInt_UInt(self):
     value = TestUtility.getRandomUInt()
     c = TestUtility.getUIntChannel()
     c.putUInt(value)
     value2 = c.get().getPyObject()
     assert (value == value2)
コード例 #24
0
ファイル: testChannelPut.py プロジェクト: pheest/pvaPy
 def testPutUByte_UByte(self):
     value = TestUtility.getRandomUByte()
     c = TestUtility.getUByteChannel()
     c.putUByte(value)
     value2 = c.get().getPyObject()
     assert(value == value2)
コード例 #25
0
ファイル: testChannelPut.py プロジェクト: epics-base/pvaPy
 def testPutDouble_Double(self):
     value = TestUtility.getRandomDouble()
     c = TestUtility.getDoubleChannel()
     c.putDouble(value)
     value2 = c.get().getPyObject()
     TestUtility.assertDoubleEquality(value, value2)
コード例 #26
0
ファイル: testChannelPut.py プロジェクト: pheest/pvaPy
 def testPut_PvByte(self):
     value = chr(TestUtility.getRandomUByte())
     c = TestUtility.getByteChannel()
     c.put(PvByte(value))
     value2 = c.get().getPyObject()
     assert(value == value2)
コード例 #27
0
ファイル: testChannelPut.py プロジェクト: pheest/pvaPy
 def testPut_Byte(self):
     value = TestUtility.getRandomByte()
     c = TestUtility.getByteChannel()
     c.put(value)
     value2 = c.get().getPyObject() # Same as: value2 = c.get().getByte()
     TestUtility.assertCharEquality(value,value2)
コード例 #28
0
ファイル: testChannelPut.py プロジェクト: pheest/pvaPy
 def testPutString_String(self):
     value = TestUtility.getRandomString()
     c = TestUtility.getStringChannel()
     c.putString(value)
     value2 = c.get().getPyObject()
     assert(value == value2)
コード例 #29
0
ファイル: testChannelPut.py プロジェクト: pheest/pvaPy
 def testPutBoolean_Boolean(self):
     value = TestUtility.getRandomBoolean()
     c = TestUtility.getBooleanChannel()
     c.putBoolean(value)
     value2 = c.get().getPyObject()
     assert(value == value2)
コード例 #30
0
ファイル: testChannelPut.py プロジェクト: pheest/pvaPy
 def testPut_Boolean(self):
     value = TestUtility.getRandomBooleanString()
     c = TestUtility.getBooleanChannel()
     c.put(value)
     value2 = c.get().getPyObject()
     TestUtility.assertBooleanEquality(value,value2)
コード例 #31
0
ファイル: testChannelPutGet.py プロジェクト: pheest/pvaPy
 def testPutGetLong_Long(self):
     value = TestUtility.getRandomLong()
     c = TestUtility.getLongChannel()
     value2 = c.putGetLong(value).getPyObject()
     assert(value == value2)
コード例 #32
0
ファイル: testChannelPut.py プロジェクト: epics-base/pvaPy
 def testPutUByte_UByte(self):
     value = TestUtility.getRandomUByte()
     c = TestUtility.getUByteChannel()
     c.putUByte(value)
     value2 = c.get().getPyObject()
     assert (value == value2)
コード例 #33
0
ファイル: testChannelPut.py プロジェクト: epics-base/pvaPy
 def testPut_PvByte(self):
     value = chr(TestUtility.getRandomUByte())
     c = TestUtility.getByteChannel()
     c.put(PvByte(value))
     value2 = c.get().getPyObject()
     assert (value == value2)
コード例 #34
0
ファイル: testChannelPut.py プロジェクト: epics-base/pvaPy
 def testPutString_String(self):
     value = TestUtility.getRandomString()
     c = TestUtility.getStringChannel()
     c.putString(value)
     value2 = c.get().getPyObject()
     assert (value == value2)
コード例 #35
0
ファイル: testChannelPut.py プロジェクト: epics-base/pvaPy
 def testPutFloat_Float(self):
     value = TestUtility.getRandomFloat()
     c = TestUtility.getFloatChannel()
     c.putFloat(value)
     value2 = c.get().getPyObject()
     TestUtility.assertFloatEquality(value, value2)
コード例 #36
0
ファイル: testChannelPut.py プロジェクト: pheest/pvaPy
 def testPut_PvUShort(self):
     value = TestUtility.getRandomUShort()
     c = TestUtility.getUShortChannel()
     c.put(PvUShort(value))
     value2 = c.get().getPyObject()
     assert(value == value2)
コード例 #37
0
ファイル: testChannelPut.py プロジェクト: epics-base/pvaPy
 def testPut_Boolean(self):
     value = TestUtility.getRandomBooleanString()
     c = TestUtility.getBooleanChannel()
     c.put(value)
     value2 = c.get().getPyObject()
     TestUtility.assertBooleanEquality(value, value2)
コード例 #38
0
ファイル: testChannelPut.py プロジェクト: pheest/pvaPy
 def testPutInt_UInt(self):
     value = TestUtility.getRandomUInt()
     c = TestUtility.getUIntChannel()
     c.putInt(value)
     value2 = c.get().getPyObject()
     assert(value == value2)
コード例 #39
0
ファイル: testChannelPut.py プロジェクト: epics-base/pvaPy
 def testPutBoolean_Boolean(self):
     value = TestUtility.getRandomBoolean()
     c = TestUtility.getBooleanChannel()
     c.putBoolean(value)
     value2 = c.get().getPyObject()
     assert (value == value2)
コード例 #40
0
ファイル: testChannelPut.py プロジェクト: pheest/pvaPy
 def testPut_ULong(self):
     value = TestUtility.getRandomULong()
     c = TestUtility.getULongChannel()
     c.put(value)
     value2 = c.get().getPyObject() 
     assert(value == value2)
コード例 #41
0
ファイル: testChannelPut.py プロジェクト: epics-base/pvaPy
 def testPut_Byte(self):
     value = TestUtility.getRandomByte()
     c = TestUtility.getByteChannel()
     c.put(value)
     value2 = c.get().getPyObject()  # Same as: value2 = c.get().getByte()
     TestUtility.assertCharEquality(value, value2)
コード例 #42
0
ファイル: testChannelPut.py プロジェクト: pheest/pvaPy
 def testPutFloat_Float(self):
     value = TestUtility.getRandomFloat()
     c = TestUtility.getFloatChannel()
     c.putFloat(value)
     value2 = c.get().getPyObject()
     TestUtility.assertFloatEquality(value, value2)
コード例 #43
0
ファイル: testChannelPut.py プロジェクト: pheest/pvaPy
 def testPutDouble_Double(self):
     value = TestUtility.getRandomDouble()
     c = TestUtility.getDoubleChannel()
     c.putDouble(value)
     value2 = c.get().getPyObject()
     TestUtility.assertDoubleEquality(value, value2)
コード例 #44
0
ファイル: testChannelPutGet.py プロジェクト: pheest/pvaPy
 def testPutGetInt_Int(self):
     value = TestUtility.getRandomInt()
     c = TestUtility.getIntChannel()
     value2 = c.putGetInt(value).getPyObject()
     assert(value == value2)