Skip to content

Commit

Permalink
resolve comments, update tests and docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
wangcj05 committed Aug 6, 2018
1 parent ffed4c7 commit be29bcb
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 93 deletions.
13 changes: 11 additions & 2 deletions framework/utils/graphStructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ def __generateEdges(self):
def findIsolatedVertices(self):
"""
This method ispects the graph and returns a list of isolated vertices.
WARNING: the self.__extendDictForGraphTheory() is used here, and never store the outputs
of this method into the self.__graphDict.
@ In, None
@ Out, isolated, list, list of isolated nodes (verteces)
"""
Expand Down Expand Up @@ -229,7 +231,10 @@ def isConnected(self, graphDict, verticesEncountered = None, startVertex=None):

def isConnectedNet(self):
"""
Method that determines if the graph is a connected net (all the vertices are connect with each other through other vertices)
Method that determines if the graph is a connected net (all the vertices are connect
with each other through other vertices).
WARNING: the self.__extendDictForGraphTheory() is used here, and never store the outputs
of this method into the self.__graphDict.
@ In, None
@ Out, graphNetConnected, bool, is the graph net fully connected?
"""
Expand All @@ -239,7 +244,11 @@ def isConnectedNet(self):

def __extendDictForGraphTheory(self):
"""
Method to extend the graph dictionary in order to be accepted by the graph theory
Method to extend the graph dictionary in order to be accepted by the graph theory.
WARNING: This is method is only used to extend the __graphDict, and should be only
used for isConnectedNet method. The extended dictionary should not be stored in
__graphDict. This is because the class graphObject is supposed to work with
directed graph to determine the execution orders of the Models listed under EnsembleModel.
@ In, None
@ Out, graphDict, dict, the extended graph dictionary, used for isConnectedNet and findIsolatedVertices
"""
Expand Down
20 changes: 8 additions & 12 deletions tests/framework/ensembleModelTests/checkConnection/alpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import copy
import time
# CAUTION HERE #
# IT IS IMPORTANT THAT THE USER IS AWARE THAT THE EXTERNAL MODEL (RUN METHOD)
# NEEDS TO BE THREAD-SAFE!!!!!
# IN CASE IT IS NOT, THE USER NEEDS TO SET A LOCK SYSTEM!!!!!
import threading
localLock = threading.RLock()

def initialize(self, runInfo, inputs):
pass

def run(self, Input):
"""
A dummy model used to check the connections for the EnsembleModel
@ In, self, object, object to store members on
@ In, Input, dict, dictionary containing inputs from RAVEN
@ Out, None
"""
self.A = Input.get('A')
self.B = Input.get('B')
self.C = self.A + self.B
20 changes: 8 additions & 12 deletions tests/framework/ensembleModelTests/checkConnection/beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import copy
import time
# CAUTION HERE #
# IT IS IMPORTANT THAT THE USER IS AWARE THAT THE EXTERNAL MODEL (RUN METHOD)
# NEEDS TO BE THREAD-SAFE!!!!!
# IN CASE IT IS NOT, THE USER NEEDS TO SET A LOCK SYSTEM!!!!!
import threading
localLock = threading.RLock()

def initialize(self, runInfo, inputs):
pass

def run(self, Input):
"""
A dummy model used to check the connections for the EnsembleModel
@ In, self, object, object to store members on
@ In, Input, dict, dictionary containing inputs from RAVEN
@ Out, None
"""
self.C = Input.get('C')
self.D = Input.get('D')
self.E = self.C - self.D + 1.0
19 changes: 7 additions & 12 deletions tests/framework/ensembleModelTests/checkConnection/delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import copy
import time
# CAUTION HERE #
# IT IS IMPORTANT THAT THE USER IS AWARE THAT THE EXTERNAL MODEL (RUN METHOD)
# NEEDS TO BE THREAD-SAFE!!!!!
# IN CASE IT IS NOT, THE USER NEEDS TO SET A LOCK SYSTEM!!!!!
import threading
localLock = threading.RLock()

def initialize(self, runInfo, inputs):
pass

def run(self, Input):
"""
A dummy model used to check the connections for the EnsembleModel
@ In, self, object, object to store members on
@ In, Input, dict, dictionary containing inputs from RAVEN
@ Out, None
"""
self.E = Input.get('E')
self.F = self.E + 1.0
19 changes: 7 additions & 12 deletions tests/framework/ensembleModelTests/checkConnection/epsilon.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import copy
import time
# CAUTION HERE #
# IT IS IMPORTANT THAT THE USER IS AWARE THAT THE EXTERNAL MODEL (RUN METHOD)
# NEEDS TO BE THREAD-SAFE!!!!!
# IN CASE IT IS NOT, THE USER NEEDS TO SET A LOCK SYSTEM!!!!!
import threading
localLock = threading.RLock()

