#12977: Let singular_function expect "attributes" not as a dict
---------------------------------------+------------------------------------
Reporter: SimonKing | Owner: malb
Type: defect | Status: needs_review
Priority: major | Milestone: sage-5.10
Component: commutative algebra | Resolution:
Keywords: sd40.5 | Work issues:
Report Upstream: N/A | Reviewers: Mike Hansen
Authors: Simon King | Merged in:
Dependencies: | Stopgaps:
---------------------------------------+------------------------------------
Changes (by SimonKing):
* status: needs_work => needs_review
* work_issues: Do not set a_attrib accidentally. Provide a flag for
"comparison by equality" =>
Old description:
> Here is how attributes are passed to libsingular when calling a singular
> function:
> {{{
> sage: from sage.libs.singular import singular_function
> sage: P.<x,y>=QQ[]
> sage: J = P*[P.random_element() for _ in range(100)]
> sage: NF = singular_function('reduce')
> sage: _ = NF(J.groebner_basis(),J,attributes={J:{'isSB':1}})
> }}}
>
> Hence, a dictionary is expected, where the keys are arguments to the
> function. Now, that's bad: The hash of ideals is broken and is slow (see
> #12976).
>
> Moreover, the attribute is supposed to be applied to a particular object,
> but ''not'' to an object that is only ''equal'' (but not identical).
>
> '''__Suggestion__'''
>
> Make it so that
> {{{
> sage: _ = NF(J.groebner_basis(),J,attributes=(None,{'isSB':1}))
> }}}
> works: attributes is a tuple or list of things that are to be interpreted
> as attribute of the different arguments of the singular function, in the
> given order.
>
> Apply
>
> * [attachment:trac12977_singular_function_attributes.patch]
> * [attachment:trac_12977-fix_doctest.patch]
New description:
Here is how attributes are passed to libsingular when calling a singular
function:
{{{
sage: from sage.libs.singular import singular_function
sage: P.<x,y>=QQ[]
sage: J = P*[P.random_element() for _ in range(100)]
sage: NF = singular_function('reduce')
sage: _ = NF(J.groebner_basis(),J,attributes={J:{'isSB':1}})
}}}
Hence, a dictionary is expected, where the keys are arguments to the
function. Now, that's bad: The hash of ideals is broken and is slow (see
#12976).
Moreover, the attribute is supposed to be applied to a particular object,
but ''not'' to an object that is only ''equal'' (but not identical).
'''__Suggestion__'''
Make it so that
{{{
sage: _ = NF(J.groebner_basis(),J,attributes=(None,{'isSB':1}))
}}}
works: attributes is a tuple or list of things that are to be interpreted
as attribute of the different arguments of the singular function, in the
given order.
Apply
* [attachment:trac12977_singular_function_attributes.patch]
--
Comment:
Sorry for not finishing it earlier.
I hope I did address the two complaints successfully. In particular,
a_attrib will now only be non-none, if it actually applies to one of the
arguments. And I provide an optional argument by which one can choose
whether one wants comparison by identity or by equality.
If the attributes are passed as a dict, then there is no change w.r.t old
behaviour: The broken hash will be used, and comparison by equality. In
particular, this will not break things that were not broken before.
If the attributes are passed as a tuple or list, then the default is a
comparison by identity---I can not imagine a use case in which one would
like to compare by equality. But if one really wants equality, one can set
an optional parameter accordingly.
Further changes: I tried to make the new syntax more visible in the docs.
The second patch is not needed. Hence:
Apply trac12977_singular_function_attributes.patch
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12977#comment:14>
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 http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.