# General Usage

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

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

**Page:** 167

---

## [How to suppress or redirect \`FileIO\` error messages](https://discourse.julialang.org/t/how-to-suppress-or-redirect-fileio-error-messages/114573)

<div class="topic-metadata">

**Author:** [@kimikage](https://discourse.julialang.org/u/kimikage)\
**Replies:** 1\
**Last updated:** [May 22, 2024, 2:27pm UTC](https://discourse.julialang.org/t/how-to-suppress-or-redirect-fileio-error-messages/114573 "2024-05-22T14:27:50Z")

</div>

When loaders or savers throw errors, FileIO.jl outputs error messages to stderr and stdout without Logging functions or macros. The messages are helpful in most cases, but can mess up proper log handling. julia\> using …

---

## [Investigating large latency on a constrained Windows environment](https://discourse.julialang.org/t/investigating-large-latency-on-a-constrained-windows-environment/114482)

<div class="topic-metadata">

**Author:** [@TimG](https://discourse.julialang.org/u/TimG)\
**Replies:** 85\
**Last updated:** [May 22, 2024, 2:21pm UTC](https://discourse.julialang.org/t/investigating-large-latency-on-a-constrained-windows-environment/114482 "2024-05-22T14:21:14Z")

</div>

On first start-up in the morning in VSCode, my code takes fully 7 minutes before executing the first line of my actual script (to read a csv file). using DataFrames using CSV using Dates using ZipArchives using GeoStats…

---

## [Using more threads than actual number of CPU cores](https://discourse.julialang.org/t/using-more-threads-than-actual-number-of-cpu-cores/114568)

<div class="topic-metadata">

**Author:** [@Ju\_ska](https://discourse.julialang.org/u/Ju_ska)\
**Replies:** 1\
**Last updated:** [May 22, 2024, 1:44pm UTC](https://discourse.julialang.org/t/using-more-threads-than-actual-number-of-cpu-cores/114568 "2024-05-22T13:44:44Z")

</div>

Hi, I currently run hundreds of tasks on a 10 core CPU, so I set JULIA\_NUM\_THREADS to 10. In my program, each task consumes only 50% of the resources of a core. Is there a downside to increase JULIA\_NUM\_THREADS to 20 …

---

## [@threads and two functions calls inside a loop](https://discourse.julialang.org/t/threads-and-two-functions-calls-inside-a-loop/114512)

<div class="topic-metadata">

**Author:** [@Ju\_ska](https://discourse.julialang.org/u/Ju_ska)\
**Replies:** 3\
**Last updated:** [May 22, 2024, 12:46pm UTC](https://discourse.julialang.org/t/threads-and-two-functions-calls-inside-a-loop/114512 "2024-05-22T12:46:37Z")

</div>

Hi, I have this use case: @threads loop function(parameters\_1) function(parameters\_2) end I would like to maximize load, problem is that sometimes everything is finished but the last iteration of the loop, mea…

---

## [Reading a file from line x to line y](https://discourse.julialang.org/t/reading-a-file-from-line-x-to-line-y/114363)

<div class="topic-metadata">

**Author:** [@Ju\_ska](https://discourse.julialang.org/u/Ju_ska)\
**Replies:** 28\
**Last updated:** [May 22, 2024, 12:28pm UTC](https://discourse.julialang.org/t/reading-a-file-from-line-x-to-line-y/114363 "2024-05-22T12:28:00Z")

</div>

Hi, I would like to read a portion of a lot of big files, as I know that the lines that interest me are located within line x and line y Currently, I load the files with CSV.File and read parts, but the loading overhea…

---

## [Callback function modifying model parameter](https://discourse.julialang.org/t/callback-function-modifying-model-parameter/114478)

<div class="topic-metadata">

**Author:** [@valerdam](https://discourse.julialang.org/u/valerdam)\
**Replies:** 15\
**Last updated:** [May 22, 2024, 12:17pm UTC](https://discourse.julialang.org/t/callback-function-modifying-model-parameter/114478 "2024-05-22T12:17:19Z")

</div>

I need to modify a parameter in an ODE problem in a callback. I found an example that does exactly what I want in here. (on the page search for PresetTimeCallback and it is the code including the first occurrence). Copie…

---

## [Segmentation fault using multithreaded julia on new server](https://discourse.julialang.org/t/segmentation-fault-using-multithreaded-julia-on-new-server/114557)

<div class="topic-metadata">

**Author:** [@Loic\_Herviou](https://discourse.julialang.org/u/Loic_Herviou)\
**Replies:** 0\
**Last updated:** [May 22, 2024, 11:46am UTC](https://discourse.julialang.org/t/segmentation-fault-using-multithreaded-julia-on-new-server/114557 "2024-05-22T11:46:05Z")

</div>

On our new server, we get random segmentation fault errors when using julia with multithreading. There is no crash for the same scripts with a single thread, or multithreaded on other machines. It seems to be independe…

---

## [How to use Cshort in Julia](https://discourse.julialang.org/t/how-to-use-cshort-in-julia/114506)

<div class="topic-metadata">

**Author:** [@VinodV](https://discourse.julialang.org/u/VinodV)\
**Replies:** 7\
**Last updated:** [May 22, 2024, 10:31am UTC](https://discourse.julialang.org/t/how-to-use-cshort-in-julia/114506 "2024-05-22T10:31:36Z")

</div>

I have a 16-bit hex string a = "4E1A". How to convert a to signed short integer using Cshort. No example usage is found for Cshort. julia\> reinterpret(Int16,\[0x4E1A\]) 1-element reinterpret(Int16, ::Vector{UInt16}): …

---

## [How does constant propagation impact latency with a Val-based dispatch?](https://discourse.julialang.org/t/how-does-constant-propagation-impact-latency-with-a-val-based-dispatch/114545)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 0\
**Last updated:** [May 22, 2024, 5:49am UTC](https://discourse.julialang.org/t/how-does-constant-propagation-impact-latency-with-a-val-based-dispatch/114545 "2024-05-22T05:49:57Z")

</div>

The example here is schematic, and isn’t really an MWE. Suppose I have a set of functions like f() = f('A') Base.@constprop :aggressive f(a, args...) = g(Val(a == 'A'), args...) Base.@constprop :aggressive g(::Val{true…

---

## [Evaluation into closed module - what's wrong?](https://discourse.julialang.org/t/evaluation-into-closed-module-whats-wrong/114526)

<div class="topic-metadata">

**Author:** [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Replies:** 3\
**Last updated:** [May 22, 2024, 5:05am UTC](https://discourse.julialang.org/t/evaluation-into-closed-module-whats-wrong/114526 "2024-05-22T05:05:26Z")

</div>

Hi metaprogramming afficionados, The package SparseConnectivityTracer.jl works by operator overloading, like ForwardDiff.jl or Measurements.jl. We overload operations on new number types called ConnectivityTracer, Gradi…

---

## [\`open\` and \`include\` might point to different folders](https://discourse.julialang.org/t/open-and-include-might-point-to-different-folders/114538)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 3\
**Last updated:** [May 22, 2024, 3:15am UTC](https://discourse.julialang.org/t/open-and-include-might-point-to-different-folders/114538 "2024-05-22T03:15:40Z")

</div>

So, I have this set-up: I have my active Julia folder in VSCode. Within it I have a folder “subfolder”. I am running stuff in the Julia file “subfolder/my\_script.jl” I am running this script: open("testfile.jl", "w")…

---

## [How to define an overload constructor across an abstract type?](https://discourse.julialang.org/t/how-to-define-an-overload-constructor-across-an-abstract-type/114535)

<div class="topic-metadata">

**Author:** [@lpz18](https://discourse.julialang.org/u/lpz18)\
**Replies:** 1\
**Last updated:** [May 22, 2024, 1:34am UTC](https://discourse.julialang.org/t/how-to-define-an-overload-constructor-across-an-abstract-type/114535 "2024-05-22T01:34:27Z")

</div>

I have various structs of parameters that I am using for things like running ODEs and least squares optimizations, i.e.: abstract type model\_A end struct params1 \<: model\_A a::Float64 end struct params2 \<: model\_A…

---

## [Alt-del to remove a word to the left in the REPL](https://discourse.julialang.org/t/alt-del-to-remove-a-word-to-the-left-in-the-repl/114517)

<div class="topic-metadata">

**Author:** [@1m1](https://discourse.julialang.org/u/1m1)\
**Replies:** 7\
**Last updated:** [May 21, 2024, 5:12pm UTC](https://discourse.julialang.org/t/alt-del-to-remove-a-word-to-the-left-in-the-repl/114517 "2024-05-21T17:12:19Z")

</div>

the macOS terminal has this feature and it is very useful

---

## [Change of variables in ModelingToolkit.jl](https://discourse.julialang.org/t/change-of-variables-in-modelingtoolkit-jl/114354)

<div class="topic-metadata">

**Author:** [@langestefan](https://discourse.julialang.org/u/langestefan)\
**Replies:** 10\
**Last updated:** [May 21, 2024, 4:51pm UTC](https://discourse.julialang.org/t/change-of-variables-in-modelingtoolkit-jl/114354 "2024-05-21T16:51:45Z")

</div>

Hi, I am trying to estimate the parameters of a simple RC network in ModelingToolkit.jl. The voltage over C can be defined by the following ODE: \\frac{dT\_i}{dt} = \\Phi\_h(t) + \\frac{T\_a(t) - T\_i(t)}{C\_i R\_{ia}} Est…

---

## [Conditional counting of array elements of mixed types](https://discourse.julialang.org/t/conditional-counting-of-array-elements-of-mixed-types/114516)

<div class="topic-metadata">

**Author:** [@ssrrii](https://discourse.julialang.org/u/ssrrii)\
**Replies:** 6\
**Last updated:** [May 21, 2024, 3:22pm UTC](https://discourse.julialang.org/t/conditional-counting-of-array-elements-of-mixed-types/114516 "2024-05-21T15:22:03Z")

</div>

I am analyzing arrays (vectors) that have a mix of strings and numbers. The strings are the same, namely “N.A.” (as a result from some test). The rest of the elements are numbers of which I would like to count how many …

---

## [Developing package CompatHelper: The requested URL returned error: 403](https://discourse.julialang.org/t/developing-package-compathelper-the-requested-url-returned-error-403/99881)

<div class="topic-metadata">

**Author:** [@KKesgin](https://discourse.julialang.org/u/KKesgin)\
**Replies:** 2\
**Last updated:** [May 21, 2024, 2:43pm UTC](https://discourse.julialang.org/t/developing-package-compathelper-the-requested-url-returned-error-403/99881 "2024-05-21T14:43:15Z")

</div>

Hi All, I’m trying to add a package for the general registry for a research work I’m about to publish. I tried following the guidelines for developing packages but I’ve been having numerous issues. The main one I’m stuc…

---

## [Passing a function over vectors as an argument to ccall](https://discourse.julialang.org/t/passing-a-function-over-vectors-as-an-argument-to-ccall/114487)

<div class="topic-metadata">

**Author:** [@brunompacheco](https://discourse.julialang.org/u/brunompacheco)\
**Replies:** 3\
**Last updated:** [May 21, 2024, 1:55pm UTC](https://discourse.julialang.org/t/passing-a-function-over-vectors-as-an-argument-to-ccall/114487 "2024-05-21T13:55:37Z")

</div>

I am not being able to properly pass a julia-defined function that takes vector and scalar values to C-defined functions. I have two functions in C EXPORT\_C double apply\_fun\_simple(double (\*fun)(double\*), double\* x) { …

---

## [Group attributes with JLD2](https://discourse.julialang.org/t/group-attributes-with-jld2/114302)

<div class="topic-metadata">

**Author:** [@bmxam](https://discourse.julialang.org/u/bmxam)\
**Replies:** 7\
**Last updated:** [May 21, 2024, 1:26pm UTC](https://discourse.julialang.org/t/group-attributes-with-jld2/114302 "2024-05-21T13:26:51Z")

</div>

I’m starting to use the JLD2.jl package to read an HDF5 file. I am bit confused about the way attributes of Group should be accessed. It seems to me that the parent node of the group is always needed to access the group …

---

## [Define the size of a String variable](https://discourse.julialang.org/t/define-the-size-of-a-string-variable/114474)

<div class="topic-metadata">

**Author:** [@Ju\_ska](https://discourse.julialang.org/u/Ju_ska)\
**Replies:** 10\
**Last updated:** [May 21, 2024, 12:58pm UTC](https://discourse.julialang.org/t/define-the-size-of-a-string-variable/114474 "2024-05-21T12:58:43Z")

</div>

Hi, I don’t know if it’s possible to pre-allocate a Vector{String} with a fixed number of elements, like: a=Array{String}(undef, 1, 4) but with a fixed length of the strings inside.

---

## [Types must be first defined then called in a module? Why?](https://discourse.julialang.org/t/types-must-be-first-defined-then-called-in-a-module-why/114497)

<div class="topic-metadata">

**Author:** [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Replies:** 7\
**Last updated:** [May 21, 2024, 11:40am UTC](https://discourse.julialang.org/t/types-must-be-first-defined-then-called-in-a-module-why/114497 "2024-05-21T11:40:10Z")

</div>

module MyModule function myfun(t::MyType) println(plusone(t.x)) end struct MyType x::Float64 end function plusone(x) x + 1 end end ERROR: UndefVarError: \`MyType\` not defined

---

## [Which format for my regions/scenario settings?](https://discourse.julialang.org/t/which-format-for-my-regions-scenario-settings/114498)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 0\
**Last updated:** [May 21, 2024, 8:46am UTC](https://discourse.julialang.org/t/which-format-for-my-regions-scenario-settings/114498 "2024-05-21T08:46:07Z")

</div>

I need to develop a new model where I need to have separate model settings for the definition of the various regions and scenarios within regions… not really the data itself, but the definition of the various dimensions …

---

## [Find indices of boundary nodes](https://discourse.julialang.org/t/find-indices-of-boundary-nodes/114493)

<div class="topic-metadata">

**Author:** [@Domenico\_Lahaye](https://discourse.julialang.org/u/Domenico_Lahaye)\
**Replies:** 2\
**Last updated:** [May 21, 2024, 7:53am UTC](https://discourse.julialang.org/t/find-indices-of-boundary-nodes/114493 "2024-05-21T07:53:56Z")

</div>

Given the code foo(x,y) = x+y xvec = range(0,1,length=5) yvec = range(0,1,length=5) fvec = vec(foo.(xvec,yvec')) Q1: how to find indices on fvec that correspond to start/end point of xvec/yvec ? Q2: how to overwrite …

---

## [Adding CUDA.jl dependency to juliacall python package](https://discourse.julialang.org/t/adding-cuda-jl-dependency-to-juliacall-python-package/114072)

<div class="topic-metadata">

**Author:** [@Dale\_James\_Black](https://discourse.julialang.org/u/Dale_James_Black)\
**Replies:** 1\
**Last updated:** [May 20, 2024, 10:36pm UTC](https://discourse.julialang.org/t/adding-cuda-jl-dependency-to-juliacall-python-package/114072 "2024-05-20T22:36:25Z")

</div>

I am trying to create a wrapper python package for my Julia library, DistanceTransforms.jl, called PyDTs. This package utilizes rye as the package manager and intends to work with CUDA.jl and PyTorch. Therefore, I am try…

---

## [Async hangs with continue](https://discourse.julialang.org/t/async-hangs-with-continue/114472)

<div class="topic-metadata">

**Author:** [@lstagner](https://discourse.julialang.org/u/lstagner)\
**Replies:** 5\
**Last updated:** [May 20, 2024, 5:32pm UTC](https://discourse.julialang.org/t/async-hangs-with-continue/114472 "2024-05-20T17:32:25Z")

</div>

I have a function that listens to a redis stream in a while loop but it hangs and doesnt release back to the REPL. I managed to create a MWE. function foo() i = 0 while true if i==0 continue …

---

## [The Problem with Julia that makes me want to leave - First run Times](https://discourse.julialang.org/t/the-problem-with-julia-that-makes-me-want-to-leave-first-run-times/114316)

<div class="topic-metadata">

**Author:** [@Maddy](https://discourse.julialang.org/u/Maddy)\
**Replies:** 52\
**Last updated:** [May 18, 2024, 6:05pm UTC](https://discourse.julialang.org/t/the-problem-with-julia-that-makes-me-want-to-leave-first-run-times/114316 "2024-05-18T18:05:01Z")

</div>

I started my programming journey in Python. A year ago, to create a real-time simulation, I came to know about Julia with its great speed. I used Julia for the first time and I remember the spark of joy I had while mess…

---

## [Claim (false): Julia isn't multiple dispatch but overloading](https://discourse.julialang.org/t/claim-false-julia-isnt-multiple-dispatch-but-overloading/42370)

<div class="topic-metadata">

**Author:** [@dataSurfer](https://discourse.julialang.org/u/dataSurfer)\
**Replies:** 133\
**Last updated:** [May 20, 2024, 1:27pm UTC](https://discourse.julialang.org/t/claim-false-julia-isnt-multiple-dispatch-but-overloading/42370 "2024-05-20T13:27:02Z")

</div>

I heard a rumour that Julia’s multiple dispatch is “fake news”, in reality it’s overloading because you compile the function before it is run and all you are doing in Julia is just a series of compile and run actions. Is…

---

## [Unexpected precompilation in Binder based on Docker image](https://discourse.julialang.org/t/unexpected-precompilation-in-binder-based-on-docker-image/114473)

<div class="topic-metadata">

**Author:** [@goerz](https://discourse.julialang.org/u/goerz)\
**Replies:** 4\
**Last updated:** [May 20, 2024, 1:17pm UTC](https://discourse.julialang.org/t/unexpected-precompilation-in-binder-based-on-docker-image/114473 "2024-05-20T13:17:15Z")

</div>

I’ve set up a Dockerfile that sets up a Julia (and Python) environment for a tutorial that should run on https://mybinder.org. The reason I’m using a Dockerfile instead of relying on Binder to set up everything based on …

---

## [Is there a \`CartesianIndex\` using \`Int32\`?](https://discourse.julialang.org/t/is-there-a-cartesianindex-using-int32/114468)

<div class="topic-metadata">

**Author:** [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Replies:** 8\
**Last updated:** [May 20, 2024, 12:18pm UTC](https://discourse.julialang.org/t/is-there-a-cartesianindex-using-int32/114468 "2024-05-20T12:18:15Z")

</div>

The definition in Julia base/multidimensional.jl is restricted to Int64 struct CartesianIndex{N} \<: AbstractCartesianIndex{N} I::NTuple{N,Int} CartesianIndex{N}(index::NTuple{N,Integer}) where {N} = new(in…

---

## [Tuple Restructuring Syntax](https://discourse.julialang.org/t/tuple-restructuring-syntax/114461)

<div class="topic-metadata">

**Author:** [@Alec\_Loudenback](https://discourse.julialang.org/u/Alec_Loudenback)\
**Replies:** 6\
**Last updated:** [May 20, 2024, 3:56am UTC](https://discourse.julialang.org/t/tuple-restructuring-syntax/114461 "2024-05-20T03:56:57Z")

</div>

Can someone help me understand why the latter works but the former does not? map((x, y) -\> x \* y, zip(xs, ys)) # MethodError map(((x, y),) -\> x \* y, zip(xs, ys)) # works To me the first is akin to the form I usually u…

---

## [\`KeyError\` when using \`pmap\`](https://discourse.julialang.org/t/keyerror-when-using-pmap/114464)

<div class="topic-metadata">

**Author:** [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Replies:** 3\
**Last updated:** [May 20, 2024, 3:42am UTC](https://discourse.julialang.org/t/keyerror-when-using-pmap/114464 "2024-05-20T03:42:19Z")

</div>

I’m trying to use pmap form Distributed.jl for parallel computing in the runtests.jl file of a package (MyPkg) that is in development. The code is like: # runtests.jl using Distributed: @everywhere, addprocs, pmap usin…

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

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