#14666: Test if a weight function is generic for a given matroid
-------------------------------------+-------------------------------------
Reporter: Stefan | Owner: Stefanf
Type: enhancement | Status: needs_review
Priority: minor | Milestone: sage-7.2
Component: matroid theory | Resolution:
Keywords: matroid, weight | Merged in:
function | Reviewers:
Authors: | Work issues:
Report Upstream: N/A | Commit:
Branch: | 059b6d3816eae7412bc5e6570c17888fa2b75678
public/ticket/14666 | Stopgaps:
Dependencies: |
-------------------------------------+-------------------------------------
Comment (by Stefan):
Replying to [comment:14 darij]:
> I've made some changes (NB: branch change!), particularly documenting
one of the undocumented codepaths (namely, passing a dictionary for
`weight`). However, it exposed a bug: The algorithm assumes `weight` to be
a function.
>
> My suggestion here would be to change the way dictionaries are handled.
Rather than doing the `try/except`s, I'd check whether `weight` is a
dictionary, and then define a function `weight_fun` to send each `e` to
`weight[e]`. Otherwise, I'd just set `weight_fun = weight`. All other uses
of `weight` in the code should then be replaced by `weight_fun`. Does this
sound reasonable to you? (I haven't done any speed comparisons or other
tests, so this might not actually be a good idea.)
In Python, any object can implement the square bracket and round bracket
notation. Your suggestion would make it impossible to have a matroid with
ground set 0..n and weight function just a list.
This code was borrowed from the max_weight_independent method, where in
the examples both dictionary and function specifications are tested. Do
you have an example of when your bug occurs?
--
Ticket URL: <http://trac.sagemath.org/ticket/14666#comment:18>
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.