fix: allow generator inputsets again

This commit is contained in:
Umut
2022-07-04 12:02:48 +02:00
parent 0a85731a3a
commit 5a065769bb
2 changed files with 8 additions and 4 deletions

View File

@@ -172,11 +172,16 @@ class Compiler:
"""
if inputset is not None:
previous_inputset_length = len(self.inputset)
for index, sample in enumerate(iter(inputset)):
self.inputset.append(sample)
if not isinstance(sample, tuple):
sample = (sample,)
if len(sample) != len(self.parameter_encryption_statuses):
self.inputset = self.inputset[:previous_inputset_length]
expected = (
"a single value"
if len(self.parameter_encryption_statuses) == 1
@@ -191,9 +196,6 @@ class Compiler:
f"(expected {expected} got {actual})"
)
for input_ in inputset:
self.inputset.append(input_)
if self.graph is None:
try:
first_sample = next(iter(self.inputset))

View File

@@ -236,6 +236,8 @@ def test_compiler_virtual_compile(helpers):
return x + 400
compiler = Compiler(f, {"x": "encrypted"})
circuit = compiler.compile(inputset=range(400), configuration=configuration, virtual=True)
inputset = (i for i in range(400))
circuit = compiler.compile(inputset, configuration=configuration, virtual=True)
assert circuit.encrypt_run_decrypt(200) == 600