Skip to content

fix: TypeError: reduce() of empty iterable with no initial value#2

Open
AstroGD wants to merge 1 commit intocassiersg:mainfrom
AstroGD:patch-1
Open

fix: TypeError: reduce() of empty iterable with no initial value#2
AstroGD wants to merge 1 commit intocassiersg:mainfrom
AstroGD:patch-1

Conversation

@AstroGD
Copy link

@AstroGD AstroGD commented Dec 30, 2025

Hey there,
I am unsure if this is only an issue on my end but I am encountering the following error:

Traceback (most recent call last):
  File ".../compress/scripts/yosys2compress.py", line 356, in <module>
    add_ports_definition(circuit_compress_lines, dic_ports)
  File ".../compress/scripts/yosys2compress.py", line 319, in add_ports_definition
    controls_str_port_sigs = ft.reduce(lambda a, b: a+' '+b, ports_cfg["controls"].keys())
TypeError: reduce() of empty iterable with no initial value

The line in question is

controls_str_port_sigs = ft.reduce(lambda a, b: a+' '+b, ports_cfg["controls"].keys())

When processing the canright_aes_sbox_opt make script from the artifact of your paper, it seems like this dictionary stays empty for me (I dont know if this is supposed to happen?)

Therefore I am proposing this change to fix the error and handle possibly empty dictionaries.
Have a nice day ^^

This fixes an error when ports_cfg[*] is an empty dictionary, which is always the case for ports_cfg["controls"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant