My QA Projects

QA Projects I was involded.

View on GitHub

NumPy

Applications

pip install numpy
pip3 install numpy

NumPy Arrays

Numpy Arrays versus Python List

NumPy Array Efficiency

np . array Constructor

np.array(object, dtype)

# return a new NumPy array from a given object
# object can be any array like object
# dtype is the type of the array
# if not specified, it will be set automatically based on contents of the object

Integer Types

   
np.bool boolean
np.int8 byte (-128-127)
np.int16 16bit-signed-integere (-2hoch15 to 2 hoch 15 -1)
np.int32 32bit-signed-integere (-2hoch31 to 2 hoch 31 -1)
np.int64 64bit-signed-integere (-2hoch63 to 2 hoch 63 -1)

Unsigned Types

   
np.uint8 byte (0 - 256)
np.uint16 16bit-signed-integere (0 to 2 hoch 16)
np.uint32 32bit-signed-integere (0 to 2 hoch 32)
np.uint64 64bit-signed-integere (0 to 2 hoch 64)

Float/Complex Types

   
np.float32 float
np.float64 double
np.complex64 float complex
np.complex128 double complex

One Dimensional Array Creation

a1 = np.array([1.2,32.4,7.5,3.4])
# one dimensional array from a list of floats
# np.array selcts a type based on the input we have given it

Two Dimensional Array Creation

a2 = np.array([2,4,10,15,13], [5,3,2,13,7],dtype=np.int16 )
# the argument is a list of lists, and the list of lists has two lists, so it makes a 
# two dimensional array 

Array Population Methods

Operators

Arithmetic Operators Example

a = np.array([2,10,-4, 5, 3.7, 80])
print(a + 2)
print(a * 10-5)
# Output [ 4. 12. -2. 7. 5.7 82. ]
			 [ 15. 95. -45. 45. 32. 795. ]
# we are not using a for loop

Comparison Operators Example

a = np.array([2, 10, -4, 5, 3.7, 80])
print(a == 10)
print(a >= 5)
# Output [ False True False False False False ]
			 [ False True False True False True ]
# we are not using a for loop

Other Methods


Recommendations