Skip to content

Commit

Permalink
Chnaged libmanager to look in all potential code for a library.
Browse files Browse the repository at this point in the history
  • Loading branch information
JezSw committed Feb 16, 2024
1 parent 60bd89d commit e0ea739
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Untitled.ipynb
.coverage
Configuration/
Experimental_Results/
venv/*

# These are generated folders for cache
.ipynb_checkpoints/
Expand All @@ -16,4 +17,4 @@ docs/source/_static/
docs/source/_templates/
JADE.egg-info/
jade.egg-info/
build/
build/
31 changes: 18 additions & 13 deletions jade/libmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,18 +471,20 @@ def select_lib(self, code: str = "mcnp") -> str:
"""
Prompt an library input selection with Xsdir availabilty check
Returns
Parameters
-------
lib : str
Library to assess.
code: str, optional
code for which the library is selected. default is MCNP
Returns
-------
lib : str
Library to assess.
"""
error = (
CRED
+ """
Error: {}
Error: Library {} with code {}
The selected library is not available.
"""
+ CEND
Expand All @@ -492,28 +494,31 @@ def select_lib(self, code: str = "mcnp") -> str:
while True:
i += 1
lib = input(" Select library (e.g. 31c or 99c-31c): ")
if lib in self.libraries[code]:
break
for library in self.libraries.values():
if lib in library:
return lib

elif lib[0] == "{":
if len(lib)>0 and lib[0] == "{":
libs = json.loads(lib)
# all libraries should be available
tocheck = list(libs.values())
tocheck.extend(list(libs.keys()))
flag = True
flag = False
for val in tocheck:
if val not in self.libraries[code]:
print(error.format(val))
flag = False
for library in self.libraries.values():
if val in library:
flag = True
if flag:
break
else:
print(error.format(val, code))

elif "-" in lib:
libs = lib.split("-")
flag = True
for val in libs:
if val not in self.libraries[code]:
print(error.format(val))
print(error.format(val, code))
flag = False
if flag:
break
Expand All @@ -525,7 +530,7 @@ def select_lib(self, code: str = "mcnp") -> str:
break

else:
print(error.format(lib))
print(error.format(val, code))

if i > 10:
raise ValueError("Too many wrong inputs")
Expand Down

0 comments on commit e0ea739

Please sign in to comment.