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

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