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

subrings of the symbolic ring #19259

Closed
dkrenn opened this issue Sep 20, 2015 · 32 comments
Closed

subrings of the symbolic ring #19259

dkrenn opened this issue Sep 20, 2015 · 32 comments

Comments

@dkrenn
Copy link
Contributor

dkrenn commented Sep 20, 2015

We create subrings of the symbolic ring, which allow or reject a given set of variables.

CC: @behackl @cheuberg

Component: symbolics

Author: Daniel Krenn

Branch/Commit: d376b10

Reviewer: Benjamin Hackl

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

@dkrenn dkrenn added this to the sage-6.9 milestone Sep 20, 2015
@dkrenn
Copy link
Contributor Author

dkrenn commented Sep 20, 2015

Branch: u/dkrenn/symbolic-subring

@rwst
Copy link

rwst commented Sep 21, 2015

comment:2

The (unregistered, yours?) patchbot seems to have problems, but probably not with this branch. I'm in favor of this enhancement as it allows some solutions to other tickets.


Last 10 new commits:

4b8f9bewrite workaround for #19231
8696a6eextend `_coerce_map_from_` in rejecting-subring
30f7058write doctests for coercions, common_parent, pushout
a54b4afminor docstring rewriting of factory
fb2885csubring in index.rst
eab9513simplify a doctest
23352b2change ValueError to TypeError to make everything work with SR as it should
2d8b7c4typo in docstring
15ec40edocstring of SR.subring
7938d95module description of subring

@rwst
Copy link

rwst commented Sep 21, 2015

Commit: 7938d95

@dkrenn
Copy link
Contributor Author

dkrenn commented Sep 21, 2015

comment:3

Replying to @rwst:

The (unregistered, yours?) patchbot seems to have problems, but probably not with this branch.

Yes, it is my patchbot. I think something related to the upgrade to beta7 ...

I'm in favor of this enhancement as it allows some solutions to other tickets.

Good :)

(Which tickets are these?)

@rwst
Copy link

rwst commented Sep 21, 2015

comment:4

Replying to @dkrenn:

Replying to @rwst:

I'm in favor of this enhancement as it allows some solutions to other tickets.

Good :)

(Which tickets are these?)

See comment 57 of #12967 by vbraun: "The symbolic constants, like pi.pyobject(), should be elements in some parent set. The symbolic constants can then coerce into the infinity ring, solving the pi.pyobject() < oo == False issue."

Consequently this would be good for #19040.

@novoselt
Copy link
Member

comment:6

This is fantastic! Don't plan to review it as I am not an expert on coersion stuff, but looks very good. I am only not quite sure that only_constants deserves to be a parameter: it can be implemented by accepting no variables and if SR.subring(accepting_variables=()) looks bad and non-obvious, than perhaps there should be a shortcut for it SR.subring_of_constants()?

@dkrenn
Copy link
Contributor Author

dkrenn commented Sep 22, 2015

comment:7

Replying to @novoselt:

This is fantastic!

Good to hear :)

Don't plan to review it as I am not an expert on coersion stuff, but looks very good.

You could review the non-coercion part ;)

I am only not quite sure that only_constants deserves to be a parameter: it can be implemented by accepting no variables and if SR.subring(accepting_variables=()) looks bad and non-obvious, than perhaps there should be a shortcut for it SR.subring_of_constants()?

My feeling is that some kind of shortcut to this special ring is convenient to have (and it is also good to mention this subring explicitly somewhere). Thus, +1 that there is some kind of explicit way to create the subring of symbolic constants.
However, I am open on how this should be achieved. My indention was having one method subring which can create all kind of subrings (cf. Unix philosophy: Do One Thing and Do It Well).

@rwst
Copy link

rwst commented Sep 22, 2015

comment:8

Ah, with constant you mean no symbols (maybe better clarify). Yeah I make that distinction in #19040 often enough so it seems very natural.

@dkrenn
Copy link
Contributor Author

dkrenn commented Sep 22, 2015

comment:9

Replying to @rwst:

Ah, with constant you mean no symbols (maybe better clarify). Yeah I make that distinction in #19040 often enough so it seems very natural.

Keyword only_constants --> no_symbols ? (And maybe all occurrences of variable --> symbol? What is the best terminology?)

@rwst
Copy link

rwst commented Sep 22, 2015

comment:10

Replying to @dkrenn:

Replying to @rwst:

Ah, with constant you mean no symbols (maybe better clarify). Yeah I make that distinction in #19040 often enough so it seems very natural.

Keyword only_constants --> no_symbols ?

Or no_variables.