def initialize(self, runInfo, inputs):
pass

def run(self, Input):
"""
A dummy model used to check the connections for the EnsembleModel
@ In, self, object, object to store members on
@ In, Input, dict, dictionary containing inputs from RAVEN
@ Out, None
"""
self.H = Input.get('H')
self.G = self.H + 3.0
19 changes: 7 additions & 12 deletions tests/framework/ensembleModelTests/checkConnection/gamma.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import copy
import time
# CAUTION HERE #
# IT IS IMPORTANT THAT THE USER IS AWARE THAT THE EXTERNAL MODEL (RUN METHOD)
# NEEDS TO BE THREAD-SAFE!!!!!
# IN CASE IT IS NOT, THE USER NEEDS TO SET A LOCK SYSTEM!!!!!
import threading
localLock = threading.RLock()

def initialize(self, runInfo, inputs):
pass

def run(self, Input):
"""
A dummy model used to check the connections for the EnsembleModel
@ In, self, object, object to store members on
@ In, Input, dict, dictionary containing inputs from RAVEN
@ Out, None
"""
self.G = Input.get('G')
self.D = self.G + 1.0
19 changes: 7 additions & 12 deletions tests/framework/ensembleModelTests/checkConnection/rho.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import copy
import time
# CAUTION HERE #
# IT IS IMPORTANT THAT THE USER IS AWARE THAT THE EXTERNAL MODEL (RUN METHOD)
# NEEDS TO BE THREAD-SAFE!!!!!
# IN CASE IT IS NOT, THE USER NEEDS TO SET A LOCK SYSTEM!!!!!
import threading
localLock = threading.RLock()

def initialize(self, runInfo, inputs):
pass

def run(self, Input):
"""
A dummy model used to check the connections for the EnsembleModel
@ In, self, object, object to store members on
@ In, Input, dict, dictionary containing inputs from RAVEN
@ Out, None
"""
self.D = Input.get('D')
self.I = self.D - 1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
A,B,C,D,E,F,G
0.0,2.0,2.0,9.0,-6.0,-5.0,8.0
0.0,2.0,2.0,10.5,-7.5,-6.5,9.5
0.0,2.0,2.0,12.0,-9.0,-8.0,11.0
0.0,3.0,3.0,9.0,-5.0,-4.0,8.0
0.0,3.0,3.0,10.5,-6.5,-5.5,9.5
0.0,3.0,3.0,12.0,-8.0,-7.0,11.0
1.0,2.0,3.0,9.0,-5.0,-4.0,8.0
1.0,2.0,3.0,10.5,-6.5,-5.5,9.5
1.0,2.0,3.0,12.0,-8.0,-7.0,11.0
1.0,3.0,4.0,9.0,-4.0,-3.0,8.0
1.0,3.0,4.0,10.5,-5.5,-4.5,9.5
1.0,3.0,4.0,12.0,-7.0,-6.0,11.0
25 changes: 7 additions & 18 deletions tests/framework/ensembleModelTests/test_em_connection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,16 @@
</MultiRun>
<IOStep name="dumpResults" pauseAtEnd="True">
<Input class="DataObjects" type="PointSet" >metaModelData</Input>
<Output class="OutStreams" type="Plot" >plotData</Output>
<Output class="OutStreams" type="Print" >printData</Output>
</IOStep>
</Steps>

<OutStreams>
<Plot name="plotData" overwrite="false" verbosity="debug">
<plotSettings>
<plot>
<type>scatter</type>
<x>metaModelData|Input|A</x>
<y>metaModelData|Input|B</y>
<z>metaModelData|Output|F</z>
</plot>
<xlabel>A</xlabel>
<ylabel>B</ylabel>
<zlabel>F</zlabel>
</plotSettings>
<actions>
<how>png</how>
</actions>
</Plot>
<OutStreams>
<Print name="printData">
<type>csv</type>
<source>metaModelData</source>
<what>input, output</what>
</Print>
</OutStreams>

<DataObjects>
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/ensembleModelTests/tests
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
[./testEMConnection]
type = 'RavenFramework'
input = 'test_em_connection.xml'
output = 'checkConnection/1-plotData_scatter.png'
UnorderedCsv = 'checkConnection/printData.csv'
[../]

[]

0 comments on commit be29bcb

Please sign in to comment.