# General Usage

**URL:** https://discourse.julialang.org/c/usage/6.md?page=953

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 954

---

## [Package modification, has no effect](https://discourse.julialang.org/t/package-modification-has-no-effect/13494)

<div class="topic-metadata">

**Author:** [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Replies:** 2\
**Last updated:** [August 15, 2018, 11:23pm UTC](https://discourse.julialang.org/t/package-modification-has-no-effect/13494 "2018-08-15T23:23:46Z")

</div>

I developed a package on the local machine and used the package in some scripts to process data. I modified the package but when I run the Julia script nothing has been changed. Only when I changed the name of the funct…

---

## [Destructuring a Union{...}](https://discourse.julialang.org/t/destructuring-a-union/13526)

<div class="topic-metadata">

**Author:** [@jamii](https://discourse.julialang.org/u/jamii)\
**Replies:** 2\
**Last updated:** [August 15, 2018, 10:33pm UTC](https://discourse.julialang.org/t/destructuring-a-union/13526 "2018-08-15T22:33:36Z")

</div>

What is the idiomatic way to take apart a Union type? The obvious structural matching doesn’t do what I expected: julia\> f1(::Type{Union{X, Int64}}) where {X} = X f1 (generic function with 1 method) julia\> f1(Union{Int…

---

## [0.7: Changes in method specificity](https://discourse.julialang.org/t/0-7-changes-in-method-specificity/13519)

<div class="topic-metadata">

**Author:** [@galenlynch](https://discourse.julialang.org/u/galenlynch)\
**Replies:** 0\
**Last updated:** [August 15, 2018, 7:00pm UTC](https://discourse.julialang.org/t/0-7-changes-in-method-specificity/13519 "2018-08-15T19:00:21Z")

</div>

in 0.6, the following code is fine: julia\> foo(::AbstractVector{E}, ::NTuple{2, E}) where E = true # A julia\> foo(::AbstractVector{E}, ::NTuple{2, \<:Any}) where E = false # B julia\> foo(\[1, 2\], (3, 4)) true However, in…

---

## [Is it possible to register a 0.7+ only package at the moment?](https://discourse.julialang.org/t/is-it-possible-to-register-a-0-7-only-package-at-the-moment/13517)

<div class="topic-metadata">

**Author:** [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Replies:** 1\
**Last updated:** [August 15, 2018, 6:19pm UTC](https://discourse.julialang.org/t/is-it-possible-to-register-a-0-7-only-package-at-the-moment/13517 "2018-08-15T18:19:40Z")

</div>

Is it possible to register a 0.7+ only package (since it was developed after v1.0) at the moment? How?

---

## [How to convert user-defined struct{T} to struct{Any} without redundant copy?](https://discourse.julialang.org/t/how-to-convert-user-defined-struct-t-to-struct-any-without-redundant-copy/13450)

<div class="topic-metadata">

**Author:** [@thautwarm](https://discourse.julialang.org/u/thautwarm)\
**Replies:** 7\
**Last updated:** [August 15, 2018, 12:32pm UTC](https://discourse.julialang.org/t/how-to-convert-user-defined-struct-t-to-struct-any-without-redundant-copy/13450 "2018-08-15T12:32:43Z")

</div>

x = Int\[1\] isimmuatble(x) # =\> false, so \`===\` performs comparing by reference, which checks if lhs and rsh are same. x === convert(Vector{Any}, x) # =\> true What if I want to do such stuffs on custom structure struct…

---

## [Markov chain as an iterable](https://discourse.julialang.org/t/markov-chain-as-an-iterable/13495)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 0\
**Last updated:** [August 15, 2018, 12:18pm UTC](https://discourse.julialang.org/t/markov-chain-as-an-iterable/13495 "2018-08-15T12:18:59Z")

</div>

I want to provide an iteration interface for a Markov chain, eg MWE: using Random struct RandomWalk{G, T} σ::T rng::G end RandomWalk(σ) = RandomWalk(σ, Random.GLOBAL\_RNG) Base.iterate(rw::RandomWalk, x = 0.0)…

---

## [Corners of an image](https://discourse.julialang.org/t/corners-of-an-image/13465)

<div class="topic-metadata">

**Author:** [@microlifecc](https://discourse.julialang.org/u/microlifecc)\
**Replies:** 3\
**Last updated:** [August 15, 2018, 8:26am UTC](https://discourse.julialang.org/t/corners-of-an-image/13465 "2018-08-15T08:26:05Z")

</div>

Hi Guys! I am writing some code for feature detection. I was wondering if there is a way to find the corners of an image, for instance the actual image provided to us is not necessarily a rectangle(maybe a parallelogram…

---

## [Taking greater advantage of let blocks](https://discourse.julialang.org/t/taking-greater-advantage-of-let-blocks/13471)

<div class="topic-metadata">

**Author:** [@Mason](https://discourse.julialang.org/u/Mason)\
**Replies:** 1\
**Last updated:** [August 15, 2018, 6:13am UTC](https://discourse.julialang.org/t/taking-greater-advantage-of-let-blocks/13471 "2018-08-15T06:13:43Z")

</div>

I’d like to make greater use of let blocks for testing out code, especially code where I’m defining types so that I can make definitions and play with them to see if what I’m doing works without polluting my namespace an…

---

## [How to read Julia docs with readthedocs?](https://discourse.julialang.org/t/how-to-read-julia-docs-with-readthedocs/13475)

<div class="topic-metadata">

**Author:** [@LeoK987](https://discourse.julialang.org/u/LeoK987)\
**Replies:** 0\
**Last updated:** [August 14, 2018, 11:59pm UTC](https://discourse.julialang.org/t/how-to-read-julia-docs-with-readthedocs/13475 "2018-08-14T23:59:18Z")

</div>

It seems in the past that Julia docs were directly presented through readthedocs, but now it’s only an html file. I like the save-to-epub feature from readthedocs. How can I easily use it to read julia docs?

---

## [Deleting methods in julia](https://discourse.julialang.org/t/deleting-methods-in-julia/13455)

<div class="topic-metadata">

**Author:** [@mwess](https://discourse.julialang.org/u/mwess)\
**Replies:** 7\
**Last updated:** [August 14, 2018, 11:41pm UTC](https://discourse.julialang.org/t/deleting-methods-in-julia/13455 "2018-08-14T23:41:45Z")

</div>

Hi all, I am a relative newcomer to this version of Julia, so sorry for the (maybe) obvious question. I have the problem, that I define multiple methods of a function in an interactive session (IJulia to be precise) in…

---

## [jl\_load update for 1.0](https://discourse.julialang.org/t/jl-load-update-for-1-0/13472)

<div class="topic-metadata">

**Author:** [@kharazity](https://discourse.julialang.org/u/kharazity)\
**Replies:** 0\
**Last updated:** [August 14, 2018, 11:29pm UTC](https://discourse.julialang.org/t/jl-load-update-for-1-0/13472 "2018-08-14T23:29:10Z")

</div>

I’m currently writing code in C++ that calls a module I wrote in Julia. It seems that since Julia 0.6 there’s been a change to the way jl\_load is treated. It initially took one argument, namely the filename (or path to f…

---

## [What's the best way to blow away the ~/.julia directory?](https://discourse.julialang.org/t/whats-the-best-way-to-blow-away-the-julia-directory/13470)

<div class="topic-metadata">

**Author:** [@NHDaly](https://discourse.julialang.org/u/NHDaly)\
**Replies:** 4\
**Last updated:** [August 14, 2018, 10:54pm UTC](https://discourse.julialang.org/t/whats-the-best-way-to-blow-away-the-julia-directory/13470 "2018-08-14T22:54:19Z")

</div>

I was told that there is something “wrong with my Manifest.” Two questions: What all would I need to delete to clear out all Pkg related files for julia 1.0 or 0.7? (Ideally, just for one and not the other.) Or, co…

---

## [Constructors with explicit and implicit types](https://discourse.julialang.org/t/constructors-with-explicit-and-implicit-types/13467)

<div class="topic-metadata">

**Author:** [@rakeshvar](https://discourse.julialang.org/u/rakeshvar)\
**Replies:** 4\
**Last updated:** [August 14, 2018, 10:04pm UTC](https://discourse.julialang.org/t/constructors-with-explicit-and-implicit-types/13467 "2018-08-14T22:04:27Z")

</div>

I am implementing functor types. A simple example is the absolute value functor. (There is a scaling just to make the problem worthwhile.) abstract type AbFun{F\<:Real} end struct Magnitude{F} \<: AbFun{F} scale::F e…

---

## [Functions inside of struct block](https://discourse.julialang.org/t/functions-inside-of-struct-block/13462)

<div class="topic-metadata">

**Author:** [@galenlynch](https://discourse.julialang.org/u/galenlynch)\
**Replies:** 3\
**Last updated:** [August 14, 2018, 9:14pm UTC](https://discourse.julialang.org/t/functions-inside-of-struct-block/13462 "2018-08-14T21:14:28Z")

</div>

I noticed this code in Pkg, and the the utility of the copy function inside the struct block eludes me even though it’s commented: struct VersionSet intervals::Vector{VersionInterval} VersionSet(intervals::Vecto…

---

## [JULIA\_PROJECT and julia --project](https://discourse.julialang.org/t/julia-project-and-julia-project/13458)

<div class="topic-metadata">

**Author:** [@danielmatz](https://discourse.julialang.org/u/danielmatz)\
**Replies:** 4\
**Last updated:** [August 14, 2018, 7:46pm UTC](https://discourse.julialang.org/t/julia-project-and-julia-project/13458 "2018-08-14T19:46:12Z")

</div>

I was just reading the documentation for Pkg.activate. Using the JULIA\_PROJECT environment variable works as expected, and Julia activates the specified project. But the --project command line argument does not seem to…

---

## [Strange performance with Adjoint structures](https://discourse.julialang.org/t/strange-performance-with-adjoint-structures/13397)

<div class="topic-metadata">

**Author:** [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Replies:** 7\
**Last updated:** [August 14, 2018, 6:12pm UTC](https://discourse.julialang.org/t/strange-performance-with-adjoint-structures/13397 "2018-08-14T18:12:35Z")

</div>

julia\> a = sprand(Int16, 10000, 10000, 0.2); julia\> y = a'; julia\> @time y\[3,:\]; 0.001126 seconds (28 allocations: 41.156 KiB) julia\> @time y.parent\[:,3\]; 0.000013 seconds (7 allocations: 19.625 KiB) julia\> y\[3,:…

---

## [Difference of type covariant in between struct and function](https://discourse.julialang.org/t/difference-of-type-covariant-in-between-struct-and-function/13453)

<div class="topic-metadata">

**Author:** [@shipengcheng1230](https://discourse.julialang.org/u/shipengcheng1230)\
**Replies:** 3\
**Last updated:** [August 14, 2018, 5:56pm UTC](https://discourse.julialang.org/t/difference-of-type-covariant-in-between-struct-and-function/13453 "2018-08-14T17:56:04Z")

</div>

Hello, let’s define a few type hierarchy (on Julia v0.7): julia\> abstract type T end julia\> abstract type T1 \<: T end julia\> abstract type T2 \<: T end For the function, it works: julia\> foo2(x::X) where {X\<:Type{\<:T…

---

## [Reading data .mat files and merge them](https://discourse.julialang.org/t/reading-data-mat-files-and-merge-them/13375)

<div class="topic-metadata">

**Author:** [@jayce\_ram](https://discourse.julialang.org/u/jayce_ram)\
**Replies:** 8\
**Last updated:** [August 14, 2018, 3:56pm UTC](https://discourse.julialang.org/t/reading-data-mat-files-and-merge-them/13375 "2018-08-14T15:56:26Z")

</div>

I have multiples files .mat that are organized at the same way. They look like that: # file name : Case\_1 # Created by Octave 4.2.0 # matrix # other comments 1 2 3 4 5 6 # vector 0.2 0.3 0.4 And I’d like to get the…

---

## [I cannot update to the latest Mux.jl](https://discourse.julialang.org/t/i-cannot-update-to-the-latest-mux-jl/13443)

<div class="topic-metadata">

**Author:** [@Iagoba\_Apellaniz](https://discourse.julialang.org/u/Iagoba_Apellaniz)\
**Replies:** 1\
**Last updated:** [August 14, 2018, 2:19pm UTC](https://discourse.julialang.org/t/i-cannot-update-to-the-latest-mux-jl/13443 "2018-08-14T14:19:59Z")

</div>

I don’t know exactly why this happens. (v1.0) pkg\> st Status \`~/.julia/environments/v1.0/Project.toml\` ··· \[a975b10e\] Mux v0.4.0 (v1.0) pkg\> up Updating registry at \`~/.julia/registries/General\` Updating gi…

---

## [rowvals of transposed matrices in 0.7](https://discourse.julialang.org/t/rowvals-of-transposed-matrices-in-0-7/13391)

<div class="topic-metadata">

**Author:** [@FHulsemann](https://discourse.julialang.org/u/FHulsemann)\
**Replies:** 2\
**Last updated:** [August 14, 2018, 1:14pm UTC](https://discourse.julialang.org/t/rowvals-of-transposed-matrices-in-0-7/13391 "2018-08-14T13:14:11Z")

</div>

Dear Julia pros, I am trying to migrate an existing application, that works just fine in 0.6.2, to 0.7 (binary installation on Linux 64bit) and I am having the following problem: When calling SparseArrays.rowvals on the…

---

## [Instant flush after newlines](https://discourse.julialang.org/t/instant-flush-after-newlines/13435)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 0\
**Last updated:** [August 14, 2018, 11:54am UTC](https://discourse.julialang.org/t/instant-flush-after-newlines/13435 "2018-08-14T11:54:36Z")

</div>

Is it possible to pass an option to open("/path/to/file", "w") so that the writes occur instantaneously after each newline (without me having to flush it?

---

## [Calculate FFT on GPU for every row of a 2D array](https://discourse.julialang.org/t/calculate-fft-on-gpu-for-every-row-of-a-2d-array/13042)

<div class="topic-metadata">

**Author:** [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Replies:** 2\
**Last updated:** [August 14, 2018, 11:18am UTC](https://discourse.julialang.org/t/calculate-fft-on-gpu-for-every-row-of-a-2d-array/13042 "2018-08-14T11:18:44Z")

</div>

Hello, I have a 2D array and I want to calculate FFT for every raw of this array. I try to do it on GPU using CuArrays, but my GPU version of the code is too slow because of multiple memory allocations that I do not kno…

---

## [Julia 0.6.4 creating ~/.julia/lib/v0.6 even when external JULIA\_PKGDIR is specified](https://discourse.julialang.org/t/julia-0-6-4-creating-julia-lib-v0-6-even-when-external-julia-pkgdir-is-specified/13432)

<div class="topic-metadata">

**Author:** [@v-i-s-h](https://discourse.julialang.org/u/v-i-s-h)\
**Replies:** 0\
**Last updated:** [August 14, 2018, 11:13am UTC](https://discourse.julialang.org/t/julia-0-6-4-creating-julia-lib-v0-6-even-when-external-julia-pkgdir-is-specified/13432 "2018-08-14T11:13:49Z")

</div>

I want to use both Julia 0.6.4 and Julia 1.0 in my Linux system (Elementary OS 0.4.1, based on Ubuntu 16.04). In order to isolate 0.6 from 1.0, I created a dir ~/.julia-0.6/ and modified {JULIA\_DIR}/etc/julia/juliarc.jl …

---

## [Pkg.add() refuses to use the required version](https://discourse.julialang.org/t/pkg-add-refuses-to-use-the-required-version/13420)

<div class="topic-metadata">

**Author:** [@MartinOtter](https://discourse.julialang.org/u/MartinOtter)\
**Replies:** 9\
**Last updated:** [August 14, 2018, 11:11am UTC](https://discourse.julialang.org/t/pkg-add-refuses-to-use-the-required-version/13420 "2018-08-14T11:11:58Z")

</div>

I am using Julia 0.7. I have a clone of ModiaMath (version 0.2.1 for Julia 0.7) in HOME/.julia/dev and would like that this version is used in Modia (for Julia 0.7). When doing the following: \]activate HOME/.julia/dev/M…

---

## [Terminal width: REPL and/or script](https://discourse.julialang.org/t/terminal-width-repl-and-or-script/13427)

<div class="topic-metadata">

**Author:** [@alee](https://discourse.julialang.org/u/alee)\
**Replies:** 2\
**Last updated:** [August 14, 2018, 10:11am UTC](https://discourse.julialang.org/t/terminal-width-repl-and-or-script/13427 "2018-08-14T10:11:14Z")

</div>

Can I get the terminal width from julia in a REPL/script agnostic manner? In the REPL, this works: terminalWidth = REPL.Terminals.width(Base.active\_repl.t) although maybe it’s not the best way to do it. When running …

---

## [Questions about memory allocation](https://discourse.julialang.org/t/questions-about-memory-allocation/13416)

<div class="topic-metadata">

**Author:** [@LeoK987](https://discourse.julialang.org/u/LeoK987)\
**Replies:** 2\
**Last updated:** [August 14, 2018, 8:21am UTC](https://discourse.julialang.org/t/questions-about-memory-allocation/13416 "2018-08-14T08:21:09Z")

</div>

I ran julia with --track-allocation=user, and found some large memory allocations that I can’t understand. Can anyone please help explain? What is going on with the for statement here: - function AtomValues(s…

---

## [slow performance of eig](https://discourse.julialang.org/t/slow-performance-of-eig/13074)

<div class="topic-metadata">

**Author:** [@itzui](https://discourse.julialang.org/u/itzui)\
**Replies:** 14\
**Last updated:** [August 14, 2018, 5:39am UTC](https://discourse.julialang.org/t/slow-performance-of-eig/13074 "2018-08-14T05:39:40Z")

</div>

Hello, the performance of the determination of the eigenvalues and the eigenvector for small complex matrices in Julia seems for me quite slow. If I use the following code N = 100000 dim = 3 function eigen() for i …

---

## [DataFrames failed to install due to CodecZlib build issue (Julia 0.7 on Windows 10)](https://discourse.julialang.org/t/dataframes-failed-to-install-due-to-codeczlib-build-issue-julia-0-7-on-windows-10/13414)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 2\
**Last updated:** [August 14, 2018, 3:00am UTC](https://discourse.julialang.org/t/dataframes-failed-to-install-due-to-codeczlib-build-issue-julia-0-7-on-windows-10/13414 "2018-08-14T03:00:12Z")

</div>

I just installed 0.7 on Windows 10. Adding DataFrames failed due to CodecZlib. I’m in a corporate environment and I don’t have admin privilege. Is that why? (v0.7) pkg\> add DataFrames Resolving package versions... …

---

## [Is there a faster bisection root solver (that uses atol)?](https://discourse.julialang.org/t/is-there-a-faster-bisection-root-solver-that-uses-atol/12658)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 22\
**Last updated:** [August 13, 2018, 9:26pm UTC](https://discourse.julialang.org/t/is-there-a-faster-bisection-root-solver-that-uses-atol/12658 "2018-08-13T21:26:59Z")

</div>

I have a code that uses bisection root-solvers – but with function calls that take a while. Does anyone have an alternative to the Roots.jl version that accepts atol and is as performant as the original (besides the obv…

---

## [\`@btime 5+2\`](https://discourse.julialang.org/t/btime-5-2/13402)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 2\
**Last updated:** [August 13, 2018, 8:50pm UTC](https://discourse.julialang.org/t/btime-5-2/13402 "2018-08-13T20:50:08Z")

</div>

@btime 5+2 reports a 100x speed up in Julia 1.0 vs. Julia 0.6.4. This is too good to be true. Perhaps constant propagation is affecting the result. Am I misusing @btime here? What would be the correct way to measure the…

[Previous page](https://discourse.julialang.org/c/usage/6.md?page=952)

[Next page](https://discourse.julialang.org/c/usage/6.md?page=954)
