# General Usage

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

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

**Page:** 772

---

## [Extract submatrix from QR factor is slow Julia 1.4](https://discourse.julialang.org/t/extract-submatrix-from-qr-factor-is-slow-julia-1-4/36582)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 3\
**Last updated:** [March 27, 2020, 4:58pm UTC](https://discourse.julialang.org/t/extract-submatrix-from-qr-factor-is-slow-julia-1-4/36582 "2020-03-27T16:58:10Z")

</div>

Hello everyone, I have a pretty large matrix A \\sim 600 \\times 200 on which I would like to perform a QR decomposition. Performing the QR decomposition takes 10ms, that seems slow to me, is there a way to make it fas…

---

## [Running julia from a shell](https://discourse.julialang.org/t/running-julia-from-a-shell/36395)

<div class="topic-metadata">

**Author:** [@AhmedAlreweny](https://discourse.julialang.org/u/AhmedAlreweny)\
**Replies:** 7\
**Last updated:** [March 27, 2020, 3:12pm UTC](https://discourse.julialang.org/t/running-julia-from-a-shell/36395 "2020-03-27T15:12:22Z")

</div>

I am trying to run a Julia code on a cluster shell (linux-based). I tried to to generate an .exe or .so file using PackageCompiler.jl to avoid having to install all of the libraries and the packages that are used in the …

---

## [Structs... creating a struct without passing all variables](https://discourse.julialang.org/t/structs-creating-a-struct-without-passing-all-variables/36588)

<div class="topic-metadata">

**Author:** [@mayar](https://discourse.julialang.org/u/mayar)\
**Replies:** 14\
**Last updated:** [March 27, 2020, 2:25pm UTC](https://discourse.julialang.org/t/structs-creating-a-struct-without-passing-all-variables/36588 "2020-03-27T14:25:39Z")

</div>

hello guys, I have defined a struct with 5 variables then I created one and I passed 3 out of 5 variables now I am getting error How do I define a struct without needing to define all variables Thank you

---

## [@deprecate of call overload](https://discourse.julialang.org/t/deprecate-of-call-overload/36578)

<div class="topic-metadata">

**Author:** [@abulak](https://discourse.julialang.org/u/abulak)\
**Replies:** 1\
**Last updated:** [March 27, 2020, 1:08pm UTC](https://discourse.julialang.org/t/deprecate-of-call-overload/36578 "2020-03-27T13:08:59Z")

</div>

module MyModule struct AAA end Base.one(A::AAA) = 1 @deprecate zero(A::AAA) one(A::AAA) end MyModule.zero(MyModule.AAA()) ┌ Warning: \`zero(A::AAA)\` is deprecated, use \`one(A::AAA)\` instead. │ caller = top-l…

---

## [Initializing "late" workers](https://discourse.julialang.org/t/initializing-late-workers/36591)

<div class="topic-metadata">

**Author:** [@pfarndt](https://discourse.julialang.org/u/pfarndt)\
**Replies:** 0\
**Last updated:** [March 27, 2020, 11:29am UTC](https://discourse.julialang.org/t/initializing-late-workers/36591 "2020-03-27T11:29:53Z")

</div>

I am using the ClusterManagers.ElasticManager to handle up to hundreds of julia processes in my cluster. Say I do: using Distributed, ClusterManagers c = ClusterManagers.ElasticManager(myip, port, "foobar") and then s…

---

## [MLJ probabilistic models basics](https://discourse.julialang.org/t/mlj-probabilistic-models-basics/36009)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 9\
**Last updated:** [March 27, 2020, 9:26am UTC](https://discourse.julialang.org/t/mlj-probabilistic-models-basics/36009 "2020-03-27T09:26:29Z")

</div>

I am new to MLJ and trying to do a linear regression: using MLJ nexamples = 10 nfeatures = 3 X = randn(nexamples, nfeatures) A = randn(nfeatures, 1) b = randn() noise = 0.1\*randn(nexamples) y = vec(X \* A .+ b) + nois…

---

## [Defining a specific dictionary key](https://discourse.julialang.org/t/defining-a-specific-dictionary-key/36485)

<div class="topic-metadata">

**Author:** [@CH-8](https://discourse.julialang.org/u/CH-8)\
**Replies:** 6\
**Last updated:** [March 27, 2020, 9:18am UTC](https://discourse.julialang.org/t/defining-a-specific-dictionary-key/36485 "2020-03-27T09:18:02Z")

</div>

Hi, I am trying to define a dictionary structure where I use a 2 element tuple as a key. A = Dict{Tuple{Int64, Int64}, Float64}(); A\[(1,2)\] = 7.0 The catch is, I don’t care for the order of the tuple. Therefore, A…

---

## [Plot, set a color to a smooth line?](https://discourse.julialang.org/t/plot-set-a-color-to-a-smooth-line/36567)

<div class="topic-metadata">

**Author:** [@BMval](https://discourse.julialang.org/u/BMval)\
**Replies:** 2\
**Last updated:** [March 27, 2020, 8:34am UTC](https://discourse.julialang.org/t/plot-set-a-color-to-a-smooth-line/36567 "2020-03-27T08:34:21Z")

</div>

I am sorry for the easy question. Would you suggest, how to set a color for a smooth line? Thank you in advance.

---

## [Time each line of a code](https://discourse.julialang.org/t/time-each-line-of-a-code/36559)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 5\
**Last updated:** [March 27, 2020, 6:46am UTC](https://discourse.julialang.org/t/time-each-line-of-a-code/36559 "2020-03-27T06:46:53Z")

</div>

Hello, Is there a way to time each line of a function without having to write @time in front of each line. I am trying to figure out what are the slowest parts of my code.

---

## [Reducing sum of OffsetArray](https://discourse.julialang.org/t/reducing-sum-of-offsetarray/36571)

<div class="topic-metadata">

**Author:** [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Replies:** 2\
**Last updated:** [March 27, 2020, 3:57am UTC](https://discourse.julialang.org/t/reducing-sum-of-offsetarray/36571 "2020-03-27T03:57:42Z")

</div>

I’m getting an error with sum(B, dims=1), where B is an OffsetArray. using OffsetArrays A = rand(3,3) B = OffsetArray(A, -1:1, 5:7) sum(A, dims=1) # OK sum(B, dims=1) # errors Here’s the output: Julia-1.4.0\> sum(A…

---

## [Show full table](https://discourse.julialang.org/t/show-full-table/36575)

<div class="topic-metadata">

**Author:** [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Replies:** 7\
**Last updated:** [March 27, 2020, 1:02am UTC](https://discourse.julialang.org/t/show-full-table/36575 "2020-03-27T01:02:02Z")

</div>

When I use a feature like print, or enter the name of a table, it shows an abridged table. Is there a way to show a complete table. I’d like to be able to cut and paste.

---

## [How to automate a laborous task (via Metaprogramming? Need to access variables of the current working space)](https://discourse.julialang.org/t/how-to-automate-a-laborous-task-via-metaprogramming-need-to-access-variables-of-the-current-working-space/36438)

<div class="topic-metadata">

**Author:** [@NilsKintscher](https://discourse.julialang.org/u/NilsKintscher)\
**Replies:** 11\
**Last updated:** [March 26, 2020, 7:24pm UTC](https://discourse.julialang.org/t/how-to-automate-a-laborous-task-via-metaprogramming-need-to-access-variables-of-the-current-working-space/36438 "2020-03-26T19:24:43Z")

</div>

I’m writing a module where a user may create and analyze arbitrary “compositions” (expressions) of so-called CrystalOperators. Right now, the manual workflow to analyze an arbitrary composition is quite laborious. I am …

---

## [Pkg error ...HELP](https://discourse.julialang.org/t/pkg-error-help/36562)

<div class="topic-metadata">

**Author:** [@mayar](https://discourse.julialang.org/u/mayar)\
**Replies:** 6\
**Last updated:** [March 26, 2020, 7:10pm UTC](https://discourse.julialang.org/t/pkg-error-help/36562 "2020-03-26T19:10:04Z")

</div>

hello guys, I am writing using Pkg but it gets a red underline What should I install or do to fix this error

---

## [Type instability when evaluating prior distributions](https://discourse.julialang.org/t/type-instability-when-evaluating-prior-distributions/19489)

<div class="topic-metadata">

**Author:** [@BenjaminBorn](https://discourse.julialang.org/u/BenjaminBorn)\
**Replies:** 8\
**Last updated:** [March 26, 2020, 6:43pm UTC](https://discourse.julialang.org/t/type-instability-when-evaluating-prior-distributions/19489 "2020-03-26T18:43:44Z")

</div>

When looking at the @code\_warntype output of the following function using Distributions const priors = \[ Normal(0, 1), Beta(2, 5)\] const pars = \[2.0, 0.9\] function prioreval\_test(priors, pars::Vector{Float64}) if …

---

## [Macro hygiene with try/catch](https://discourse.julialang.org/t/macro-hygiene-with-try-catch/36468)

<div class="topic-metadata">

**Author:** [@benninkrs](https://discourse.julialang.org/u/benninkrs)\
**Replies:** 14\
**Last updated:** [March 26, 2020, 6:40pm UTC](https://discourse.julialang.org/t/macro-hygiene-with-try-catch/36468 "2020-03-26T18:40:06Z")

</div>

I have a macro that is supposed to define a new function in the caller’s scope (plus do several other things). The code to be evaluated is wrapped in a try/catch block so that if something fails, I can clean things up. …

---

## [Dteremine the type of fields in a struct](https://discourse.julialang.org/t/dteremine-the-type-of-fields-in-a-struct/36563)

<div class="topic-metadata">

**Author:** [@Ferran\_Mazzanti](https://discourse.julialang.org/u/Ferran_Mazzanti)\
**Replies:** 1\
**Last updated:** [March 26, 2020, 6:36pm UTC](https://discourse.julialang.org/t/dteremine-the-type-of-fields-in-a-struct/36563 "2020-03-26T18:36:43Z")

</div>

Hi, is it possible to know the types of each field in an instance of a struct? Assume I have been given a code that I can’t see, but that includes a struct like this mutable struct kroko{T} where T x :: Int32; y :…

---

## [Type-instability indexing tuple](https://discourse.julialang.org/t/type-instability-indexing-tuple/36528)

<div class="topic-metadata">

**Author:** [@jonas-kr](https://discourse.julialang.org/u/jonas-kr)\
**Replies:** 5\
**Last updated:** [March 26, 2020, 3:14pm UTC](https://discourse.julialang.org/t/type-instability-indexing-tuple/36528 "2020-03-26T15:14:07Z")

</div>

Is it possible to modify the following piece of code such that it becomes type-stable? julia\> function f(x) for k in eachindex(x) display(x\[k\]) end end; julia\> a = tuple(1:2,1.0:2.0) (1:2, 1…

---

## [Broadcasting in matrix multiplication](https://discourse.julialang.org/t/broadcasting-in-matrix-multiplication/36498)

<div class="topic-metadata">

**Author:** [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)\
**Replies:** 11\
**Last updated:** [March 26, 2020, 2:48pm UTC](https://discourse.julialang.org/t/broadcasting-in-matrix-multiplication/36498 "2020-03-26T14:48:05Z")

</div>

Consider a 1x2 matrix A and a 1d array of 2x2 matrices B: A = \[1 2\] B = \[rand(2,2) for \_ in 1:3\] Obviously, B\[1\] is a 2x2 matrix, B\[2\] and B\[3\] as well. Now, I would like to get an array of matrix products \[A\*B\[1\], A\*…

---

## [Including header files for OpenCL kernels](https://discourse.julialang.org/t/including-header-files-for-opencl-kernels/36551)

<div class="topic-metadata">

**Author:** [@swishmas](https://discourse.julialang.org/u/swishmas)\
**Replies:** 0\
**Last updated:** [March 26, 2020, 1:47pm UTC](https://discourse.julialang.org/t/including-header-files-for-opencl-kernels/36551 "2020-03-26T13:47:45Z")

</div>

I think something has changed in the OpenCL.jl package about how to link header files to GPU kernels. It’s either that or I’m missing something crucial about how julia looks for packages and header files and what needs …

---

## [Array and Table not updating in a loop](https://discourse.julialang.org/t/array-and-table-not-updating-in-a-loop/36442)

<div class="topic-metadata">

**Author:** [@bandaya](https://discourse.julialang.org/u/bandaya)\
**Replies:** 4\
**Last updated:** [March 26, 2020, 1:02pm UTC](https://discourse.julialang.org/t/array-and-table-not-updating-in-a-loop/36442 "2020-03-26T13:02:51Z")

</div>

Hello, I am getting some strange behaviour in a loop which is reading some columns from a table and converting it to an array. The loop seems to exit after the first iteration. I have given a simple example below. If I c…

---

## [Type inconsistency for sum function in case of complex CuArrays](https://discourse.julialang.org/t/type-inconsistency-for-sum-function-in-case-of-complex-cuarrays/36540)

<div class="topic-metadata">

**Author:** [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Replies:** 0\
**Last updated:** [March 26, 2020, 7:57am UTC](https://discourse.julialang.org/t/type-inconsistency-for-sum-function-in-case-of-complex-cuarrays/36540 "2020-03-26T07:57:21Z")

</div>

The result of sum(abs2, a) for complex a is also complex in case of a being a CuArray: using CuArrays a = zeros(ComplexF32, 10) s = sum(abs2, a) @show typeof(s) agpu = CuArrays.zeros(ComplexF32, 10) sgpu = sum(abs2, a…

---

## [I want to filter a dataframe by a column value and then modify another column in the original dataframe based on the filtered condition. How would I do this?](https://discourse.julialang.org/t/i-want-to-filter-a-dataframe-by-a-column-value-and-then-modify-another-column-in-the-original-dataframe-based-on-the-filtered-condition-how-would-i-do-this/36502)

<div class="topic-metadata">

**Author:** [@Julia1](https://discourse.julialang.org/u/Julia1)\
**Replies:** 3\
**Last updated:** [March 26, 2020, 6:34am UTC](https://discourse.julialang.org/t/i-want-to-filter-a-dataframe-by-a-column-value-and-then-modify-another-column-in-the-original-dataframe-based-on-the-filtered-condition-how-would-i-do-this/36502 "2020-03-26T06:34:18Z")

</div>

Hi how’s it going? Let me give a simple example Say we have a dataframe df with columns A,B and C. Column B holds integer values between 1 and 40. We then have a list K of a specific subset of column B values \[1,2,3\] I…

---

## [Help with choosing the loosest \[compat\] bounds in Project.toml?](https://discourse.julialang.org/t/help-with-choosing-the-loosest-compat-bounds-in-project-toml/36530)

<div class="topic-metadata">

**Author:** [@marius311](https://discourse.julialang.org/u/marius311)\
**Replies:** 3\
**Last updated:** [March 26, 2020, 6:34am UTC](https://discourse.julialang.org/t/help-with-choosing-the-loosest-compat-bounds-in-project-toml/36530 "2020-03-26T06:34:12Z")

</div>

I’m in the situation that I just made a new package and since I needed to put \[compat\] bounds on all my dependencies to get registered, and since I haven’t been following closely the development of all these dependencies…

---

## [Is it possible to load a subset of a package?](https://discourse.julialang.org/t/is-it-possible-to-load-a-subset-of-a-package/31136)

<div class="topic-metadata">

**Author:** [@StevenWhitaker](https://discourse.julialang.org/u/StevenWhitaker)\
**Replies:** 5\
**Last updated:** [March 25, 2020, 11:51pm UTC](https://discourse.julialang.org/t/is-it-possible-to-load-a-subset-of-a-package/31136 "2020-03-25T23:51:21Z")

</div>

I have run into issues with long loading times for using some of my custom packages, and it appears to be because those packages load a lot of dependencies (as suggested here). But often my packages only need some small …

---

## [My experiences using Pkg.Artifacts for test data](https://discourse.julialang.org/t/my-experiences-using-pkg-artifacts-for-test-data/36510)

<div class="topic-metadata">

**Author:** [@NicholasWMRitchie](https://discourse.julialang.org/u/NicholasWMRitchie)\
**Replies:** 1\
**Last updated:** [March 25, 2020, 7:59pm UTC](https://discourse.julialang.org/t/my-experiences-using-pkg-artifacts-for-test-data/36510 "2020-03-25T19:59:35Z")

</div>

I really like the Pkg.Artifacts mechanism but I found it a little bit difficult to figure out how it worked from the current documentation. To help others, I’ll mention a couple of the stumbling points along the way to h…

---

## [Abstract type versus singleton struct](https://discourse.julialang.org/t/abstract-type-versus-singleton-struct/36356)

<div class="topic-metadata">

**Author:** [@Bernard\_GODARD](https://discourse.julialang.org/u/Bernard_GODARD)\
**Replies:** 6\
**Last updated:** [March 25, 2020, 7:39pm UTC](https://discourse.julialang.org/t/abstract-type-versus-singleton-struct/36356 "2020-03-25T19:39:47Z")

</div>

This question originates from a discussion in Use relative transformations by helgee · Pull Request #48 · JuliaAstro/AstroTime.jl · GitHub The AstroTime library provides a way to store and operate on Epochs in different…

---

## [Julia v1.4, @ in default environment name?](https://discourse.julialang.org/t/julia-v1-4-in-default-environment-name/36508)

<div class="topic-metadata">

**Author:** [@ccoffrin](https://discourse.julialang.org/u/ccoffrin)\
**Replies:** 2\
**Last updated:** [March 25, 2020, 6:52pm UTC](https://discourse.julialang.org/t/julia-v1-4-in-default-environment-name/36508 "2020-03-25T18:52:20Z")

</div>

In Julia v1.4 the default environment looks like (@v1.4) pkg\> previously it looked like, (v1.3) pkg\> What’s the meaning of the @?

---

## [Strange allocations during broadcasting](https://discourse.julialang.org/t/strange-allocations-during-broadcasting/26605)

<div class="topic-metadata">

**Author:** [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Replies:** 13\
**Last updated:** [March 25, 2020, 6:20pm UTC](https://discourse.julialang.org/t/strange-allocations-during-broadcasting/26605 "2020-03-25T18:20:45Z")

</div>

Can you please explain me why in the following code the second broadcasting results in 3 allocations? using BenchmarkTools u = rand(100) k1 = similar(u) k2 = similar(u) k3 = similar(u) k4 = similar(u) @btime @. $u = $…

---

## [Calling a function breaks REPL in Juno -- ERROR: unlock from wrong thread](https://discourse.julialang.org/t/calling-a-function-breaks-repl-in-juno-error-unlock-from-wrong-thread/36165)

<div class="topic-metadata">

**Author:** [@vlandau](https://discourse.julialang.org/u/vlandau)\
**Replies:** 4\
**Last updated:** [March 25, 2020, 5:29pm UTC](https://discourse.julialang.org/t/calling-a-function-breaks-repl-in-juno-error-unlock-from-wrong-thread/36165 "2020-03-25T17:29:53Z")

</div>

Running the code below in Juno renders the REPL broken, and by that I mean I can no longer run anything from the REPL. I’m trying to do more than just a simple wrapper function, but the code below was the minimum needed …

---

## [I have a list of dataframes with the same columns, how would I stack them on top of each other and make one dataframe?](https://discourse.julialang.org/t/i-have-a-list-of-dataframes-with-the-same-columns-how-would-i-stack-them-on-top-of-each-other-and-make-one-dataframe/36495)

<div class="topic-metadata">

**Author:** [@Julia1](https://discourse.julialang.org/u/Julia1)\
**Replies:** 3\
**Last updated:** [March 25, 2020, 4:05pm UTC](https://discourse.julialang.org/t/i-have-a-list-of-dataframes-with-the-same-columns-how-would-i-stack-them-on-top-of-each-other-and-make-one-dataframe/36495 "2020-03-25T16:05:51Z")

</div>

Hi how’s it going, I tried using hcat to stack each of these dataframes on top of each other, but it’s not really working as intended. I want to combine a list of dataframes, all with the same column names, into one big…

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

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