# General Usage

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

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

**Page:** 785

---

## [Condition number for a sparse matrix](https://discourse.julialang.org/t/condition-number-for-a-sparse-matrix/35049)

<div class="topic-metadata">

**Author:** [@AhmedAlreweny](https://discourse.julialang.org/u/AhmedAlreweny)\
**Replies:** 0\
**Last updated:** [February 23, 2020, 3:27pm UTC](https://discourse.julialang.org/t/condition-number-for-a-sparse-matrix/35049 "2020-02-23T15:27:24Z")

</div>

Hello, I am trying to solve a big sparse linear system using the direct solver. I get accurate results most of the times. However, sometimes the matrix is ill-conditioned and I get unreasonable solution. In this contex…

---

## [How can I reduce memory allocation and execution time while ray tracing using VoxelRayTracers package?](https://discourse.julialang.org/t/how-can-i-reduce-memory-allocation-and-execution-time-while-ray-tracing-using-voxelraytracers-package/34971)

<div class="topic-metadata">

**Author:** [@Manu\_Francis](https://discourse.julialang.org/u/Manu_Francis)\
**Replies:** 4\
**Last updated:** [February 23, 2020, 9:55am UTC](https://discourse.julialang.org/t/how-can-i-reduce-memory-allocation-and-execution-time-while-ray-tracing-using-voxelraytracers-package/34971 "2020-02-23T09:55:16Z")

</div>

Hi, I am trying to use VoxelRayTracers.jl package to trace a ray through cubic voxels. I want to improve the performance of ray tracing by reducing execution time because in my application I have to use many rays in th…

---

## [Associating information to a type](https://discourse.julialang.org/t/associating-information-to-a-type/34937)

<div class="topic-metadata">

**Author:** [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Replies:** 4\
**Last updated:** [February 23, 2020, 6:05am UTC](https://discourse.julialang.org/t/associating-information-to-a-type/34937 "2020-02-23T06:05:21Z")

</div>

Consider struct Foo end @is\_friend(Foo, "Bob") @is\_friend(Foo, "Tim") println(friends\_of(Foo)) Is there a clean way of implementing @is\_friend and friends\_of to return \["Bob", "Tim"\]? One solution is with a global D…

---

## [How to properly unwrap nested structs to access internals?](https://discourse.julialang.org/t/how-to-properly-unwrap-nested-structs-to-access-internals/35003)

<div class="topic-metadata">

**Author:** [@tlnagy](https://discourse.julialang.org/u/tlnagy)\
**Replies:** 4\
**Last updated:** [February 22, 2020, 8:39pm UTC](https://discourse.julialang.org/t/how-to-properly-unwrap-nested-structs-to-access-internals/35003 "2020-02-22T20:39:33Z")

</div>

Say I have the following architecture: struct AArray \<: AbstractArray arr end struct BArray \<: AbstractArray data::AbstractArray end struct CArray \<: AbstractArray cool\_mapping::Dict end Where I can have…

---

## [How to run tasks in parallel?](https://discourse.julialang.org/t/how-to-run-tasks-in-parallel/35018)

<div class="topic-metadata">

**Author:** [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Replies:** 6\
**Last updated:** [February 22, 2020, 8:25pm UTC](https://discourse.julialang.org/t/how-to-run-tasks-in-parallel/35018 "2020-02-22T20:25:40Z")

</div>

I am trying to understand how to work properly with multithreading. Currently, I am on julia 1.3.1, which is started with JULIA\_NUM\_THREADS=4 julia and trying to simulate simple embarrassingly parallel task. f(x) = sum(…

---

## [Error building \`PackageCompiler\`:](https://discourse.julialang.org/t/error-building-packagecompiler/35019)

<div class="topic-metadata">

**Author:** [@Iulian.Cioarca](https://discourse.julialang.org/u/Iulian.Cioarca)\
**Replies:** 2\
**Last updated:** [February 22, 2020, 7:15pm UTC](https://discourse.julialang.org/t/error-building-packagecompiler/35019 "2020-02-22T19:15:31Z")

</div>

I recently upgraded my setup and reinstalled Julia. Package compiler will not build because it’s looking for 7z.exe in the Julia bin folder instead of libexec (on Windows). (v1.3) pkg\> add PackageCompiler Resolving pac…

---

## [\`eachrow\` over Array{Any, 2} does not return rows, why?](https://discourse.julialang.org/t/eachrow-over-array-any-2-does-not-return-rows-why/34601)

<div class="topic-metadata">

**Author:** [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Replies:** 23\
**Last updated:** [February 22, 2020, 3:45pm UTC](https://discourse.julialang.org/t/eachrow-over-array-any-2-does-not-return-rows-why/34601 "2020-02-22T15:45:57Z")

</div>

I use Julia often, but mostly JuMP. I have incentivized the use of Julia in my laboratory. Today, one of my laboratory colleagues has said to me he used Julia to make a small program, and while he overall liked the langu…

---

## [Is there a more elegant solution than \`sortperm(sortperm(...))\`](https://discourse.julialang.org/t/is-there-a-more-elegant-solution-than-sortperm-sortperm/35015)

<div class="topic-metadata">

**Author:** [@pfarndt](https://discourse.julialang.org/u/pfarndt)\
**Replies:** 6\
**Last updated:** [February 22, 2020, 3:38pm UTC](https://discourse.julialang.org/t/is-there-a-more-elegant-solution-than-sortperm-sortperm/35015 "2020-02-22T15:38:36Z")

</div>

Say I have two vectors of identifiers - the second one being a shuffled version of the first one - like this: using Random, Test a = \[ randstring(5) for \_ in 1:20 \] b = shuffle(a) and now I want to loop through a such …

---

## [Dispatching on function types?](https://discourse.julialang.org/t/dispatching-on-function-types/34983)

<div class="topic-metadata">

**Author:** [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Replies:** 1\
**Last updated:** [February 22, 2020, 9:37am UTC](https://discourse.julialang.org/t/dispatching-on-function-types/34983 "2020-02-22T09:37:00Z")

</div>

Motivating problem: julia\> struct MappedElement{F \<: Function,T \<: Real} \<: Real x::T fx::T MappedElement{F}(x::T, fx::T) where {F,T} = new{F,T}(x, fx) MappedElement{F}(x, fx…

---

## [Is it possible to have a field CholeskyPivoted and update it?](https://discourse.julialang.org/t/is-it-possible-to-have-a-field-choleskypivoted-and-update-it/34946)

<div class="topic-metadata">

**Author:** [@kai](https://discourse.julialang.org/u/kai)\
**Replies:** 4\
**Last updated:** [February 22, 2020, 6:07am UTC](https://discourse.julialang.org/t/is-it-possible-to-have-a-field-choleskypivoted-and-update-it/34946 "2020-02-22T06:07:46Z")

</div>

My function performs cholesky decomposition on a matrix V many many times, so I want to create a field Vchol in my model struct m to avoid repeated allocation. So my type looks like struct m{T \<:Real} ... V::Mat…

---

## [Debugger.jl halted on the line of JSON.parse()](https://discourse.julialang.org/t/debugger-jl-halted-on-the-line-of-json-parse/34988)

<div class="topic-metadata">

**Author:** [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Replies:** 4\
**Last updated:** [February 22, 2020, 4:05am UTC](https://discourse.julialang.org/t/debugger-jl-halted-on-the-line-of-json-parse/34988 "2020-02-22T04:05:15Z")

</div>

I tested Debugger using Julia1.3 and Julia 1.2. I use command n to debug line by line. When it encounter the line using JSON.jl package. VS running a long time and halted there, and can not go to the next line. The demo…

---

## [How to create private arrays for each thread before a loop?](https://discourse.julialang.org/t/how-to-create-private-arrays-for-each-thread-before-a-loop/34987)

<div class="topic-metadata">

**Author:** [@pedrohnv](https://discourse.julialang.org/u/pedrohnv)\
**Replies:** 2\
**Last updated:** [February 21, 2020, 10:39pm UTC](https://discourse.julialang.org/t/how-to-create-private-arrays-for-each-thread-before-a-loop/34987 "2020-02-21T22:39:30Z")

</div>

I have a loop that does some linear algebra. Each iteration is independent of each other. I need some helper arrays in each iteration. How can I make each thread allocate its helper arrays once before the loop? In the e…

---

## [Issues querying a DataFrame](https://discourse.julialang.org/t/issues-querying-a-dataframe/34943)

<div class="topic-metadata">

**Author:** [@bensetterholm](https://discourse.julialang.org/u/bensetterholm)\
**Replies:** 5\
**Last updated:** [February 21, 2020, 8:21pm UTC](https://discourse.julialang.org/t/issues-querying-a-dataframe/34943 "2020-02-21T20:21:57Z")

</div>

Suppose I have a DataFrame df which was generated by a Dictionary which may include whitespace in the keys using DataFrames myDict = Dict() myDict\["aKey"\] = 1:10 myDict\["anotherKey"\] = zeros(10) myDict\["a\_nice\_key"\] = …

---

## [Parametric and Union Types](https://discourse.julialang.org/t/parametric-and-union-types/34932)

<div class="topic-metadata">

**Author:** [@fedario](https://discourse.julialang.org/u/fedario)\
**Replies:** 11\
**Last updated:** [February 21, 2020, 8:11pm UTC](https://discourse.julialang.org/t/parametric-and-union-types/34932 "2020-02-21T20:11:50Z")

</div>

Hi Community! While playing around with types, some questions came up: What is the difference between Type{\<:Union{Int,String}} and Union{Type{Int}, Type{String}}? Type{\<:Union{Int,String}} |\> supertype # Any Typ…

---

## [Serious slowdown with FFTW v1.1.0 and v1.2.0 on Windows](https://discourse.julialang.org/t/serious-slowdown-with-fftw-v1-1-0-and-v1-2-0-on-windows/34726)

<div class="topic-metadata">

**Author:** [@turtle](https://discourse.julialang.org/u/turtle)\
**Replies:** 21\
**Last updated:** [February 21, 2020, 2:22pm UTC](https://discourse.julialang.org/t/serious-slowdown-with-fftw-v1-1-0-and-v1-2-0-on-windows/34726 "2020-02-21T14:22:38Z")

</div>

I have just upgraded from Julia 0.7.0 → 1.0.5 and 1.3.1, and experienced a serious slowdown. It seems to me that the reason is the default FFTW version that is: FFTW v0.2.4 for Julia 0.7.0 FFTW v1.1.0 for Julia 1.0.5 …

---

## [Multi-thread parsing json](https://discourse.julialang.org/t/multi-thread-parsing-json/33389)

<div class="topic-metadata">

**Author:** [@racinmat](https://discourse.julialang.org/u/racinmat)\
**Replies:** 16\
**Last updated:** [February 21, 2020, 2:07pm UTC](https://discourse.julialang.org/t/multi-thread-parsing-json/33389 "2020-02-21T14:07:31Z")

</div>

Hi, I am loading lots of gzipped jsons, parsing and further processing them. TL;DR: Why is map much slower than list comprehension/dot notation when using in tmap on multiple threads? I am trying to use multiple thread…

---

## [Pmap and udp socket communication causes segmentation fault](https://discourse.julialang.org/t/pmap-and-udp-socket-communication-causes-segmentation-fault/34977)

<div class="topic-metadata">

**Author:** [@racinmat](https://discourse.julialang.org/u/racinmat)\
**Replies:** 0\
**Last updated:** [February 21, 2020, 2:05pm UTC](https://discourse.julialang.org/t/pmap-and-udp-socket-communication-causes-segmentation-fault/34977 "2020-02-21T14:05:04Z")

</div>

I need to do some data processing in a highly parallel manner and want to track how many of it was done. For that, I am using pmap and sending some message over UDP to signal that a single sample was processed (to send …

---

## [Warntype from anonymous function](https://discourse.julialang.org/t/warntype-from-anonymous-function/34975)

<div class="topic-metadata">

**Author:** [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Replies:** 1\
**Last updated:** [February 21, 2020, 1:23pm UTC](https://discourse.julialang.org/t/warntype-from-anonymous-function/34975 "2020-02-21T13:23:02Z")

</div>

anonymous = (x -\> 2x) callanonymous(a) = anonymous(a) normal(x) = 2x callnormal(a) = normal(a) julia\> @code\_warntype callanonymous(1) Body::Any 1 ─ %1 = Main.anonymous(a)::Any └── return %1 julia\> @code\_warntype …

---

## [Data Layout](https://discourse.julialang.org/t/data-layout/34974)

<div class="topic-metadata">

**Author:** [@Kruxigt](https://discourse.julialang.org/u/Kruxigt)\
**Replies:** 1\
**Last updated:** [February 21, 2020, 1:04pm UTC](https://discourse.julialang.org/t/data-layout/34974 "2020-02-21T13:04:26Z")

</div>

Good day! I’m trying to come up with the best data layout using structs for the following situation. I have a struct mutable struct MyStruct field1::Float64 field2::String end From this struct I would like to li…

---

## [Type system limitations](https://discourse.julialang.org/t/type-system-limitations/34963)

<div class="topic-metadata">

**Author:** [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Replies:** 5\
**Last updated:** [February 21, 2020, 12:39pm UTC](https://discourse.julialang.org/t/type-system-limitations/34963 "2020-02-21T12:39:09Z")

</div>

Conceptually I want to do something like function f(x::V{T}, y::W{U}) where V where T where W where U yy = convert(V{U}, y) ... end which is not possible, and seems to be a common problem (https://discourse.juli…

---

## [Packages that depend on unregistered packages](https://discourse.julialang.org/t/packages-that-depend-on-unregistered-packages/34908)

<div class="topic-metadata">

**Author:** [@RJDennis](https://discourse.julialang.org/u/RJDennis)\
**Replies:** 2\
**Last updated:** [February 21, 2020, 10:27am UTC](https://discourse.julialang.org/t/packages-that-depend-on-unregistered-packages/34908 "2020-02-21T10:27:27Z")

</div>

Hi All, I have a package that was registered pre-0.7 and that has a REQUIRE file and not a Project.toml file. I want to make improvements to this package and tag an update. The improvements that I want to make will ma…

---

## [ERROR: \[...\] is not satisfied, cannot generate deps.jl! when building after a Pkg.update()](https://discourse.julialang.org/t/error-is-not-satisfied-cannot-generate-deps-jl-when-building-after-a-pkg-update/34953)

<div class="topic-metadata">

**Author:** [@ElectronicTeaCup](https://discourse.julialang.org/u/ElectronicTeaCup)\
**Replies:** 0\
**Last updated:** [February 21, 2020, 7:40am UTC](https://discourse.julialang.org/t/error-is-not-satisfied-cannot-generate-deps-jl-when-building-after-a-pkg-update/34953 "2020-02-21T07:40:55Z")

</div>

I’m getting this kind of error on a couple of dependencies of a package (MAT.jl). I get an idea from the error that the requirements for the package aren’t fulfilled—but these packages weren’t updated recently. Can anyon…

---

## [Unknown hang-up in v1.3.1](https://discourse.julialang.org/t/unknown-hang-up-in-v1-3-1/34912)

<div class="topic-metadata">

**Author:** [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Replies:** 8\
**Last updated:** [February 21, 2020, 7:16am UTC](https://discourse.julialang.org/t/unknown-hang-up-in-v1-3-1/34912 "2020-02-21T07:16:37Z")

</div>

Julia v1.3.1 hangs when running the following call of pickvarnames(:(a + b)): pickvarnames(ex::Symbol) = ex function pickvarnames(ex::Expr) varnames = () if ex.head == :call for arg in ex.args\[2:end\] …

---

## [Future.randjump peculiar speed](https://discourse.julialang.org/t/future-randjump-peculiar-speed/34862)

<div class="topic-metadata">

**Author:** [@stephenll](https://discourse.julialang.org/u/stephenll)\
**Replies:** 1\
**Last updated:** [February 21, 2020, 3:05am UTC](https://discourse.julialang.org/t/future-randjump-peculiar-speed/34862 "2020-02-21T03:05:07Z")

</div>

At my company we typically break up the simulations into predefined fixed “chunks”, and assign a seed to each chunk this way the dynamic scheduler in the threading is repeatable no matter the number of threads. I have b…

---

## [Reading different types of data from single line in binary file](https://discourse.julialang.org/t/reading-different-types-of-data-from-single-line-in-binary-file/34915)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 7\
**Last updated:** [February 20, 2020, 10:37pm UTC](https://discourse.julialang.org/t/reading-different-types-of-data-from-single-line-in-binary-file/34915 "2020-02-20T22:37:18Z")

</div>

Edit: I changed the description in a following answer to clarify the issue. I need to read a binary file which contains more than one type of variable written in a single line, as if it was written with i = 1 ; x = 1e…

---

## [How to prevent \`Updating registry; Resolving package\`, while running \`Pkg\> test\`](https://discourse.julialang.org/t/how-to-prevent-updating-registry-resolving-package-while-running-pkg-test/34927)

<div class="topic-metadata">

**Author:** [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Replies:** 1\
**Last updated:** [February 20, 2020, 5:59pm UTC](https://discourse.julialang.org/t/how-to-prevent-updating-registry-resolving-package-while-running-pkg-test/34927 "2020-02-20T17:59:59Z")

</div>

I am developing some package. I run Pkg\> test for testing purpose. However, every time it take some time to update registry, git-repo and resolving package versions. If I work without network, it even fails. Is there any…

---

## [Functions inside loops](https://discourse.julialang.org/t/functions-inside-loops/22947)

<div class="topic-metadata">

**Author:** [@lacaca](https://discourse.julialang.org/u/lacaca)\
**Replies:** 3\
**Last updated:** [February 20, 2020, 5:50pm UTC](https://discourse.julialang.org/t/functions-inside-loops/22947 "2020-02-20T17:50:20Z")

</div>

Defining a function f inside a loop, using it and then redefining it to behave some other way actually does not work as I thought it would/should. For instance, this

---

## [Plots & LaTeX?](https://discourse.julialang.org/t/plots-latex/34902)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 4\
**Last updated:** [February 20, 2020, 5:34pm UTC](https://discourse.julialang.org/t/plots-latex/34902 "2020-02-20T17:34:56Z")

</div>

It seems like Plots (pyplot backend) doesn’t make a distinction between LaTeX symbols \\epsilon (\\epsilon) and \\varepsilon (\\varepsilon). However, it does make a distinction between \\sigma (\\sigma) and \\varsigma (\\varsigm…

---

## [OnlineStats at Series how to get numer of case? s.n , n(s) not works](https://discourse.julialang.org/t/onlinestats-at-series-how-to-get-numer-of-case-s-n-n-s-not-works/34913)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 2\
**Last updated:** [February 20, 2020, 4:45pm UTC](https://discourse.julialang.org/t/onlinestats-at-series-how-to-get-numer-of-case-s-n-n-s-not-works/34913 "2020-02-20T16:45:15Z")

</div>

using OnlineStats, Distributed julia\> s = @distributed merge for i in 1:3 fit!(Series(Mean()), randn(10\_000)) end Series └── Mean: n=30000 | value=0.0018463 julia\> s.stats (Mean: n=30000 | value=0.00170161,) juli…

---

## [What is wrong with my profiling?](https://discourse.julialang.org/t/what-is-wrong-with-my-profiling/34898)

<div class="topic-metadata">

**Author:** [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Replies:** 4\
**Last updated:** [February 20, 2020, 3:26pm UTC](https://discourse.julialang.org/t/what-is-wrong-with-my-profiling/34898 "2020-02-20T15:26:36Z")

</div>

I am profiling my Deep Learning algorithm and I am getting this weird shape. That long line on the left does not make sense, is it precompiling or something ? The name of the top bar is task.jl,poptaskref: line 660. Mayb…

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

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