# General Usage

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

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

**Page:** 128

---

## [Issue with FMU File Creation in FMIExport.jl: Empty Files and UndefVarError](https://discourse.julialang.org/t/issue-with-fmu-file-creation-in-fmiexport-jl-empty-files-and-undefvarerror/119949)

<div class="topic-metadata">

**Author:** [@CurioMath](https://discourse.julialang.org/u/CurioMath)\
**Replies:** 0\
**Last updated:** [September 27, 2024, 11:00am UTC](https://discourse.julialang.org/t/issue-with-fmu-file-creation-in-fmiexport-jl-empty-files-and-undefvarerror/119949 "2024-09-27T11:00:15Z")

</div>

I’ve been trying to run exact examples from the FMIExport.jl package but have been unable to generate the expected FMU file. Specifically, when working with the “BouncingBall” example, files are generated in the specifie…

---

## [Getting the parametric constructors from \`methods\`](https://discourse.julialang.org/t/getting-the-parametric-constructors-from-methods/96632)

<div class="topic-metadata">

**Author:** [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Replies:** 2\
**Last updated:** [September 29, 2024, 1:42am UTC](https://discourse.julialang.org/t/getting-the-parametric-constructors-from-methods/96632 "2024-09-29T01:42:58Z")

</div>

If I call methods(Dict), it just returns the “non-parametric constructors”: julia\> methods(Dict) # 5 methods for type constructor: \[1\] Dict() in Base at dict.jl:118 \[2\] Dict(ps::Pair{K, V}...) where {K, V} in Base at di…

---

## [How to set the frame-rate of a gif file?](https://discourse.julialang.org/t/how-to-set-the-frame-rate-of-a-gif-file/120392)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 2\
**Last updated:** [September 29, 2024, 10:41am UTC](https://discourse.julialang.org/t/how-to-set-the-frame-rate-of-a-gif-file/120392 "2024-09-29T10:41:31Z")

</div>

I have the following code: using FileIO, ImageIO, Colors, FixedPointNumbers, Images folder = "video" A = Array{Array{RGB{Normed{UInt8,8}},2},1}() files = readdir(folder) pngfiles = filter(file-\>(occursin.("png",file))…

---

## [How can you call a function inside a taylor model function for reachability analysis?](https://discourse.julialang.org/t/how-can-you-call-a-function-inside-a-taylor-model-function-for-reachability-analysis/119945)

<div class="topic-metadata">

**Author:** [@Muhammad\_Arsal](https://discourse.julialang.org/u/Muhammad_Arsal)\
**Replies:** 2\
**Last updated:** [September 29, 2024, 9:46am UTC](https://discourse.julialang.org/t/how-can-you-call-a-function-inside-a-taylor-model-function-for-reachability-analysis/119945 "2024-09-29T09:46:12Z")

</div>

I am using Jupyter Notebook. And I have a grid interploation function. Which gives me the value of a variable based upon the data of other two. But the problem is when I try to run reachability analysis, it starts throwi…

---

## [When to use \`DomainError\` instead of \`ArgumentError\`?](https://discourse.julialang.org/t/when-to-use-domainerror-instead-of-argumenterror/120556)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 7\
**Last updated:** [September 29, 2024, 8:51am UTC](https://discourse.julialang.org/t/when-to-use-domainerror-instead-of-argumenterror/120556 "2024-09-29T08:51:03Z")

</div>

For example, if an algorithm can only be used on square matrices, which error should I throw? function square\_matrix\_algorithm(A::AbstractMatrix) if size(A, 1) != size(A, 2) throw(ArgumentError("This functio…

---

## [Customize test failure display](https://discourse.julialang.org/t/customize-test-failure-display/120610)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 2\
**Last updated:** [September 29, 2024, 6:22am UTC](https://discourse.julialang.org/t/customize-test-failure-display/120610 "2024-09-29T06:22:35Z")

</div>

I like how it shows the values of y and x here julia\> @test y \< x Test Failed at REPL\[6\]:1 Expression: y \< x Evaluated: 2 \< 1 Can I make it do that for the arguments of my custom function too? julia\> eq(x,y) = x …

---

## [Minimize Watson test function for n=12](https://discourse.julialang.org/t/minimize-watson-test-function-for-n-12/119807)

<div class="topic-metadata">

**Author:** [@Hans\_W\_Borchers](https://discourse.julialang.org/u/Hans_W_Borchers)\
**Replies:** 4\
**Last updated:** [September 29, 2024, 5:37am UTC](https://discourse.julialang.org/t/minimize-watson-test-function-for-n-12/119807 "2024-09-29T05:37:49Z")

</div>

More or less by chance I encountered the Watson function, that is test function #20, page 25, in the report “Testing Unconstrained Optimization Software” from 1991 by Moré, Garbow, and Hillstrom. See https://typeset.i…

---

## [Help with optimization](https://discourse.julialang.org/t/help-with-optimization/120522)

<div class="topic-metadata">

**Author:** [@lancejnelson](https://discourse.julialang.org/u/lancejnelson)\
**Replies:** 18\
**Last updated:** [September 28, 2024, 11:47pm UTC](https://discourse.julialang.org/t/help-with-optimization/120522 "2024-09-28T23:47:46Z")

</div>

I have the following function that is going to be called hundreds of thousands of times, and right now it’s running way too slow. function sample\_σ!(metrop::LJ\_metrop,data::DataSet,LJ::LJ,LJ\_next::LJ,std) for j = 1…

---

## [Collecting all output from shell commands](https://discourse.julialang.org/t/collecting-all-output-from-shell-commands/15592)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 27\
**Last updated:** [September 28, 2024, 7:34pm UTC](https://discourse.julialang.org/t/collecting-all-output-from-shell-commands/15592 "2024-09-28T19:34:32Z")

</div>

I want to run a command that may or may not exit gracefully. In any case I want to get all of the following information from it: content of stdout as String content of stderr as String exit code as Int What is the rec…

---

## [When to use mutable structs?](https://discourse.julialang.org/t/when-to-use-mutable-structs/120391)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 1\
**Last updated:** [September 28, 2024, 4:57pm UTC](https://discourse.julialang.org/t/when-to-use-mutable-structs/120391 "2024-09-28T16:57:15Z")

</div>

@jameson (hope I’ve got the username right, apologies if not!) I think we were getting a bit off-topic in Ref docstring should note clearly that it's an abstract type · Issue #55321 · JuliaLang/julia · GitHub. You’ve sa…

---

## [Printing a function](https://discourse.julialang.org/t/printing-a-function/119957)

<div class="topic-metadata">

**Author:** [@Paul\_Warburton](https://discourse.julialang.org/u/Paul_Warburton)\
**Replies:** 9\
**Last updated:** [September 28, 2024, 2:27pm UTC](https://discourse.julialang.org/t/printing-a-function/119957 "2024-09-28T14:27:30Z")

</div>

If I declare a function like f(x) = x^2 + log(x) how to I display it in a function like title!=f(x)

---

## [Problems with MethodOfLines discretizing PDESystem involving equations of symbolic arrays](https://discourse.julialang.org/t/problems-with-methodoflines-discretizing-pdesystem-involving-equations-of-symbolic-arrays/119916)

<div class="topic-metadata">

**Author:** [@r0uv3n](https://discourse.julialang.org/u/r0uv3n)\
**Replies:** 2\
**Last updated:** [September 28, 2024, 10:14am UTC](https://discourse.julialang.org/t/problems-with-methodoflines-discretizing-pdesystem-involving-equations-of-symbolic-arrays/119916 "2024-09-28T10:14:21Z")

</div>

Hi, I’m using ModelingToolkit to do some work involving Riemannian geometry, and in particular would like to work with tensor fields in arbitrary dimension. The following is as close to a MWE as I can get my code, I thin…

---

## [Constructors for parametric types](https://discourse.julialang.org/t/constructors-for-parametric-types/119971)

<div class="topic-metadata">

**Author:** [@Maurizio\_Tomasi](https://discourse.julialang.org/u/Maurizio_Tomasi)\
**Replies:** 5\
**Last updated:** [September 28, 2024, 8:52am UTC](https://discourse.julialang.org/t/constructors-for-parametric-types/119971 "2024-09-28T08:52:11Z")

</div>

Hi all, I am studying how Julia handles constructors in parametric types and have found a puzzling behavior. Consider this trivial type: struct Test1{R \<: Real} x::R end I can instantiate Test1 either with or with…

---

## [Rotate lower n bits](https://discourse.julialang.org/t/rotate-lower-n-bits/119923)

<div class="topic-metadata">

**Author:** [@Nichola](https://discourse.julialang.org/u/Nichola)\
**Replies:** 6\
**Last updated:** [September 27, 2024, 8:46am UTC](https://discourse.julialang.org/t/rotate-lower-n-bits/119923 "2024-09-27T08:46:26Z")

</div>

I would like to rotate the lower n bits of an integer x by r. Here is my current solution : function rotate\_lower(x::Int, n::Int, r::Int) mask = (1 \<\< n) - 1 lower\_bits = x & mask rotated\_bits = (lower\_bits…

---

## [Weightened linear model in GLM.jl](https://discourse.julialang.org/t/weightened-linear-model-in-glm-jl/119962)

<div class="topic-metadata">

**Author:** [@achjaj](https://discourse.julialang.org/u/achjaj)\
**Replies:** 3\
**Last updated:** [September 28, 2024, 6:21am UTC](https://discourse.julialang.org/t/weightened-linear-model-in-glm-jl/119962 "2024-09-28T06:21:28Z")

</div>

Hi, I want to fit a plane to measured points, i.e., the function Z = aX + bY + c to data, where the Z coordinate (dependent variable) has a measurement error \\sigma. The documentation for GLM.jl mentions that lm functio…

---

## [Does anyone have an implementation of MPI\_Ibcast wrapper?](https://discourse.julialang.org/t/does-anyone-have-an-implementation-of-mpi-ibcast-wrapper/119970)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 2\
**Last updated:** [September 27, 2024, 11:56pm UTC](https://discourse.julialang.org/t/does-anyone-have-an-implementation-of-mpi-ibcast-wrapper/119970 "2024-09-27T23:56:47Z")

</div>

MPI.jl does not seem to have it. I thought I would ask. (Why redesign the wheel?)

---

## [Is there an Official Shebang for Julia](https://discourse.julialang.org/t/is-there-an-official-shebang-for-julia/51581)

<div class="topic-metadata">

**Author:** [@anon70284489](https://discourse.julialang.org/u/anon70284489)\
**Replies:** 12\
**Last updated:** [September 27, 2024, 6:25pm UTC](https://discourse.julialang.org/t/is-there-an-official-shebang-for-julia/51581 "2024-09-27T18:25:24Z")

</div>

Is there an Official Shebang for Julia and if so how do I install and use it ?

---

## [How to find the elbow of a graph in Julia](https://discourse.julialang.org/t/how-to-find-the-elbow-of-a-graph-in-julia/36912)

<div class="topic-metadata">

**Author:** [@Julia1](https://discourse.julialang.org/u/Julia1)\
**Replies:** 13\
**Last updated:** [September 27, 2024, 5:57pm UTC](https://discourse.julialang.org/t/how-to-find-the-elbow-of-a-graph-in-julia/36912 "2024-09-27T17:57:40Z")

</div>

Hi how’s it going? A common technique to finding the optimal number for K in K-means clustering is to use the elbow method. You try different values of K, and plot the average euclidean distance from the points to their…

---

## [Comparison of Julia autodiff packages](https://discourse.julialang.org/t/comparison-of-julia-autodiff-packages/119965)

<div class="topic-metadata">

**Author:** [@Tarny\_GG\_Channie](https://discourse.julialang.org/u/Tarny_GG_Channie)\
**Replies:** 1\
**Last updated:** [September 27, 2024, 2:38pm UTC](https://discourse.julialang.org/t/comparison-of-julia-autodiff-packages/119965 "2024-09-27T14:38:37Z")

</div>

Julia now has so many different autodiff packages. Can somebody summarize the status of these packages? From what I know, there is Forwarddiff (which uses dual numbers), and then there is the Reversediff, which I’m not …

---

## [Tracking the change in no: of real solutions from HomotopyContinuation.jl using Interval arithematic](https://discourse.julialang.org/t/tracking-the-change-in-no-of-real-solutions-from-homotopycontinuation-jl-using-interval-arithematic/119964)

<div class="topic-metadata">

**Author:** [@ij05](https://discourse.julialang.org/u/ij05)\
**Replies:** 0\
**Last updated:** [September 27, 2024, 1:37pm UTC](https://discourse.julialang.org/t/tracking-the-change-in-no-of-real-solutions-from-homotopycontinuation-jl-using-interval-arithematic/119964 "2024-09-27T13:37:55Z")

</div>

I am just thinking out loud here and would deeply appreciate any pointers regarding the following problem. I use the “HomotopyContinuation.jl” package to solve a system of polynomial equations. Now there are two paramet…

---

## [Failed to precompile TrajectoryOptimization](https://discourse.julialang.org/t/failed-to-precompile-trajectoryoptimization/119900)

<div class="topic-metadata">

**Author:** [@jay\_Gao](https://discourse.julialang.org/u/jay_Gao)\
**Replies:** 5\
**Last updated:** [September 27, 2024, 1:36pm UTC](https://discourse.julialang.org/t/failed-to-precompile-trajectoryoptimization/119900 "2024-09-27T13:36:11Z")

</div>

when I add TrajectoryOptimization , I got an error message: ERROR: LoadError: LoadError: UndefVarError: QuatRotation not defined \[ Info: Precompiling TrajectoryOptimization \[c79d492b-0548-5874-b488-5a62c1d9d0ca\] ERROR:…

---

## [Invoke a method](https://discourse.julialang.org/t/invoke-a-method/1275)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 11\
**Last updated:** [September 27, 2024, 9:42am UTC](https://discourse.julialang.org/t/invoke-a-method/1275 "2024-09-27T09:42:18Z")

</div>

Is it possible to invoke a Method? Ie suppose I picked one from the MethodList returned by methods, and I want to invoke that particular method with given arguments. Eg m=which((+),(Int,Int)) # now how to call m with (1…

---

## [How to Load Prism (Wedge) Elements in Gridap.jl?](https://discourse.julialang.org/t/how-to-load-prism-wedge-elements-in-gridap-jl/119938)

<div class="topic-metadata">

**Author:** [@Skadi](https://discourse.julialang.org/u/Skadi)\
**Replies:** 0\
**Last updated:** [September 27, 2024, 5:30am UTC](https://discourse.julialang.org/t/how-to-load-prism-wedge-elements-in-gridap-jl/119938 "2024-09-27T05:30:15Z")

</div>

Hello, I am working on solving PDEs using Gridap.jl, specifically on a 3D mesh with 6-node prism (wedge) elements. I converted my original mesh(with node coordinates and connectivity matrix) to a .msh file and tried to …

---

## [Is it possible to do Nested AD ~elegantly~ in Julia? (PINNs)](https://discourse.julialang.org/t/is-it-possible-to-do-nested-ad-elegantly-in-julia-pinns/98888)

<div class="topic-metadata">

**Author:** [@Bizzi](https://discourse.julialang.org/u/Bizzi)\
**Replies:** 43\
**Last updated:** [September 27, 2024, 2:18am UTC](https://discourse.julialang.org/t/is-it-possible-to-do-nested-ad-elegantly-in-julia-pinns/98888 "2024-09-27T02:18:30Z")

</div>

To differentiate a loss function defined in terms of a network’s derivatives seems to have been an issue since forever, specially when Zygote is involved; see \[1\] \[2\] \[3\] and many more over at Zygote’s git. In many of t…

---

## [Catch ctrl-c in script](https://discourse.julialang.org/t/catch-ctrl-c-in-script/119885)

<div class="topic-metadata">

**Author:** [@matthew3245](https://discourse.julialang.org/u/matthew3245)\
**Replies:** 2\
**Last updated:** [September 27, 2024, 1:11am UTC](https://discourse.julialang.org/t/catch-ctrl-c-in-script/119885 "2024-09-27T01:11:35Z")

</div>

From the Julia docs: Running a Julia script using julia file.jl does not throw InterruptException when you try to terminate it with CTRL-C (SIGINT). To run a certain code before terminating a Julia script, which may or…

---

## [Exportall?](https://discourse.julialang.org/t/exportall/4970)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 21\
**Last updated:** [September 26, 2024, 9:52pm UTC](https://discourse.julialang.org/t/exportall/4970 "2024-09-26T21:52:57Z")

</div>

Is there a way to export ALL the symbols declared in a module? Just to avoid writing them all under export.

---

## [Why mutable structs are allocated on the heap?](https://discourse.julialang.org/t/why-mutable-structs-are-allocated-on-the-heap/12992)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 36\
**Last updated:** [September 26, 2024, 8:48pm UTC](https://discourse.julialang.org/t/why-mutable-structs-are-allocated-on-the-heap/12992 "2024-09-26T20:48:47Z")

</div>

From https://docs.julialang.org/en/latest/manual/types/#Mutable-Composite-Types-1: In order to support mutation, such objects are generally allocated on the heap, and have stable memory addresses. If I define: mutab…

---

## [Solving nonlinear equations using inexact Newton — seeking recommendations](https://discourse.julialang.org/t/solving-nonlinear-equations-using-inexact-newton-seeking-recommendations/119887)

<div class="topic-metadata">

**Author:** [@mpf01](https://discourse.julialang.org/u/mpf01)\
**Replies:** 5\
**Last updated:** [September 26, 2024, 7:37pm UTC](https://discourse.julialang.org/t/solving-nonlinear-equations-using-inexact-newton-seeking-recommendations/119887 "2024-09-26T19:37:51Z")

</div>

I’m seeking recommendations for a package for solving a large system of nonlinear equations, allowing for inexact Newton system solves using iterative linear solvers. My Jacobian is symmetric indefinite, and so I hope to…

---

## [Unclear allocations with in-place mutating functions](https://discourse.julialang.org/t/unclear-allocations-with-in-place-mutating-functions/119896)

<div class="topic-metadata">

**Author:** [@fmor](https://discourse.julialang.org/u/fmor)\
**Replies:** 14\
**Last updated:** [September 26, 2024, 6:50pm UTC](https://discourse.julialang.org/t/unclear-allocations-with-in-place-mutating-functions/119896 "2024-09-26T18:50:48Z")

</div>

I am fitting a statistical model and I refactored the code to reduce the allocations it generated. I morally halved them, with respect to the first version, but there are still some unclear sections which I see from runn…

---

## [Macro usage: create dispatch for vector length](https://discourse.julialang.org/t/macro-usage-create-dispatch-for-vector-length/118142)

<div class="topic-metadata">

**Author:** [@heronrick](https://discourse.julialang.org/u/heronrick)\
**Replies:** 8\
**Last updated:** [September 26, 2024, 3:44pm UTC](https://discourse.julialang.org/t/macro-usage-create-dispatch-for-vector-length/118142 "2024-09-26T15:44:56Z")

</div>

Hello, I have an Idea I would like to implement for a module I am working on. I will try to explain, but I am not sure if such implementation would make much sense, probably there are better solutions. I have a macro, …

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

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