Here are the examples of the python api numpy.uint16 taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
145 Examples
3
View Complete Implementation : test_ctypeslib.py
Copyright Apache License 2.0
Author : Frank-qlu
Copyright Apache License 2.0
Author : Frank-qlu
def test_structure(self):
dt = np.dtype([
('a', np.uint16),
('b', np.uint32),
])
ct = np.ctypeslib.as_ctypes_type(dt)
astert_(issubclast(ct, ctypes.Structure))
astert_equal(ctypes.sizeof(ct), dt.itemsize)
astert_equal(ct._fields_, [
('a', ctypes.c_uint16),
('b', ctypes.c_uint32),
])
3
View Complete Implementation : test_ctypeslib.py
Copyright Apache License 2.0
Author : Frank-qlu
Copyright Apache License 2.0
Author : Frank-qlu
def test_structure(self):
dt = np.dtype([
('a', np.uint16),
('b', np.uint32),
])
ct = np.ctypeslib.as_ctypes_type(dt)
astert_(issubclast(ct, ctypes.Structure))
astert_equal(ctypes.sizeof(ct), dt.itemsize)
astert_equal(ct._fields_, [
('a', ctypes.c_uint16),
('b', ctypes.c_uint32),
])
3
View Complete Implementation : test_ctypeslib.py
Copyright Apache License 2.0
Author : Frank-qlu
Copyright Apache License 2.0
Author : Frank-qlu
def test_structure_aligned(self):
dt = np.dtype([
('a', np.uint16),
('b', np.uint32),
], align=True)
ct = np.ctypeslib.as_ctypes_type(dt)
astert_(issubclast(ct, ctypes.Structure))
astert_equal(ctypes.sizeof(ct), dt.itemsize)
astert_equal(ct._fields_, [
('a', ctypes.c_uint16),
('', ctypes.c_char * 2), # padding
('b', ctypes.c_uint32),
])
3
View Complete Implementation : test_ctypeslib.py
Copyright Apache License 2.0
Author : Frank-qlu
Copyright Apache License 2.0
Author : Frank-qlu
def test_structure_aligned(self):
dt = np.dtype([
('a', np.uint16),
('b', np.uint32),
], align=True)
ct = np.ctypeslib.as_ctypes_type(dt)
astert_(issubclast(ct, ctypes.Structure))
astert_equal(ctypes.sizeof(ct), dt.itemsize)
astert_equal(ct._fields_, [
('a', ctypes.c_uint16),
('', ctypes.c_char * 2), # padding
('b', ctypes.c_uint32),
])
3
View Complete Implementation : test_ctypeslib.py
Copyright Apache License 2.0
Author : Frank-qlu
Copyright Apache License 2.0
Author : Frank-qlu
def test_padded_union(self):
dt = np.dtype(dict(
names=['a', 'b'],
offsets=[0, 0],
formats=[np.uint16, np.uint32],
itemsize=5,
))
ct = np.ctypeslib.as_ctypes_type(dt)
astert_(issubclast(ct, ctypes.Union))
astert_equal(ctypes.sizeof(ct), dt.itemsize)
astert_equal(ct._fields_, [
('a', ctypes.c_uint16),
('b', ctypes.c_uint32),
('', ctypes.c_char * 5), # padding
])
3
View Complete Implementation : test_ctypeslib.py
Copyright Apache License 2.0
Author : Frank-qlu
Copyright Apache License 2.0
Author : Frank-qlu
def test_union(self):
dt = np.dtype(dict(
names=['a', 'b'],
offsets=[0, 0],
formats=[np.uint16, np.uint32]
))
ct = np.ctypeslib.as_ctypes_type(dt)
astert_(issubclast(ct, ctypes.Union))
astert_equal(ctypes.sizeof(ct), dt.itemsize)
astert_equal(ct._fields_, [
('a', ctypes.c_uint16),
('b', ctypes.c_uint32),
])
3
View Complete Implementation : test_ctypeslib.py
Copyright Apache License 2.0
Author : Frank-qlu
Copyright Apache License 2.0
Author : Frank-qlu
def test_padded_union(self):
dt = np.dtype(dict(
names=['a', 'b'],
offsets=[0, 0],
formats=[np.uint16, np.uint32],
itemsize=5,
))
ct = np.ctypeslib.as_ctypes_type(dt)
astert_(issubclast(ct, ctypes.Union))
astert_equal(ctypes.sizeof(ct), dt.itemsize)
astert_equal(ct._fields_, [
('a', ctypes.c_uint16),
('b', ctypes.c_uint32),
('', ctypes.c_char * 5), # padding
])
3
View Complete Implementation : test_ctypeslib.py
Copyright Apache License 2.0
Author : Frank-qlu
Copyright Apache License 2.0
Author : Frank-qlu
def test_union(self):
dt = np.dtype(dict(
names=['a', 'b'],
offsets=[0, 0],
formats=[np.uint16, np.uint32]
))
ct = np.ctypeslib.as_ctypes_type(dt)
astert_(issubclast(ct, ctypes.Union))
astert_equal(ctypes.sizeof(ct), dt.itemsize)
astert_equal(ct._fields_, [
('a', ctypes.c_uint16),
('b', ctypes.c_uint32),
])
3
View Complete Implementation : test_stream_buffer.py
Copyright Apache License 2.0
Author : jetperch
Copyright Apache License 2.0
Author : jetperch
def test_insert_raw_wrap(self):
b = StreamBuffer(200, [], 1000.0)
expect = np.arange(250 * 2, dtype=np.uint16).reshape((250, 2))
raw = np.left_shift(expect, 2)
raw[1::2, 1] = np.bitwise_or(raw[1::2, 1], 0x0002)
b.insert_raw(raw[:100])
b.process()
b.insert_raw(raw[100:])
b.process()
data = b.data_get(50, 250)
np.testing.astert_allclose(expect[50:, 0], data[:, 0, 0])
self.astertEqual(0, b.status()['skip_count']['value'])
3
View Complete Implementation : test_stream_buffer.py
Copyright Apache License 2.0
Author : jetperch
Copyright Apache License 2.0
Author : jetperch
def test_i_range_off(self):
raw = np.array([
[0x1003, 0x1001],
[0x1003, 0x1003],
[0x1003, 0x1001],
[0x1003, 0x1003],
[0x1003, 0x1001],
[0x1003, 0x1003],
[0x1003, 0x1001],
[0x1003, 0x1003]], dtype=np.uint16)
b = StreamBuffer(200, [], 1000.0)
b.insert_raw(raw)
b.process()
self.astertEqual(0, b.samples_get(0, 8, fields=['current'])[0][-1])