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
modified 'get_numbered_constants' and test 9239, added another test #15504
modified 'get_numbered_constants' and test 9239, added another test #15504
Conversation
✅ Hi, I am the SymPy bot (v134). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.4. Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
@@ -395,6 +395,9 @@ def get_numbered_constants(eq, num=1, start=1, prefix='C'): | |||
raise ValueError("Expected Expr or iterable but got %s" % eq) | |||
|
|||
atom_set = set().union(*[i.free_symbols for i in eq]) | |||
func_set = set().union(*[i.atoms(Function) for i in eq]) | |||
if func_set: | |||
atom_set |= {Symbol(str(f.func)) for f in func_set} |
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's an example of where #15460 would apply: if all functions had a name attribute then this could be Symbol(f.name)
. But if no function has a name attribute (as is the case in this PR), then what you have done here makes sense and will work even if a non-Undefined functions happened to have a number in the name (like log2
).
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.
@smichr Yes that makes sense. But looking at the discussion in #15460 I don't think you or @asmeurer (or in this case, me too) agree to have all the functions return a name attribute. So introducing that change (Symbol(f.name)
) wouldn't be necessary unless we give all the functions a name
attribute.
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.
@avishrivastava11 can you state whether
- you did this work independently
or - you read someone else's code to come up with this fix.
Its not a big deal either way (and this is not an accusation---I'm just trying to keep and clean open record of our development).
If you did read someone else's code to come up with this fix, then perhaps I would prefer to cherry-pick a commit from elsewhere (and then rebase your tests on top of it).
@asmeurer please do not merge until we resolve this.
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.
@cbm755 I assure you, I'm completely against plagiarism. I did this independently (and actually have been on the receiving end of someone else using my ideas, so I know how it feels and how bad it is) and therefore appreciate your concern. And yes, whenever I use someone else's commits or work, I first pull their commits in the PR and then work on top of them and also give them credit for it (you can take a look at a few of my previous PRs)
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 did not mean to suggest anything inappropriate had happened; please accept my apologies if you felt threatened by my comments.
@asmeurer an equivalent change was done in Diofant (which Github has linked to my original bug report). We could've simply cherry-picked that change but no one did so. Instead, we have what I believe to be an independently written solution (based on a different variable name and a clear statement from the author).
I'm now +1 for this change after minor reformating.
The failing test in d04f808 commit is passing on my local system :
Can someone restart the failing test? |
Release notes should describe what is changed for the point of view of the end user (for example, " |
The changes themselves look good, though. |
t = Symbol('t') | ||
C3 = Symbol('C3') | ||
assert get_numbered_constants(Symbol('C1') * Function('C2')(t)) == C3 | ||
|
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 don't know why this file has so much empty space, but there should be only one or two blank lines between functions.
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've removed a few blank lines from the tests/test_ode.py
file. I've not gone about removing all the extra blank lines as that's not the purpose of this PR.
Can someone please restart the failing builds? (the tests should pass since there's been no change other than removal of a few blank lines) |
sympy/solvers/tests/test_ode.py
Outdated
dsolve) | ||
classify_ode, classify_sysode, constant_renumber, constantsimp, | ||
homogeneous_order, infinitesimals, checkinfsol, checksysodesol, solve_ics, | ||
dsolve, get_numbered_constants) |
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.
now these lines look too long to me, past column 80? Maybe just leave the local formatting alone?
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, I should've seen that. PyCharm actually does some addition of lines and spaces while automatically adding a needed import. Removing them now.
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.
Done. Please take a look
I restarted the job and I edited your release notes; please double-check |
Again, one of the tests fail, although works perfectly on my local system.
Please, someone restart the failing job. |
The job will fail until #15523 is merged. |
sympy/solvers/tests/test_ode.py
Outdated
homogeneous_order, infinitesimals, checkinfsol, checksysodesol, solve_ics, | ||
dsolve) | ||
classify_ode, classify_sysode, constant_renumber, constantsimp, homogeneous_order, | ||
infinitesimals, checkinfsol, checksysodesol, solve_ics, dsolve, get_numbered_constants) |
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.
sorry but these lines are still too long
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.
Done.
@asmeurer Should the changes be merged now? |
modified 'get_numbered_constants' and test_C1_function_9239
added another test
Fixes #15056
Earlier
gave
Symbol('C2')
which is technically ok but could lead to confusion (seetest_C1_function_9239
in themaster branch
; it's been updated in this PR).It's been corrected now and it returns
Symbol('C3')
Release Notes
get_numbered_constants
indsolve
now considers functions, in case you have a function named, for example,C1(t)
.