def test_data_type_failure(self): d_d = Descriptor(128, ctypes.c_double) d_d[:] = 1 nose.tools.assert_equal(d_d.sum(), 128) nose.tools.assert_raises(VitalDynamicCastException, Descriptor, from_cptr=d_d.c_pointer, ctype=ctypes.c_float) d_f = Descriptor(128, ctypes.c_float) d_f[:] = 1 nose.tools.assert_equal(d_f.sum(), 128) nose.tools.assert_raises(VitalDynamicCastException, Descriptor, from_cptr=d_f.c_pointer, ctype=ctypes.c_double)
def test_desc(self): # Some random initialized descriptor d = Descriptor() d[:] = 1 nose.tools.assert_equal(d.sum(), d.size) ts = TrackState(0, descriptor=d) numpy.testing.assert_equal(d, ts.descriptor)
def test_raw_data(self): d = Descriptor(64) d[:] = 1 nose.tools.assert_equal(d.sum(), 64) # Check that slicing the array data yields an array with the same # values. d2 = d[:] numpy.testing.assert_equal(d.todoublearray(), d2)
def test_data_type_failure(self): d_d = Descriptor(128, ctypes.c_double) d_d[:] = 1 nose.tools.assert_equal(d_d.sum(), 128) nose.tools.assert_raises( VitalDynamicCastException, Descriptor, from_cptr=d_d.c_pointer, ctype=ctypes.c_float ) d_f = Descriptor(128, ctypes.c_float) d_f[:] = 1 nose.tools.assert_equal(d_f.sum(), 128) nose.tools.assert_raises( VitalDynamicCastException, Descriptor, from_cptr=d_f.c_pointer, ctype=ctypes.c_double )
def test_raw_data(self): d = Descriptor(64) d[:] = 1 nose.tools.assert_equal(d.sum(), 64) d2 = d[:] numpy.testing.assert_almost_equal(d, d2) d2[:] = 2 numpy.testing.assert_almost_equal(d, d2)
def test_raw_data(self): d = Descriptor(64) d[:] = 1 nose.tools.assert_equal(d.sum(), 64) # Check that slicing the array data yields an array with the same # values. d2 = d[:] numpy.testing.assert_almost_equal(d, d2) # Check that modifying the sliced array shared the same data as the # parent descriptor. d2[:] = 2 numpy.testing.assert_almost_equal(d, d2)