# General Usage

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

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

**Page:** 605

---

## [Invalid sink argument after upgrading to julia 1.6](https://discourse.julialang.org/t/invalid-sink-argument-after-upgrading-to-julia-1-6/60465)

<div class="topic-metadata">

**Author:** [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Replies:** 2\
**Last updated:** [May 3, 2021, 2:57pm UTC](https://discourse.julialang.org/t/invalid-sink-argument-after-upgrading-to-julia-1-6/60465 "2021-05-03T14:57:22Z")

</div>

I updated to Julia 1.6 by downloading the generic linux and moving them in the folder I keep julia. I launched atom, reinstalled all the packages (I need to do it every time I update, so I try to upgrade as little as pos…

---

## [Undef array with customized index](https://discourse.julialang.org/t/undef-array-with-customized-index/60377)

<div class="topic-metadata">

**Author:** [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Replies:** 17\
**Last updated:** [May 3, 2021, 2:17pm UTC](https://discourse.julialang.org/t/undef-array-with-customized-index/60377 "2021-05-03T14:17:11Z")

</div>

I’m curious if there is a convenient way to define an array with customized index. In fortran, we have real, dimension(2:6) :: array. I know in julia we can use Array{Float64}(undef, 10) to declare a 10-element array w…

---

## [Import ONNX model](https://discourse.julialang.org/t/import-onnx-model/60260)

<div class="topic-metadata">

**Author:** [@March-08](https://discourse.julialang.org/u/March-08)\
**Replies:** 3\
**Last updated:** [May 3, 2021, 12:22pm UTC](https://discourse.julialang.org/t/import-onnx-model/60260 "2021-05-03T12:22:11Z")

</div>

Hi. I am having issues including ONNX models in my code. mnistnet = ONNX.load\_model("/user/mp/home/models/vision/classification/mnist/model/mnist-1.onnx") weights = ONNX.load\_weights("/user/mp/home/models/vision/classi…

---

## [No method matching loss\_multiple\_shooting](https://discourse.julialang.org/t/no-method-matching-loss-multiple-shooting/60445)

<div class="topic-metadata">

**Author:** [@raj6798](https://discourse.julialang.org/u/raj6798)\
**Replies:** 1\
**Last updated:** [May 3, 2021, 11:55am UTC](https://discourse.julialang.org/t/no-method-matching-loss-multiple-shooting/60445 "2021-05-03T11:55:07Z")

</div>

using DataDrivenDiffEq using DiffEqFlux, Flux using Plots path = @DIR include(“multipleshooting.jl”) Mutliple shoot function #include(“Multiple\_shooting1.jl”) generating possible basis @variables x\[1:ns\] # variabl…

---

## [How to specify text in Plots? (font family, font size, etc.)](https://discourse.julialang.org/t/how-to-specify-text-in-plots-font-family-font-size-etc/60311)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 3\
**Last updated:** [May 3, 2021, 7:44am UTC](https://discourse.julialang.org/t/how-to-specify-text-in-plots-font-family-font-size-etc/60311 "2021-05-03T07:44:29Z")

</div>

Suppose I have a plot using package Plots.jl, and I specify the title: plot!(title="My title") How do I modify the font family, font style, font size, etc.? A link to where in the documentation would do.

---

## [When Should One Use \`(...)\` or \`\[...\]\` for Array Comprehensions](https://discourse.julialang.org/t/when-should-one-use-or-for-array-comprehensions/60423)

<div class="topic-metadata">

**Author:** [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)\
**Replies:** 3\
**Last updated:** [May 3, 2021, 7:11am UTC](https://discourse.julialang.org/t/when-should-one-use-or-for-array-comprehensions/60423 "2021-05-03T07:11:11Z")

</div>

When Should One Use (...) or \[...\] for Array Comprehensions? What is the difference between the 2? From Slack: julia\> @btime \[x^2 for x in 1:10000\]; 6.519 μs (2 allocations: 78.20 KiB)julia\> @btime (x^2 for x in 1:1…

---

## [Calling \`first(some\_set)\` gets me "ArgumentError: collection must be non-empty", even though I checked the Set for emptiness immediately before](https://discourse.julialang.org/t/calling-first-some-set-gets-me-argumenterror-collection-must-be-non-empty-even-though-i-checked-the-set-for-emptiness-immediately-before/60449)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 2\
**Last updated:** [May 3, 2021, 10:36am UTC](https://discourse.julialang.org/t/calling-first-some-set-gets-me-argumenterror-collection-must-be-non-empty-even-though-i-checked-the-set-for-emptiness-immediately-before/60449 "2021-05-03T10:36:18Z")

</div>

This is Julia 1.6.1. I hit an error that seems really weird right now. The code’s basically like this: loop if isempty(some\_set) # Change some\_set # ... conti…

---

## [Floating subplot in Plots recipe?](https://discourse.julialang.org/t/floating-subplot-in-plots-recipe/60441)

<div class="topic-metadata">

**Author:** [@jdh62043](https://discourse.julialang.org/u/jdh62043)\
**Replies:** 1\
**Last updated:** [May 3, 2021, 5:43am UTC](https://discourse.julialang.org/t/floating-subplot-in-plots-recipe/60441 "2021-05-03T05:43:35Z")

</div>

I am making a user recipe for Plots to visualize a struct representing a spectrum: Currently, this works by having three subplots stacked vertically. Here is the relevant code in the recipe: grid := false fr…

---

## [Execute a CodeInfo object?](https://discourse.julialang.org/t/execute-a-codeinfo-object/60446)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 0\
**Last updated:** [May 3, 2021, 2:50am UTC](https://discourse.julialang.org/t/execute-a-codeinfo-object/60446 "2021-05-03T02:50:02Z")

</div>

I used @code\_typed f(100) to get a CodeInfo object. Is it possible to execute that object to get the result? CodeInfo( 1 ─ goto #3 if not false 2 ─ nothing::Nothing 3 ┄ goto #4 4 ─ %4 = Base.add\_int(99, a…

---

## [Problem parsing a txt file](https://discourse.julialang.org/t/problem-parsing-a-txt-file/60432)

<div class="topic-metadata">

**Author:** [@statspy](https://discourse.julialang.org/u/statspy)\
**Replies:** 4\
**Last updated:** [May 2, 2021, 8:22pm UTC](https://discourse.julialang.org/t/problem-parsing-a-txt-file/60432 "2021-05-02T20:22:19Z")

</div>

Hello, I am reading a txt file with this format: 06/22/2021 {somenthing} 06/22/2021 {somenthing} 06/22/2021 {somenthing so long that goes to the other line} 06/22/2021 {somenthing} To read this file i am using: open(…

---

## [Supressing banner from a package](https://discourse.julialang.org/t/supressing-banner-from-a-package/60321)

<div class="topic-metadata">

**Author:** [@maajdl](https://discourse.julialang.org/u/maajdl)\
**Replies:** 11\
**Last updated:** [May 2, 2021, 7:38pm UTC](https://discourse.julialang.org/t/supressing-banner-from-a-package/60321 "2021-05-02T19:38:25Z")

</div>

Hello, I am writing my first small package. I found Nemo useful for my purpose and I am using it in my package. But it comes with a small trouble: it prints a banner in the Jupyter notebook when it is loaded. Below…

---

## [Parsing WhatsApp text chat](https://discourse.julialang.org/t/parsing-whatsapp-text-chat/60427)

<div class="topic-metadata">

**Author:** [@statspy](https://discourse.julialang.org/u/statspy)\
**Replies:** 2\
**Last updated:** [May 2, 2021, 6:55pm UTC](https://discourse.julialang.org/t/parsing-whatsapp-text-chat/60427 "2021-05-02T18:55:27Z")

</div>

Hello, I am trying to parse a whatsapp text chat as a DataFrame . What I need is to parse this format: 06/18/2021 20:48 - +36 41 9989-8989: Hello, how are you? \<= all in one column or 06/18/2021 20:48 - Paul F…

---

## [Destructuring and broadcast](https://discourse.julialang.org/t/destructuring-and-broadcast/5672)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 12\
**Last updated:** [May 2, 2021, 6:49pm UTC](https://discourse.julialang.org/t/destructuring-and-broadcast/5672 "2021-05-02T18:49:04Z")

</div>

If I want to broadcast a function that returns a tuple, is there a simple way to “broadcast” the left hand side destructuring? a = 1:10 b = 11:20 transform(a, b) = a+b, a\*b, a-b # MWE, the real one is more compicated …

---

## [Vector of pointers to struct array elements](https://discourse.julialang.org/t/vector-of-pointers-to-struct-array-elements/60417)

<div class="topic-metadata">

**Author:** [@vitelot](https://discourse.julialang.org/u/vitelot)\
**Replies:** 6\
**Last updated:** [May 2, 2021, 1:28pm UTC](https://discourse.julialang.org/t/vector-of-pointers-to-struct-array-elements/60417 "2021-05-02T13:28:48Z")

</div>

Hi, I’m trying to avoid multiple vector allocations to speed up the weighted sampling of a vector of structs: using StatsBase function chooseBox(room::Vector{Box}) v = \[x.k for x in room\] sample(room, Weights(v)…

---

## [Differences in MATLAB's versus Julia's beta(x, y) for large x or y?](https://discourse.julialang.org/t/differences-in-matlabs-versus-julias-beta-x-y-for-large-x-or-y/60138)

<div class="topic-metadata">

**Author:** [@bashonubuntu](https://discourse.julialang.org/u/bashonubuntu)\
**Replies:** 16\
**Last updated:** [May 1, 2021, 7:20pm UTC](https://discourse.julialang.org/t/differences-in-matlabs-versus-julias-beta-x-y-for-large-x-or-y/60138 "2021-05-01T19:20:06Z")

</div>

Hi everyone, I was comparing a colleague’s MATLAB code to my version (we are coding in parallel, and I am using Julia. I am also trying to convince him to move to Julia. Making progress… :slight\_smile: ), and I noticed …

---

## [How to set JULIA\_PROJECT for JuliaCall?](https://discourse.julialang.org/t/how-to-set-julia-project-for-juliacall/60408)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 2\
**Last updated:** [May 2, 2021, 5:17am UTC](https://discourse.julialang.org/t/how-to-set-julia-project-for-juliacall/60408 "2021-05-02T05:17:09Z")

</div>

I need access to a pre-existing project environment within JuliaCall. The following MWE does not work: MWE: Create the ‘pre-existing’ environment # run this in the terminal $ cd ~/ $ mkdir /tmp/testenv && cd /tmp/teste…

---

## [Thread safe buffer correctness](https://discourse.julialang.org/t/thread-safe-buffer-correctness/60183)

<div class="topic-metadata">

**Author:** [@halleysfifthinc](https://discourse.julialang.org/u/halleysfifthinc)\
**Replies:** 13\
**Last updated:** [May 2, 2021, 1:17am UTC](https://discourse.julialang.org/t/thread-safe-buffer-correctness/60183 "2021-05-02T01:17:21Z")

</div>

For a recent multi-threaded simulation, I needed a thread-safe way to use pre-allocated arrays, and the simple “nthreads() length vector of arrays” wasn’t working due to the presence of yield points in the spawn’ed tasks…

---

## [Distributions.jl](https://discourse.julialang.org/t/distributions-jl/60394)

<div class="topic-metadata">

**Author:** [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Replies:** 2\
**Last updated:** [May 1, 2021, 7:59pm UTC](https://discourse.julialang.org/t/distributions-jl/60394 "2021-05-01T19:59:08Z")

</div>

Is Distributions.jl a built in package? When I try running it I get this: !\[Screenshot from 2021-05-01 13-35-14|690x387\](upload://rvrwCS99k3WHfz0jtaZw8Asf8Ip.png) !\[Screenshot from 2021-05-01 13-35-27|690x387\](upload:…

---

## [Unexpected ERROR: UndefVarError: a not defined](https://discourse.julialang.org/t/unexpected-error-undefvarerror-a-not-defined/60379)

<div class="topic-metadata">

**Author:** [@M0ran](https://discourse.julialang.org/u/M0ran)\
**Replies:** 8\
**Last updated:** [May 1, 2021, 7:40pm UTC](https://discourse.julialang.org/t/unexpected-error-undefvarerror-a-not-defined/60379 "2021-05-01T19:40:52Z")

</div>

Hey, I’m new to Julia and I have to program the game “paper soccer” for school. It’s almost finished, but now I got this “UndefVarError: a not defined” error. Since I’ve always adapted my code step by step, I really don’…

---

## [Using containers with abstract type parameters](https://discourse.julialang.org/t/using-containers-with-abstract-type-parameters/60264)

<div class="topic-metadata">

**Author:** [@anon60034542](https://discourse.julialang.org/u/anon60034542)\
**Replies:** 11\
**Last updated:** [May 1, 2021, 4:28pm UTC](https://discourse.julialang.org/t/using-containers-with-abstract-type-parameters/60264 "2021-05-01T16:28:38Z")

</div>

Consider the following code: abstract type GameObject end abstract type Weapon \<: GameObject end struct Sword \<: Weapon name::String damage::Int32 end struct Bow \<:Weapon name::String damage::Int32 end m…

---

## [Opening file "matpower/case30.m": No such file or directory](https://discourse.julialang.org/t/opening-file-matpower-case30-m-no-such-file-or-directory/46237)

<div class="topic-metadata">

**Author:** [@zlq178](https://discourse.julialang.org/u/zlq178)\
**Replies:** 5\
**Last updated:** [May 1, 2021, 1:43pm UTC](https://discourse.julialang.org/t/opening-file-matpower-case30-m-no-such-file-or-directory/46237 "2021-05-01T13:43:20Z")

</div>

‘’’ ##code using PowerModels using Ipopt result=run\_ac\_opf(“matpower/case30.m”, with\_optimizer(Ipopt.Optimizer)) ‘’’ errors: question:How could I add all files about “matpower/caseXX.m”?The document has said the …

---

## [Key map error](https://discourse.julialang.org/t/key-map-error/60353)

<div class="topic-metadata">

**Author:** [@Sumanshekhar17](https://discourse.julialang.org/u/Sumanshekhar17)\
**Replies:** 0\
**Last updated:** [May 1, 2021, 2:30am UTC](https://discourse.julialang.org/t/key-map-error/60353 "2021-05-01T02:30:09Z")

</div>

Hi all, I am facing difficulty in running any command in julia on my cluster. I get this error on every statement - julia\> exit() ┌ Error: Error in the keymap │ exception = │ SystemError: flush: Input/output erro…

---

## [Revisiting Rock, Paper, Scissors](https://discourse.julialang.org/t/revisiting-rock-paper-scissors/60347)

<div class="topic-metadata">

**Author:** [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Replies:** 5\
**Last updated:** [May 1, 2021, 12:22am UTC](https://discourse.julialang.org/t/revisiting-rock-paper-scissors/60347 "2021-05-01T00:22:31Z")

</div>

In 2017 @giordano (with 2019 @Mason update) wrote about implementing Rock, Paper, Scissors. Using v1.7 or v1.6, can we do this any better (more: elegantly, performantly, type-stable, gamelike)? Are there new (or better…

---

## [How to convert h5 to csv](https://discourse.julialang.org/t/how-to-convert-h5-to-csv/60346)

<div class="topic-metadata">

**Author:** [@T-Shino-0603](https://discourse.julialang.org/u/T-Shino-0603)\
**Replies:** 2\
**Last updated:** [April 30, 2021, 9:17pm UTC](https://discourse.julialang.org/t/how-to-convert-h5-to-csv/60346 "2021-04-30T21:17:16Z")

</div>

My question is very simple. I have a h5 file with the following structure. Dict{String,Any}("mb" =\> MeansBands class: obs product: forecast cond: none para: full dates: 2021-03-31 - 2030-12-31 # of variable…

---

## [Include file differently when within a module](https://discourse.julialang.org/t/include-file-differently-when-within-a-module/60341)

<div class="topic-metadata">

**Author:** [@pg261](https://discourse.julialang.org/u/pg261)\
**Replies:** 1\
**Last updated:** [April 30, 2021, 8:57pm UTC](https://discourse.julialang.org/t/include-file-differently-when-within-a-module/60341 "2021-04-30T20:57:04Z")

</div>

Hi ! I want to include a .jl file in two different ways, according as it is included within a module or on its own. I know this sounds confusing ; here is a way to do it, which I think is awkward, and I’m looking for so…

---

## [Long fetching on local package update](https://discourse.julialang.org/t/long-fetching-on-local-package-update/60330)

<div class="topic-metadata">

**Author:** [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Replies:** 2\
**Last updated:** [April 30, 2021, 7:08pm UTC](https://discourse.julialang.org/t/long-fetching-on-local-package-update/60330 "2021-04-30T19:08:10Z")

</div>

Hi, I was just wondering if I have set up something wrong if this happens: Context : this package is stored locally on my computer, I frequently change it so every time I do a commit, I must update it. But there is…

---

## [Pull DataFrames columns to the front](https://discourse.julialang.org/t/pull-dataframes-columns-to-the-front/60327)

<div class="topic-metadata">

**Author:** [@rikh](https://discourse.julialang.org/u/rikh)\
**Replies:** 5\
**Last updated:** [April 30, 2021, 4:40pm UTC](https://discourse.julialang.org/t/pull-dataframes-columns-to-the-front/60327 "2021-04-30T16:40:25Z")

</div>

I often need to pull certain DataFrames columns to the front and do this via replace with Not. I wonder if there is a more readable way to do it. julia\> using DataFrames julia\> df = DataFrame(D=\[1\], E=\[2\], C=\[3\], A=\[4\]…

---

## [How to execute julia code in a bash shell script itself](https://discourse.julialang.org/t/how-to-execute-julia-code-in-a-bash-shell-script-itself/30848)

<div class="topic-metadata">

**Author:** [@StevenSiew](https://discourse.julialang.org/u/StevenSiew)\
**Replies:** 8\
**Last updated:** [April 30, 2021, 4:18pm UTC](https://discourse.julialang.org/t/how-to-execute-julia-code-in-a-bash-shell-script-itself/30848 "2021-04-30T16:18:12Z")

</div>

$ cat zzz #!/bin/bash /usr/bin/tail +4 "$0" | julia exit println("hello world from a bash script") versioninfo() Dont forget to $ chmod u+x zzz Sample run $ ./zzz hello world from a bash script Julia Version 1.2.0 Co…

---

## [Efficient eval, splat, eval?](https://discourse.julialang.org/t/efficient-eval-splat-eval/60323)

<div class="topic-metadata">

**Author:** [@mewilhel](https://discourse.julialang.org/u/mewilhel)\
**Replies:** 2\
**Last updated:** [April 30, 2021, 3:23pm UTC](https://discourse.julialang.org/t/efficient-eval-splat-eval/60323 "2021-04-30T15:23:53Z")

</div>

Essentially, I’d like to perform the following snippet of code without allocating or creating an intermediate array (temp): x = Int\[1,2\] # could be of any length n (n is only known at runtime) temp = f.(x) #…

---

## [\[PyCall\] Julia Exception to Python exception](https://discourse.julialang.org/t/pycall-julia-exception-to-python-exception/60320)

<div class="topic-metadata">

**Author:** [@Mrion](https://discourse.julialang.org/u/Mrion)\
**Replies:** 0\
**Last updated:** [April 30, 2021, 2:39pm UTC](https://discourse.julialang.org/t/pycall-julia-exception-to-python-exception/60320 "2021-04-30T14:39:05Z")

</div>

Hello! I want to create python exception from Julia exception with preserving backtrace (writing my Julia api for sentry using python sdk). Is it possible? How could I achieve that?

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

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