Beispiel #1
0
 def test_0(self):
     points = 0
     # use the same input vector for both u and v to avoid ambiguity in the order of iteration
     results = Feedback.call_user(
         self.st.power_iteration, self.ref.M_test, self.ref.x_test)
     if results is None:
         Feedback.add_feedback(
             'Your function is not returning any variables.')
         self.fail()
     if Feedback.check_numpy_array_allclose('The return value from your function power_iteration', self.ref.xc, results):
         points += 0.5
     results_hidden = Feedback.call_user(
         self.st.power_iteration, self.ref.M_hidden, self.ref.x_hidden)
     if Feedback.check_numpy_array_allclose('The return value from your function power_iteration (hidden test case)', self.ref.xc_hidden, results_hidden):
         points += 0.5
     Feedback.set_score(points)
Beispiel #2
0
 def test_4(self):
     if Feedback.check_numpy_array_allclose('right_side',
                                            self.ref.right_side,
                                            self.st.right_side):
         Feedback.set_score(1)
     else:
         Feedback.set_score(0)
Beispiel #3
0
    def test_1(self):
        points = 0
        results = feedback.call_user(self.st.array_to_scalar, self.ref.a1,
                                     self.ref.a2)
        ## Testing if the return values are given correctly
        if results is not None:
            if hasattr(results, '__len__'):
                if (len(results) != 2):
                    feedback.add_feedback(
                        'Your function is not returning the correct number of variables'
                    )
                    self.fail()
                else:
                    (st_c, st_sumc) = results
            else:
                feedback.add_feedback(
                    'The return variables do not appear to be in tuple format')
                self.fail()
        else:
            feedback.add_feedback(
                'Your function is not returning any variables.')
            self.fail()

        if feedback.check_numpy_array_allclose('c',
                                               self.ref.c,
                                               st_c,
                                               accuracy_critical=False):
            points += 0.5

        if feedback.check_scalar('sum_c',
                                 self.ref.sum_c,
                                 st_sumc,
                                 accuracy_critical=True):
            points += 0.5

        feedback.set_score(points)
Beispiel #4
0
 def test_2(self):
     points = 0
     xstar2 = convert_to_float_array(self.st.xstar2)
     if Feedback.check_numpy_array_allclose('xstar2', self.ref.xstar2, xstar2):
         points += 1
     Feedback.set_score(points)
Beispiel #5
0
 def test_1(self):
     points = 0
     if Feedback.check_numpy_array_allclose('G', self.ref.G, self.st.G):
         points += 1
     Feedback.set_score(points)
Beispiel #6
0
 def test_0(self):
     if Feedback.check_numpy_array_allclose("x", self.ref.x, self.st.x):
         Feedback.set_score(1)
     else:
         Feedback.set_score(0)
Beispiel #7
0
 def test_2(self):
     score = 0
     if feedback.check_numpy_array_allclose("composition", self.ref.composition, self.st.composition, accuracy_critical=False):
         score += 1.0
     feedback.set_score(score)
Beispiel #8
0
 def test_4(self):
     points = 0
     if Feedback.check_numpy_array_allclose('M3', self.ref.M3, self.st.M3):
         points += 1
     Feedback.set_score(points)
Beispiel #9
0
 def test_0(self):
     if Feedback.check_numpy_array_allclose('groups', self.ref.groups,
                                            self.st.groups):
         Feedback.set_score(1)
     else:
         Feedback.set_score(0)
Beispiel #10
0
 def test_5(self):
     if Feedback.check_numpy_array_allclose('next_arr', self.ref.next_arr,
                                            self.st.next_arr):
         Feedback.set_score(1)
     else:
         Feedback.set_score(0)
Beispiel #11
0
 def test_1(self):
     if Feedback.check_numpy_array_allclose('medians', self.ref.medians,
                                            self.st.medians):
         Feedback.set_score(1)
     else:
         Feedback.set_score(0)