# General Usage

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

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

**Page:** 1044

---

## [\`rand()\` vs. \`rand.()\`?](https://discourse.julialang.org/t/rand-vs-rand/2079)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 13\
**Last updated:** [June 18, 2017, 1:48am UTC](https://discourse.julialang.org/t/rand-vs-rand/2079 "2017-06-18T01:48:20Z")

</div>

Consider the following example: x = zeros(10) x .= rand() All components of x will have the same (random) value. Now suppose I do instead: x = zeros(10) x .= rand.() Since rand.() is dotted, I’d expect it to apply to…

---

## [What are the DataType and Union definitions?](https://discourse.julialang.org/t/what-are-the-datatype-and-union-definitions/4332)

<div class="topic-metadata">

**Author:** [@hpoit](https://discourse.julialang.org/u/hpoit)\
**Replies:** 2\
**Last updated:** [June 18, 2017, 12:42am UTC](https://discourse.julialang.org/t/what-are-the-datatype-and-union-definitions/4332 "2017-06-18T00:42:43Z")

</div>

typeof(Union{Real,Rational}) # =\> DataType typeof(Union{Real,String}) # =\> Union (1) typeof(Union{Real,Float64}) # =\> DataType typeof(Union{Int64,Float64}) # =\> Union (2) typeof(Union{Real,Float64,Rational}) # =\> DataTyp…

---

## [WinRPM doesn't build: Cannot parse XML file](https://discourse.julialang.org/t/winrpm-doesnt-build-cannot-parse-xml-file/3841)

<div class="topic-metadata">

**Author:** [@robertdj](https://discourse.julialang.org/u/robertdj)\
**Replies:** 8\
**Last updated:** [June 17, 2017, 7:15pm UTC](https://discourse.julialang.org/t/winrpm-doesnt-build-cannot-parse-xml-file/3841 "2017-06-17T19:15:47Z")

</div>

Some time ago I successfully installed the WinRPM. I recently ran into trouble with some packages and decided to wipe the package dir v0.5. Since then, I cannot install the WinRPM package (which I need for the HDF5 pack…

---

## [Images.save downsizes images](https://discourse.julialang.org/t/images-save-downsizes-images/4329)

<div class="topic-metadata">

**Author:** [@shiv](https://discourse.julialang.org/u/shiv)\
**Replies:** 4\
**Last updated:** [June 17, 2017, 4:21pm UTC](https://discourse.julialang.org/t/images-save-downsizes-images/4329 "2017-06-17T16:21:52Z")

</div>

I am using Julia 0.5.2 (Ubuntu 16.04) and recently Images.save has started downsizing PNG files (by half). Neither help or searching through sources reveals the “options” that can be used to go back to the old behaviour …

---

## [Comprehension type inference](https://discourse.julialang.org/t/comprehension-type-inference/4324)

<div class="topic-metadata">

**Author:** [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Replies:** 2\
**Last updated:** [June 17, 2017, 3:36pm UTC](https://discourse.julialang.org/t/comprehension-type-inference/4324 "2017-06-17T15:36:25Z")

</div>

Could someone explain me why Julia has problem with type inference in the following function (the comprehension example is taken from Julia Documentation): julia\> f() = \[(i,j) for i=1:3 for j=1:i\] …

---

## [Building multiple versions of Julia](https://discourse.julialang.org/t/building-multiple-versions-of-julia/4224)

<div class="topic-metadata">

**Author:** [@Iagoba\_Apellaniz](https://discourse.julialang.org/u/Iagoba_Apellaniz)\
**Replies:** 10\
**Last updated:** [June 17, 2017, 12:35pm UTC](https://discourse.julialang.org/t/building-multiple-versions-of-julia/4224 "2017-06-17T12:35:01Z")

</div>

Currently I have 2 versions of julia in my system, v0.5.2 and v0.7.0-DEV (master). To do so I cloned twice the repository to different folders and I build them to have both versions. I think that it should be a way of d…

---

## [FunctionWrappers showing ~25x overhead over a native function call](https://discourse.julialang.org/t/functionwrappers-showing-25x-overhead-over-a-native-function-call/4323)

<div class="topic-metadata">

**Author:** [@Nitin\_Arora](https://discourse.julialang.org/u/Nitin_Arora)\
**Replies:** 10\
**Last updated:** [June 17, 2017, 11:43am UTC](https://discourse.julialang.org/t/functionwrappers-showing-25x-overhead-over-a-native-function-call/4323 "2017-06-17T11:43:52Z")

</div>

I am seeing performance a big difference between using FunctionWrappers and native function call. Is this to be expected ? Please see the MWE below: using BenchmarkTools using FunctionWrappers: FunctionWrapper str…

---

## [Stack overflow error when splatting strings into \`join\`](https://discourse.julialang.org/t/stack-overflow-error-when-splatting-strings-into-join/4322)

<div class="topic-metadata">

**Author:** [@DNF](https://discourse.julialang.org/u/DNF)\
**Replies:** 6\
**Last updated:** [June 17, 2017, 10:33am UTC](https://discourse.julialang.org/t/stack-overflow-error-when-splatting-strings-into-join/4322 "2017-06-17T10:33:05Z")

</div>

I accidentally splatted several strings into join, and got the following behaviour, with many screens of error messages scrolling past: julia\> join('a', 'b', 'c') "a" julia\> join('a', 'b', 'c', 'd') ERROR: StackOverf…

---

## [Embedding Julia and Packages](https://discourse.julialang.org/t/embedding-julia-and-packages/4305)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 8\
**Last updated:** [June 16, 2017, 11:23pm UTC](https://discourse.julialang.org/t/embedding-julia-and-packages/4305 "2017-06-16T23:23:01Z")

</div>

Hi, I’m guessing the answer but anyway would like a confirmation. Reading the Embedding docs I see no reference to the possibility to call Julia modules from other languages, right? There is this jl\_function\_t \*func = …

---

## [Get \`@amacro x 3\` to produce \`\[(:x, x), (:3, 3)\]\` -- a version of \`@show\`](https://discourse.julialang.org/t/get-amacro-x-3-to-produce-x-x-3-3-a-version-of-show/4311)

<div class="topic-metadata">

**Author:** [@prolixobora](https://discourse.julialang.org/u/prolixobora)\
**Replies:** 1\
**Last updated:** [June 16, 2017, 8:01pm UTC](https://discourse.julialang.org/t/get-amacro-x-3-to-produce-x-x-3-3-a-version-of-show/4311 "2017-06-16T20:01:37Z")

</div>

I want a macro that behaves as follows: julia\> x=7; @amacro x x+x 3 \[(:x, 7), (:(x+x), 14), (:3, 3)\] julia\> x=7; macroexpand(:( @amacro x x+x 3 )) \[(:x, x), (:(x+x), x+x, (:3, 3)\] I think you can consider this a varia…

---

## [Can we solve IP model with parallel processing?](https://discourse.julialang.org/t/can-we-solve-ip-model-with-parallel-processing/4312)

<div class="topic-metadata">

**Author:** [@gopal2017](https://discourse.julialang.org/u/gopal2017)\
**Replies:** 0\
**Last updated:** [June 16, 2017, 5:22pm UTC](https://discourse.julialang.org/t/can-we-solve-ip-model-with-parallel-processing/4312 "2017-06-16T17:22:56Z")

</div>

In Julia parallel processing is possible. For instance, we can try the problem mentioned below: nprocs() function Square(n) sum=0 for i=1:n sum+=i^2 end return sum end @time Square(10000000) Now try with paral…

---

## [Suddenly qualified Base-types](https://discourse.julialang.org/t/suddenly-qualified-base-types/4292)

<div class="topic-metadata">

**Author:** [@ulysses](https://discourse.julialang.org/u/ulysses)\
**Replies:** 3\
**Last updated:** [June 16, 2017, 2:20pm UTC](https://discourse.julialang.org/t/suddenly-qualified-base-types/4292 "2017-06-16T14:20:15Z")

</div>

Consider the output of subtypes function: julia\> subtypes(Associative) 5-element Array{Union{DataType, UnionAll},1}: Base.EnvHash Base.ImmutableDict Dict ObjectIdDict WeakKeyDict What is …

---

## [Error with addprocs\_sge()](https://discourse.julialang.org/t/error-with-addprocs-sge/4304)

<div class="topic-metadata">

**Author:** [@thielehhi](https://discourse.julialang.org/u/thielehhi)\
**Replies:** 0\
**Last updated:** [June 16, 2017, 1:08pm UTC](https://discourse.julialang.org/t/error-with-addprocs-sge/4304 "2017-06-16T13:08:53Z")

</div>

Is there someone experiencing the same issue and having a solution for me: I started using Julia in combination with the ClusterManager on our HPC. I am trying to start workers with the following lines: ## predefining …

---

## [What is the expected way to add code to a package in the metadata directory](https://discourse.julialang.org/t/what-is-the-expected-way-to-add-code-to-a-package-in-the-metadata-directory/4301)

<div class="topic-metadata">

**Author:** [@Jackels](https://discourse.julialang.org/u/Jackels)\
**Replies:** 4\
**Last updated:** [June 16, 2017, 12:34pm UTC](https://discourse.julialang.org/t/what-is-the-expected-way-to-add-code-to-a-package-in-the-metadata-directory/4301 "2017-06-16T12:34:28Z")

</div>

I can use Pkgdev.generate to make a repository. Now what is the expected way to put code into that and how to tell git to use it? Manually copy-pasting stuff in there and manually telling git to use it? Or is there some …

---

## [Extracting parametric types](https://discourse.julialang.org/t/extracting-parametric-types/4298)

<div class="topic-metadata">

**Author:** [@shivin9](https://discourse.julialang.org/u/shivin9)\
**Replies:** 2\
**Last updated:** [June 16, 2017, 8:41am UTC](https://discourse.julialang.org/t/extracting-parametric-types/4298 "2017-06-16T08:41:49Z")

</div>

Hi, I have an object defined as A = LinearOperator{Float64}(2,2,1000,:D0,:D0,\[-1,-1\]) so when I do typeof(A), I get PDEOperators.LinearOperator{Float64,SVector{3,Float64},:D0,:D1} (doing this with inner constructors a…

---

## [Dynamic dispatch in \`catch\` clauses](https://discourse.julialang.org/t/dynamic-dispatch-in-catch-clauses/4294)

<div class="topic-metadata">

**Author:** [@ulysses](https://discourse.julialang.org/u/ulysses)\
**Replies:** 1\
**Last updated:** [June 15, 2017, 11:18pm UTC](https://discourse.julialang.org/t/dynamic-dispatch-in-catch-clauses/4294 "2017-06-15T23:18:05Z")

</div>

Docs tell that one could create user-defined exception types simply subtyping Exception. But how to use those? In other languages we can use multiple catch clauses. Doesn’t Julia have ones? struct MyEx \<: Exception end …

---

## [Contents of pkg.julialang.org in machine-readable form](https://discourse.julialang.org/t/contents-of-pkg-julialang-org-in-machine-readable-form/4290)

<div class="topic-metadata">

**Author:** [@ulysses](https://discourse.julialang.org/u/ulysses)\
**Replies:** 1\
**Last updated:** [June 15, 2017, 10:17pm UTC](https://discourse.julialang.org/t/contents-of-pkg-julialang-org-in-machine-readable-form/4290 "2017-06-15T22:17:02Z")

</div>

Is there a way to get the contents of pkg.julialang.org in machine-readable form (JSON/XML)? I mean not only the list of packages (this can be obtained at METADATA.jl repo). But also the versions of Julia supported, the …

---

## [Inconsistency between \`findmax\` and \`maximum\` with respect to \`NaN\`](https://discourse.julialang.org/t/inconsistency-between-findmax-and-maximum-with-respect-to-nan/4214)

<div class="topic-metadata">

**Author:** [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Replies:** 9\
**Last updated:** [June 15, 2017, 9:41am UTC](https://discourse.julialang.org/t/inconsistency-between-findmax-and-maximum-with-respect-to-nan/4214 "2017-06-15T09:41:42Z")

</div>

I read this discussion about max and maximum returning NaN when the collection includes NaN. For example, julia\> VERSION v"0.7.0-DEV.82" julia\> v = \[1.0, NaN, 2.0\] 3-element Array{Float64,1}: 1.0 NaN 2.0 julia\>…

---

## [Multiple files in a gzip archive](https://discourse.julialang.org/t/multiple-files-in-a-gzip-archive/4261)

<div class="topic-metadata">

**Author:** [@rcnlee](https://discourse.julialang.org/u/rcnlee)\
**Replies:** 6\
**Last updated:** [June 15, 2017, 2:14am UTC](https://discourse.julialang.org/t/multiple-files-in-a-gzip-archive/4261 "2017-06-15T02:14:16Z")

</div>

Is it possible to create a single compressed archive that contains a number of text or csv files? It looks like gzip.jl only zips a single file at a time. Thanks!

---

## [Does Cxx.jl only work with dynamic (shared) libraries, and not static libraries?](https://discourse.julialang.org/t/does-cxx-jl-only-work-with-dynamic-shared-libraries-and-not-static-libraries/4253)

<div class="topic-metadata">

**Author:** [@fasiha](https://discourse.julialang.org/u/fasiha)\
**Replies:** 4\
**Last updated:** [June 14, 2017, 5:43pm UTC](https://discourse.julialang.org/t/does-cxx-jl-only-work-with-dynamic-shared-libraries-and-not-static-libraries/4253 "2017-06-14T17:43:20Z")

</div>

I seek to use Cxx.jl to call functions in a C++ library which we usually distribute as a static library, but when I do Libdl.dlopen(lib\_path, Libdl.RTLD\_GLOBAL), Cxx prints out the error: ERROR: LoadError: could not loa…

---

## [Keyword argument with a default value that depends on a type parameter](https://discourse.julialang.org/t/keyword-argument-with-a-default-value-that-depends-on-a-type-parameter/4260)

<div class="topic-metadata">

**Author:** [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Replies:** 3\
**Last updated:** [June 14, 2017, 4:56pm UTC](https://discourse.julialang.org/t/keyword-argument-with-a-default-value-that-depends-on-a-type-parameter/4260 "2017-06-14T16:56:35Z")

</div>

Consider the following test function: julia\> test\_default(x::T, y::R=Base.rtoldefault(R)) where {R\<:Real,T\<:Union{R,Complex{R}}} = (R, T) test\_default (generic function with 2 methods) When a single complex number x is…

---

## [Sporadic segfaults in 0.6-rc3 and DataStreams](https://discourse.julialang.org/t/sporadic-segfaults-in-0-6-rc3-and-datastreams/4251)

<div class="topic-metadata">

**Author:** [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Replies:** 1\
**Last updated:** [June 14, 2017, 1:25pm UTC](https://discourse.julialang.org/t/sporadic-segfaults-in-0-6-rc3-and-datastreams/4251 "2017-06-14T13:25:42Z")

</div>

Something decidedly fishy is going on in 0.6-rc3. I keep getting sporadic segfaults when trying to use DataStreams. I had this problem in the past, but it seemed to happen mostly when using ODBC and it was much rarer. …

---

## [Operations on \`StaticArrays\` without intermediate allocation](https://discourse.julialang.org/t/operations-on-staticarrays-without-intermediate-allocation/4255)

<div class="topic-metadata">

**Author:** [@cortner](https://discourse.julialang.org/u/cortner)\
**Replies:** 9\
**Last updated:** [June 13, 2017, 10:27pm UTC](https://discourse.julialang.org/t/operations-on-staticarrays-without-intermediate-allocation/4255 "2017-06-13T22:27:53Z")

</div>

The following line defines a contraction between two vectors and a fourth-dimensional tensor, the result being a matrix. contract(a::Vec3, C::Ten43, b::Vec3) = Mat3(\[dot(C\[i,:,j,:\] \* b, a) for i=1:3, j = 1:3\]) where Ve…

---

## [A harness to test daily, hourly and millisecondly data processing](https://discourse.julialang.org/t/a-harness-to-test-daily-hourly-and-millisecondly-data-processing/4223)

<div class="topic-metadata">

**Author:** [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Replies:** 5\
**Last updated:** [June 13, 2017, 7:23pm UTC](https://discourse.julialang.org/t/a-harness-to-test-daily-hourly-and-millisecondly-data-processing/4223 "2017-06-13T19:23:56Z")

</div>

I need to demonstrate that software intended to accept, record and respond to financial multi-market data (both slow, once-a-day and fast, lots-a-day) does in fact accept, record and respond properly. I know how to evi…

---

## [Non-catting version of matrix construction](https://discourse.julialang.org/t/non-catting-version-of-matrix-construction/4205)

<div class="topic-metadata">

**Author:** [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)\
**Replies:** 12\
**Last updated:** [June 13, 2017, 5:47pm UTC](https://discourse.julialang.org/t/non-catting-version-of-matrix-construction/4205 "2017-06-13T17:47:58Z")

</div>

I want to do the following but obtaining a Matrix{Matrix{Float64}} not a Matrix{Float64}: julia\> A = rand(2,2); julia\> \[A A; A A\] 4×4 Array{Float64,2}: 0.636575 0.458969 0.636575 0.458969 0.236709 0.0897579 0.…

---

## [How best to enfold stable parameter values](https://discourse.julialang.org/t/how-best-to-enfold-stable-parameter-values/4222)

<div class="topic-metadata">

**Author:** [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Replies:** 2\
**Last updated:** [June 13, 2017, 3:45pm UTC](https://discourse.julialang.org/t/how-best-to-enfold-stable-parameter-values/4222 "2017-06-13T15:45:26Z")

</div>

A very general function for short-windowed timeseries smoothing would have a handful of algorithmically subselective params and other args that influence the behavior. Most uses/users will adopt a few styles and keep us…

---

## [Embedded Julia: Backslash hangs thread](https://discourse.julialang.org/t/embedded-julia-backslash-hangs-thread/4233)

<div class="topic-metadata">

**Author:** [@Sinfaen](https://discourse.julialang.org/u/Sinfaen)\
**Replies:** 13\
**Last updated:** [June 13, 2017, 2:29pm UTC](https://discourse.julialang.org/t/embedded-julia-backslash-hangs-thread/4233 "2017-06-13T14:29:13Z")

</div>

I’m not entirely sure where the best place to put this question as I am new to this place and Julia in general. I’ve tried stack overflow but I think this is too specific for that. I’ve embedded Julia into C# using the …

---

## [Setting multiple Callback functions inside a for loop](https://discourse.julialang.org/t/setting-multiple-callback-functions-inside-a-for-loop/4241)

<div class="topic-metadata">

**Author:** [@Amulya\_Yadav](https://discourse.julialang.org/u/Amulya_Yadav)\
**Replies:** 0\
**Last updated:** [June 13, 2017, 11:59am UTC](https://discourse.julialang.org/t/setting-multiple-callback-functions-inside-a-for-loop/4241 "2017-06-13T11:59:10Z")

</div>

I want to implement Benders decomposition on a MIP that I have. To that end, I am using JuliaOpt’s sample code on Benders (by Shuvomoy) as a reference point: JuliaOpt - Optimization packages for the Julia language Howev…

---

## [Creating Arrays - different behavior of \*(a,b) and +(a,b) elements](https://discourse.julialang.org/t/creating-arrays-different-behavior-of-a-b-and-a-b-elements/4213)

<div class="topic-metadata">

**Author:** [@strickek](https://discourse.julialang.org/u/strickek)\
**Replies:** 1\
**Last updated:** [June 12, 2017, 9:53am UTC](https://discourse.julialang.org/t/creating-arrays-different-behavior-of-a-b-and-a-b-elements/4213 "2017-06-12T09:53:40Z")

</div>

Any\[1 +(1,3)\] gives 1x2 Array{Any,2}: 1 4 but Any\[1 \*(1,3)\] have an MethodError: \`\*\` has no method matching \*(::Int64, ::Tuple{Int64,Int64}) Closest candidates are: \*(::Any, ::Any, ::Any, ::Any...) \*(::Real, …

---

## [Questions regarding a few ForwardDiff.jl limitations](https://discourse.julialang.org/t/questions-regarding-a-few-forwarddiff-jl-limitations/4218)

<div class="topic-metadata">

**Author:** [@mcovalt](https://discourse.julialang.org/u/mcovalt)\
**Replies:** 2\
**Last updated:** [June 12, 2017, 9:42am UTC](https://discourse.julialang.org/t/questions-regarding-a-few-forwarddiff-jl-limitations/4218 "2017-06-12T09:42:14Z")

</div>

I have a project I’m wanting to use ForwardDiff.jl on. I have a few question: Chunk Size If I’m reading correctly, ForwardDiff.jl evaluates partial derivatives on chunks of the input vector. What if computations depen…

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

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