petercorke / petercorke/bdsim

[bdsim BUG] When block is completely discrete, no integrator reference should be used

Open
#32 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
267
Forks
39
Avg merge
11d 18h
Merged PRs (30d)
6

Description

bdsim version 1.1.2
Describe the bug
Error:

File ".../lib/python3.10/site-packages/bdsim/run_sim.py", line 918, in run_interval
out = b.output(integrator.t, b.inputs, b._x)[p.port]
UnboundLocalError: local variable 'integrator' referenced before assignment

To Reproduce
Any block diagram with only discrete blocks

Expected behavior
Simulation runs smoothly

Operating environment (please complete the following information):

  • OS: Ubuntu 22.04

Suggestion:

instead

out = b.output(integrator.t, b.inputs, b._x)[p.port]

use

out = b.output(t, b.inputs, b._x)[p.port]

as integrator is not defined here

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at lib/python3.10/site-packages/bdsim/run_sim.py around line 918 and inspect how run_interval handles diagrams containing only discrete blocks. Reproduce the issue with an all-discrete block diagram, then verify the output call uses the available simulation time and that the simulation completes without the UnboundLocalError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.