Get Number of Bits in Exponent of Floating Point Representation in Python

AmitDiwan
Updated on 24-Feb-2022 10:39:21

611 Views

To get the number of bits in the exponent portion of the floating point representation, use the iexp attribute of the numpy.finfo() method in Python Numpy. The first parameter is the float i.e. the kind of float data type to get information about.StepsAt first, import the required library −import numpy as npChecking for float16 type. The iexp is to get the number of bits in the exponent portion. The min is the minimum value of given dtype. The max is the minimum value of given dtype. −a = np.finfo(np.float16(45.9)) print("Number of bits in the exponent portion float16 type...", a.iexp) print("Minimum ... Read More

Conductor Material Required in Single Phase Overhead AC Transmission System

Manish Kumar Saini
Updated on 24-Feb-2022 10:38:22

2K+ Views

Single-Phase AC Transmission SystemThe electric power transmission system in which two conductors viz. phase conductor and neutral wire are used to transmit the electric power is known as single phase AC transmission system.The single phase AC transmission system can be classified into following three types viz. −Single-phase two-wire system with one conductor earthedSingle-phase two-wire system with mid-point earthedSingle-phase three-wire systemConductor Material Required in 1-Phase 2-Wire System with One Conductor EarthedThe single phase two wire AC system with one conductor earthed is shown in Figure-1.Let, $\mathrm{Power\: transmitted\mathrm{\, =\, }\mathit{P}}$$\mathrm{Maximum \: voltage \: between\: conductors\mathrm{\, =\, }\mathit{V_{m}}}$$\mathrm{RMS\: value\: of \: voltage\mathrm{\, =\, ... Read More

Compute Hyperbolic Tangent of Array Elements in Python

AmitDiwan
Updated on 24-Feb-2022 10:36:47

204 Views

To compute the Hyperbolic tangent of the array elements, use the numpy.tanh() method in Python Numpy. The method is equivalent to np.sinh(x)/np.cosh(x) or -1j * np.tan(1j*x). Returns the corresponding hyperbolic tangent values. This is a scalar if x is a scalar. The 1st parameter, x is input array. 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 is returned.The 3rd parameter is the condition is broadcast over the input. ... Read More

Compute the Hyperbolic Tangent in Python

AmitDiwan
Updated on 24-Feb-2022 10:34:42

492 Views

To compute the Hyperbolic tangent, use the numpy.tanh() method in Python Numpy. Equivalent to np.sinh(x)/np.cosh(x) or -1j * np.tan(1j*x). Returns the corresponding hyperbolic tangent values. This is a scalar if x is a scalar. The 1st parameter, x is input array. 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 is returned.The 3rd parameter is the condition is broadcast over the input. At locations where the condition is True, ... Read More

Get Machine Limits Information for Float Types in Python

AmitDiwan
Updated on 24-Feb-2022 10:32:24

674 Views

To get the machine limits information for float types, use the numpy.finfo() method in Python Numpy. The first parameter is the floating type i.e. the kind of float data type to get information about.StepsAt first, import the required library −import numpy as npThe min is the minimum value of given dtype and max is the minimum value of given dtype.Checking for float16 type −a = np.finfo(np.float16) print("Minimum of float16 type...", a.min) print("Maximum of float16 type...", a.max)Checking for float32 type −b = np.finfo(np.float32) print("Minimum of float32 type...", b.min) print("Maximum of float32 type...", b.max)Checking for float64 type −c = np.finfo(np.float64) print("Minimum of ... Read More

Get Machine Limits Information for int with Instances in Python

AmitDiwan
Updated on 24-Feb-2022 10:30:52

187 Views

To get the machine limits information for integer types, use the numpy.iinfo() method in Python Numpy. The first parameter is the int_type i.e. the kind of integer data type to get information about.StepsAt first, import the required library −import numpy as npThe min is the minimum value of given dtype and max is the minimum value of given dtype.Checking for int16 type with instances −a = np.iinfo(np.int16(20)) print("Minimum of int16 type...", a.min) print("Maximum of int16 type...", a.max)Checking for int32 type with instances −b = np.iinfo(np.int32(30)) print("Minimum of int32 type...", b.min) print("Maximum of int32 type...", b.max)Checking for int64 type with instances ... Read More

Get Machine Limits Information for Integer Types in Python

AmitDiwan
Updated on 24-Feb-2022 10:28:50

290 Views

To get the machine limits information for integer types, use the numpy.iinfo() method in Python Numpy. The first parameter is the int_type i.e. the kind of integer data type to get information about.StepsAt first, import the required library −import numpy as npThe min is the minimum value of given dtype and max is the minimum value of given dtype.Checking for int16 type −a = np.iinfo(np.int16) print("Minimum of int16 type...", a.min) print("Maximum of int16 type...", a.max)Checking for int32 type −b = np.iinfo(np.int32) print("Minimum of int32 type...", b.min) print("Maximum of int32 type...", b.max)Checking for int64 type −c = np.iinfo(np.int64) print("Minimum of int64 ... Read More

Return Scalar Dtype or Numpy Equivalent of Python Type

AmitDiwan
Updated on 24-Feb-2022 10:27:08

284 Views

To return the scalar dtype or NumPy equivalent of Python type of an object, use the numpy.obj2sctype() method. The 1st parameter is the object of which the type is returned The default parameter, if given, is returned for objects whose types cannot be determined. If not given, None is returned for those objects.StepsAt first, import the required library −import numpy as npTo return the scalar dtype or NumPy equivalent of Python type of an object, use the numpy.obj2sctype() method −print("Using the obj2sctype() method in Numpy")Checking for int −print("Result...", np.obj2sctype(np.array([45, 89]))) print("Result...", np.obj2sctype(np.array([389, 7985])))Checking for float −print("Result...", np.obj2sctype(np.float32)) print("Result...", np.obj2sctype(np.float64)) print("Result...", ... Read More

Return a Common Scalar Type from Input Arrays in Python

AmitDiwan
Updated on 24-Feb-2022 10:24:33

456 Views

To return a scalar type which is common to the input arrays, use the numpy.common_type() method in Python Numpy. The 1st parameter is the input array(s). The return type will always be an inexact (i.e. floating point) scalar type, even if all the arrays are integer arrays. If one of the inputs is an integer array, the minimum precision type that is returned is a 64-bit floating point dtype.All input arrays except int64 and uint64 can be safely cast to the returned dtype without loss of information.StepsAt first, import the required library −import numpy as npTo return a scalar type ... Read More

Return True if Cast Between Array, Scalar and Data Type Can Occur in Python

AmitDiwan
Updated on 24-Feb-2022 10:22:41

168 Views

The numpy.can_cast() method returns True if array scalar and data type can occur according to the casting rule. The 1st parameter is the scalar or data type or array to cast from. The 2nd parameter is the data type to cast to.StepsAt first, import the required library −import numpy as npChecking if array scalar and data type can occur according to the casting rule −print("Checking with can_cast() method in Numpy") print("Result...", np.can_cast(np.array(20), 'i1')) print("Result...", np.can_cast(np.array(280), 'i1')) print("Result...", np.can_cast(np.array(80), 'u1')) print("Result...", np.can_cast(np.array(300.7), np.float32)) print("Result...", np.can_cast(np.array(120.6), np.float64)) print("Result...", np.can_cast(np.array(7.2e100), np.float32)) print("Result...", np.can_cast(np.array(6.5e100), np.float64))Exampleimport numpy as np # The numpy.can_cast() method returns ... Read More

Advertisements