Best Python code snippet using hypothesis
numpy.py
Source: numpy.py
...65 # Subarray datatypes, eg '(2, 3)i4'66 if dtype.subdtype is not None:67 subtype, shape = dtype.subdtype68 return arrays(subtype, shape, elements=kwargs)69 def compat_kw(*args, **kw):70 """Update default args to the strategy with user-supplied keyword args."""71 assert {"min_value", "max_value", "max_size"}.issuperset(kw)72 for key in set(kwargs).intersection(kw):73 msg = f"dtype {dtype!r} requires {key}={kwargs[key]!r} to be %s {kw[key]!r}"74 if kw[key] is not None:75 if key.startswith("min_") and kw[key] > kwargs[key]:76 raise InvalidArgument(msg % ("at least",))77 elif key.startswith("max_") and kw[key] < kwargs[key]:78 raise InvalidArgument(msg % ("at most",))79 kw.update({k: v for k, v in kwargs.items() if k in args or k in kw})80 return kw81 # Scalar datatypes82 if dtype.kind == "b":83 result = st.booleans() # type: SearchStrategy[Any]84 elif dtype.kind == "f":85 result = st.floats(86 width=8 * dtype.itemsize,87 **compat_kw(88 "min_value",89 "max_value",90 "allow_nan",91 "allow_infinity",92 "exclude_min",93 "exclude_max",94 ),95 )96 elif dtype.kind == "c":97 # If anyone wants to add a `width` argument to `complex_numbers()`, we would98 # accept a pull request and add passthrough support for magnitude bounds,99 # but it's a low priority otherwise.100 if dtype.itemsize == 8:101 float32 = st.floats(width=32, **compat_kw("allow_nan", "allow_infinity"))102 result = st.builds(complex, float32, float32)103 else:104 result = st.complex_numbers(**compat_kw("allow_nan", "allow_infinity"))105 elif dtype.kind in ("S", "a"):106 # Numpy strings are null-terminated; only allow round-trippable values.107 # `itemsize == 0` means 'fixed length determined at array creation'108 max_size = dtype.itemsize or None109 result = st.binary(**compat_kw("min_size", max_size=max_size)).filter(110 lambda b: b[-1:] != b"\0"111 )112 elif dtype.kind == "u":113 kw = compat_kw(min_value=0, max_value=2 ** (8 * dtype.itemsize) - 1)114 result = st.integers(**kw)115 elif dtype.kind == "i":116 overflow = 2 ** (8 * dtype.itemsize - 1)117 result = st.integers(**compat_kw(min_value=-overflow, max_value=overflow - 1))118 elif dtype.kind == "U":119 # Encoded in UTF-32 (four bytes/codepoint) and null-terminated120 max_size = (dtype.itemsize or 0) // 4 or None121 result = st.text(**compat_kw("alphabet", "min_size", max_size=max_size)).filter(122 lambda b: b[-1:] != "\0"123 )124 elif dtype.kind in ("m", "M"):125 if "[" in dtype.str:126 res = st.just(dtype.str.split("[")[-1][:-1])127 else:128 # Note that this case isn't valid to pass to arrays(), but we support129 # it here because we'd have to guard against equivalents in arrays()130 # regardless and drawing scalars is a valid use-case.131 res = st.sampled_from(TIME_RESOLUTIONS)132 result = st.builds(dtype.type, st.integers(-(2 ** 63), 2 ** 63 - 1), res)133 else:134 raise InvalidArgument(f"No strategy inference for {dtype}")135 return result.map(dtype.type)...
Check out the latest blogs from LambdaTest on this topic:
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.
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.
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.
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.
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.
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!!