How to use register_dtype method in pandera

Best Python code snippet using pandera_python

dtypes.py

Source:dtypes.py Github

copy

Full Screen

...24OTHER DEALINGS IN THE SOFTWARE.25"""26# {{{ registry27NAME_TO_DTYPE = {}28def register_dtype(dtype, c_names):29 """30 Associate a numpy dtype with its C equivalents.31 :param dtype: type to associate32 :type dtype: numpy.dtype or string33 :param c_names: list of C type names34 :type c_names: str or list35 Will register `dtype` for use with the gpuarray module. If the36 c_names argument is a list then the first element of that list is37 taken as the primary association and will be used for generated C38 code. The other types will be mapped to the provided dtype when39 going in the other direction.40 """41 if isinstance(c_names, str):42 c_names = [c_names]43 dtype = np.dtype(dtype)44 # register if not already there45 try:46 gpuarray.dtype_to_ctype(dtype)47 except ValueError:48 gpuarray.register_dtype(dtype, c_names[0])49 for nm in c_names:50 if nm in NAME_TO_DTYPE and NAME_TO_DTYPE[nm] != dtype:51 raise RuntimeError("name '%s' already registered" % nm)52 NAME_TO_DTYPE[nm] = dtype53def _fill_dtype_registry(respect_windows):54 from sys import platform55 register_dtype(np.bool, ["ga_bool", "bool"])56 register_dtype(np.int8, ["ga_byte", "char", "signed char"])57 register_dtype(np.uint8, ["ga_ubyte", "unsigned char"])58 register_dtype(np.int16, ["ga_short", "short", "signed short", "signed short int", "short signed int"])59 register_dtype(np.uint16, ["ga_ushort", "unsigned short", "unsigned short int", "short unsigned int"])60 register_dtype(np.int32, ["ga_int", "int", "signed int"])61 register_dtype(np.uint32, ["ga_uint", "unsigned", "unsigned int"])62 register_dtype(np.int64, ["ga_long"])63 register_dtype(np.uint64, ["ga_ulong"])64 is_64_bit = tuple.__itemsize__ * 8 == 6465 if is_64_bit:66 if 'win32' in platform and respect_windows:67 i64_name = "long long"68 else:69 i64_name = "long"70 register_dtype(np.int64, [i64_name, "%s int" % i64_name,71 "signed %s int" % i64_name,72 "%s signed int" % i64_name])73 register_dtype(np.uint64, ["unsigned %s" % i64_name,74 "unsigned %s int" % i64_name,75 "%s unsigned int" % i64_name])76 # According to this uintp may not have the same hash as uint32:77 # http://projects.scipy.org/numpy/ticket/201778 # Failing tests tell me this is the case for intp too.79 if is_64_bit:80 register_dtype(np.intp, ["ga_long"])81 register_dtype(np.uintp, ["ga_ulong"])82 else:83 register_dtype(np.intp, ["ga_int"])84 register_dtype(np.uintp, ["ga_uint"])85 register_dtype(np.float32, ["ga_float", "float"])86 register_dtype(np.float64, ["ga_double", "double"])87# }}}88# {{{ dtype -> ctype89def dtype_to_ctype(dtype, with_fp_tex_hack=False):90 """91 Return the C type that corresponds to `dtype`.92 :param dtype: a numpy dtype93 """94 if dtype is None:95 raise ValueError("dtype may not be None")96 dtype = np.dtype(dtype)97 if with_fp_tex_hack:98 if dtype == np.float32:99 return "fp_tex_float"100 elif dtype == np.float64:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pandera automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful