Skip to content
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

AsymptoticRing: pass log-function more systematically #27883

Closed
dkrenn opened this issue May 28, 2019 · 27 comments
Closed

AsymptoticRing: pass log-function more systematically #27883

dkrenn opened this issue May 28, 2019 · 27 comments

Comments

@dkrenn
Copy link
Contributor

dkrenn commented May 28, 2019

In #22154 (merged in a recent beta), a new log parameter was introduced. This was very specifically done for this parameter and does not allow any easy extensions. The aim of this ticket is to generalize this by using a general locals parameter. (In this sense it can be seen as a fixup for #22154.)

(Note that no deprecation for log is needed, as this was only merged in a recent beta and not yet in a stable release.)

CC: @behackl

Component: asymptotic expansions

Author: Daniel Krenn

Branch/Commit: 551b052

Reviewer: Benjamin Hackl

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

@dkrenn

This comment has been minimized.

@dkrenn
Copy link
Contributor Author

dkrenn commented May 28, 2019

Branch: u/dkrenn/asy-locals-for-log

@dkrenn
Copy link
Contributor Author

dkrenn commented May 28, 2019

Last 10 new commits:

627ba1cTrac #27837: update doctests
26e84ebTrac #27837: fixup docstrings
687fee5Trac #27837: fix all doctests in sage.rings.asymptotic
4ac605eTrac #27837: make variable names more consistent
9aad19cTrac #27837: fix some more doctests
b4ee24dTrac #27837: fixup doctest in sage.rings.big_oh
3cb6a45Trac #27883: class Locals
e4dfe01Trac #27883: class extension WithLocals
33c951dTrac #27883: introduce new locals parameter
41a9a65Trac #27883: use log also in generators

@dkrenn
Copy link
Contributor Author

dkrenn commented May 28, 2019

Commit: 41a9a65

@dkrenn
Copy link
Contributor Author

dkrenn commented May 28, 2019

Changed dependencies from #22154 to #22154, #27837

@dkrenn
Copy link
Contributor Author

dkrenn commented May 28, 2019

comment:4

Trivial dependency #27837 added.

@fchapoton
Copy link
Contributor

comment:5

You are using incompatible-with-python3 syntax, see patchbot report. As said on sage-devel, developers should rather switch now to python3-sage.

@dkrenn
Copy link
Contributor Author

dkrenn commented May 28, 2019

comment:6

Replying to @fchapoton:

You are using incompatible-with-python3 syntax, see patchbot report.

Without the parenthesis it doesn't work either

>>> di={1:2, 3:4}
>>> sorted(di.items(), key=lambda k,v: k)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: <lambda>() missing 1 required positional argument: 'v'

Not sure, how to nicely rewrite this (I am now using lambda e: e[0] which I find less nice but it works.)

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 28, 2019

Changed commit from 41a9a65 to fb8bcf5

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 28, 2019

Branch pushed to git repo; I updated commit sha1. New commits:

fb8bcf5Trac #27883: fix py3 (lambda)

@dkrenn
Copy link
Contributor Author

dkrenn commented May 28, 2019

comment:8

Replying to @fchapoton:

You are using incompatible-with-python3 syntax, see patchbot report. As said on sage-devel, developers should rather switch now to python3-sage.

Thank you for telling; I wasn't aware that this is not Py3. (FWIW, I have a Py3-Sage, but I see this ticket more like a fixup of a recent change, so still using my "old" Sage for this. But I will switch soon. ;) )

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 28, 2019

Branch pushed to git repo; I updated commit sha1. New commits:

9be0b63Trac #27883: remove unneccessary import (pyflakes)

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 28, 2019

Changed commit from fb8bcf5 to 9be0b63

@dkrenn
Copy link
Contributor Author

dkrenn commented May 29, 2019

comment:10

Replying to @dkrenn:

Replying to @fchapoton:

You are using incompatible-with-python3 syntax, see patchbot report.

Without the parenthesis it doesn't work either

>>> di={1:2, 3:4}
>>> sorted(di.items(), key=lambda k,v: k)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: <lambda>() missing 1 required positional argument: 'v'

