ohe_alignment_test.py 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import unittest
  2. import uuid
  3. from fate_arch.session import computing_session as session
  4. from federatedml.feature.homo_onehot.homo_ohe_arbiter import HomoOneHotArbiter
  5. class TestOHE_alignment(unittest.TestCase):
  6. def setUp(self):
  7. self.job_id = str(uuid.uuid1())
  8. session.init(self.job_id)
  9. def test_instance(self):
  10. ohe_alignment_arbiter = HomoOneHotArbiter()
  11. guest_columns = [
  12. {'race_black': ['0', '1'], 'race_hispanic': ['0'], 'race_asian': ['0', '1'], 'race_other': ['1'],
  13. 'electivesurgery': ['0', '1']}]
  14. host_columns = [
  15. {'race_black': ['0', '1'], 'race_hispanic': ['0', '1'], 'race_asian': ['0', '1'], 'race_other': ['0'],
  16. 'electivesurgery': ['0', '1']}]
  17. aligned_columns = sorted(
  18. ohe_alignment_arbiter.combine_all_column_headers(guest_columns, host_columns)['race_hispanic'])
  19. self.assertTrue(len(aligned_columns) == 2)
  20. self.assertEqual(['0', '1'], aligned_columns)
  21. def tearDown(self):
  22. session.stop()
  23. if __name__ == '__main__':
  24. unittest.main()