# General Usage

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

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

**Page:** 377

---

## [SymPy undefined behavior](https://discourse.julialang.org/t/sympy-undefined-behavior/89432)

<div class="topic-metadata">

**Author:** [@mendeli](https://discourse.julialang.org/u/mendeli)\
**Replies:** 3\
**Last updated:** [October 28, 2022, 12:59pm UTC](https://discourse.julialang.org/t/sympy-undefined-behavior/89432 "2022-10-28T12:59:06Z")

</div>

Being relatively new to Julia, I wrote something like the code below and stumbled on undefined behavior. Since the code below does not use the correct expr.subs() syntax, shouldn’t it issue an error message or warning? T…

---

## [Memory Leak Using OrdinaryDiffEq and Zygote on a HPC Cluster](https://discourse.julialang.org/t/memory-leak-using-ordinarydiffeq-and-zygote-on-a-hpc-cluster/89440)

<div class="topic-metadata">

**Author:** [@alistair.white](https://discourse.julialang.org/u/alistair.white)\
**Replies:** 0\
**Last updated:** [October 28, 2022, 10:26am UTC](https://discourse.julialang.org/t/memory-leak-using-ordinarydiffeq-and-zygote-on-a-hpc-cluster/89440 "2022-10-28T10:26:22Z")

</div>

While attempting to train some neural differential equations on a HPC cluster, I’ve been getting some unexpected OOM errors from Slurm. Here’s a MWE: GC.enable\_logging(true) # Uncomment these lines if running in a Dock…

---

## [Unitful.jl Molarity Calculation Question](https://discourse.julialang.org/t/unitful-jl-molarity-calculation-question/89372)

<div class="topic-metadata">

**Author:** [@brotherjack](https://discourse.julialang.org/u/brotherjack)\
**Replies:** 4\
**Last updated:** [October 28, 2022, 12:42pm UTC](https://discourse.julialang.org/t/unitful-jl-molarity-calculation-question/89372 "2022-10-28T12:42:58Z")

</div>

So, I’ve used Unitful a little bit and I like the library, but there is one oddity I’ve noticed with the Moriarty unit, at least in v1.11.0. If you enter this… 1u"mol/L" \* 20u"L" You get… 20 mol OK, that’s what I…

---

## [Environment Variables in interactive window](https://discourse.julialang.org/t/environment-variables-in-interactive-window/89349)

<div class="topic-metadata">

**Author:** [@this\_josh](https://discourse.julialang.org/u/this_josh)\
**Replies:** 11\
**Last updated:** [October 28, 2022, 12:29pm UTC](https://discourse.julialang.org/t/environment-variables-in-interactive-window/89349 "2022-10-28T12:29:16Z")

</div>

In my .zshrc startup script I set some environment variables export FOO="BAR" which I’d like to use in Julia. From a terminal I get julia\> ENV\["FOO"\] "BAR" But from a VS code interactive session using shift+enter # f…

---

## [Import graphs in graphml format](https://discourse.julialang.org/t/import-graphs-in-graphml-format/89436)

<div class="topic-metadata">

**Author:** [@ahmad88](https://discourse.julialang.org/u/ahmad88)\
**Replies:** 1\
**Last updated:** [October 28, 2022, 11:14am UTC](https://discourse.julialang.org/t/import-graphs-in-graphml-format/89436 "2022-10-28T11:14:13Z")

</div>

I have more than 700 graphs saved in textfiles in graphml format, I want to import those graphs to my julia code get the edge list from each graph and run a specific code for each graph and save the output for each graph…

---

## [Switching data type in a vector](https://discourse.julialang.org/t/switching-data-type-in-a-vector/89423)

<div class="topic-metadata">

**Author:** [@Phuntsho](https://discourse.julialang.org/u/Phuntsho)\
**Replies:** 2\
**Last updated:** [October 28, 2022, 7:08am UTC](https://discourse.julialang.org/t/switching-data-type-in-a-vector/89423 "2022-10-28T07:08:33Z")

</div>

I have a vector V::Vector{Tuple{Int64, Int64}} but sometimes one of the second entries becomes Float64. I don’t want to make it V::Vector{Tuple{Int64, Float64}} or V::Vector{Tuple{Int64, Any}} for performance. Is there a…

---

## [Can typeof() return an alias?](https://discourse.julialang.org/t/can-typeof-return-an-alias/89412)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 4\
**Last updated:** [October 28, 2022, 6:58am UTC](https://discourse.julialang.org/t/can-typeof-return-an-alias/89412 "2022-10-28T06:58:11Z")

</div>

Is it possible to have a type alias where typeof() returns the alias rather than the base type e.g. XString = String x::XString = "ab" typeof(x) # gives XString not String Use Case The below code produc…

---

## [Mosaic plot in Makie](https://discourse.julialang.org/t/mosaic-plot-in-makie/89425)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 3\
**Last updated:** [October 28, 2022, 5:25am UTC](https://discourse.julialang.org/t/mosaic-plot-in-makie/89425 "2022-10-28T05:25:03Z")

</div>

Does Makie have Mosaic plots?

---

## [How to capture stdout from one Thread?](https://discourse.julialang.org/t/how-to-capture-stdout-from-one-thread/45812)

<div class="topic-metadata">

**Author:** [@danspielman](https://discourse.julialang.org/u/danspielman)\
**Replies:** 5\
**Last updated:** [October 28, 2022, 4:25am UTC](https://discourse.julialang.org/t/how-to-capture-stdout-from-one-thread/45812 "2022-10-28T04:25:27Z")

</div>

I would like to capture the stdout from one thread out of many that are running, and save it in a string. Does anyone know how to do this thread-by-thread? I can at least know the id of the thread I care about. redire…

---

## [Understanding type instability related to StructArrays](https://discourse.julialang.org/t/understanding-type-instability-related-to-structarrays/89413)

<div class="topic-metadata">

**Author:** [@jsjie](https://discourse.julialang.org/u/jsjie)\
**Replies:** 1\
**Last updated:** [October 28, 2022, 1:39am UTC](https://discourse.julialang.org/t/understanding-type-instability-related-to-structarrays/89413 "2022-10-28T01:39:41Z")

</div>

A minimun example in REPL: julia\> using StructArrays julia\> mutable struct Foo foo::Int end julia\> mutable struct Bar bar::StructArray{Foo} end julia\> bar = Bar(StructArray(\[Foo(1)…

---

## [Is there way to do math on type parameters for function defintions](https://discourse.julialang.org/t/is-there-way-to-do-math-on-type-parameters-for-function-defintions/89400)

<div class="topic-metadata">

**Author:** [@prittjam](https://discourse.julialang.org/u/prittjam)\
**Replies:** 2\
**Last updated:** [October 27, 2022, 9:16pm UTC](https://discourse.julialang.org/t/is-there-way-to-do-math-on-type-parameters-for-function-defintions/89400 "2022-10-27T21:16:53Z")

</div>

I would like to do something like this, pt\_to\_line\_dist(x::SVector{N-1},l::SVector{N}) where N \<: UInt = print("hi") Is it possible?

---

## [The huge difference of two functions for the same goal inside and outside of function](https://discourse.julialang.org/t/the-huge-difference-of-two-functions-for-the-same-goal-inside-and-outside-of-function/89389)

<div class="topic-metadata">

**Author:** [@swish47](https://discourse.julialang.org/u/swish47)\
**Replies:** 5\
**Last updated:** [October 27, 2022, 8:22pm UTC](https://discourse.julialang.org/t/the-huge-difference-of-two-functions-for-the-same-goal-inside-and-outside-of-function/89389 "2022-10-27T20:22:49Z")

</div>

There are two functions for computing the same array. However, there is a weird thing on time elapse. Inside function: using FLoops ot=collect(range(start=-3,length=3600\*4,stop=3)); st=rand(1000000); sgf::Vector{Comple…

---

## [How do you export a binary operator from a module?](https://discourse.julialang.org/t/how-do-you-export-a-binary-operator-from-a-module/89376)

<div class="topic-metadata">

**Author:** [@prittjam](https://discourse.julialang.org/u/prittjam)\
**Replies:** 2\
**Last updated:** [October 27, 2022, 8:01pm UTC](https://discourse.julialang.org/t/how-do-you-export-a-binary-operator-from-a-module/89376 "2022-10-27T20:01:37Z")

</div>

I have the following defined, homogenize(x) = push(x,one(eltype(x))) mixed\_matvec\_multiplication(A::AbstractArray,x::AbstractVector) = A\*homogenize(x) ⊛(A,x) = mixed\_matvec\_multiplication(A,x) I can’t seem to export …

---

## [Plotting on an unstructured grid](https://discourse.julialang.org/t/plotting-on-an-unstructured-grid/89316)

<div class="topic-metadata">

**Author:** [@HMegh](https://discourse.julialang.org/u/HMegh)\
**Replies:** 2\
**Last updated:** [October 27, 2022, 6:53pm UTC](https://discourse.julialang.org/t/plotting-on-an-unstructured-grid/89316 "2022-10-27T18:53:38Z")

</div>

I have points \\{(x\_i,y\_i)\\}\_{i=1}^n and values \\{z\_i\\}\_{i=1}^n and I wish to plot them as a surface plot. However, when using surface(x,y,z) I get the following error \*\*\* IDENTICAL DATA POINTS. NDP = 3772 IP1 =…

---

## [Getting UndefVarError even though variables are defined](https://discourse.julialang.org/t/getting-undefvarerror-even-though-variables-are-defined/89383)

<div class="topic-metadata">

**Author:** [@Max\_A](https://discourse.julialang.org/u/Max_A)\
**Replies:** 5\
**Last updated:** [October 27, 2022, 5:45pm UTC](https://discourse.julialang.org/t/getting-undefvarerror-even-though-variables-are-defined/89383 "2022-10-27T17:45:33Z")

</div>

Hi all, I am using the following code to solve an ODE. I defined my variables but I am still getting an UndefVarError. Any help here? v\_x(x, y, t) = -sin(pi \* y) \* cos(pi \* t / 5) v\_y(x, y, t) = sin(pi \* x) \* cos(pi …

---

## [Is there a built-in function to get the size of a folder?](https://discourse.julialang.org/t/is-there-a-built-in-function-to-get-the-size-of-a-folder/76762)

<div class="topic-metadata">

**Author:** [@feanor12](https://discourse.julialang.org/u/feanor12)\
**Replies:** 7\
**Last updated:** [October 27, 2022, 5:28pm UTC](https://discourse.julialang.org/t/is-there-a-built-in-function-to-get-the-size-of-a-folder/76762 "2022-10-27T17:28:02Z")

</div>

I saw that there are stat and filesize, but I don’t see a recursive option. Is there a small package or another function that can give me the cumulative size of all files in a folder? Another thing I am not sure about …

---

## [Flushing output for Logging immediately without buffering](https://discourse.julialang.org/t/flushing-output-for-logging-immediately-without-buffering/26800)

<div class="topic-metadata">

**Author:** [@scottstanie](https://discourse.julialang.org/u/scottstanie)\
**Replies:** 4\
**Last updated:** [October 26, 2022, 5:24pm UTC](https://discourse.julialang.org/t/flushing-output-for-logging-immediately-without-buffering/26800 "2022-10-26T17:24:26Z")

</div>

I’ve got a problem similar to this question: How to flush stdout where I want to log output from a long running script, usually to stderr, and check on it with tail -f If I run it and redirect the output to a file wit…

---

## [Plots Broken on Mac](https://discourse.julialang.org/t/plots-broken-on-mac/65551)

<div class="topic-metadata">

**Author:** [@RafGeo](https://discourse.julialang.org/u/RafGeo)\
**Replies:** 9\
**Last updated:** [August 11, 2021, 12:23am UTC](https://discourse.julialang.org/t/plots-broken-on-mac/65551 "2021-08-11T00:23:06Z")

</div>

After woking on my project i saved, quit everything and updated to the new version of Mac Big Sur 11.5.1. Once i got the next day Julia refused to plot anything. While in REPL, typing the command julia\> plot(collect(1:…

---

## [Why are macros re-pre-compiled](https://discourse.julialang.org/t/why-are-macros-re-pre-compiled/89319)

<div class="topic-metadata">

**Author:** [@tfiers](https://discourse.julialang.org/u/tfiers)\
**Replies:** 4\
**Last updated:** [October 27, 2022, 3:39pm UTC](https://discourse.julialang.org/t/why-are-macros-re-pre-compiled/89319 "2022-10-27T15:39:26Z")

</div>

I am trying to improve load time of a package of mine. I found that a lot of this time was spent type-inferring macro-related functions, for example: Through using @match (Match.jl): Match.gen\_match\_expr(::String, :…

---

## [libGL error: MESA... after (unintended) Plots update](https://discourse.julialang.org/t/libgl-error-mesa-after-unintended-plots-update/48265)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 8\
**Last updated:** [October 27, 2022, 3:19pm UTC](https://discourse.julialang.org/t/libgl-error-mesa-after-unintended-plots-update/48265 "2022-10-27T15:19:08Z")

</div>

Today, after installing some new packages (Ipopt and JuMP), for some reason Plots got updated as well. After that, every time I plot something, I get these errors. Any tip on how to get rid of them? (the plots themselves…

---

## [Slowdown due to subnormal float, coming from neural net training](https://discourse.julialang.org/t/slowdown-due-to-subnormal-float-coming-from-neural-net-training/89286)

<div class="topic-metadata">

**Author:** [@Fabrice\_Rosay](https://discourse.julialang.org/u/Fabrice_Rosay)\
**Replies:** 20\
**Last updated:** [October 27, 2022, 11:03am UTC](https://discourse.julialang.org/t/slowdown-due-to-subnormal-float-coming-from-neural-net-training/89286 "2022-10-27T11:03:04Z")

</div>

Here is a minimal working example function mygemavx!(C, A, B, bias) @turbo for m ∈ axes(A,1) Cmk = bias\[m\] for k ∈ axes(A,2) Cmk += A\[m,k\] \* B\[k\] end C\[m\] = Cmk end C end A1=zeros…

---

## [PythonCall - from X import Y](https://discourse.julialang.org/t/pythoncall-from-x-import-y/89353)

<div class="topic-metadata">

**Author:** [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Replies:** 3\
**Last updated:** [October 27, 2022, 11:20am UTC](https://discourse.julialang.org/t/pythoncall-from-x-import-y/89353 "2022-10-27T11:20:44Z")

</div>

When I want to import a module X, I can call using PythonCall pyimport("X") I want to import Image from PIL, which in python is done by from PIL import Image However, I can not access Image from PIL directly: \>\>\> i…

---

## [Does Julia's speed get slower over time in REPL?](https://discourse.julialang.org/t/does-julias-speed-get-slower-over-time-in-repl/89066)

<div class="topic-metadata">

**Author:** [@tiZ](https://discourse.julialang.org/u/tiZ)\
**Replies:** 4\
**Last updated:** [October 27, 2022, 4:25am UTC](https://discourse.julialang.org/t/does-julias-speed-get-slower-over-time-in-repl/89066 "2022-10-27T04:25:36Z")

</div>

When I’m on a Julia REPL that has been running for a while, I find that julia will slow down, but if I restart the REPL, the speed returns to normal. For example, I have a function denoted f(x), that takes 15 minutes in…

---

## [Shuffling multiple N-arrays over a given dimension](https://discourse.julialang.org/t/shuffling-multiple-n-arrays-over-a-given-dimension/59206)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 2\
**Last updated:** [October 27, 2022, 8:19am UTC](https://discourse.julialang.org/t/shuffling-multiple-n-arrays-over-a-given-dimension/59206 "2022-10-27T08:19:51Z")

</div>

Sometimes we have the need to shuffle a given list of arrays over a given dimension, but keeping the relative order on that dimension ( e.g. when we have in machine learning to shuffle features and label matrices over th…

---

## [Error in DynamicPolynomials?](https://discourse.julialang.org/t/error-in-dynamicpolynomials/89196)

<div class="topic-metadata">

**Author:** [@mhar](https://discourse.julialang.org/u/mhar)\
**Replies:** 1\
**Last updated:** [October 24, 2022, 4:31pm UTC](https://discourse.julialang.org/t/error-in-dynamicpolynomials/89196 "2022-10-24T16:31:56Z")

</div>

The following code used to work, but I’m having an issue with it now: using DynamicPolynomials @polyvar var1 var2 v = randn(3); \_mons = monomials(\[var1, var2\], length(v) - 1); p = sum(\_mons .\* v) p + p ERROR: AssertionE…

---

## [Initialize nested arrays](https://discourse.julialang.org/t/initialize-nested-arrays/89284)

<div class="topic-metadata">

**Author:** [@ManuelFossa](https://discourse.julialang.org/u/ManuelFossa)\
**Replies:** 4\
**Last updated:** [October 27, 2022, 5:32am UTC](https://discourse.julialang.org/t/initialize-nested-arrays/89284 "2022-10-27T05:32:44Z")

</div>

I need to initialize a Matrix, containing Matrices, the latter containing a Vector or Matrices. I did something like this: sizeMat11 = 2 sizeMat12 = 3 sizeMat21 = 5 sizeMat22 = 6 sizeVec31 = 9 struct SomeStruct x:…

---

## [Most efficient way to add new columns in each SubDataFrame of a GroupDataFrame](https://discourse.julialang.org/t/most-efficient-way-to-add-new-columns-in-each-subdataframe-of-a-groupdataframe/89272)

<div class="topic-metadata">

**Author:** [@phantom](https://discourse.julialang.org/u/phantom)\
**Replies:** 6\
**Last updated:** [October 27, 2022, 2:08am UTC](https://discourse.julialang.org/t/most-efficient-way-to-add-new-columns-in-each-subdataframe-of-a-groupdataframe/89272 "2022-10-27T02:08:14Z")

</div>

Sorry kind of a beginners question again. Suppose I have a large GroupDataFrame and I would like to add columns to each SubDataFrame in the Group. function build(GDF) for k = eachindex(GDF) GDF\[k\].newcol1 = fun…

---

## [Sqrt not giving the correct value](https://discourse.julialang.org/t/sqrt-not-giving-the-correct-value/89318)

<div class="topic-metadata">

**Author:** [@Giulianno\_G](https://discourse.julialang.org/u/Giulianno_G)\
**Replies:** 5\
**Last updated:** [October 26, 2022, 8:28pm UTC](https://discourse.julialang.org/t/sqrt-not-giving-the-correct-value/89318 "2022-10-26T20:28:57Z")

</div>

Hello, I’m new to Julia and I was trying to use for Fermat Factoring problem I’m having issues with the sqrt not returning the correct value function fermat(n::Int64) x = isqrt(n); y = 0.1 while y%1 != 0 …

---

## [\`cond\` and \`condskeel\`](https://discourse.julialang.org/t/cond-and-condskeel/89328)

<div class="topic-metadata">

**Author:** [@nchisholm](https://discourse.julialang.org/u/nchisholm)\
**Replies:** 1\
**Last updated:** [October 26, 2022, 8:28pm UTC](https://discourse.julialang.org/t/cond-and-condskeel/89328 "2022-10-26T20:28:00Z")

</div>

I am wondering about the usage of cond versus condskeel. I am familiar with the condition number, but not as much with the Skeel condition number. I have found that the two functions generally produce numbers of the sa…

---

## [Adding a function nthcomb() to Combinatorics.jl](https://discourse.julialang.org/t/adding-a-function-nthcomb-to-combinatorics-jl/89326)

<div class="topic-metadata">

**Author:** [@ajloza](https://discourse.julialang.org/u/ajloza)\
**Replies:** 2\
**Last updated:** [October 26, 2022, 8:01pm UTC](https://discourse.julialang.org/t/adding-a-function-nthcomb-to-combinatorics-jl/89326 "2022-10-26T20:01:57Z")

</div>

I recently had a project that required writing code for generating Nth lexicographic combinations of size k. Combinatorics.jl has nthperm, but not the equivalent for combinations. If there is interest in adding this func…

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

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