# General Usage

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

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

**Page:** 1014

---

## [User Defined N-ary Types, like Array{T,N}?](https://discourse.julialang.org/t/user-defined-n-ary-types-like-array-t-n/7239)

<div class="topic-metadata">

**Author:** [@ccoffrin](https://discourse.julialang.org/u/ccoffrin)\
**Replies:** 5\
**Last updated:** [November 23, 2017, 1:47am UTC](https://discourse.julialang.org/t/user-defined-n-ary-types-like-array-t-n/7239 "2017-11-23T01:47:01Z")

</div>

Is it possible for users to define types with a parametric integer value? Similar to the Array{T,1}, Array{T,2}, Array{T,3}… types? On a related note, It is possible or users to define types similar to Tuples, which ha…

---

## [Resources for running julia routines in the background 24/7](https://discourse.julialang.org/t/resources-for-running-julia-routines-in-the-background-24-7/7237)

<div class="topic-metadata">

**Author:** [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Replies:** 16\
**Last updated:** [November 22, 2017, 10:52pm UTC](https://discourse.julialang.org/t/resources-for-running-julia-routines-in-the-background-24-7/7237 "2017-11-22T22:52:06Z")

</div>

Hi all, I’d like to write a routine in Julia that will run 24/7, possibly for weeks or months at a time. It will run on one computer which won’t be used for much else other than running the Julia routine. The routine ne…

---

## [Julia using AOT compiler?](https://discourse.julialang.org/t/julia-using-aot-compiler/7232)

<div class="topic-metadata">

**Author:** [@Yifan\_Liu](https://discourse.julialang.org/u/Yifan_Liu)\
**Replies:** 5\
**Last updated:** [November 22, 2017, 11:08am UTC](https://discourse.julialang.org/t/julia-using-aot-compiler/7232 "2017-11-22T11:08:44Z")

</div>

I met a guy from London at a conference recently, and he told me that a new language called Pony might been the next C++ in financial industry. He talked about the AOT (Ahead Of Time) compiler used by Pony, and I guess i…

---

## [Why is v0.7 faster?](https://discourse.julialang.org/t/why-is-v0-7-faster/7244)

<div class="topic-metadata">

**Author:** [@111](https://discourse.julialang.org/u/111)\
**Replies:** 3\
**Last updated:** [November 22, 2017, 2:17pm UTC](https://discourse.julialang.org/t/why-is-v0-7-faster/7244 "2017-11-22T14:17:54Z")

</div>

As we know, there are so many versions of Julia available. I downloaded three of them, and compared the speed of my code using them. I have used the “@profile” macro to find the hotspots, it showed that most of the cpu t…

---

## [How to ensure normalization of generalized eigenvalue problem](https://discourse.julialang.org/t/how-to-ensure-normalization-of-generalized-eigenvalue-problem/7221)

<div class="topic-metadata">

**Author:** [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)\
**Replies:** 5\
**Last updated:** [November 22, 2017, 1:12pm UTC](https://discourse.julialang.org/t/how-to-ensure-normalization-of-generalized-eigenvalue-problem/7221 "2017-11-22T13:12:06Z")

</div>

I have a Hermitian matrix H and a Hermitian and positive definite matrix S. I want the solutions to the following generalized eigenvalue problem Hx=\\lambda Sx and want x to be properly normalized. In scipy, there’s an ei…

---

## [How to insert any string after var into parse("](https://discourse.julialang.org/t/how-to-insert-any-string-after-var-into-parse/7219)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 4\
**Last updated:** [November 22, 2017, 9:08am UTC](https://discourse.julialang.org/t/how-to-insert-any-string-after-var-into-parse/7219 "2017-11-22T09:08:01Z")

</div>

julia\> dzien 5 julia\> kanal 1 julia\> parse(“Sw$dzien$kanal=read(file,"Sw$dzien")”) :(Sw51 = read(file,“Sw5”)) is OK , but I need: :(Sw5\_1 = read(file,“Sw5”)) how to insert string “\_” afeter “5” ? julia\> parse(“S…

---

## [Best way to infer precision for periods (Date)](https://discourse.julialang.org/t/best-way-to-infer-precision-for-periods-date/7165)

<div class="topic-metadata">

**Author:** [@Nosferican](https://discourse.julialang.org/u/Nosferican)\
**Replies:** 2\
**Last updated:** [November 19, 2017, 4:59pm UTC](https://discourse.julialang.org/t/best-way-to-infer-precision-for-periods-date/7165 "2017-11-19T16:59:01Z")

</div>

Given an AbstractVector{T} where T \<: Dates.AbstractTime what would be a good way to infer the precision of the dates/times? For example, consider obj = Date("2000"):Dates.Year(1):Date("2009") when first differencing …

---

## [Memory hog when using include() in a for loop](https://discourse.julialang.org/t/memory-hog-when-using-include-in-a-for-loop/7235)

<div class="topic-metadata">

**Author:** [@jac0320](https://discourse.julialang.org/u/jac0320)\
**Replies:** 0\
**Last updated:** [November 21, 2017, 11:14pm UTC](https://discourse.julialang.org/t/memory-hog-when-using-include-in-a-for-loop/7235 "2017-11-21T23:14:14Z")

</div>

I was trying to load a bunch of JuMP optimization models by including(include/evalfile) a model script in a for loop. A simple example: for i in 1:1000 m = include("o7.jl") end This loop seem to have an accumulating …

---

## [Invertable Dict structure?](https://discourse.julialang.org/t/invertable-dict-structure/7225)

<div class="topic-metadata">

**Author:** [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Replies:** 5\
**Last updated:** [November 21, 2017, 9:34pm UTC](https://discourse.julialang.org/t/invertable-dict-structure/7225 "2017-11-21T21:34:34Z")

</div>

Hello all. I was wondering if there is a “standard” implementation somewhere of an invertable lookup-table structure (i.e. a pair of Dicts, each the inverse of the other). Obviously this is trivial to implement using D…

---

## [Broadcast for vectors of vector like objects](https://discourse.julialang.org/t/broadcast-for-vectors-of-vector-like-objects/7226)

<div class="topic-metadata">

**Author:** [@gasagna](https://discourse.julialang.org/u/gasagna)\
**Replies:** 1\
**Last updated:** [November 21, 2017, 8:47pm UTC](https://discourse.julialang.org/t/broadcast-for-vectors-of-vector-like-objects/7226 "2017-11-21T20:47:09Z")

</div>

Say I have an object Foo for which broadcast is defined struct Foo{T, V\<:AbstractVector{T}} data::V end Foo(data::AbstractVector) = Foo{eltype(data), typeof(data)}(data) @generated function Base.Broadcast.broadca…

---

## [How to calculate the typeof an expression without actually running it?](https://discourse.julialang.org/t/how-to-calculate-the-typeof-an-expression-without-actually-running-it/7211)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 5\
**Last updated:** [November 21, 2017, 8:42pm UTC](https://discourse.julialang.org/t/how-to-calculate-the-typeof-an-expression-without-actually-running-it/7211 "2017-11-21T20:42:46Z")

</div>

Hi, I would like to calculate the typeof an expression without running it. For example: function f(x::Int) y = x+3 if x \> 0 y+=1 else y-=3 end x+y end for example in a macro i am wor…

---

## [Subplot of heatmap in Plots](https://discourse.julialang.org/t/subplot-of-heatmap-in-plots/7207)

<div class="topic-metadata">

**Author:** [@babaq](https://discourse.julialang.org/u/babaq)\
**Replies:** 5\
**Last updated:** [November 21, 2017, 7:54pm UTC](https://discourse.julialang.org/t/subplot-of-heatmap-in-plots/7207 "2017-11-21T19:54:42Z")

</div>

Hi i have a vector of images that need to plot in heatmap, i want to display all of them in an grid subplots, the Plots doc shows that the easiest way is to use heatmap(a,layout=grid(3,3) given a=array(matrix,9). but i…

---

## [Array + scalar deprecation](https://discourse.julialang.org/t/array-scalar-deprecation/7214)

<div class="topic-metadata">

**Author:** [@turtle](https://discourse.julialang.org/u/turtle)\
**Replies:** 6\
**Last updated:** [November 21, 2017, 7:13pm UTC](https://discourse.julialang.org/t/array-scalar-deprecation/7214 "2017-11-21T19:13:41Z")

</div>

The Deprecated section of Julia v0.7.0 Release Notes says: “Automatically broadcasted + and - for array + scalar, scalar - array, and so-on have been deprecated due to inconsistency with linear algebra. Use .+ and .- …

---

## [Recreating julia environments](https://discourse.julialang.org/t/recreating-julia-environments/7224)

<div class="topic-metadata">

**Author:** [@nbren12](https://discourse.julialang.org/u/nbren12)\
**Replies:** 1\
**Last updated:** [November 21, 2017, 6:48pm UTC](https://discourse.julialang.org/t/recreating-julia-environments/7224 "2017-11-21T18:48:19Z")

</div>

It is really easy to install all the third party libraries used in a python project by making an environment.yml file and calling conda env create environment.yml. Is there an equivalent way to do this in julia?

---

## [Is anyone using Emacs on Windows 10?](https://discourse.julialang.org/t/is-anyone-using-emacs-on-windows-10/6617)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 5\
**Last updated:** [November 21, 2017, 4:17pm UTC](https://discourse.julialang.org/t/is-anyone-using-emacs-on-windows-10/6617 "2017-11-21T16:17:41Z")

</div>

If so, would you have some advice on which Emacs to choose and how to set up the environment?

---

## [Match construction of \`Array\` without adding a type parameter](https://discourse.julialang.org/t/match-construction-of-array-without-adding-a-type-parameter/7204)

<div class="topic-metadata">

**Author:** [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Replies:** 2\
**Last updated:** [November 21, 2017, 3:30pm UTC](https://discourse.julialang.org/t/match-construction-of-array-without-adding-a-type-parameter/7204 "2017-11-21T15:30:15Z")

</div>

Array(Float64, 3) in 0.6 should be Array{Float64}(3). If I wanted to make a type that, say, wraps an Array and also stores its length, I can: mutable struct Wrap{A \<: Array{T, 1} where {T}} a::A l::Int64 end If I …

---

## [Bug in @testset with @test\_throws?](https://discourse.julialang.org/t/bug-in-testset-with-test-throws/7213)

<div class="topic-metadata">

**Author:** [@cjb](https://discourse.julialang.org/u/cjb)\
**Replies:** 3\
**Last updated:** [November 21, 2017, 8:01am UTC](https://discourse.julialang.org/t/bug-in-testset-with-test-throws/7213 "2017-11-21T08:01:14Z")

</div>

Writing some tests yesterday I discovered the following weird behavior difference between a test inside and outside a @testset. This seems to be the case when returning a type (in this case Void) from the function being …

---

## [How to check a RemoteChannel is open?](https://discourse.julialang.org/t/how-to-check-a-remotechannel-is-open/3829)

<div class="topic-metadata">

**Author:** [@gasagna](https://discourse.julialang.org/u/gasagna)\
**Replies:** 1\
**Last updated:** [November 21, 2017, 7:54am UTC](https://discourse.julialang.org/t/how-to-check-a-remotechannel-is-open/3829 "2017-11-21T07:54:51Z")

</div>

You can check whether a RemoteChannel object isready, but isopen(::RemoteChannel) seems not to be defined. Basically, I am using a RemoteChannel to transfer jobs to remote workers but these throw an error when the under…

---

## [DateTime constructor that uses Date.value(x) as input](https://discourse.julialang.org/t/datetime-constructor-that-uses-date-value-x-as-input/7212)

<div class="topic-metadata">

**Author:** [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Replies:** 3\
**Last updated:** [November 21, 2017, 5:45am UTC](https://discourse.julialang.org/t/datetime-constructor-that-uses-date-value-x-as-input/7212 "2017-11-21T05:45:32Z")

</div>

Hi all, I’m probably overlooking something obvious, but I can’t work out how to construct a DateTime using as input the Int64 returned by Dates.value(). Note the following: julia\> dt = now() 2017-11-21T15:38:01.282 ju…

---

## [Custom error message from @test macro](https://discourse.julialang.org/t/custom-error-message-from-test-macro/2299)

<div class="topic-metadata">

**Author:** [@marius311](https://discourse.julialang.org/u/marius311)\
**Replies:** 2\
**Last updated:** [November 20, 2017, 11:05pm UTC](https://discourse.julialang.org/t/custom-error-message-from-test-macro/2299 "2017-11-20T23:05:33Z")

</div>

Is there a way to specify a custom error message for the @test macro to print if it fails? Something like, @test a==b "a didn't equal b" The problem is that e.g. if a and b are large vectors then if the test fails they…

---

## [Reclaim parametric method syntax](https://discourse.julialang.org/t/reclaim-parametric-method-syntax/7145)

<div class="topic-metadata">

**Author:** [@lstagner](https://discourse.julialang.org/u/lstagner)\
**Replies:** 6\
**Last updated:** [November 20, 2017, 10:24pm UTC](https://discourse.julialang.org/t/reclaim-parametric-method-syntax/7145 "2017-11-20T22:24:39Z")

</div>

Since the new where syntax has depreciated the parametric method syntax that means it can be used for something else. I propose the following foo{T::Number}(x::T,y::T} = ... as syntactic sugar for let T=Number foo…

---

## [Making broadcast work for own type](https://discourse.julialang.org/t/making-broadcast-work-for-own-type/7195)

<div class="topic-metadata">

**Author:** [@Ward9250](https://discourse.julialang.org/u/Ward9250)\
**Replies:** 4\
**Last updated:** [November 20, 2017, 6:31pm UTC](https://discourse.julialang.org/t/making-broadcast-work-for-own-type/7195 "2017-11-20T18:31:37Z")

</div>

If I have my own type, which can be indexed like an array, and has a length. How can I get broadcast to work with it as an array-like type instead of a scalar? I can only find useage guides in the language manual for vec…

---

## [Does ccall still work in 0.6.1?](https://discourse.julialang.org/t/does-ccall-still-work-in-0-6-1/7190)

<div class="topic-metadata">

**Author:** [@bgavin](https://discourse.julialang.org/u/bgavin)\
**Replies:** 3\
**Last updated:** [November 20, 2017, 3:13pm UTC](https://discourse.julialang.org/t/does-ccall-still-work-in-0-6-1/7190 "2017-11-20T15:13:32Z")

</div>

I’m trying to use ccall in 0.6.1, and I receive an error telling me that it is undefined: julia\> ccall ERROR: UndefVarError: ccall not defined I’m not even sure where to start with this. Is it now necessary to impor…

---

## [\`broadcast\` behaves differently for tuples and arrays](https://discourse.julialang.org/t/broadcast-behaves-differently-for-tuples-and-arrays/7167)

<div class="topic-metadata">

**Author:** [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Replies:** 4\
**Last updated:** [November 20, 2017, 2:15pm UTC](https://discourse.julialang.org/t/broadcast-behaves-differently-for-tuples-and-arrays/7167 "2017-11-20T14:15:48Z")

</div>

I was surprised to find that broadcast behaves differently for tuples and arrays: julia\> ((x,y) -\> @show x,y).((:a,),\[1,2\]); (x, y) = (:a, 1) (x, y) = (:a, 2) julia\> ((x,y) -\> @show x,y).((:a,),(1,2)); (x, y) = (:a, 1)…

---

## [Reinterpret on primitive type](https://discourse.julialang.org/t/reinterpret-on-primitive-type/7187)

<div class="topic-metadata">

**Author:** [@ScottPJones](https://discourse.julialang.org/u/ScottPJones)\
**Replies:** 0\
**Last updated:** [November 20, 2017, 1:56pm UTC](https://discourse.julialang.org/t/reinterpret-on-primitive-type/7187 "2017-11-20T13:56:24Z")

</div>

I ran into another issue dealing with reinterpret on bits (primitive) types. julia\> primitive type Foo 64 end julia\> struct Bar ; data::NTuple{8,UInt8} ; end julia\> reinterpret(Foo, 0x123456789abcdef0) Foo(0x1234567…

---

## [Importing a package to all the submodules of a module](https://discourse.julialang.org/t/importing-a-package-to-all-the-submodules-of-a-module/7148)

<div class="topic-metadata">

**Author:** [@v-i-s-h](https://discourse.julialang.org/u/v-i-s-h)\
**Replies:** 6\
**Last updated:** [November 20, 2017, 1:45pm UTC](https://discourse.julialang.org/t/importing-a-package-to-all-the-submodules-of-a-module/7148 "2017-11-20T13:45:10Z")

</div>

I want to import a common package to all the submodules inside my module. How to do this? Example module X1 using Distributions abstract type abstract\_Y end # How to make both 'abstract\_Y' and 'Distribution…

---

## [What is the reason for a zero-dimensional array?](https://discourse.julialang.org/t/what-is-the-reason-for-a-zero-dimensional-array/7175)

<div class="topic-metadata">

**Author:** [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Replies:** 2\
**Last updated:** [November 20, 2017, 8:23am UTC](https://discourse.julialang.org/t/what-is-the-reason-for-a-zero-dimensional-array/7175 "2017-11-20T08:23:49Z")

</div>

Consider: foo(v) = \[x + 5 for x in v\] I think that in most cases if foo is called with a scalar, one wants a scalar value back, equivalent to foo(v) = v + 5. However, this function results in julia\> foo(5) 0-dimension…

---

## [JLD2 seems slow at write operations compared to serialize and HDF5](https://discourse.julialang.org/t/jld2-seems-slow-at-write-operations-compared-to-serialize-and-hdf5/7177)

<div class="topic-metadata">

**Author:** [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Replies:** 3\
**Last updated:** [November 20, 2017, 4:31am UTC](https://discourse.julialang.org/t/jld2-seems-slow-at-write-operations-compared-to-serialize-and-hdf5/7177 "2017-11-20T04:31:46Z")

</div>

EDITED: Thanks to Elrod for politely pointing out a very obvious mistake in my code. I’m leaving the question open as even with the fix JLD2 is still significantly slower than HDF5. Hi all, I asked a question on StackO…

---

## [Adding remote workers on different domains](https://discourse.julialang.org/t/adding-remote-workers-on-different-domains/7176)

<div class="topic-metadata">

**Author:** [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Replies:** 0\
**Last updated:** [November 20, 2017, 3:33am UTC](https://discourse.julialang.org/t/adding-remote-workers-on-different-domains/7176 "2017-11-20T03:33:32Z")

</div>

I have a problem adding remote workers. There are servers on the same domain as master process. There are servers on a different domain to the master process. I can successfully add workers on local machine + workers …

---

## [How to Bypass the World Age Problem](https://discourse.julialang.org/t/how-to-bypass-the-world-age-problem/7012)

<div class="topic-metadata">

**Author:** [@cortner](https://discourse.julialang.org/u/cortner)\
**Replies:** 30\
**Last updated:** [November 19, 2017, 9:58pm UTC](https://discourse.julialang.org/t/how-to-bypass-the-world-age-problem/7012 "2017-11-19T21:58:02Z")

</div>

I finally managed to move some of my codes to v0.6. The World Age problem was a shock as it clashes with one of the main design principles of my code. I’ve read the documentation, and all the discourse topics I could fin…

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

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