Here are the examples of the python api numpy.uint32 taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
165 Examples
5
Example 1
@property
def events(self):
if self._events is None:
n = self.header['NumberEvents']
offset = self.offset + self.header.nbytes
self._events = []
for i in range(n):
entry_size = self.ifdentry.tiff.get_value (offset, numpy.uint32)
time = self.ifdentry.tiff.get_value(offset+4, numpy.float64)
event_type = self.ifdentry.tiff.get_value(offset + 4+8, numpy.uint32)
unknown = self.ifdentry.tiff.get_value(offset + 4+8+4, numpy.uint32)
descr = self.ifdentry.tiff.get_string(offset + 4+8+4+4)
self._events.append(EventEntry(entry_size, time, event_type, unknown, descr))
offset += entry_size
return self._events
5
Example 2
def calcMasterChecksum(self, directory):
# calculate checkSumAdjustment
tags = self.tables.keys()
checksums = numpy.zeros(len(tags)+1, numpy.uint32)
for i in range(len(tags)):
checksums[i] = self.tables[tags[i]].checkSum
directory_end = sfntDirectorySize + len(self.tables) * sfntDirectoryEntrySize
assert directory_end == len(directory)
checksums[-1] = calcChecksum(directory)
checksum = numpy.add.reduce(checksums,dtype=numpy.uint32)
# BiboAfba!
checksumadjustment = int(numpy.subtract.reduce(numpy.array([0xB1B0AFBA, checksum], numpy.uint32)))
# write the checksum to the file
self.file.seek(self.tables['head'].offset + 8)
self.file.write(struct.pack(">L", checksumadjustment))
5
Example 3
def __init__(self, entry, type_name, label, data):
self._offset = None
self.record = (entry, type_name, label, data)
self.footer = None
if type_name == 'ASCII':
self.type = 2
self.header = numpy.array([entry, 2, len(data)+1], dtype=numpy.uint32).view(dtype=numpy.ubyte)
elif type_name == 'LONG':
self.type = 4
self.header = numpy.array([entry, 4, 4], dtype=numpy.uint32).view(dtype=numpy.ubyte)
elif type_name == 'DOUBLE':
self.type = 5
self.header = numpy.array([entry, 5, 8], dtype=numpy.uint32).view(dtype=numpy.ubyte)
elif type_name == 'SUBBLOCK':
self.type = 0
self.header = numpy.array([entry, 0, 0], dtype=numpy.uint32).view(dtype=numpy.ubyte)
else:
raise NotImplementedError (repr(self.record))
3
Example 4
Project: distributions Source File: betabinomial.py
def simtwo(alpha, beta, n, ITERS):
counts = np.zeros((ITERS, 2), dtype=np.uint32)
thetas = np.random.beta(alpha, beta, size=ITERS)
for i in range(ITERS):
if i % 1000000 == 0:
print i
counts[i] = np.random.binomial(n, thetas[i], size=2)
return counts
3
Example 5
Project: CudaTree Source File: random_tree.py
def __allocate_numpyarrays(self):
f = self.forest
self.left_children = np.zeros(self.n_samples * 2, dtype = np.uint32)
self.right_children = np.zeros(self.n_samples * 2, dtype = np.uint32)
self.feature_idx_array = np.zeros(2 * self.n_samples, dtype = np.uint16)
self.feature_threshold_array = np.zeros(2 * self.n_samples, dtype = np.float32)
self.idx_array = f.idx_array
self.si_idx_array = f.si_idx_array
self.nid_array = f.nid_array
self.values_idx_array = f.values_idx_array
self.values_si_idx_array = f.values_si_idx_array
self.threshold_value_idx = f.threshold_value_idx
self.min_imp_info = f.min_imp_info
self.features_array = f.features_array
3
Example 6
Project: git-vanity Source File: git_vanity.py
def hex2target(hex_prefix):
"""Returns 5*int32 0-padded target and bit length based on hex prefix"""
data = hex_prefix + ('0' * (40 - len(hex_prefix)))
target = np.array(
[int(data[i*8 : (i+1)*8], 16) for i in range(5)],
dtype=np.uint32)
return target, len(hex_prefix)*4
3
Example 7
Project: ale_python_interface Source File: ale_python_interface.py
def getScreenRGB(self,screen_data=None):
"""This function fills screen_data with the data
screen_data MUST be a numpy array of uint32/int32. This can be initialized like so:
screen_data = np.array(w*h,dtype=np.uint32)
Notice, it must be width*height in size also
If it is None, then this function will initialize it
"""
if(screen_data is None):
width = ale_lib.getScreenWidth(self.obj)
height = ale_lib.getScreenWidth(self.obj)
screen_data = np.zeros(width*height,dtype=np.uint32)
ale_lib.getScreenRGB(self.obj,as_ctypes(screen_data))
return screen_data
3
Example 8
Project: oq-engine Source File: source.py
def init_serials(self):
"""
Generate unique seeds for each rupture with numpy.arange.
This should be called only in event based calculators
"""
n = sum(sg.tot_ruptures() for sg in self.src_groups)
rup_serial = numpy.arange(n, dtype=numpy.uint32)
start = 0
for src in self.get_sources():
nr = src.num_ruptures
src.serial = rup_serial[start:start + nr]
start += nr
3
Example 9
def test_add_V32uV32u_V64u(self):
a_tmp = self.a.astype(numpy.uint32)
b_tmp = self.b.astype(numpy.uint32)
c = numpy.empty([self.n]).astype(numpy.uint64)
a_ptr = a_tmp.ctypes.data_as(ctypes.POINTER(ctypes.c_uint32))
b_ptr = b_tmp.ctypes.data_as(ctypes.POINTER(ctypes.c_uint32))
c_ptr = c.ctypes.data_as(ctypes.POINTER(ctypes.c_uint64))
yepCore_Add_V32uV32u_V64u(a_ptr, b_ptr, c_ptr, self.n)
for i in range(self.n):
self.assertEqual(a_tmp[i] + b_tmp[i], c[i])
3
Example 10
Project: gprMax Source File: grid.py
def initialise_geometry_arrays(self):
"""Initialise an array for volumetric material IDs (solid); boolean arrays for specifying whether materials can have dielectric smoothing (rigid);
and an array for cell edge IDs (ID). Solid and ID arrays are initialised to free_space (one); rigid arrays to allow dielectric smoothing (zero).
"""
self.solid = np.ones((self.nx + 1, self.ny + 1, self.nz + 1), dtype=np.uint32)
self.rigidE = np.zeros((12, self.nx + 1, self.ny + 1, self.nz + 1), dtype=np.int8)
self.rigidH = np.zeros((6, self.nx + 1, self.ny + 1, self.nz + 1), dtype=np.int8)
self.IDlookup = {'Ex': 0, 'Ey': 1, 'Ez': 2, 'Hx': 3, 'Hy': 4, 'Hz': 5}
self.ID = np.ones((6, self.nx + 1, self.ny + 1, self.nz + 1), dtype=np.uint32)
3
Example 11
@operator
def over(src, dst):
sr, sg, sb, sa = extract_scaled(src)
dr, dg, db, da = extract_scaled(dst)
factor = 1 - sa
a = sa + da * factor
if a == 0:
return np.uint32(0)
r = (sr * sa + dr * da * factor)/a
g = (sg * sa + dg * da * factor)/a
b = (sb * sa + db * da * factor)/a
return combine_scaled(r, g, b, a)
3
Example 12
Project: pypcd Source File: pypcd.py
def decode_rgb_from_pcl(rgb):
rgb = rgb.copy()
rgb.dtype = np.uint32
r = np.asarray((rgb >> 16) & 255, dtype=np.uint8)
g = np.asarray((rgb >> 8) & 255, dtype=np.uint8)
b = np.asarray(rgb & 255, dtype=np.uint8)
rgb_arr = np.zeros((len(rgb), 3), dtype=np.uint8)
rgb_arr[:, 0] = r
rgb_arr[:, 1] = g
rgb_arr[:, 2] = b
return rgb_arr
3
Example 13
def hash(midstate, merkle_end, time, difficulty, nonce):
work = np.zeros(64, np.uint32)
work[0]=merkle_end; work[1]=time; work[2]=difficulty; work[3]=nonce
work[4]=0x80000000; work[5]=0x00000000; work[6]=0x00000000; work[7]=0x00000000
work[8]=0x00000000; work[9]=0x00000000; work[10]=0x00000000; work[11]=0x00000000
work[12]=0x00000000; work[13]=0x00000000; work[14]=0x00000000; work[15]=0x00000280
state = sha256(midstate, work)
work[0]=state[0]; work[1]=state[1]; work[2]=state[2]; work[3]=state[3]
work[4]=state[4]; work[5]=state[5]; work[6]=state[6]; work[7]=state[7]
work[8]=0x80000000; work[15]=0x00000100
return sha256(STATE, work)
3
Example 14
Project: distarray Source File: test_context.py
def test_apply_distarray(self):
da = self.context.empty((len(self.context.targets),),
dtype=numpy.uint32)
def local_label(la):
la.ndarray.fill(la.comm.rank)
# Testing that we can pass in `da`
# and `apply()` extracts `da.key` automatically.
self.context.apply(local_label, (da,))
assert_array_equal(da.tondarray(), range(len(self.context.targets)))
self.context.apply(local_label, kwargs={'la': da})
assert_array_equal(da.tondarray(), range(len(self.context.targets)))
3
Example 15
Project: word2gauss Source File: words.py
def tokenize_ids(self, s, remove_oov=True):
tokens = self._tokenizer(s)
if remove_oov:
return np.array([self.word2id(token)
for token in tokens if token in self._tokens],
dtype=np.uint32)
else:
ret = np.zeros(len(tokens), dtype=np.uint32)
for k, token in enumerate(tokens):
try:
ret[k] = self.word2id(token)
except KeyError:
ret[k] = LARGEST_UINT32
return ret
3
Example 16
def _make_box(self, c1, c2, margin):
self.update(c1, c2, margin)
self.indices = np.array([ [0,1,5,4],
[2,3,7,6],
[2,0,1,3],
[3,7,5,1],
[7,6,4,5],
[6,2,0,4] ], dtype = np.uint32)
self.vertices_nr = self.vertices.shape[0]
self.indices_nr = self.indices.size
self.vertices_ptr = self.vertices.ctypes.data
self.indices_ptr = self.indices.ctypes.data
3
Example 17
def _calculate_normals(self):
vertices, faces = self._vertices, self._faces
if faces is None:
# ensure it's always 2D so we can use our methods
faces = np.arange(0, vertices.size, dtype=np.uint32)[:, np.newaxis]
normals = _calculate_normals(vertices, faces)
return normals
3
Example 18
def _activate(self):
""" Activate framebuffer on GPU """
log.debug("GPU: Activate render framebuffer")
gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, self._handle)
if self._need_attach:
self._attach()
self._need_attach = False
attachments = [gl.GL_COLOR_ATTACHMENT0+i for i in range(len(self.color))]
gl.glDrawBuffers(np.array(attachments,dtype=np.uint32))
3
Example 19
def test_byteswap():
for val in (
1,
0x100,
0x10000):
a = np.array(val, dtype=np.uint32)
b = a.byteswap()
c = m5u.byteswap_u4(a)
assert_equal(b.item(), c)
d = m5u.byteswap_u4(c)
assert_equal(a.item(), d)
3
Example 20
Project: rasterizer.py Source File: glutwindow.py
def __init__(self, width, height, title):
super(GlutWindow, self).__init__()
self.width = width
self.height = height
self.title = title
self.texture_id = 0
self.vertices = None
self.pixels = np.zeros(self.width * self.height, np.uint32)
self.window = Window(self.pixels, self.width, self.height)
self.setup()
3
Example 21
Project: plip Source File: supplemental.py
def int32_to_negative(int32):
"""Checks if a suspicious number (e.g. ligand position) is in fact a negative number represented as a
32 bit integer and returns the actual number.
"""
dct = {}
if int32 == 4294967295: # Special case in some structures (note, this is just a workaround)
return -1
for i in range(-1000, -1):
dct[np.uint32(i)] = i
if int32 in dct:
return dct[int32]
else:
return int32
3
Example 22
Project: iris Source File: test_netcdf.py
def test_uint32_dimension_coord_netcdf3(self):
coord = iris.coords.DimCoord(np.array([1, 2], dtype=np.uint32),
long_name='x')
self.cube.add_dim_coord(coord, 0)
with self.temp_filename(suffix='.nc') as filename:
iris.save(self.cube, filename, netcdf_format='NETCDF3_CLASSIC')
reloaded = iris.load_cube(filename)
self.assertCML(reloaded, ('netcdf',
'uint32_dimension_coord_netcdf3.cml'),
checksum=False)
3
Example 23
@operator
def add(src, dst):
sr, sg, sb, sa = extract_scaled(src)
dr, dg, db, da = extract_scaled(dst)
a = min(1, sa + da)
if a == 0:
return np.uint32(0)
r = (sr * sa + dr * da)/a
g = (sg * sa + dg * da)/a
b = (sb * sa + db * da)/a
return combine_scaled(r, g, b, a)
3
Example 24
def get_rng():
global _random_state
if _random_state is None:
options, _ = parser.parse_known_args()
_random_state = np.random.RandomState(np.uint32(hash(options.random_seed)))
return _random_state
3
Example 25
@operator
def saturate(src, dst):
sr, sg, sb, sa = extract_scaled(src)
dr, dg, db, da = extract_scaled(dst)
a = min(1, sa + da)
if a == 0:
return np.uint32(0)
factor = min(sa, 1 - da)
r = (factor * sr + dr * da)/a
g = (factor * sg + dg * da)/a
b = (factor * sb + db * da)/a
return combine_scaled(r, g, b, a)
3
Example 26
def __init__(self, image, samplefac=10, colors=256):
# Check Numpy
if np is None:
raise RuntimeError("Need Numpy for the NeuQuant algorithm.")
# Check image
if image.size[0] * image.size[1] < NeuQuant.MAXPRIME:
raise IOError("Image is too small")
assert image.mode == "RGBA"
# Initialize
self.setconstants(samplefac, colors)
self.pixels = np.fromstring(image.tostring(), np.uint32)
self.setUpArrays()
self.learn()
self.fix()
self.inxbuild()
3
Example 27
def calcChecksum(data, start=0):
"""Calculate the checksum for an arbitrary block of data.
Optionally takes a 'start' argument, which allows you to
calculate a checksum in chunks by feeding it a previous
result.
If the data length is not a multiple of four, it assumes
it is to be padded with null byte.
"""
from fontTools import ttLib
remainder = len(data) % 4
if remainder:
data = data + '\0' * (4-remainder)
data = struct.unpack(">%dL"%(len(data)/4), data)
a = numpy.array((start,)+data, numpy.uint32)
return int(numpy.sum(a,dtype=numpy.uint32))
3
Example 28
def setUp(self):
seed = os.getenv("SEED")
seed = np.uint32(seed if seed else time.time())
print('Random test using SEED={}'.format(seed))
random.seed(seed)
np.random.seed(seed)
3
Example 29
Project: poclbm Source File: BFLMiner.py
def nonce_generator(self, nonces):
for nonce in nonces.split(b','):
if len(nonce) != 8: continue
try:
yield np.fromstring(unhexlify(nonce)[::-1], dtype=np.uint32, count=1)[0]
except TypeError:
pass
3
Example 30
def load_pkl(self, name):
""" Read hash table values from file <name>, return params """
with gzip.open(name, 'rb') as f:
temp = pickle.load(f)
assert temp.ht_version >= HT_COMPAT_VERSION
params = temp.params
self.hashbits = temp.hashbits
self.depth = temp.depth
if hasattr(temp, 'maxtimebits'):
self.maxtimebits = temp.maxtimebits
else:
self.maxtimebits = _bitsfor(temp.maxtime)
self.table = temp.table
self.counts = temp.counts
self.names = temp.names
self.hashesperid = np.array(temp.hashesperid).astype(np.uint32)
self.ht_version = temp.ht_version
self.dirty = False
return params
3
Example 31
Project: iris Source File: test_netcdf.py
def test_uint32_data_netcdf3(self):
self.cube.data = self.cube.data.astype(np.uint32)
with self.temp_filename(suffix='.nc') as filename:
iris.save(self.cube, filename, netcdf_format='NETCDF3_CLASSIC')
reloaded = iris.load_cube(filename)
self.assertCML(reloaded, ('netcdf',
'uint32_data_netcdf3.cml'))
3
Example 32
def __init__(self, minhash, b=1, r=0.0):
'''
Initialize a b-bit MinHash given an existing full MinHash
object and parameter b - the number of bits to store for
each minimum hashed values in the MinHash object.
'''
b = int(b)
r = float(r)
if b > 32 or b < 0:
raise ValueError("b must be an integer in [0, 32]")
if r > 1.0:
raise ValueError("r must be a float in [0.0, 1.0]")
bmask = (1 << b) - 1
self.hashvalues = np.bitwise_and(minhash.hashvalues, bmask)\
.astype(np.uint32)
self.seed = minhash.seed
self.b = b
self.r = r
3
Example 33
Project: friture Source File: spectrogram_image.py
def prepare_palette(self):
print("palette preparation")
N = 256
cmap = cmrmap.compute_colors(N)
self.colors = numpy.zeros((N), dtype=numpy.uint32)
for i in range(N):
self.colors[i] = QtGui.QColor(cmap[i, 0] * 255, cmap[i, 1] * 255, cmap[i, 2] * 255).rgb()
3
Example 34
Project: reikna Source File: cbrng_ref.py
def threefry_rotate(W, R, x):
# Cast to uint is required by numpy coercion rules.
# "% W" is technically redundant since R < W always.
s1 = numpy.uint32(R % W)
s2 = numpy.uint32((W - R) % W)
return (x << s1) | (x >> s2)
3
Example 35
Project: scikit-image Source File: test_texture.py
def test_output_empty(self):
result = greycomatrix(self.image, [10], [0], 4)
np.testing.assert_array_equal(result[:, :, 0, 0],
np.zeros((4, 4), dtype=np.uint32))
result = greycomatrix(self.image, [10], [0], 4, normed=True)
np.testing.assert_array_equal(result[:, :, 0, 0],
np.zeros((4, 4), dtype=np.uint32))
3
Example 36
Project: fos Source File: microcircuit_neurohdf.py
def map_vertices_id2index(vertices_id):
map_vertices_id2index = dict(zip(vertices_id,range(len(vertices_id))))
connectivity_indices = np.zeros( connectivity_id.shape, dtype=np.uint32 )
for i,c in enumerate(connectivity_id):
connectivity_indices[i,0]=map_vertices_id2index[connectivity_id[i,0]]
connectivity_indices[i,1]=map_vertices_id2index[connectivity_id[i,1]]
return connectivity_indices
3
Example 37
def _prepare_data(self, data, convert=False):
if isinstance(data, list):
data = np.array(data, dtype=np.uint32)
if not isinstance(data, np.ndarray):
raise ValueError('Data must be a ndarray (got %s)' % type(data))
if not data.dtype.isbuiltin:
raise TypeError("Element buffer dtype cannot be structured")
else:
if convert:
if data.dtype is not np.uint32:
data = data.astype(np.uint32)
else:
if data.dtype not in [np.uint32, np.uint16, np.uint8]:
raise TypeError("Invalid dtype for IndexBuffer: %r" %
data.dtype)
return data
3
Example 38
Project: fos-legacy Source File: network_primitives.py
def _make_edges(self, position, edges):
assert position.shape[1] == 3
assert edges.shape[1] == 2
nr = len(edges)
self.nr_edges = nr
self.vertices = position
self.indices = edges.ravel()
self.vertices = self.vertices[self.indices,:]
self.indices = np.array( range(len(self.indices)), dtype = np.uint32)
self.indices_ptr = self.indices.ctypes.data
self.indices_nr = self.indices.size
self.vertices_nr = self.vertices.size
self.vertices_ptr = self.vertices.ctypes.data
3
Example 39
@property
def Z(self):
if self._Z is None:
self._Z = []
for Tk in self.Ts:
self._Z.append(np.zeros((Tk, 1+self.K*self.B), dtype=np.uint32))
return self._Z
3
Example 40
def test(self):
groups = parser.parse_groups(MIXED_SRC_MODEL)
([point], [cmplx], [area, simple],
[char_simple, char_complex, char_multi]) = groups
fh, self.path = tempfile.mkstemp(suffix='.hdf5')
os.close(fh)
print('Writing on %s' % self.path)
self.i = 0
self.sids = numpy.array([0], numpy.uint32)
self.events = numpy.array([(0, 1, 1, 0)], calc.event_dt)
self.write_read(point)
self.write_read(char_simple)
self.write_read(char_complex)
self.write_read(char_multi)
3
Example 41
Project: Yeppp Source File: sse_add_test.py
def test_add_V32uV32u_V64u(self):
a_tmp = self.a.astype(numpy.uint32)
b_tmp = self.b.astype(numpy.uint32)
c = numpy.empty([self.n]).astype(numpy.uint64)
a_ptr = a_tmp.ctypes.data_as(ctypes.POINTER(ctypes.c_uint32))
b_ptr = b_tmp.ctypes.data_as(ctypes.POINTER(ctypes.c_uint32))
c_ptr = c.ctypes.data_as(ctypes.POINTER(ctypes.c_uint64))
func = sse.add.yepCore_Add.yepCore_Add_V32uV32u_V64u.load()
self.assertEqual(func(a_ptr, b_ptr, c_ptr, self.n), 0)
for i in range(self.n):
self.assertEqual(a_tmp[i] + b_tmp[i], c[i])
3
Example 42
def _delete(self):
""" Delete texture from GPU """
log.debug("GPU: Deleting texture")
if self.handle > -1:
gl.glDeleteTextures(np.array([self.handle], dtype=np.uint32))
3
Example 43
def _zerofill(self, table, numdays):
# Compute the number of minutes to be filled, accounting for the
# possibility of a partial day's worth of minutes existing for
# the previous day.
minute_offset = len(table) % self._minutes_per_day
num_to_prepend = numdays * self._minutes_per_day - minute_offset
prepend_array = np.zeros(num_to_prepend, np.uint32)
# Fill all OHLCV with zeros.
table.append([prepend_array] * 5)
table.flush()
3
Example 44
Project: westpa Source File: data_reader.py
def get_seg_ids(self, n_iter, bool_array = None):
try:
all_ids = self.__c_seg_id_ranges[n_iter]
except KeyError:
all_ids = self.__c_seg_id_ranges[n_iter] = numpy.arange(0,len(self.get_seg_index(n_iter)), dtype=numpy.uint32)
if bool_array is None:
return all_ids
else:
seg_ids = all_ids[bool_array]
try:
if len(seg_ids) == 0: return []
except TypeError:
# Not iterable, for some bizarre reason
return [seg_ids]
else:
return seg_ids
3
Example 45
Project: hope Source File: test_cast.py
@pytest.mark.parametrize("dtype", [dtype for dtype in dtypes if dtype != float])
def test_func_uint32(dtype):
def fkt(a):
return np.uint32(a)
hfkt = hope.jit(fkt)
ao, ah = random(dtype, [])
co, ch = fkt(ao), hfkt(ah)
assert type(co) == type(ch)
3
Example 46
Project: numexpr Source File: test_numexpr.py
def test_small_uint32(self):
# Small uint32 should not be downgraded to ints.
a = np.uint32(42)
res = evaluate('a')
assert_array_equal(res, 42)
self.assertEqual(res.dtype.name, 'int64')
3
Example 47
def perform(self, editor):
i1 = self.start_index
i2 = self.end_index
if i2 < i1:
i1, i2 = i2, i1
self.undo_info = undo = UndoInfo()
undo.flags.byte_values_changed = True
undo.flags.index_range = i1, i2
undo.flags.cursor_index = self.end_index
line = np.asarray(self.get_points(i1, i2, editor.map_width), dtype=np.uint32)
old_data = self.segment[line].copy()
self.segment[line] = self.get_data(old_data)
if (self.segment[line] == old_data).all():
undo.flags.success = False
undo.data = (line, old_data)
return undo
3
Example 48
Project: iris Source File: test_netcdf.py
def test_uint32_auxiliary_coord_netcdf3(self):
coord = iris.coords.AuxCoord(np.array([1, 2], dtype=np.uint32),
long_name='x')
self.cube.add_aux_coord(coord, 0)
with self.temp_filename(suffix='.nc') as filename:
iris.save(self.cube, filename, netcdf_format='NETCDF3_CLASSIC')
reloaded = iris.load_cube(filename)
self.assertCML(reloaded, ('netcdf',
'uint32_auxiliary_coord_netcdf3.cml'),
checksum=False)
3
Example 49
def __init__(self, image, samplefac=10, colors=256):
# Check Numpy
if np is None:
raise RuntimeError("Need Numpy for the NeuQuant algorithm.")
# Check image
if image.size[0] * image.size[1] < NeuQuant.MAXPRIME:
raise IOError("Image is too small")
if image.mode != "RGBA":
raise IOError("Image mode should be RGBA.")
# Initialize
self.setconstants(samplefac, colors)
self.pixels = np.fromstring(image.tostring(), np.uint32)
self.setup_arrays()
self.learn()
self.fix()
self.inxbuild()
3
Example 50
def __init__(self):
self.i = 1
self.f = 1.
self.ai = np.array([1, 2, 3], dtype=np.uint32)
self.af = np.array([1, 2, 3], dtype=np.float32)
self.res = np.array([0, 0, 0], dtype=np.float32)
self.obj = SubCls()