# General Usage

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

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

**Page:** 492

---

## [Question About @allocated](https://discourse.julialang.org/t/question-about-allocated/75155)

<div class="topic-metadata">

**Author:** [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Replies:** 2\
**Last updated:** [January 26, 2022, 1:11am UTC](https://discourse.julialang.org/t/question-about-allocated/75155 "2022-01-26T01:11:39Z")

</div>

I am observing some behavior and I don’t understand it. I would appreciate any thoughts. For context, I’m using VSCode with the Julia extension, interactively evaluating each line of my code by highlighting it and pressi…

---

## [Improving performance of dynamic programming problem of households in a labor market model](https://discourse.julialang.org/t/improving-performance-of-dynamic-programming-problem-of-households-in-a-labor-market-model/74892)

<div class="topic-metadata">

**Author:** [@Mario\_Silva](https://discourse.julialang.org/u/Mario_Silva)\
**Replies:** 25\
**Last updated:** [January 26, 2022, 12:13am UTC](https://discourse.julialang.org/t/improving-performance-of-dynamic-programming-problem-of-households-in-a-labor-market-model/74892 "2022-01-26T00:13:04Z")

</div>

Greetings: I am working on solving a heterogeneous-agent economics model in Julia. The most demanding part is solving the household problem using dynamic programming. Households can be either employed or unemployed. The…

---

## [Vscode: tag new version failing](https://discourse.julialang.org/t/vscode-tag-new-version-failing/73456)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 2\
**Last updated:** [January 25, 2022, 9:54pm UTC](https://discourse.julialang.org/t/vscode-tag-new-version-failing/73456 "2022-01-25T21:54:08Z")

</div>

I am getting this error when using the “tag new version” feature of the VSCode extension: ┌ Warning: The active manifest file is an older format with no julia version entry. Dependencies may have been resolved with a d…

---

## [Call julia function from python](https://discourse.julialang.org/t/call-julia-function-from-python/75202)

<div class="topic-metadata">

**Author:** [@xspeng](https://discourse.julialang.org/u/xspeng)\
**Replies:** 2\
**Last updated:** [January 25, 2022, 9:48pm UTC](https://discourse.julialang.org/t/call-julia-function-from-python/75202 "2022-01-25T21:48:24Z")

</div>

Hi, guys, I use bayesion optimization of python plus subfunction of julia to do my simulation, and I can successfully run the simple function see here, maybe I should ask another question, if I want to combine the speed…

---

## [Unmatched dimensions for 3D plot](https://discourse.julialang.org/t/unmatched-dimensions-for-3d-plot/75180)

<div class="topic-metadata">

**Author:** [@BuddhiLW](https://discourse.julialang.org/u/BuddhiLW)\
**Replies:** 14\
**Last updated:** [January 25, 2022, 8:48pm UTC](https://discourse.julialang.org/t/unmatched-dimensions-for-3d-plot/75180 "2022-01-25T20:48:00Z")

</div>

I have a program to solve 1D Burguer’s equation. I have the following values/dimensions, which are giving me a dimensional error. I don’t understand what is going wrong. If anyone can help me, I appreciate it. julia\> si…

---

## [Precompilation does not see added dependecy](https://discourse.julialang.org/t/precompilation-does-not-see-added-dependecy/75192)

<div class="topic-metadata">

**Author:** [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)\
**Replies:** 0\
**Last updated:** [January 25, 2022, 5:52pm UTC](https://discourse.julialang.org/t/precompilation-does-not-see-added-dependecy/75192 "2022-01-25T17:52:21Z")

</div>

I have added “Infiltrator” as a dependency to my locally developed package “SpinGauss”. However, it produced an error at precompilation stage. When I run import Pkg; Pkg.precompile() as suggested by the error log, I ge…

---

## [Best way to install julia with CLI on linux enviroment?](https://discourse.julialang.org/t/best-way-to-install-julia-with-cli-on-linux-enviroment/75151)

<div class="topic-metadata">

**Author:** [@rmsmsgood](https://discourse.julialang.org/u/rmsmsgood)\
**Replies:** 3\
**Last updated:** [January 25, 2022, 4:51pm UTC](https://discourse.julialang.org/t/best-way-to-install-julia-with-cli-on-linux-enviroment/75151 "2022-01-25T16:51:09Z")

</div>

Recently, i am interested in distributed computing and spend much time for install julia on our servers. But as i know, the installation of julia with CLI is very inconvenient until now. I want command like below can in…

---

## [Help optimizing bad multithreading code](https://discourse.julialang.org/t/help-optimizing-bad-multithreading-code/75099)

<div class="topic-metadata">

**Author:** [@isaac.rubberducky](https://discourse.julialang.org/u/isaac.rubberducky)\
**Replies:** 2\
**Last updated:** [January 25, 2022, 2:41pm UTC](https://discourse.julialang.org/t/help-optimizing-bad-multithreading-code/75099 "2022-01-25T14:41:00Z")

</div>

function cleanExample(rootNode::Node) queue = Vector{Node}() push!(queue, rootNode) bestKnownSolution = 100 queueLock = ReentrantLock() solutionLock = ReentrantLock() while !isempty(queue) …

---

## [Help with setting up Distributed computing](https://discourse.julialang.org/t/help-with-setting-up-distributed-computing/75081)

<div class="topic-metadata">

**Author:** [@isaac.rubberducky](https://discourse.julialang.org/u/isaac.rubberducky)\
**Replies:** 5\
**Last updated:** [January 25, 2022, 2:39pm UTC](https://discourse.julialang.org/t/help-with-setting-up-distributed-computing/75081 "2022-01-25T14:39:04Z")

</div>

queue = Vector{Node}() push!(queue, rootNode) bestKnownSolution = 100 while !isempty(queue) nextNode = pop!(queue) newNode1, newNode2, bestFoundSolution = processNode!(nextNode) if !isnothing(newNode1) …

---

## [A way to capture screenshots with Julia programatically](https://discourse.julialang.org/t/a-way-to-capture-screenshots-with-julia-programatically/57666)

<div class="topic-metadata">

**Author:** [@sefffal](https://discourse.julialang.org/u/sefffal)\
**Replies:** 8\
**Last updated:** [January 25, 2022, 1:44pm UTC](https://discourse.julialang.org/t/a-way-to-capture-screenshots-with-julia-programatically/57666 "2022-01-25T13:44:30Z")

</div>

Today I found a simple way to capture a screenshot of your desktop using Julia and thought I would share. I guess it is a hidden feature of the ImageMagick.jl package. Just run using ImageMagick screenshot = ImageMagi…

---

## [Embedding multiple versions of Julia in a single C application](https://discourse.julialang.org/t/embedding-multiple-versions-of-julia-in-a-single-c-application/75133)

<div class="topic-metadata">

**Author:** [@cariocecus](https://discourse.julialang.org/u/cariocecus)\
**Replies:** 6\
**Last updated:** [January 25, 2022, 11:38am UTC](https://discourse.julialang.org/t/embedding-multiple-versions-of-julia-in-a-single-c-application/75133 "2022-01-25T11:38:13Z")

</div>

Dear Julia community, I have a C application that calls code that was developed in Julia 0.3.12 (hereafter called old code). I do this by following the guidelines of the Embedding Julia section of the manual. Now I nee…

---

## [Subsetting dataframe with multiple conditions](https://discourse.julialang.org/t/subsetting-dataframe-with-multiple-conditions/75160)

<div class="topic-metadata">

**Author:** [@lobshi](https://discourse.julialang.org/u/lobshi)\
**Replies:** 2\
**Last updated:** [January 25, 2022, 9:59am UTC](https://discourse.julialang.org/t/subsetting-dataframe-with-multiple-conditions/75160 "2022-01-25T09:59:19Z")

</div>

Why should i wrap every condition in a pair of parentheses when subsetting data? Example dataframe as below: d = DataFrame(a = \[1, 2, 3\], b = \["x", "y", "z"\]) d2 = d\[(d.a .\> 1) .| (d.b == "z"), :\] If I remove parenthes…

---

## [\`VectorContinuousCallback\` not picking up threshold](https://discourse.julialang.org/t/vectorcontinuouscallback-not-picking-up-threshold/74596)

<div class="topic-metadata">

**Author:** [@colebrookson](https://discourse.julialang.org/u/colebrookson)\
**Replies:** 1\
**Last updated:** [January 25, 2022, 6:14am UTC](https://discourse.julialang.org/t/vectorcontinuouscallback-not-picking-up-threshold/74596 "2022-01-25T06:14:32Z")

</div>

I’m having trouble getting VectorContinuousCallback to work as desired and I’m not sure what I’m doing wrong. I have a large system of equations, and essentially, any time any of the values cross some threshold value (in…

---

## [Why isn't \`size\` always inferred to be an Integer?](https://discourse.julialang.org/t/why-isnt-size-always-inferred-to-be-an-integer/75139)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 24\
**Last updated:** [January 24, 2022, 11:57pm UTC](https://discourse.julialang.org/t/why-isnt-size-always-inferred-to-be-an-integer/75139 "2022-01-24T23:57:09Z")

</div>

I have also spent an endless number of hours in SnooptCompile to achieve improvements of 1-2 seconds in compile time. One thing that I really can’t understand is why taking the size or length of a var that is Any returns…

---

## [Best Julian way to copy many files?](https://discourse.julialang.org/t/best-julian-way-to-copy-many-files/75142)

<div class="topic-metadata">

**Author:** [@chowerth](https://discourse.julialang.org/u/chowerth)\
**Replies:** 2\
**Last updated:** [January 24, 2022, 7:24pm UTC](https://discourse.julialang.org/t/best-julian-way-to-copy-many-files/75142 "2022-01-24T19:24:00Z")

</div>

Hello. I’m wondering what is the best Julian way to copy files. My particular use case is I have a large number of files (of varying size) and I’m automating their data cleaning and backup process. Without going into gr…

---

## [Bravais lattice with a gaussian at every site](https://discourse.julialang.org/t/bravais-lattice-with-a-gaussian-at-every-site/75055)

<div class="topic-metadata">

**Author:** [@ash](https://discourse.julialang.org/u/ash)\
**Replies:** 9\
**Last updated:** [January 24, 2022, 7:16pm UTC](https://discourse.julialang.org/t/bravais-lattice-with-a-gaussian-at-every-site/75055 "2022-01-24T19:16:45Z")

</div>

I am trying to generate a numerical initial condition for a PDE that looks like this: it is a Bravais lattice, with a gaussian at each site (in 2D). This is not difficult to do by hand for a square lattice with two atoms…

---

## [Are Value types the correct solution for me? (as parameters that choose the algorithm)](https://discourse.julialang.org/t/are-value-types-the-correct-solution-for-me-as-parameters-that-choose-the-algorithm/75069)

<div class="topic-metadata">

**Author:** [@Elyco](https://discourse.julialang.org/u/Elyco)\
**Replies:** 4\
**Last updated:** [January 24, 2022, 5:51pm UTC](https://discourse.julialang.org/t/are-value-types-the-correct-solution-for-me-as-parameters-that-choose-the-algorithm/75069 "2022-01-24T17:51:37Z")

</div>

Hi, I need some help in understanding whether value types are the right solution for my situation. I have some simulation that can be solved in different ways. When I run it, I can choose different parameters such as t…

---

## [GitHub GMT.jl documentation broken and have no idea on how to fix](https://discourse.julialang.org/t/github-gmt-jl-documentation-broken-and-have-no-idea-on-how-to-fix/74987)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 1\
**Last updated:** [January 24, 2022, 3:31pm UTC](https://discourse.julialang.org/t/github-gmt-jl-documentation-broken-and-have-no-idea-on-how-to-fix/74987 "2022-01-24T15:31:41Z")

</div>

Hi, I’m totally lost on why the documentation of GMT.jl is now broken. Problems start to arise when, for some unknown reason the Linux CI build started to fail. ERROR: LoadError: could not load library "/home/runner/gm…

---

## [Is Gtk.jl mature and stable on macOS?](https://discourse.julialang.org/t/is-gtk-jl-mature-and-stable-on-macos/75000)

<div class="topic-metadata">

**Author:** [@Erik\_Engheim](https://discourse.julialang.org/u/Erik_Engheim)\
**Replies:** 6\
**Last updated:** [January 24, 2022, 2:47pm UTC](https://discourse.julialang.org/t/is-gtk-jl-mature-and-stable-on-macos/75000 "2022-01-24T14:47:25Z")

</div>

I am trying to determine what GUI toolkit to use in Julia. I want to avoid pursuing a toolkit which is unstable and prone to crashes forcing me to switch toolkit midstream. I am interested in using Gtk but I know from t…

---

## [MLStyle variadic match ast](https://discourse.julialang.org/t/mlstyle-variadic-match-ast/75021)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 1\
**Last updated:** [January 24, 2022, 2:42pm UTC](https://discourse.julialang.org/t/mlstyle-variadic-match-ast/75021 "2022-01-24T14:42:43Z")

</div>

This code works using MLStyle, MLStyle.Modules.AST @match :( (a::Foo, b::Bar) ) begin :($n1::$t1, $n2::$t2) =\> (n1,n2) end but I want to do this with arbitrarily many variables, not just 2. I tried using ... but it…

---

## [Speeding up maximization](https://discourse.julialang.org/t/speeding-up-maximization/74298)

<div class="topic-metadata">

**Author:** [@juliauser](https://discourse.julialang.org/u/juliauser)\
**Replies:** 4\
**Last updated:** [January 24, 2022, 4:12am UTC](https://discourse.julialang.org/t/speeding-up-maximization/74298 "2022-01-24T04:12:15Z")

</div>

I am trying to speed up this code. The maximization is very time consuming. Perhaps I am also not doing the allocations efficiently. I have a core with 64 threads, but if I use multithread I incur in an error (the result…

---

## [Plots.jl legend box](https://discourse.julialang.org/t/plots-jl-legend-box/18433)

<div class="topic-metadata">

**Author:** [@monty](https://discourse.julialang.org/u/monty)\
**Replies:** 8\
**Last updated:** [January 24, 2022, 10:16am UTC](https://discourse.julialang.org/t/plots-jl-legend-box/18433 "2022-01-24T10:16:09Z")

</div>

How to remove surrounding box of the legend in Plots.jl?

---

## [ProfileView's @profview generates blank window](https://discourse.julialang.org/t/profileviews-profview-generates-blank-window/74997)

<div class="topic-metadata">

**Author:** [@kaitlyn-loftus](https://discourse.julialang.org/u/kaitlyn-loftus)\
**Replies:** 5\
**Last updated:** [January 24, 2022, 10:06am UTC](https://discourse.julialang.org/t/profileviews-profview-generates-blank-window/74997 "2022-01-24T10:06:59Z")

</div>

I am trying to use ProfileView’s @profview, but it’s only generating a blank window instead of a flamegraph. For a minimum working example, this behavior occurs for me with the ProfileView tutorial example: function pro…

---

## [What am I doing wrong with \`unsafe\_wrap()\`?](https://discourse.julialang.org/t/what-am-i-doing-wrong-with-unsafe-wrap/75105)

<div class="topic-metadata">

**Author:** [@heyx3](https://discourse.julialang.org/u/heyx3)\
**Replies:** 10\
**Last updated:** [January 24, 2022, 8:38am UTC](https://discourse.julialang.org/t/what-am-i-doing-wrong-with-unsafe-wrap/75105 "2022-01-24T08:38:16Z")

</div>

Trying to write some test code with unsafe\_wrap(), and getting unexpected garbage results. julia\> function f() r = Ref(tuple(5.0, 2.0, 1.0, 6.0)) p = Base.unsafe\_convert(Ptr{Float64}, r) u …

---

## [Using Dependency inversion to avoid depending on volatile/heavy packages](https://discourse.julialang.org/t/using-dependency-inversion-to-avoid-depending-on-volatile-heavy-packages/74181)

<div class="topic-metadata">

**Author:** [@bgctw](https://discourse.julialang.org/u/bgctw)\
**Replies:** 1\
**Last updated:** [January 24, 2022, 8:02am UTC](https://discourse.julialang.org/t/using-dependency-inversion-to-avoid-depending-on-volatile-heavy-packages/74181 "2022-01-24T08:02:45Z")

</div>

I want to use a simple optimization of an univariate function in my package DistributionFits.jl, but I want to avoid the package dependency on the heavy-weight package Optim.jl. So far, I tried implementing Dependency i…

---

## [BenchmarkTools: How to use different random array on each run (esp. for mutating functions)?](https://discourse.julialang.org/t/benchmarktools-how-to-use-different-random-array-on-each-run-esp-for-mutating-functions/75061)

<div class="topic-metadata">

**Author:** [@rakeshvar](https://discourse.julialang.org/u/rakeshvar)\
**Replies:** 6\
**Last updated:** [January 24, 2022, 6:24am UTC](https://discourse.julialang.org/t/benchmarktools-how-to-use-different-random-array-on-each-run-esp-for-mutating-functions/75061 "2022-01-24T06:24:07Z")

</div>

I am implementing a routine to find ‘a’ median of an integer array. The algorithm is based on quicksort, and both implementations below partially search/sort about half the array. They both have the same O(n) average com…

---

## [PyCall stdout buffer processing not doing what I expected](https://discourse.julialang.org/t/pycall-stdout-buffer-processing-not-doing-what-i-expected/75086)

<div class="topic-metadata">

**Author:** [@anon69491625](https://discourse.julialang.org/u/anon69491625)\
**Replies:** 10\
**Last updated:** [January 23, 2022, 9:37pm UTC](https://discourse.julialang.org/t/pycall-stdout-buffer-processing-not-doing-what-i-expected/75086 "2022-01-23T21:37:57Z")

</div>

Hi all I am using PyCall to run a simple python script that prints out the ascii table. #test\_stdout\_pycall.py digit = 0 while digit\<=255: print("%d = %c" %(digit, chr(digit))) digit += 1 print("done") I w…

---

## [Julia passing a string to Fortran](https://discourse.julialang.org/t/julia-passing-a-string-to-fortran/74781)

<div class="topic-metadata">

**Author:** [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)\
**Replies:** 11\
**Last updated:** [January 23, 2022, 9:17pm UTC](https://discourse.julialang.org/t/julia-passing-a-string-to-fortran/74781 "2022-01-23T21:17:08Z")

</div>

How can I pass a string to Fortran? The following methods doesn’t seem to work julia\> T = Ref{Char} Ref{Char} julia\> Base.unsafe\_convert(T, Base.cconvert(T, "foo")) ERROR: MethodError: Cannot \`convert\` an object of typ…

---

## [Need help fixing an sqrt related error](https://discourse.julialang.org/t/need-help-fixing-an-sqrt-related-error/75084)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 2\
**Last updated:** [January 23, 2022, 8:24pm UTC](https://discourse.julialang.org/t/need-help-fixing-an-sqrt-related-error/75084 "2022-01-23T20:24:29Z")

</div>

Here is the error message: ERROR: LoadError: DomainError with -0.038468373019053814: sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)). \[12\] CO2SYS(PAR1::Vector{Float64}, P…

---

## [Why code stops working after seemingly trivial function redefinition?](https://discourse.julialang.org/t/why-code-stops-working-after-seemingly-trivial-function-redefinition/75083)

<div class="topic-metadata">

**Author:** [@Soldalma](https://discourse.julialang.org/u/Soldalma)\
**Replies:** 2\
**Last updated:** [January 23, 2022, 8:32pm UTC](https://discourse.julialang.org/t/why-code-stops-working-after-seemingly-trivial-function-redefinition/75083 "2022-01-23T20:32:07Z")

</div>

I am puzzled by this one, spent a lot of time trying to figure it out. I have two alternative definitions for a pair of functions. Some code using groupby/combine works with one pair of definitions, not with the other o…

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

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