spdz_test_param.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Copyright 2019 The FATE Authors. All Rights Reserved.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. #
  18. from federatedml.param.base_param import BaseParam
  19. class SPDZTestParam(BaseParam):
  20. def __init__(self, data_num=10000, test_round=1, data_partition=4, seed=123,
  21. data_lower_bound=-1000000000, data_upper_bound=1000000000):
  22. self.data_num = data_num
  23. self.test_round = test_round
  24. self.seed = seed
  25. self.data_partition = data_partition
  26. self.data_lower_bound = data_lower_bound
  27. self.data_upper_bound = data_upper_bound
  28. def check(self):
  29. if self.seed is None or not isinstance(self.seed, int):
  30. raise ValueError("random seed should be integer")
  31. if not isinstance(self.test_round, int) or self.test_round < 1:
  32. raise ValueError("test_round should be positive integer")
  33. if not isinstance(self.data_num, int) or self.data_num < 1:
  34. raise ValueError("data_num should be positive integer")
  35. if not isinstance(self.data_partition, int) or self.data_partition < 1:
  36. raise ValueError("data partition should be positive integer")
  37. if not isinstance(self.data_upper_bound, (int, float)) or not isinstance(self.data_lower_bound, (int, float)):
  38. raise ValueError("bound of data should be numeric")