-
Notifications
You must be signed in to change notification settings - Fork 91
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
[enhancement]evaluating more than 1 condition fixes #277 #279
Conversation
@dirk-thomas , can you please review the changes. |
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.
Please also add unit tests for the newly supported cases as well as make sure that all tests pass.
I will make the recommended changes.
Regarding that, |
I don't think such a limitation exists. Please re-read the error message from the CI build (trailing whitespace) and commit a fix for it to the branch of your PR.
You can easily clone your forked repo, switch to the branch of this PR, and apply any kind of change necessary - if need be even a squash of commit (which I highly doubt is necessary).
The PR will not be merged until it passes CI. Please address the above comments and CI will pass. |
@dirk-thomas , you were correct.
Thanks for pointing it out. |
Still pending. |
@dirk-thomas , the unit tests have been implemented. I have run the code numerous times taking into account many edge cases, the results were as desired. Also, I have taken into account precedence order in logical |
@dirk-thomas, Gentle Reminder 😄 |
@dirk-thomas Gentle Reminder 😄 |
@dirk-thomas, can you please review the code. It's been almost a week. |
@nepython I will review the pull request as soon as I find time for it. Poking me four times won't generate more time on my side unfortunately. |
I took another look at the patch and the logic with this loop and additional recursion doesn't make any sense to me. The function already does check for the logical operators It should be completely sufficient to reduce this patch to two simple changes:
|
@dirk-thomas, thank you for the review 😃
I had implemented these to account for short-circuiting which is quite useful when evaluating logical expressions.
Note:Above, condition refers to a list containing three arguements like If you don't find them useful, please comment it and I will make the changes as per your suggestion. Though, after applying your second suggested change(which I assume makes the loop go on until all conditions have been evaluated or some condition evaluates to |
What do you mean with this? Why is it being useful? Please try to be more detailed / precise in your comment.
My suggestion is for the while diff to be reduced to my previous comment. There shouldn't be any need for a loop in the first place. |
@dirk-thomas, thanks for the quick response
I think I have mentioned it in the code snippet #279 (comment) next to every line how it is helping in the short circuiting by stopping evaluation of further conditions in cases when we know that at the end result would be
Is your suggestion to implement something like:-
|
No, my suggestion is literally in the above comment: #279 (comment) The code snippets in that comment are the complete diff I think is needed. |
@dirk-thomas, I do get what you mean but can you please consider edge cases such as one below:- Also, short-circuiting will help reduce the total recursion calls as it would simply return a value as I have explained above and not evalute all the conditions and then take decision, should definitely help. Rest is your call, I can definitely make those changes just thought that few cases as the one I have mentioned above were amiss. |
Then please add a unit test for that edge case ensuring that it does return the expected result. |
Sure, does everything else in #279 (comment) seems fine? I will squash all my commits and send one with these lines them finally. |
No, as mentioned multiple time I don't see a reason to duplicate all this logic. If you really want to limit recursion then please do so in a separate PR. This one is to support multiple conditions. |
@nepython Friendly ping. |
9bb84b7
to
116a3a0
Compare
@dirk-thomas, extremely sorry got a little busy. I have sent the patch as per your suggestions in comment. Please have a look. Shall I open another PR for limiting the number of recursions, this will help if there happen to be many conditions involved. :) |
The recursion limit is 3000 (at least in Python 3.8) which should be plenty and I don't expect we ever have the case of that many conditions. But I will leave that up to you to decide - if you think it is valuable please open a new PR once this one has been merged. |
@dirk-thomas, I think this is finally done on my side. Not sure why is Travis not running at all, might be down for maintenance. I have locally run
I think then there is no need for it then. |
…ed for results with more than three items
You might want to check https://www.traviscistatus.com/ for that information rather than just guessing. Anyway I committed to tiny changes (see ae9fff5 and 657e0ec) and Travis is processing the latest commit now. |
Thanks for the improvement and for iterating on the ticket. |
This is a improvement which fixes issue #277(A feature request to be able to apply more than 1 condition in a go).