# General Usage

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

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

**Page:** 216

---

## [How to ensure :sum of state varaibles remain a constant value , dde with constant lags](https://discourse.julialang.org/t/how-to-ensure-sum-of-state-varaibles-remain-a-constant-value-dde-with-constant-lags/108244)

<div class="topic-metadata">

**Author:** [@Ananya\_Hazarika](https://discourse.julialang.org/u/Ananya_Hazarika)\
**Replies:** 3\
**Last updated:** [January 3, 2024, 12:52am UTC](https://discourse.julialang.org/t/how-to-ensure-sum-of-state-varaibles-remain-a-constant-value-dde-with-constant-lags/108244 "2024-01-03T00:52:04Z")

</div>

how can i make sure that none of the values become negative and at the same time their sum to be constant? solving a dde with constant lags.

---

## [OrdinaryDiffEq fails to precompile in Julia 1.9.3](https://discourse.julialang.org/t/ordinarydiffeq-fails-to-precompile-in-julia-1-9-3/107005)

<div class="topic-metadata">

**Author:** [@Pranav\_Vinod](https://discourse.julialang.org/u/Pranav_Vinod)\
**Replies:** 5\
**Last updated:** [January 2, 2024, 10:52pm UTC](https://discourse.julialang.org/t/ordinarydiffeq-fails-to-precompile-in-julia-1-9-3/107005 "2024-01-02T22:52:58Z")

</div>

I am suddenly getting an error while precompiling the OrdinaryDiffEq package. I am using Julia on a cluster and it had been working fine until last night. But I tried to run my code using it and I get the following error…

---

## [Examples of programs (simulations, etc.) sped up with StaticArrays](https://discourse.julialang.org/t/examples-of-programs-simulations-etc-sped-up-with-staticarrays/108270)

<div class="topic-metadata">

**Author:** [@awiersdorf](https://discourse.julialang.org/u/awiersdorf)\
**Replies:** 2\
**Last updated:** [January 2, 2024, 9:56pm UTC](https://discourse.julialang.org/t/examples-of-programs-simulations-etc-sped-up-with-staticarrays/108270 "2024-01-02T21:56:24Z")

</div>

Hey folks, I’m looking for some examples of programs that got sped up by using StaticArrays—do any of you have an example (preferably real-world or close to real-world) of a time when dropping StaticArrays into your pro…

---

## [The sort！function](https://discourse.julialang.org/t/the-sort-function/108261)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 8\
**Last updated:** [January 2, 2024, 4:19pm UTC](https://discourse.julialang.org/t/the-sort-function/108261 "2024-01-02T16:19:02Z")

</div>

In matlab, with the code \[table, ind\]= sort(table) we get not only the sorted ‘table’, but also the ‘ind’ that contains the information of the positions of the sorted elements in the original table. What is the counte…

---

## [Adding arbitrary text to Plots.jl output](https://discourse.julialang.org/t/adding-arbitrary-text-to-plots-jl-output/108262)

<div class="topic-metadata">

**Author:** [@paulmelis](https://discourse.julialang.org/u/paulmelis)\
**Replies:** 3\
**Last updated:** [January 2, 2024, 3:35pm UTC](https://discourse.julialang.org/t/adding-arbitrary-text-to-plots-jl-output/108262 "2024-01-02T15:35:26Z")

</div>

I’d like to add some footer text to my plots (I’m already using two lines of title), but can’t seem to find a way to do it. I know about annotate!(), but that only adds text within the plot region in the plot coordinate …

---

## [Idea: New julia CLI switches (\`-m\` and \`--pkg\`)](https://discourse.julialang.org/t/idea-new-julia-cli-switches-m-and-pkg/98897)

<div class="topic-metadata">

**Author:** [@pankgeorg](https://discourse.julialang.org/u/pankgeorg)\
**Replies:** 9\
**Last updated:** [January 2, 2024, 2:32pm UTC](https://discourse.julialang.org/t/idea-new-julia-cli-switches-m-and-pkg/98897 "2024-01-02T14:32:08Z")

</div>

\-m: shorthand for -e using Module: Module julia -e "import Pluto; Pluto.run()" is a pattern I happen to use very often With this idea it could get converted to julia -m Pluto which could even run pluto as-is (inv…

---

## [How can I splat expressions into quote blocks?](https://discourse.julialang.org/t/how-can-i-splat-expressions-into-quote-blocks/108263)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 3\
**Last updated:** [January 2, 2024, 2:15pm UTC](https://discourse.julialang.org/t/how-can-i-splat-expressions-into-quote-blocks/108263 "2024-01-02T14:15:33Z")

</div>

ex1 = quote a = 1 a += 1 end ex2 = quote a \*= 2 a += 3 end quote $ex1... $ex2... end gives me quote #= REPL\[65\]:2 =# begin #= REPL\[61\]:2 =# a = 1 #= REPL\[61\]:3 =#…

---

## [Fast conversion from Matrix{Union{Missing, Float64}} to Sparse](https://discourse.julialang.org/t/fast-conversion-from-matrix-union-missing-float64-to-sparse/108161)

<div class="topic-metadata">

**Author:** [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Replies:** 11\
**Last updated:** [January 2, 2024, 2:10pm UTC](https://discourse.julialang.org/t/fast-conversion-from-matrix-union-missing-float64-to-sparse/108161 "2024-01-02T14:10:55Z")

</div>

I have a matrix that contains lots of missing values. I am toying with the idea of using sparsity to represent those missing values instead. However, one hurdle to easy conversion from Matrix to SparseMatrix is that the …

---

## [Using ForwardDiff and Symbolics, with arithmetic operations](https://discourse.julialang.org/t/using-forwarddiff-and-symbolics-with-arithmetic-operations/106530)

<div class="topic-metadata">

**Author:** [@polhager](https://discourse.julialang.org/u/polhager)\
**Replies:** 2\
**Last updated:** [January 2, 2024, 9:32am UTC](https://discourse.julialang.org/t/using-forwarddiff-and-symbolics-with-arithmetic-operations/106530 "2024-01-02T09:32:49Z")

</div>

I have a somewhat complicated function I’d like to find the analytical jacobian for. When using ForwardDiff and Symbolics and defining a function where both the input variables and certain parameters are symbolic, I get …

---

## [Modifying the fields of an immutable struct](https://discourse.julialang.org/t/modifying-the-fields-of-an-immutable-struct/108224)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 5\
**Last updated:** [January 2, 2024, 7:07am UTC](https://discourse.julialang.org/t/modifying-the-fields-of-an-immutable-struct/108224 "2024-01-02T07:07:45Z")

</div>

I have defined a struct struct foo x y end Then I created a variable a = foo(\[1,2\], \[3,45\]) I got error with a.x= \[3,4\] ERROR: setfield!: immutable struct of type foo cannot be changed Stacktrace: \[1\] setpropert…

---

## [Surrogates.jl - RBF surrogate issues](https://discourse.julialang.org/t/surrogates-jl-rbf-surrogate-issues/108198)

<div class="topic-metadata">

**Author:** [@Obtuya7](https://discourse.julialang.org/u/Obtuya7)\
**Replies:** 5\
**Last updated:** [January 1, 2024, 10:12pm UTC](https://discourse.julialang.org/t/surrogates-jl-rbf-surrogate-issues/108198 "2024-01-01T22:12:24Z")

</div>

Hello, I’m running into an issue with the Surrogates.jl RBF models. I’m attempting to generate surfaces with 25 sample points using various surrogate modeling techniques. I was able to generate the GPR surfaces without…

---

## [Base.throwto() blocking perpetually](https://discourse.julialang.org/t/base-throwto-blocking-perpetually/108237)

<div class="topic-metadata">

**Author:** [@JoO0oss](https://discourse.julialang.org/u/JoO0oss)\
**Replies:** 1\
**Last updated:** [January 1, 2024, 10:00pm UTC](https://discourse.julialang.org/t/base-throwto-blocking-perpetually/108237 "2024-01-01T22:00:44Z")

</div>

I recently found that throwto() never returns, it just hangs (see this GitHub issue) and constructed a little demo: task = @async begin while true print("-") end end sleep(0.003) println("Throwing...")…

---

## [Why does juliaup delete the old versions?](https://discourse.julialang.org/t/why-does-juliaup-delete-the-old-versions/108193)

<div class="topic-metadata">

**Author:** [@Tetrakai](https://discourse.julialang.org/u/Tetrakai)\
**Replies:** 10\
**Last updated:** [January 1, 2024, 7:44pm UTC](https://discourse.julialang.org/t/why-does-juliaup-delete-the-old-versions/108193 "2024-01-01T19:44:54Z")

</div>

I started with this: $ juliaup status Default Channel Version Update ------------------------------------------------------------------------------------------…

---

## [Error with multiple extensions - related to \_\_init\_\_()?](https://discourse.julialang.org/t/error-with-multiple-extensions-related-to-init/108196)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 5\
**Last updated:** [January 1, 2024, 5:40pm UTC](https://discourse.julialang.org/t/error-with-multiple-extensions-related-to-init/108196 "2024-01-01T17:40:09Z")

</div>

Why is \_\_init\_\_() for a package called during precompilation of package extensions? I thought (from the docs) that \_\_init\_\_() would only be called when the module was loaded with using or \`import? The reason for the que…

---

## [Stipple with Apache mod\_rewrite front-end](https://discourse.julialang.org/t/stipple-with-apache-mod-rewrite-front-end/108228)

<div class="topic-metadata">

**Author:** [@grahamstark](https://discourse.julialang.org/u/grahamstark)\
**Replies:** 0\
**Last updated:** [January 1, 2024, 12:16pm UTC](https://discourse.julialang.org/t/stipple-with-apache-mod-rewrite-front-end/108228 "2024-01-01T12:16:36Z")

</div>

Hi, Can anyone share with me an example of a reactive Stipple app using Apache with mod-rewrite as a front end? I already have a Genie server using rewrite and Apache, but that’s just a back-end, and I’d like to stick t…

---

## [Problem with parametric composite types](https://discourse.julialang.org/t/problem-with-parametric-composite-types/108222)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 5\
**Last updated:** [January 1, 2024, 11:13am UTC](https://discourse.julialang.org/t/problem-with-parametric-composite-types/108222 "2024-01-01T11:13:10Z")

</div>

I defined a type: struct Point{T} x :: T y :: T end Then when I tried to construct an variable b = Point(1.0, 2) I got ERROR: MethodError: no method matching Point(::Float64, ::Int64) Closest candidates are: P…

---

## [Are StaticArrays always faster?](https://discourse.julialang.org/t/are-staticarrays-always-faster/108225)

<div class="topic-metadata">

**Author:** [@Uranium238](https://discourse.julialang.org/u/Uranium238)\
**Replies:** 2\
**Last updated:** [January 1, 2024, 10:07am UTC](https://discourse.julialang.org/t/are-staticarrays-always-faster/108225 "2024-01-01T10:07:31Z")

</div>

I was under the impression that StaticArrays or operations that involve SMatrix are faster than the non Static counterparts. To test this out I wrote a small code that does matrix-multiplication related computations of a…

---

## [What is the difference between copy() and deepcopy()?](https://discourse.julialang.org/t/what-is-the-difference-between-copy-and-deepcopy/3918)

<div class="topic-metadata">

**Author:** [@leejm516](https://discourse.julialang.org/u/leejm516)\
**Replies:** 7\
**Last updated:** [January 1, 2024, 5:39am UTC](https://discourse.julialang.org/t/what-is-the-difference-between-copy-and-deepcopy/3918 "2024-01-01T05:39:44Z")

</div>

julia\> a = \[1,2,3,4\]; julia\> b = a; julia\> a\[1\] = 4; julia\> b 4-element Array{Int64,1}: 4 2 3 4 This is the shallow copy AFAIK. But at a glance, I couldn’t find clear differences between copy() and deepcopy(), alth…

---

## [Convert variable vs. hardcode allocations/time](https://discourse.julialang.org/t/convert-variable-vs-hardcode-allocations-time/108211)

<div class="topic-metadata">

**Author:** [@mattsignorelli](https://discourse.julialang.org/u/mattsignorelli)\
**Replies:** 2\
**Last updated:** [December 31, 2023, 5:34pm UTC](https://discourse.julialang.org/t/convert-variable-vs-hardcode-allocations-time/108211 "2023-12-31T17:34:07Z")

</div>

Alright, I’m sure there’s a good answer for this, but I am perplexed. julia\> using BenchmarkTools: @btime julia\> @btime convert(Float64, 5) 0.964 ns (0 allocations: 0 bytes) 5.0 julia\> a = 5 5 julia\> @btime convert…

---

## [Cannot catch Ctrl-C gracefully in this script](https://discourse.julialang.org/t/cannot-catch-ctrl-c-gracefully-in-this-script/79757)

<div class="topic-metadata">

**Author:** [@chunjiw](https://discourse.julialang.org/u/chunjiw)\
**Replies:** 12\
**Last updated:** [December 31, 2023, 10:54am UTC](https://discourse.julialang.org/t/cannot-catch-ctrl-c-gracefully-in-this-script/79757 "2023-12-31T10:54:03Z")

</div>

This is related to this issue. Put the following into a script file.jl: function try\_interrupt() while true try sleep(1) println("trying...") @async 1+1 catch e …

---

## [Composite type comparison](https://discourse.julialang.org/t/composite-type-comparison/108192)

<div class="topic-metadata">

**Author:** [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Replies:** 1\
**Last updated:** [December 30, 2023, 7:20pm UTC](https://discourse.julialang.org/t/composite-type-comparison/108192 "2023-12-30T19:20:58Z")

</div>

Something similar to this probably has been asked and answered before, but my search-Fu is not strong enough to find the answer. I can’t figure out why the last comparison doesn’t succeed. julia\> x (\[1\], \[1\]) julia\> t…

---

## [Compiling Julia from source vs release binaries](https://discourse.julialang.org/t/compiling-julia-from-source-vs-release-binaries/108180)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 6\
**Last updated:** [December 30, 2023, 5:26pm UTC](https://discourse.julialang.org/t/compiling-julia-from-source-vs-release-binaries/108180 "2023-12-30T17:26:42Z")

</div>

I have always been compiling Julia from sources (checking out the relevant release- branch in the git repo), but since juliaup is so convenient, I am wondering if I should do that. Specifically, compiling from source ta…

---

## [Issues in conda-based simultaneous installation of PyCall and RCall](https://discourse.julialang.org/t/issues-in-conda-based-simultaneous-installation-of-pycall-and-rcall/108183)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 2\
**Last updated:** [December 30, 2023, 3:27pm UTC](https://discourse.julialang.org/t/issues-in-conda-based-simultaneous-installation-of-pycall-and-rcall/108183 "2023-12-30T15:27:56Z")

</div>

Hello, I have a project where I use both PyCall and RCall with both downloaded using conda (i.e. I set both ENV\["PYTHON"\] = "" and ENV\["R\_HOME"\] = "\*"). Now the issue is in github CI, where conda complains of package co…

---

## [GPU parallelization for a very large system of ODEs](https://discourse.julialang.org/t/gpu-parallelization-for-a-very-large-system-of-odes/107187)

<div class="topic-metadata">

**Author:** [@ian](https://discourse.julialang.org/u/ian)\
**Replies:** 5\
**Last updated:** [December 30, 2023, 10:46am UTC](https://discourse.julialang.org/t/gpu-parallelization-for-a-very-large-system-of-odes/107187 "2023-12-30T10:46:48Z")

</div>

Hi all, I need to simulate a very large system of ODEs (~10^5 states). At every time step in the simulation I need to update a matrix using the current value of the state vector. Here is an MWE of the matrix updating f…

---

## [Bad performance of anonymous functions even when they are type-stable](https://discourse.julialang.org/t/bad-performance-of-anonymous-functions-even-when-they-are-type-stable/108173)

<div class="topic-metadata">

**Author:** [@frankwswang](https://discourse.julialang.org/u/frankwswang)\
**Replies:** 2\
**Last updated:** [December 30, 2023, 6:56am UTC](https://discourse.julialang.org/t/bad-performance-of-anonymous-functions-even-when-they-are-type-stable/108173 "2023-12-30T06:56:46Z")

</div>

MWE: julia\> f1 = function (x) x/2 end #3 (generic function with 1 method) julia\> function f1\_2(x) x/2 end f1\_2 (generic function with 1 method) julia\> f2 = function (x) …

---

## [Some notes on performance of callable structs](https://discourse.julialang.org/t/some-notes-on-performance-of-callable-structs/108042)

<div class="topic-metadata">

**Author:** [@arik](https://discourse.julialang.org/u/arik)\
**Replies:** 17\
**Last updated:** [December 30, 2023, 3:52am UTC](https://discourse.julialang.org/t/some-notes-on-performance-of-callable-structs/108042 "2023-12-30T03:52:05Z")

</div>

Hello together. I want to showcase some performance characteristics and slight problems with ‘homemade closures’. By that I mean some kind of struct that carries some data and has a call method in which this data is use…

---

## [Provide repl mode for my package](https://discourse.julialang.org/t/provide-repl-mode-for-my-package/108166)

<div class="topic-metadata">

**Author:** [@floswald](https://discourse.julialang.org/u/floswald)\
**Replies:** 2\
**Last updated:** [December 29, 2023, 9:15pm UTC](https://discourse.julialang.org/t/provide-repl-mode-for-my-package/108166 "2023-12-29T21:15:02Z")

</div>

I want to provide a REPL mode for my package. I’m looking for help to set it up. I’ve looked at RCall.jl but it’s too complicated for me to understand. Also Pkg.jl, there’s too much stuff for me to understand. here is wh…

---

## [Strategies for Parallelizing Long Tasks with Many Parts](https://discourse.julialang.org/t/strategies-for-parallelizing-long-tasks-with-many-parts/108162)

<div class="topic-metadata">

**Author:** [@mrufsvold](https://discourse.julialang.org/u/mrufsvold)\
**Replies:** 0\
**Last updated:** [December 29, 2023, 6:11pm UTC](https://discourse.julialang.org/t/strategies-for-parallelizing-long-tasks-with-many-parts/108162 "2023-12-29T18:11:40Z")

</div>

I have a pipeline that concatenates parquet tables from S3 and writes them back out at the end. It goes something like: Read in the metadata for a bunch of parquet files in a partition Get their RowGroups (the unit of …

---

## [Understanding LoadError: ArgumentError in Tables.jl interface](https://discourse.julialang.org/t/understanding-loaderror-argumenterror-in-tables-jl-interface/108159)

<div class="topic-metadata">

**Author:** [@WekawTirso](https://discourse.julialang.org/u/WekawTirso)\
**Replies:** 4\
**Last updated:** [December 29, 2023, 3:56pm UTC](https://discourse.julialang.org/t/understanding-loaderror-argumenterror-in-tables-jl-interface/108159 "2023-12-29T15:56:55Z")

</div>

I am trying to create and save simple array using either of the two methods: using CSV, DataFrames #Attempt 1 let N = 20 My\_Array = \[\] i = 0 for b=2:N-1 i += 1 summation = 0.0 f…

---

## [Are branches in Julia a problem for performance?](https://discourse.julialang.org/t/are-branches-in-julia-a-problem-for-performance/108062)

<div class="topic-metadata">

**Author:** [@KZiemian](https://discourse.julialang.org/u/KZiemian)\
**Replies:** 10\
**Last updated:** [December 29, 2023, 8:55am UTC](https://discourse.julialang.org/t/are-branches-in-julia-a-problem-for-performance/108062 "2023-12-29T08:55:14Z")

</div>

Due to how modern CPU and computer memory works, branching, like using if statement, can produce high cost for the performance and produce cache misses. At basic level I understand that, but I’m deficiently not expert in…

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

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