# General Usage

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

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

**Page:** 267

---

## [At what stage of package development do you write docstrings?](https://discourse.julialang.org/t/at-what-stage-of-package-development-do-you-write-docstrings/101816)

<div class="topic-metadata">

**Author:** [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Replies:** 11\
**Last updated:** [July 21, 2023, 3:20am UTC](https://discourse.julialang.org/t/at-what-stage-of-package-development-do-you-write-docstrings/101816 "2023-07-21T03:20:46Z")

</div>

When I develop a package, I eventually write docstrings of functions so that the users can find the meanings and usages of the functions easily by help?\>. However, I wait until the package gets matured, because I tend t…

---

## [Adding set of equations in ModelingToolkit](https://discourse.julialang.org/t/adding-set-of-equations-in-modelingtoolkit/100019)

<div class="topic-metadata">

**Author:** [@Ethan\_Tran](https://discourse.julialang.org/u/Ethan_Tran)\
**Replies:** 1\
**Last updated:** [June 7, 2023, 7:55pm UTC](https://discourse.julialang.org/t/adding-set-of-equations-in-modelingtoolkit/100019 "2023-06-07T19:55:05Z")

</div>

I have several sets of differential equations, and to reduce the time of implementation I try to implement each set of equations by for loop as below (just for example): @variable (x(t))\[1:n\] (y(t))\[1:n\] eq1 = \[0 ~ D(x\[…

---

## [Advice for wrapping c++ library that throws exceptions?](https://discourse.julialang.org/t/advice-for-wrapping-c-library-that-throws-exceptions/101855)

<div class="topic-metadata">

**Author:** [@frylock](https://discourse.julialang.org/u/frylock)\
**Replies:** 0\
**Last updated:** [July 20, 2023, 9:27pm UTC](https://discourse.julialang.org/t/advice-for-wrapping-c-library-that-throws-exceptions/101855 "2023-07-20T21:27:11Z")

</div>

I have a vendor library that throws exceptions, which makes wrapping them a bit more miserable. I only have access to headers and shared libraries, and I couldn’t figure out a way to link the libraries and prevent except…

---

## [How does julia downscale from 16 bit to 8 bit?](https://discourse.julialang.org/t/how-does-julia-downscale-from-16-bit-to-8-bit/101838)

<div class="topic-metadata">

**Author:** [@JmsChf](https://discourse.julialang.org/u/JmsChf)\
**Replies:** 2\
**Last updated:** [July 20, 2023, 8:30pm UTC](https://discourse.julialang.org/t/how-does-julia-downscale-from-16-bit-to-8-bit/101838 "2023-07-20T20:30:20Z")

</div>

I am attempting to revamp an old script that I found that converts a TIF format 16 bit image into a 8 bit JPG format image. I was wondering how Julia handles the downscaling of 16 bit images. It seems like this code is r…

---

## [Multithreaded program hangs without explict GC.gc()](https://discourse.julialang.org/t/multithreaded-program-hangs-without-explict-gc-gc/99452)

<div class="topic-metadata">

**Author:** [@hayk](https://discourse.julialang.org/u/hayk)\
**Replies:** 6\
**Last updated:** [July 20, 2023, 7:35pm UTC](https://discourse.julialang.org/t/multithreaded-program-hangs-without-explict-gc-gc/99452 "2023-07-20T19:35:54Z")

</div>

I have the following code that uses Julia’s atomic variables and hangs if I do not use gc. I run the program with julia -t 6. I set two atomic variables to false, then spawn two threads that wait in a while loop for the…

---

## [Modified the neural network to capture nonlinear system](https://discourse.julialang.org/t/modified-the-neural-network-to-capture-nonlinear-system/101789)

<div class="topic-metadata">

**Author:** [@Ethan\_Tran](https://discourse.julialang.org/u/Ethan_Tran)\
**Replies:** 4\
**Last updated:** [July 20, 2023, 7:07pm UTC](https://discourse.julialang.org/t/modified-the-neural-network-to-capture-nonlinear-system/101789 "2023-07-20T19:07:52Z")

</div>

I tried to use NeuralPDE to solve ODE problem and my code is below: domains = \[t ∈ Interval(0.0,25.0)\] chain =\[Lux.Chain(Dense(1,10,Lux.tanh),Dense(10,20,Lux.tanh),Dense(20,10,Lux.tanh),Dense(10,1)) for \_ in 1:12\] dv…

---

## [Composing Lux with Optim Algorithms](https://discourse.julialang.org/t/composing-lux-with-optim-algorithms/101846)

<div class="topic-metadata">

**Author:** [@George\_Stepaniants](https://discourse.julialang.org/u/George_Stepaniants)\
**Replies:** 3\
**Last updated:** [July 20, 2023, 7:05pm UTC](https://discourse.julialang.org/t/composing-lux-with-optim-algorithms/101846 "2023-07-20T19:05:27Z")

</div>

Is there a way to use optimization algorithms from Optim to train Lux neural networks and neural ODEs? In particular, I would like to use LBFGS to train a Lux neural network but don’t see a simple way to do this. There i…

---

## [Zero allocation: tuple subsetting?](https://discourse.julialang.org/t/zero-allocation-tuple-subsetting/23122)

<div class="topic-metadata">

**Author:** [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Replies:** 9\
**Last updated:** [July 20, 2023, 6:42pm UTC](https://discourse.julialang.org/t/zero-allocation-tuple-subsetting/23122 "2023-07-20T18:42:56Z")

</div>

The following function allocates: function h() tup = (:a,:b,:c) return (getfield(tup, 1), getfield(tup, 3)) end; See: julia\> @btime h() 6.637 ns (1 allocation: 32 bytes) (:a, :c) I can’t workout how to m…

---

## [Push! vs. pushfirst! performance issue with BitArrays](https://discourse.julialang.org/t/push-vs-pushfirst-performance-issue-with-bitarrays/101845)

<div class="topic-metadata">

**Author:** [@tradler](https://discourse.julialang.org/u/tradler)\
**Replies:** 1\
**Last updated:** [July 20, 2023, 5:28pm UTC](https://discourse.julialang.org/t/push-vs-pushfirst-performance-issue-with-bitarrays/101845 "2023-07-20T17:28:12Z")

</div>

push! seems to have equal speed as pushfirst! for non-bit vectors. In addition, for bit and non-bit vectors push! is equally fast. For bit and non-bit vectors pushfirst! is ~10Kx slower. Does this seem like an issue, or …

---

## [\`@fastmath\` is not applied to macros](https://discourse.julialang.org/t/fastmath-is-not-applied-to-macros/101835)

<div class="topic-metadata">

**Author:** [@Keluaa](https://discourse.julialang.org/u/Keluaa)\
**Replies:** 5\
**Last updated:** [July 20, 2023, 4:21pm UTC](https://discourse.julialang.org/t/fastmath-is-not-applied-to-macros/101835 "2023-07-20T16:21:30Z")

</div>

Today I discovered that @fastmath is not applied to inlined function calls (maybe this should be in the docs?), I understand that there is a good reason behind it. However I would have expected this to work on expressio…

---

## [What are most used packages in Julia ecosystem, e.g. DataStructures and StaticArrays? And most used parts of them?](https://discourse.julialang.org/t/what-are-most-used-packages-in-julia-ecosystem-e-g-datastructures-and-staticarrays-and-most-used-parts-of-them/101787)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 1\
**Last updated:** [July 20, 2023, 3:52pm UTC](https://discourse.julialang.org/t/what-are-most-used-packages-in-julia-ecosystem-e-g-datastructures-and-staticarrays-and-most-used-parts-of-them/101787 "2023-07-20T15:52:29Z")

</div>

Can I easily with some script find out the most used packages in the Julia package ecosystem? Or anyone have a good guess? Anyway I want to comment on those two very important and much used ones. I was optimizing a star…

---

## [Good template for defining a custom type with an addition method](https://discourse.julialang.org/t/good-template-for-defining-a-custom-type-with-an-addition-method/101725)

<div class="topic-metadata">

**Author:** [@pierre-haessig](https://discourse.julialang.org/u/pierre-haessig)\
**Replies:** 5\
**Last updated:** [July 20, 2023, 3:22pm UTC](https://discourse.julialang.org/t/good-template-for-defining-a-custom-type-with-an-addition-method/101725 "2023-07-20T15:22:53Z")

</div>

Hello, I’m implementing for the first time a custom type with a custom addition method (i.e. the + operator). Unless I missed something in the manual, I didn’t find a paragraph focused on the topic. After several itera…

---

## [How to keep u\>0 when solving ODEs](https://discourse.julialang.org/t/how-to-keep-u-0-when-solving-odes/101824)

<div class="topic-metadata">

**Author:** [@liao2877104858](https://discourse.julialang.org/u/liao2877104858)\
**Replies:** 2\
**Last updated:** [July 20, 2023, 3:02pm UTC](https://discourse.julialang.org/t/how-to-keep-u-0-when-solving-odes/101824 "2023-07-20T15:02:10Z")

</div>

I’m using Rodas3() to solve a stiff ODEs in Julia. du/dt = F(u). The Analytical expression of u should be positive. However, when I use julia to solve the ODE, u may be less equal 0. I suspect that the time step was too …

---

## [Reinterpret array into SMatrices of different sizes for Interpolations. Julia v0.6 vs now](https://discourse.julialang.org/t/reinterpret-array-into-smatrices-of-different-sizes-for-interpolations-julia-v0-6-vs-now/101827)

<div class="topic-metadata">

**Author:** [@floswald](https://discourse.julialang.org/u/floswald)\
**Replies:** 6\
**Last updated:** [July 20, 2023, 2:32pm UTC](https://discourse.julialang.org/t/reinterpret-array-into-smatrices-of-different-sizes-for-interpolations-julia-v0-6-vs-now/101827 "2023-07-20T14:32:02Z")

</div>

Hi all, I’m trying to check whether my approach to translation something that used to work in previous julia versions is the best way to go. I have the following use case. I have values stored in a 4-dimensional array y…

---

## [Getter function naming: Consider avoiding nouns](https://discourse.julialang.org/t/getter-function-naming-consider-avoiding-nouns/101832)

<div class="topic-metadata">

**Author:** [@stemann](https://discourse.julialang.org/u/stemann)\
**Replies:** 2\
**Last updated:** [July 20, 2023, 12:53pm UTC](https://discourse.julialang.org/t/getter-function-naming-consider-avoiding-nouns/101832 "2023-07-20T12:53:37Z")

</div>

I am (heavily) considering judging using nouns for (exported) getter accessor functions bad practice. I’ve found myself writing structs with getter accessors named equal to the names of the fields they are getting, i.e.…

---

## [Permutedims not working on DataFrame](https://discourse.julialang.org/t/permutedims-not-working-on-dataframe/100053)

<div class="topic-metadata">

**Author:** [@mfariacastro](https://discourse.julialang.org/u/mfariacastro)\
**Replies:** 7\
**Last updated:** [July 20, 2023, 10:22am UTC](https://discourse.julialang.org/t/permutedims-not-working-on-dataframe/100053 "2023-07-20T10:22:50Z")

</div>

Hi all, I am trying to transpose a DataFrame, following what is explained here: Functions · DataFrames.jl When applying the ‘permutedims’ function, I get an error that says that this function cannot take a DataFrame as…

---

## [Using ODE solution in NEURAL ODE](https://discourse.julialang.org/t/using-ode-solution-in-neural-ode/101788)

<div class="topic-metadata">

**Author:** [@Marco\_Nesta](https://discourse.julialang.org/u/Marco_Nesta)\
**Replies:** 6\
**Last updated:** [July 20, 2023, 9:47am UTC](https://discourse.julialang.org/t/using-ode-solution-in-neural-ode/101788 "2023-07-20T09:47:39Z")

</div>

using ComponentArrays, Lux, DiffEqFlux, DifferentialEquations, Optimization, OptimizationOptimJL, Random, Plots,OptimizationOptimisers rng = Random.default\_rng() ## Setup ODE to optimize u0 = Float32\[1.0 ; 1.0\] tspan = (…

---

## [GLMakie fails to Precompile even if I Have GLFW: GLFW couldn't create an OpenGL Window](https://discourse.julialang.org/t/glmakie-fails-to-precompile-even-if-i-have-glfw-glfw-couldnt-create-an-opengl-window/101826)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 0\
**Last updated:** [July 20, 2023, 9:22am UTC](https://discourse.julialang.org/t/glmakie-fails-to-precompile-even-if-i-have-glfw-glfw-couldnt-create-an-opengl-window/101826 "2023-07-20T09:22:43Z")

</div>

I try to use GLMakie but failed: GLFW couldn’t create an OpenGL Window. I already have GLFW and OpenGL by checking through glxinfo -B I hope I can get this solved. Thanks.

---

## [Multithreading using more CPUs than expected](https://discourse.julialang.org/t/multithreading-using-more-cpus-than-expected/101599)

<div class="topic-metadata">

**Author:** [@lzxnl](https://discourse.julialang.org/u/lzxnl)\
**Replies:** 11\
**Last updated:** [July 20, 2023, 5:10am UTC](https://discourse.julialang.org/t/multithreading-using-more-cpus-than-expected/101599 "2023-07-20T05:10:57Z")

</div>

I opened a Jupyter Notebook kernel with 25 threads (threadid() prints out 25 in the beginning). I then proceed to run some code that manages to use 8900% CPU, as recorded by top on the terminal, i.e. 89 threads worth of …

---

## [Request minimum rank in LowRankApprox.jl?](https://discourse.julialang.org/t/request-minimum-rank-in-lowrankapprox-jl/99191)

<div class="topic-metadata">

**Author:** [@miles](https://discourse.julialang.org/u/miles)\
**Replies:** 3\
**Last updated:** [July 20, 2023, 2:50am UTC](https://discourse.julialang.org/t/request-minimum-rank-in-lowrankapprox-jl/99191 "2023-07-20T02:50:35Z")

</div>

I’m using the id method (interpolative decomposition or ID) from the LowRankApprox.jl package. In the algorithm I’m trying to program (a variant of the “tensor cross interpolation”, reviewed in depth in this article whic…

---

## [Code\_errortype: Error if code\_warntype shows red](https://discourse.julialang.org/t/code-errortype-error-if-code-warntype-shows-red/101809)

<div class="topic-metadata">

**Author:** [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Replies:** 1\
**Last updated:** [July 19, 2023, 11:27pm UTC](https://discourse.julialang.org/t/code-errortype-error-if-code-warntype-shows-red/101809 "2023-07-19T23:27:38Z")

</div>

I was thinking about the Appendix with JET.jl of the Rust vs Julia in scientific computing blog, and I started wondering if we could create a code\_errortype or @code\_errortype that errors if @code\_warntype would display …

---

## [Calculating the 3d volume between arbitrary planes](https://discourse.julialang.org/t/calculating-the-3d-volume-between-arbitrary-planes/101793)

<div class="topic-metadata">

**Author:** [@Gavin\_Held](https://discourse.julialang.org/u/Gavin_Held)\
**Replies:** 8\
**Last updated:** [July 19, 2023, 8:39pm UTC](https://discourse.julialang.org/t/calculating-the-3d-volume-between-arbitrary-planes/101793 "2023-07-19T20:39:10Z")

</div>

Hello, So I am trying to find an efficient way to calculate the volume between planes (e.g. the ones in the image). The planes are not parallel with one another, and I have not found any resources online that have be…

---

## [How to iterate in a thread safe way?](https://discourse.julialang.org/t/how-to-iterate-in-a-thread-safe-way/101727)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 18\
**Last updated:** [July 19, 2023, 8:33pm UTC](https://discourse.julialang.org/t/how-to-iterate-in-a-thread-safe-way/101727 "2023-07-19T20:33:55Z")

</div>

I have the following code: λ\_noms = sort(unique(vcat(7:0.1:9.5, 7.8:0.02:8.2, 7.98:0.005:8.02))) rel\_sigmas = zeros(length(λ\_noms)) i = 1 Threads.@threads for λ\_nom in λ\_noms println("lambda\_nom: $λ\_nom") rel\_si…

---

## [Automatically Update WebApp Components like Plots with Genie/Stipple](https://discourse.julialang.org/t/automatically-update-webapp-components-like-plots-with-genie-stipple/77725)

<div class="topic-metadata">

**Author:** [@stakaz](https://discourse.julialang.org/u/stakaz)\
**Replies:** 1\
**Last updated:** [July 19, 2023, 7:51pm UTC](https://discourse.julialang.org/t/automatically-update-webapp-components-like-plots-with-genie-stipple/77725 "2023-07-19T19:51:19Z")

</div>

Hello, I would like to know if there is a generic way of automatically update e.g. plots or other elements on the webpage created with stippleUI without explicit triggering some buttons or sliders. I would like to run a…

---

## [Remove allocations from splatting?](https://discourse.julialang.org/t/remove-allocations-from-splatting/101749)

<div class="topic-metadata">

**Author:** [@mihalybaci](https://discourse.julialang.org/u/mihalybaci)\
**Replies:** 18\
**Last updated:** [July 19, 2023, 5:36pm UTC](https://discourse.julialang.org/t/remove-allocations-from-splatting/101749 "2023-07-19T17:36:03Z")

</div>

I have a simple function and cannot figure out where allocations happening. using BenchmarkTools p2s(x, y) = (360.0 + x) % 360, (360.0 + y) % 360.0 # 0 allocations function p2s!(p::T, s::T) where T \<: VecOrMat …

---

## [How to examine a pointer address?](https://discourse.julialang.org/t/how-to-examine-a-pointer-address/101791)

<div class="topic-metadata">

**Author:** [@frylock](https://discourse.julialang.org/u/frylock)\
**Replies:** 2\
**Last updated:** [July 19, 2023, 5:11pm UTC](https://discourse.julialang.org/t/how-to-examine-a-pointer-address/101791 "2023-07-19T17:11:29Z")

</div>

I am wrapping a library that returns an opaque structure. The call that gives me my result looks like: z = @ccall mylib.returns\_opaque()::Ptr{Cvoid} If the structure is properly initialized, it will be nonzero (i.e. n…

---

## [Get info about variables and functions in REPL](https://discourse.julialang.org/t/get-info-about-variables-and-functions-in-repl/101790)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 0\
**Last updated:** [July 19, 2023, 4:25pm UTC](https://discourse.julialang.org/t/get-info-about-variables-and-functions-in-repl/101790 "2023-07-19T16:25:07Z")

</div>

I know that there is the function varinfo(). But how can I get only a list of: global variables global constants global structs global enums global functions and not a mix of everything?

---

## [Interrupts in @async code](https://discourse.julialang.org/t/interrupts-in-async-code/95837)

<div class="topic-metadata">

**Author:** [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Replies:** 20\
**Last updated:** [July 19, 2023, 4:16pm UTC](https://discourse.julialang.org/t/interrupts-in-async-code/95837 "2023-07-19T16:16:08Z")

</div>

I’m trying to wrap my head around how Julia handles interrupts in @async code. I have three different scripts that I’m trying to interrupt using ctrl+c, with various degrees of success. Script1: julia\> @async begin …

---

## [PyCall build fails during Conda installation on Win 11](https://discourse.julialang.org/t/pycall-build-fails-during-conda-installation-on-win-11/101786)

<div class="topic-metadata">

**Author:** [@Disperser3804](https://discourse.julialang.org/u/Disperser3804)\
**Replies:** 2\
**Last updated:** [July 19, 2023, 4:11pm UTC](https://discourse.julialang.org/t/pycall-build-fails-during-conda-installation-on-win-11/101786 "2023-07-19T16:11:55Z")

</div>

On a fresh Win 11 and Julia 1.9.2 installation, building PyCall results in an error during the miniconda installation step: ERROR: Error building PyCall: ┌ Info: Using the Python distribution in the Conda package by def…

---

## [Saving data a scan at a time and reading as a contiguous block](https://discourse.julialang.org/t/saving-data-a-scan-at-a-time-and-reading-as-a-contiguous-block/101691)

<div class="topic-metadata">

**Author:** [@Jake](https://discourse.julialang.org/u/Jake)\
**Replies:** 11\
**Last updated:** [July 19, 2023, 3:52pm UTC](https://discourse.julialang.org/t/saving-data-a-scan-at-a-time-and-reading-as-a-contiguous-block/101691 "2023-07-19T15:52:59Z")

</div>

I am looking at collecting data from an instrument. The data comes in multiple channels of one to sixteen channels, for this example lets use 4. It is collected with a specified frame size, for the sake of argument cal…

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

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