How to use check_valid_minmax method in hypothesis

Best Python code snippet using hypothesis

array_api.py

Source: array_api.py Github

copy

Full Screen

...160 check_xp_attributes(xp, ["iinfo", "finfo"])161 if isinstance(dtype, str):162 dtype = dtype_from_name(xp, dtype)163 builtin = find_castable_builtin_for_dtype(xp, dtype)164 def check_valid_minmax(prefix, val, info_obj):165 name = f"{prefix}_value"166 check_valid_bound(val, name)167 check_argument(168 val >= info_obj.min,169 f"dtype={dtype} requires {name}={val} to be at least {info_obj.min}",170 )171 check_argument(172 val <= info_obj.max,173 f"dtype={dtype} requires {name}={val} to be at most {info_obj.max}",174 )175 if builtin is bool:176 return st.booleans()177 elif builtin is int:178 iinfo = xp.iinfo(dtype)179 if min_value is None:180 min_value = iinfo.min181 if max_value is None:182 max_value = iinfo.max183 check_valid_integer(min_value, "min_value")184 check_valid_integer(max_value, "max_value")185 assert isinstance(min_value, int)186 assert isinstance(max_value, int)187 check_valid_minmax("min", min_value, iinfo)188 check_valid_minmax("max", max_value, iinfo)189 check_valid_interval(min_value, max_value, "min_value", "max_value")190 return st.integers(min_value=min_value, max_value=max_value)191 else:192 finfo = xp.finfo(dtype)193 kw = {}194 # Whilst we know the boundary values of float dtypes from finfo, we do195 # not assign them to the floats() strategy by default - passing min/​max196 # values will modify test case reduction behaviour so that simple bugs197 # may become harder for users to identify. We plan to improve floats()198 # behaviour in https:/​/​github.com/​HypothesisWorks/​hypothesis/​issues/​2907.199 # Setting width should manage boundary values for us anyway.200 if min_value is not None:201 check_valid_bound(min_value, "min_value")202 assert isinstance(min_value, Real)203 check_valid_minmax("min", min_value, finfo)204 kw["min_value"] = min_value205 if max_value is not None:206 check_valid_bound(max_value, "max_value")207 assert isinstance(max_value, Real)208 check_valid_minmax("max", max_value, finfo)209 if min_value is not None:210 check_valid_interval(min_value, max_value, "min_value", "max_value")211 kw["max_value"] = max_value212 # We infer whether an array module will flush subnormals to zero, as may213 # be the case when libraries are built with compiler options that214 # violate IEEE-754 (e.g. -ffast-math and -ftz=true). Note we do this for215 # the specific dtype, as compilers may end up flushing subnormals for216 # one float but supporting subnormals for the other.217 #218 # By default, floats() will generate subnormals if they are in the219 # inferred values range. If we have detected that xp flushes to zero for220 # the passed dtype, we ensure from_dtype() will not generate subnormals221 # by default.222 if allow_subnormal is not None:...

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