bigphoton/arch

TypeError: unsupported operand type(s) for |=: 'dict' and 'dict'

Opened this issue · 3 comments

arch/arch/models/model.py

Lines 241 to 242 in e2c76ef

state |= {op:oe.subs(state) for op,oe in mod.out_exprs.items()}
state |= {pi:state[po] for po,pi in connectivity if po in state}

Ran into this when running py3 new_arch.py, trying to solve it

daquintero@Darios-MacBook-Pro-2 ~/Documents/arch/examples
± % py3 new_arch.py                                                                                                                               !3104
Unable to import `thewalrus`. How about a backup permanent function?
Unable to import `thewalrus`. How about a backup permanent function?
Welcome to the new arch
Traceback (most recent call last):
  File "new_arch.py", line 97, in <module>
    cm = laser.model.compound("compound name", [laser.model, mz0.model, ps0.model, ps1.model, bs.model, mz1.model], connections)
  File "/Users/daquintero/Documents/arch/arch/models/model.py", line 241, in compound
    state |= {op : oe.subs(state) for op,oe in mod.out_exprs.items()}
TypeError: unsupported operand type(s) for |=: 'dict' and 'dict'
(venv) 

Solved, will include in control_solver branch pending a pull request

  for model in ready_models:
      for output_key, output_expression in model.out_exprs.items():
          state.update({
              output_key: output_expression.subs(state)
          })
      for output_port, input_port in connectivity:
          if output_port in state:
              state.update({
                  input_port: state[output_port]
              })
  model_set -= ready_models

Now got:

Traceback (most recent call last):
  File "examples/new_arch.py", line 137, in <module>
    state = cm.out_func(state)
  File "/Users/daquintero/Documents/arch/arch/models/model.py", line 205, in out_func
    subs = self.default_input_state | in_state
TypeError: unsupported operand type(s) for |: 'dict' and 'dict'
(venv)