# General Usage

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

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

**Page:** 370

---

## [How to consider the timezone in unix2datetime?](https://discourse.julialang.org/t/how-to-consider-the-timezone-in-unix2datetime/90179)

<div class="topic-metadata">

**Author:** [@marllos](https://discourse.julialang.org/u/marllos)\
**Replies:** 9\
**Last updated:** [November 14, 2022, 2:49pm UTC](https://discourse.julialang.org/t/how-to-consider-the-timezone-in-unix2datetime/90179 "2022-11-14T14:49:17Z")

</div>

Hello everyone. In the code below my time zone is not being considered in dt. Please, how to make it be considered? using Dates function test() f = "local/file" u = mtime(f) unix2datetime(u) # three hours too long …

---

## [Threads (including Polyester) question](https://discourse.julialang.org/t/threads-including-polyester-question/90233)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 1\
**Last updated:** [November 14, 2022, 1:10pm UTC](https://discourse.julialang.org/t/threads-including-polyester-question/90233 "2022-11-14T13:10:15Z")

</div>

I get worse timing with threads (in the best case), and also different values, not pi, or at best if I’m lucky. I had already sped that benchmark up more than 5x, and curious if threading in some form could make even bet…

---

## [Metaprogramming: Defining new methods to existing function](https://discourse.julialang.org/t/metaprogramming-defining-new-methods-to-existing-function/90239)

<div class="topic-metadata">

**Author:** [@HashBrown](https://discourse.julialang.org/u/HashBrown)\
**Replies:** 0\
**Last updated:** [November 14, 2022, 2:24pm UTC](https://discourse.julialang.org/t/metaprogramming-defining-new-methods-to-existing-function/90239 "2022-11-14T14:24:15Z")

</div>

I want to create a macro that adds methods to a function for particular types and creates some global variables (I know not the best practice but this is what I am trying). It is not difficult for me to do this if the m…

---

## [Understanding Shuffle in CUDA](https://discourse.julialang.org/t/understanding-shuffle-in-cuda/90235)

<div class="topic-metadata">

**Author:** [@nethaji8](https://discourse.julialang.org/u/nethaji8)\
**Replies:** 1\
**Last updated:** [November 14, 2022, 1:43pm UTC](https://discourse.julialang.org/t/understanding-shuffle-in-cuda/90235 "2022-11-14T13:43:43Z")

</div>

Hi everyone, I am trying to use shuffle in a Cuda kernel, can someone explain to me how to use CUDA.shfl\_sync, CUDA.shfl\_up\_sync, CUDA.shfl\_down\_sync, CUDA.shfl\_xor\_sync with a simple example…? It’s not clear in the do…

---

## [How to calcule the mean of values considering their tuples of another value:](https://discourse.julialang.org/t/how-to-calcule-the-mean-of-values-considering-their-tuples-of-another-value/89974)

<div class="topic-metadata">

**Author:** [@Juan\_Mac\_Donagh](https://discourse.julialang.org/u/Juan_Mac_Donagh)\
**Replies:** 6\
**Last updated:** [November 14, 2022, 12:02pm UTC](https://discourse.julialang.org/t/how-to-calcule-the-mean-of-values-considering-their-tuples-of-another-value/89974 "2022-11-14T12:02:18Z")

</div>

Hi all, I have an issue that I can’t figure out how to solve it: I have a df that stores two columns that look like this: df.scores1 = \[\[1,2,2,3,5,6,1,2,9,2,1,6,4,2\]\] df.normalized\_len = \[\[0,0,0.1,0.1,0.2,0.3,0.4,0.5,…

---

## [\`empty!\` and garbage collection for \`Tuple\`, \`NamedTuple\`, and \`Pairs\`](https://discourse.julialang.org/t/empty-and-garbage-collection-for-tuple-namedtuple-and-pairs/90214)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 2\
**Last updated:** [November 14, 2022, 7:50am UTC](https://discourse.julialang.org/t/empty-and-garbage-collection-for-tuple-namedtuple-and-pairs/90214 "2022-11-14T07:50:39Z")

</div>

I just started learning garbage collection, so this question may not be well-proposed, please bear with me if I am wrong. AFAIU, you can empty! a Vector or Dict so that what are inside them will be garbage collected in …

---

## [Syntax error when interpolating a quoted operator into a quoted expression](https://discourse.julialang.org/t/syntax-error-when-interpolating-a-quoted-operator-into-a-quoted-expression/90217)

<div class="topic-metadata">

**Author:** [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Replies:** 3\
**Last updated:** [November 14, 2022, 2:52am UTC](https://discourse.julialang.org/t/syntax-error-when-interpolating-a-quoted-operator-into-a-quoted-expression/90217 "2022-11-14T02:52:56Z")

</div>

I thought I understood how expression interpolation worked. This works as expected: julia\> sym = :a :a julia\> :(b \> $sym) :(b \> a) But when I try to interpolate an operator into an expression, I get a weird syntax err…

---

## [How to call multi-dimensional vector value Vectorized Cubature numerical integration?](https://discourse.julialang.org/t/how-to-call-multi-dimensional-vector-value-vectorized-cubature-numerical-integration/90200)

<div class="topic-metadata">

**Author:** [@swish47](https://discourse.julialang.org/u/swish47)\
**Replies:** 2\
**Last updated:** [November 13, 2022, 9:16pm UTC](https://discourse.julialang.org/t/how-to-call-multi-dimensional-vector-value-vectorized-cubature-numerical-integration/90200 "2022-11-13T21:16:56Z")

</div>

As the topic, I want to use parallelized numerical integration. However, since the special receives of hcubature with vector-valued integrands, and I don’t know how to set each components of v respectively, there is a pr…

---

## [Trouble using plots (on macOS)](https://discourse.julialang.org/t/trouble-using-plots-on-macos/90182)

<div class="topic-metadata">

**Author:** [@Schneeschaufel](https://discourse.julialang.org/u/Schneeschaufel)\
**Replies:** 18\
**Last updated:** [November 13, 2022, 9:15pm UTC](https://discourse.julialang.org/t/trouble-using-plots-on-macos/90182 "2022-11-13T21:15:49Z")

</div>

And now the next blow I realised pyplot() wouldn’t work on my OSX Ventura. Recap: Using Plots; pyplot() works on Linux using Plots without pyplot() works on my Ventura (e.g. import Plots as plt; plt.rand(23)) using Pl…

---

## [Lambdify getting error if expression is function of time](https://discourse.julialang.org/t/lambdify-getting-error-if-expression-is-function-of-time/90118)

<div class="topic-metadata">

**Author:** [@Starpower\_Power](https://discourse.julialang.org/u/Starpower_Power)\
**Replies:** 6\
**Last updated:** [November 13, 2022, 8:55pm UTC](https://discourse.julialang.org/t/lambdify-getting-error-if-expression-is-function-of-time/90118 "2022-11-13T20:55:22Z")

</div>

using SymPy using PyCall sp = pyimport("sympy") @vars t x = sp.Function("x")(t) y = sp.Function("y")(t) z = x^2+y^2 hz = lambdify(z,(x,y)) # hz = lambdify(z,(x,y)) hz(1,1)

---

## [Convert Array to DataFrame](https://discourse.julialang.org/t/convert-array-to-dataframe/90163)

<div class="topic-metadata">

**Author:** [@Mastomaki](https://discourse.julialang.org/u/Mastomaki)\
**Replies:** 11\
**Last updated:** [November 13, 2022, 2:37pm UTC](https://discourse.julialang.org/t/convert-array-to-dataframe/90163 "2022-11-13T14:37:54Z")

</div>

Dear Friends, I would like to convert a multi-dimensional array to DataFrame. For example a = \[0 1;2 3\] Expected result: 4×3 DataFrame Row │ index1 index2 value │ Int64 Int64 Int64 ─────┼────────…

---

## [A Tree? Multi-dimensional Array? hmm](https://discourse.julialang.org/t/a-tree-multi-dimensional-array-hmm/89969)

<div class="topic-metadata">

**Author:** [@theboiwholived](https://discourse.julialang.org/u/theboiwholived)\
**Replies:** 9\
**Last updated:** [November 13, 2022, 11:02am UTC](https://discourse.julialang.org/t/a-tree-multi-dimensional-array-hmm/89969 "2022-11-13T11:02:25Z")

</div>

Hey all, could really use your expertise in determining if what i need here is a tree… and how i would go about doing that At the moment my code basically determines out the difference of all trades between currencies. …

---

## [Why do functions whose arguments are named tuples fail when one element of the named tuple has type Any?](https://discourse.julialang.org/t/why-do-functions-whose-arguments-are-named-tuples-fail-when-one-element-of-the-named-tuple-has-type-any/90172)

<div class="topic-metadata">

**Author:** [@Soldalma](https://discourse.julialang.org/u/Soldalma)\
**Replies:** 3\
**Last updated:** [November 13, 2022, 7:39am UTC](https://discourse.julialang.org/t/why-do-functions-whose-arguments-are-named-tuples-fail-when-one-element-of-the-named-tuple-has-type-any/90172 "2022-11-13T07:39:00Z")

</div>

I defined a function that prints the elements of a named tuple. I do not know the type of the second element of the named tuple, so I set it to Any. function foo(nt::NamedTuple{(:A, :V), Tuple{String, Any}}) printl…

---

## [Tricky interpolation issue](https://discourse.julialang.org/t/tricky-interpolation-issue/90142)

<div class="topic-metadata">

**Author:** [@ejlongman](https://discourse.julialang.org/u/ejlongman)\
**Replies:** 6\
**Last updated:** [November 13, 2022, 4:22am UTC](https://discourse.julialang.org/t/tricky-interpolation-issue/90142 "2022-11-13T04:22:23Z")

</div>

Hi All, I am trying to create a function that turns a shorter vector (len nk) into a longer vector (len nkp). For example, 1x10 would become 1x20. I’m running into an issue with indexing. I see why mine does not work, b…

---

## [Simulate manual memory management to reduce RAM usage?](https://discourse.julialang.org/t/simulate-manual-memory-management-to-reduce-ram-usage/67281)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 3\
**Last updated:** [November 13, 2022, 1:17am UTC](https://discourse.julialang.org/t/simulate-manual-memory-management-to-reduce-ram-usage/67281 "2022-11-13T01:17:06Z")

</div>

Julia can avoid unnecessary GC by allocating immutable objects on the stack, but I’m wondering if it’s possible to push further: for heap-allocated local objects that do not “escape” the function (e.g. returned or passed…

---

## [Graph compile issue](https://discourse.julialang.org/t/graph-compile-issue/90173)

<div class="topic-metadata">

**Author:** [@ejlongman](https://discourse.julialang.org/u/ejlongman)\
**Replies:** 3\
**Last updated:** [November 13, 2022, 12:08am UTC](https://discourse.julialang.org/t/graph-compile-issue/90173 "2022-11-13T00:08:23Z")

</div>

I’m suddenly unable to graph without getting an error. when I try re-compiling GR. When I run: using Pkg; Pkg.build("GR") I get: Building GR → \`~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/c98aea69666…

---

## [Macro question (create variables)](https://discourse.julialang.org/t/macro-question-create-variables/90160)

<div class="topic-metadata">

**Author:** [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Replies:** 4\
**Last updated:** [November 12, 2022, 9:09pm UTC](https://discourse.julialang.org/t/macro-question-create-variables/90160 "2022-11-12T21:09:44Z")

</div>

Wanted: a macro @moo a b which is in effect equivalent to a = foo("a") b = foo("b") and actually I got it: foo(x) = "$x-$x" macro moo(args...) for x in args xs = string(x) @eval eval(Meta.parse…

---

## [Unreasonable slow speed in numerical integration](https://discourse.julialang.org/t/unreasonable-slow-speed-in-numerical-integration/89910)

<div class="topic-metadata">

**Author:** [@swish47](https://discourse.julialang.org/u/swish47)\
**Replies:** 16\
**Last updated:** [November 12, 2022, 7:15pm UTC](https://discourse.julialang.org/t/unreasonable-slow-speed-in-numerical-integration/89910 "2022-11-12T19:15:45Z")

</div>

I hope to compute an intergration of a function with intergration inside, however the efficiency is extremely slow. using HCubature,QuadGK,NumericalIntegration spinonenergy(kx::Float64,ky::Float64)::Float64=2\*(cos(kx)+c…

---

## [Setting fish shell environment variables correctly for julia shell](https://discourse.julialang.org/t/setting-fish-shell-environment-variables-correctly-for-julia-shell/90158)

<div class="topic-metadata">

**Author:** [@floswald](https://discourse.julialang.org/u/floswald)\
**Replies:** 2\
**Last updated:** [November 12, 2022, 5:01pm UTC](https://discourse.julialang.org/t/setting-fish-shell-environment-variables-correctly-for-julia-shell/90158 "2022-11-12T17:01:39Z")

</div>

I need to come back to an old question. I am unable to see my system ENV variables in the julia shell. I set the env vars in fish with set -U key value like so: floswald@PTL11077 ~\> set -U JULIA\_VAR howdie floswald@PTL…

---

## [How to plot multiple interval notations with plots layout in Julia?](https://discourse.julialang.org/t/how-to-plot-multiple-interval-notations-with-plots-layout-in-julia/90166)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 0\
**Last updated:** [November 12, 2022, 3:57pm UTC](https://discourse.julialang.org/t/how-to-plot-multiple-interval-notations-with-plots-layout-in-julia/90166 "2022-11-12T15:57:27Z")

</div>

Hi all, I have this code to plot interval notation: using Plots, LaTeXStrings, Plots.PlotMeasures f(x) = 0.1 plot(\[0.3,0.9\],\[0,0\],arrow=true,color=:black,linewidth=2, xticks=false, yticks=false, ylims=(0,1), showaxis=…

---

## [Is there a way to see the maximum working memory of my code?](https://discourse.julialang.org/t/is-there-a-way-to-see-the-maximum-working-memory-of-my-code/76024)

<div class="topic-metadata">

**Author:** [@StevenWhitaker](https://discourse.julialang.org/u/StevenWhitaker)\
**Replies:** 2\
**Last updated:** [November 12, 2022, 2:58pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-see-the-maximum-working-memory-of-my-code/76024 "2022-11-12T14:58:06Z")

</div>

@time gives the total memory allocation of a piece of code, but because of garbage collection I can have code that allocates much more memory than my system has RAM. Is there a way to see the maximum working memory of a …

---

## [How to draw tangent line for my second plot with MTH229?](https://discourse.julialang.org/t/how-to-draw-tangent-line-for-my-second-plot-with-mth229/90159)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 2\
**Last updated:** [November 12, 2022, 2:43pm UTC](https://discourse.julialang.org/t/how-to-draw-tangent-line-for-my-second-plot-with-mth229/90159 "2022-11-12T14:43:13Z")

</div>

Hi all, I want to plot tangent lines to my second plot below (the g(x) function), but I do not know how. I am using tangent function from MTH229 package. Here is my code: using Plots, LaTeXStrings, MTH229 gr() f(x) =…

---

## [How to produce nice boxplots](https://discourse.julialang.org/t/how-to-produce-nice-boxplots/9345)

<div class="topic-metadata">

**Author:** [@burfel](https://discourse.julialang.org/u/burfel)\
**Replies:** 12\
**Last updated:** [November 12, 2022, 10:03am UTC](https://discourse.julialang.org/t/how-to-produce-nice-boxplots/9345 "2022-11-12T10:03:56Z")

</div>

Does anyone know how to produce nice boxplots out of a dataframe of this form? │ Row │ Smarcc1 │ Socs3 │ Sox1 │ Sox2 │ Stat3 │ T │ Tbx3 │ Tcf7l1 │ ├─────┼─────────┼─────────┼──────┼─────────┼─────────┼─────…

---

## [Help with CI not running](https://discourse.julialang.org/t/help-with-ci-not-running/90152)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 2\
**Last updated:** [November 12, 2022, 7:02am UTC](https://discourse.julialang.org/t/help-with-ci-not-running/90152 "2022-11-12T07:02:07Z")

</div>

When I started testing a package on Julia version 1, CI stopped running, with no apparent error message. Does anybody know what is going on here?

---

## [When to return NaN vs throw an Error?](https://discourse.julialang.org/t/when-to-return-nan-vs-throw-an-error/89587)

<div class="topic-metadata">

**Author:** [@Alec\_Loudenback](https://discourse.julialang.org/u/Alec_Loudenback)\
**Replies:** 17\
**Last updated:** [November 12, 2022, 4:23am UTC](https://discourse.julialang.org/t/when-to-return-nan-vs-throw-an-error/89587 "2022-11-12T04:23:12Z")

</div>

I have a function with a suggested PR to throw an error if the result would return a NaN. I am very much appreciative of someone opening a PR but I was looking for advice on the approach. I am unsure if it is better pac…

---

## [Freeing up the threads for multi-threading](https://discourse.julialang.org/t/freeing-up-the-threads-for-multi-threading/90097)

<div class="topic-metadata">

**Author:** [@Phuntsho](https://discourse.julialang.org/u/Phuntsho)\
**Replies:** 12\
**Last updated:** [November 11, 2022, 11:14pm UTC](https://discourse.julialang.org/t/freeing-up-the-threads-for-multi-threading/90097 "2022-11-11T23:14:51Z")

</div>

I use IJulia for interactive programming. I usually start with julia\> ENV\["JULIA\_NUM\_THREADS"\]=60 julia\> using IJulia julia\> notebook() From there I get a Jupyter environment where I can run programs like those given h…

---

## [ANN: CBOOCall](https://discourse.julialang.org/t/ann-cboocall/81420)

<div class="topic-metadata">

**Author:** [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Replies:** 3\
**Last updated:** [November 11, 2022, 7:29pm UTC](https://discourse.julialang.org/t/ann-cboocall/81420 "2022-11-11T19:29:53Z")

</div>

From the README of CBOOCall.jl: split(",", "a,b,c") is not really the right way to do it. split only works with strings, so it should be a class method. We should be able to do ",".split("a,b,c"). There’s even a mnem…

---

## [Efficient calculation of Mahalanobis distance](https://discourse.julialang.org/t/efficient-calculation-of-mahalanobis-distance/90121)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 5\
**Last updated:** [November 11, 2022, 7:18pm UTC](https://discourse.julialang.org/t/efficient-calculation-of-mahalanobis-distance/90121 "2022-11-11T19:18:57Z")

</div>

Hello, I would like to compute the following Mahalanobis distance for M samples \\{ x^i \\} with x^i \\in \\mathbb{R}^n d(x^i) = (x^i - \\mu)^\\top \\Sigma^{-1} (x^i - \\mu) where we don’t know \\Sigma but we only know a “squar…

---

## [Object-oriented syntax in julia](https://discourse.julialang.org/t/object-oriented-syntax-in-julia/90017)

<div class="topic-metadata">

**Author:** [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Replies:** 11\
**Last updated:** [November 11, 2022, 6:43pm UTC](https://discourse.julialang.org/t/object-oriented-syntax-in-julia/90017 "2022-11-11T18:43:05Z")

</div>

I learned and wrote some c++ code recently. Although I’m convinced that the whole system including like inheritance and modifiers (private vs public) is good, I do think the syntax foo.func(...) has some benefits. I kno…

---

## [Datetime difference](https://discourse.julialang.org/t/datetime-difference/90075)

<div class="topic-metadata">

**Author:** [@marllos](https://discourse.julialang.org/u/marllos)\
**Replies:** 4\
**Last updated:** [November 11, 2022, 6:19pm UTC](https://discourse.julialang.org/t/datetime-difference/90075 "2022-11-11T18:19:13Z")

</div>

Hello everyone. I know that for calculations, the difference between two datetimes is useful, when in form of seconds (or another unit). My question is: to get this difference in form of days H:M:S, do I need to write a…

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

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