Neuron.py 873 B

123456789101112131415161718192021222324252627282930313233
  1. class Neuron(object):
  2. """
  3. This Class is representing a Neuron which is corresponding to an action to perform.
  4. .. note:: Neurons are defined in the brain file
  5. """
  6. def __init__(self, name=None, parameters=None):
  7. self.name = name
  8. self.parameters = parameters
  9. def serialize(self):
  10. """
  11. This method allows to serialize in a proper way this object
  12. :return: A dict of name and parameters
  13. :rtype: Dict
  14. """
  15. return {
  16. 'name': self.name,
  17. 'parameters': str(self.parameters)
  18. }
  19. def __str__(self):
  20. return "Neuron: name: %s, parameters: %s" % (self.name, self.parameters)
  21. def __eq__(self, other):
  22. """
  23. This is used to compare 2 objects
  24. :param other:
  25. :return:
  26. """
  27. return self.__dict__ == other.__dict__