On Wed, May 27, 2015 at 11:38 AM, Johan S. R. Nielsen
<santaph...@gmail.com> wrote:
> Hi Sage-devel
>
> We just crashed our heads against a bug in our code due to extremely weird
> semantics of Sage. Consider the following code which creates a sub-space C
> of the four-dimensional vector space over the binary field, and then
> modifies a *copy* of a vector from the subspace:
>
> F = GF(2)
> VS = F^4
> C = VS.subspace([ (F.one(),F.one(),F.one(),F.one()) ])
> w = C([F.one(),F.one(),F.one(),F.one()])
> y = copy(w)

Isn't it more Pythonic to copy+modify the list of entries instead?
Then you can coerce it where ever you want. I try to keep operations
at as low a level as possible for as long as possible.

> y[0] = F.zero()
> print "y's parent is ", y.parent()
> print "y is in C: ", y in C
> print "y = ", y
>
> The code above is going to print:
>
> y's parent is  Vector space of degree 4 and dimension 1 over Finite Field of
> size 2
> Basis matrix:
> [1 1 1 1]
> y is in C:  True
> y =  (0, 1, 1, 1)
>
> So even though y is clearly not in our space C, Sage claims it is. The
> reason is that y's parent is still this sub-space.
>
> Sage disallows that we modify w, the original vector from C. But we are
> allowed to modify the copy y (even encouraged by a warning that Sage prints
> when you try to modify c).
>
> I assume everyone agrees the above behaviour is bad? In that case, what is
> the bug?
>
> - Is it that the copy of c is allowed to be mutated (for instance, without
> first casting it into the ambient vector space)?
>
> - Is it that the parent of y is still C immediately after copying?
>
> - Or is it that the parent of y is still C after modification?
>
> - Or a fourth option I didn't think of?
>
> Best,
> Johan
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-devel+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-devel@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to