(And maybe all occurrences of variable --> symbol?

Not necessary IMO.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 22, 2015

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

852959arename only_constants --> no_variables

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 22, 2015

Changed commit from 7938d95 to 852959a

@dkrenn
Copy link
Contributor Author

dkrenn commented Sep 22, 2015

comment:12

Replying to @rwst:

Keyword only_constants --> no_symbols ?

Or no_variables.

Fits good; renamed.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 19, 2015

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

e4837e9correct parent of result of an_element

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 19, 2015

Changed commit from 852959a to e4837e9

@dkrenn
Copy link
Contributor Author

dkrenn commented Oct 19, 2015

comment:14

Replying to @sagetrac-git:

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

e4837e9correct parent of result of an_element

Small commit to correct the parent. Needs_review.

@behackl
Copy link
Member

behackl commented Jan 22, 2016

comment:15

Hello! I started reviewing this ticket, and for now, I have the following comments:

  • is_variable_valid --> has_valid_variable or allows_variable? This would be a semantic improvement as the current version does not really fit to the other parent.is_*-methods, IMHO.
  • While it is OK that the subring factory checks that every element in the vars-tuple can be thrown into SR in SymbolicSubringFactory.create_key_and_extra_args, the elements are not checked for being valid identifiers. I'd suggest to do so either in the factory, or directly in GenericSymbolicSubring.__init__. Otherwise, this is possible:
sage: SR.subring(accepting_variables=(0, pi, sqrt(2), I))
Symbolic Subring accepting the variables 0, I, pi, sqrt(2)

I also have some minor changes (language etc.) which I will push as soon as I am done with my review.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 23, 2016

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

ff99c7fTrac #19259: change to has_valid_variable
581f315Trac #19259: check validity of variables

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 23, 2016

Changed commit from e4837e9 to 581f315

@dkrenn
Copy link
Contributor Author

dkrenn commented Jan 23, 2016

comment:17

Replying to @behackl:

Hello! I started reviewing this ticket, and for now, I have the following comments:

  • is_variable_valid --> has_valid_variable or allows_variable? This would be a semantic improvement as the current version does not really fit to the other parent.is_*-methods, IMHO.

I agree; changed.

  • While it is OK that the subring factory checks that every element in the vars-tuple can be thrown into SR in SymbolicSubringFactory.create_key_and_extra_args, the elements are not checked for being valid identifiers. I'd suggest to do so either in the factory, or directly in GenericSymbolicSubring.__init__.

Added check.

Otherwise, this is possible:

sage: SR.subring(accepting_variables=(0, pi, sqrt(2), I))
Symbolic Subring accepting the variables 0, I, pi, sqrt(2)

Doctest added.

@behackl
Copy link
Member

behackl commented Jan 23, 2016

Changed commit from 581f315 to c4a0e22

@behackl
Copy link
Member

behackl commented Jan 23, 2016

comment:18

Thanks, this resolves these two issues.

Besides some minor changes to the code and documentation, I noticed that the merge methods for the functors were doing the wrong thing:

  • merging two accepting functors should give an accepting functor with the intersection of the variables,
  • merging two rejecting functors should give a rejecting functor with the union of the variables,
  • when merging a rejecting and an accepting functor, the result has to to be an accepting functor with all accepted variables, but without the rejected ones.

I adapted the code accordingly.

In principle, this would be a positive_review from my side, however, I'd like to rewrite your code some more such that subrings of subrings can be constructed as well. The easiest way to do so (probably), is to let the functors do everything.


Last 10 new commits:

7938d95module description of subring
852959arename only_constants --> no_variables
e4837e9correct parent of result of an_element
ff99c7fTrac #19259: change to has_valid_variable
581f315Trac #19259: check validity of variables
c9b2428improve language
05dc834misc. changes, indentation, line breaks
8cc884afix merge of functors
aeae8f3Merge tag '7.0' into symbolics/symbolic-subring
c4a0e22merge accepting and rejecting functors in all cases

@behackl
Copy link
Member

behackl commented Jan 23, 2016

@cheuberg
Copy link
Contributor

comment:19

Replying to @behackl:

In principle, this would be a positive_review from my side, however, I'd like to rewrite your code some more such that subrings of subrings can be constructed as well. The easiest way to do so (probably), is to let the functors do everything.

The question is whether to postpone the rewriting to a follow-up ticket (i.e., does your planned rewriting affect the interface or is it just internal rewriting which will then allow new things to be done?) This also in view of several tickets depending on this ticket here.

@dkrenn
Copy link
Contributor Author

dkrenn commented Jan 23, 2016

comment:20

Replying to @behackl:

Besides some minor changes to the code and documentation,

Cross-review of the minor things positive, but ...

I noticed that the merge methods for the functors were doing the wrong thing:

  • merging two accepting functors should give an accepting functor with the intersection of the variables,
  • merging two rejecting functors should give a rejecting functor with the union of the variables,
  • when merging a rejecting and an accepting functor, the result has to to be an accepting functor with all accepted variables, but without the rejected ones.

No, merge is correct. Composition means creating a larger subring, which contains both the corresonding rings (it is used in pushout).
So please git revert

8cc884a fix merge of functors

and

c4a0e22 merge accepting and rejecting functors in all cases

@dkrenn
Copy link
Contributor Author

dkrenn commented Jan 23, 2016

comment:21

Replying to @cheuberg:

Replying to @behackl:

In principle, this would be a positive_review from my side, however, I'd like to rewrite your code some more such that subrings of subrings can be constructed as well. The easiest way to do so (probably), is to let the functors do everything.

The question is whether to postpone the rewriting to a follow-up ticket (i.e., does your planned rewriting affect the interface or is it just internal rewriting which will then allow new things to be done?) This also in view of several tickets depending on this ticket here.

+1 for postpone to follow-up ticket.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 23, 2016

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

d376b10revert changes to merge of functors

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 23, 2016

Changed commit from c4a0e22 to d376b10

@behackl
Copy link
Member

behackl commented Jan 23, 2016

comment:23

Replying to @dkrenn:

No, merge is correct. Composition means creating a larger subring, which contains both the corresonding rings (it is used in pushout).
So please git revert

Done. I thought of composition instead of something that is used in the construction of the pushout, sorry.

My approach requires an implemented compoisiton of functors; I'll take care of that in a follow-up ticket.

As you have reviewed my changes, I'll set this to positive_review after building and checking the documentation again.

@dkrenn
Copy link
Contributor Author

dkrenn commented Jan 23, 2016

comment:25

Reviewer(s), please insert your name(s) in the corresponding field of the ticket.

@cheuberg
Copy link
Contributor

Reviewer: Benjamin Hackl

@vbraun
Copy link
Member

vbraun commented Jan 24, 2016

Changed branch from u/behackl/symbolics/symbolic-subring to d376b10

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

6 participants