def test_num_cases(self):
     uni = Uniform(10)
     uni.num_parameters = 3
     cases = [case for case in uni]
     expected = 10*[[1.0,1.0,1.0]]
     self.assertEqual(len(expected),len(cases))
     self.assertEqual(len(expected[0]),len(cases[0]))    
 def test_low_sample_count(self): 
     uni = Uniform()
     uni.num_paramters = 1
     
     try: 
         for case in uni: 
             pass
     except ValueError as err: 
         self.assertEqual(str(err),"Uniform distributions must have at least 2 samples. num_samples is set to less than 2.")
示例#3
0
    def test_low_sample_count(self):
        uni = Uniform()
        uni.num_paramters = 1

        try:
            for case in uni:
                pass
        except ValueError as err:
            self.assertEqual(
                str(err),
                "Uniform distributions must have at least 2 samples. num_samples is set to less than 2."
            )
    def test_nested_loop(self):
        # test to make sure the generator can handle nested loops
        uni = Uniform(5)
        uni.num_parameters = 2

        inner_count = 0
        outer_count = 0
        for case_outer in uni:
            outer_count += 1
            for case_inner in uni:
                inner_count += 1

        self.assertEqual(5,outer_count)
        self.assertEqual(25,inner_count)
示例#5
0
    def test_nested_loop(self):
        # test to make sure the generator can handle nested loops
        uni = Uniform(5)
        uni.num_parameters = 2

        inner_count = 0
        outer_count = 0
        for case_outer in uni:
            outer_count += 1
            for case_inner in uni:
                inner_count += 1

        self.assertEqual(5, outer_count)
        self.assertEqual(25, inner_count)
示例#6
0
    def __init__(self, *args, **kwargs):
        super(Analysis, self).__init__(self, *args, **kwargs)

        self._tdir = mkdtemp()

        #Component
        self.add("A", ConceptA())

        #Driver
        self.add("DOE_A", DOEdriver())
        #self.DOE_A.sequential = True
        #self.DOE_A.DOEgenerator = FullFactorial(num_levels = 3)
        self.DOE_A.DOEgenerator = Uniform(num_levels=3)
        self.DOE_A.add_parameter("A.x")
        self.DOE_A.add_parameter("A.y")
        self.DOE_A.case_outputs = ['A.f1', 'A.f2']
        self.DOE_A.recorders = [
            DBCaseRecorder(os.path.join(self._tdir, 'A.db'))
        ]

        #Iteration Hierarchy
        self.driver.workflow.add(['DOE_A'])
        self.DOE_A.workflow.add('A')
示例#7
0
 def execute(self):
     n = self.cases.pop()
     print 'Number of training cases = ', n
     self.DOEgen = Uniform(num_samples=n)
示例#8
0
 def test_num_cases(self):
     uni = Uniform(10)
     uni.num_parameters = 3
     cases = [case for case in uni]