Skip to content

Commit

Permalink
Fixed instance checker in voidMat (#264)
Browse files Browse the repository at this point in the history
* Fixed instance checker in voidMat

Fixed the void mat instance checker to  check for the first entry being an int, second entry being a float or int, and the third entry being a str.

* Update config_cadtocsg_non_defaults.json

Updated config_cadtocsg_non_defaults.json to test voidMat with a material defined

* Update tests/config_cadtocsg_non_defaults.json

* Update src/geouned/GEOUNED/utils/data_classes.py

black format

---------

Co-authored-by: Patrick Sauvan <psauvan@ind.uned.es>
  • Loading branch information
tcmcclan-ornl and psauvan authored Aug 6, 2024
1 parent 40abd59 commit 3992d3a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
15 changes: 11 additions & 4 deletions src/geouned/GEOUNED/utils/data_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,10 +769,17 @@ def voidMat(self):
def voidMat(self, voidMat: list):
if not isinstance(voidMat, list):
raise TypeError(f"geouned.Settings.voidMat should be a list, not a {type(voidMat)}")
for entry in voidMat:
if not isinstance(entry, int):
raise TypeError(f"geouned.Settings.voidMat should be a list of ints, not a {type(entry)}")
self._voidMat = voidMat
if len(voidMat) == 0:
self._voidMat = voidMat
else:
if not isinstance(voidMat[0], int):
raise TypeError(f"first entry of geouned.Settings.voidMat should be an int, not a {type(entry)}")
if not isinstance(voidMat[1], int):
if not isinstance(voidMat[1], float):
raise TypeError(f"second entry of geouned.Settings.voidMat should be an int or float, not a {type(entry)}")
if not isinstance(voidMat[2], str):
raise TypeError(f"third entry of geouned.Settings.voidMat should be a str, not a {type(entry)}")
self._voidMat = voidMat

@property
def voidExclude(self):
Expand Down
5 changes: 3 additions & 2 deletions tests/config_cadtocsg_non_defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"P_abc": "15.7e"
},
"Settings": {
"matFile": "non default"
"matFile": "non default",
"voidMat": [1, -1.29E-3, "Dry air"]
}
}
}

0 comments on commit 3992d3a

Please sign in to comment.