# General Usage

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

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

**Page:** 466

---

## [Error in mean value of sparse arrays](https://discourse.julialang.org/t/error-in-mean-value-of-sparse-arrays/78796)

<div class="topic-metadata">

**Author:** [@nbakas](https://discourse.julialang.org/u/nbakas)\
**Replies:** 5\
**Last updated:** [March 31, 2022, 6:20pm UTC](https://discourse.julialang.org/t/error-in-mean-value-of-sparse-arrays/78796 "2022-03-31T18:20:03Z")

</div>

in the following code, I noticed two errors: the mean value of the positive elements is less than the mean value including zeros the mean value obtained from the loop is different than the mean value from the function …

---

## [I get a dead lock with only one lock](https://discourse.julialang.org/t/i-get-a-dead-lock-with-only-one-lock/78788)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 15\
**Last updated:** [March 31, 2022, 6:13pm UTC](https://discourse.julialang.org/t/i-get-a-dead-lock-with-only-one-lock/78788 "2022-03-31T18:13:44Z")

</div>

Hi all :slight\_smile: I’ve got the following in one of my pkgs. I put a print before and after. But one in 100 run it just stops there and does not print the second time. I’m kinda clueless how to debug this problem eve…

---

## [Package developers: what version of Julia to run tests on?](https://discourse.julialang.org/t/package-developers-what-version-of-julia-to-run-tests-on/78828)

<div class="topic-metadata">

**Author:** [@vtjeng](https://discourse.julialang.org/u/vtjeng)\
**Replies:** 1\
**Last updated:** [March 31, 2022, 4:46pm UTC](https://discourse.julialang.org/t/package-developers-what-version-of-julia-to-run-tests-on/78828 "2022-03-31T16:46:23Z")

</div>

I recently realized that the Julia LTS version is now 1.6 rather than 1.0 (Julia v1.7.0 has been released and v1.6 is now LTS). As a package developer, what version of Julia should I be having my tests run on? Today, I …

---

## [Poll: speed vs accuracy for \`Float64^-3\`](https://discourse.julialang.org/t/poll-speed-vs-accuracy-for-float64-3/77619)

<div class="topic-metadata">

**Author:** [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Replies:** 55\
**Last updated:** [March 31, 2022, 4:01pm UTC](https://discourse.julialang.org/t/poll-speed-vs-accuracy-for-float64-3/77619 "2022-03-31T16:01:23Z")

</div>

In Julia 1.8, we are getting a pure Julia pow function, and as discussed in https://github.com/JuliaLang/julia/pull/44529, part of this involved fixing a bug in x^-3. Before 1.8, Julia’s Literal pow meant that 10^-3 = 0…

---

## [Differences in Distributions.quantile output between package v0.18 and v0.25.52](https://discourse.julialang.org/t/differences-in-distributions-quantile-output-between-package-v0-18-and-v0-25-52/78821)

<div class="topic-metadata">

**Author:** [@Jon\_Barker](https://discourse.julialang.org/u/Jon_Barker)\
**Replies:** 0\
**Last updated:** [March 31, 2022, 4:10pm UTC](https://discourse.julialang.org/t/differences-in-distributions-quantile-output-between-package-v0-18-and-v0-25-52/78821 "2022-03-31T16:10:55Z")

</div>

I have a Julia 1.1 application I’m upgrading to 1.7 Here is some code: using Distributions g = Distributions.Gamma(0.004190129634501312, 0.00043125955824484334) q = 0.0444788802702531 Distributions.quantile(g, q) Unde…

---

## [Memory allocation when evaluating a function inside struct](https://discourse.julialang.org/t/memory-allocation-when-evaluating-a-function-inside-struct/78784)

<div class="topic-metadata">

**Author:** [@Kishore\_Nori](https://discourse.julialang.org/u/Kishore_Nori)\
**Replies:** 6\
**Last updated:** [March 31, 2022, 2:19pm UTC](https://discourse.julialang.org/t/memory-allocation-when-evaluating-a-function-inside-struct/78784 "2022-03-31T14:19:51Z")

</div>

I am trying to understand the following memory allocation behaviour: struct justfunc f::Function end func = justfunc(sin) @allocated func.f(0.1) # 32 @allocated sin(0.1) # 0 Having an other variant where the type i…

---

## [When not to use Multiple Dispatch?](https://discourse.julialang.org/t/when-not-to-use-multiple-dispatch/78792)

<div class="topic-metadata">

**Author:** [@helgee](https://discourse.julialang.org/u/helgee)\
**Replies:** 6\
**Last updated:** [March 31, 2022, 1:40pm UTC](https://discourse.julialang.org/t/when-not-to-use-multiple-dispatch/78792 "2022-03-31T13:40:55Z")

</div>

Hi folks! On my endless quest to make AstroTime.jl the best date and time handling package in the universe, I am pondering another redesign :see\_no\_evil: When modelling my problem domains, I always gravitate to pushing…

---

## [Error when trying to open a file](https://discourse.julialang.org/t/error-when-trying-to-open-a-file/78782)

<div class="topic-metadata">

**Author:** [@dannofthursday](https://discourse.julialang.org/u/dannofthursday)\
**Replies:** 2\
**Last updated:** [March 31, 2022, 1:36pm UTC](https://discourse.julialang.org/t/error-when-trying-to-open-a-file/78782 "2022-03-31T13:36:45Z")

</div>

I am writing what I thought would be a straight-forward piece of julia code to fix an issue with a json file in multiple folders. using JSON root = "C:\\\\ROOTFOLDER\\\\" cd(root) filename = "my.json" folderList = \["A", "…

---

## [Is it possible to throw errors over missed compiler optimizations?](https://discourse.julialang.org/t/is-it-possible-to-throw-errors-over-missed-compiler-optimizations/78805)

<div class="topic-metadata">

**Author:** [@cgeoga](https://discourse.julialang.org/u/cgeoga)\
**Replies:** 0\
**Last updated:** [March 31, 2022, 1:21pm UTC](https://discourse.julialang.org/t/is-it-possible-to-throw-errors-over-missed-compiler-optimizations/78805 "2022-03-31T13:21:35Z")

</div>

Hi all. I have a naive question: is it possible, and how involved would it be, to somehow write Julia code that throws an error if certain compiler optimizations fail to happen? Like, if you accidentally use globals/type…

---

## [NamedArrays REPL Issue](https://discourse.julialang.org/t/namedarrays-repl-issue/78675)

<div class="topic-metadata">

**Author:** [@tlorans](https://discourse.julialang.org/u/tlorans)\
**Replies:** 8\
**Last updated:** [March 31, 2022, 12:50pm UTC](https://discourse.julialang.org/t/namedarrays-repl-issue/78675 "2022-03-31T12:50:40Z")

</div>

Hello everyone, All my code isn’t working anymore since today, with the following simple MWE: x = NamedArray(\[0,4,5\],\["a","b","c"\]) Now output’s: ERROR: ArgumentError: reducing over an empty collection is not allowed…

---

## [Edge case in Sets with Floats](https://discourse.julialang.org/t/edge-case-in-sets-with-floats/78787)

<div class="topic-metadata">

**Author:** [@fatteneder](https://discourse.julialang.org/u/fatteneder)\
**Replies:** 6\
**Last updated:** [March 31, 2022, 12:25pm UTC](https://discourse.julialang.org/t/edge-case-in-sets-with-floats/78787 "2022-03-31T12:25:00Z")

</div>

Hi Julia Community, recently I was approached by a colleague who just got started with Julia and ran into a problem that took him ages to debug. We then seat down together and could come up with the following MWE: juli…

---

## [Memory allocation in iterator](https://discourse.julialang.org/t/memory-allocation-in-iterator/78786)

<div class="topic-metadata">

**Author:** [@Tqft](https://discourse.julialang.org/u/Tqft)\
**Replies:** 9\
**Last updated:** [March 31, 2022, 9:40am UTC](https://discourse.julialang.org/t/memory-allocation-in-iterator/78786 "2022-03-31T09:40:54Z")

</div>

There are already several discussions about memory allocations in iterators but I have a very simple question that bothers me whenever I implement an iterator. Take the example iterator from the manual: julia\> struct Sq…

---

## [Improving my mental model: Why is \`sizehint!()\` so much slower than \`zeros()\`?](https://discourse.julialang.org/t/improving-my-mental-model-why-is-sizehint-so-much-slower-than-zeros/78776)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 9\
**Last updated:** [March 31, 2022, 9:03am UTC](https://discourse.julialang.org/t/improving-my-mental-model-why-is-sizehint-so-much-slower-than-zeros/78776 "2022-03-31T09:03:57Z")

</div>

I am asking this question in an effort to improve my understanding of computer science, not to complain about Julia’s performance :wink: I understand that, in principle, if we know that we are going to be filling an vec…

---

## [Super slow string performance](https://discourse.julialang.org/t/super-slow-string-performance/78156)

<div class="topic-metadata">

**Author:** [@peteole](https://discourse.julialang.org/u/peteole)\
**Replies:** 2\
**Last updated:** [March 31, 2022, 8:59am UTC](https://discourse.julialang.org/t/super-slow-string-performance/78156 "2022-03-31T08:59:46Z")

</div>

Hi, while solving a coding competition problem with julia I experienced extreme performance issues with the String type. This program: function deleteCount(target::String, input::String) if length(target) \> length…

---

## [How to import module namespaces from julia session with PackageCompiler?](https://discourse.julialang.org/t/how-to-import-module-namespaces-from-julia-session-with-packagecompiler/78785)

<div class="topic-metadata">

**Author:** [@YongHee-Kim](https://discourse.julialang.org/u/YongHee-Kim)\
**Replies:** 1\
**Last updated:** [March 31, 2022, 7:57am UTC](https://discourse.julialang.org/t/how-to-import-module-namespaces-from-julia-session-with-packagecompiler/78785 "2022-03-31T07:57:00Z")

</div>

I’m trying to distribute my package with a PackageCompiler, so my users can run my package by just clicking the executable. And I also need to use the REPL, because I want my users to play with packages with commands I’…

---

## [Terminaal - cursor position](https://discourse.julialang.org/t/terminaal-cursor-position/78783)

<div class="topic-metadata">

**Author:** [@FedeClaudi](https://discourse.julialang.org/u/FedeClaudi)\
**Replies:** 0\
**Last updated:** [March 31, 2022, 6:29am UTC](https://discourse.julialang.org/t/terminaal-cursor-position/78783 "2022-03-31T06:29:51Z")

</div>

Hey everyone, The way progressbars will be rendered by Term.jl, I need to be moving the cursor in the terminal around, do some stuff and then restore its position. All of this is done by printing ANSI codes. Now, my pr…

---

## [Numerical precision](https://discourse.julialang.org/t/numerical-precision/78749)

<div class="topic-metadata">

**Author:** [@F-YF](https://discourse.julialang.org/u/F-YF)\
**Replies:** 15\
**Last updated:** [March 31, 2022, 12:38am UTC](https://discourse.julialang.org/t/numerical-precision/78749 "2022-03-31T00:38:00Z")

</div>

Recently I had a small problem with Julia that confused me. The code is shown below: Julia\> x=2.0e-10 2.0e-10 Julia\> -1.0\*(-0.5\*x^3 - 3.0\*x^2 - 7.5\*x - 7.5)\*exp(-x)/x^6 + 1.0\*(0.5\*x^3 - 3.0\*x^2 + 7.5\*x - 7.5)\*exp(x)/x…

---

## [Avoiding double lookup](https://discourse.julialang.org/t/avoiding-double-lookup/78636)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 11\
**Last updated:** [March 31, 2022, 12:18am UTC](https://discourse.julialang.org/t/avoiding-double-lookup/78636 "2022-03-31T00:18:58Z")

</div>

Is it possible to cache the location so I don’t need to look it up twice (once in get and once in setindex!)? "Increment the count by 1, starting from 0." function bump!(d::Dict{K,Int}, k::K) where K v = get(d, k, 0…

---

## [Finding which var is an invalid type when initialising a struct](https://discourse.julialang.org/t/finding-which-var-is-an-invalid-type-when-initialising-a-struct/78734)

<div class="topic-metadata">

**Author:** [@this\_josh](https://discourse.julialang.org/u/this_josh)\
**Replies:** 21\
**Last updated:** [March 31, 2022, 12:16am UTC](https://discourse.julialang.org/t/finding-which-var-is-an-invalid-type-when-initialising-a-struct/78734 "2022-03-31T00:16:01Z")

</div>

I have a function which loads some CSVs, and then constructs a large Struct, sometimes these CSVs contain information as Strings when they should be numerical. Currently When initialising a struct I get the unhelpful err…

---

## [Can the output of --track-allocation be trusted with multi-threading enabled?](https://discourse.julialang.org/t/can-the-output-of-track-allocation-be-trusted-with-multi-threading-enabled/78744)

<div class="topic-metadata">

**Author:** [@krcools](https://discourse.julialang.org/u/krcools)\
**Replies:** 9\
**Last updated:** [March 30, 2022, 6:07pm UTC](https://discourse.julialang.org/t/can-the-output-of-track-allocation-be-trusted-with-multi-threading-enabled/78744 "2022-03-30T18:07:43Z")

</div>

Below the output of --track-allocation. The first time when the code is ran with a single thread, the second time when the work is divided and the code is called from 8 threads. Is this output to be trusted? If so where …

---

## [Problem loading ML model using DataDeps](https://discourse.julialang.org/t/problem-loading-ml-model-using-datadeps/78692)

<div class="topic-metadata">

**Author:** [@Maxim\_Lubov](https://discourse.julialang.org/u/Maxim_Lubov)\
**Replies:** 1\
**Last updated:** [March 30, 2022, 6:03pm UTC](https://discourse.julialang.org/t/problem-loading-ml-model-using-datadeps/78692 "2022-03-30T18:03:51Z")

</div>

@oxinabox Hello everyone. I have a problem loading ML model using DataDeps. I load model via shared link to Google Drive. Model should be loaded to a specific folder on my drive, so I set: ENV\["DATADEPS\_ALWAYS\_AC…

---

## [Issue with 2 y axis using twinx with subplots using Plots.jl](https://discourse.julialang.org/t/issue-with-2-y-axis-using-twinx-with-subplots-using-plots-jl/78696)

<div class="topic-metadata">

**Author:** [@Iddingsite](https://discourse.julialang.org/u/Iddingsite)\
**Replies:** 5\
**Last updated:** [March 30, 2022, 5:04pm UTC](https://discourse.julialang.org/t/issue-with-2-y-axis-using-twinx-with-subplots-using-plots-jl/78696 "2022-03-30T17:04:12Z")

</div>

Hi everyone, I am trying to make a very simple plot using Plots and I can’t make it work. My goal is to use layout to have 2 subplots. The first 1 has to have two different y axis, using twinx I assume. My problem is t…

---

## [How to change CSS and remove double newline for @repl block in Documenter output?](https://discourse.julialang.org/t/how-to-change-css-and-remove-double-newline-for-repl-block-in-documenter-output/78753)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 2\
**Last updated:** [March 30, 2022, 4:16pm UTC](https://discourse.julialang.org/t/how-to-change-css-and-remove-double-newline-for-repl-block-in-documenter-output/78753 "2022-03-30T16:16:07Z")

</div>

Hello, I would like to make a couple of customisations to a Documenter output, more specifically when the @repl block is used: setting padding-bottom and padding-top to 0.1rem instead of 0.7 remove the extra newline be…

---

## [Avoid explicit conversion from scientific notation to int for generic struct](https://discourse.julialang.org/t/avoid-explicit-conversion-from-scientific-notation-to-int-for-generic-struct/78739)

<div class="topic-metadata">

**Author:** [@Uroc327](https://discourse.julialang.org/u/Uroc327)\
**Replies:** 2\
**Last updated:** [March 30, 2022, 1:56pm UTC](https://discourse.julialang.org/t/avoid-explicit-conversion-from-scientific-notation-to-int-for-generic-struct/78739 "2022-03-30T13:56:21Z")

</div>

Generic structs need an explicit conversion from double to int whereas non-generic don’t. I find this a bit confusing due to the inconsistency. Is there a way to avoid the explicit conversion? Example: struct A a::…

---

## [Fail to update my own Package](https://discourse.julialang.org/t/fail-to-update-my-own-package/78677)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 6\
**Last updated:** [March 30, 2022, 1:02pm UTC](https://discourse.julialang.org/t/fail-to-update-my-own-package/78677 "2022-03-30T13:02:10Z")

</div>

Hi, I have created the package EspyInsideFunction.jl, which is publicly available on GIT and is in the Julia registry. I have updated EspyInsideFunction.jl: a new commit of master, with tag \`\`0.1.2\`. Pushed, and check…

---

## [Makie: GLMakie backend fails to join the points in lines plot](https://discourse.julialang.org/t/makie-glmakie-backend-fails-to-join-the-points-in-lines-plot/78724)

<div class="topic-metadata">

**Author:** [@kunzaatko](https://discourse.julialang.org/u/kunzaatko)\
**Replies:** 2\
**Last updated:** [March 30, 2022, 12:51pm UTC](https://discourse.julialang.org/t/makie-glmakie-backend-fails-to-join-the-points-in-lines-plot/78724 "2022-03-30T12:51:11Z")

</div>

In line graphs using Makie with the backend GLMakie, the lines are not joined together. I do not know how to debug this. I suspect that this is an issue with my OpenGL. The compilation of GLMakie did not throw any warnin…

---

## [Tsit5 algorithm gives wrong results while lower order methods like Midpoint work fine](https://discourse.julialang.org/t/tsit5-algorithm-gives-wrong-results-while-lower-order-methods-like-midpoint-work-fine/78728)

<div class="topic-metadata">

**Author:** [@RayleighLord](https://discourse.julialang.org/u/RayleighLord)\
**Replies:** 3\
**Last updated:** [March 30, 2022, 12:12pm UTC](https://discourse.julialang.org/t/tsit5-algorithm-gives-wrong-results-while-lower-order-methods-like-midpoint-work-fine/78728 "2022-03-30T12:12:47Z")

</div>

Hello I was solving a test problem of a 1 DOF system with a friction interface. I was somewhat surprised that when I integrated the problem, Tsit5() gives very wrong results even when setting very low tolerances. Other …

---

## [Learning to Rank with Categorical variables](https://discourse.julialang.org/t/learning-to-rank-with-categorical-variables/78735)

<div class="topic-metadata">

**Author:** [@Billpete002](https://discourse.julialang.org/u/Billpete002)\
**Replies:** 0\
**Last updated:** [March 30, 2022, 11:56am UTC](https://discourse.julialang.org/t/learning-to-rank-with-categorical-variables/78735 "2022-03-30T11:56:35Z")

</div>

Hi all, I have a question about which package should I use for running against categorical and numerical values that will rank the results similar to Catboost with ranking as the objective. I know there is pycall.jl but…

---

## [Error: findfirst(((x,y))-\>x==1, \[(1,2), (3,4)\])](https://discourse.julialang.org/t/error-findfirst-x-y-x-1-1-2-3-4/78733)

<div class="topic-metadata">

**Author:** [@Sijun](https://discourse.julialang.org/u/Sijun)\
**Replies:** 3\
**Last updated:** [March 30, 2022, 11:55am UTC](https://discourse.julialang.org/t/error-findfirst-x-y-x-1-1-2-3-4/78733 "2022-03-30T11:55:30Z")

</div>

Why does this fail? :thinking: julia\> findfirst(((x,y))-\>x==1, \[(1,2), (3,4)\]) ERROR: MethodError: no method matching (::var"#7#8")(::Tuple{Int64, Int64}) while these two are fine: julia\> findfirst(\[(1,2), (3,4)\]) d…

---

## [Scratch or line detection in images](https://discourse.julialang.org/t/scratch-or-line-detection-in-images/78708)

<div class="topic-metadata">

**Author:** [@jonjilla](https://discourse.julialang.org/u/jonjilla)\
**Replies:** 1\
**Last updated:** [March 30, 2022, 8:16am UTC](https://discourse.julialang.org/t/scratch-or-line-detection-in-images/78708 "2022-03-30T08:16:21Z")

</div>

I have a general question regarding which package I should use to process image files to extract features like straight lines, scratches, arcs and other such features. Thanks.

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

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