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

Prevent Optimizer from taking in non-unique emitter instances #75

Merged
merged 4 commits into from
Feb 3, 2021

Conversation

btjanaka
Copy link
Member

@btjanaka btjanaka commented Feb 3, 2021

Description

Users were previously able to do something like:

emitters = [GaussianEmitter(...)] * 5
optimizer = Optimizer(archive, emitters)

However, this is incorrect because emitters now contains 5 of the same instance of GaussianEmitter, when it should really contain 5 unique instances, which one would get if they instead did:

emitters = [GaussianEmitter(...) for _ in range(5)]

This PR makes sure Optimizer cannot take in an emitters list where any of the members have the same id().

Changelog Description

Fixed a bug where Optimizer is able to take in non-unique emitter instances

TODO

  • Add test for this bug
  • Fix the bug
  • Add warning in documentation

Questions

Status

  • I have read the guidelines in
    CONTRIBUTING.md.
  • I have formatted my code using yapf
  • I have tested my code by running pytest (tox is run in CI/CD)
  • I have linted my code with pylint
  • This PR is ready to go

@btjanaka btjanaka merged commit 5d36987 into master Feb 3, 2021
@btjanaka btjanaka deleted the optimizer branch February 3, 2021 06:22
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.

1 participant