mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Added the import to openmc.lib to model.py while leaving it optiona
l
This commit is contained in:
parent
f0c1ce8bb1
commit
123fefe08d
1 changed files with 14 additions and 2 deletions
|
|
@ -14,8 +14,17 @@ import openmc
|
|||
from openmc.dummy_comm import DummyCommunicator
|
||||
from openmc.executor import _process_CLI_arguments
|
||||
from openmc.checkvalue import check_type, check_value
|
||||
|
||||
from openmc.exceptions import InvalidIDError
|
||||
|
||||
# Establish whether openmc.lib is available for downstream uses;
|
||||
# this avoids the need for extraneous try/import/except statements
|
||||
try:
|
||||
import openmc.lib
|
||||
_openmc_lib_present = True
|
||||
except ImportError:
|
||||
_openmc_lib_present = False
|
||||
|
||||
|
||||
@contextmanager
|
||||
def _change_directory(working_dir):
|
||||
|
|
@ -137,7 +146,10 @@ class Model:
|
|||
|
||||
@property
|
||||
def is_initialized(self):
|
||||
return openmc.lib.is_initialized
|
||||
if _openmc_lib_present:
|
||||
return openmc.lib.is_initialized
|
||||
else:
|
||||
return False
|
||||
|
||||
@geometry.setter
|
||||
def geometry(self, geometry):
|
||||
|
|
@ -512,7 +524,7 @@ class Model:
|
|||
for arg_name, arg, default in zip(
|
||||
['threads', 'geometry_debug', 'restart_file', 'tracks'],
|
||||
[threads, geometry_debug, restart_file, tracks],
|
||||
[None, False, None, False]):
|
||||
[None, False, None, False]):
|
||||
if arg != default:
|
||||
msg = f"{arg_name} must be set via Model.is_initialized(...)"
|
||||
raise ValueError(msg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue