# General Usage

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

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

**Page:** 812

---

## [Types for log-domain values](https://discourse.julialang.org/t/types-for-log-domain-values/31394)

<div class="topic-metadata">

**Author:** [@maxmouchet](https://discourse.julialang.org/u/maxmouchet)\
**Replies:** 12\
**Last updated:** [November 24, 2019, 6:59am UTC](https://discourse.julialang.org/t/types-for-log-domain-values/31394 "2019-11-24T06:59:25Z")

</div>

Hi, I was wondering if there are existing solutions to the following problem. In statistics, it is common to work with likelihoods (positive reals) or log-likelihoods values. Let’s say that we want to implement an alg…

---

## [@threads for only using master thread?](https://discourse.julialang.org/t/threads-for-only-using-master-thread/27725)

<div class="topic-metadata">

**Author:** [@dstarerstor](https://discourse.julialang.org/u/dstarerstor)\
**Replies:** 7\
**Last updated:** [November 24, 2019, 6:43am UTC](https://discourse.julialang.org/t/threads-for-only-using-master-thread/27725 "2019-11-24T06:43:23Z")

</div>

I just switched to 1.3 to try out implementing multithreaded algorithms. I tried a very simple loop, from the announcement post: Threads.@threads for i = 1:10 println(Threads.threadid(), " of ", Threads.nthreads()) e…

---

## [Threads.@spawn not using master thread](https://discourse.julialang.org/t/threads-spawn-not-using-master-thread/31442)

<div class="topic-metadata">

**Author:** [@ignis](https://discourse.julialang.org/u/ignis)\
**Replies:** 2\
**Last updated:** [November 24, 2019, 4:56am UTC](https://discourse.julialang.org/t/threads-spawn-not-using-master-thread/31442 "2019-11-24T04:56:37Z")

</div>

I’ve been using Julia to parallelize some algorithms, so I’m also studying how julia parallel programming works. I did a simple code to check the behavior of Threads.@spawn and I’ve noticed it would only use the master …

---

## [Functions inside functions using "global" variables](https://discourse.julialang.org/t/functions-inside-functions-using-global-variables/31434)

<div class="topic-metadata">

**Author:** [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Replies:** 2\
**Last updated:** [November 23, 2019, 11:08pm UTC](https://discourse.julialang.org/t/functions-inside-functions-using-global-variables/31434 "2019-11-23T23:08:23Z")

</div>

Hi! I need help about constructing functions inside functions that use variables that “seems” global: function a() aux = Float64\[\] b = ()-\>begin push!(aux, rand()) end b() b() return aux…

---

## [Regular Expression and Threads](https://discourse.julialang.org/t/regular-expression-and-threads/31415)

<div class="topic-metadata">

**Author:** [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)\
**Replies:** 3\
**Last updated:** [November 23, 2019, 7:07pm UTC](https://discourse.julialang.org/t/regular-expression-and-threads/31415 "2019-11-23T19:07:11Z")

</div>

Hi All, in our Flux ML project, we need to process large volume of data with a single models. We do it by dividing the minibatch into chunks, calculate gradient on each chunk in a separate thread, and reduce it (is it c…

---

## [REPL domain error for exponentiation](https://discourse.julialang.org/t/repl-domain-error-for-exponentiation/31408)

<div class="topic-metadata">

**Author:** [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Replies:** 4\
**Last updated:** [November 23, 2019, 1:05pm UTC](https://discourse.julialang.org/t/repl-domain-error-for-exponentiation/31408 "2019-11-23T13:05:19Z")

</div>

Why julia\> 2^-10 0.0009765625 julia\> t = -10 -10 julia\> 2^t ERROR: DomainError with -10: Cannot raise an integer x to a negative power -10. Make x or -10 a float by adding a zero decimal (e.g., 2.0^-10 or 2^-10.0 inst…

---

## [Good road network routing packages in julia using .osm data?](https://discourse.julialang.org/t/good-road-network-routing-packages-in-julia-using-osm-data/31417)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 0\
**Last updated:** [November 23, 2019, 12:02pm UTC](https://discourse.julialang.org/t/good-road-network-routing-packages-in-julia-using-osm-data/31417 "2019-11-23T12:02:31Z")

</div>

Hi. I was wondering, is there any good road network routing package in Julia, using .osm data? Any suggestions?

---

## [Code execution problem](https://discourse.julialang.org/t/code-execution-problem/31307)

<div class="topic-metadata">

**Author:** [@dty](https://discourse.julialang.org/u/dty)\
**Replies:** 16\
**Last updated:** [November 23, 2019, 11:06am UTC](https://discourse.julialang.org/t/code-execution-problem/31307 "2019-11-23T11:06:36Z")

</div>

---

## [Macro Question where I can't do the proper substition](https://discourse.julialang.org/t/macro-question-where-i-cant-do-the-proper-substition/31413)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 3\
**Last updated:** [November 23, 2019, 7:22am UTC](https://discourse.julialang.org/t/macro-question-where-i-cant-do-the-proper-substition/31413 "2019-11-23T07:22:10Z")

</div>

julia\> macro testy() args=\[:T,:U,:M\] code = :(foreach(a-\>println(typeof(a)),$args)) quote macro qq($(args...)) $code |\>esc end …

---

## [Ccall() and libc on Linux](https://discourse.julialang.org/t/ccall-and-libc-on-linux/31402)

<div class="topic-metadata">

**Author:** [@mleisher](https://discourse.julialang.org/u/mleisher)\
**Replies:** 3\
**Last updated:** [November 22, 2019, 10:28pm UTC](https://discourse.julialang.org/t/ccall-and-libc-on-linux/31402 "2019-11-22T22:28:09Z")

</div>

Trying to use ccall() to call a function from libc and julia only finds the GNU ld script in /usr/lib64/libc.so, not the actual library which is located in /lib64/libc.so.6. Can julia be told to parse the GNU ld script …

---

## [JSON to Array of DataFrames](https://discourse.julialang.org/t/json-to-array-of-dataframes/31391)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 4\
**Last updated:** [November 22, 2019, 8:30pm UTC](https://discourse.julialang.org/t/json-to-array-of-dataframes/31391 "2019-11-22T20:30:03Z")

</div>

Hi all- I am trying to store an array of DataFrames as a JSON file and read the JSON file back as the same array of DataFrames. As far as I can tell, the best approach currently is to use JSONTables. Unfortunately, I a…

---

## [Scale.y\_continuous percentage format](https://discourse.julialang.org/t/scale-y-continuous-percentage-format/31397)

<div class="topic-metadata">

**Author:** [@Phillip\_Sutton](https://discourse.julialang.org/u/Phillip_Sutton)\
**Replies:** 4\
**Last updated:** [November 22, 2019, 8:19pm UTC](https://discourse.julialang.org/t/scale-y-continuous-percentage-format/31397 "2019-11-22T20:19:41Z")

</div>

Is there way to format the y axis as percentages in Gadfly? Something like Scale.y\_continuous(format=:percent)

---

## [Solving delayed differential equations with Julia](https://discourse.julialang.org/t/solving-delayed-differential-equations-with-julia/30827)

<div class="topic-metadata">

**Author:** [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Replies:** 6\
**Last updated:** [November 22, 2019, 5:26pm UTC](https://discourse.julialang.org/t/solving-delayed-differential-equations-with-julia/30827 "2019-11-22T17:26:01Z")

</div>

Dear all, I would like to solve some delayed differential equations that look like this where t is a fix time and x is a variable time point. I understand that there are specific packages that do this analysis, one …

---

## [Slow Custom Digits Iterator](https://discourse.julialang.org/t/slow-custom-digits-iterator/31367)

<div class="topic-metadata">

**Author:** [@jebej](https://discourse.julialang.org/u/jebej)\
**Replies:** 7\
**Last updated:** [November 22, 2019, 4:52pm UTC](https://discourse.julialang.org/t/slow-custom-digits-iterator/31367 "2019-11-22T16:52:38Z")

</div>

I was trying to replace calls to digits, which allocates, with a custom iterator, but for some reason calling sum on it is really slow and allocates, despite e.g. calls to collect being fast: using BenchmarkTools struc…

---

## [Accessing the solution of differential equations: understanding alloc](https://discourse.julialang.org/t/accessing-the-solution-of-differential-equations-understanding-alloc/31364)

<div class="topic-metadata">

**Author:** [@Egwene\_al\_Vere](https://discourse.julialang.org/u/Egwene_al_Vere)\
**Replies:** 3\
**Last updated:** [November 22, 2019, 2:30pm UTC](https://discourse.julialang.org/t/accessing-the-solution-of-differential-equations-understanding-alloc/31364 "2019-11-22T14:30:41Z")

</div>

I’m preallocating an array for the solution of an ODE at each time step, for post-processing. However, julia --track-allocation=user foo.jl still reports large allocations. To simplify with @btime: using DifferentialEqu…

---

## [Accessing 2D array/matrix values with Booleans](https://discourse.julialang.org/t/accessing-2d-array-matrix-values-with-booleans/31384)

<div class="topic-metadata">

**Author:** [@keeler](https://discourse.julialang.org/u/keeler)\
**Replies:** 3\
**Last updated:** [November 22, 2019, 2:03pm UTC](https://discourse.julialang.org/t/accessing-2d-array-matrix-values-with-booleans/31384 "2019-11-22T14:03:26Z")

</div>

Take a matrix A and a vector of Booleans , say, booleRand (whose length is the same as the number of columns or rows in A). I want to be able to access entire rows or columns using the Boolean vector. I am a bit surpris…

---

## [For loop in function and multiplication of larger matrices, slow speed in parallel](https://discourse.julialang.org/t/for-loop-in-function-and-multiplication-of-larger-matrices-slow-speed-in-parallel/31258)

<div class="topic-metadata">

**Author:** [@luboshanus](https://discourse.julialang.org/u/luboshanus)\
**Replies:** 3\
**Last updated:** [November 22, 2019, 1:42pm UTC](https://discourse.julialang.org/t/for-loop-in-function-and-multiplication-of-larger-matrices-slow-speed-in-parallel/31258 "2019-11-22T13:42:58Z")

</div>

Hello, I’d like to understand how does the performance of large for loops in julia work? Running the same function on one core or on multiple cores does not give me similar time results. The computer has 48 physical co…

---

## [Improving Performance of this Code](https://discourse.julialang.org/t/improving-performance-of-this-code/31326)

<div class="topic-metadata">

**Author:** [@jmcastro2109](https://discourse.julialang.org/u/jmcastro2109)\
**Replies:** 12\
**Last updated:** [November 22, 2019, 11:59am UTC](https://discourse.julialang.org/t/improving-performance-of-this-code/31326 "2019-11-22T11:59:25Z")

</div>

Hello! I am trying to solve a big model and at the core I have the following loop which essentially solves a Backward Induction Problem. In what follows I provide a MWE. In my model, I am solving this problem many many…

---

## [Save Array of Arrays in HDF5](https://discourse.julialang.org/t/save-array-of-arrays-in-hdf5/31359)

<div class="topic-metadata">

**Author:** [@jacob-roth](https://discourse.julialang.org/u/jacob-roth)\
**Replies:** 1\
**Last updated:** [November 22, 2019, 9:26am UTC](https://discourse.julialang.org/t/save-array-of-arrays-in-hdf5/31359 "2019-11-22T09:26:43Z")

</div>

Continuing the discussion from here and here, how can I best save a large number of arrays using HDF5? And more generally, how can I save an array of arrays? I know that HDF5 doesn’t support array of arrays, so trying t…

---

## [Isapprox documentation has argument norm, but call signature does not?](https://discourse.julialang.org/t/isapprox-documentation-has-argument-norm-but-call-signature-does-not/31072)

<div class="topic-metadata">

**Author:** [@jtg](https://discourse.julialang.org/u/jtg)\
**Replies:** 5\
**Last updated:** [November 21, 2019, 11:01pm UTC](https://discourse.julialang.org/t/isapprox-documentation-has-argument-norm-but-call-signature-does-not/31072 "2019-11-21T23:01:17Z")

</div>

I noticed this trying to extend the function. I am using: Julia Version 1.3.0-rc4.1 Commit 8c4656b97a (2019-10-15 14:08 UTC) Platform Info: OS: macOS (x86\_64-apple-darwin18.6.0) CPU: Intel(R) Core(TM) i5-8279U CPU…

---

## [How can I make this plot?](https://discourse.julialang.org/t/how-can-i-make-this-plot/31278)

<div class="topic-metadata">

**Author:** [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Replies:** 11\
**Last updated:** [November 21, 2019, 4:37pm UTC](https://discourse.julialang.org/t/how-can-i-make-this-plot/31278 "2019-11-21T16:37:01Z")

</div>

I came across this article on Freakonometrics and it has the following really nice plot in it (generated with R, I believe): Has anyone seen anything similar plotted in Julia or does anyone know if this is at least po…

---

## [Optimization of Code for NaN Operations](https://discourse.julialang.org/t/optimization-of-code-for-nan-operations/31339)

<div class="topic-metadata">

**Author:** [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Replies:** 3\
**Last updated:** [November 21, 2019, 8:50pm UTC](https://discourse.julialang.org/t/optimization-of-code-for-nan-operations/31339 "2019-11-21T20:50:33Z")

</div>

Hi, I’ve been trying to perform operations on Arrays that may have missing values, using the below prototype function: function nanop(f::Function,data::Array;dim=1) ndim = ndims(data); dsize = size(data); if nd…

---

## [How to proper debug Julia?](https://discourse.julialang.org/t/how-to-proper-debug-julia/31234)

<div class="topic-metadata">

**Author:** [@adrpo](https://discourse.julialang.org/u/adrpo)\
**Replies:** 6\
**Last updated:** [November 21, 2019, 7:31pm UTC](https://discourse.julialang.org/t/how-to-proper-debug-julia/31234 "2019-11-21T19:31:27Z")

</div>

Hi all, I have some code that works fine in Atom/Juno debugger but when I run it directly in Julia it goes in some sort of cycle and spins forever. Any ideas on how to debug such a thing? I have tried to attach to the j…

---

## [Calculating the \`k\` smallest positive eigenvalues of a matrix with ARPACK](https://discourse.julialang.org/t/calculating-the-k-smallest-positive-eigenvalues-of-a-matrix-with-arpack/28864)

<div class="topic-metadata">

**Author:** [@sergevic](https://discourse.julialang.org/u/sergevic)\
**Replies:** 25\
**Last updated:** [November 21, 2019, 7:13pm UTC](https://discourse.julialang.org/t/calculating-the-k-smallest-positive-eigenvalues-of-a-matrix-with-arpack/28864 "2019-11-21T19:13:20Z")

</div>

I have a sqaure matrix that is not necessarily positive definite, for example rand(10000,10000), and I’m trying to obtain the k smallest positive eigenvalues with the command eigs() from ARPACK. How can I achieve that pr…

---

## [Current practice for specifying custom target dependencies?](https://discourse.julialang.org/t/current-practice-for-specifying-custom-target-dependencies/31349)

<div class="topic-metadata">

**Author:** [@garborg](https://discourse.julialang.org/u/garborg)\
**Replies:** 2\
**Last updated:** [November 21, 2019, 4:10pm UTC](https://discourse.julialang.org/t/current-practice-for-specifying-custom-target-dependencies/31349 "2019-11-21T16:10:15Z")

</div>

I’m looking to specify extra dependencies for code in an ‘example’ dir and separately for code in a ‘benchmark’ dir of a package. Akin to how ‘targets’ and ‘extras’ works for test dependencies. Early discussions I saw …

---

## [Check whether the type of an object is from a package not loaded](https://discourse.julialang.org/t/check-whether-the-type-of-an-object-is-from-a-package-not-loaded/31344)

<div class="topic-metadata">

**Author:** [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Replies:** 2\
**Last updated:** [November 21, 2019, 2:03pm UTC](https://discourse.julialang.org/t/check-whether-the-type-of-an-object-is-from-a-package-not-loaded/31344 "2019-11-21T14:03:44Z")

</div>

I have a package A in which I’d like to have a functionality foo which works on AbstractArray but does something different on LazyArrays.ApplyArray. twist: I would like not to have LazyArrays loaded in A. Is this pos…

---

## [Periodic Schur decomposition](https://discourse.julialang.org/t/periodic-schur-decomposition/30682)

<div class="topic-metadata">

**Author:** [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Replies:** 3\
**Last updated:** [November 21, 2019, 2:31pm UTC](https://discourse.julialang.org/t/periodic-schur-decomposition/30682 "2019-11-21T14:31:03Z")

</div>

Hi, I am wondering if anybody has implemented, and is willing to share, a periodic Schur decomposition. The first paper mentioning it is D. Kressner, An efficient and reliable implementation of the periodic qz algorith…

---

## [CSV, DataFrames problems with threads](https://discourse.julialang.org/t/csv-dataframes-problems-with-threads/31318)

<div class="topic-metadata">

**Author:** [@Rudi79](https://discourse.julialang.org/u/Rudi79)\
**Replies:** 2\
**Last updated:** [November 21, 2019, 2:30pm UTC](https://discourse.julialang.org/t/csv-dataframes-problems-with-threads/31318 "2019-11-21T14:30:44Z")

</div>

Today I encountered an odd problem: using CSV, DataFrames dt = DataFrame(a = rand(10000), b = rand(10000), c = rand(10000)) CSV.write("test.csv", dt) df = CSV.File("test.csv") |\> DataFrame! df\[(ismissing.(df.a)) .| (is…

---

## [Inner constructors with parametric types, can't seem to get them to work for me](https://discourse.julialang.org/t/inner-constructors-with-parametric-types-cant-seem-to-get-them-to-work-for-me/31337)

<div class="topic-metadata">

**Author:** [@tlnagy](https://discourse.julialang.org/u/tlnagy)\
**Replies:** 3\
**Last updated:** [November 21, 2019, 1:56pm UTC](https://discourse.julialang.org/t/inner-constructors-with-parametric-types-cant-seem-to-get-them-to-work-for-me/31337 "2019-11-21T13:56:13Z")

</div>

Say I have a type that looks the following: julia\> struct Test{T, N, A} \<: AbstractArray{T, N} a::Dict{NTuple{N, Int}, String} b::Type{T} c::A d::Array{T, 2} funct…

---

## [Performance of the iterator approach](https://discourse.julialang.org/t/performance-of-the-iterator-approach/31293)

<div class="topic-metadata">

**Author:** [@alanderos](https://discourse.julialang.org/u/alanderos)\
**Replies:** 3\
**Last updated:** [November 21, 2019, 7:27am UTC](https://discourse.julialang.org/t/performance-of-the-iterator-approach/31293 "2019-11-21T07:27:11Z")

</div>

I started using IterativeSolvers.jl in some of my work and found the iterator-based code to be easy on the eyes and rather slick. It seems to me that any Julia implementation of an iterative algorithm ought to adopt this…

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

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