How to use integer_range method in hypothesis

Best Python code snippet using hypothesis

exponentials.py

Source:exponentials.py Github

copy

Full Screen

1""" TO DO:2make difficulty more interesting3add parameter for num terms to produce and let difficulty effect the actual integral (coefficients ext)45find a way to print bases nicely6find an even prettier print7"""89from sympy import *10import numpy as np11from fractions import Fraction as frac12from sympy.integrals.manualintegrate import integral_steps1314x = symbols('x')15integer_choice = range(-10, 10)161718def get_fractional_coeff(int_range):19 coefficient_denominator = np.random.choice(int_range)20 coefficient_numerator = np.random.choice(int_range)21 coefficient = frac(coefficient_numerator, coefficient_denominator)22 return coefficient232425def generate_polynomial(order, integer_range, architecture=None):26 terms = order + 127 integral = 028 if architecture == None:29 architecture = tuple(1 for _ in range(terms))3031 for power, terms in enumerate(architecture):32 for j in range(terms):33 coefficient = get_fractional_coeff(integer_range)34 integral += coefficient * x**power35 return integral363738def generate_exponential(difficulty, integer_range):39 integral = 04041 match difficulty:42 case 'Easy': # simple exponential43 coefficient = get_fractional_coeff(integer_range)44 integral += coefficient * exp(x)45 case 'Medium':46 coefficient = get_fractional_coeff(integer_range)47 polynomial_ord1 = generate_polynomial(1, integer_range)48 integral += coefficient * exp(polynomial_ord1)49 case 'Hard':50 chance = 'heads' if np.random.random() >= 0.5 else 'tails'51 coefficient = get_fractional_coeff(integer_range)52 if chance == 'heads':53 polynomial_power = generate_polynomial(2, integer_range)54 polynomial_coefficient = generate_polynomial(1, integer_range)55 else:56 polynomial_power = generate_polynomial(3, integer_range)57 polynomial_coefficient = generate_polynomial(2, integer_range)58 integral += coefficient * polynomial_coefficient * exp(polynomial_power)5960 return integral616263def generate_ln(difficulty, integer_range):64 terms = No_of_terms[difficulty]65 integral = 06667 for i in range(terms):68 power = get_fractional_coeff(integer_range)69 coefficient = get_fractional_coeff(integer_range)70 ln_coefficient = get_fractional_coeff(integer_range)7172 integral += coefficient * log(ln_coefficient * x**power)73 return integral747576def generate_log(difficulty, integer_range, base):77 terms = No_of_terms[difficulty]78 integral = 07980 for i in range(terms):81 power = get_fractional_coeff(integer_range)82 coefficient = get_fractional_coeff(integer_range)83 ln_coefficient = get_fractional_coeff(integer_range)8485 integral += coefficient * log(ln_coefficient * x**power, base)86 return integral878889test = generate_polynomial(2, integer_choice)9091solution = generate_exponential('easy', integer_range=integer_choice)92# FOR PERTY PRINTING93init_printing() ...

Full Screen

Full Screen

domain.py

Source:domain.py Github

copy

Full Screen

1from typing import Tuple2import DZ1.defaults3class Domain:4 def __init__(self, integer_range: Tuple[int, int] = DZ1.defaults.DEFAULT_DOMAIN_RANGE):5 if integer_range is None or not isinstance(integer_range, tuple) or not len(integer_range) == 2\6 or not (isinstance(integer_range[0], int) and isinstance(integer_range[1], int))\7 or not (integer_range[0] - integer_range[1] < 0):8 integer_range = DZ1.defaults.DEFAULT_DOMAIN_RANGE9 self.__members = tuple(range(*integer_range))10 @staticmethod11 def from_domains(domains: Tuple["Domain", "Domain"]) -> "Domain":12 if domains is None or not isinstance(domains, tuple) or not len(domains) == 2\13 or not (isinstance(domains[0], Domain) and isinstance(domains[1], Domain)):14 raise ValueError(DZ1.defaults.DOMAIN_INPUT_IS_POOPOO)15 members = list()16 for domain_predecessor in domains[0]:17 if isinstance(domain_predecessor, int):18 domain_predecessor = (domain_predecessor, )19 for domain_successor in domains[1]:20 if isinstance(domain_successor, int):21 domain_successor = (domain_successor, )22 members.append(domain_predecessor + domain_successor)23 to_return = Domain((0, 1))24 to_return.__members = tuple(members)25 return to_return26 @staticmethod27 def from_domains_merge(domains: Tuple["Domain", "Domain"]) -> "Domain":28 if domains is None or not isinstance(domains, tuple) or not len(domains) == 2 \29 or not (isinstance(domains[0], Domain) and isinstance(domains[1], Domain)):30 raise ValueError(DZ1.defaults.DOMAIN_INPUT_IS_POOPOO)31 to_return = Domain((0, 1))32 to_return.__members = tuple(sorted(set(domains[0].__members + domains[1].__members)))33 return to_return34 def cardinality(self) -> int:35 return len(self)36 def index(self, element, start=None, end=None) -> int:37 if start is None or not isinstance(start, int):38 start = 039 if end is None or not isinstance(end, int):40 end = len(self.__members)41 return self.__members.index(element, start, end)42 def __getitem__(self, key) -> Tuple or int:43 return self.__members[key]44 def __len__(self) -> int:45 return len(self.__members)46 def __str__(self) -> str:...

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