How to use _check_source_dtype method in pandera

Best Python code snippet using pandera_python

engine.py

Source: engine.py Github

copy

Full Screen

...58 def dtype(data_type: Any) -> DataType:59 raise ValueError(f"Data type '{data_type}' not understood")60 cls._registry[engine] = _DtypeRegistry(dispatch=dtype, equivalents={})61 return engine62 def _check_source_dtype(cls, data_type: Any) -> None:63 if isinstance(data_type, cls._base_pandera_dtypes) or (64 inspect.isclass(data_type)65 and issubclass(data_type, cls._base_pandera_dtypes)66 ):67 base_names = [68 f"{base.__module__}.{base.__qualname__}"69 for base in cls._base_pandera_dtypes70 ]71 raise ValueError(72 f"Subclasses of {base_names} cannot be registered"73 f" with {cls.__name__}."74 )75 def _register_from_parametrized_dtype(76 cls,77 pandera_dtype_cls: Type[DataType],78 ) -> None:79 method = pandera_dtype_cls.__dict__["from_parametrized_dtype"]80 if not isinstance(method, classmethod):81 raise ValueError(82 f"{pandera_dtype_cls.__name__}.from_parametrized_dtype "83 + "must be a classmethod."84 )85 func = method.__func__86 annotations = get_type_hints(func).values()87 dtype = next(iter(annotations)) # get 1st annotation88 # parse typing.Union89 dtypes = typing_inspect.get_args(dtype) or [dtype]90 def _method(*args, **kwargs):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 be...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Test strategy and how to communicate it

I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.

How To Write End-To-End Tests Using Cypress App Actions

When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.

Pair testing strategy in an Agile environment

Pair testing can help you complete your testing tasks faster and with higher quality. But who can do pair testing, and when should it be done? And what form of pair testing is best for your circumstance? Check out this blog for more information on how to conduct pair testing to optimize its benefits.

LIVE With Automation Testing For OTT Streaming Devices ????

People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.

Different Ways To Style CSS Box Shadow Effects

Have you ever visited a website that only has plain text and images? Most probably, no. It’s because such websites do not exist now. But there was a time when websites only had plain text and images with almost no styling. For the longest time, websites did not focus on user experience. For instance, this is how eBay’s homepage looked in 1999.

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