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

abs(matrix) should not be a shortcut for det #17443

Closed
videlec opened this issue Dec 4, 2014 · 18 comments
Closed

abs(matrix) should not be a shortcut for det #17443

videlec opened this issue Dec 4, 2014 · 18 comments

Comments

@videlec
Copy link
Contributor

videlec commented Dec 4, 2014

We have currently

sage: M = matrix([[-1]])
sage: abs(M)
-1

Because matrix.__abs__ is a shortcut for determinant!!I

n scipy, __abs__ applies the absolute value to each coefficient. But it is not likely what we want to do in Sage. Instead we raise a TypeError and inform the user about matrix.norm(1) and matrix.apply_map(abs).

Related discussion on sage-devel https://groups.google.com/forum/#!topic/sage-devel/pFI9y3YZIQQ

Component: linear algebra

Author: Vincent Delecroix

Branch/Commit: e6a4de8

Reviewer: Nathann Cohen

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

@videlec videlec added this to the sage-6.5 milestone Dec 4, 2014
@videlec
Copy link
Contributor Author

videlec commented Dec 4, 2014

Commit: 697c759

@videlec
Copy link
Contributor Author

videlec commented Dec 4, 2014

New commits:

697c759trac #17443: fix abs(matrix)

@videlec
Copy link
Contributor Author

videlec commented Dec 4, 2014

Branch: u/vdelecroix/17443

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Dec 4, 2014

comment:2

Crazy O_o

I will run the tests and see if it breaks anything.

Why do you make "abs" an alias for __abs__ ? If you believe that it is worth adding a function (given that abs(M) works I do not understand why it would be), can you make it .absolute_value ? We try to not have full names for methods.

Nathann

@videlec

This comment has been minimized.

@videlec
Copy link
Contributor Author

videlec commented Dec 4, 2014

comment:3

No hurry. Discussion going on on sage-devel...

@jdemeyer
Copy link

jdemeyer commented Dec 4, 2014

comment:4

The discussions seem to indicate a preference for deprecating __abs__.

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Dec 4, 2014

comment:5

The discussions seem to indicate a preference for deprecating __abs__.

Yesyes, this seems to be the wisest thing to do indeed.

Nathann

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 5, 2014

Changed commit from 697c759 to f4ac40f

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 5, 2014

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

f4ac40ftrac #17443: deprecate abs + generic apply_map

@videlec

This comment has been minimized.

@jdemeyer
Copy link

jdemeyer commented Dec 5, 2014

comment:8

This should be a deprecation, not an error.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 6, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

e6a4de8trac #17443: change TypeError to a deprecation

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 6, 2014

Changed commit from f4ac40f to e6a4de8

@videlec
Copy link
Contributor Author

videlec commented Dec 6, 2014

comment:10

All right, it is now a deprecation...

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Dec 11, 2014

comment:11

Passes all tests, so positive review.

Do you know of a tool to detect that you only "moved" the code of those two big functions ?

I found no way to do this, so in order to check your patch I moved what you wrote in matrix2 back to matrix_dense, only to see as it was detected as "leaving those function as they were" when merged with your patch.

Nathann

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Dec 11, 2014

Reviewer: Nathann Cohen

@vbraun
Copy link
Member

vbraun commented Dec 15, 2014

Changed branch from u/vdelecroix/17443 to e6a4de8

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

3 participants