setup.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. from setuptools import setup
  2. import distutils.command.check
  3. from macop import __version__
  4. class TestCommand(distutils.command.check.check):
  5. """Custom test command."""
  6. def run(self):
  7. # run tests using doctest
  8. import doctest
  9. # set specific seed for pseudo-random process
  10. import random
  11. import numpy as np
  12. # discrete and continuous solutions module
  13. from macop.solutions import discrete
  14. from macop.solutions import continuous
  15. # operators module
  16. from macop.operators.discrete import mutators as discrete_mutators
  17. from macop.operators.discrete import crossovers as discrete_crossovers
  18. from macop.operators.continuous import mutators as continuous_mutators
  19. from macop.operators.continuous import crossovers as continuous_crossovers
  20. # policies module
  21. from macop.policies import classicals
  22. from macop.policies import reinforcement
  23. # evaluators module
  24. from macop.evaluators.discrete import mono as discrete_mono
  25. from macop.evaluators.discrete import multi as discrete_multi
  26. # algorithms
  27. from macop.algorithms import mono as algo_mono
  28. from macop.algorithms import multi as algo_multi
  29. # run all doctest
  30. print("==============================")
  31. print("Runs test command...")
  32. random.seed(42)
  33. np.random.seed(42)
  34. # discrete solutions module
  35. doctest.testmod(discrete)
  36. doctest.testmod(continuous)
  37. random.seed(42)
  38. np.random.seed(42)
  39. # operators module
  40. doctest.testmod(discrete_mutators)
  41. doctest.testmod(discrete_crossovers)
  42. random.seed(42)
  43. np.random.seed(42)
  44. # operators module
  45. doctest.testmod(continuous_mutators)
  46. doctest.testmod(continuous_crossovers)
  47. random.seed(42)
  48. np.random.seed(42)
  49. # policies module
  50. doctest.testmod(classicals)
  51. doctest.testmod(reinforcement)
  52. random.seed(42)
  53. np.random.seed(42)
  54. # policies module
  55. doctest.testmod(discrete_mono)
  56. doctest.testmod(discrete_multi)
  57. random.seed(42)
  58. np.random.seed(42)
  59. # policies module
  60. doctest.testmod(algo_mono)
  61. doctest.testmod(algo_multi)
  62. # pass test using doctest
  63. distutils.command.check.check.run(self)
  64. setup(
  65. name='macop',
  66. version=__version__,
  67. description='Minimalist And Customisable Optimisation Package',
  68. long_description=open('README.md').read(),
  69. long_description_content_type='text/markdown',
  70. classifiers=[
  71. 'Development Status :: 5 - Production/Stable',
  72. 'License :: OSI Approved :: MIT License',
  73. 'Programming Language :: Python :: 3.8',
  74. 'Topic :: Scientific/Engineering',
  75. 'Topic :: Utilities'
  76. ],
  77. url='https://github.com/prise-3d/macop',
  78. author='Jérôme BUISINE',
  79. author_email='jerome.buisine@univ-littoral.fr',
  80. license='MIT',
  81. packages=['macop',
  82. 'macop.algorithms',
  83. 'macop.callbacks',
  84. 'macop.evaluators',
  85. 'macop.evaluators.discrete',
  86. 'macop.evaluators.continuous',
  87. 'macop.operators',
  88. 'macop.operators.discrete',
  89. 'macop.operators.continuous',
  90. 'macop.policies',
  91. 'macop.solutions',
  92. 'macop.utils'],
  93. install_requires=[
  94. 'numpy',
  95. ],
  96. cmdclass={
  97. 'test': TestCommand,
  98. },
  99. zip_safe=False)