# General Usage

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

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

**Page:** 590

---

## [Unitful + DiffEq + different physical quantities + derivatives?](https://discourse.julialang.org/t/unitful-diffeq-different-physical-quantities-derivatives/62635)

<div class="topic-metadata">

**Author:** [@ggggggggg](https://discourse.julialang.org/u/ggggggggg)\
**Replies:** 1\
**Last updated:** [June 9, 2021, 5:48pm UTC](https://discourse.julialang.org/t/unitful-diffeq-different-physical-quantities-derivatives/62635 "2021-06-09T17:48:30Z")

</div>

I’m working on model using Differential Equation that has two state variables, current and temperature. So when using DifferentialEquations.jl I define something like f(du, u, p, t) = ... u is a vector with two element…

---

## [DataFrames groupby() by a column of mutable custom type](https://discourse.julialang.org/t/dataframes-groupby-by-a-column-of-mutable-custom-type/62632)

<div class="topic-metadata">

**Author:** [@AndreLC](https://discourse.julialang.org/u/AndreLC)\
**Replies:** 4\
**Last updated:** [June 9, 2021, 4:44pm UTC](https://discourse.julialang.org/t/dataframes-groupby-by-a-column-of-mutable-custom-type/62632 "2021-06-09T16:44:07Z")

</div>

Here is a small example: mutable struct Mystring str::String end using DataFrames strs = \["a","b","a","b"\]; mystrs = Mystring.(strs); df = DataFrame(col\_str=strs, col\_mystr=mystrs); println(df) println(groupby(df…

---

## [Scope of variable in if in loop](https://discourse.julialang.org/t/scope-of-variable-in-if-in-loop/62621)

<div class="topic-metadata">

**Author:** [@Fred\_He](https://discourse.julialang.org/u/Fred_He)\
**Replies:** 8\
**Last updated:** [June 9, 2021, 3:13pm UTC](https://discourse.julialang.org/t/scope-of-variable-in-if-in-loop/62621 "2021-06-09T15:13:02Z")

</div>

from my understanding, “if” doesn’t create new scope, so the variable “b” should be local variable in for loop. So why there is an error saying b is not found in the “else” ? function f1(a) for i = 1:2 if i ==1 …

---

## [Any updates on Julia Stipple](https://discourse.julialang.org/t/any-updates-on-julia-stipple/62631)

<div class="topic-metadata">

**Author:** [@bww00](https://discourse.julialang.org/u/bww00)\
**Replies:** 0\
**Last updated:** [June 9, 2021, 2:53pm UTC](https://discourse.julialang.org/t/any-updates-on-julia-stipple/62631 "2021-06-09T14:53:47Z")

</div>

I have some need to use julia with oracle, produce a web app and use SAML or AD authenication. Regards Bryan

---

## [Confusion about type stability: functions or methods?](https://discourse.julialang.org/t/confusion-about-type-stability-functions-or-methods/62277)

<div class="topic-metadata">

**Author:** [@fedario](https://discourse.julialang.org/u/fedario)\
**Replies:** 17\
**Last updated:** [June 9, 2021, 2:39pm UTC](https://discourse.julialang.org/t/confusion-about-type-stability-functions-or-methods/62277 "2021-06-09T14:39:03Z")

</div>

Hi! Reading the documentation about type stability actually made me unsure if I understood the concept correctly. The documentation states that When possible, it helps to ensure that a function always returns a value…

---

## [Add predictor term to formula](https://discourse.julialang.org/t/add-predictor-term-to-formula/62595)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 3\
**Last updated:** [June 9, 2021, 1:24pm UTC](https://discourse.julialang.org/t/add-predictor-term-to-formula/62595 "2021-06-09T13:24:09Z")

</div>

I have a formula object defined by formula = @formula(y ~ x1 + x2) How can I add another predictor term to that FormulaTerm object after it is created? I tried formula.rhs += Term(:x3) # error push!(formula.rhs, Term…

---

## [Disable Markers when Plotting with Ribbon](https://discourse.julialang.org/t/disable-markers-when-plotting-with-ribbon/62615)

<div class="topic-metadata">

**Author:** [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Replies:** 5\
**Last updated:** [June 9, 2021, 12:06pm UTC](https://discourse.julialang.org/t/disable-markers-when-plotting-with-ribbon/62615 "2021-06-09T12:06:07Z")

</div>

Hey everyone, Since the last update I have the following problem. I have a plot including a ribbon using pgfplotsx. It automatically includes markers on the ribbon and on the mean, which I would like to remove both. He…

---

## [Fully parallelized for-loop becomes slower with more threads](https://discourse.julialang.org/t/fully-parallelized-for-loop-becomes-slower-with-more-threads/62614)

<div class="topic-metadata">

**Author:** [@vmuser](https://discourse.julialang.org/u/vmuser)\
**Replies:** 2\
**Last updated:** [June 9, 2021, 9:29am UTC](https://discourse.julialang.org/t/fully-parallelized-for-loop-becomes-slower-with-more-threads/62614 "2021-06-09T09:29:02Z")

</div>

Basically the title says it all: I have a for-loop that is fully parallelizable, so all the operations in the loop can be calculated independently. They only need access to the same multidimensional array but I make sure…

---

## [Improving performance in solving SDEProblem](https://discourse.julialang.org/t/improving-performance-in-solving-sdeproblem/62396)

<div class="topic-metadata">

**Author:** [@Frazze](https://discourse.julialang.org/u/Frazze)\
**Replies:** 8\
**Last updated:** [June 9, 2021, 9:00am UTC](https://discourse.julialang.org/t/improving-performance-in-solving-sdeproblem/62396 "2021-06-09T09:00:56Z")

</div>

Hi everyone, I’m studying part of the 2D Swift Hohenberg model with an additive noise term, but I’m really new to the SDEProblems so I don’t know if my way to build the model is the best way to solve it. I’ve take a lo…

---

## [Local expr with local variables - aka metaprogramming C++](https://discourse.julialang.org/t/local-expr-with-local-variables-aka-metaprogramming-c/62501)

<div class="topic-metadata">

**Author:** [@sapo](https://discourse.julialang.org/u/sapo)\
**Replies:** 18\
**Last updated:** [June 9, 2021, 8:32am UTC](https://discourse.julialang.org/t/local-expr-with-local-variables-aka-metaprogramming-c/62501 "2021-06-09T08:32:31Z")

</div>

Hi all, I am trying to use a C++ library by creating C++ code dynamically (i.e. meta-programming C++). I’m using Cxx package for this. In Cxx there’s a macro-string named icxx\_str which basically wraps the code inside …

---

## [Nanmean for 3d array](https://discourse.julialang.org/t/nanmean-for-3d-array/62569)

<div class="topic-metadata">

**Author:** [@kongdd](https://discourse.julialang.org/u/kongdd)\
**Replies:** 3\
**Last updated:** [June 9, 2021, 7:22am UTC](https://discourse.julialang.org/t/nanmean-for-3d-array/62569 "2021-06-09T07:22:26Z")

</div>

Does julia have the nanmean function for 3d array, just like what in MATLAB (Not recommended) Mean, ignoring NaN values - MATLAB nanmean?

---

## [How to add MyPkg to local registry?](https://discourse.julialang.org/t/how-to-add-mypkg-to-local-registry/62183)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 6\
**Last updated:** [June 9, 2021, 7:09am UTC](https://discourse.julialang.org/t/how-to-add-mypkg-to-local-registry/62183 "2021-06-09T07:09:18Z")

</div>

Hi all, I work behind company walls and develop in Julia. I’m creating custom packages and want to register them locally. How would that work? Thanks!

---

## [\`\<=\` does not desugar correctly with custom struct](https://discourse.julialang.org/t/does-not-desugar-correctly-with-custom-struct/62570)

<div class="topic-metadata">

**Author:** [@Samuel\_Ainsworth](https://discourse.julialang.org/u/Samuel_Ainsworth)\
**Replies:** 4\
**Last updated:** [June 9, 2021, 5:18am UTC](https://discourse.julialang.org/t/does-not-desugar-correctly-with-custom-struct/62570 "2021-06-09T05:18:51Z")

</div>

So I have a bit of code: struct Foo val::Float64 end @show 0.0 \<= Foo(0.0) but then MethodError: no method matching isless(::Float64, ::Foo). Oh right, I forgot to define isless: struct Foo val::Float64 end functi…

---

## [Macro for checking predicates](https://discourse.julialang.org/t/macro-for-checking-predicates/62603)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 0\
**Last updated:** [June 9, 2021, 2:47am UTC](https://discourse.julialang.org/t/macro-for-checking-predicates/62603 "2021-06-09T02:47:12Z")

</div>

Is there a macro that behaves like @assert, showing the contents on failure, but isn’t disabled by optimization, so it can be used for validation? It seems like it would be useful in a lot of cases but I can’t find a p…

---

## ["LoadError: InitError: Evaluation into the closed module \`GR\` breaks incremental compilation..."](https://discourse.julialang.org/t/loaderror-initerror-evaluation-into-the-closed-module-gr-breaks-incremental-compilation/53637)

<div class="topic-metadata">

**Author:** [@Michael\_Barmann](https://discourse.julialang.org/u/Michael_Barmann)\
**Replies:** 12\
**Last updated:** [June 8, 2021, 9:30pm UTC](https://discourse.julialang.org/t/loaderror-initerror-evaluation-into-the-closed-module-gr-breaks-incremental-compilation/53637 "2021-06-08T21:30:24Z")

</div>

I installed Plots with the gr() back end several weeks ago, and it had been working fine up until today. I shutdown the kernel yesterday evening after I was done working on my Jupyter notebook, and when I restarted it to…

---

## [What is the best way to wrap C double pointers into a Julia \`Matrix\`?](https://discourse.julialang.org/t/what-is-the-best-way-to-wrap-c-double-pointers-into-a-julia-matrix/62472)

<div class="topic-metadata">

**Author:** [@sapo](https://discourse.julialang.org/u/sapo)\
**Replies:** 3\
**Last updated:** [June 8, 2021, 7:38pm UTC](https://discourse.julialang.org/t/what-is-the-best-way-to-wrap-c-double-pointers-into-a-julia-matrix/62472 "2021-06-08T19:38:01Z")

</div>

Take this code which represents a matrix in C. int\*\* mat = (int\*\*) malloc(rows \* sizeof(int\*)) for (int index=0;index\<row;++index) { mat\[index\] = (int\*) malloc(cols \* sizeof(int)); } What is the best way to wrap m…

---

## [Plots/GR + png() results in "Too many open files"](https://discourse.julialang.org/t/plots-gr-png-results-in-too-many-open-files/48998)

<div class="topic-metadata">

**Author:** [@ErikE](https://discourse.julialang.org/u/ErikE)\
**Replies:** 15\
**Last updated:** [June 8, 2021, 5:42pm UTC](https://discourse.julialang.org/t/plots-gr-png-results-in-too-many-open-files/48998 "2021-06-08T17:42:11Z")

</div>

Hello! I have a piece of Julia code where I generate (a lot of) scatter plots with the scatter function from Plots (with the GR backend), and save the plots to PNGs, using the png(filename) function (to later turn them …

---

## [DifferentialEquations.jl saving data without redundant calculation of control inputs](https://discourse.julialang.org/t/differentialequations-jl-saving-data-without-redundant-calculation-of-control-inputs/62559)

<div class="topic-metadata">

**Author:** [@iHany](https://discourse.julialang.org/u/iHany)\
**Replies:** 5\
**Last updated:** [June 8, 2021, 3:55pm UTC](https://discourse.julialang.org/t/differentialequations-jl-saving-data-without-redundant-calculation-of-control-inputs/62559 "2021-06-08T15:55:46Z")

</div>

I’m trying to save some data, which is also calculated within given ODE. For example, with a linear system, I usually write a function A = Matrix(I, n, n) B = Matrix(I, n, m) function dynamics!(dx, x, p, t; u) dx .…

---

## [Question on Julia Source and Doc Pages](https://discourse.julialang.org/t/question-on-julia-source-and-doc-pages/62577)

<div class="topic-metadata">

**Author:** [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Replies:** 2\
**Last updated:** [June 8, 2021, 1:27pm UTC](https://discourse.julialang.org/t/question-on-julia-source-and-doc-pages/62577 "2021-06-08T13:27:28Z")

</div>

Looking at the Julia documentation - you can click on “source” and it will take you to a file on github that shows how it is actually written. You can also see that all the documentation/text describing the source is jus…

---

## [\`@code\_typed (-2 \<= 1 \<= 2)\` fails](https://discourse.julialang.org/t/code-typed-2-1-2-fails/62561)

<div class="topic-metadata">

**Author:** [@Samuel\_Ainsworth](https://discourse.julialang.org/u/Samuel_Ainsworth)\
**Replies:** 3\
**Last updated:** [June 8, 2021, 1:01pm UTC](https://discourse.julialang.org/t/code-typed-2-1-2-fails/62561 "2021-06-08T13:01:15Z")

</div>

I’m stumped by this: julia\> -2 \<= 1 \<= 2 true julia\> @code\_typed (-2 \<= 1 \<= 2) ERROR: expression is not a function call, or is too complex for @code\_typed to analyze; break it down to simpler parts if possible. In som…

---

## [Broadcasting in CUDA kernels](https://discourse.julialang.org/t/broadcasting-in-cuda-kernels/62521)

<div class="topic-metadata">

**Author:** [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Replies:** 7\
**Last updated:** [June 8, 2021, 12:58pm UTC](https://discourse.julialang.org/t/broadcasting-in-cuda-kernels/62521 "2021-06-08T12:58:44Z")

</div>

Hello, In the following example code there are two kernels, kernel1 and kernel2, which do exactly the same, but kernel1 uses broadcasting and, as a result, causes an error. Is it an expected behaviour? Is it possible to…

---

## [Issues with saving plot as pdf](https://discourse.julialang.org/t/issues-with-saving-plot-as-pdf/46358)

<div class="topic-metadata">

**Author:** [@bhache](https://discourse.julialang.org/u/bhache)\
**Replies:** 6\
**Last updated:** [June 8, 2021, 8:29am UTC](https://discourse.julialang.org/t/issues-with-saving-plot-as-pdf/46358 "2021-06-08T08:29:51Z")

</div>

I was trying to save plots generated using gr() backend in pdf format and this messes up the negative values along y-axes. This doesn’t seem to happen when the figure is saved as png though. I am attaching the plot comma…

---

## [Only plot a subset of x](https://discourse.julialang.org/t/only-plot-a-subset-of-x/62485)

<div class="topic-metadata">

**Author:** [@Albert\_Zevelev](https://discourse.julialang.org/u/Albert_Zevelev)\
**Replies:** 10\
**Last updated:** [June 7, 2021, 10:54pm UTC](https://discourse.julialang.org/t/only-plot-a-subset-of-x/62485 "2021-06-07T22:54:07Z")

</div>

using CSV, HTTP, DataFrames, Statistics, Plots, Dates # Get Data link = "https://github.com/azev77/Synthetic\_Control\_in\_Julia/raw/main/HP\_q.csv" r = HTTP.get(link) df = CSV.read(r.body, DataFrame, missingstring="NA") …

---

## [LaTeX code for titles, labels,... with Plots.jl](https://discourse.julialang.org/t/latex-code-for-titles-labels-with-plots-jl/1967)

<div class="topic-metadata">

**Author:** [@Holy\_Monk](https://discourse.julialang.org/u/Holy_Monk)\
**Replies:** 34\
**Last updated:** [June 8, 2021, 6:49am UTC](https://discourse.julialang.org/t/latex-code-for-titles-labels-with-plots-jl/1967 "2021-06-08T06:49:09Z")

</div>

I am using Plots.jl for making plots, but I would like to have my legend, title, labels,… in latex typesetting. With other libraries I know I can just use L"…", but when I run the following code: using Plots plot(0:2,0:…

---

## [Check which Makie backend is activated](https://discourse.julialang.org/t/check-which-makie-backend-is-activated/62550)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 1\
**Last updated:** [June 8, 2021, 5:34am UTC](https://discourse.julialang.org/t/check-which-makie-backend-is-activated/62550 "2021-06-08T05:34:23Z")

</div>

How can I check which backend is in use?

---

## [Makie: add title to plot](https://discourse.julialang.org/t/makie-add-title-to-plot/22340)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 11\
**Last updated:** [June 8, 2021, 5:33am UTC](https://discourse.julialang.org/t/makie-add-title-to-plot/22340 "2021-06-08T05:33:45Z")

</div>

How to add a title to a Makie plot? I would to produce a plot like the following using Makie instead of Plots.jl: julia\> using Plots; plot(randn(10), title="my random numbers")

---

## [ForwardDiff and ImageTransformations](https://discourse.julialang.org/t/forwarddiff-and-imagetransformations/62373)

<div class="topic-metadata">

**Author:** [@Arrigo\_Benedetti](https://discourse.julialang.org/u/Arrigo_Benedetti)\
**Replies:** 2\
**Last updated:** [June 8, 2021, 2:59am UTC](https://discourse.julialang.org/t/forwarddiff-and-imagetransformations/62373 "2021-06-08T02:59:35Z")

</div>

I am trying to compute the gradient of a cost function defined as the Sum of Square Differences (SSD) between two images with respect to the parameters of an image transformation. In the code shown below, one of the imag…

---

## [MethodError: no method matching Weights(::Array{Any,1}, ::Float64)](https://discourse.julialang.org/t/methoderror-no-method-matching-weights-array-any-1-float64/62551)

<div class="topic-metadata">

**Author:** [@Sebastian\_Mena](https://discourse.julialang.org/u/Sebastian_Mena)\
**Replies:** 0\
**Last updated:** [June 8, 2021, 1:24am UTC](https://discourse.julialang.org/t/methoderror-no-method-matching-weights-array-any-1-float64/62551 "2021-06-08T01:24:03Z")

</div>

Hi, I’m trying to do a sample of a string array, incorporating weights for each of the elements of the array. Specifically, new\_name\_event = sample(events,Weights(dict\_betas\_choices\[string(new\_player)\]\[new\_zone\]\[string…

---

## [How to specify a type of Vector, SVector, OR Tuple of a certain type, such as Int?](https://discourse.julialang.org/t/how-to-specify-a-type-of-vector-svector-or-tuple-of-a-certain-type-such-as-int/62537)

<div class="topic-metadata">

**Author:** [@jinml](https://discourse.julialang.org/u/jinml)\
**Replies:** 3\
**Last updated:** [June 7, 2021, 6:44pm UTC](https://discourse.julialang.org/t/how-to-specify-a-type-of-vector-svector-or-tuple-of-a-certain-type-such-as-int/62537 "2021-06-07T18:44:15Z")

</div>

I’d like the function to take a Vector, an SVector or Tuple of certain eltype, and unspecified length, what is the most concise type qualifier? Thanks,

---

## [Common LAPACK/Blas utility functions](https://discourse.julialang.org/t/common-lapack-blas-utility-functions/62530)

<div class="topic-metadata">

**Author:** [@dgleich](https://discourse.julialang.org/u/dgleich)\
**Replies:** 1\
**Last updated:** [June 7, 2021, 4:35pm UTC](https://discourse.julialang.org/t/common-lapack-blas-utility-functions/62530 "2021-06-07T16:35:32Z")

</div>

LAPACK and Blas have all these handy little routines like dlascl - scale an array between two normalized quantities handling overflow/underflow/etc. # \_dlascl(from, to, x) # This will compute x .\*= x (to/from) and hand…

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

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