nils-wisiol/pypuf

TypeError when evaluating LTFArray within unittest

Closed this issue · 9 comments

I am not entirely sure if this is a bug or just my personal misunderstanding...
The following code (branch cma_hansen, pypuf/test/test_reliability_based_cmaes.py) leads to an error when executed within unittest, while working fine in other cases:

[...]
n = 16
k = 2
mu_weight = 0
sigma_weight = 1
transform = LTFArray.transform_atf
combiner = LTFArray.combiner_xor
seed_instance = 1234
prng_i = np.random.RandomState(seed_instance)

weight_array = LTFArray.normal_weights(n, k, mu_weight, sigma_weight, prng_i)
sigma_noise = NoisyLTFArray.sigma_noise_from_random_weights(n, sigma_weight, noisiness=0.05)
instance = NoisyLTFArray(weight_array, transform, combiner, sigma_noise, prng_i)

def test_create_abortion_function(self):
    is_same_solution = Learner.create_abortion_function(
        chains_learned=self.instance.weight_array,
        num_learned=1,
        transform=self.transform,
        combiner=self.combiner,
        threshold=0.25,
    )
    assert is_same_solution(self.instance.weight_array[0, :])

The corresponding error description is the following:
Error
Traceback (most recent call last):
File "/usr/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
yield
File "/usr/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/home/dude/workspace/pypuf/test/test_reliability_based_cmaes.py", line 54, in test_create_abortion_function
assert is_same_solution(self.instance.weight_array[0, :])
File "/home/dude/workspace/pypuf/pypuf/learner/evolution_strategies/reliability_based_cmaes.py", line 195, in is_same_solution
dist = tools.approx_dist(current_ltf_array, new_ltf_array, this.APPROX_CHALLENGE_NUM)
File "/home/dude/workspace/pypuf/pypuf/tools.py", line 125, in approx_dist
return (num - count_nonzero(instance1.eval(inputs) == instance2.eval(inputs))) / num
File "/home/dude/workspace/pypuf/pypuf/simulation/arbiter_based/ltfarray.py", line 657, in eval
return sign(self.val(inputs))
File "/home/dude/workspace/pypuf/pypuf/simulation/arbiter_based/ltfarray.py", line 669, in val
return self.combiner(self.ltf_eval(self.transform(inputs, self.k)))

TypeError: combiner_xor() takes 1 positional argument but 2 were given

Make sure you're using the correct version of pypuf_helper. For your branch, it should be 0.1.4. Which version are you using? Maybe it's most effective to try different versions to see if that's causing the error.

Install different versions of pypuf_helper with pip install pypuf-helper==0.1.4

I tried the versions 0.1.x, where x=1,2,3,4.
The error occurred at each of them.

pypuf_helper version 0.1.4 is the last without int8 and should work.
Also, I can't reproduce the error, all the tests from pypuf/test/test_reliability_based_cmaes.py run fine on my machine.

I am currently using following versions of libraries from pip:

alabaster (0.7.10)
appdirs (1.4.3)
asn1crypto (0.23.0)
astroid (1.5.3)
attrs (17.3.0)
Automat (0.6.0)
Babel (2.5.1)
Beaker (1.8.1)
Brlapi (0.6.6)
cffi (1.11.2)
chardet (3.0.4)
click (6.7)
cma (2.3.1)
constantly (15.1.0)
cryptography (2.1.3)
cssselect (1.0.1)
cupshelpers (1.0)
cycler (0.10.0)
docutils (0.14)
gitdb2 (2.0.3)
GitPython (2.1.7)
gufw (17.10.0)
hyperlink (17.3.1)
idna (2.6)
imagesize (0.7.1)
incremental (17.5.0)
invoke (0.21.0)
isc (2.0)
isort (4.2.15)
Jinja2 (2.9.6)
lazy-object-proxy (1.3.1)
louis (3.4.0)
lxml (4.1.1)
Mako (1.0.7)
MarkupSafe (1.0)
matplotlib (2.1.1)
mccabe (0.6.1)
mock (2.0.0)
numpy (1.13.3)
packaging (16.8)
pandas (0.21.0)
parsel (1.2.0)
pbr (3.1.1)
pep8 (1.7.1)
pip (9.0.1)
pluggy (0.5.2)
polymath (0.1.17)
pprintpp (0.3.0)
psutil (5.4.1)
py (1.4.34)
pyasn1 (0.3.7)
pyasn1-modules (0.1.5)
pycairo (1.15.4)
pycparser (2.18)
pycups (1.9.73)
pycurl (7.43.0.1)
pydbus (0.6.0)
PyDispatcher (2.0.5)
Pygments (2.2.0)
pygobject (3.26.1)
pylint (1.7.4)
pyOpenSSL (17.3.0)
pyparsing (2.2.0)
pypuf-helper (0.1.5)
pysmbc (1.0.15.8)
pytest (3.2.4.dev58+g2e2f7215)
python-dateutil (2.6.1)
pytz (2017.3)
pyxdg (0.25)
queuelib (1.4.2)
requests (2.18.4)
scipy (1.0.0)
Scrapy (1.4.0)
service-identity (17.0.0)
setuptools (38.2.5)
simplejson (3.13.2)
six (1.11.0)
smmap2 (2.0.3)
snowballstemmer (1.2.1)
Sphinx (1.4.9)
sphinx-rtd-theme (0.2.4)
team (1.0)
termcolor (1.1.0)
toml (0.9.3)
towncrier (17.8.0)
tox (2.9.1)
Twisted (17.9.0)
urllib3 (1.22)
virtualenv (15.1.0)
w3lib (1.18.0)
wheel (0.30.0)
wrapt (1.10.11)
zope.interface (4.4.3)

@taudor, could you provide your pip list?

Sorry for the delay. Here's my pip list

astroid (1.5.3)
cma (2.3.1)
cycler (0.10.0)
isort (4.2.15)
lazy-object-proxy (1.3.1)
matplotlib (2.1.0)
mccabe (0.6.1)
mock (2.0.0)
nose (1.3.7)
numpy (1.13.1)
pbr (3.1.1)
pep8 (1.7.0)
pip (9.0.1)
polymath (0.1.17)
pylint (1.7.2)
pyparsing (2.2.0)
pypuf-helper (0.1.4)
python-dateutil (2.6.1)
pytz (2017.2)
scipy (0.19.1)
setuptools (32.2.0)
six (1.11.0)
virtualenv (15.1.0)
wheel (0.29.0)
wrapt (1.10.11)

after resetting my relevant libraries according to the current requirements.txt file:

astroid (1.5.3)
cma (2.3.1)
cycler (0.10.0)
isort (4.2.15)
lazy-object-proxy (1.3.1)
matplotlib (2.1.1)
mccabe (0.6.1)
mock (2.0.0)
numpy (1.13.3) ###
pbr (3.1.1)
pep8 (1.7.1) ###
pip (9.0.1)
polymath (0.1.17)
pylint (1.7.5) ###
pyparsing (2.2.0)
pypuf-helper (0.1.4)
python-dateutil (2.6.1)
pytz (2017.3)
scipy (0.19.1)
setuptools (38.4.0)
six (1.11.0)
virtualenv (15.1.0)
wheel (0.30.0)
wrapt (1.10.11)

@Chrism7, is this still an issue? Then please feel free to reopen.