コード例 #1
0
ファイル: test_io_base.py プロジェクト: yuta2/orange3
 def test_adjust_data_width_empty(self):
     names, types, flags = ["a", "b"], [], []
     header = Mock()
     header.names = names
     header.types = types
     header.flags = flags
     data = [["", ""], ["", ""]]
     adjusted, n = DataTableMixin.adjust_data_width(data, header)
     np.testing.assert_array_equal(adjusted, [])
     self.assertEqual(n, 2)
     self.assertListEqual(names, ["a", "b"])
     self.assertListEqual(types, [])
     self.assertListEqual(flags, [])
コード例 #2
0
 def test_adjust_data_width_shorten(self):
     names, types, flags = ["a", "b", "c"], ["", "c"], ["m", "c"]
     header = Mock()
     header.names = names
     header.types = types
     header.flags = flags
     adjusted, n = DataTableMixin.adjust_data_width(self.header0, header)
     np.testing.assert_array_equal(
         adjusted, np.array(self.header0, dtype=object)[:, :3])
     self.assertEqual(adjusted.shape, (len(self.header0), 3))
     self.assertEqual(n, 3)
     self.assertListEqual(names, ["a", "b", "c"])
     self.assertListEqual(types, ["", "c", ""])
     self.assertListEqual(flags, ["m", "c", ""])
コード例 #3
0
 def test_adjust_data_width_lengthen(self):
     names, types, flags = ["a", "b", "c", "d", "e"], ["", "c"], ["m", "c"]
     header = Mock()
     header.names = names
     header.types = types
     header.flags = flags
     adjusted, n = DataTableMixin.adjust_data_width(self.header0, header)
     _data = np.hstack((np.array(self.header0, dtype=object),
                        np.array([[""]] * 3, dtype=object)))
     np.testing.assert_array_equal(_data, adjusted)
     self.assertEqual(adjusted.shape, (len(self.header0), 5))
     self.assertEqual(n, 5)
     self.assertListEqual(names, ["a", "b", "c", "d", "e"])
     self.assertListEqual(types, ["", "c", "", "", ""])
     self.assertListEqual(flags, ["m", "c", "", "", ""])