# General Usage

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

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

**Page:** 50

---

## [DifferentiationInterface+ForwardDiff unable to diff ldiv! (any other options to solve linear system w/o allocations and differentiate?)](https://discourse.julialang.org/t/differentiationinterface-forwarddiff-unable-to-diff-ldiv-any-other-options-to-solve-linear-system-w-o-allocations-and-differentiate/131076)

<div class="topic-metadata">

**Author:** [@r0uv3n](https://discourse.julialang.org/u/r0uv3n)\
**Replies:** 34\
**Last updated:** [July 28, 2025, 4:30pm UTC](https://discourse.julialang.org/t/differentiationinterface-forwarddiff-unable-to-diff-ldiv-any-other-options-to-solve-linear-system-w-o-allocations-and-differentiate/131076 "2025-07-28T16:30:11Z")

</div>

I have a function where both a matrix g as well as a vector q depend on some vector input p. On the way I need to solve for g^{-1} q. I want to use DifferentiationInterface+AutoForwardDiff to take derivatives of this fu…

---

## [Avoid allocations in one-dimensional Optim when target expects vector](https://discourse.julialang.org/t/avoid-allocations-in-one-dimensional-optim-when-target-expects-vector/131159)

<div class="topic-metadata">

**Author:** [@JADekker](https://discourse.julialang.org/u/JADekker)\
**Replies:** 5\
**Last updated:** [July 29, 2025, 8:48am UTC](https://discourse.julialang.org/t/avoid-allocations-in-one-dimensional-optim-when-target-expects-vector/131159 "2025-07-29T08:48:35Z")

</div>

Hi, I’m in an optimization situation where I have an objective function that expects a vector input, but the optimization problem is over just one variable, so I’d like to use Brent’s algorithm. To make it compatible wit…

---

## [Semantically equivalent expressions with wildly different performance](https://discourse.julialang.org/t/semantically-equivalent-expressions-with-wildly-different-performance/131123)

<div class="topic-metadata">

**Author:** [@bremez](https://discourse.julialang.org/u/bremez)\
**Replies:** 10\
**Last updated:** [July 28, 2025, 2:54pm UTC](https://discourse.julialang.org/t/semantically-equivalent-expressions-with-wildly-different-performance/131123 "2025-07-28T14:54:10Z")

</div>

I came across the following example when I needed something that beats the performance of LinearAlgebra’s build in mul!(M, x, y'). Any known reason for this huge difference in performance? Tested on 11.6. using Benchmar…

---

## [How to use OhMyREPL's FZF history search with NixOS](https://discourse.julialang.org/t/how-to-use-ohmyrepls-fzf-history-search-with-nixos/131150)

<div class="topic-metadata">

**Author:** [@torgo](https://discourse.julialang.org/u/torgo)\
**Replies:** 4\
**Last updated:** [July 29, 2025, 7:18am UTC](https://discourse.julialang.org/t/how-to-use-ohmyrepls-fzf-history-search-with-nixos/131150 "2025-07-29T07:18:55Z")

</div>

I’m trying to use OhMyREPL’s fuzzy history search, which uses fzf. I am on NixOS and I have the fzf binary available, but I think OMR tries to use it’s own fzf which is not something that NixOS can run. When I try Ctrl+R…

---

## [Strange data race problems in multi-threaded code (a possible solution)](https://discourse.julialang.org/t/strange-data-race-problems-in-multi-threaded-code-a-possible-solution/130772)

<div class="topic-metadata">

**Author:** [@jsjie](https://discourse.julialang.org/u/jsjie)\
**Replies:** 15\
**Last updated:** [July 29, 2025, 1:51am UTC](https://discourse.julialang.org/t/strange-data-race-problems-in-multi-threaded-code-a-possible-solution/130772 "2025-07-29T01:51:46Z")

</div>

The actual code that runs into problem is like the following: s = mol.max\_buf\_size Threads.@threads for ijkl = 1 : nbas^4 t1, l = divrem(ijkl-1, nbas) t2, k = divrem(t1, nbas) i, j = divrem(t2, nbas) she…

---

## [Help optimizing my generic sigma clipping function in Julia](https://discourse.julialang.org/t/help-optimizing-my-generic-sigma-clipping-function-in-julia/131132)

<div class="topic-metadata">

**Author:** [@Matt\_jl](https://discourse.julialang.org/u/Matt_jl)\
**Replies:** 2\
**Last updated:** [July 28, 2025, 5:36pm UTC](https://discourse.julialang.org/t/help-optimizing-my-generic-sigma-clipping-function-in-julia/131132 "2025-07-28T17:36:14Z")

</div>

Hi everyone, I’m working on a small personal project and wrote this sigma clipping function in Julia. It works fine so far, but I’m definitely not an expert and I feel like it could be way more efficient — especially to…

---

## [RequestError: schannel: failed to open CA file 'C:\\ProgramDatanaconda3\_2024\_10\_1\\Library\\ssl': Unknown error 123 (0x0000007B](https://discourse.julialang.org/t/requesterror-schannel-failed-to-open-ca-file-c-programdatanaconda3-2024-10-1-library-ssl-unknown-error-123-0x0000007b/131130)

<div class="topic-metadata">

**Author:** [@dk-zen](https://discourse.julialang.org/u/dk-zen)\
**Replies:** 3\
**Last updated:** [July 28, 2025, 1:59pm UTC](https://discourse.julialang.org/t/requesterror-schannel-failed-to-open-ca-file-c-programdatanaconda3-2024-10-1-library-ssl-unknown-error-123-0x0000007b/131130 "2025-07-28T13:59:30Z")

</div>

When I updated the Julia library, I encountered an error. However, it was working fine before. Has anyone encountered such a problem? julia\> versioninfo() Julia Version 1.10.4 Commit 48d4fd4843 (2024-06-04 10:41 UTC) Bu…

---

## [Understanding typing rules](https://discourse.julialang.org/t/understanding-typing-rules/131087)

<div class="topic-metadata">

**Author:** [@benc](https://discourse.julialang.org/u/benc)\
**Replies:** 4\
**Last updated:** [July 28, 2025, 8:11am UTC](https://discourse.julialang.org/t/understanding-typing-rules/131087 "2025-07-28T08:11:32Z")

</div>

Hi, In the following expression using StaticArrays using Random Random.seed(42) a = SVector{2, Float64}(1.0, 2) b = a + rand(2) I was initially (incorrectly) expecting that b’s type would be SVector{2, Float64}. In…

---

## [Showing a BitVector in NamedTuple](https://discourse.julialang.org/t/showing-a-bitvector-in-namedtuple/131048)

<div class="topic-metadata">

**Author:** [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Replies:** 17\
**Last updated:** [July 28, 2025, 5:37am UTC](https://discourse.julialang.org/t/showing-a-bitvector-in-namedtuple/131048 "2025-07-28T05:37:26Z")

</div>

I find a bit of inconsistency, probably about showing a NamedTuple julia\> v = \[1, 0, 1.\]; julia\> nt = (bitvec = Bool.(v),) # the following output is not accurate (bitvec = Bool\[1, 0, 1\],) julia\> nt.bitvec 3-element Bi…

---

## [Understanding dispatch through TypeVar](https://discourse.julialang.org/t/understanding-dispatch-through-typevar/131091)

<div class="topic-metadata">

**Author:** [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)\
**Replies:** 4\
**Last updated:** [July 27, 2025, 8:53pm UTC](https://discourse.julialang.org/t/understanding-dispatch-through-typevar/131091 "2025-07-27T20:53:44Z")

</div>

I’m trying to understand how dispatch happens through TypeVars related to some debugging of Mooncake.jl internals. For example: julia\> foo(::Type{\<:Array{T,N}}) where {T,N} = N foo (generic function with 1 method) juli…

---

## [Pkg: private repository usage and keys](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575)

<div class="topic-metadata">

**Author:** [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Replies:** 35\
**Last updated:** [July 27, 2025, 8:37pm UTC](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575 "2025-07-27T20:37:47Z")

</div>

I have several dependencies from a private repository and I’m trying to figure out how to add them. Following another thread here on discourse, it seems I should add the leaf dependencies first and work my way up. Firs…

---

## [Function fails when used in precompile workload](https://discourse.julialang.org/t/function-fails-when-used-in-precompile-workload/131095)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 7\
**Last updated:** [July 27, 2025, 5:55pm UTC](https://discourse.julialang.org/t/function-fails-when-used-in-precompile-workload/131095 "2025-07-27T17:55:35Z")

</div>

I have the following function: function str2type(name) typename = Symbol(name) t = getfield(Main, typename) instance = t() end I need it to get an instance of a type of a marker struct at runtime based on s…

---

## [How to fix SSL cert issues in Pkg](https://discourse.julialang.org/t/how-to-fix-ssl-cert-issues-in-pkg/115495)

<div class="topic-metadata">

**Author:** [@musm](https://discourse.julialang.org/u/musm)\
**Replies:** 9\
**Last updated:** [July 27, 2025, 4:52pm UTC](https://discourse.julialang.org/t/how-to-fix-ssl-cert-issues-in-pkg/115495 "2025-07-27T16:52:39Z")

</div>

It seems like there is a clash between the SSL environment variable set by miniconda and the one that Julia is using. I’ve tried setting JULIA\_SSL\_CA\_ROOTS\_PATH="" as suggested however the error persists. ❯ $env:SSL\_C…

---

## [Using BinaryBuilder.jl to build librariers for Julia versions \>1.7](https://discourse.julialang.org/t/using-binarybuilder-jl-to-build-librariers-for-julia-versions-1-7/131085)

<div class="topic-metadata">

**Author:** [@leespen1](https://discourse.julialang.org/u/leespen1)\
**Replies:** 5\
**Last updated:** [July 27, 2025, 4:15pm UTC](https://discourse.julialang.org/t/using-binarybuilder-jl-to-build-librariers-for-julia-versions-1-7/131085 "2025-07-27T16:15:21Z")

</div>

I have some small Fortran scripts that I use in a Julia package I am developing. Currently, I have just compiled them myself into a shared library and used ccall. But I want my package to be deployable on other people’s …

---

## [Pkg.activate vs Base.set\_active\_project](https://discourse.julialang.org/t/pkg-activate-vs-base-set-active-project/131111)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 0\
**Last updated:** [July 27, 2025, 3:59pm UTC](https://discourse.julialang.org/t/pkg-activate-vs-base-set-active-project/131111 "2025-07-27T15:59:14Z")

</div>

Can someone please explain the difference between Pkg.activate vs Base.set\_active\_project from a practical perspective? I looked at the source and they do slightly different things (besides setting Base.ACTIVE\_PROJECT\[\])…

---

## [Zip with length checking](https://discourse.julialang.org/t/zip-with-length-checking/16395)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 7\
**Last updated:** [July 27, 2025, 2:44pm UTC](https://discourse.julialang.org/t/zip-with-length-checking/16395 "2025-07-27T14:44:35Z")

</div>

Consider a loop for (i, elt) in zip(indexes, itr) do\_something(i, elt) end where Base.IteratorSize(itr) can potentially be Base.HasLength() or Base.SizeUnknown(). I want the code to work for both. indexes is an Ab…

---

## [Code coverage on Github not displayed](https://discourse.julialang.org/t/code-coverage-on-github-not-displayed/131083)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 2\
**Last updated:** [July 27, 2025, 12:42pm UTC](https://discourse.julialang.org/t/code-coverage-on-github-not-displayed/131083 "2025-07-27T12:42:34Z")

</div>

Until this morning, code coverage for my package GitHub - ufechner7/FLORIDyn.jl: Dynamic wind farm simulation software was displayed fine. Now it says “codecov unknown”. What could be the reason? The tests look fine, fo…

---

## [How to plot a impulse unit function using Plots.jl and SymPy.jl?](https://discourse.julialang.org/t/how-to-plot-a-impulse-unit-function-using-plots-jl-and-sympy-jl/131066)

<div class="topic-metadata">

**Author:** [@jcbritobr](https://discourse.julialang.org/u/jcbritobr)\
**Replies:** 6\
**Last updated:** [July 27, 2025, 10:15am UTC](https://discourse.julialang.org/t/how-to-plot-a-impulse-unit-function-using-plots-jl-and-sympy-jl/131066 "2025-07-27T10:15:54Z")

</div>

Hello. Good evening. I’m doing all exercises of the Sadiku’s book in julia programming. The code is in github Im stucked to plot the impulse unit function after get it differentiating the unit step function. The p…

---

## [Broadcasting over an array of custom struct gives type instability](https://discourse.julialang.org/t/broadcasting-over-an-array-of-custom-struct-gives-type-instability/131086)

<div class="topic-metadata">

**Author:** [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)\
**Replies:** 5\
**Last updated:** [July 27, 2025, 9:02am UTC](https://discourse.julialang.org/t/broadcasting-over-an-array-of-custom-struct-gives-type-instability/131086 "2025-07-27T09:02:52Z")

</div>

Hello, I have a simple problem in Julia v1.10 using Test struct MyMatrix{MT\<:AbstractMatrix} M::MT end Base.:(\*)(A::MyMatrix, x::Number) = MyMatrix(A.M \* x) function f(x) # return \[y / 10 for y in x\] ret…

---

## [Optimizing performance](https://discourse.julialang.org/t/optimizing-performance/131065)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 33\
**Last updated:** [July 26, 2025, 5:54pm UTC](https://discourse.julialang.org/t/optimizing-performance/131065 "2025-07-26T17:54:00Z")

</div>

I try to optimize the performance of the following function: function iterateOPs!(::IterateOPs\_basic, wf::WindFarm, sim::Sim, floris::Floris, floridyn::FloriDyn) # Save turbine OPs tmpOPStates = copy(wf.States\_O…

---

## [Can I try updating LoopVectorization?](https://discourse.julialang.org/t/can-i-try-updating-loopvectorization/125064)

<div class="topic-metadata">

**Author:** [@Tarny\_GG\_Channie](https://discourse.julialang.org/u/Tarny_GG_Channie)\
**Replies:** 5\
**Last updated:** [July 26, 2025, 6:45am UTC](https://discourse.julialang.org/t/can-i-try-updating-loopvectorization/125064 "2025-07-26T06:45:27Z")

</div>

After contributing to Stockfish (and failing, though having good runs), I’m back to Julia. LoopVectorization seems to be deprecated for Julia 1.12. There is a bounty to fix it. I’m probing whether or not I can do the…

---

## [TTSX: Recompilation on every run](https://discourse.julialang.org/t/ttsx-recompilation-on-every-run/131003)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 9\
**Last updated:** [July 25, 2025, 12:11pm UTC](https://discourse.julialang.org/t/ttsx-recompilation-on-every-run/131003 "2025-07-25T12:11:20Z")

</div>

Colleagues and I are developing Muscade.jl. Muscade is deliberately putting a high workload on the Julia 1.11 compiler. I have done nothing with module precompilation so far. Thus I have a significant TTFX, but this i…

---

## [Why does it always recompile a package?](https://discourse.julialang.org/t/why-does-it-always-recompile-a-package/131037)

<div class="topic-metadata">

**Author:** [@Kirby\_Zhang](https://discourse.julialang.org/u/Kirby_Zhang)\
**Replies:** 2\
**Last updated:** [July 25, 2025, 1:11am UTC](https://discourse.julialang.org/t/why-does-it-always-recompile-a-package/131037 "2025-07-25T01:11:50Z")

</div>

I have a locally developed package Inherit.jl. It has a \_\_precompile\_\_(true) statement. When I open the package project, importing it does not show any compilation time: K:\\DevDocuments\\fourthwave\\pkg\\Inherit\>more Mani…

---

## [How to properly nest parametrically typed structs while using @kwdef](https://discourse.julialang.org/t/how-to-properly-nest-parametrically-typed-structs-while-using-kwdef/131036)

<div class="topic-metadata">

**Author:** [@askprash](https://discourse.julialang.org/u/askprash)\
**Replies:** 0\
**Last updated:** [July 24, 2025, 11:29pm UTC](https://discourse.julialang.org/t/how-to-properly-nest-parametrically-typed-structs-while-using-kwdef/131036 "2025-07-24T23:29:59Z")

</div>

How to use @kwdef with parametric structs and default constructors? I’m trying to understand how to best use @kwdef with parametric structs in Julia, particularly when I want to define some default constructors and have …

---

## [Getting Graphical Output from Catlab.jl](https://discourse.julialang.org/t/getting-graphical-output-from-catlab-jl/131014)

<div class="topic-metadata">

**Author:** [@rogms223](https://discourse.julialang.org/u/rogms223)\
**Replies:** 3\
**Last updated:** [July 24, 2025, 9:53pm UTC](https://discourse.julialang.org/t/getting-graphical-output-from-catlab-jl/131014 "2025-07-24T21:53:40Z")

</div>

:::::::::::::: Project.toml :::::::::::::: \[deps\] Catlab = “134e5e36-593f-5add-ad60-77f754baafbe” GATlab = “f0ffcf3b-d13a-433e-917c-cc44ccf5ead2” can supply Manifest.toml if of interest running snippet below from…

---

## [Why is accessing an SMatrix from a struct allocating?](https://discourse.julialang.org/t/why-is-accessing-an-smatrix-from-a-struct-allocating/131016)

<div class="topic-metadata">

**Author:** [@r0uv3n](https://discourse.julialang.org/u/r0uv3n)\
**Replies:** 4\
**Last updated:** [July 24, 2025, 7:04pm UTC](https://discourse.julialang.org/t/why-is-accessing-an-smatrix-from-a-struct-allocating/131016 "2025-07-24T19:04:08Z")

</div>

Considering the following simple MWE: using StaticArrays, BenchmarkTools struct SomeStruct matrix::SMatrix{3,3,Float64} end function testing\_allocation(g::MMatrix{3,3,Float64}, struct\_matrix::SomeStruct) fill!(g,…

---

## [Difference between dates, in years](https://discourse.julialang.org/t/difference-between-dates-in-years/130997)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 3\
**Last updated:** [July 24, 2025, 4:00pm UTC](https://discourse.julialang.org/t/difference-between-dates-in-years/130997 "2025-07-24T16:00:28Z")

</div>

The difference between Dates.Date returns a Day object. I want to get that number of days “in years”. I’ve been doing stuff like this d/Day(1)/365.25, but repeatedly typing number literals is so ripe for a typo, let alon…

---

## [Threads with Channels sometimes lead to weird code excecution](https://discourse.julialang.org/t/threads-with-channels-sometimes-lead-to-weird-code-excecution/130975)

<div class="topic-metadata">

**Author:** [@ncxst](https://discourse.julialang.org/u/ncxst)\
**Replies:** 11\
**Last updated:** [July 24, 2025, 12:23pm UTC](https://discourse.julialang.org/t/threads-with-channels-sometimes-lead-to-weird-code-excecution/130975 "2025-07-24T12:23:14Z")

</div>

Background story I had the problem, that I wanted to generate a certain object from random seeds, which only with a very low probability gives me the result I want. Too speed the calculation up I wanted to parallelize th…

---

## [Export enum](https://discourse.julialang.org/t/export-enum/5396)

<div class="topic-metadata">

**Author:** [@babaq](https://discourse.julialang.org/u/babaq)\
**Replies:** 5\
**Last updated:** [July 23, 2025, 2:06pm UTC](https://discourse.julialang.org/t/export-enum/5396 "2025-07-23T14:06:35Z")

</div>

Hi I am defining an enum such as @enum myenum enumname1 enumname2 in a module using Julia 0.6. it seems I have to explicitly export both enum type name(myenum) and enum elements(enumname1,enumname2). I know this way is …

---

## [ReentrantLock: generate once, or every time before \`for\`](https://discourse.julialang.org/t/reentrantlock-generate-once-or-every-time-before-for/130965)

<div class="topic-metadata">

**Author:** [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Replies:** 3\
**Last updated:** [July 23, 2025, 1:24pm UTC](https://discourse.julialang.org/t/reentrantlock-generate-once-or-every-time-before-for/130965 "2025-07-23T13:24:38Z")

</div>

I learnt about ReentrantLock in JuMP’s doc. function a\_correct\_way\_to\_build\_with\_multithreading() model = Model() @variable(model, x\[1:10\]) my\_lock = Threads.ReentrantLock() T…

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

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