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

fraction field: fix conversion from symbolic ring #26150

Closed
dkrenn opened this issue Aug 28, 2018 · 34 comments
Closed

fraction field: fix conversion from symbolic ring #26150

dkrenn opened this issue Aug 28, 2018 · 34 comments

Comments

@dkrenn
Copy link
Contributor

dkrenn commented Aug 28, 2018

sage: z = SR.var('z')
sage: CyclotomicField(2)['z'].fraction_field()(2*(4*z + 5)/((z + 1)*(z - 1)^4))

raises an error but shouldn't. This issue is also mentioned on #24539.

AFAICS it worked in earlier SageMath versions, but probably due to #23664 (unchecked) it stopped working.

CC: @cheuberg @mezzarobba

Component: algebra

Author: Daniel Krenn

Branch/Commit: 1a3cc58

Reviewer: Marc Mezzarobba

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

@dkrenn dkrenn added this to the sage-8.4 milestone Aug 28, 2018
@dkrenn
Copy link
Contributor Author

dkrenn commented Aug 28, 2018

Branch: u/dkrenn/conv-fraction-field

@dkrenn
Copy link
Contributor Author

dkrenn commented Aug 28, 2018

Commit: f76254a

@dkrenn
Copy link
Contributor Author

dkrenn commented Aug 28, 2018

New commits:

f76254aTrac #26150: fix conversion in fraction_field

@dkrenn
Copy link
Contributor Author

dkrenn commented Aug 28, 2018

Author: Daniel Krenn

@dkrenn

This comment has been minimized.

@mezzarobba
Copy link
Member

Reviewer: Marc Mezzarobba

@mezzarobba
Copy link
Member

comment:4

Thanks for the fix! You can set the ticket to positive_review on my behalf if the patchbot is happy.

@dkrenn
Copy link
Contributor Author

dkrenn commented Aug 29, 2018

comment:5

Unfortunately, there is one doctest failing:

File "src/sage/rings/function_field/function_field.py", line 1602, in sage.rings.function_field.function_field.FunctionField_polymod.hom
Failed example:
    L.hom(r, base_morphism=phi)
Exception raised:
    Traceback (most recent call last):
    ...
    ValueError: invalid literal for int() with base 10: "Error in dput(length(sage1)) : object 'sage1' not foun"

I have no idea what is going on here.

@jdemeyer
Copy link

comment:6

Nitpick: :trac:`#26150` -> :trac:`26150`

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 29, 2018

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

b0920f3fix trac ticket number reference in docstring

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 29, 2018

Changed commit from f76254a to b0920f3

@dkrenn
Copy link
Contributor Author

dkrenn commented Aug 29, 2018

comment:8

Replying to @jdemeyer:

Nitpick: :trac:`#26150` -> :trac:`26150`

Thanks. Changed.

@dkrenn
Copy link
Contributor Author

dkrenn commented Aug 29, 2018

comment:9

Replying to @dkrenn:

Unfortunately, there is one doctest failing:

File "src/sage/rings/function_field/function_field.py", line 1602, in sage.rings.function_field.function_field.FunctionField_polymod.hom
Failed example:
    L.hom(r, base_morphism=phi)
Exception raised:
    Traceback (most recent call last):
    ...
    ValueError: invalid literal for int() with base 10: "Error in dput(length(sage1)) : object 'sage1' not foun"

Follow up at #26155.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 30, 2018

Changed commit from b0920f3 to f98b015

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 30, 2018

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

f98b015Trac #26150: catch internal ValueError to get correct outer error response

@dkrenn
Copy link
Contributor Author

dkrenn commented Aug 30, 2018

comment:11

This is now an alternative fix for the issue. Needs review again and let's see what the patchbot says :)

@dkrenn
Copy link
Contributor Author

dkrenn commented Aug 30, 2018

comment:12

Again some failing doctests... :(

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 30, 2018

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

b31583aTrac #26150: fix element_constructor of int(1)

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 30, 2018

Changed commit from f98b015 to b31583a

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 30, 2018

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

b3be7d9Trac #26150: fix doctest (remove error message as something is now working)

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 30, 2018

Changed commit from b31583a to b3be7d9

@dkrenn
Copy link
Contributor Author

dkrenn commented Aug 30, 2018

comment:15

There is some underlying problem with a recursive call when creating an element out of int(1). This was somehow hidden before. I rewrote the element constructor a bit to adapt; also fixing an issue raised on #24539. The behavior is now more consistent with remaining SageMath.

So again, let us see what the patchbot says...

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 15, 2018

Changed commit from b3be7d9 to cdbed4f

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 15, 2018

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

cdbed4fMerge tag '8.4.beta3' into t/26150/conv-fraction-field

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 15, 2018

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

2697d5cTrac #26150: fix using correct one-element
45df8b5Trac #26150: extend trying of decomposing the fraction

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 15, 2018

Changed commit from cdbed4f to 45df8b5

@dkrenn
Copy link
Contributor Author

dkrenn commented Sep 16, 2018

comment:18

Finally, I've written a fix that solves the issues and with which the patchbot is happy as well. To be more accurate, I've took the liberty to slightly rewrite the element constructor so that it covers a broader spectrum of inputs for the conversion. Now it should also be "correct" in the sense what it does at which point ;)

Please Review (again)

@dkrenn
Copy link
Contributor Author

dkrenn commented Mar 27, 2019

comment:19

@mezzarobba: You already have reviewed this ticket, but a small change was done after that. I would appreciate a review of the changes :)

@mezzarobba
Copy link
Member

comment:20

Thanks for the notice.

I agree with most of the changes, but I'm not sure I like the unconditional conversions in resolve_fractions(). For which cases are they intended?

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 3, 2019

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

7625e86Merge tag '8.7' into u/dkrenn/conv-fraction-field
1a3cc58Trac #26150: add another doctest

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 3, 2019

Changed commit from 45df8b5 to 1a3cc58

@dkrenn
Copy link
Contributor Author

dkrenn commented Apr 3, 2019

comment:22

Replying to @mezzarobba:

Thanks for the notice.

I agree with most of the changes, but I'm not sure I like the unconditional conversions in resolve_fractions(). For which cases are they intended?

Added a doctest:

1a3cc58 Trac #26150: add another doctest
+            sage: T.<t> = ZZ[]
+            sage: S.<s> = ZZ[]
+            sage: S.fraction_field()(s/(s+1), (t-1)/(t+2))
+            (s^2 + 2*s)/(s^2 - 1)

Note that there is a conversion between S and T, so this conversion should be used also in the fraction field, at least in the case nothing else (proper coercion) works.

@mezzarobba
Copy link
Member

comment:23

If you are really sure you want that, I won't oppose...

@vbraun
Copy link
Member

vbraun commented Apr 8, 2019

Changed branch from u/dkrenn/conv-fraction-field to 1a3cc58

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