Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Numpy Articles
Page 43 of 81
Compute element-wise arc tangent of x1/x2 choosing the quadrant correctly in Python
The quadrant is chosen so that arctan2(x1, x2) is the signed angle in radians between the ray ending at the origin and passing through the point (1, 0), and the ray ending at the origin and passing through the point (x2, x1).The 1st parameter is the y-coordinates. The 2nd parameter is the x-coordinates. If x1.shape != x2.shape, they must be broadcastable to a common shape. The method returns array of angles in radians, in the range [-pi, pi]. This is a scalar if both x1 and x2 are scalars.StepsAt first, import the required library −import numpy as npCreating arrays using ...
Read MoreGet the Trigonometric inverse cosine in Python
The arccos is a multivalued function: for each x there are infinitely many numbers z such that cos(z) = x. The convention is to return the angle z whose real part lies in [0, pi]. For real-valued input data types, arccos always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag. For complex-valued input, arccos is a complex analytic function that has branch cuts [-inf, -1] and [1, inf] and is continuous from above on the former and from below on the ...
Read MoreCompute the determinant of an array in linear algebra in Python
To Compute the determinant of an array in linear algebra, use the np.linalg.det() in Python Numpy. The 1st parameter, a is the input array to compute determinants for. The method returns the determinant.StepsAt first, import the required libraries -import numpy as npCreate an array −arr = np.array([[ 5, 10], [12, 18]])Display the array −print("Our Array...", arr)Check the Dimensions −print("Dimensions of our Array...", arr.ndim)Get the Datatype −print("Datatype of our Array object...", arr.dtype)Get the Shape −print("Shape of our Array object...", arr.shape)To Compute the determinant of an array in linear algebra, use the np.linalg.det() in Python Numpy −print("Result (determinant)...", np.linalg.det(arr))Exampleimport numpy as np ...
Read MoreReturn True if first argument is a typecode lower/equal in type hierarchy in Python
To return True if first argument is a typecode lower/equal in type hierarchy, use the numpy.issubdtype() method in Python Numpy. The parameters are the dtype or object coercible to oneStepsAt first, import the required library −import numpy as npUsing the issubdtype() method in Numpy −print("Result...", np.issubdtype(np.float64, np.float32)) print("Result...", np.issubdtype(np.float64, np.floating)) print("Result...", np.issubdtype(np.float32, np.floating)) print("Result...", np.issubdtype('i4', np.signedinteger)) print("Result...", np.issubdtype('i8', np.signedinteger)) print("Result...", np.issubdtype(np.int32, np.integer))Exampleimport numpy as np # To return True if first argument is a typecode lower/equal in type hierarchy, use the numpy.issubdtype() method in Python Numpy. # The parameters are the dtype or object coercible to one print("Using ...
Read MoreReturn the imaginary part of the complex argument in Python
To return the imaginary part of the complex argument, use the numpy.imag() method. The method returns the imaginary component of the complex argument. If val is real, the type of val is used for the output. If val has complex elements, the returned type is float. The 1st parameter, val is the input arrayStepsAt first, import the required libraries -import numpy as npCreate an array using the array() method −arr = np.array([36.+5.j , 27.+3.j , 68.+2.j , 23.+7.j])Display the array −print("Our Array...", arr)Check the Dimensions −print("Dimensions of our Array...", arr.ndim) Get the Datatype −print("Datatype of our Array object...", arr.dtype)Get the ...
Read MoreReturn the data type with the smallest size and scalar kind to which both the given types be safely cast in Python
The numpy.promote_types() method returns the data type with the smallest size and smallest scalar kind to which both type1 and type2 may be safely cast. Returns the promoted data type. The returned data type is always in native byte order. The 1st parameter is the first data type. The 2nd parameter is the second data type.StepsAt first, import the required library −import numpy as npChecking with promote_types() method in Numpy −print("Result...", np.promote_types('f4', 'f8')) print("Result...", np.promote_types('i8', 'f4')) print("Result...", np.promote_types('>i8', 'i8', '
Read MoreReturn the cumulative sum of array elements over given axis treating NaNs as zero in Python
To return the cumulative sum of array elements over a given axis treating NaNs as zero, use the nancumprod() method. The cumulative sum does not change when NaNs are encountered and leading NaNs are replaced by zeros.Zeros are returned for slices that are all-NaN or empty. The method returns a new array holding the result unless out is specified, in which it is returned. The result has the same size as a, and the same shape as a if axis is not None or a is a 1-d array. Cumulative works like, 5, 5+10, 5+10+15, 5+10+15+20. The 1st parameter is ...
Read MoreGet the Trigonometric tangent of an array of angles given in degrees with Python
Trigonometric tangent is equivalent to np.sin(x)/np.cos(x) element-wise. To get the Trigonometric tangent of an array of angles given in degrees, use the numpy.tan() method in Python Numpy. The method returns the tangent of each element of the 1st parameter x. The 1st parameter, x, is an Angle, in radians (2pi means 360 degrees). Here, it is an array of angles.The 2nd and 3rd parameters are optional. The 2nd parameter is an ndarray, A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array ...
Read MoreReturn the gradient of an N-dimensional array over given axis in Python
The gradient is computed using second order accurate central differences in the interior points and either first or second order accurate one-sides (forward or backwards) differences at the boundaries. The returned gradient hence has the same shape as the input array. The 1st parameter, f is an Ndimensional array containing samples of a scalar function. The 2nd parameter is the varargs i.e. the spacing between f values. Default unitary spacing for all dimensions.The 3rd parameter is the edge_order{1, 2} i.e. the Gradient is calculated using N-th order accurate differences at the boundaries. Default: 1. The 4th parameter is the Gradient, ...
Read MoreTest whether similar float type of different sizes are subdtypes of floating class in Python
To test whether similar float type of different sizes are subdtypes of floating class, use the numpy.issubdtype() method in Python Numpy. The parameters are the dtype or object coercible to one.StepsAt first, import the required library −import numpy as npUsing the issubdtype() method in Numpy. Checking for floating point datatype with different sizes −print("Result...", np.issubdtype(np.float16, np.floating)) print("Result...", np.issubdtype(np.float32, np.floating)) print("Result...", np.issubdtype(np.float64, np.floating))Exampleimport numpy as np # To test whether similar float type of different sizes are subdtypes of floating class, use the numpy.issubdtype() method in Python Numpy. # The parameters are the dtype or object coercible to one print("Using ...
Read More