atmtools / typhon

Tools for atmospheric research
http://www.radiativetransfer.org/
MIT License
58 stars 33 forks source link

BUG: API doesn't catch access to uninitialized user variable #358

Closed olemke closed 4 years ago

olemke commented 4 years ago

Bug report

Bug summary

Access to an uninitialized user created variable is not caught by the API.

Code for reproduction

from typhon.arts.workspace import Workspace
# from arts.workspace import Workspace

ws = Workspace()
ws.IndexCreate("myindex")

print("1st try:")
print(ws.myindex.value)
ws.Print(ws.myindex, 0)

print("2nd try:")
ws = Workspace()
print(ws.myindex.value)
ws.Print(ws.myindex, 0)

Actual outcome

1st try:
8070450532247928832
- Print
8070450532247928832
2nd try:
Traceback (most recent call last):
  File "./uninitialized-user-var.py", line 16, in <module>
    print(ws.myindex.value)
  File "/Users/u237002/Hacking/git/typhon/typhon/arts/workspace/variables.py", line 281, in value
    raise Exception("WorkspaceVariable " + self.name + " is uninitialized.")
Exception: WorkspaceVariable myindex is uninitialized.

Expected outcome

Already on the 1st try, the Exception should be thrown.

Version information

simonpf commented 4 years ago

ARTS interface has been migrated to ARTS.