# General Usage

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

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

**Page:** 218

---

## [Good line numbers in macro expansions](https://discourse.julialang.org/t/good-line-numbers-in-macro-expansions/107425)

<div class="topic-metadata">

**Author:** [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Replies:** 5\
**Last updated:** [December 25, 2023, 1:37am UTC](https://discourse.julialang.org/t/good-line-numbers-in-macro-expansions/107425 "2023-12-25T01:37:24Z")

</div>

My macros often have poor line numbers. For instance, given this simple macro, macro add\_hi(def) @capture(def, function f\_(args\_\_) body\_\_ end) esc(:(function $f($(args...)) println(hi); $body end)) end a…

---

## [Atreplinit and DrWatson's quickactivate at startup.jl file](https://discourse.julialang.org/t/atreplinit-and-drwatsons-quickactivate-at-startup-jl-file/107969)

<div class="topic-metadata">

**Author:** [@mocalvao](https://discourse.julialang.org/u/mocalvao)\
**Replies:** 5\
**Last updated:** [December 24, 2023, 8:18pm UTC](https://discourse.julialang.org/t/atreplinit-and-drwatsons-quickactivate-at-startup-jl-file/107969 "2023-12-24T20:18:34Z")

</div>

Dear all, I would like to have a startup.jl file which, when Julia is called interactively, from the REPL, at a given directory, automatically: uses OhMyREPL, DrWatson and Revise packages activates a possible project …

---

## [Discarding rows of dataframe base on condition on column of another dataframe](https://discourse.julialang.org/t/discarding-rows-of-dataframe-base-on-condition-on-column-of-another-dataframe/107973)

<div class="topic-metadata">

**Author:** [@mocalvao](https://discourse.julialang.org/u/mocalvao)\
**Replies:** 6\
**Last updated:** [December 24, 2023, 12:07pm UTC](https://discourse.julialang.org/t/discarding-rows-of-dataframe-base-on-condition-on-column-of-another-dataframe/107973 "2023-12-24T12:07:06Z")

</div>

Hi there, I have two dataframes: df1=DataFrame(Student=\["Abel", "Beatriz", "Beatriz", "Caio", "Dario", "Dario"\],Class=\["12", "12", "10", "11", "13", "14"\], Professor=\["John", "John", "Jack", "Moe", "Heather", "Lisa"\], …

---

## [Lsqfit Nonlinear Regression Using Two Parameters: One Parameter Is Stuck At The Initial Parameter Value](https://discourse.julialang.org/t/lsqfit-nonlinear-regression-using-two-parameters-one-parameter-is-stuck-at-the-initial-parameter-value/108001)

<div class="topic-metadata">

**Author:** [@HNormanW](https://discourse.julialang.org/u/HNormanW)\
**Replies:** 0\
**Last updated:** [December 24, 2023, 8:53am UTC](https://discourse.julialang.org/t/lsqfit-nonlinear-regression-using-two-parameters-one-parameter-is-stuck-at-the-initial-parameter-value/108001 "2023-12-24T08:53:48Z")

</div>

Hi, I’m trying to run a nonlinear regression fit for a perturbation function, but it seems to only fit one of my two parameters. The perturbation function is for modeling grating efficacy curves, with wavelength as the …

---

## [Warmup option in FluxTraining.jl](https://discourse.julialang.org/t/warmup-option-in-fluxtraining-jl/107773)

<div class="topic-metadata">

**Author:** [@cirobr](https://discourse.julialang.org/u/cirobr)\
**Replies:** 1\
**Last updated:** [December 23, 2023, 5:08am UTC](https://discourse.julialang.org/t/warmup-option-in-fluxtraining-jl/107773 "2023-12-23T05:08:49Z")

</div>

Cheers. I’m using FluxTraining.jl. I wonder if there is a kind of warmup option, which would allow training of n epochs without early stopping. If such an option is not implemented, any hint on how to do it at user code …

---

## [After I add TrajOptPlots packeg，the build meshcat went wrong，so as build TrajOptPlots](https://discourse.julialang.org/t/after-i-add-trajoptplots-packeg-the-build-meshcat-went-wrong-so-as-build-trajoptplots/107966)

<div class="topic-metadata">

**Author:** [@jinmingyue123](https://discourse.julialang.org/u/jinmingyue123)\
**Replies:** 0\
**Last updated:** [December 23, 2023, 3:27am UTC](https://discourse.julialang.org/t/after-i-add-trajoptplots-packeg-the-build-meshcat-went-wrong-so-as-build-trajoptplots/107966 "2023-12-23T03:27:56Z")

</div>

After I add TrajOptPlots packeg，the build meshcat went wrong，so as build TrajOptPlots. I have spent a lot of time to fix it. But still not fixed. Could you please help me with that. ERROR: Error building MeshCat: 7-Zip…

---

## [Julia startup options for VSCode](https://discourse.julialang.org/t/julia-startup-options-for-vscode/107911)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 4\
**Last updated:** [December 22, 2023, 7:19pm UTC](https://discourse.julialang.org/t/julia-startup-options-for-vscode/107911 "2023-12-22T19:19:01Z")

</div>

Hi all, I was wondering if there is a way to include julia startup options in VSCode. Specifically, I would like to enable deprecation warnings by default. Thanks!

---

## [How to use \`@kwdef\` with parametric types and inner constructors](https://discourse.julialang.org/t/how-to-use-kwdef-with-parametric-types-and-inner-constructors/107948)

<div class="topic-metadata">

**Author:** [@Maurizio\_Tomasi](https://discourse.julialang.org/u/Maurizio_Tomasi)\
**Replies:** 2\
**Last updated:** [December 22, 2023, 5:30pm UTC](https://discourse.julialang.org/t/how-to-use-kwdef-with-parametric-types-and-inner-constructors/107948 "2023-12-22T17:30:38Z")

</div>

I am having problems declaring a parametric structure with @kwdef and an inner constructor to perform some checks. My struct has many parameters and complicated checks, but this simple example is enough to explain my pr…

---

## [Why is relpath("x","y") == "../x"?](https://discourse.julialang.org/t/why-is-relpath-x-y-x/107932)

<div class="topic-metadata">

**Author:** [@evanfields](https://discourse.julialang.org/u/evanfields)\
**Replies:** 5\
**Last updated:** [December 22, 2023, 2:26pm UTC](https://discourse.julialang.org/t/why-is-relpath-x-y-x/107932 "2023-12-22T14:26:21Z")

</div>

julia\> relpath("tatooine", "naboo") "../tatooine" The docs say relpath(path::AbstractString, startpath::AbstractString = ".") -\> AbstractString Return a relative filepath to path either from the current directory or …

---

## [A package for arbitrary array indices?](https://discourse.julialang.org/t/a-package-for-arbitrary-array-indices/107848)

<div class="topic-metadata">

**Author:** [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Replies:** 2\
**Last updated:** [December 22, 2023, 1:22am UTC](https://discourse.julialang.org/t/a-package-for-arbitrary-array-indices/107848 "2023-12-22T01:22:25Z")

</div>

Hello, I am a looking for a package that allows me to dynamically change the indexing of an array. I’m aware of OffsetArrays but this is not what I need. Say I have an 8 by 8 symmetric matrix A. I have an algorithm tha…

---

## [Strange type instability](https://discourse.julialang.org/t/strange-type-instability/107912)

<div class="topic-metadata">

**Author:** [@abraunst](https://discourse.julialang.org/u/abraunst)\
**Replies:** 2\
**Last updated:** [December 22, 2023, 7:11am UTC](https://discourse.julialang.org/t/strange-type-instability/107912 "2023-12-22T07:11:09Z")

</div>

I’m encountering a strange type instability that I could distill to the following minimal code: function unstable(rv,x0) x1=copy(x0) for t in 1:10 p::Int = prod(x0\[j\] for j in rv; init=1) x1\[1\] =…

---

## [Windows is slower than WSL2 in loading GR, Preferences, Julia 1.9.0-beta2](https://discourse.julialang.org/t/windows-is-slower-than-wsl2-in-loading-gr-preferences-julia-1-9-0-beta2/92623)

<div class="topic-metadata">

**Author:** [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Replies:** 8\
**Last updated:** [December 22, 2023, 4:29am UTC](https://discourse.julialang.org/t/windows-is-slower-than-wsl2-in-loading-gr-preferences-julia-1-9-0-beta2/92623 "2023-12-22T04:29:32Z")

</div>

I recently installed WSL 2. I noticed that @time\_imports reports faster import times for Preferences and GR under WSL2 than under Windows. The loading time for Preferences.jl is appears to be 10x worse. # WSL 2 julia\> @…

---

## [Caching Bytecode/Binary for Dynamic Modules in Embedded Context](https://discourse.julialang.org/t/caching-bytecode-binary-for-dynamic-modules-in-embedded-context/107927)

<div class="topic-metadata">

**Author:** [@chayden](https://discourse.julialang.org/u/chayden)\
**Replies:** 2\
**Last updated:** [December 22, 2023, 3:09am UTC](https://discourse.julialang.org/t/caching-bytecode-binary-for-dynamic-modules-in-embedded-context/107927 "2023-12-22T03:09:09Z")

</div>

Suppose I have embedded Julia in a C++ application so I can write plugins/extensions in Julia. The form of each plugin is (more or less) the following. module \<dynamically-generated\> import Main.bindings # Julia bindin…

---

## [Typed Units instead of parameterized (Unitful) or exponent-tracking (DynamicQuantities)?](https://discourse.julialang.org/t/typed-units-instead-of-parameterized-unitful-or-exponent-tracking-dynamicquantities/105735)

<div class="topic-metadata">

**Author:** [@bcon](https://discourse.julialang.org/u/bcon)\
**Replies:** 8\
**Last updated:** [December 22, 2023, 1:56am UTC](https://discourse.julialang.org/t/typed-units-instead-of-parameterized-unitful-or-exponent-tracking-dynamicquantities/105735 "2023-12-22T01:56:53Z")

</div>

Adding units to a package greatly obfuscates error messages, slowing development. If you share this annoyance I’d appreciate your thoughts on a package, ‘UnitTypes’, that simply treats units as types. The package would …

---

## [Extensions and Plots.jl Finding Broken pre-compiles](https://discourse.julialang.org/t/extensions-and-plots-jl-finding-broken-pre-compiles/107920)

<div class="topic-metadata">

**Author:** [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Replies:** 1\
**Last updated:** [December 22, 2023, 1:18am UTC](https://discourse.julialang.org/t/extensions-and-plots-jl-finding-broken-pre-compiles/107920 "2023-12-22T01:18:09Z")

</div>

Trying to update my code to make it super cool. Trying to add in Package extensions for some of the plot scripts so I can divorce calculation code from the plotting packages. I have a mix of Plots and Makie. Any ideas…

---

## [Is there a way to repeatedly call a function](https://discourse.julialang.org/t/is-there-a-way-to-repeatedly-call-a-function/107762)

<div class="topic-metadata">

**Author:** [@Zentrik](https://discourse.julialang.org/u/Zentrik)\
**Replies:** 12\
**Last updated:** [December 21, 2023, 10:41pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-repeatedly-call-a-function/107762 "2023-12-21T22:41:31Z")

</div>

Say I have a function f, I want to call it repeatedly n times. I.e. for n = 3, I want f ∘ f ∘ f. Is there a nice notation to do this for n not known at compile time, ideally something like f^n.

---

## [Good package to smooth outliers?](https://discourse.julialang.org/t/good-package-to-smooth-outliers/107919)

<div class="topic-metadata">

**Author:** [@PeX](https://discourse.julialang.org/u/PeX)\
**Replies:** 2\
**Last updated:** [December 21, 2023, 8:40pm UTC](https://discourse.julialang.org/t/good-package-to-smooth-outliers/107919 "2023-12-21T20:40:12Z")

</div>

Hi all, I’m looking for a package (or a good method) that can smooth out outliers like these: Any suggestions?

---

## [CRC32 checksums](https://discourse.julialang.org/t/crc32-checksums/107922)

<div class="topic-metadata">

**Author:** [@LeePhillips](https://discourse.julialang.org/u/LeePhillips)\
**Replies:** 2\
**Last updated:** [December 21, 2023, 7:57pm UTC](https://discourse.julialang.org/t/crc32-checksums/107922 "2023-12-21T19:57:08Z")

</div>

Why are the checksums from CRCR32c.crc32c in the Standard Library different from the ones I get from the linux crc32 command? Documentation suggests that they are both using the same algorithm.

---

## [Alternatives to LsqFit for nonlinear curve fitting?](https://discourse.julialang.org/t/alternatives-to-lsqfit-for-nonlinear-curve-fitting/107685)

<div class="topic-metadata">

**Author:** [@PeX](https://discourse.julialang.org/u/PeX)\
**Replies:** 12\
**Last updated:** [December 21, 2023, 4:48pm UTC](https://discourse.julialang.org/t/alternatives-to-lsqfit-for-nonlinear-curve-fitting/107685 "2023-12-21T16:48:52Z")

</div>

Hi! I’m trying to use Julia to make a curve fit with the functional form: model = ( p\[1\] / x ) \* exp( -p\[2\] / x ) to a data-set I have. I tried LsqFit, however, if I’m not making really good initial guesses for the p…

---

## [Hide default constructor for a struct](https://discourse.julialang.org/t/hide-default-constructor-for-a-struct/89064)

<div class="topic-metadata">

**Author:** [@prittjam](https://discourse.julialang.org/u/prittjam)\
**Replies:** 13\
**Last updated:** [December 21, 2023, 12:53pm UTC](https://discourse.julialang.org/t/hide-default-constructor-for-a-struct/89064 "2023-12-21T12:53:49Z")

</div>

Is there a way to hide a default constructor for a struct so that it is not callable? Thanks.

---

## [Dates in DataFrames](https://discourse.julialang.org/t/dates-in-dataframes/107887)

<div class="topic-metadata">

**Author:** [@David\_Annetts](https://discourse.julialang.org/u/David_Annetts)\
**Replies:** 1\
**Last updated:** [December 21, 2023, 3:07am UTC](https://discourse.julialang.org/t/dates-in-dataframes/107887 "2023-12-21T03:07:53Z")

</div>

Hi, I (think I) have a vector of dates in rdat. At least, typeof.(rdat) returns a lot of Date. So I’m confused as to why tmp = DataFrame(td = rdat) returns a DataFrame with the column td listed as a vector of type An…

---

## [Efficiently check if a sparse vector is a column of a sparse matrix](https://discourse.julialang.org/t/efficiently-check-if-a-sparse-vector-is-a-column-of-a-sparse-matrix/107861)

<div class="topic-metadata">

**Author:** [@max29](https://discourse.julialang.org/u/max29)\
**Replies:** 13\
**Last updated:** [December 21, 2023, 2:57am UTC](https://discourse.julialang.org/t/efficiently-check-if-a-sparse-vector-is-a-column-of-a-sparse-matrix/107861 "2023-12-21T02:57:47Z")

</div>

I have a sparse matrix A and a sparse vector x and want to check if the vector is a column of the matrix. using SparseArrays, BenchmarkTools A = spdiagm(1:1000); x = sparsevec(\[950\],\[950\],1000); B = Array(A); # dense y…

---

## [Broadcast inside of \`@mtkmodel\` macro causes precompilation failures when put into a package](https://discourse.julialang.org/t/broadcast-inside-of-mtkmodel-macro-causes-precompilation-failures-when-put-into-a-package/107277)

<div class="topic-metadata">

**Author:** [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Replies:** 19\
**Last updated:** [December 21, 2023, 12:23am UTC](https://discourse.julialang.org/t/broadcast-inside-of-mtkmodel-macro-causes-precompilation-failures-when-put-into-a-package/107277 "2023-12-21T00:23:05Z")

</div>

While trying to implement a 3D version of the Mass-Spring model here in a package, I get the following error ERROR: LoadError: Evaluation into the closed module ModelingToolkit breaks incremental compilation because th…

---

## [How to extend method used in package extension](https://discourse.julialang.org/t/how-to-extend-method-used-in-package-extension/107871)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 11\
**Last updated:** [December 20, 2023, 11:58pm UTC](https://discourse.julialang.org/t/how-to-extend-method-used-in-package-extension/107871 "2023-12-20T23:58:47Z")

</div>

Hello, I am using a package which has plotting functionality defined in a package extension. It uses a function package\_function which is defined in the package module as function package\_function end and in the modul…

---

## [Different api for scalar input in Enzyme.jl](https://discourse.julialang.org/t/different-api-for-scalar-input-in-enzyme-jl/107882)

<div class="topic-metadata">

**Author:** [@jwalker](https://discourse.julialang.org/u/jwalker)\
**Replies:** 2\
**Last updated:** [December 20, 2023, 11:50pm UTC](https://discourse.julialang.org/t/different-api-for-scalar-input-in-enzyme-jl/107882 "2023-12-20T23:50:56Z")

</div>

I’m puzzled by a difference in the API of Reverse mode with functions of scalar inputs versus those of other (e.g. vector inputs). It seems to be the case that for a scalar function of a scalar input, you must use Rever…

---

## [How can I return a live websocket connection in HTTP.jl?](https://discourse.julialang.org/t/how-can-i-return-a-live-websocket-connection-in-http-jl/66752)

<div class="topic-metadata">

**Author:** [@PyDataBlog](https://discourse.julialang.org/u/PyDataBlog)\
**Replies:** 17\
**Last updated:** [December 20, 2023, 7:09pm UTC](https://discourse.julialang.org/t/how-can-i-return-a-live-websocket-connection-in-http-jl/66752 "2023-12-20T19:09:15Z")

</div>

I have a live streaming connection opened via HTTP.jl’s Websocket with this snippet using HTTP using JSON3 HTTP.WebSockets.open("wss://ws.coincap.io/trades/binance") do ws while !eof(ws) println(readavailab…

---

## ["None Sym BasicSymbolic doesn't have a name" Problem when using NeuralPDE](https://discourse.julialang.org/t/none-sym-basicsymbolic-doesnt-have-a-name-problem-when-using-neuralpde/100348)

<div class="topic-metadata">

**Author:** [@Ethan\_Tran](https://discourse.julialang.org/u/Ethan_Tran)\
**Replies:** 1\
**Last updated:** [December 20, 2023, 6:25pm UTC](https://discourse.julialang.org/t/none-sym-basicsymbolic-doesnt-have-a-name-problem-when-using-neuralpde/100348 "2023-12-20T18:25:13Z")

</div>

I try to use NeuralPDE to solve ODE problem, when I define the system with the separate variable u1(…) and u2(…) it run normally. (The code following) using NeuralPDE, Lux, ModelingToolkit, Optimization, OptimizationOpt…

---

## [How can I build an inner constructor accepting keywords arguments?](https://discourse.julialang.org/t/how-can-i-build-an-inner-constructor-accepting-keywords-arguments/107866)

<div class="topic-metadata">

**Author:** [@Tortar](https://discourse.julialang.org/u/Tortar)\
**Replies:** 5\
**Last updated:** [December 20, 2023, 5:13pm UTC](https://discourse.julialang.org/t/how-can-i-build-an-inner-constructor-accepting-keywords-arguments/107866 "2023-12-20T17:13:07Z")

</div>

I show my problem with a minimal example, say I have: julia\> @kwdef struct Foo x::Int = 3 y::Int Foo(m, x, y) = new(m\*x, m\*y) Foo(m; x, y) = Foo(m, x, y) end Foo I’d l…

---

## [Testing a package extension?](https://discourse.julialang.org/t/testing-a-package-extension/107846)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 6\
**Last updated:** [December 20, 2023, 2:47pm UTC](https://discourse.julialang.org/t/testing-a-package-extension/107846 "2023-12-20T14:47:49Z")

</div>

General question is: what is the recommended way to run CI tests on functionality provided in package extensions? One option would be I guess to make the tests require all the possible extension-triggering weak-dependen…

---

## [Franklin.jl - how to link to a local PDF file?](https://discourse.julialang.org/t/franklin-jl-how-to-link-to-a-local-pdf-file/107860)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 1\
**Last updated:** [December 20, 2023, 2:46pm UTC](https://discourse.julialang.org/t/franklin-jl-how-to-link-to-a-local-pdf-file/107860 "2023-12-20T14:46:18Z")

</div>

How can I add a PDF file as a downloadable link, in a webpage generated by Franklin.jl? I can store the PDF file in e.g. \_assets/.

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

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