def test_find_key(self): indict = {'A': {'AA': {'AAA': 0, 'X': 1}, 'AB': {'ABA': 2, 'X': 3}, 'AC': {'ACA': 4, 'X': 5}}} outdict = [{'X': 1, 'AAA': 0}, {'X': 5, 'ACA': 4}, {'ABA': 2, 'X': 3}] try: self.assertCountEqual(list(rainbow.find_key('X', indict)), outdict) self.assertCountEqual(list(rainbow.find_key('Y', indict)), []) except AttributeError: self.assertItemsEqual(list(rainbow.find_key('X', indict)), outdict) self.assertItemsEqual(list(rainbow.find_key('Y', indict)), [])
def test_find_key(self): indict = {'A': {'AA': {'AAA': 0, 'X': 1}, 'AB': {'ABA': 2, 'X': 3}, 'AC': {'ACA': 4, 'X': 5}, 'AD': [{'ADA': 4, 'X': 2}]}} outdict = [{'X': 1, 'AAA': 0}, {'X': 5, 'ACA': 4}, {'ABA': 2, 'X': 3}, {'ADA': 4, 'X': 2}] try: self.assertCountEqual(list(rainbow.find_key('X', indict)), outdict) self.assertCountEqual(list(rainbow.find_key('Y', indict)), []) except AttributeError: self.assertItemsEqual(list(rainbow.find_key('X', indict)), outdict) self.assertItemsEqual(list(rainbow.find_key('Y', indict)), [])
def test_get_RB_data_shape(self): xmltodict = wrl.util.import_optional('xmltodict') data = xmltodict.parse(('<slicedata time="13:30:05" date="2013-04-26">' '#<rayinfo refid="startangle" blobid="0" ' 'rays="361" depth="16"/> #<rawdata blobid="1" ' 'rays="361" type="dBuZ" bins="400" ' 'min="-31.5" max="95.5" depth="8"/> #<flagmap ' 'blobid="2" rows="800" type="dBuZ" ' 'columns="400" min="-31.5" max="95.5" ' 'depth="6"/> #<defect blobid="3" type="dBuZ" ' 'columns="400" min="-31.5" max="95.5" ' 'depth="6"/> #</slicedata>')) data = list(rainbow.find_key('@blobid', data)) self.assertEqual(rainbow.get_RB_data_shape(data[0]), 361) self.assertEqual(rainbow.get_RB_data_shape(data[1]), (361, 400)) self.assertEqual(rainbow.get_RB_data_shape(data[2]), (800, 400, 6)) self.assertRaises(KeyError, lambda: rainbow.get_RB_data_shape(data[3]))
def test_get_RB_data_attribute(self): xmltodict = wrl.util.import_optional('xmltodict') data = xmltodict.parse(('<slicedata time="13:30:05" date="2013-04-26">' '#<rayinfo refid="startangle" blobid="0" ' 'rays="361" depth="16"/> ' '#<rawdata blobid="1" rays="361" type="dBuZ" ' 'bins="400" min="-31.5" max="95.5" ' 'depth="8"/> #</slicedata>')) data = list(rainbow.find_key('@blobid', data)) self.assertEqual(rainbow.get_RB_data_attribute(data[0], 'blobid'), 0) self.assertEqual(rainbow.get_RB_data_attribute(data[1], 'blobid'), 1) self.assertEqual(rainbow.get_RB_data_attribute(data[0], 'rays'), 361) self.assertEqual(rainbow.get_RB_data_attribute(data[1], 'rays'), 361) self.assertEqual(rainbow.get_RB_data_attribute(data[1], 'bins'), 400) self.assertRaises( KeyError, lambda: rainbow.get_RB_data_attribute(data[0], 'Nonsense')) self.assertEqual(rainbow.get_RB_data_attribute(data[0], 'depth'), 16)
def test_get_rb_data_attribute(self): xmltodict = wrl.util.import_optional('xmltodict') data = xmltodict.parse(('<slicedata time="13:30:05" date="2013-04-26">' '#<rayinfo refid="startangle" blobid="0" ' 'rays="361" depth="16"/> ' '#<rawdata blobid="1" rays="361" type="dBuZ" ' 'bins="400" min="-31.5" max="95.5" ' 'depth="8"/> #</slicedata>')) data = list(rainbow.find_key('@blobid', data)) self.assertEqual(rainbow.get_rb_data_attribute(data[0], 'blobid'), 0) self.assertEqual(rainbow.get_rb_data_attribute(data[1], 'blobid'), 1) self.assertEqual(rainbow.get_rb_data_attribute(data[0], 'rays'), 361) self.assertEqual(rainbow.get_rb_data_attribute(data[1], 'rays'), 361) self.assertEqual(rainbow.get_rb_data_attribute(data[1], 'bins'), 400) self.assertRaises(KeyError, lambda: rainbow.get_rb_data_attribute(data[0], 'Nonsense')) self.assertEqual(rainbow.get_rb_data_attribute(data[0], 'depth'), 16)
def test_get_rb_data_shape(self): xmltodict = wrl.util.import_optional('xmltodict') data = xmltodict.parse(('<slicedata time="13:30:05" date="2013-04-26">' '#<rayinfo refid="startangle" blobid="0" ' 'rays="361" depth="16"/> #<rawdata blobid="1" ' 'rays="361" type="dBuZ" bins="400" ' 'min="-31.5" max="95.5" depth="8"/> #<flagmap ' 'blobid="2" rows="800" type="dBuZ" ' 'columns="400" min="-31.5" max="95.5" ' 'depth="6"/> #<defect blobid="3" type="dBuZ" ' 'columns="400" min="-31.5" max="95.5" ' 'depth="6"/> #<rawdata2 ' 'blobid="4" rows="800" type="dBuZ" ' 'columns="400" min="-31.5" max="95.5" ' 'depth="8"/> #</slicedata>')) data = list(rainbow.find_key('@blobid', data)) self.assertEqual(rainbow.get_rb_data_shape(data[0]), 361) self.assertEqual(rainbow.get_rb_data_shape(data[1]), (361, 400)) self.assertEqual(rainbow.get_rb_data_shape(data[2]), (800, 400, 6)) self.assertEqual(rainbow.get_rb_data_shape(data[4]), (800, 400)) self.assertRaises(KeyError, lambda: rainbow.get_rb_data_shape(data[3]))