Python Notes
zip: returns a list of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables.
Python __repr__() function returns the object representation. It could be any valid python expression such as tuple, dictionary, string etc.
id(object): return the "identity" of an object. This is an integer which is guaranteed to be unique and constant for this object during its lifetime. Two objects with non-overlapping lifetimes may have the same id() value.
hasattr()
The hasattr() method returns true if an object has the given named attribute and false if it does not.
hasattr(object, name)
PIL.Image.resize(size, resample = 0)
returns a resized copy of this image
Parameters:
-size: the requested size in pixels, as a 2-tuple
-resample: an optional resampling filter. This can be one of PIL.Image.NEAREST(use nearest neighbour), PIL.Image.BILINEAR(linear interpolation in a 2x2 environment), PIL.Image.BICUBIC(cubic spline interpolation in a 4x4 environment) or PIL.Image.ANTIALIAS(a high-quality downsampling filter). If omitted, or if the image has mode "1" or "P", it is set PIL.Image.NEAREST.
return an Image object.
np.prod(a, axis = None)
returns the product of array elements over a given axis
isinstance(object, type)
returns true if the specified object is of the specified type, otherwise false
If the type parameter is a tuple, this function will return true if the object is one of the types in the tuple.
PIL: python image library
np.cumsum(a, axis = None)
return the cumulative sum of the elements along a given axis
Mahotas: Computer Vision in Python
Mahotas is a computer vision and image processing library for Python.
np.ravel(a, order='C')
return a contiguous flattened array.
parameters: a: array_like, input array, the elements in a are read in the order specified by order and packed as a 1-D array.
order: {'C', 'F', 'A', 'K'}, optional
'C': index the elements in row-major
'F': index the elements in column-major
a = [1, 2, 3]
b = ['a', 'b', 'c']
for i, j in zip(a, b):
print(i,j)
=>1 a
=>2 b
=>3 c
Python __repr__() function returns the object representation. It could be any valid python expression such as tuple, dictionary, string etc.
id(object): return the "identity" of an object. This is an integer which is guaranteed to be unique and constant for this object during its lifetime. Two objects with non-overlapping lifetimes may have the same id() value.
hasattr()
The hasattr() method returns true if an object has the given named attribute and false if it does not.
hasattr(object, name)
PIL.Image.resize(size, resample = 0)
returns a resized copy of this image
Parameters:
-size: the requested size in pixels, as a 2-tuple
-resample: an optional resampling filter. This can be one of PIL.Image.NEAREST(use nearest neighbour), PIL.Image.BILINEAR(linear interpolation in a 2x2 environment), PIL.Image.BICUBIC(cubic spline interpolation in a 4x4 environment) or PIL.Image.ANTIALIAS(a high-quality downsampling filter). If omitted, or if the image has mode "1" or "P", it is set PIL.Image.NEAREST.
return an Image object.
np.prod(a, axis = None)
returns the product of array elements over a given axis
isinstance(object, type)
returns true if the specified object is of the specified type, otherwise false
If the type parameter is a tuple, this function will return true if the object is one of the types in the tuple.
PIL: python image library
np.cumsum(a, axis = None)
return the cumulative sum of the elements along a given axis
Mahotas: Computer Vision in Python
Mahotas is a computer vision and image processing library for Python.
np.ravel(a, order='C')
return a contiguous flattened array.
parameters: a: array_like, input array, the elements in a are read in the order specified by order and packed as a 1-D array.
order: {'C', 'F', 'A', 'K'}, optional
'C': index the elements in row-major
'F': index the elements in column-major
Comments
Post a Comment