Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bug in ExpressionNice with composite variables #33399

Closed
egourgoulhon opened this issue Feb 22, 2022 · 13 comments
Closed

Bug in ExpressionNice with composite variables #33399

egourgoulhon opened this issue Feb 22, 2022 · 13 comments

Comments

@egourgoulhon
Copy link
Member

In Sage 9.6.beta2, we have

sage: from sage.manifolds.utilities import ExpressionNice
sage: u, v = var('u v')
sage: f = function('F')(u + v)
sage: f
F(u + v)
sage: ExpressionNice(diff(f, u))
d(F)/d(u + v)

So far, so good, but

sage: f = function('F')(u - v)
sage: ExpressionNice(diff(f, u))
d(F)/du - v

This bug has been reported in https://groups.google.com/g/sage-support/c/fbE0APqThEk

With the fix introduced in this ticket, the last output is now

d(F)/d(u - v)

CC: @tscrim

Component: manifolds

Author: Eric Gourgoulhon

Branch/Commit: 9b9b65b

Reviewer: Matthias Koeppe

Issue created by migration from https://trac.sagemath.org/ticket/33399

@egourgoulhon
Copy link
Member Author

@egourgoulhon
Copy link
Member Author

Commit: 70729d9

@egourgoulhon
Copy link
Member Author

New commits:

70729d9Fix bug in ExpressionNice (#33399)

@egourgoulhon

This comment has been minimized.

@egourgoulhon egourgoulhon changed the title Bug in ExpressionNIce with composite variables Bug in ExpressionNice with composite variables Feb 22, 2022
@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 23, 2022

Reviewer: Matthias Koeppe

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 23, 2022

Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. New commits:

9b9b65bRemove import re from ExpressionNice (#33399)

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 23, 2022

Changed commit from 70729d9 to 9b9b65b

@egourgoulhon
Copy link
Member Author

comment:6

Thank you for the review. Here is a new version, which avoids import re.

@egourgoulhon
Copy link
Member Author

comment:7

What do you think about the new version? Sorry for having pushed it after your positive review, but I thought this rewriting was better than the quick fix I first submitted, especially because it relies on standard Python, without the need of importing the re module.

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 28, 2022

comment:8

This version is also fine. Note though that re is part of the Python standard library.

@egourgoulhon
Copy link
Member Author

comment:9

Replying to @mkoeppe:

This version is also fine.

Thank you!

Note though that re is part of the Python standard library.

You are right; I should have said basic Python, instead of standard Python. My concern was actually the CPU performance: it's always better to avoid an import, isn't it? (unless of course the function you import does the job more efficiently).

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 28, 2022

comment:10

This module is already widely used by pretty much everything, so it's likely to be already loaded. And it's likely to be faster than doing the loop over the characters in the new version. But I don't think it matters.

@vbraun
Copy link
Member

vbraun commented Mar 1, 2022

Changed branch from public/manifolds/expression_nice-33399 to 9b9b65b

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants