Skip to content

Commit

Permalink
Closes #1003. Closes #973
Browse files Browse the repository at this point in the history
  • Loading branch information
alfoa committed Jun 5, 2019
1 parent b520449 commit 210e4ee
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 29 deletions.
14 changes: 7 additions & 7 deletions framework/Distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,9 @@ def cdf(self,x):
@ Out, retunrCdf, float, requested cdf
"""
if hasattr(x,'__len__'):
returnCdf = np.array([self.cdf(i) for i in x])
returnCdf = np.array([self.cdf(utils.floatConversion(i)) for i in x])
else:
returnCdf = self._distribution.cdf(x)
returnCdf = self._distribution.cdf(utils.floatConversion(x))
return returnCdf

def ppf(self,x):
Expand All @@ -400,9 +400,9 @@ def ppf(self,x):
"""
# TODO speed this up by doing it in Crow, not in python
if hasattr(x,'__len__'):
returnPpf = np.array([self.ppf(i) for i in x])
returnPpf = np.array([self.ppf(utils.floatConversion(i)) for i in x])
else:
returnPpf = self._distribution.inverseCdf(x)
returnPpf = self._distribution.inverseCdf(utils.floatConversion(x))
return returnPpf

def pdf(self,x):
Expand All @@ -411,7 +411,7 @@ def pdf(self,x):
@ In, x, float, value to get the pdf at
@ Out, returnPdf, float, requested pdf
"""
returnPdf = self._distribution.pdf(x)
returnPdf = self._distribution.pdf(utils.floatConversion(x))
return returnPdf

def untruncatedCdfComplement(self, x):
Expand All @@ -420,15 +420,15 @@ def untruncatedCdfComplement(self, x):
@ In, x, float, value to get the untruncated cdf complement at
@ Out, float, requested untruncated cdf complement
"""
return self._distribution.untrCdfComplement(x)
return self._distribution.untrCdfComplement(utils.floatConversion(x))

def untruncatedHazard(self, x):
"""
Function to get the untruncated Hazard at a provided coordinate
@ In, x, float, value to get the untruncated Hazard at
@ Out, float, requested untruncated Hazard
"""
return self._distribution.untrHazard(x)
return self._distribution.untrHazard(utils.floatConversion(x))

def untruncatedMean(self):
"""
Expand Down
36 changes: 18 additions & 18 deletions tests/framework/gold/GridTest/outGrid_dump.csv
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
VarGauss2,VarGauss1,VarTri1
0.0,0.02,3.5
0.0,0.02,4.0
1.0,0.02,3.5
1.0,0.02,4.0
2.0,0.02,3.5
2.0,0.02,4.0
0.0,0.5,3.5
0.0,0.5,4.0
1.0,0.5,3.5
1.0,0.5,4.0
2.0,0.5,3.5
2.0,0.5,4.0
0.0,0.6,3.5
0.0,0.6,4.0
1.0,0.6,3.5
1.0,0.6,4.0
2.0,0.6,3.5
2.0,0.6,4.0
0.0,0,3.5
0.0,0,4.0
1.0,0,3.5
1.0,0,4.0
2.0,0,3.5
2.0,0,4.0
0.0,1,3.5
0.0,1,4.0
1.0,1,3.5
1.0,1,4.0
2.0,1,3.5
2.0,1,4.0
0.0,2,3.5
0.0,2,4.0
1.0,2,3.5
1.0,2,4.0
2.0,2,3.5
2.0,2,4.0
9 changes: 5 additions & 4 deletions tests/framework/test_Grid_Sampler.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<revision author="maljdan" date="2016-04-06">Updating test cases to reflect the changes to the user input.</revision>
<revision author="talbpaul" date="2016-04-26">added check for pre-existing backup files when validating</revision>
<revision author="alfoa" date="2017-01-21">Adding this test description.</revision>
<revision author="alfoa" date="2019-06-05">Modified grid to test resolution of issue #1003</revision>
</revisions>
<requirements>R-RE-3</requirements>
</TestInfo>
Expand Down Expand Up @@ -54,10 +55,10 @@

<Samplers>
<Grid name="myGrid">
<variable name="VarGauss1">
<distribution>Gauss1</distribution>
<grid construction="custom" type="value">0.02 0.5 0.6</grid>
</variable>
<variable name="VarGauss1">
<distribution>Gauss1</distribution>
<grid construction="custom" type="value">0 1 2</grid>
</variable>
<variable name="VarGauss2">
<distribution>Gauss2</distribution>
<grid construction="custom" type="CDF">0.5 1.0 0.0</grid>
Expand Down

0 comments on commit 210e4ee

Please sign in to comment.