-
Notifications
You must be signed in to change notification settings - Fork 334
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
Refactor codebase #246
Refactor codebase #246
Conversation
Fix GeneralOptimizer -> |
This commit removes the if-else hierarchy in GeneralOptimizer by abstracting some parts of the topologies. Resolves #232 Signed-off-by: Lester James V. Miranda <[email protected]>
This commit adds test abstractions to PySwarms Resolves #240, #241 Signed-off-by: Lester James V. Miranda <[email protected]>
1973eba
to
54affeb
Compare
This commit adds a .coveragerc file to set-up the coverage requirements when running pytest. Related #245 Signed-off-by: Lester James V. Miranda <[email protected]>
This commit adds an isort configuration to ensure that isort works out of the box. Signed-off-by: Lester James V. Miranda <[email protected]>
54affeb
to
569c8a7
Compare
.coveragerc
Outdated
<<<<<<< HEAD | ||
pos = init_pos | ||
======= | ||
>>>>>>> 092ad40... Add pytest-cov config file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is still a merge conflict 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, can you check if there are still instances of this in other files?
) | ||
assert vector.shape == ( | ||
n_particles, | ||
), "The cost function should return a single value." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should remove this assert statement 🤔 We could replace it with a try-except.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you’re correct, but this is more of a validator that ensures vector.shape == (n_particles,), maybe we can do a LBYL style here? ( Let’s just remove asserts since assert statements can be skipped during runtime) 👍
This commit adds the `init_pos` argument in the Optimizer docstrings. Turns out that it's not documented in the high-level optimizers, so here we go. Related #251 Signed-off-by: Lester James V. Miranda <[email protected]>
This commit removes the assert statement when verifying if the resulting cost actually has the desired shape. Moreover, additional tests were created to test this validator. Signed-off-by: Lester James V. Miranda <[email protected]>
Just check this one first, @whzup , then we can push this to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked through it and it seems alright to me 👍 Just wondering if the Import from ...
comments are necessary 🤔
pyswarms/backend/topology/star.py
Outdated
# Update best_cost and position | ||
swarm.best_pos, swarm.best_cost = my_topology.compute_best_particle(my_swarm) | ||
# Update best_cost and position | ||
swarm.best_pos, swarm.best_cost = my_topology.compute_best_particle(my_swarm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does compute_best_particle
exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops. No it does not exist. Let me fix it
I'd like to continue with the Handlers first 😄 I think there is still quite some work to do especially with the tests etc. |
Replaces compute_best_particle with compute_gbest. Signed-off-by: Lester James V. Miranda <[email protected]>
Sure thing! I will check if I can handle the random seed 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one looks good! 👍 I reckon it's ready for merging 😄
Thanks a lot @whzup ! Sorry if I got a bit busy. Just started working this monday! haha |
Description
A large pull request that deals mainly with refactoring some parts of the codebase. Specifically:
Related Issues
#232, #240, #241
Motivation and Context
It is important that we make our code scalable, and has a consistent design before we add bigger features.
Types of changes
Checklist: