# Why \`eye\` has been deprecated?

**URL:** <https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824>\
**Category:** Internals & Design\
**Created:** [August 2, 2018, 2:12pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824 "2018-08-02T14:12:13Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![dlfivefifty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlfivefifty/32/1959_2.png) [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)\
**Post date:** [August 3, 2018, 5:37am UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/21 "2018-08-03T05:37:38Z")

</div>

I really am struggling to understand what’s so difficult with

```julia
using MatlabCompat
linspace(0,1,100)
eye(5)

```

Just add MatlabCompat to your startup file and you won’t even notice the change.

Sure, this means you need a startup file. But Julia v0.7 is almost unusable without one for LinearAlegbra, Random, etc. So what’s one more package?

Whether or not I find this slightly inconvenient (I do of course), I agree with the principle that `Base` should be as minimal as possible, as it’s good coding practice.

---

<div class="post-metadata">

**Author:** ![Roger-luo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roger-luo/32/3399_2.png) [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Post date:** [August 3, 2018, 5:57am UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/22 "2018-08-03T05:57:55Z")

</div>

I do think `eye` is not necessary, however a type for Identity matrix should be defined like `IMatrix`. Because current `LinearAlgebra.UniformScaling` type do not have shape information and it is not a matrix (not subtype of `AbstractMatrix`).

We recently extended `stdlib` a little bit in [https://github.com/QuantumBFS/Yao.jl/blob/master/src/LuxurySparse/IMatrix.jl](https://github.com/QuantumBFS/Yao.jl/blob/master/src/LuxurySparse/IMatrix.jl)

This not only boost our performance, but also provide more explicit way to use an identity matrix (since you have to treat it differently according to the matrix size sometimes)

We are willing to contribute this to upstream if possible.

---

<div class="post-metadata">

**Author:** ![pkofod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pkofod/32/2179_2.png) [@pkofod](https://discourse.julialang.org/u/pkofod)\
**Post date:** [August 3, 2018, 7:04am UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/23 "2018-08-03T07:04:31Z")

</div>

I think this is extremely unfair to the contributors, and I doubt you follow the PRs and issues very closely when you make these claims and statements. We actually have very active contributors who mostly do documentation (and tests!). Ofc, there is always more to do, but there are actually people who enjoy doing these parts of the development of Julia, and I think comparing their work to that of janitors is not really fair, and implying that it isn’t stimulating shows you’re underestimating the level of detailed knowledge you need to write good tests and docs.

I am sure you didn’t mean to insult anyone, and I am sure my comment is overly defensive. However, since you’re right that we don’t have an unlimited supply of labor, I don’t think there’s any reason to devalue the work that IS being done.

---

<div class="post-metadata">

**Author:** ![Per](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/per/32/10387_2.png) [@Per](https://discourse.julialang.org/u/Per)\
**Post date:** [August 3, 2018, 7:11am UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/24 "2018-08-03T07:11:54Z")

</div>

> [@airpmb](#):
>
> > I also get the sense that any time the devs have a chance to expunge Matlab idioms from the language, they take it.
> 
> Whether or not it’s accurate, you see the result–what is the issue that you have with it?

It seems you attributed that quote to the wrong person. I do quite a bit of coding in Matlab, and as a result there have been quite a few occasions where I’ve been annoyed with the quirks of that language. Every time Julia has moved away from Matlab syntax, I’ve found it made the language better. (I wish that they’d gotten rid of the hard-coded `f' = adjoint(f)` as well.)

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [August 3, 2018, 7:13am UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/25 "2018-08-03T07:13:07Z")

</div>

> [@Per](#):
>
> (I wish that they’d gotten rid of the hard-coded `f' = adjoint(f)` as well.)

Yikes! What would you suggest instead?

---

<div class="post-metadata">

**Author:** ![Roger-luo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roger-luo/32/3399_2.png) [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Post date:** [August 3, 2018, 7:18am UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/26 "2018-08-03T07:18:57Z")

</div>

Why should we fully adopt MATLAB idioms? Isn’t it because we think it is not perfect and then we have the Julia language?

`eye` is not explicit, you won’t notice which type you are using. I will vote for `IMatrix` if we need something for identity matrix rather than `eye`. If we have

```julia
eye(3)

```

You cannot tell whether this is a `Array`, or `SparseMatrixCSC`, or `CuArray` etc. explicit is better than implicit.

MATLAB is not Julia, Python is not Julia, although Julia make use part of their idioms. I don’t think it is good to use `UniformScaling` either though. But this should be another story.

---

<div class="post-metadata">

**Author:** ![Roger-luo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roger-luo/32/3399_2.png) [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Post date:** [August 3, 2018, 7:20am UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/27 "2018-08-03T07:20:58Z")

</div>

Why hard-coded `f' = adjoint(f)` is annoying? Is there any example for this?

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [August 3, 2018, 4:10pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/28 "2018-08-03T16:10:22Z")

</div>

33 posts were split to a new topic: [On adjoints and custom postfix and infix operators](https://discourse.julialang.org/t/on-adjoints-and-custom-postfix-and-infix-operators/12863)

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [August 3, 2018, 7:24am UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/29 "2018-08-03T07:24:27Z")

</div>

> [@pkofod](#):
>
> I think comparing their work to that of janitors is not really fair

I don’t think there is anything wrong with being a janitor, and I have in fact often heard that title used in a respectful way about people who do a lot of important, low-profile work.

While I agree with much of your post, I didn’t see any devaluation of “janitorial tasks” in @stillyslalom’s post.

---

<div class="post-metadata">

**Author:** ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Post date:** [August 3, 2018, 4:06pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/62 "2018-08-03T16:06:27Z")

</div>

In finance and econometrics, there’s often a fair number of I\_n (`eye(n)`) floating around in the papers/texts. Since I like my programs to stick closely to the “theory,” this carries over to my attempts to code.

In the run up to 0.7, I spent some time purging `eye` from all my code for my lecture notes (and using `I` instead). In line with Stefan’s forecast, I had 95% luck. I believe that the only remaining case that I still have is a couple of `kron(X,I)` where `X` is a square matrix. However, I suspect it qualifies as an anti pattern.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [August 3, 2018, 4:12pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/63 "2018-08-03T16:12:47Z")

</div>

> [@stillyslalom](#):
>
> To be clear, I don’t have an issue with the changes themselves (except for `linspace` , RIP. `linspace(0, pi` ) is so much nicer for interactive use than `range(0, stop=pi, length=50` ).

This is temporarily worse than it will be in the future. With the deprecation removed in `1.0-dev`, we can now have a pull-request to allow `range(0, pi, length=50)`.

Moderator’s note: I’ve split this thread as best I could.

---

<div class="post-metadata">

**Author:** ![airpmb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/airpmb/32/7826_2.png) [@airpmb](https://discourse.julialang.org/u/airpmb)\
**Post date:** [August 3, 2018, 4:24pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/64 "2018-08-03T16:24:23Z")

</div>

Ok so maybe rather than just my specific suggestions of contributing to the Wikibook and working on a `MatlabToJulia.jl` (or modernizing `MatlabCompat.jl`) is anyone interested in forming some sort of MATLAB/Julia users SIG which can do these sorts of things (including others’ probably better ideas than mine) in a coordinated way? This could just be a sub-forum here on Discourse (and, if people insist, a Slack channel, but ugh, Slack 🙂 ).

I think individually we probably are very busy and have little time but collectively we can do a lot to turn some of the kinds of discussion we have on threads like these into some concrete solutions that build on the (1.0) core language.

---

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [August 3, 2018, 4:27pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/65 "2018-08-03T16:27:19Z")

</div>

Count on me! 99,99% of the engineers at INPE (National Institute for Space Research) use MATLAB and an easy update path is required 🙂

I think `MatlabCompat` is fine. But we need to make it come back to life.

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [August 3, 2018, 4:42pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/66 "2018-08-03T16:42:33Z")

</div>

I’m sorry, my tone was a bit sharp. Most of the small handful of contributions I’ve made to the language and ecosystem have been docs-related, I’ve worked as an actual janitor, and I really do appreciate well-written documentation. I’m just looking forward to the ecosystem documentation/blogs/examples catching up to the language (and ready to help once 1.0 and major peripheral packages are stable).

Re: Matlab, I don’t think we need to copy the syntax, per se, but I’d like a `Batteries.jl` or `KitchenSink.jl` package that just reexports other packages to provide functionality on par with what’s built into Matlab. (FFTW, SpecialFunctions, Plots, LinearAlgebra, Images, DataFrames, Interpolations, Roots, Random, LsqFit, QuadGK, DifferentialEquations, ???)

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [August 3, 2018, 4:44pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/67 "2018-08-03T16:44:58Z")

</div>

Frankly I feel that Matlab developers have made a number of questionable choices over the years, and very rarely they made the effort to correct them. Consistency and obviousness is a great advantage of Julia!

---

<div class="post-metadata">

**Author:** ![airpmb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/airpmb/32/7826_2.png) [@airpmb](https://discourse.julialang.org/u/airpmb)\
**Post date:** [August 3, 2018, 4:45pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/68 "2018-08-03T16:45:24Z")

</div>

@StefanKarpinski could we get perhaps a subcategory of Development?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [August 3, 2018, 5:08pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/69 "2018-08-03T17:08:40Z")

</div>

> [@stillyslalom](#):
>
> Re: Matlab, I don’t think we need to copy the syntax, per se, but I’d like a `Batteries.jl` or `KitchenSink.jl` package that just reexports other packages to provide functionality on par with what’s built into Matlab. (FFTW, SpecialFunctions, Plots, LinearAlgebra, Images, DataFrames, Interpolations, Roots, Random, LsqFit, QuadGK, DifferentialEquations, ???)

[GitHub - ChrisRackauckas/Cuddle.jl: A repo equivalent to a giant hug!](https://github.com/ChrisRackauckas/Cuddle.jl) ? :troll:

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [August 3, 2018, 5:29pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/70 "2018-08-03T17:29:53Z")

</div>

> [@airpmb](#):
>
> @StefanKarpinski could we get perhaps a subcategory of Development?

I’m not Stefan, but I’m also a moderator here — why don’t you start with a new thread and if there’s sufficient interest/traffic we can expand it out to a subcategory. Really, though, I think this would be best coordinated around a specific repository (like MatlabCompat) and discussion within issues there.

---

<div class="post-metadata">

**Author:** ![Stephen\_Vavasis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stephen_vavasis/32/3389_2.png) [@Stephen\_Vavasis](https://discourse.julialang.org/u/Stephen_Vavasis)\
**Post date:** [August 3, 2018, 8:52pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/71 "2018-08-03T20:52:01Z")

</div>

On a related note, could someone post a one-liner that creates a dense Float64 identity matrix in both 0.6 and 0.7 with no deprecation warnings? Here is what I using now:

```julia
   eye1 = zeros(n,n)
   for i = 1 : n
        eye1[i,i] = 1.0
   end

```

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [August 3, 2018, 8:59pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/72 "2018-08-03T20:59:15Z")

</div>

With [Compat](https://github.com/JuliaLang/Compat.jl) you can use

```julia
Matrix{Float64}(I, n, n)

```

on both versions.

[Previous page](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824.md?page=1)

[Next page](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824.md?page=3)
