# General Usage

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

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

**Page:** 933

---

## [On array comprehensions with \`if\` statements](https://discourse.julialang.org/t/on-array-comprehensions-with-if-statements/15866)

<div class="topic-metadata">

**Author:** [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Replies:** 6\
**Last updated:** [October 4, 2018, 2:21pm UTC](https://discourse.julialang.org/t/on-array-comprehensions-with-if-statements/15866 "2018-10-04T14:21:14Z")

</div>

Array comprehensions are great to construct multidimensional arrays: The default case julia\> \[x \* y for x in 1:10, y in 1:10 \] 10×10 Array{Int64,2}: 1 2 3 4 5 6 7 8 9 10 2 4 6 8 10 12 1…

---

## [Error while deserializing a socket](https://discourse.julialang.org/t/error-while-deserializing-a-socket/15879)

<div class="topic-metadata">

**Author:** [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)\
**Replies:** 0\
**Last updated:** [October 4, 2018, 1:47pm UTC](https://discourse.julialang.org/t/error-while-deserializing-a-socket/15879 "2018-10-04T13:47:44Z")

</div>

Sorry I don’t have a minimal example for this, I basically try to make two Julia instances connect to each other and exchange data (via listenany, connect, accept, serialize, deserialize, etc). The part that throw me an…

---

## [Push! to vector of DataFrames](https://discourse.julialang.org/t/push-to-vector-of-dataframes/15854)

<div class="topic-metadata">

**Author:** [@natemcintosh](https://discourse.julialang.org/u/natemcintosh)\
**Replies:** 2\
**Last updated:** [October 4, 2018, 1:37pm UTC](https://discourse.julialang.org/t/push-to-vector-of-dataframes/15854 "2018-10-04T13:37:43Z")

</div>

If I create an empty vector to hold DataFrames: vecOfDFs = Vector{DataFrame}\[\] (is that an ok way to do it? Are there better ways? ) And then I use push!(vecOfDFs, myNewDF) to add my myNewDF to vecOfDFs I get the erro…

---

## [Calling julia functions with keyword arguments using macro](https://discourse.julialang.org/t/calling-julia-functions-with-keyword-arguments-using-macro/15868)

<div class="topic-metadata">

**Author:** [@skam](https://discourse.julialang.org/u/skam)\
**Replies:** 2\
**Last updated:** [October 4, 2018, 12:25pm UTC](https://discourse.julialang.org/t/calling-julia-functions-with-keyword-arguments-using-macro/15868 "2018-10-04T12:25:30Z")

</div>

I’m trying to write a macro which calls functions with keyword arguments (for using in JuMP NLexpressions and mappings. This functions are just functions for accessing a database. So they do not represent a mathematical …

---

## [Deprecated syntax parametric method syntax with type of output](https://discourse.julialang.org/t/deprecated-syntax-parametric-method-syntax-with-type-of-output/15867)

<div class="topic-metadata">

**Author:** [@FemtoTrader](https://discourse.julialang.org/u/FemtoTrader)\
**Replies:** 3\
**Last updated:** [October 4, 2018, 12:00pm UTC](https://discourse.julialang.org/t/deprecated-syntax-parametric-method-syntax-with-type-of-output/15867 "2018-10-04T12:00:45Z")

</div>

Hello, I’m fixing some Julia 0.6 code to Julia 0.7/1.0 short{T\<:Real}(qty::T)::T = qty I was trying julia\> short(qty::T)::T where {T\<:Real} = qty ERROR: UndefVarError: T not defined Stacktrace: \[1\] top-level scope a…

---

## [How to switch between PrettyContext and CompactContext in JSON package?](https://discourse.julialang.org/t/how-to-switch-between-prettycontext-and-compactcontext-in-json-package/15857)

<div class="topic-metadata">

**Author:** [@YongHee-Kim](https://discourse.julialang.org/u/YongHee-Kim)\
**Replies:** 0\
**Last updated:** [October 4, 2018, 2:26am UTC](https://discourse.julialang.org/t/how-to-switch-between-prettycontext-and-compactcontext-in-json-package/15857 "2018-10-04T02:26:29Z")

</div>

I want to write .json from DataFrame But I want to write some element to be indented, and some are not indented Here is a minimal example using DataFrames using JSON function JSON.show\_json(io::SC, s::CS, df::DataFra…

---

## [KeyError: key "git-tree-sha1" not found](https://discourse.julialang.org/t/keyerror-key-git-tree-sha1-not-found/15817)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 4\
**Last updated:** [October 4, 2018, 2:07am UTC](https://discourse.julialang.org/t/keyerror-key-git-tree-sha1-not-found/15817 "2018-10-04T02:07:48Z")

</div>

I’m trying to update my packages in 1.0.1 and I keep getting the error (v1.0) pkg\> up Updating registry at \`~/.julia/registries/General\` Updating git-repo \`https://github.com/JuliaRegistries/General.git\` Resolving …

---

## [Parallel use of Julia 0.7 and 1.0](https://discourse.julialang.org/t/parallel-use-of-julia-0-7-and-1-0/15785)

<div class="topic-metadata">

**Author:** [@Moses](https://discourse.julialang.org/u/Moses)\
**Replies:** 7\
**Last updated:** [October 4, 2018, 1:07am UTC](https://discourse.julialang.org/t/parallel-use-of-julia-0-7-and-1-0/15785 "2018-10-04T01:07:34Z")

</div>

Hi. Is there any way to use versions 0.7.0 and 1.0.0/1.0.1 on the same computer (Windows 8.1 Pro with Atom/Juno) in parallel? I have some old code of 0.6, which I need to transfer, so I need version 0.7 for the depreca…

---

## [How to load \`CuArray\` depends on available devices?](https://discourse.julialang.org/t/how-to-load-cuarray-depends-on-available-devices/15851)

<div class="topic-metadata">

**Author:** [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Replies:** 0\
**Last updated:** [October 3, 2018, 10:37pm UTC](https://discourse.julialang.org/t/how-to-load-cuarray-depends-on-available-devices/15851 "2018-10-03T22:37:29Z")

</div>

Say I have a package ExamplePackage, and it will use CuArray if we have a usable GPU device, but it will just use CPU if we don’t. Then how do I add CuArray as my dependency with Pkg3?

---

## [Macro for \`do\` block boilerplate?](https://discourse.julialang.org/t/macro-for-do-block-boilerplate/15847)

<div class="topic-metadata">

**Author:** [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Replies:** 0\
**Last updated:** [October 3, 2018, 9:32pm UTC](https://discourse.julialang.org/t/macro-for-do-block-boilerplate/15847 "2018-10-03T21:32:23Z")

</div>

I often am making types that need a open / close pair, so I usually add a method allowing them to be used in a do block that automatically clean up after itself. I’m thinking about wrapping this boilerplate into a @doabl…

---

## [Numerical differentiation and Integration](https://discourse.julialang.org/t/numerical-differentiation-and-integration/15838)

<div class="topic-metadata">

**Author:** [@Ferran\_Mazzanti](https://discourse.julialang.org/u/Ferran_Mazzanti)\
**Replies:** 4\
**Last updated:** [October 3, 2018, 7:31pm UTC](https://discourse.julialang.org/t/numerical-differentiation-and-integration/15838 "2018-10-03T19:31:27Z")

</div>

Hi folks, I was wondering if somebody could recommend the best(?) package for numerical differentiation and integration. I’m mostly interested in numerics, which means that I usually have a set of points on a grid and w…

---

## [DifferentialEquations.jl plotting multiple components with vars = \[(f, a, b) \] form](https://discourse.julialang.org/t/differentialequations-jl-plotting-multiple-components-with-vars-f-a-b-form/15799)

<div class="topic-metadata">

**Author:** [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)\
**Replies:** 4\
**Last updated:** [October 3, 2018, 6:09pm UTC](https://discourse.julialang.org/t/differentialequations-jl-plotting-multiple-components-with-vars-f-a-b-form/15799 "2018-10-03T18:09:50Z")

</div>

First off, I should say I am very new to using DifferentialEquations, but I have not seen this question addressed anywhere else :slight\_smile: . I am trying to plot the solution to a second order ODE, particularly the s…

---

## [Random not defined](https://discourse.julialang.org/t/random-not-defined/15835)

<div class="topic-metadata">

**Author:** [@joekang](https://discourse.julialang.org/u/joekang)\
**Replies:** 2\
**Last updated:** [October 3, 2018, 4:44pm UTC](https://discourse.julialang.org/t/random-not-defined/15835 "2018-10-03T16:44:35Z")

</div>

Hello Alex, I have a hard to run Random.seed!(1234) in Julia 1.0.0. Below is the error message I get: julia\> Random.seed!(1) ERROR: UndefVarError: Random not defined Stacktrace: \[1\] top-level scope at none:0 Any he…

---

## [Why do these SGE procs fail to launch?](https://discourse.julialang.org/t/why-do-these-sge-procs-fail-to-launch/15558)

<div class="topic-metadata">

**Author:** [@aaraun](https://discourse.julialang.org/u/aaraun)\
**Replies:** 1\
**Last updated:** [October 3, 2018, 1:50pm UTC](https://discourse.julialang.org/t/why-do-these-sge-procs-fail-to-launch/15558 "2018-10-03T13:50:07Z")

</div>

julia\> using Distributed, ClusterManagers julia\> addprocs(SGEManager(1,""), qsub\_env="",res\_list="") Error launching workers MethodError(iterate, (Base.ProcessChain(Base.Process\[Process(\`echo 'cd /lmb/home/alewis && /lm…

---

## [K-Mean Clustering Issue](https://discourse.julialang.org/t/k-mean-clustering-issue/15812)

<div class="topic-metadata">

**Author:** [@Ajaychat3](https://discourse.julialang.org/u/Ajaychat3)\
**Replies:** 7\
**Last updated:** [October 3, 2018, 1:11pm UTC](https://discourse.julialang.org/t/k-mean-clustering-issue/15812 "2018-10-03T13:11:25Z")

</div>

I have trying to learn kmean clustering using the Clustering package and the example code given on “ClusteringSolutions” on the iris data. After reading CSV file, when I attempt to initiate kmean clustering using the ex…

---

## [== for custom type and promote\_rule](https://discourse.julialang.org/t/for-custom-type-and-promote-rule/15806)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 2\
**Last updated:** [October 3, 2018, 12:44pm UTC](https://discourse.julialang.org/t/for-custom-type-and-promote-rule/15806 "2018-10-03T12:44:01Z")

</div>

From the docs for ==: New numeric types should implement this function for two arguments of the new type, and handle comparison to other types via promotion rules where possible. So I tried this: struct A x::Float…

---

## [Help understanding Dict allocation](https://discourse.julialang.org/t/help-understanding-dict-allocation/15809)

<div class="topic-metadata">

**Author:** [@LeoK987](https://discourse.julialang.org/u/LeoK987)\
**Replies:** 7\
**Last updated:** [October 3, 2018, 12:08pm UTC](https://discourse.julialang.org/t/help-understanding-dict-allocation/15809 "2018-10-03T12:08:28Z")

</div>

I amd trying to find out about a huge allocation in my code (with --track-allocation=user): 608 ValueDict = Dict{Function, Array{Float64,1}}() 0 for atom in Atoms - values = zeros(F…

---

## [How different are the ways of aliasing functions?](https://discourse.julialang.org/t/how-different-are-the-ways-of-aliasing-functions/15824)

<div class="topic-metadata">

**Author:** [@LeoK987](https://discourse.julialang.org/u/LeoK987)\
**Replies:** 1\
**Last updated:** [October 3, 2018, 11:29am UTC](https://discourse.julialang.org/t/how-different-are-the-ways-of-aliasing-functions/15824 "2018-10-03T11:29:14Z")

</div>

Say I have 2 functions: function f1(i::Int) i end function f2(i::Int) 2\*i end I have these 2 ways of aliasing them: f = f1 g(i::Int) = f1(i) Calling either f or g give the right result, but somehow, calling …

---

## [Properly exporting foreign types in module - for save/load JLD2](https://discourse.julialang.org/t/properly-exporting-foreign-types-in-module-for-save-load-jld2/15822)

<div class="topic-metadata">

**Author:** [@JonasIsensee](https://discourse.julialang.org/u/JonasIsensee)\
**Replies:** 0\
**Last updated:** [October 3, 2018, 9:30am UTC](https://discourse.julialang.org/t/properly-exporting-foreign-types-in-module-for-save-load-jld2/15822 "2018-10-03T09:30:03Z")

</div>

Hey! I’ve got a questing on modules and (re-)exporting types imported from another module. The MWE below shows my problem. I want to use/export a type from a different module. This works fine. However I cannot load s…

---

## [Different UUID in Project.toml and registry](https://discourse.julialang.org/t/different-uuid-in-project-toml-and-registry/15819)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 5\
**Last updated:** [October 3, 2018, 8:40am UTC](https://discourse.julialang.org/t/different-uuid-in-project-toml-and-registry/15819 "2018-10-03T08:40:16Z")

</div>

I was tracking down a problem with my packages, and I think it stems from having a different UUID than in https://github.com/tpapp/TransformVariables.jl/blob/master/Project.toml Is this supposed to happen? Did I mak…

---

## [General reduction performance](https://discourse.julialang.org/t/general-reduction-performance/15675)

<div class="topic-metadata">

**Author:** [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Replies:** 4\
**Last updated:** [October 3, 2018, 7:59am UTC](https://discourse.julialang.org/t/general-reduction-performance/15675 "2018-10-03T07:59:43Z")

</div>

I need to efficiently apply a custom reduction function along specific axis of a large array, basically what mapslices does. However the performance is 30 times worse than expected: using BenchmarkTools using Statistic…

---

## [Questions about using \`Parameters\`](https://discourse.julialang.org/t/questions-about-using-parameters/14378)

<div class="topic-metadata">

**Author:** [@briochemc](https://discourse.julialang.org/u/briochemc)\
**Replies:** 4\
**Last updated:** [October 3, 2018, 7:16am UTC](https://discourse.julialang.org/t/questions-about-using-parameters/14378 "2018-10-03T07:16:43Z")

</div>

I thought I’d ask some questions about the Parameters package here because hopefully the answers will be useful to others. (Maybe some answers actually will make their way to the Parameters package documentation?) Ok, s…

---

## [How to make suitable data for silhouettes() function of Clustering package?](https://discourse.julialang.org/t/how-to-make-suitable-data-for-silhouettes-function-of-clustering-package/15543)

<div class="topic-metadata">

**Author:** [@Tomoyuki\_Kosaka](https://discourse.julialang.org/u/Tomoyuki_Kosaka)\
**Replies:** 7\
**Last updated:** [October 3, 2018, 3:07am UTC](https://discourse.julialang.org/t/how-to-make-suitable-data-for-silhouettes-function-of-clustering-package/15543 "2018-10-03T03:07:23Z")

</div>

I’m trying to use Clustering.jl. I hope to obtain result values of silhouettes() from KmeansResult. I understand that silhouettes() requires assignments, counts, dists, Assignments and counts are referred from KmeansR…

---

## [Abstract supertype or type union for a set of parametric types](https://discourse.julialang.org/t/abstract-supertype-or-type-union-for-a-set-of-parametric-types/15722)

<div class="topic-metadata">

**Author:** [@Azzaare](https://discourse.julialang.org/u/Azzaare)\
**Replies:** 4\
**Last updated:** [October 3, 2018, 1:10am UTC](https://discourse.julialang.org/t/abstract-supertype-or-type-union-for-a-set-of-parametric-types/15722 "2018-10-03T01:10:26Z")

</div>

Hello there, I am a bit lost with when should I use Union or not in Julia 0.7/1.0+. In the following example, I would have used an abstract super type for TimeComponent. Should I use an Union as in the example. What wou…

---

## [Cannot replace docstring in projects](https://discourse.julialang.org/t/cannot-replace-docstring-in-projects/15805)

<div class="topic-metadata">

**Author:** [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Replies:** 0\
**Last updated:** [October 2, 2018, 9:26pm UTC](https://discourse.julialang.org/t/cannot-replace-docstring-in-projects/15805 "2018-10-02T21:26:45Z")

</div>

I was able to replace kw\_str’s doc simply by re-declare it. But this does not work for Projects, e.g module TestProject import Base.BaseDocs: @kw\_str """ aaa """ kw"" end # module If you simply run this in REPL, and…

---

## [How should I know if the nightly binaries contain a certain commit?](https://discourse.julialang.org/t/how-should-i-know-if-the-nightly-binaries-contain-a-certain-commit/15803)

<div class="topic-metadata">

**Author:** [@Non-Contradiction](https://discourse.julialang.org/u/Non-Contradiction)\
**Replies:** 3\
**Last updated:** [October 2, 2018, 8:25pm UTC](https://discourse.julialang.org/t/how-should-i-know-if-the-nightly-binaries-contain-a-certain-commit/15803 "2018-10-02T20:25:25Z")

</div>

For example, how should I know if the windows nightly binary contains #29374? Thanks in advance.

---

## [Dump variables to global scope](https://discourse.julialang.org/t/dump-variables-to-global-scope/15802)

<div class="topic-metadata">

**Author:** [@jonjilla](https://discourse.julialang.org/u/jonjilla)\
**Replies:** 2\
**Last updated:** [October 2, 2018, 8:24pm UTC](https://discourse.julialang.org/t/dump-variables-to-global-scope/15802 "2018-10-02T20:24:27Z")

</div>

Hello I’m having trouble debugging some scripts due to how variables are now set to local within for/try/while blocks It’s easy to debug other languages, because I can see what the state of the variables were when it f…

---

## [Mysterious \`StackOverFlow\` error with type constructor when using \`PyPlot\` in conjunction with \`Reduce\`](https://discourse.julialang.org/t/mysterious-stackoverflow-error-with-type-constructor-when-using-pyplot-in-conjunction-with-reduce/14050)

<div class="topic-metadata">

**Author:** [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Replies:** 6\
**Last updated:** [October 2, 2018, 8:16pm UTC](https://discourse.julialang.org/t/mysterious-stackoverflow-error-with-type-constructor-when-using-pyplot-in-conjunction-with-reduce/14050 "2018-10-02T20:16:36Z")

</div>

It’s not clear how to resolve this StackOverFlow error, call to mandelbrot calls a Define type constructor: pkg\> dev Fatou julia\> using Fatou julia\> mandelbrot(:(z^3-1)) ERROR: StackOverflowError: Stacktrace: \[1\] Typ…

---

## [Very slow readdlm()](https://discourse.julialang.org/t/very-slow-readdlm/14994)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 14\
**Last updated:** [October 2, 2018, 7:33pm UTC](https://discourse.julialang.org/t/very-slow-readdlm/14994 "2018-10-02T19:33:09Z")

</div>

Julia 0.6 file 500MB (only digits, linux stnadard ) on Win by readcsv() is reading in ±150 sek. Julia 0.7 has only readdlm(), The same file was reading over 2 h! What to do ? Is any package to conver file linux\>win ? It …

---

## [Documenting Fields of Parametric Type](https://discourse.julialang.org/t/documenting-fields-of-parametric-type/15760)

<div class="topic-metadata">

**Author:** [@JaredCrean2](https://discourse.julialang.org/u/JaredCrean2)\
**Replies:** 2\
**Last updated:** [October 2, 2018, 1:43pm UTC](https://discourse.julialang.org/t/documenting-fields-of-parametric-type/15760 "2018-10-02T13:43:45Z")

</div>

I am having trouble documenting the fields of a parametric type, but not of a non-parametric type. Example: """ This is struct Foo """ struct Foo{T} """ This is field x """ x end """ This is struct Bar …

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

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