Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFE: should there be a more obvious error message when the value at t=0 is not provided? #169

Open
ANogin opened this issue Dec 22, 2023 · 0 comments

Comments

@ANogin
Copy link

ANogin commented Dec 22, 2023

import rtamt

spec = rtamt.StlDenseTimeSpecification()
spec.name = "Bug?"
spec.declare_var("y", "int")
spec.declare_var("x", "int")
spec.set_var_io_type("y", "input")
spec.set_var_io_type("x", "output")
spec.spec = "((historically[0,5] x==1) and y) implies (eventually[0, 0.02] x==0)"

spec.parse()
spec.pastify()
rob = spec.update(["x", [(0.0, 1)]])

results in

    rob = spec.update(["x", [(0.0, 1)]])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aleksey/python-venv/3.12/lib/python3.12/site-packages/rtamt/spec/abstract_specification.py", line 288, in update
    return self.online_interpreter.update(dataset)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aleksey/python-venv/3.12/lib/python3.12/site-packages/rtamt/semantics/abstract_dense_time_online_interpreter.py", line 35, in update
    rob = self.updateVisitor.visitAst(self.ast, self.online_operator_dict, self.ast.var_object_dict)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aleksey/python-venv/3.12/lib/python3.12/site-packages/rtamt/syntax/ast/visitor/abstract_ast_visitor.py", line 33, in visitAst
    out.append(self.visit(spec, *args, **kwargs))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aleksey/python-venv/3.12/lib/python3.12/site-packages/rtamt/syntax/ast/visitor/abstract_ast_visitor.py", line 21, in visit
    result = self.visitBinary(node, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aleksey/python-venv/3.12/lib/python3.12/site-packages/rtamt/semantics/abstract_online_interpreter.py", line 69, in visitBinary
    sample_left  = self.visit(node.children[0], online_operator_dict, var_object_dict)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aleksey/python-venv/3.12/lib/python3.12/site-packages/rtamt/syntax/ast/visitor/abstract_ast_visitor.py", line 21, in visit
    result = self.visitBinary(node, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aleksey/python-venv/3.12/lib/python3.12/site-packages/rtamt/semantics/abstract_online_interpreter.py", line 70, in visitBinary
    sample_right = self.visit(node.children[1], online_operator_dict, var_object_dict)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aleksey/python-venv/3.12/lib/python3.12/site-packages/rtamt/syntax/ast/visitor/abstract_ast_visitor.py", line 23, in visit
    result = self.visitUnary(node, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aleksey/python-venv/3.12/lib/python3.12/site-packages/rtamt/semantics/abstract_online_interpreter.py", line 78, in visitUnary
    sample_return = op.update(sample)
                    ^^^^^^^^^^^^^^^^^
  File "/Users/aleksey/python-venv/3.12/lib/python3.12/site-packages/rtamt/semantics/stl/dense_time/online/once_timed_operation.py", line 36, in update
    while len(sample) >= i:
          ^^^^^^^^^^^
TypeError: object of type 'int' has no len()

If I add print(node.name, sample) just before line 78 in abstract_online_interpreter.py, it prints

once[1/50,1/50](x) [(0.0, 1)]
historically[0,5]((once[1/50,1/50](x))==(1.0)) []
once[1/50,1/50](y) 0

before it dies. I am guessing the issue is that I did not provide the value of y at time 0? If so, it would be good to catch it and provide an explicit error message about that.

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

No branches or pull requests

1 participant