-
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
Implement assertions() in search methods #27
Comments
Hi! |
Hi @jazcap53, awesome! Just leave a message here if you're stuck or need some help! 👍 |
Hi @ljvmiranda921, Will do! Thanks.
…On Sat, Sep 16, 2017 at 8:03 AM, Lj Miranda ***@***.***> wrote:
Hi @jazcap53 <https://github.com/jazcap53>, awesome! Just leave a message
here if you're stuck or need some help! 👍
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#27 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABYrl7aTHEOvQwZuE07-azXwyRtrqisoks5si7kegaJpZM4PYkSy>
.
|
@ljvmiranda921 Making good progress on #27. Just had to overcome a little nervousness :-) |
Awesome! Thanks a lot!
Nerves are also good! If you encounter any problem, question, or stuck on
something, just leave a comment here and I'd be glad to help. 👍
On Sun, 17 Sep 2017 at 7:23 AM Andrew Jarcho ***@***.***> wrote:
@ljvmiranda921 <https://github.com/ljvmiranda921> Making good progress on
#27 <#27>. Just had to
overcome a little nervousness :-)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#27 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMWYs6e0ya6JGokl51EKBHG6utWMsy4_ks5sjEpggaJpZM4PYkSy>
.
--
Lester James V. Miranda
BS Electronics and Communications Engineering,
Minor in Philosophy (Class of 2016)
Ateneo de Manila University
lester.miranda@ <lester.miranda@obf.ateneo.edu>*o
<http://toki.waseda.jp>bf.ateneo.edu <http://bf.ateneo.edu>*
|
Hi @ljvmiranda921
|
Hi @jazcap53!
Yes you are correct! It should check if
Yes you are correct. Since it inherits everything from
Hmmm...not sure if asserting a certain range will limit the implementation. The previous conversation about this would be to implement a Thanks a lot and I hope you're having fun! |
Oops! I missed that. I put in some unnecessary checks which I'll remove. I'll do the type check on n_selection_iters. Yes, this is fun! I'm learning... |
@ljvmiranda921 Hi! I have two related questions:
|
Hi @jazcap53! regarding your questions, For Question 1Just add another class, # Inside tests/utils/search/test_randomsearch.py
class Base(unittest.TestCase):
def setUp(self):
"""Set-up test fixtures"""
# If you want to add test fixtures here, feel
# free to add new lines of code. Don't include
# the pass
pass
class Instantiation(Base):
def test_something_about_instantiation(self):
"""Tests something about instantiation"""
# Don't include the pass
pass For Question 2Hmmmm, normally when I run tests, I go to the top-most level of the package where I can see both the $ python -m unittest discover This is the same command that is implemented when we're doing the checks in travis-ci. The If you want to run a specific test, say, $ python -m unittest tests.utils.search.test_gridsearch Hope it helps and good luck!! 😄 |
@ljvmiranda921 Thanks very much! |
Hi @ljvmiranda921, The new code adds no new Errors or Warnings to the output of flake8, passes I haven't yet done the "Go the Extra Mile?" part; will work on that tomorrow. Also, I'm new to Travis CI, so until I read up on that, Part 3 of the Pull Request Guidelines remains unfulfilled. I appreciate your patience in helping me, and of course am open to any suggestions you may have. |
Awesome @jazcap53! Many things happened recently, I got quite busy, but I will check your fork this weekend! 👍 Maybe some minor comment: It would be nice if you can Thank you so much for your effort and time as well! |
Check that optimizer member in SearchBase has an optimize attribute. Check type of n_selection_iters member in RandomSearch. Add self.assertions() line to __init__() in each of Searchbase, GridSearch, and RandomSearch. Add call to super().assertions() in RandomSearch. Author: jazcap53 Email: andrew.jarcho@gmail.com
Hi @jazcap53, how's it going? I'm wondering how's your progress on this. If you have any problems or stuck, feel free to comment :) |
Hi @ljvmiranda921,
I was working on this but got distracted. What I came up with so far was
not useful or correct -- I'll have questions for you by tomorrow.
Thank you for contacting me; I really want to move forward on this
immediately. 👍
…On Thu, Sep 28, 2017 at 3:58 PM, Lj Miranda ***@***.***> wrote:
Hi @jazcap53 <https://github.com/jazcap53>, how's it going? I'm wondering
how's your progress on this. If you have any problems or stuck, feel free
to comment :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#27 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABYrl-b19xszCi-yUWoGLct9yqU9WBoUks5sm_pegaJpZM4PYkSy>
.
|
Sure sure! No pressure, I was just concerned if you are still interested on working in it. Thanks a lot Andrew @jazcap53! Hope you're fine and well! |
Very interested and I'm glad no-one has taken it over due to my inactivity.
Looking forward to tackling this! :-)
…On Thu, Sep 28, 2017 at 4:09 PM, Lj Miranda ***@***.***> wrote:
Sure sure! No pressure, I was just concerned if you are still interested
on working in it. Thanks a lot Andrew @jazcap53
<https://github.com/jazcap53>! Hope you're fine and well!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#27 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABYrlz3xPxbntsILz0BYYRBcmB_gaLcrks5sm_zegaJpZM4PYkSy>
.
|
Hi @ljvmiranda921! I've got a question and a comment. The question: For example if I put a I think the answer to that question is "no". If I'm wrong, please let me know. The comment: I think I'm getting a handle on this and will proceed. 😄 My apologies for the delay. |
Hmm! Am looking at the use-cases in your doc to try and answer my own question. |
Nope. I've still got questions.
|
Hey Andrew,
Sorry I cannot reply properly, currently on a trip until Tuesday so don't
have a laptop and reliable internet connection.
1. Yes for the #1 you are correct. No need perhaps of testing the inputs
for the optimizer. Hmmm what do you think is a more efficient design though?
2. Hmmm, normally what we do is put the class instantiations in the
setUp(). So we have a self.my_object, but the arguments can be specified
individually in the test methods. Usually for unit testing I'm not really
that particular to the cost. Hmmm, honestly I'm still starting out to learn
testing patterns so I'm not yet sure of a more efficient design.
Thank you so much for your questions! It's very nice that I am learning new
things as well. :D really happy to have you contributing!
On Sun, 1 Oct 2017 at 8:55 AM Lj Miranda <lester.miranda@obf.ateneo.edu>
wrote:
Hey Andrew,
On Sun, 1 Oct 2017 at 4:00 AM Andrew Jarcho ***@***.***>
wrote:
> Nope. I've still got questions.
>
> 1. It looks like the Instantiation subclass in test_randomsearch.py
> only needs to test the types of optimizer and n_selection_iters. The
> Instantiation subclass in test_gridsearch.py only needs to test the
> type of optimizer. Is this correct?
> 2. To check the type assertions I made in class RandomSearch, I need
> to create instances of RandomSearch. I chose to create the instances
> within the tests themselves, instead of in the setUp() function. That
> way the test runner will not have to pay the cost of the instantiations
> with every test in the file. Is that a correct approach (it looks ugly) ?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#27 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AMWYszkhB57hmvNp_De2JU32QwP-pWqRks5sno-9gaJpZM4PYkSy>
> .
>
--
Lester James V. Miranda
BS Electronics and Communications Engineering,
Minor in Philosophy (Class of 2016)
Ateneo de Manila University
lester.miranda@ <lester.miranda@obf.ateneo.edu>*o
<http://toki.waseda.jp>bf.ateneo.edu <http://bf.ateneo.edu>*
|
Hey Lester,
Thanks for your reply -- it's much appreciated.
My knowledge and understanding around testing is limited; but I'll think
hard about these issues between now and Tuesday.
Have a safe and pleasant trip!
On Sat, Sep 30, 2017 at 8:07 PM, Lj Miranda <notifications@github.com>
wrote:
… Hey Andrew,
Sorry I cannot reply properly, currently on a trip until Tuesday so don't
have a laptop and reliable internet connection.
1. Yes for the #1 you are correct. No need perhaps of testing the inputs
for the optimizer. Hmmm what do you think is a more efficient design
though?
2. Hmmm, normally what we do is put the class instantiations in the
setUp(). So we have a self.my_object, but the arguments can be specified
individually in the test methods. Usually for unit testing I'm not really
that particular to the cost. Hmmm, honestly I'm still starting out to learn
testing patterns so I'm not yet sure of a more efficient design.
Thank you so much for your questions! It's very nice that I am learning new
things as well. :D really happy to have you contributing!
On Sun, 1 Oct 2017 at 8:55 AM Lj Miranda ***@***.***>
wrote:
> Hey Andrew,
>
> On Sun, 1 Oct 2017 at 4:00 AM Andrew Jarcho ***@***.***>
> wrote:
>
>> Nope. I've still got questions.
>>
>> 1. It looks like the Instantiation subclass in test_randomsearch.py
>> only needs to test the types of optimizer and n_selection_iters. The
>> Instantiation subclass in test_gridsearch.py only needs to test the
>> type of optimizer. Is this correct?
>> 2. To check the type assertions I made in class RandomSearch, I need
>> to create instances of RandomSearch. I chose to create the instances
>> within the tests themselves, instead of in the setUp() function. That
>> way the test runner will not have to pay the cost of the instantiations
>> with every test in the file. Is that a correct approach (it looks ugly)
?
>>
>> —
>> You are receiving this because you were mentioned.
>> Reply to this email directly, view it on GitHub
>> <https://github.com/ljvmiranda921/pyswarms/issues/
27#issuecomment-333328932>,
>> or mute the thread
>> <https://github.com/notifications/unsubscribe-auth/AMWYszkhB57hmvNp_
De2JU32QwP-pWqRks5sno-9gaJpZM4PYkSy>
>> .
>>
> --
Lester James V. Miranda
BS Electronics and Communications Engineering,
Minor in Philosophy (Class of 2016)
Ateneo de Manila University
lester.miranda@ ***@***.***>*o
<http://toki.waseda.jp>bf.ateneo.edu <http://bf.ateneo.edu>*
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#27 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABYrl-yielLdmIR2CIrzc8BvXRChDp-jks5sntfZgaJpZM4PYkSy>
.
|
Hi Andrew @jazcap53, I am back already, hopefully I can reply to your messages quickly. Just ping me if you have any questions/concerns! 👍 |
Hi Lester @ljvmiranda921, I've been thinking about testing the instantiations for
It looks to me like that may not work here. In file My instantiation tests also work by checking for exceptions raised on object creation. So my Since we're expecting the object creations to fail, we can't put them in the Does this seem right to you? Having a lot of fun here! 👍 |
Hi Andrew @jazcap53 ! I see, I think what you said is correct. Thank you for catching my mistake. I guess your design is all good, it would be much better then to have the objects be created in the tests themselves. I tried out the search utilities earlier and I figured that your design is the way to go. Awesome! Thank you so much! 💯 |
Hi Lester @ljvmiranda921 , Great! I'll finish up and check my work tomorrow morning! |
Great! I'm looking forward to it! Take care and have a good rest! 👍 |
Hi @ljvmiranda921 ! |
Hi @jazcap53 , Let me check that one first. Sometimes travis makes a build error randomly and it's weird. I'll get back to you! 😄 |
It's working now, I just clicked the Restart Build button 👍 |
Tests that a bad type for the optimizer parameter to GridSearch() raises a TypeError. Tests that a bad type for the optimizer parameter or the n_selection_iters parameter to RandomSearch() raises a TypeError. Author: jazcap53 Email: andrew.jarcho@gmail.com
Hey @jazcap53, I have merged your PR already. Thank you so much for your contribution! It was really nice working with you. Just drop-by anytime you wish to contribute. Take care and have a nice day! 💯 👍 |
Thank you @ljvmiranda921 !
This was fun! 👍
…On Tue, Oct 3, 2017 at 6:28 PM, Lj Miranda ***@***.***> wrote:
Closed #27 <#27>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#27 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABYrl73foHoXDyvyGqMrEKxOUL6vBxrdks5sorUCgaJpZM4PYkSy>
.
|
Thanks to @SioKCronin , we're now able to implement hyperparameter search tools such as
GridSearch
andRandomSearch
. These are awesome implementations, but we can maximize its robustness by adding anassertions()
method in our classes. Would you like to try?What you'll do
Simply put, you will just add an
assertions()
method in theSearchBase
class. This should contain variouschecks when instantiating any class that inherits from it. You can check the docstrings for each class and create a proper method call for it.
If you want to check previous implementations, see the
SwarmBase.assertions
method, and check how it is being implemented inGlobalBestPSO
(it is not called explicitly because it just inherits from the base) or inLocalBestPSO
(additional lines of code were added after calling thesuper()
because of extra attributes).Go the extra mile?
If you want to go the extra mile, you can add tests to check for edge cases and see if your assertions are working when passed with an invalid input (maybe an invalid type, out-of-bounds, etc.). For this, you just need to add an
Instantiation
class in thetest.utils.search.test_gridsearch
andtest.utils.search.test_randomsearch
modules.Again, if you want a template, you can check the
Instantiation
classes intest.optimizers.test_global_best
and others. Notice how we try to feed the class with invalid arguments/edge cases and have the unit test capture them. It's a very fun activity!If you wish to take this on, then feel free to drop a comment here! I'd be glad to help you!
Update: 9/17/2017
Follow the instructions in this quick-start guide to get you started!
Commit Guidelines
I'd appreciate if we lessen the number of commits per issue to 1-2. Of course you can commit often, but before merging, I would ask you to rebase them depending on the changes you've done. A commit format that we follow is shown below:
The text was updated successfully, but these errors were encountered: