import skrf as rf
from hypothesis import given, strategies as st
from hypothesis.extra import numpy as stnp
datatypes = st.one_of(st.integers,st.floats,st.complex_numbers)
# TODO: fix arguements for st.builds so that it generates correctly
def build_hypothesis_test_network(nports, npoints):
return st.builds(
rf.Network,
name=st.characters,
f=stnp.arrays(datatypes, [npoints]),
z0=stnp.arrays(datatypes, [st.sampled_from([nports, npoints])]),
s=stnp.arrays(datatypes, [npoints, nports, nports]),
comments=st.characters,
f_unit=st.sampled_from((None, 'hz', 'khz', 'mhz', 'ghz'))
)
test_ntwk = build_hypothesis_test_network(st.integers(min_value=1, max_value=20),
st.integers(min_value=0, max_value=100000))
Traceback (most recent call last):
test_viewer.py", line 34, in <module>
st.integers(min_value=0, max_value=100000))
test_viewer.py", line 30, in build_hypothesis_test_network
f_unit=st.sampled_from((None, 'hz', 'khz', 'mhz', 'ghz'))
site-packages\hypothesis\_strategies.py", line 1208, in builds
@defines_strategy
site-packages\hypothesis\_strategies.py", line 197, in cached_strategy
if not isinstance(result, SearchStrategy) or result.is_cacheable:
site-packages\hypothesis\searchstrategy\strategies.py", line 154, in accept
recur(self)
site-packages\hypothesis\searchstrategy\strategies.py", line 150, in recur
mapping[strat] = getattr(strat, calculation)(recur)
site-packages\hypothesis\searchstrategy\lazy.py", line 100, in calc_is_cacheable
if isinstance(v, SearchStrategy) and not v.is_cacheable:
site-packages\hypothesis\searchstrategy\strategies.py", line 154, in accept
recur(self)
site-packages\hypothesis\searchstrategy\strategies.py", line 150, in recur
mapping[strat] = getattr(strat, calculation)(recur)
site-packages\hypothesis\searchstrategy\lazy.py", line 100, in calc_is_cacheable
if isinstance(v, SearchStrategy) and not v.is_cacheable:
site-packages\hypothesis\searchstrategy\strategies.py", line 154, in accept
recur(self)
site-packages\hypothesis\searchstrategy\strategies.py", line 150, in recur
mapping[strat] = getattr(strat, calculation)(recur)
site-packages\hypothesis\searchstrategy\strategies.py", line 441, in calc_is_cacheable
return all(recur(e) for e in self.original_strategies)
site-packages\hypothesis\searchstrategy\strategies.py", line 441, in <genexpr>
return all(recur(e) for e in self.original_strategies)
site-packages\hypothesis\searchstrategy\strategies.py", line 150, in recur
mapping[strat] = getattr(strat, calculation)(recur)
AttributeError: 'function' object has no attribute 'calc_is_cacheable'
datatypes = st.one_of(st.integers(), st.floats(), st.complex_numbers())
@st.composite
def build_hypothesis_test_network(draw):
nports = draw(st.integers(min_value=1, max_value=20))
npoints = draw(st.integers(min_value=0, max_value=100000))
return draw(st.builds(
rf.Network,
name=st.characters(),
f=stnp.arrays(datatypes, [npoints]),
z0=stnp.arrays(datatypes, [draw(st.sampled_from([nports, npoints]))]),
s=stnp.arrays(datatypes, [npoints, nports, nports]),
comments=st.characters(),
f_unit=st.sampled_from((None, 'hz', 'khz', 'mhz', 'ghz'))
))
--
You received this message because you are subscribed to the Google Groups "Hypothesis users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hypothesis-use...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/hypothesis-users/2dc61a8a-82d7-48ac-8638-d8d9a79384ec%40googlegroups.com.