Not sure, how to nicely rewrite this (I am now using lambda e: e[0] which I find less nice but it works.)

Ok, seems to be just this way according to
https://www.python.org/dev/peps/pep-3113/
They say I should rather use lambda k_v: k_v[0].

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 29, 2019

Changed commit from 9be0b63 to 551b052

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 29, 2019

Branch pushed to git repo; I updated commit sha1. New commits:

551b052Trac #27883: rename variable in lambda-fixup (PEP3113)

@dkrenn
Copy link
Contributor Author

dkrenn commented May 29, 2019

comment:12

Now patchbots seem to be happy :)

@behackl
Copy link
Member

behackl commented May 29, 2019

Reviewer: Benjamin Hackl

@behackl
Copy link
Member

behackl commented May 29, 2019

comment:13

I reviewed the changes and overall, I like this approach to make the module more flexible.

Personally, I would prefer if the log function in the AsymptoticRing still had a parameter to which an alternative log could be passed directly, instead of passing it inside a locals-dictionary; just as a convenience method. What do you think about that?

@dkrenn
Copy link
Contributor Author

dkrenn commented May 29, 2019

comment:14

Replying to @behackl:

Personally, I would prefer if the log function in the AsymptoticRing still had a parameter to which an alternative log could be passed directly, instead of passing it inside a locals-dictionary; just as a convenience method. What do you think about that?

I thought exactly about doing this. However, I decided not not use it, so that all these kind of parameter passing because:

  • When usually something is defined in SageMath globally, it should be overridden in a well defined manner and that's locals.
  • This scales to other (future) extensions.
  • By using locals (only), it is somehow self explanatory (when knowing what locals is), what it does, whereas I find a log parameter less obvious (although not too bad either).

Therefore, I removed the log parameter completely.

@behackl
Copy link
Member

behackl commented May 29, 2019

comment:15

Replying to @dkrenn:

Replying to @behackl:

Personally, I would prefer if the log function in the AsymptoticRing still had a parameter to which an alternative log could be passed directly, instead of passing it inside a locals-dictionary; just as a convenience method. What do you think about that?

I thought exactly about doing this. However, I decided not not use it, so that all these kind of parameter passing because:

  • When usually something is defined in SageMath globally, it should be overridden in a well defined manner and that's locals.
  • This scales to other (future) extensions.
  • By using locals (only), it is somehow self explanatory (when knowing what locals is), what it does, whereas I find a log parameter less obvious (although not too bad either).

Therefore, I removed the log parameter completely.

Alright. I see, and agree with your conclusion. (Besides, I would assume that if someone wants to use a custom log function, then they should set it globally for their entire AsymptoticRing anyways; adapting the log locally probably isn't really that common anyways.)

I want to do some further investigations regarding this ticket; I should be done soon.

@behackl
Copy link
Member

behackl commented Jun 3, 2019

comment:16

Of course, I forgot to set this to positive_review after I was done.

I reviewed the changes carefully, everything looks good to me and also the patchbot seems to be happy.

@fchapoton
Copy link
Contributor

Changed dependencies from #22154, #27837 to none

@dkrenn
Copy link
Contributor Author

dkrenn commented Jun 11, 2019

comment:18

Replying to @fchapoton:

Dependencies #22154, #27837 deleted

I am curious: Why were the (closed) dependencies deleted? Is there any advantage for doing this and should we do this on a regular basis? (However, I do not mind that it was done, just curious as said.) ;)

@fchapoton
Copy link
Contributor

comment:19

This may be blocking the merge by the release manager. Not sure, but just to be safe.

@dkrenn
Copy link
Contributor Author

dkrenn commented Jun 11, 2019

comment:20

Replying to @fchapoton:

This may be blocking the merge by the release manager. Not sure, but just to be safe.

I see; I think this is not an issue here, see https://groups.google.com/d/msg/sage-release/E4vp20O2FN0/Sk5IynzSAwAJ (it will be in rc1).

@vbraun
Copy link
Member

vbraun commented Jun 11, 2019

Changed branch from u/dkrenn/asy-locals-for-log to 551b052

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

No branches or pull requests

4 participants