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

Clean up MPolynomialRing_generic.completion #23377

Closed
jdemeyer opened this issue Jul 6, 2017 · 19 comments
Closed

Clean up MPolynomialRing_generic.completion #23377

jdemeyer opened this issue Jul 6, 2017 · 19 comments

Comments

@jdemeyer
Copy link
Contributor

jdemeyer commented Jul 6, 2017

In src/sage/rings/polynomial/multi_polynomial_ring_generic.pyx, the method completion() constructs a PowerSeriesRing either from variable names or from an polynomial ring element. The latter must be changed for #10483. Moreover, the error checking also needs to be improved.

CC: @tscrim

Component: algebra

Author: Jeroen Demeyer

Branch/Commit: 52e13d8

Reviewer: Travis Scrimshaw

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

@jdemeyer jdemeyer added this to the sage-8.0 milestone Jul 6, 2017
@jdemeyer
Copy link
Contributor Author

jdemeyer commented Jul 6, 2017

Author: Jeroen Demeyer

@jdemeyer
Copy link
Contributor Author

jdemeyer commented Jul 6, 2017

@jdemeyer
Copy link
Contributor Author

jdemeyer commented Jul 6, 2017

Commit: 8108128

@jdemeyer
Copy link
Contributor Author

jdemeyer commented Jul 6, 2017

New commits:

8108128Clean up MPolynomialRing_generic.completion

@tscrim
Copy link
Collaborator

tscrim commented Jul 6, 2017

comment:4

The doc for completion is no longer correct (it mentions p). Also, do we want to support R.completion('x,y')?

@jdemeyer
Copy link
Contributor Author

comment:6

Replying to @tscrim:

Also, do we want to support R.completion('x,y')?

Not sure. So far, there doesn't seem to be a need.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 18, 2017

Changed commit from 8108128 to 7cfb4af

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 18, 2017

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

92bafe2Merge tag '8.1.beta2' into t/23377/clean_up_mpolynomialring_generic_completion
7cfb4afFix doc of completion()

@tscrim
Copy link
Collaborator

tscrim commented Aug 18, 2017

comment:9

Replying to @jdemeyer:

Replying to @tscrim:

Also, do we want to support R.completion('x,y')?

Not sure. So far, there doesn't seem to be a need.

I ask because it feels like we should pass names off to normalize_names, which will then support that semantic. Is there a reason why you are not using that?

Also, could we add the @rename_keyword(deprecation=23377, p='names') in order to avoid backwards incompatible changes (just in case someone in the wild is explicitly doing R.completion(p='x'))?

@jdemeyer
Copy link
Contributor Author

comment:10

Replying to @tscrim:

just in case someone in the wild is explicitly doing R.completion(p='x'))?

Python should really invent syntax for positional-only arguments. They have keyword-only arguments now in Python 3, but why not positional-only arguments? My favourite consequence:

sage: R.<self,other> = QQ[[]]
sage: a = R.random_element(); a
-3/4*self^4 + 12*self^5*other - 3/2*self^4*other^3 + self^3*other^7 + 1/2*self^6*other^5 + O(self, other)^12
sage: a(self=1)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-6b78fae4891c> in <module>()
----> 1 a(self=Integer(1))

TypeError: __call__() got multiple values for keyword argument 'self'

Anyway... I'll add the deprecation since you asked.

@tscrim
Copy link
Collaborator

tscrim commented Aug 19, 2017

comment:11

Python does have a way for positional only arguments. You just have to do foo(self, *args, **kwds) and manually handle keywords. However, that is indeed a fun examples.

@jdemeyer
Copy link
Contributor Author

comment:12

Replying to @tscrim:

Python does have a way for positional only arguments. You just have to do foo(self, *args, **kwds) and manually handle keywords.

Yes, that works but it's not a very satisfactory solution...

@jdemeyer
Copy link
Contributor Author

comment:13

Replying to @tscrim:

I ask because it feels like we should pass names off to normalize_names

There is a different here for names than the PolynomialRing constructor for example: the names are not arbitrary names, they refer to an element of self. The fact that we actually allow to give an element, not just a string, is another example of that.

I would argue that giving an element is actually recommend, because it makes sense mathematically: you have a ring and you are completing it w.r.t. a given element from that ring.

For me, the main reason to allow strings is to allow the C.<...> = R.completion() syntax.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 23, 2017

Changed commit from 7cfb4af to 52e13d8

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 23, 2017

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

52e13d8Add deprecation for completion(p=...)

@tscrim
Copy link
Collaborator

tscrim commented Aug 23, 2017

comment:16

Replying to @jdemeyer:

Replying to @tscrim:

Python does have a way for positional only arguments. You just have to do foo(self, *args, **kwds) and manually handle keywords.

Yes, that works but it's not a very satisfactory solution...

I agree completely, but its the constraints we must live in. :/

@tscrim
Copy link
Collaborator

tscrim commented Aug 23, 2017

Reviewer: Travis Scrimshaw

@tscrim
Copy link
Collaborator

tscrim commented Aug 23, 2017

comment:17

Replying to @jdemeyer:

Replying to @tscrim:

I ask because it feels like we should pass names off to normalize_names

There is a different here for names than the PolynomialRing constructor for example: the names are not arbitrary names, they refer to an element of self. The fact that we actually allow to give an element, not just a string, is another example of that.

I would argue that giving an element is actually recommend, because it makes sense mathematically: you have a ring and you are completing it w.r.t. a given element from that ring.

For me, the main reason to allow strings is to allow the C.<...> = R.completion() syntax.

Ah, I see. LGTM. Thanks.

@vbraun
Copy link
Member

vbraun commented Aug 29, 2017

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

3 participants