Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #0: Remove slow hash. #169

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft

Issue #0: Remove slow hash. #169

wants to merge 1 commit into from

Conversation

Mark2000
Copy link
Contributor

@Mark2000 Mark2000 commented Aug 2, 2024

Description

This is slower than the python default hash function for the Target object.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How should this pull request be reviewed?

  • By commit
  • All changes at once

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Passes Tests

  • Unit tests pytest --cov bsk_rl --cov-report term-missing tests/unittest
  • Integrated tests pytest --cov bsk_rl --cov-report term-missing tests/integration
  • Documentation builds cd docs; make html

Test Configuration

  • Python: 3.11
  • Basilisk: 2.3
  • Platform: Mac

Checklist:

  • My code follows the style guidelines of this project (passes Black, ruff, and isort)
  • I have performed a self-review of my code
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation and release notes
  • Commit messages are atomic, are in the form Issue #XXX: Message and have a useful message
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • If I changed an example ipynb, I have locally rebuilt the documentation

@@ -48,10 +48,6 @@ def id(self) -> str:
self._id = f"{self.name}_{id(self)}"
return self._id

def __hash__(self) -> int:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To check if I understood it right, the hash will now be generated based on the entire object, and not only on its id, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm not sure why I put this in in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it may be worth checking how targets are copied, if ever. I believe deepcopy changes the hash but not the id, so this could potentially lead to issues. I'll take a closer look at some point; not a big enough performance improvement to warrant potentially introducing an error without being sure of this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't considered that before, but I agree. This is a subtle change that can lead to unexpected consequences.

@Mark2000 Mark2000 marked this pull request as draft September 23, 2024 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants