# 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:** 3

<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, 9:23pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/73 "2018-08-03T21:23:27Z")

</div>

> [@stillyslalom](#):
>
> I’ve worked as an actual janitor, and I really do appreciate well-written documentation

> [@DNF](#):
>
> 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.

I didn’t say that being a janitor was bad, or something that is offensive to be compared to. I said that the comparison wasn’t fair, and the following text was supposed to explain why…

> [@pkofod](#):
>
> shows you’re underestimating the level of detailed knowledge you need to write good tests and docs

A janitor does important work, but it is routine work: cleaning, moving stuff around, and maybe doing some small repairs - but nothing that requires specialized, skilled (licensed) work. What I’m saying is that _proper_ documentation and testing is **not** routine work. If you’ve ever had to document or test a program _you did not write yourself_ you’ll know what I mean. It requires lots of knowledge and ability to read and understand code to do this well.

Anyway, since I don’t think there were any ill intentions I don’t think we should continue this sub-thread beyond this message. I think we’re all on the same page 🙂

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [August 4, 2018, 1:36am UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/74 "2018-08-04T01:36:28Z")

</div>

Count me too. _MatlabCompat_ has the right name but I would prefer a package without the dependencies it has.

---

<div class="post-metadata">

**Author:** ![Tero\_Frondelius](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tero_frondelius/32/7629_2.png) [@Tero\_Frondelius](https://discourse.julialang.org/u/Tero_Frondelius)\
**Post date:** [August 4, 2018, 6:17am UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/75 "2018-08-04T06:17:40Z")

</div>

Maybe you want to make MatlabCombat a metapackage, which reexports. This way the package which implements eye and similar won’t have any dependencies.

---

<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 4, 2018, 6:30am UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/76 "2018-08-04T06:30:52Z")

</div>

> [@Tero\_Frondelius](#):
>
> Maybe you want to make MatlabCombat a metapackage, which reexports. This way the package which implements eye and similar won’t have any dependencies.

But at some point you just start doing `Matrix(1.0I,n,n)`

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 4, 2018, 7:39am UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/77 "2018-08-04T07:39:00Z")

</div>

Frankly, I don’t think that relying on idioms from other languages in parallel with Julia’s own is a good idea. I understand that people miss `eye` and similar, but they were removed for a reason. IMO just learning idiomatic Julia and keeping up with the changes is a better solution in the long run.

For example, I recently brought a library of mine up to date with v0.7, and had to rewrite a lot of uses of `diagm` & friends. A lot of time time this involved much more than simple replacement (thinking about what the deprecation message suggests, and reshaping it to my use case), but now the resulting code is much cleaner.

---

<div class="post-metadata">

**Author:** ![Olof\_Salberger](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/olof_salberger/32/4850_2.png) [@Olof\_Salberger](https://discourse.julialang.org/u/Olof_Salberger)\
**Post date:** [August 4, 2018, 2:04pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/78 "2018-08-04T14:04:44Z")

</div>

I use `kron(X,I)` all the time as well for quantum gates, and in S & R-matrices of quantum integrable models. Having a space-efficient solution for tensor products of different kinds of matrices in general would be very nice.

---

<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 4, 2018, 2:09pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/79 "2018-08-04T14:09:13Z")

</div>

> [@Olof\_Salberger](#):
>
> I use `kron(X,I)` all the time as well for quantum gates, and in S & R-matrices of quantum integrable models. Having a space-efficient solution for tensor products of different kinds of matrices in general would be very nice.

I agree: creating lazy `kron` types would be awesome for saving memory. Going down the route to better exploit the type system for efficiency is much more fruitful than trying to just make unnecessary matrices.

---

<div class="post-metadata">

**Author:** ![cortner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cortner/32/204_2.png) [@cortner](https://discourse.julialang.org/u/cortner)\
**Post date:** [August 4, 2018, 4:25pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/80 "2018-08-04T16:25:01Z")

</div>

That’s all fine for library development but don’t underestimate the additional mental effort in parsing Matrix(1.0I, n, n) vs eye(n)

Edit: though I(n) would be nice I guess

---

<div class="post-metadata">

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

</div>

Based on the idea in the post above, how about something like

```nohighlight
identity(Float64, n) 

```

Then you can specify the type and `n`, and you don’t have to type `n` twice.

---

<div class="post-metadata">

**Author:** ![cortner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cortner/32/204_2.png) [@cortner](https://discourse.julialang.org/u/cortner)\
**Post date:** [August 4, 2018, 4:49pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/82 "2018-08-04T16:49:25Z")

</div>

Float64 is the default

---

<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 4, 2018, 4:54pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/83 "2018-08-04T16:54:58Z")

</div>

> [@cortner](#):
>
> That’s all fine for library development but don’t underestimate the additional mental effort in parsing Matrix(1.0I, n, n) vs eye(n)

But when are you actually using this? I haven’t seen a code that should be making a dense identity matrix in a very long time. Does something that shows up up once every few hundred thousand lines of code really need a special shortened syntax?

---

<div class="post-metadata">

**Author:** ![cortner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cortner/32/204_2.png) [@cortner](https://discourse.julialang.org/u/cortner)\
**Post date:** [August 4, 2018, 6:20pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/84 "2018-08-04T18:20:36Z")

</div>

My comment was general, not specific.

But fwiw I regularly use speye

---

<div class="post-metadata">

**Author:** ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Post date:** [August 4, 2018, 6:25pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/85 "2018-08-04T18:25:04Z")

</div>

Why not treat it as `rand()`? That’s, `eye(n)` is the default, the second `n` is redundant, and `A .+ eye()` is similar to `A .+ rand()` and `eye(Int8,n)`, `eye(Int16,n)`,`eye(Int32,n)`,`eye(Int64,n)`, `eye(Float32,n)` all with their obvious meanings are similar to their `rand([..,] <size>)` counterparts.

It’s not a sin to use a well-known, easy to remember and type, function from language X in Julia unless it is too bad. Also `I` seems a pretty natural choice, only if used as `eye()` described above. When I first used Julia, Version 0.2 I think, It was so intuitive and easy that I understood every thing in 3 days. I even delivered some lectures to colleagues who are 99% MATLAB users and many of them were impressed. Now, if say there is no `eye` but `Matrix{Float64}(I, n, n)`, no `linspace` but `range(start, step=, stop=)`, etc., I imagine people saying Ughhh … Also `dims =`, why all these unnecessary changes, too much explicitness leads to verbosity and noise. If something is intuitive and frequently used keep it very short and memorable. If you had to add `dims =`, for example, why not just `dim =` as Fortran?

This is not to say that all latest changes are bad at all, in fact Julia has made very nice improvements lately, the ones I mentioned are only small examples that need more reexamination.

---

<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 4, 2018, 6:56pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/86 "2018-08-04T18:56:30Z")

</div>

Not sure if this can be avoided, but the update step of the Kalman filter requires an identity matrix:

```
Pu_k = (eye(n) - K_k*H_k)*Pp_k

```

Actually, it was when I coded a Kalman filter in v0.7 that I realized it was deprecated and then I started the original thread.

---

<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 4, 2018, 7:09pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/87 "2018-08-04T19:09:31Z")

</div>

> [@Ronis\_BR](#):
>
> `Pu_k = (eye(n) - K_k*H_k)*Pp_k`

Why doesn’t

```julia
Pu_k = (I - K_k*H_k)*Pp_k

```

work?

---

<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 4, 2018, 7:11pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/88 "2018-08-04T19:11:21Z")

</div>

> [@Seif\_Shebl](#):
>
> Now, if say there is no `eye` but `Matrix{Float64}(I, n, n)`

There is no `eye`, but there is `I`.

---

<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 4, 2018, 7:13pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/89 "2018-08-04T19:13:38Z")

</div>

Excellent! I just did not thought about it 😃 Thanks. Will it work in every operation that uses identity?

I am seeing some problems here, but maybe it is just my ignorance:

```julia
julia> A = zeros(3,3)
3×3 Array{Float64,2}:
 0.0 0.0 0.0
 0.0 0.0 0.0
 0.0 0.0 0.0

julia> (I+A.+1)
3×3 Array{Float64,2}:
 2.0 1.0 1.0
 1.0 2.0 1.0
 1.0 1.0 2.0

julia> (I.+1+A)
┌ Warning: `a::Number + b::AbstractArray` is deprecated, use `a .+ b` instead.
│ caller = top-level scope at none:0
└ @ Core none:0
3×3 Array{Float64,2}:
 2.0 2.0 2.0
 2.0 2.0 2.0
 2.0 2.0 2.0

```

Is it expected?

---

<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 4, 2018, 7:19pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/90 "2018-08-04T19:19:52Z")

</div>

> [@Ronis\_BR](#):
>
> Will it work in every operation that uses identity?

I don’t know! 🙂

Your example caught me by surprise. I’ve simplified it, and I think it’s weird:

```julia
julia> A = ones(2, 2)
2×2 Array{Float64,2}:
 1.0 1.0
 1.0 1.0

julia> A + I
2×2 Array{Float64,2}:
 2.0 1.0
 1.0 2.0

julia> A .+ I
2×2 Array{Float64,2}:
 2.0 2.0
 2.0 2.0

```

---

<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 4, 2018, 7:40pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/91 "2018-08-04T19:40:39Z")

</div>

Yes, that’s known and deprecated in 0.7 to make space for it operating correctly in 1.x.

> [@Why \`eye\` has been deprecated?](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/9):
>
> That’s slated to be fixed; it’s just gotta be deprecated first. One rationale here is simply that the name eye is pretty bad. It’s a literal pun that depends upon knowledge of the English pronunciation of both eye and I and the ability to connect them. Julia is not MATLAB — there’s a [MatlabCompat](https://github.com/MatlabCompat/MatlabCompat.jl) package that would make for a nice place for these kinds of simple aliases.

---

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [August 4, 2018, 8:14pm UTC](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/92 "2018-08-04T20:14:44Z")

</div>

`I` before `E(ye)` except after `RC`

* * *

here’s some cambridge graffiti to get you through the next couple days

 ![eye](https://global.discourse-cdn.com/julialang/original/3X/e/d/ed2a7a84ad3e247cbc96945f7e87370c13658199.jpeg)

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

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