Best Python code snippet using pandera_python
engine.py
Source:engine.py
...91 return func(pandera_dtype_cls, *args, **kwargs)92 for source_dtype in dtypes:93 cls._check_source_dtype(source_dtype)94 cls._registry[cls].dispatch.register(source_dtype, _method)95 def _register_equivalents(96 cls, pandera_dtype_cls: Type[DataType], *source_dtypes: Any97 ) -> None:98 pandera_dtype = pandera_dtype_cls() # type: ignore99 for source_dtype in source_dtypes:100 cls._check_source_dtype(source_dtype)101 cls._registry[cls].equivalents[source_dtype] = pandera_dtype102 def register_dtype(103 cls: _EngineType,104 pandera_dtype_cls: Type[_DataType] = None,105 *,106 equivalents: Optional[List[Any]] = None,107 ) -> Callable:108 """Register a Pandera :class:`~pandera.dtypes.DataType` with the engine,109 as class decorator.110 :param pandera_dtype: The DataType to register.111 :param equivalents: Equivalent scalar data type classes or112 non-parametrized data type instances.113 .. note::114 The classmethod ``from_parametrized_dtype`` will also be115 registered. See :ref:`here<dtypes>` for more usage details.116 :example:117 >>> import pandera as pa118 >>>119 >>> class MyDataType(pa.DataType):120 ... pass121 >>>122 >>> class MyEngine(123 ... metaclass=pa.engines.engine.Engine,124 ... base_pandera_dtypes=MyDataType,125 ... ):126 ... pass127 >>>128 >>> @MyEngine.register_dtype(equivalents=[bool])129 ... class MyBool(MyDataType):130 ... pass131 """132 def _wrapper(pandera_dtype_cls: Type[_DataType]) -> Type[_DataType]:133 if not inspect.isclass(pandera_dtype_cls):134 raise ValueError(135 f"{cls.__name__}.register_dtype can only decorate a class,"136 f" got {pandera_dtype_cls}"137 )138 if equivalents:139 cls._register_equivalents(pandera_dtype_cls, *equivalents)140 if "from_parametrized_dtype" in pandera_dtype_cls.__dict__:141 cls._register_from_parametrized_dtype(pandera_dtype_cls)142 cls._registered_dtypes.add(pandera_dtype_cls)143 return pandera_dtype_cls144 if pandera_dtype_cls:145 return _wrapper(pandera_dtype_cls)146 return _wrapper147 def dtype(cls: _EngineType, data_type: Any) -> _DataType:148 """Convert input into a Pandera :class:`DataType` object."""149 if isinstance(data_type, cls._base_pandera_dtypes):150 return data_type151 if inspect.isclass(data_type) and issubclass(152 data_type, cls._base_pandera_dtypes153 ):...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!