#18942: Weird bug in roots of a polynomial in relative number field extension
-------------------------------------+-------------------------------------
Reporter: robharron | Owner:
Type: defect | Status: needs_work
Priority: major | Milestone: sage-7.2
Component: number fields | Resolution:
Keywords: Relative number | Merged in:
field, roots | Reviewers: Peter Bruin
Authors: Kiran Kedlaya | Work issues:
Report Upstream: N/A | Commit:
Branch: | fa9c48539be9e27a676463710da32122943d95d8
u/kedlaya/weird_bug_in_roots_of_a_polynomial_in_relative_number_field_extension|
Stopgaps:
Dependencies: |
-------------------------------------+-------------------------------------
Changes (by pbruin):
* status: needs_review => needs_work
* reviewer: => Peter Bruin
Comment:
Several comments:
- Changing `__hash__` is not enough; you also have to update `__cmp__` to
be compatible with it. Python (and Sage) objects are supposed to satisfy
the implication `x == y` ==> `hash(x) == hash(y)`. Otherwise things like
the cache lookup in comment:2 will give undesired results if there is a
hash collision.
- In particular, the output of `K == L` in the first doctest should be
`False`.
- There is no reason to introduce a new attribute `__relative_polynomial`.
Since `relative_polynomial()` simply returns an existing attribute, you
can just do
{{{
return hash((self.variable_name(), self.base_field(),
tuple(self.relative_polynomial())))
}}}
- An indented block should always be indented by 4 spaces relative to the
previous line; in some of the doctests there are only 3 spaces.
- It is not very useful to have a doctest whose output consists of dozens
of lines `True`; it is cleaner to replace `print(elt.is_integral)` by
`assert(elt.is_integral)`.
--
Ticket URL: <http://trac.sagemath.org/ticket/18942#comment:9>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.