Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make apply_map deal with empty matrices #3023

Closed
jasongrout opened this issue Apr 25, 2008 · 3 comments
Closed

make apply_map deal with empty matrices #3023

jasongrout opened this issue Apr 25, 2008 · 3 comments

Comments

@jasongrout
Copy link
Member

sage: m=matrix([])
sage: m.apply_map?
sage: m.apply_map(lambda x: x)
---------------------------------------------------------------------------
<type 'exceptions.TypeError'>             Traceback (most recent call last)

/home/grout/sage/devel/sage-main/sage/matrix/<ipython console> in <module>()

/home/grout/sage/devel/sage-main/sage/matrix/matrix_dense.pyx in sage.matrix.matrix_dense.Matrix_dense.apply_map (sage/matrix/matrix_dense.c:3098)()
    307             v = sage.structure.sequence.Sequence(v)
    308             R = v.universe()
--> 309         M = sage.matrix.matrix_space.MatrixSpace(R, self._nrows,
    310                    self._ncols, sparse=False)
    311         image = M(v)

/home/grout/sage/local/lib/python2.5/site-packages/sage/matrix/matrix_space.py in MatrixSpace(base_ring, nrows, ncols, sparse)
    171     """
    172     if not sage.rings.ring.is_Ring(base_ring):
--> 173         raise TypeError, "base_ring (=%s) must be a ring"%base_ring
    174
    175     if ncols is None: ncols = nrows

<type 'exceptions.TypeError'>: base_ring (=Category of objects) must be a ring

m.apply_map(blah) should return an empty matrix in this case.

Component: linear algebra

Issue created by migration from https://trac.sagemath.org/ticket/3023

@jasongrout
Copy link
Member Author

comment:1

Attachment: trac-3023-matrix-applymap-empty.patch.gz

doctests in the matrix/ directory pass with the above patch.

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Apr 25, 2008

comment:3
[19:04] <mabshoff> so, what is the verdict on #3023?
[19:04] <jason> positive review from me :)  I don't think that counts, though
[19:05] <mabshoff> Well, as author it is expected that you think your patch it a good idea.
[19:05] <mabshoff> It seems like the sensible thing to do.
[19:07] <dfdeshom> running testall now, but positive review from me
[19:08] <dfdeshom> (and i'll put it in writing when the tests finish)

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Apr 25, 2008

comment:4

Merged in Sage 3.0.1.alpha0

@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed Apr 25, 2008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants