We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KeyError
draw_capped_multipart
Hi,
A KeyError is raised in draw_capped_multipart in version 5.8.1 and 5.10.1 that is not raised in 5.8.0.
A reproducible example and full stacktrace are given below.
Error:
data = ConjectureData(VALID, 1 bytes, frozen), min_value = Timestamp('2017-01-01 00:00:00'), max_value = Timestamp('2019-01-01 00:00:00') def draw_capped_multipart(data, min_value, max_value): assert isinstance(min_value, (dt.date, dt.time, dt.datetime)) assert type(min_value) == type(max_value) assert min_value <= max_value result = {} cap_low, cap_high = True, True duration_names_by_type = { dt.date: DATENAMES, dt.time: TIMENAMES, dt.datetime: DATENAMES + TIMENAMES, } > for name in duration_names_by_type[type(min_value)]: E KeyError: <class 'pandas._libs.tslibs.timestamps.Timestamp'>
import numpy as np import pandas as pd from hypothesis import given, settings import hypothesis.strategies as hst from hypothesis.extra import pandas as hpd @given( hpd.data_frames(columns=[ hpd.column(name='prog_start', elements=hst.datetimes( min_value=pd.Timestamp(2017, 1, 1), max_value=pd.Timestamp(2019, 1, 1) ), unique=True), hpd.column(name='mat_code', elements=hst.integers(min_value=100)), hpd.column(name='SOME***@#!@%*FLoat', elements=hst.floats(max_value=1000.0) ), hpd.column(name='useful_STR', elements=hst.text() ), ], index=hpd.range_indexes(min_size=3) ) ) @settings(deadline=None) def test_hypothesis_testing(df): pass
../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/core.py:678: in _execute_once_for_engine escalate_hypothesis_internal_error() ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/core.py:649: in _execute_once_for_engine result = self.execute_once(data) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/core.py:604: in execute_once result = self.test_runner(data, run) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/executors.py:52: in default_new_style_executor return function(data) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/core.py:545: in run args, kwargs = data.draw(self.search_strategy) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:893: in draw return strategy.do_draw(self) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/strategies/_internal/collections.py:57: in do_draw return tuple(data.draw(e) for e in self.element_strategies) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/strategies/_internal/collections.py:57: in <genexpr> return tuple(data.draw(e) for e in self.element_strategies) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:888: in draw return strategy.do_draw(self) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:658: in do_draw result = self.pack(data.draw(self.mapped_strategy)) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:888: in draw return strategy.do_draw(self) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/strategies/_internal/lazy.py:150: in do_draw return data.draw(self.wrapped_strategy) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:888: in draw return strategy.do_draw(self) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:658: in do_draw result = self.pack(data.draw(self.mapped_strategy)) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:888: in draw return strategy.do_draw(self) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/strategies/_internal/collections.py:57: in do_draw return tuple(data.draw(e) for e in self.element_strategies) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/strategies/_internal/collections.py:57: in <genexpr> return tuple(data.draw(e) for e in self.element_strategies) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:888: in draw return strategy.do_draw(self) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/strategies/_internal/lazy.py:150: in do_draw return data.draw(self.wrapped_strategy) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:888: in draw return strategy.do_draw(self) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/strategies/_internal/lazy.py:150: in do_draw return data.draw(self.wrapped_strategy) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:888: in draw return strategy.do_draw(self) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/strategies/_internal/core.py:1722: in do_draw return self.definition(data.draw, *self.args, **self.kwargs) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/extra/pandas/impl.py:584: in just_draw_columns value = draw(c.elements) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:888: in draw return strategy.do_draw(self) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/strategies/_internal/lazy.py:150: in do_draw return data.draw(self.wrapped_strategy) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:888: in draw return strategy.do_draw(self) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/strategies/_internal/datetime.py:131: in do_draw result = self.draw_naive_datetime_and_combine(data, tz) ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/strategies/_internal/datetime.py:145: in draw_naive_datetime_and_combine result = draw_capped_multipart(data, self.min_value, self.max_value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ data = ConjectureData(VALID, 1 bytes, frozen), min_value = Timestamp('2017-01-01 00:00:00'), max_value = Timestamp('2019-01-01 00:00:00') def draw_capped_multipart(data, min_value, max_value): assert isinstance(min_value, (dt.date, dt.time, dt.datetime)) assert type(min_value) == type(max_value) assert min_value <= max_value result = {} cap_low, cap_high = True, True duration_names_by_type = { dt.date: DATENAMES, dt.time: TIMENAMES, dt.datetime: DATENAMES + TIMENAMES, } > for name in duration_names_by_type[type(min_value)]: E KeyError: <class 'pandas._libs.tslibs.timestamps.Timestamp'> ../../../../.pyenv/versions/3.7.5/envs/TOOLS/lib/python3.7/site-packages/hypothesis/strategies/_internal/datetime.py:92: KeyError ========================================================================================================== short test summary info =========================================================================================================== FAILED hypothesis_bug.py::test_hypothesis_testing - KeyError: <class 'pandas._libs.tslibs.timestamps.Timestamp'>
The text was updated successfully, but these errors were encountered:
import pandas as pd from hypothesis import given, strategies as st @given(st.datetimes(min_value=pd.Timestamp(2017, 1, 1))) def test_hypothesis_testing(dt): pass
Looks like we didn't have any tests which use datetime subclasses for the bounds to datetimes(). At least it'll be easy to fix!
datetime
datetimes()
Sorry, something went wrong.
st.datetimes()
Cool, thanks for the quick fix!
Zac-HD
Successfully merging a pull request may close this issue.
Hi,
A
KeyErroris raised indraw_capped_multipartin version 5.8.1 and 5.10.1 that is not raised in 5.8.0.A reproducible example and full stacktrace are given below.
Error:
Reproducible code:
full stacktrace:
The text was updated successfully, but these errors were encountered: