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

RFC: rename trace to tr #26365

Merged
merged 1 commit into from
Mar 15, 2018
Merged

RFC: rename trace to tr #26365

merged 1 commit into from
Mar 15, 2018

Conversation

JeffBezanson
Copy link
Sponsor Member

In math this is always written as tr(A), and trace could potentially mean other things.

@JeffBezanson JeffBezanson added linear algebra Linear algebra deprecation This change introduces or involves a deprecation labels Mar 8, 2018
@ViralBShah
Copy link
Member

I have never seen it written as tr in math. It is a pretty standard name, and I have always seen it as trace. More so, I don't think we should be taking up 2 letter names like this.

@JeffBezanson
Copy link
Sponsor Member Author

@mbauman
Copy link
Sponsor Member

mbauman commented Mar 8, 2018

It also helps that this is now behind a using LinearAlgebra in order to bring it into your namespace. I think it's totally ok for LinearAlgebra to export a two-letter function like this. Base would be a much tougher sell, I agree.

@ViralBShah
Copy link
Member

I still feel that being in Stdlib is special. And something like LinearAlgebra will be widely used.

@innerlee
Copy link
Contributor

innerlee commented Mar 8, 2018

I support tr. The math books (maybe old books) I used use tr. Until recently, I noticed that engineering books like the verbose trace. It is understandable because the target audience is different.

@GlenHertz
Copy link
Contributor

Functions should have long verbose names so users variables can have short names. Otherwise people will write t = tr(a) and it will not be obvious what it does. If people want they can tr = trace themselves.

@strickek
Copy link
Contributor

strickek commented Mar 8, 2018

SciPy and Matlab also use "trace". And it is short, so why change it?

@antoine-levitt
Copy link
Contributor

There are already two letter names (qr, lu) and abbreviations (det, inv). tr for trace is very standard (I haven't ever seen trace written down in full)

@haampie
Copy link
Contributor

haampie commented Mar 8, 2018

Wolfram Language also usesTr.

It could be confused with a shorthand for transpose, though.

@KristofferC
Copy link
Sponsor Member

KristofferC commented Mar 8, 2018

Googling on images for trace matrix math and counting I got 18 tr and 4 trace. Science.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Mar 8, 2018

tr seems a bit less common, so it's harder for someone to google than trace, but it does seem to go right along with the glorious tradition of using truncated names (I'm looking at you "sine"): cos, atan, exp, det, log, log1p, sqrt, pow, mul, hypot, etc.

@ajkeller34
Copy link
Contributor

In physics, I rarely if ever see trace written out in full; almost always I see tr. The context makes it clear though. If tr lived in Base I'd be against this change, but if it lived in LinearAlgebra I think it'd be fine.

@Keno
Copy link
Member

Keno commented Mar 8, 2018

No love for https://en.wikipedia.org/wiki/Tr_(Unix)?

@JeffBezanson JeffBezanson added the triage This should be discussed on a triage call label Mar 8, 2018
@ararslan
Copy link
Member

ararslan commented Mar 8, 2018

I've seen both tr and trace in math, but more often than not I've seen this written as tr. That said, I'm against this change. While we usually adhere to mathematical names, take for example transpose; no one writes the word out in math. I think in this case trace is perfectly clear and not without precedent. What else could trace(::AbstractMatrix) mean?

@StefanKarpinski
Copy link
Sponsor Member

I've only ever seen the mathematical trace operator written in equations as tr(A). In prose it's referred to as "the trace" but as an operator this is called tr so I'm in favor of changing it.

@JeffBezanson JeffBezanson removed the triage This should be discussed on a triage call label Mar 8, 2018
@GlenHertz
Copy link
Contributor

I can foresee tr being in an html package (table row), tr is also a common Unix command, Total Return in finances, etc. Someone doing financial stuff may want to generate html reports and use linear algebra. If Julia is general purpose then to gain the full benefits of multi-dispatch shouldn't function names be long enough so people can combine packages and still be able to write generic code? Maybe this is better now but in the past it was problematic. Please consider other factors than popularity and people what don't have word auto-complete in there text editor.

@DNF2
Copy link

DNF2 commented Mar 9, 2018

I agree with @GlenHertz here (except I don't like verbosity in general). It is nice to write

tr = trace(A)

While tr is common in mathematics, where the context is always totally obvious, trace is common in programming languages.

It's even monosyllabic.

@antoine-levitt
Copy link
Contributor

It is nice to write
tr = trace(A)

It's the same argument for det & co. I usually write detA = det(A).

I think in this case trace is perfectly clear and not without precedent. What else could trace(::AbstractMatrix) mean?

In Julia there is at least https://github.com/MikeInnes/Traceur.jl (although in macro form). Trace in non-numerical programming languages usually means to examine the execution of a command, e.g. strace, dtrace, python's trace, etc.

@andyferris
Copy link
Member

Personally I find trace more readable - I like to consider that people (eg at work) who aren’t mathematicians will read my code and have enough breadcrumbs to figure out what it means. tr wouldn’t Google well (though there is the docsting, I guess).

@JeffBezanson JeffBezanson added the triage This should be discussed on a triage call label Mar 13, 2018
@JeffBezanson
Copy link
Sponsor Member Author

I think readability by non-mathematicians is not a real requirement --- tr is the standard notation, like sin, cos, and det.

@StefanKarpinski
Copy link
Sponsor Member

StefanKarpinski commented Mar 14, 2018

This seems to me to be exactly the same situation as the determinant which is always, always, always written as det(A) in math textbooks; similarly tr(A) is always how the trace of A is written as an operator. You do not write determinant(A) or trace(A).

@StefanKarpinski
Copy link
Sponsor Member

Evidence: just look through this google image search (courtesy of @mbauman):

https://www.google.com/search?tbm=isch&q=linear%20algebra%20trace&tbs=imgo:1

@StefanKarpinski
Copy link
Sponsor Member

This one's for @fredrikekre!

@JeffBezanson
Copy link
Sponsor Member Author

Ok, looks like the "aye"s have it.

@StefanKarpinski StefanKarpinski merged commit 66147ff into master Mar 15, 2018
@StefanKarpinski StefanKarpinski deleted the jb/tr branch March 15, 2018 18:21
@StefanKarpinski StefanKarpinski removed the triage This should be discussed on a triage call label Mar 15, 2018
@StefanKarpinski StefanKarpinski added this to the 1.0 milestone Mar 15, 2018
ararslan added a commit that referenced this pull request Mar 15, 2018
trace was renamed to tr in #26365 but the deprecation in sysimg was not
updated.
ararslan added a commit that referenced this pull request Mar 16, 2018
trace was renamed to tr in #26365 but the deprecation in sysimg was not
updated.
@garrison garrison added the needs news A NEWS entry is required for this change label Aug 12, 2018
@KristofferC KristofferC removed the needs news A NEWS entry is required for this change label Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation This change introduces or involves a deprecation linear algebra Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.