mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
A couple capi.plot module fixes and an added test.
This commit is contained in:
parent
2d144e21ac
commit
44654e7759
2 changed files with 24 additions and 2 deletions
|
|
@ -1,7 +1,6 @@
|
|||
from ctypes import c_int, c_int32, c_double, Structure, POINTER
|
||||
|
||||
from . import _dll
|
||||
from .core import _DLLGlobal
|
||||
from .error import _error_handler
|
||||
|
||||
import numpy as np
|
||||
|
|
@ -31,7 +30,7 @@ class _Position(Structure):
|
|||
elif idx == 2:
|
||||
return self.z
|
||||
else:
|
||||
raise IndexError("{} index is invalid for _Position".format(key))
|
||||
raise IndexError("{} index is invalid for _Position".format(idx))
|
||||
|
||||
def __setitem__(self, idx, val):
|
||||
if idx == 0:
|
||||
|
|
|
|||
|
|
@ -438,3 +438,26 @@ def test_property_map(capi_init):
|
|||
|
||||
properties = openmc.capi.plot.property_map(s)
|
||||
assert np.allclose(expected_properties, properties, atol=1e-04)
|
||||
|
||||
|
||||
def test_position(capi_init):
|
||||
|
||||
pos = openmc.capi.plot._Position(1.0, 1.0, 1.0)
|
||||
|
||||
assert pos[0] == 1.0
|
||||
assert pos[1] == 1.0
|
||||
assert pos[2] == 1.0
|
||||
|
||||
pos[0] = 1.3
|
||||
pos[1] = 1.3
|
||||
pos[2] = 1.3
|
||||
|
||||
assert pos[0] == 1.3
|
||||
assert pos[1] == 1.3
|
||||
assert pos[2] == 1.3
|
||||
|
||||
with pytest.raises(IndexError) as e:
|
||||
pos[3] = 1.3
|
||||
|
||||
with pytest.raises(IndexError) as e:
|
||||
pos[-1] = 1.3
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue