# How can I display all Float64 multidimensional arrays as vectors?

**URL:** <https://discourse.julialang.org/t/how-can-i-display-all-float64-multidimensional-arrays-as-vectors/55787>\
**Category:** General Usage\
**Created:** [February 22, 2021, 5:24pm UTC](https://discourse.julialang.org/t/how-can-i-display-all-float64-multidimensional-arrays-as-vectors/55787 "2021-02-22T17:24:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BridgeBot](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bridgebot/32/21491_2.png) [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Post date:** [February 22, 2021, 5:24pm UTC](https://discourse.julialang.org/t/how-can-i-display-all-float64-multidimensional-arrays-as-vectors/55787/1 "2021-02-22T17:24:40Z")

</div>

How can I display all Float64 multidimensional arrays as vectors? I tried the following but it stackoverflows:

```julia
Base.show(io::IO, x::Array{Float64}) = print(io, vec(x))

```

Probably it is running into a deadlock.

Note that the original poster on Slack cannot see your response here on Discourse. Consider _transcribing the appropriate answer back to Slack_, or pinging the poster here on Discourse so they can _follow this thread_.  
[(Original message :slack:)](https://julialang.slack.com/archives/C6A044SQH/p1614014575142700?thread_ts=1614014575.142700&cid=C6A044SQH) [(More Info)](https://github.com/JuliaCommunity/SlackBridge)

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [February 22, 2021, 5:48pm UTC](https://discourse.julialang.org/t/how-can-i-display-all-float64-multidimensional-arrays-as-vectors/55787/2 "2021-02-22T17:48:05Z")

</div>

Something like this?

```julia
julia> a = rand(2,3,5)
2×3×5 Array{Float64,3}:
[:, :, 1] =
 0.593246 0.122574 0.77908
 0.959088 0.218372 0.0891396

[:, :, 2] =
 0.853314 0.171189 0.313323
 0.195373 0.342458 0.642057

[:, :, 3] =
 0.731841 0.951687 0.316416
 0.640172 0.230144 0.701338

[:, :, 4] =
 0.307028 0.172853 0.990212
 0.872871 0.79285 0.214958

[:, :, 5] =
 0.908459 0.441589 0.0691264
 0.00724457 0.371763 0.968289

julia> a[:]
30-element Array{Float64,1}:
 0.5932464540468072
 0.9590878214304634
 0.12257439090533429
 0.21837219429910104
 0.7790802711397888
 0.08913955642713955
 0.8533144973503481
 0.19537331243008405
 0.1711887305635067
 0.3424581504859132
 0.31332337994899184
 0.6420571681929719
 0.7318410592897324
 ⋮
 0.30702789473558245
 0.8728713274277637
 0.17285287148135597
 0.7928495776848725
 0.9902119213201215
 0.2149577614800653
 0.9084586968143415
 0.007244565168584183
 0.44158904493286766
 0.3717633735726962
 0.06912640765172728
 0.9682886566736622

```

---

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [February 22, 2021, 5:51pm UTC](https://discourse.julialang.org/t/how-can-i-display-all-float64-multidimensional-arrays-as-vectors/55787/3 "2021-02-22T17:51:28Z")

</div>

It is not generally recommendable to rewrite the `show` method for arrays or other basic types (or any other method of functions from Base for types that you didn’t define – see the [advice against “type piracy” in the manual](https://docs.julialang.org/en/v1/manual/style-guide/#Avoid-type-piracy)). But let aside that, the specific problem in this case is that `Array{Float64}` includes `Array{Float64, 1}` (i.e. `Vector{Float64}`), so the method that you defined calls itself forever.

To make it work, you should also define:

```julia
Base.show(io::IO, x::Vector{Float64}) = print(io, x)

```

---

<div class="post-metadata">

**Author:** ![mroavi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mroavi/32/8804_2.png) [@mroavi](https://discourse.julialang.org/u/mroavi)\
**Post date:** [February 22, 2021, 11:37pm UTC](https://discourse.julialang.org/t/how-can-i-display-all-float64-multidimensional-arrays-as-vectors/55787/4 "2021-02-22T23:37:10Z")

</div>

I wasn’t aware of the advice against “type piracy”. I guess that the proper way is to make my own print function. Thank you very much.
