How to use _draw_loop_dimensions method in hypothesis

Best Python code snippet using hypothesis

numpy.py

Source: numpy.py Github

copy

Full Screen

...708 self.size_one_allowed = self.min_side <= 1 <= self.max_side709 def do_draw(self, data):710 # We don't usually have a gufunc signature; do the common case first & fast.711 if self.signature is None:712 return self._draw_loop_dimensions(data)713 # When we *do*, draw the core dims, then draw loop dims, and finally combine.714 core_in, core_res = self._draw_core_dimensions(data)715 # If some core shape has omitted optional dimensions, it's an error to add716 # loop dimensions to it. We never omit core dims if min_dims >= 1.717 # This ensures that we respect Numpy's gufunc broadcasting semantics and user718 # constraints without needing to check whether the loop dims will be719 # interpreted as an invalid substitute for the omitted core dims.720 # We may implement this check later!721 use = [None not in shp for shp in core_in]722 loop_in, loop_res = self._draw_loop_dimensions(data, use=use)723 def add_shape(loop, core):724 return tuple(x for x in (loop + core)[-32:] if x is not None)725 return BroadcastableShapes(726 input_shapes=tuple(add_shape(l, c) for l, c in zip(loop_in, core_in)),727 result_shape=add_shape(loop_res, core_res),728 )729 def _draw_core_dimensions(self, data):730 # Draw gufunc core dimensions, with None standing for optional dimensions731 # that will not be present in the final shape. We track omitted dims so732 # that we can do an accurate per-shape length cap.733 dims = {}734 shapes = []735 for shape in self.signature.input_shapes + (self.signature.result_shape,):736 shapes.append([])737 for name in shape:738 if name.isdigit():739 shapes[-1].append(int(name))740 continue741 if name not in dims:742 dim = name.strip("?")743 dims[dim] = data.draw(self.side_strat)744 if self.min_dims == 0 and not data.draw_bits(3):745 dims[dim + "?"] = None746 else:747 dims[dim + "?"] = dims[dim]748 shapes[-1].append(dims[name])749 return tuple(tuple(s) for s in shapes[:-1]), tuple(shapes[-1])750 def _draw_loop_dimensions(self, data, use=None):751 # All shapes are handled in column-major order; i.e. they are reversed752 base_shape = self.base_shape[::-1]753 result_shape = list(base_shape)754 shapes = [[] for _ in range(self.num_shapes)]755 if use is None:756 use = [True for _ in range(self.num_shapes)]757 else:758 assert len(use) == self.num_shapes759 assert all(isinstance(x, bool) for x in use)760 for dim_count in range(1, self.max_dims + 1):761 dim = dim_count - 1762 # We begin by drawing a valid dimension-size for the given763 # dimension. This restricts the variability across the shapes764 # at this dimension such that they can only choose between...

Full Screen

Full Screen

_array_helpers.py

Source: _array_helpers.py Github

copy

Full Screen

...429 self.size_one_allowed = self.min_side <= 1 <= self.max_side430 def do_draw(self, data):431 # We don't usually have a gufunc signature; do the common case first & fast.432 if self.signature is None:433 return self._draw_loop_dimensions(data)434 # When we *do*, draw the core dims, then draw loop dims, and finally combine.435 core_in, core_res = self._draw_core_dimensions(data)436 # If some core shape has omitted optional dimensions, it's an error to add437 # loop dimensions to it. We never omit core dims if min_dims >= 1.438 # This ensures that we respect Numpy's gufunc broadcasting semantics and user439 # constraints without needing to check whether the loop dims will be440 # interpreted as an invalid substitute for the omitted core dims.441 # We may implement this check later!442 use = [None not in shp for shp in core_in]443 loop_in, loop_res = self._draw_loop_dimensions(data, use=use)444 def add_shape(loop, core):445 return tuple(x for x in (loop + core)[-NDIM_MAX:] if x is not None)446 return BroadcastableShapes(447 input_shapes=tuple(add_shape(l_in, c) for l_in, c in zip(loop_in, core_in)),448 result_shape=add_shape(loop_res, core_res),449 )450 def _draw_core_dimensions(self, data):451 # Draw gufunc core dimensions, with None standing for optional dimensions452 # that will not be present in the final shape. We track omitted dims so453 # that we can do an accurate per-shape length cap.454 dims = {}455 shapes = []456 for shape in self.signature.input_shapes + (self.signature.result_shape,):457 shapes.append([])458 for name in shape:459 if name.isdigit():460 shapes[-1].append(int(name))461 continue462 if name not in dims:463 dim = name.strip("?")464 dims[dim] = data.draw(self.side_strat)465 if self.min_dims == 0 and not data.draw_bits(3):466 dims[dim + "?"] = None467 else:468 dims[dim + "?"] = dims[dim]469 shapes[-1].append(dims[name])470 return tuple(tuple(s) for s in shapes[:-1]), tuple(shapes[-1])471 def _draw_loop_dimensions(self, data, use=None):472 # All shapes are handled in column-major order; i.e. they are reversed473 base_shape = self.base_shape[::-1]474 result_shape = list(base_shape)475 shapes = [[] for _ in range(self.num_shapes)]476 if use is None:477 use = [True for _ in range(self.num_shapes)]478 else:479 assert len(use) == self.num_shapes480 assert all(isinstance(x, bool) for x in use)481 for dim_count in range(1, self.max_dims + 1):482 dim = dim_count - 1483 # We begin by drawing a valid dimension-size for the given484 # dimension. This restricts the variability across the shapes485 # at this dimension such that they can only choose between...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Joomla Testing Guide: How To Test Joomla Websites

Before we discuss the Joomla testing, let us understand the fundamentals of Joomla and how this content management system allows you to create and maintain web-based applications or websites without having to write and implement complex coding requirements.

Now Log Bugs Using LambdaTest and DevRev

In today’s world, an organization’s most valuable resource is its customers. However, acquiring new customers in an increasingly competitive marketplace can be challenging while maintaining a strong bond with existing clients. Implementing a customer relationship management (CRM) system will allow your organization to keep track of important customer information. This will enable you to market your services and products to these customers better.

Why Agile Teams Have to Understand How to Analyze and Make adjustments

How do we acquire knowledge? This is one of the seemingly basic but critical questions you and your team members must ask and consider. We are experts; therefore, we understand why we study and what we should learn. However, many of us do not give enough thought to how we learn.

27 Best Website Testing Tools In 2022

Testing is a critical step in any web application development process. However, it can be an overwhelming task if you don’t have the right tools and expertise. A large percentage of websites still launch with errors that frustrate users and negatively affect the overall success of the site. When a website faces failure after launch, it costs time and money to fix.

11 Best Mobile Automation Testing Tools In 2022

Mobile application development is on the rise like never before, and it proportionally invites the need to perform thorough testing with the right mobile testing strategies. The strategies majorly involve the usage of various mobile automation testing tools. Mobile testing tools help businesses automate their application testing and cut down the extra cost, time, and chances of human error.

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 hypothesis 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