Opened 6 years ago

Closed 5 years ago

# Conversion from SR to number fields

Reported by: Owned by: Karl-Dieter Crisman minor sage-8.0 number fields Samuel Lelièvre Jeroen Demeyer Travis Scrimshaw N/A beed700 beed7001cf8f8b2a18b77b591e05334c2ec9a91e

I'm not sure if this is kosher, but I would like

```sage: G = GaussianIntegers()
sage: G(2+I)
```

to "just work".

### comment:1 Changed 6 years ago by Ralf Stephan

Looks like a conversion as in `symbolic/expression_conversions.py` should do the trick.

### comment:2 follow-up:  3 Changed 6 years ago by Nils Bruin

This could help: #18036

### comment:3 in reply to:  2 Changed 6 years ago by Karl-Dieter Crisman

This could help: #18036

Haha, I was sure that one had been merged by others long ago! I'll at least put a xref to this one there.

### comment:4 Changed 6 years ago by Jeroen Demeyer

Milestone: sage-7.6 → sage-duplicate/invalid/wontfix → duplicate new → closed

### comment:5 Changed 6 years ago by Samuel Lelièvre

Note that the following also works (in Sage 7.5.1).

```sage: G = GaussianIntegers()
sage: G('2 + I')
I + 2
```

### comment:6 Changed 5 years ago by Jeroen Demeyer

Description: modified (diff) duplicate closed → new Allow immediate coercion from SR to Gaussian? → Conversion from SR to number fields

### comment:7 Changed 5 years ago by Jeroen Demeyer

I'm reopening this because there are two ways to interpret this ticket:

1. Allow `G(2 + I)` to just work, using the symbol `I`.
1. Allow `G(expr)` to work, where `expr` is some symbolic expression representing a Gaussian integer.

Only the first one would be fixed by #18036.

Version 0, edited 5 years ago by Jeroen Demeyer (next)

### comment:8 Changed 5 years ago by Jeroen Demeyer

Authors: → Jeroen Demeyer sage-duplicate/invalid/wontfix → sage-8.0

### comment:9 Changed 5 years ago by Jeroen Demeyer

Branch: → u/jdemeyer/conversion_from_sr_to_number_fields

### comment:10 Changed 5 years ago by Jeroen Demeyer

Commit: → 0128efca77e3faf7cd18749ad49f610958008021 new → needs_review

New commits:

 ​0128efc `Conversion from AA, QQbar and SR to number fields`

### comment:11 Changed 5 years ago by Ralf Stephan

Can you be more specific than `except Exception`?

### comment:12 Changed 5 years ago by Jeroen Demeyer

I'll try to just drop the `except Exception` completely.

### comment:13 Changed 5 years ago by git

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

 ​47845a4 `Further fixes to conversion of non-number-field elements`

### comment:14 Changed 5 years ago by Jeroen Demeyer

In the end, I did some more refactoring, including removing some duplicate code.

### comment:15 follow-up:  16 Changed 5 years ago by Ralf Stephan

Sorry, to much algebra, cannot review.

### comment:16 in reply to:  15 Changed 5 years ago by Karl-Dieter Crisman

Sorry, to much algebra, cannot review.

Most of the algebra is just cutting and pasting some examples, though, so those wouldn't need explicit review ...

### comment:17 Changed 5 years ago by Travis Scrimshaw

Reviewers: → Travis Scrimshaw

I double-checked, and the algebra LGTM. I do have one minor docstring fix:

```         """
-        Convert a non-number field element x into this number field.
+        Convert a non-number field element ``x`` into this number field.

INPUT:

-        - ``x`` -- a non number field element x, e.g., a list, integer,
-          rational, or polynomial.
+        - ``x`` -- a non number field element, e.g., a list, integer,
+          rational, or polynomial
```

Once that is done, you can set a positive review on my behalf.

### comment:18 Changed 5 years ago by git

Commit: 47845a424847db5ef208298d4e7fdbd84c695b03 → 4a3e6386daf2ea7c691810cab70373339f5c161d

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

 ​4a3e638 `Minor doc fix`

### comment:19 Changed 5 years ago by Jeroen Demeyer

Status: needs_review → positive_review

### comment:20 Changed 5 years ago by Volker Braun

Status: positive_review → needs_work

Merge conflict

### comment:21 Changed 5 years ago by git

Commit: 4a3e6386daf2ea7c691810cab70373339f5c161d → beed7001cf8f8b2a18b77b591e05334c2ec9a91e

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

 ​beed700 `Merge tag '8.1.beta0' into t/22208/conversion_from_sr_to_number_fields`

### comment:22 Changed 5 years ago by Jeroen Demeyer

Status: needs_work → positive_review

### comment:23 Changed 5 years ago by Volker Braun

Branch: u/jdemeyer/conversion_from_sr_to_number_fields → beed7001cf8f8b2a18b77b591e05334c2ec9a91e → fixed positive_review → closed
Note: See TracTickets for help on using tickets.