# General Usage

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

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

**Page:** 814

---

## [Correct way to populate an empty array in parallel in Julia?](https://discourse.julialang.org/t/correct-way-to-populate-an-empty-array-in-parallel-in-julia/31187)

<div class="topic-metadata">

**Author:** [@bashonubuntu](https://discourse.julialang.org/u/bashonubuntu)\
**Replies:** 2\
**Last updated:** [November 17, 2019, 10:19pm UTC](https://discourse.julialang.org/t/correct-way-to-populate-an-empty-array-in-parallel-in-julia/31187 "2019-11-17T22:19:34Z")

</div>

Hello, Often times in parallel code, I find myself in need of populating an empty array. I have gone back and forth between using a vcat operation versus a SharedArray. A typical pseudo-code would look like: function m…

---

## [Function generation interpolating symbol with a string](https://discourse.julialang.org/t/function-generation-interpolating-symbol-with-a-string/31171)

<div class="topic-metadata">

**Author:** [@Amval](https://discourse.julialang.org/u/Amval)\
**Replies:** 2\
**Last updated:** [November 17, 2019, 6:49pm UTC](https://discourse.julialang.org/t/function-generation-interpolating-symbol-with-a-string/31171 "2019-11-17T18:49:51Z")

</div>

Hi all, not sure the title is clear enough, but I was struggling to find a clear description. Although I think what I am trying to do is pretty straight forward and the problem is that I simply don’t understand how macr…

---

## [How to add shared c library to the load path](https://discourse.julialang.org/t/how-to-add-shared-c-library-to-the-load-path/31061)

<div class="topic-metadata">

**Author:** [@fleecy](https://discourse.julialang.org/u/fleecy)\
**Replies:** 6\
**Last updated:** [November 17, 2019, 11:57am UTC](https://discourse.julialang.org/t/how-to-add-shared-c-library-to-the-load-path/31061 "2019-11-17T11:57:48Z")

</div>

In the “Calling C and Fortran Code” guide, it says you can add your shared library to the load path, but what exactly is this load path and which environmental variable does it correspond to? Is there a way to change thi…

---

## [Why the code recompiles?](https://discourse.julialang.org/t/why-the-code-recompiles/31092)

<div class="topic-metadata">

**Author:** [@Janis\_Erdmanis](https://discourse.julialang.org/u/Janis_Erdmanis)\
**Replies:** 9\
**Last updated:** [November 17, 2019, 10:04am UTC](https://discourse.julialang.org/t/why-the-code-recompiles/31092 "2019-11-17T10:04:35Z")

</div>

When I am working with scientific projects, I am quite an old school guy who writes code and executes that with include("source.jl") in the Julia REPL. That had worked pretty well so far, but today I encountered a recomp…

---

## [Implementing parallel sum](https://discourse.julialang.org/t/implementing-parallel-sum/31097)

<div class="topic-metadata">

**Author:** [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Replies:** 12\
**Last updated:** [November 17, 2019, 8:17am UTC](https://discourse.julialang.org/t/implementing-parallel-sum/31097 "2019-11-17T08:17:48Z")

</div>

In MATLAB, summing the entries of a vector in a for loop can be easily parallelized using parfor of Parallel Computing Toolbox. I remember @threads served a more or less similar purpose in Julia, but after reading Annou…

---

## [Unmarshaling JSON based on a type defined in the JSON object](https://discourse.julialang.org/t/unmarshaling-json-based-on-a-type-defined-in-the-json-object/31170)

<div class="topic-metadata">

**Author:** [@watzon](https://discourse.julialang.org/u/watzon)\
**Replies:** 0\
**Last updated:** [November 17, 2019, 8:10am UTC](https://discourse.julialang.org/t/unmarshaling-json-based-on-a-type-defined-in-the-json-object/31170 "2019-11-17T08:10:37Z")

</div>

I asked a similar question in the gitter chat, but I figured I’d ask here too. Basically this is the issue: I am attempting to write a Julia wrapper for TDLib, and more specifically for the libtdjson portion of the libr…

---

## [Non-deallocating (permanently growing) extensible arrays](https://discourse.julialang.org/t/non-deallocating-permanently-growing-extensible-arrays/31056)

<div class="topic-metadata">

**Author:** [@Sean\_Matthews](https://discourse.julialang.org/u/Sean_Matthews)\
**Replies:** 5\
**Last updated:** [November 17, 2019, 7:36am UTC](https://discourse.julialang.org/t/non-deallocating-permanently-growing-extensible-arrays/31056 "2019-11-17T07:36:46Z")

</div>

\[Sorry for all errors of subject subcategory, ignorance of packages, etc. - this is my first post here\] I am looking for a package implementing a vector type where once space is allocated for an expansion (using, e.g., …

---

## [Possible Bug With TypeVars](https://discourse.julialang.org/t/possible-bug-with-typevars/31166)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 1\
**Last updated:** [November 17, 2019, 7:07am UTC](https://discourse.julialang.org/t/possible-bug-with-typevars/31166 "2019-11-17T07:07:41Z")

</div>

\_ \_ \_(\_)\_ | Documentation: https://docs.julialang.org (\_) | (\_) (\_) | \_ \_ \_| |\_ \_\_ \_ | Type "?" for help, "\]?" for Pkg help. | | | | | | |/ \_\` | | | | |\_| | | | (\_| | | Version 1.2.…

---

## [How to distinguish between UnionAll and DataType of the same type?](https://discourse.julialang.org/t/how-to-distinguish-between-unionall-and-datatype-of-the-same-type/31165)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 1\
**Last updated:** [November 17, 2019, 6:49am UTC](https://discourse.julialang.org/t/how-to-distinguish-between-unionall-and-datatype-of-the-same-type/31165 "2019-11-17T06:49:05Z")

</div>

Hi, let’s assume that I have a struct like julia\> struct MM{T} x::T end julia\> const TypeGen{T} = MM{M} where M\<:T MM{M} where M\<:T where T julia\> TypeGen{Int} MM{M} where M\<:Int64 julia\> f(::Type{…

---

## [ForwardDiff & "complicated" functions?](https://discourse.julialang.org/t/forwarddiff-complicated-functions/31094)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 14\
**Last updated:** [November 16, 2019, 10:15am UTC](https://discourse.julialang.org/t/forwarddiff-complicated-functions/31094 "2019-11-16T10:15:42Z")

</div>

I’d need to compute the derivative (and later: the Jacobian) of the following function: f = x -\> sqrt(max(-x,0)) which looks like the following: Obviously, the derivative doesn’t exist for x=0. Still, I try to use F…

---

## [Setting initial values of a three dimensional optimization variable](https://discourse.julialang.org/t/setting-initial-values-of-a-three-dimensional-optimization-variable/31145)

<div class="topic-metadata">

**Author:** [@mamuniut09](https://discourse.julialang.org/u/mamuniut09)\
**Replies:** 0\
**Last updated:** [November 16, 2019, 4:43am UTC](https://discourse.julialang.org/t/setting-initial-values-of-a-three-dimensional-optimization-variable/31145 "2019-11-16T04:43:51Z")

</div>

Hello, I want to set the initial values of a three dimensional optimization variable, but not getting any perfect documentation about that. A sample code is given below. m = Model(with\_optimizer(Ipopt.Optimizer)); @var…

---

## [Can Blosc.jl only decompress content that it has compressed?](https://discourse.julialang.org/t/can-blosc-jl-only-decompress-content-that-it-has-compressed/31141)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 3\
**Last updated:** [November 16, 2019, 2:55am UTC](https://discourse.julialang.org/t/can-blosc-jl-only-decompress-content-that-it-has-compressed/31141 "2019-11-16T02:55:06Z")

</div>

I have been using Blocs.jl and it’s quite awesome. I am trying to make passing compressed data between Python, Julia, and R easier so I was looking for compression format that can used in all of them. I tried to compres…

---

## [Julia Distributed ethernet adapter switching](https://discourse.julialang.org/t/julia-distributed-ethernet-adapter-switching/30570)

<div class="topic-metadata">

**Author:** [@subunit](https://discourse.julialang.org/u/subunit)\
**Replies:** 2\
**Last updated:** [November 15, 2019, 11:58pm UTC](https://discourse.julialang.org/t/julia-distributed-ethernet-adapter-switching/30570 "2019-11-15T23:58:03Z")

</div>

I am doing calculations on a cluster of workers with over ssh with machines on both wifi and wired LAN. I noticed that I am able to connect an ethernet cable to a machine that started the calculations on wifi, and the wo…

---

## [State of Compilation to Single Executable for Julia](https://discourse.julialang.org/t/state-of-compilation-to-single-executable-for-julia/30792)

<div class="topic-metadata">

**Author:** [@Usor](https://discourse.julialang.org/u/Usor)\
**Replies:** 13\
**Last updated:** [November 15, 2019, 11:26pm UTC](https://discourse.julialang.org/t/state-of-compilation-to-single-executable-for-julia/30792 "2019-11-15T23:26:24Z")

</div>

This seems like the right forum part to post this to, but please put it to the correct one if necesssry. I saw some messages on the forum about compiling to executables, but nothing about the current state. What is t…

---

## [Set disjunction for arguments, if defining a function](https://discourse.julialang.org/t/set-disjunction-for-arguments-if-defining-a-function/31124)

<div class="topic-metadata">

**Author:** [@Usor](https://discourse.julialang.org/u/Usor)\
**Replies:** 8\
**Last updated:** [November 15, 2019, 10:40pm UTC](https://discourse.julialang.org/t/set-disjunction-for-arguments-if-defining-a-function/31124 "2019-11-15T22:40:57Z")

</div>

If you define a function, can you set disjunctions for the arguments? For example; function simpleadd(a::Float64||Int64, b::Float64||Int64) a + b end I could use Any, but this alternative would be more expressiv…

---

## [Easily enforce horizontal space use REPL, if printing](https://discourse.julialang.org/t/easily-enforce-horizontal-space-use-repl-if-printing/31132)

<div class="topic-metadata">

**Author:** [@Usor](https://discourse.julialang.org/u/Usor)\
**Replies:** 4\
**Last updated:** [November 15, 2019, 5:48pm UTC](https://discourse.julialang.org/t/easily-enforce-horizontal-space-use-repl-if-printing/31132 "2019-11-15T17:48:20Z")

</div>

If you let something be printed to the REPL, can you enforce that horizontal space is used to the right side of an existing printout? For example, you have some variables, a small DataFrame and something else; you have …

---

## [Any Tracker.forward in Zygote.jl?](https://discourse.julialang.org/t/any-tracker-forward-in-zygote-jl/31079)

<div class="topic-metadata">

**Author:** [@vavrines](https://discourse.julialang.org/u/vavrines)\
**Replies:** 5\
**Last updated:** [November 15, 2019, 1:36pm UTC](https://discourse.julialang.org/t/any-tracker-forward-in-zygote-jl/31079 "2019-11-15T13:36:28Z")

</div>

Hi, Maybe a noob question. I’ve an old code based on Flux and Tracker, which solves the derivatives of a matrix using Flux ann = Chain(Dense(2, 10, tanh), Dense(10, 1)) u(x) = ann(x) ux(x) = Tracker.forward(u, x)\[2\](1…

---

## [How to get the .osm file of an area based on a given boxing latitude and longitude pair limit?](https://discourse.julialang.org/t/how-to-get-the-osm-file-of-an-area-based-on-a-given-boxing-latitude-and-longitude-pair-limit/31121)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 0\
**Last updated:** [November 15, 2019, 10:35am UTC](https://discourse.julialang.org/t/how-to-get-the-osm-file-of-an-area-based-on-a-given-boxing-latitude-and-longitude-pair-limit/31121 "2019-11-15T10:35:49Z")

</div>

Hi. I was confused about how to use osm data to create a road network, and I would really appreciate it if someone could point me to any references or comments. So, I downloaded .osm.pbf file data from the internet and t…

---

## [Function to calculate the mode in Julia?](https://discourse.julialang.org/t/function-to-calculate-the-mode-in-julia/31095)

<div class="topic-metadata">

**Author:** [@vlandau](https://discourse.julialang.org/u/vlandau)\
**Replies:** 4\
**Last updated:** [November 15, 2019, 7:13am UTC](https://discourse.julialang.org/t/function-to-calculate-the-mode-in-julia/31095 "2019-11-15T07:13:46Z")

</div>

I feel silly even asking this, but I can’t find the answer via google search for the life of me. Does Julia not have a function to calculate the mode of an array? I’ve tried the code below in Julia 1.2 and Julia 1.3-rc4 …

---

## [How to extend \`Base.parse\` for my types?](https://discourse.julialang.org/t/how-to-extend-base-parse-for-my-types/30940)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 0\
**Last updated:** [November 11, 2019, 7:09am UTC](https://discourse.julialang.org/t/how-to-extend-base-parse-for-my-types/30940 "2019-11-11T07:09:22Z")

</div>

Suppose I have an output from a software. It is a pure text without any specific syntax. I need to write regular expressions to capture the information I want. For example, if I want to capture the following pattern: XX…

---

## [Array of arrays construction](https://discourse.julialang.org/t/array-of-arrays-construction/31096)

<div class="topic-metadata">

**Author:** [@SingingKim](https://discourse.julialang.org/u/SingingKim)\
**Replies:** 10\
**Last updated:** [November 15, 2019, 1:44am UTC](https://discourse.julialang.org/t/array-of-arrays-construction/31096 "2019-11-15T01:44:38Z")

</div>

Hi, The following is how I usually construct an array. Each element of array temp is an array that has different number of elements (which I assign later). temp = Array{Array{Float64},1}(undef,10) for ii in 1:10 tem…

---

## [Julia 1.3 missing windows dependency, ERROR: LoadError: LoadError: error compiling top-level scope: could not load library “zlib1”](https://discourse.julialang.org/t/julia-1-3-missing-windows-dependency-error-loaderror-loaderror-error-compiling-top-level-scope-could-not-load-library-zlib1/31102)

<div class="topic-metadata">

**Author:** [@vlandau](https://discourse.julialang.org/u/vlandau)\
**Replies:** 1\
**Last updated:** [November 15, 2019, 1:11am UTC](https://discourse.julialang.org/t/julia-1-3-missing-windows-dependency-error-loaderror-loaderror-error-compiling-top-level-scope-could-not-load-library-zlib1/31102 "2019-11-15T01:11:48Z")

</div>

Hi All, I’m running into an error trying to test my package on windows in Julia 1.3 via Travis. Everything works fine in Julia 1.2 but I’m confronted with this error when testing in Julia 1.3. ERROR: LoadError: LoadErr…

---

## [LightGraph tutorial](https://discourse.julialang.org/t/lightgraph-tutorial/31070)

<div class="topic-metadata">

**Author:** [@gmouts](https://discourse.julialang.org/u/gmouts)\
**Replies:** 6\
**Last updated:** [November 14, 2019, 11:16pm UTC](https://discourse.julialang.org/t/lightgraph-tutorial/31070 "2019-11-14T23:16:47Z")

</div>

I am trying to replicate this LightGraph tutorial. Right at the start it has this snippet of code: pkgs = readdir(Pkg.dir("METADATA")) filterfunc = p -\> isdir(joinpath(Pkg.dir("METADATA"), p)) && p ∉ \[".git",".test"\] pk…

---

## [JuliaDB question](https://discourse.julialang.org/t/juliadb-question/31106)

<div class="topic-metadata">

**Author:** [@stillill](https://discourse.julialang.org/u/stillill)\
**Replies:** 0\
**Last updated:** [November 14, 2019, 11:13pm UTC](https://discourse.julialang.org/t/juliadb-question/31106 "2019-11-14T23:13:22Z")

</div>

Hello, Is there a way to remove duplicate row values in JuliaDB based on a subset of columns (which are also the keys in my case)? I’m working with a distributed table in chunks in case that matters. For example, for d…

---

## [Tips for high level structuring of a Gtk.jl UI](https://discourse.julialang.org/t/tips-for-high-level-structuring-of-a-gtk-jl-ui/31090)

<div class="topic-metadata">

**Author:** [@mantzaris](https://discourse.julialang.org/u/mantzaris)\
**Replies:** 1\
**Last updated:** [November 14, 2019, 7:24pm UTC](https://discourse.julialang.org/t/tips-for-high-level-structuring-of-a-gtk-jl-ui/31090 "2019-11-14T19:24:35Z")

</div>

I am using Gtk.jl to work on a UI. There will be multiple windows and components with the box layouts in different sections. I am wondering what is the recommended structuring for the definition and organization of the c…

---

## [Unnecessary \`where {T}\` causes huge performance drop?](https://discourse.julialang.org/t/unnecessary-where-t-causes-huge-performance-drop/31078)

<div class="topic-metadata">

**Author:** [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Replies:** 6\
**Last updated:** [November 14, 2019, 2:12pm UTC](https://discourse.julialang.org/t/unnecessary-where-t-causes-huge-performance-drop/31078 "2019-11-14T14:12:02Z")

</div>

This might be a silly question but I something which I do not understand. I was playing around with different implementations of a function to check the performance changes and sometimes I left an unnecessary where {T} i…

---

## [Performance: replace conditional jump by some shift/and/or?](https://discourse.julialang.org/t/performance-replace-conditional-jump-by-some-shift-and-or/30966)

<div class="topic-metadata">

**Author:** [@rryi](https://discourse.julialang.org/u/rryi)\
**Replies:** 10\
**Last updated:** [November 14, 2019, 2:31pm UTC](https://discourse.julialang.org/t/performance-replace-conditional-jump-by-some-shift-and-or/30966 "2019-11-14T14:31:31Z")

</div>

I work on a data type which stores several fields bit-packed into a container c :: Int64. There are two different storage layouts, depending on the most significant bit. A simplified example: if bit63 is 0, my bit-packed…

---

## [How do I know when a new version of a dependency is available?](https://discourse.julialang.org/t/how-do-i-know-when-a-new-version-of-a-dependency-is-available/31083)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 2\
**Last updated:** [November 14, 2019, 2:07pm UTC](https://discourse.julialang.org/t/how-do-i-know-when-a-new-version-of-a-dependency-is-available/31083 "2019-11-14T14:07:42Z")

</div>

I have recently switched to using a comprehensive \[compat\] section in my Project.toml files in order to enable automatic registration (which works great, btw). However, now how do I know which packages get new versions …

---

## [Big endian conversion on custom datatypes](https://discourse.julialang.org/t/big-endian-conversion-on-custom-datatypes/31076)

<div class="topic-metadata">

**Author:** [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Replies:** 3\
**Last updated:** [November 14, 2019, 10:01am UTC](https://discourse.julialang.org/t/big-endian-conversion-on-custom-datatypes/31076 "2019-11-14T10:01:00Z")

</div>

I have to deal with a couple of “big endian” structures in raw files and want to parse them into Julia structs. Here is an MWE, where I have some data (big endian, coming from the network or from a file), a struct and a…

---

## [Is this function well optimized for speed?](https://discourse.julialang.org/t/is-this-function-well-optimized-for-speed/31032)

<div class="topic-metadata">

**Author:** [@Ferran\_Mazzanti](https://discourse.julialang.org/u/Ferran_Mazzanti)\
**Replies:** 13\
**Last updated:** [November 13, 2019, 11:29pm UTC](https://discourse.julialang.org/t/is-this-function-well-optimized-for-speed/31032 "2019-11-13T23:29:33Z")

</div>

Hi folks, in my process of building up a neural networks code which I can compare to my colleague’s Python code, I have a simple function that I’m calling over and over again function Log\_Unnorm\_Probs\_B(x, W, Nh) @…

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

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