# General Usage

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

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

**Page:** 580

---

## [\`@code\_native\` shows an algorithm that appears to be O(N), but benchmarking suggests that it's actually O(1)](https://discourse.julialang.org/t/code-native-shows-an-algorithm-that-appears-to-be-o-n-but-benchmarking-suggests-that-its-actually-o-1/63834)

<div class="topic-metadata">

**Author:** [@seamsay](https://discourse.julialang.org/u/seamsay)\
**Replies:** 12\
**Last updated:** [July 5, 2021, 2:16pm UTC](https://discourse.julialang.org/t/code-native-shows-an-algorithm-that-appears-to-be-o-n-but-benchmarking-suggests-that-its-actually-o-1/63834 "2021-07-05T14:16:22Z")

</div>

I hope this is an OK category to put this under, I couldn’t see anything that matched better :grimacing: I’m trying to get better at reading assembly output by looking at some interesting optimisations. I’m currently lo…

---

## [Qksqt incoming network connections](https://discourse.julialang.org/t/qksqt-incoming-network-connections/61888)

<div class="topic-metadata">

**Author:** [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Replies:** 2\
**Last updated:** [July 5, 2021, 1:28pm UTC](https://discourse.julialang.org/t/qksqt-incoming-network-connections/61888 "2021-07-05T13:28:38Z")

</div>

When I plot with the GR backend (Plots.jl) a popup window asks Do you want the application “gksqt.app” to accept incoming network connections? This appears each time I plot. How can I avoid this? julia\> versioninfo() …

---

## [Question in Strings.ipynb](https://discourse.julialang.org/t/question-in-strings-ipynb/64074)

<div class="topic-metadata">

**Author:** [@Paresh](https://discourse.julialang.org/u/Paresh)\
**Replies:** 2\
**Last updated:** [July 5, 2021, 12:24pm UTC](https://discourse.julialang.org/t/question-in-strings-ipynb/64074 "2021-07-05T12:24:38Z")

</div>

Hello, I am new to Julia. I have a question in Strings.ipynb in Intro to Julia. Exercise 2.1 part (b), what is the exponentiation operator in Julia? How can I produce “hi” 1000 times by using \* under the hood? Please gi…

---

## [How to know when a task is done?](https://discourse.julialang.org/t/how-to-know-when-a-task-is-done/63978)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 10\
**Last updated:** [July 5, 2021, 11:23am UTC](https://discourse.julialang.org/t/how-to-know-when-a-task-is-done/63978 "2021-07-05T11:23:16Z")

</div>

If I create a Task using @async, and want to do something (like changing some status) immediately after that task is done, how do I do that? I guess istaskdone can only let me check everytime manually. I don’t quite unde…

---

## [Applying Machine learning models to Diabetes dataset using MLJ.jl packages](https://discourse.julialang.org/t/applying-machine-learning-models-to-diabetes-dataset-using-mlj-jl-packages/64047)

<div class="topic-metadata">

**Author:** [@Maria\_Brown](https://discourse.julialang.org/u/Maria_Brown)\
**Replies:** 2\
**Last updated:** [July 4, 2021, 8:45pm UTC](https://discourse.julialang.org/t/applying-machine-learning-models-to-diabetes-dataset-using-mlj-jl-packages/64047 "2021-07-04T20:45:56Z")

</div>

\*\*Hello, \*\* Please I have this diabetes dataset which i have cleaned using Altery designer, and I would love to build ML models(Random Forest tree, Logistic regression, KNN, Support Vector Machine and Naive Baye algorit…

---

## [Advanced submodule: Pattern or Anti-pattern?](https://discourse.julialang.org/t/advanced-submodule-pattern-or-anti-pattern/63894)

<div class="topic-metadata">

**Author:** [@DrChainsaw](https://discourse.julialang.org/u/DrChainsaw)\
**Replies:** 6\
**Last updated:** [July 4, 2021, 5:48pm UTC](https://discourse.julialang.org/t/advanced-submodule-pattern-or-anti-pattern/63894 "2021-07-04T17:48:12Z")

</div>

The package in question has a handful (about 10) simple ‘main API’ functions. Most of those functions follow the pattern of examining the user input a bit, then selecting some combination of more generic functions to cal…

---

## [Pkg.gc() results in error](https://discourse.julialang.org/t/pkg-gc-results-in-error/63972)

<div class="topic-metadata">

**Author:** [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)\
**Replies:** 7\
**Last updated:** [July 4, 2021, 5:33pm UTC](https://discourse.julialang.org/t/pkg-gc-results-in-error/63972 "2021-07-04T17:33:17Z")

</div>

julia\> import Pkg julia\> Pkg.gc() ERROR: SystemError: opening file "/usr/share/julia/logs/manifest\_usage.toml": Permission denied Stacktrace: \[1\] systemerror(p::String, errno::Int32; extrainfo::Nothing) @ Base ./e…

---

## [How to save .string, .float data in .csv at the same time?](https://discourse.julialang.org/t/how-to-save-string-float-data-in-csv-at-the-same-time/64029)

<div class="topic-metadata">

**Author:** [@Sawyer\_Zhou](https://discourse.julialang.org/u/Sawyer_Zhou)\
**Replies:** 4\
**Last updated:** [July 4, 2021, 3:34pm UTC](https://discourse.julialang.org/t/how-to-save-string-float-data-in-csv-at-the-same-time/64029 "2021-07-04T15:34:54Z")

</div>

I want to save the float and string data in CSV at the same time, here is a mini-case of my code: using CSV for i in 1:10 x = "test"; y = rand(1) CSV.write("out.csv", (x = x, y = y), append = true) end I w…

---

## [Loop doesn't work](https://discourse.julialang.org/t/loop-doesnt-work/64035)

<div class="topic-metadata">

**Author:** [@shajeenahamed](https://discourse.julialang.org/u/shajeenahamed)\
**Replies:** 2\
**Last updated:** [July 4, 2021, 12:55pm UTC](https://discourse.julialang.org/t/loop-doesnt-work/64035 "2021-07-04T12:55:54Z")

</div>

I have just started learning julia, but it kind of stuck in loop. Below code does not work, but syntax seems to be good. any idea? k = 0 while k \< 10 k += 1 println(k) end Error ERROR: LoadError: UndefVarError…

---

## [Control where mutables are allocated in a very special case: a large number of mutables of the same type](https://discourse.julialang.org/t/control-where-mutables-are-allocated-in-a-very-special-case-a-large-number-of-mutables-of-the-same-type/63971)

<div class="topic-metadata">

**Author:** [@zsunberg](https://discourse.julialang.org/u/zsunberg)\
**Replies:** 11\
**Last updated:** [July 4, 2021, 5:41am UTC](https://discourse.julialang.org/t/control-where-mutables-are-allocated-in-a-very-special-case-a-large-number-of-mutables-of-the-same-type/63971 "2021-07-04T05:41:36Z")

</div>

In my research, I often find myself incrementally creating large graphs or trees where each node has some properties that might get updated later. Semantically, it makes the most sense for each node to be represented by…

---

## [Saving to PDF Using Palatino Roman Doesn't Show Negative Signs with Plots.jl](https://discourse.julialang.org/t/saving-to-pdf-using-palatino-roman-doesnt-show-negative-signs-with-plots-jl/64003)

<div class="topic-metadata">

**Author:** [@ggarza](https://discourse.julialang.org/u/ggarza)\
**Replies:** 8\
**Last updated:** [July 4, 2021, 5:19am UTC](https://discourse.julialang.org/t/saving-to-pdf-using-palatino-roman-doesnt-show-negative-signs-with-plots-jl/64003 "2021-07-04T05:19:22Z")

</div>

As stated in the topic title, saving a plot to a pdf when using the fontfamily “Palatino Roman” doesn’t show negative signs. Here’s a MWE: using Plots f(x) = x^2-3 pl = plot(f, -3, 3, fontfamily="Palatino Roman") savef…

---

## [PackageCompiler: compiling modules not in a package](https://discourse.julialang.org/t/packagecompiler-compiling-modules-not-in-a-package/24274)

<div class="topic-metadata">

**Author:** [@asprionj](https://discourse.julialang.org/u/asprionj)\
**Replies:** 3\
**Last updated:** [July 3, 2021, 11:15pm UTC](https://discourse.julialang.org/t/packagecompiler-compiling-modules-not-in-a-package/24274 "2021-07-03T23:15:28Z")

</div>

I have several modules that are not in a package but defined in each one file in some local folder. For normal usage, I just add this folder to LOAD\_PATH in the startup.jl and I can use using to load the modules. Is ther…

---

## [Overriding Base.show for Int64 causes madness](https://discourse.julialang.org/t/overriding-base-show-for-int64-causes-madness/63961)

<div class="topic-metadata">

**Author:** [@ess3sq](https://discourse.julialang.org/u/ess3sq)\
**Replies:** 6\
**Last updated:** [July 3, 2021, 10:32pm UTC](https://discourse.julialang.org/t/overriding-base-show-for-int64-causes-madness/63961 "2021-07-03T22:32:40Z")

</div>

Dear all, I am dumbstruck. I just tried the pointless endeavour overriding Base.show for Int64. This is what I did (REPL): julia\> import Base.show julia\> Base.show(io::IO, x::Int64) = println("Hello. I am $x") julia\> …

---

## [Large memory consumption when reading multiple HDF5 files](https://discourse.julialang.org/t/large-memory-consumption-when-reading-multiple-hdf5-files/63992)

<div class="topic-metadata">

**Author:** [@useJulia](https://discourse.julialang.org/u/useJulia)\
**Replies:** 3\
**Last updated:** [July 3, 2021, 6:30pm UTC](https://discourse.julialang.org/t/large-memory-consumption-when-reading-multiple-hdf5-files/63992 "2021-07-03T18:30:55Z")

</div>

I found this large memory consumption running the following code. Memory usage n=1 0.003026944 GB Memory usage n=2 0.136589312 GB Memory usage n=4 0.27860992 GB Memory usage n=8 0.60479488 GB Memory usage n=16 1.2072632…

---

## [Installed last version of Julia and and Jupyter doesnt work because Kernel error](https://discourse.julialang.org/t/installed-last-version-of-julia-and-and-jupyter-doesnt-work-because-kernel-error/53288)

<div class="topic-metadata">

**Author:** [@elkinjosuerc](https://discourse.julialang.org/u/elkinjosuerc)\
**Replies:** 4\
**Last updated:** [July 3, 2021, 5:20pm UTC](https://discourse.julialang.org/t/installed-last-version-of-julia-and-and-jupyter-doesnt-work-because-kernel-error/53288 "2021-07-03T17:20:00Z")

</div>

Hi i used to have the Julia version 1.0.5 but i read i must update the version for the most recent one in order to solve a package error, so i installed the last version and delete the older. But when i try tu use Jupyte…

---

## [How to properly add two new columns (in dataframe) from a function that returns two arrays?](https://discourse.julialang.org/t/how-to-properly-add-two-new-columns-in-dataframe-from-a-function-that-returns-two-arrays/63964)

<div class="topic-metadata">

**Author:** [@joonp](https://discourse.julialang.org/u/joonp)\
**Replies:** 7\
**Last updated:** [July 3, 2021, 1:42pm UTC](https://discourse.julialang.org/t/how-to-properly-add-two-new-columns-in-dataframe-from-a-function-that-returns-two-arrays/63964 "2021-07-03T13:42:09Z")

</div>

Hello, I am a Julia newbie and I have a question. The example below sort of simplified my current problem— function myfun(id) a = \[id .+ 1, id .+ 2, id .+ 2\] b = \[id .- 1, id .- 2, id .- 3\] return \[a, b\] end myd…

---

## [Functions as keyword arguments](https://discourse.julialang.org/t/functions-as-keyword-arguments/63983)

<div class="topic-metadata">

**Author:** [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Replies:** 2\
**Last updated:** [July 3, 2021, 12:54pm UTC](https://discourse.julialang.org/t/functions-as-keyword-arguments/63983 "2021-07-03T12:54:58Z")

</div>

This function is to be called either without an auxiliary function or with one. But how can you test the supplied keyword argument to know when an auxiliary function has been supplied? function f(a; func = (b, c) -\> ())…

---

## [Tools/patterns to reduce latency with strategy pattern](https://discourse.julialang.org/t/tools-patterns-to-reduce-latency-with-strategy-pattern/63985)

<div class="topic-metadata">

**Author:** [@DrChainsaw](https://discourse.julialang.org/u/DrChainsaw)\
**Replies:** 0\
**Last updated:** [July 3, 2021, 12:15pm UTC](https://discourse.julialang.org/t/tools-patterns-to-reduce-latency-with-strategy-pattern/63985 "2021-07-03T12:15:56Z")

</div>

I’m looking into redesigning some code I wrote long ago which implements a strategy pattern. A mockup example: struct StrategyX{T1,T2, V} \<: AbstractStrategy strategyparam1::T1 strategyparam2::T2 applyto:…

---

## [Remove inner module function name with @docs in Documenter.jl](https://discourse.julialang.org/t/remove-inner-module-function-name-with-docs-in-documenter-jl/61617)

<div class="topic-metadata">

**Author:** [@MattWillFlood](https://discourse.julialang.org/u/MattWillFlood)\
**Replies:** 2\
**Last updated:** [July 3, 2021, 10:09am UTC](https://discourse.julialang.org/t/remove-inner-module-function-name-with-docs-in-documenter-jl/61617 "2021-07-03T10:09:44Z")

</div>

Hi Guys, :slightly\_smiling\_face: I’m creating documentation for a package using Documenter.jl :man\_teacher:t2: :woman\_teacher:t2:, and I’m loving the efficiency that the @docs macro provides. :raised\_hands:t2: However…

---

## [ODE solver giving wrong results](https://discourse.julialang.org/t/ode-solver-giving-wrong-results/63891)

<div class="topic-metadata">

**Author:** [@rodpiferreira](https://discourse.julialang.org/u/rodpiferreira)\
**Replies:** 5\
**Last updated:** [July 3, 2021, 3:56am UTC](https://discourse.julialang.org/t/ode-solver-giving-wrong-results/63891 "2021-07-03T03:56:29Z")

</div>

Hey everyone! I want to solve f(u,p,t) = An\*u + b, where: An = \[0.0+0.0im 1.0+0.0im 5.0+0.0im -1.0+0.0im\], b = \[1.0+0.0im, 0.0+0.0im\], x = \[0.0+0.0im, 1.0+0.0im\] (initial condition) Which means that I have a system…

---

## [Unsuppress compiler error messages in Clang.jl](https://discourse.julialang.org/t/unsuppress-compiler-error-messages-in-clang-jl/63934)

<div class="topic-metadata">

**Author:** [@elkawee](https://discourse.julialang.org/u/elkawee)\
**Replies:** 3\
**Last updated:** [July 2, 2021, 5:27pm UTC](https://discourse.julialang.org/t/unsuppress-compiler-error-messages-in-clang-jl/63934 "2021-07-02T17:27:00Z")

</div>

Hi :slight\_smile: I’m pretty sure i’m the 100th guy who asks this, but i can’t find anything. I ripped out the relevant parts to be able to call trans\_unit.jl/parse\_header(..) directly, and when i do, the usual clang …

---

## [Calling Julia from Python with subprocess](https://discourse.julialang.org/t/calling-julia-from-python-with-subprocess/63939)

<div class="topic-metadata">

**Author:** [@FabVonBellingshausen](https://discourse.julialang.org/u/FabVonBellingshausen)\
**Replies:** 1\
**Last updated:** [July 2, 2021, 4:43pm UTC](https://discourse.julialang.org/t/calling-julia-from-python-with-subprocess/63939 "2021-07-02T16:43:31Z")

</div>

I am trying to call a Julia script from a Python script using the subprocess module from the Python standard library (I tried using PyJulia but couldn’t get it to run), as follows: cmd = "foo.jl bar" subproc…

---

## [Parallelization of estimation loop or using GPU for bayesian neural ODE](https://discourse.julialang.org/t/parallelization-of-estimation-loop-or-using-gpu-for-bayesian-neural-ode/63162)

<div class="topic-metadata">

**Author:** [@minou92](https://discourse.julialang.org/u/minou92)\
**Replies:** 1\
**Last updated:** [July 2, 2021, 4:05pm UTC](https://discourse.julialang.org/t/parallelization-of-estimation-loop-or-using-gpu-for-bayesian-neural-ode/63162 "2021-07-02T16:05:39Z")

</div>

I would like to improve the speed process of this following loop using wether gpu or CPU. in case using CPU, What is the best way nowadays to parallelize it ? Could you please help to include it in the code ? Regards f…

---

## [Trouble using ForwardDiff on a function with a cache vector and a custom struct](https://discourse.julialang.org/t/trouble-using-forwarddiff-on-a-function-with-a-cache-vector-and-a-custom-struct/63420)

<div class="topic-metadata">

**Author:** [@vettert](https://discourse.julialang.org/u/vettert)\
**Replies:** 1\
**Last updated:** [July 2, 2021, 4:04pm UTC](https://discourse.julialang.org/t/trouble-using-forwarddiff-on-a-function-with-a-cache-vector-and-a-custom-struct/63420 "2021-07-02T16:04:39Z")

</div>

I am having trouble calculating the gradient (via ForwardDiff.gradient) of a function that involves a cached vector and a custom struct. Here is my MWE: module atest using DiffEqBase: get\_tmp, dualcache, DiffCache using…

---

## [Best way to construct 2-D Laplacian banded matrix: BandedMatrices, sparse, or BlockBandedMatrices?](https://discourse.julialang.org/t/best-way-to-construct-2-d-laplacian-banded-matrix-bandedmatrices-sparse-or-blockbandedmatrices/29123)

<div class="topic-metadata">

**Author:** [@EmadMasroor](https://discourse.julialang.org/u/EmadMasroor)\
**Replies:** 22\
**Last updated:** [July 2, 2021, 12:13pm UTC](https://discourse.julialang.org/t/best-way-to-construct-2-d-laplacian-banded-matrix-bandedmatrices-sparse-or-blockbandedmatrices/29123 "2021-07-02T12:13:31Z")

</div>

Hi! I am trying to construct the matrix associated with the 2-D Laplacian operator. To do this, I need a special kind of banded matrix. It’s best illustrated at this excellent page, and I reproduce their example matrix …

---

## [Change a struct in place](https://discourse.julialang.org/t/change-a-struct-in-place/63914)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 20\
**Last updated:** [July 2, 2021, 11:16am UTC](https://discourse.julialang.org/t/change-a-struct-in-place/63914 "2021-07-02T11:16:36Z")

</div>

I made a struct with Float32 julia\> struct Foo x::Float32 end julia\> foo = Foo(1) Foo(1.0f0) But now I realized Float32 isn’t big enough and I want Float64, and I want the change to propagate to the ins…

---

## [Reading/Writing struct instance to file as binary](https://discourse.julialang.org/t/reading-writing-struct-instance-to-file-as-binary/63818)

<div class="topic-metadata">

**Author:** [@nullmap](https://discourse.julialang.org/u/nullmap)\
**Replies:** 7\
**Last updated:** [July 2, 2021, 11:02am UTC](https://discourse.julialang.org/t/reading-writing-struct-instance-to-file-as-binary/63818 "2021-07-02T11:02:15Z")

</div>

Hi everyone, I am looking into possible solutions for persisting struct instances on disk as binary data. I’m using credentials data as an MVP example. The following code works as I expect. I create a struct with some f…

---

## [How to parallelize list comprehension and map with multithreading?](https://discourse.julialang.org/t/how-to-parallelize-list-comprehension-and-map-with-multithreading/49509)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 20\
**Last updated:** [July 2, 2021, 10:22am UTC](https://discourse.julialang.org/t/how-to-parallelize-list-comprehension-and-map-with-multithreading/49509 "2021-07-02T10:22:55Z")

</div>

The macro Threads.@threads parallelizes for loops. Is there something similar for list comprehension and map? I can trivially rewrite them as for loops, but prefer not to.

---

## [Plot lines disappear when savefig to svg](https://discourse.julialang.org/t/plot-lines-disappear-when-savefig-to-svg/59173)

<div class="topic-metadata">

**Author:** [@BaronvonderHeyden](https://discourse.julialang.org/u/BaronvonderHeyden)\
**Replies:** 2\
**Last updated:** [July 2, 2021, 8:42am UTC](https://discourse.julialang.org/t/plot-lines-disappear-when-savefig-to-svg/59173 "2021-07-02T08:42:03Z")

</div>

When using the gr backend and saving a plot with savefig() as SVG some lines simply disappear. However, when saving the same figures as PNG or PDF they are present. This is what the SVG looks like: This is the PNG …

---

## [Package interoperability showcases](https://discourse.julialang.org/t/package-interoperability-showcases/33734)

<div class="topic-metadata">

**Author:** [@mschauer](https://discourse.julialang.org/u/mschauer)\
**Replies:** 7\
**Last updated:** [July 2, 2021, 7:49am UTC](https://discourse.julialang.org/t/package-interoperability-showcases/33734 "2021-07-02T07:49:35Z")

</div>

Picking up on our discussion on nice packages of the Julia ecosystem, What packages are state of the art… I argued that naming isolated packages does the ecosystem disregard because things julia-magically work together a…

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

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