Example #1
0
 def testExtractArrayFloat(self):
     """
     Test that extractList extracts floats from np.array string.
     """
     list_string = '[0.0 1.0 2.0 3.1 4.2]'
     extracted_list = extractList(list_string, float)
     self.assertEqual([0.0, 1.0, 2.0, 3.1, 4.2], extracted_list)
     list_string = '[ 0.0 1.0 2.0 3.1 4.2]'
     extracted_list = extractList(list_string, float)
     self.assertEqual([0.0, 1.0, 2.0, 3.1, 4.2], extracted_list)
Example #2
0
 def testExtractArrayInt(self):
     """
     Test that extractList extracts floats from np.array string.
     """
     list_string = '[0 1 2 3 4]'
     extracted_list = extractList(list_string, int)
     self.assertEqual([0, 1, 2, 3, 4], extracted_list)
     list_string = '[ 0 1 2 3 4]'
     extracted_list = extractList(list_string, int)
     self.assertEqual([0, 1, 2, 3, 4], extracted_list)
Example #3
0
 def testExtractListFloat(self):
     """
     Test that extractList extracts floats.
     """
     list_string = '[0.0, 1.0, 2.0, 3.1, 4.2]'
     extracted_list = extractList(list_string, float)
     self.assertEqual([0.0, 1.0, 2.0, 3.1, 4.2], extracted_list)
     list_string = '[ 0.0, 1.0, 2.0, 3.1, 4.2]'
     extracted_list = extractList(list_string, float)
     self.assertEqual([0.0, 1.0, 2.0, 3.1, 4.2], extracted_list)
Example #4
0
 def testExtractListInt(self):
     """
     Test that extractList extracts ints.
     """
     list_string = '[0, 1, 2, 3, 42]'
     extracted_list = extractList(list_string, int)
     self.assertEqual([0, 1, 2, 3, 42], extracted_list)
     list_string = '[ 0, 1, 2, 3, 42]'
     extracted_list = extractList(list_string, int)
     self.assertEqual([0, 1, 2, 3, 42], extracted_list)
Example #5
0
 def testExtractArrayFloatNoTrailingZero(self):
     """
     Test that extractList extracts floats from np.array string.
     """
     list_string = '[0. 1. 2.]'
     extracted_list = extractList(list_string, float)
     self.assertEqual([0.0, 1.0, 2.0], extracted_list)
     list_string = '[ 0. 1. 2.]'
     extracted_list = extractList(list_string, float)
     self.assertEqual([0.0, 1.0, 2.0], extracted_list)
Example #6
0
    def testExtractListNoType(self):
        """
        Test that extractList extracts without type.
        """
        list_string = '[0.0, 1.0, 2.0, 3.1, 4.2]'
        extracted_list = extractList(list_string)
        self.assertEqual([0.0, 1.0, 2.0, 3.1, 4.2], extracted_list)

        list_string = '[0, 1, 2, 3, 42]'
        extracted_list = extractList(list_string)
        self.assertEqual([0, 1, 2, 3, 42], extracted_list)
Example #7
0
 def testExtractArrayMixedSignFloat(self):
     """
     Test that extractList extracts floats from np.array string.
     """
     list_string = '[20.0, -20.0]'
     extracted_list = extractList(list_string, float)
     self.assertEqual([20.0, -20.0], extracted_list)
     list_string = '[ 20.0, -20.0]'
     extracted_list = extractList(list_string, float)
     list_string = '[  20.0, -20.0]'
     extracted_list = extractList(list_string, float)
     list_string = '[   20.0, -20.0]'
     extracted_list = extractList(list_string, float)
     self.assertEqual([20.0, -20.0], extracted_list)
     list_string = '[-20.0,20.0]'
     extracted_list = extractList(list_string, float)
     self.assertEqual([-20.0, 20.0], extracted_list)
     list_string = '[-20.0, 20.0]'
     extracted_list = extractList(list_string, float)
     self.assertEqual([-20.0, 20.0], extracted_list)
     list_string = '[-20.0,  20.0]'
     extracted_list = extractList(list_string, float)
     self.assertEqual([-20.0, 20.0], extracted_list)
     list_string = '[ -20.0,20.0]'
     extracted_list = extractList(list_string, float)
     self.assertEqual([-20.0, 20.0], extracted_list)
Example #8
0
 def testExtractListEmpty(self):
     """
     Test that accepts empty lists.
     """
     list_string = ''
     extracted_list = extractList(list_string, float)
     self.assertEqual([], extracted_list)
Example #9
0
 def testExtractArrayNegativeInt(self):
     """
     Test that extractList extracts floats from np.array string.
     """
     list_string = '[-20, -20]'
     extracted_list = extractList(list_string, float)
     self.assertEqual([-20, -20], extracted_list)
     list_string = '[ -20, -20]'
     extracted_list = extractList(list_string, float)
     self.assertEqual([-20, -20], extracted_list)
     list_string = '[-20,-20]'
     extracted_list = extractList(list_string, float)
     self.assertEqual([-20, -20], extracted_list)
     list_string = '[ -20,-20]'
     extracted_list = extractList(list_string, float)
     self.assertEqual([-20, -20], extracted_list)
Example #10
0
 def testExtractNestedLists(self):
     """
     Test that extractList extracts nested lists.
     """
     list_string = '[0, 1, 2, 3, 42, [67, 89], "Hello World"]'
     extracted_list = extractList(list_string)
     self.assertEqual([0, 1, 2, 3, 42, [67, 89], "Hello World"],
                      extracted_list)