How to use just_draw_columns method in hypothesis

Best Python code snippet using hypothesis

impl.py

Source:impl.py Github

copy

Full Screen

...407 )408 rewritten_columns.append(c)409 if rows is None:410 @st.composite411 def just_draw_columns(draw):412 index = draw(index_strategy)413 local_index_strategy = st.just(index)414 data = OrderedDict((c.name, None) for c in rewritten_columns)415 # Depending on how the columns are going to be generated we group416 # them differently to get better shrinking. For columns with fill417 # enabled, the elements can be shrunk independently of the size,418 # so we can just shrink by shrinking the index then shrinking the419 # length and are generally much more free to move data around.420 # For columns with no filling the problem is harder, and drawing421 # them like that would result in rows being very far apart from422 # each other in the underlying data stream, which gets in the way423 # of shrinking. So what we do is reorder and draw those columns424 # row wise, so that the values of each row are next to each other.425 # This makes life easier for the shrinker when deleting blocks of426 # data.427 columns_without_fill = [428 c for c in rewritten_columns if c.fill.is_empty]429 if columns_without_fill:430 for c in columns_without_fill:431 data[c.name] = pandas.Series(432 np.zeros(shape=len(index), dtype=c.dtype),433 index=index,434 )435 seen = {436 c.name: set() for c in columns_without_fill if c.unique}437 for i in hrange(len(index)):438 for c in columns_without_fill:439 if c.unique:440 for _ in range(5):441 value = draw(c.elements)442 if value not in seen[c.name]:443 seen[c.name].add(value)444 break445 else:446 reject()447 else:448 value = draw(c.elements)449 data[c.name][i] = value450 for c in rewritten_columns:451 if not c.fill.is_empty:452 data[c.name] = draw(series(453 index=local_index_strategy, dtype=c.dtype,454 elements=c.elements, fill=c.fill, unique=c.unique))455 return pandas.DataFrame(data, index=index)456 return just_draw_columns()457 else:458 @st.composite459 def assign_rows(draw):460 index = draw(index_strategy)461 result = pandas.DataFrame(OrderedDict(462 (c.name, pandas.Series(463 np.zeros(dtype=c.dtype, shape=len(index)), dtype=c.dtype))464 for c in rewritten_columns465 ), index=index)466 fills = {}467 any_unique = any(c.unique for c in rewritten_columns)468 if any_unique:469 all_seen = [470 set() if c.unique else None for c in rewritten_columns]...

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