def testSetName(self): name = 'dummy' values = range(100) ea = ExtendedArray(name=name, values=values) self.assertEqual(ea.name, name) name = 'another dummy' ea.setName(name) self.assertEqual(ea.name, name)
def testType(self): name = 'dummy' values = range(100) ea = ExtendedArray(name=name, values=values) self.assertEqual(ea.dtype, np.int64) values = [x * 0.1 for x in range(100)] ea = ExtendedArray(name=name, values=values) self.assertEqual(ea.dtype, np.float64)
def testBasic(self): name = 'dummy' values = range(100) ea = ExtendedArray(name=name, values=values) self.assertEqual(ea.name, name) ea_values = [x for x in ea] self.assertEqual(ea_values, values)
def testIsEquivalentNestedArray(self): array = ExtendedArray([ np.array([0.069]), np.array([0.015, 0.069, 0.021]), np.array([0.027]), np.array([0.027]), np.array([0.027]) ]) self.assertTrue(cell_types.isEquivalentData(array, array)) array2 = ExtendedArray([ np.array([0.069]), np.array([0.15, 0.069, 0.021]), # 0.015->0.15 np.array([0.027]), np.array([0.027]), np.array([0.027]) ]) self.assertFalse(cell_types.isEquivalentData(array, array2))
def testIsEquivalentData(self): self.assertTrue(cell_types.isEquivalentData(1, 1)) self.assertFalse(cell_types.isEquivalentData(1, 2)) range1 = range(5) range2 = range(6) self.assertTrue(cell_types.isEquivalentData(range1, range1)) self.assertFalse(cell_types.isEquivalentData(range1, range2)) values1 = [np.nan, np.nan, np.nan] values2 = ExtendedArray(0.41509) self.assertFalse(cell_types.isEquivalentData(values1, values2))
def testIsEquivalentData2(self): values = [ '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60', '61', '62', '63', '64' ] array = ExtendedArray(values) self.assertTrue(cell_types.isEquivalentData(array, array))
def testIsEquivalentMismatchedData(self): values1 = ExtendedArray([ 0.04123, 0.00729, 0.03847, 0.01675, 0.01031, 0.01563, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan ]) values2 = [ 0.04123, 0.00729, 0.03847, 0.01675, 0.01031, 0.01563, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan ] self.assertTrue(cell_types.isEquivalentData(values1, values2))
def testIsEquivalentUnicode(self): values1 = ExtendedArray([0., 1., 2., 3., np.nan, np.nan, np.nan]) values2 = [u'0.0', u'1.0', u'2.0', u'3.0', None] self.assertTrue(cell_types.isEquivalentData(values1, values2))
def testIsEquivalentNestedNan(self): values1 = ExtendedArray([np.array([ 1.]), np.array([ 0.183, 0.966, 0.966]), np.array([ np.nan]), \ np.array([ np.nan]), np.array([ np.nan]), None, None]) values2 = np.array([np.array([ 1.]), np.array([ 0.183, 0.966, 0.966]), np.array([ np.nan]), \ np.array([ np.nan])]) self.assertTrue(cell_types.isEquivalentData(values1, values2))
def testIsEquivalentMismatchedData(self): values1 = ExtendedArray([[0.0], [1.0], [2.0], [3.0], None, None]) values2 = [[0.0], [1.0], [2.0], [3.0]] values3 = [[u'0'], [u'1'], [u'2'], [u'3']] self.assertTrue(cell_types.isEquivalentData(values1, values3)) self.assertTrue(cell_types.isEquivalentData(values1, values2))
def makeArray(aList): return ExtendedArray(values=aList)
def testSingleValue(self): ea = ExtendedArray(name='Dummy', values=1) self.assertEqual(len(ea), 1)
def testLen(self): values = range(5) ea = ExtendedArray(name='Dummy', values=values) self.assertEqual(len(values), len(ea)) ea = ExtendedArray(name='Dummy', values=1) self.assertEqual(1, len(ea))