# General Usage

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

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

**Page:** 337

---

## [Zygote gradient with custom type results in error](https://discourse.julialang.org/t/zygote-gradient-with-custom-type-results-in-error/93519)

<div class="topic-metadata">

**Author:** [@maxfreu](https://discourse.julialang.org/u/maxfreu)\
**Replies:** 2\
**Last updated:** [January 28, 2023, 12:59pm UTC](https://discourse.julialang.org/t/zygote-gradient-with-custom-type-results-in-error/93519 "2023-01-28T12:59:58Z")

</div>

Hi! I’m once more struggling with Zygote. I’m trying to maximize the kernel-correlation between two point sets in 2D. Imagine two scattered sets of points, calculate the distances between all points in one set to all poi…

---

## [@turbo macro giving slightly different results](https://discourse.julialang.org/t/turbo-macro-giving-slightly-different-results/93529)

<div class="topic-metadata">

**Author:** [@Shashank](https://discourse.julialang.org/u/Shashank)\
**Replies:** 6\
**Last updated:** [January 28, 2023, 10:37am UTC](https://discourse.julialang.org/t/turbo-macro-giving-slightly-different-results/93529 "2023-01-28T10:37:03Z")

</div>

I am trying to vectorize a loop, and adding the turbo gives slightly different results. The code does not rely on specific execution order as is the case with the example in the post below: I have pasted a MWE below. …

---

## [Symbolic matrix multiplication to polynomial](https://discourse.julialang.org/t/symbolic-matrix-multiplication-to-polynomial/93679)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 1\
**Last updated:** [January 28, 2023, 9:46am UTC](https://discourse.julialang.org/t/symbolic-matrix-multiplication-to-polynomial/93679 "2023-01-28T09:46:57Z")

</div>

Can I get a polynomial out of this? julia\> @variables x\[1:3\] y\[1:3\] 3-element Vector{Symbolics.Arr{Num}}: x\[1:3\] y\[1:3\] julia\> A = \[ 1 2 14 -5 2 -3 8 19 -2 \] 3×3 Mat…

---

## [Workflow for forking an environment](https://discourse.julialang.org/t/workflow-for-forking-an-environment/93660)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 7\
**Last updated:** [January 28, 2023, 8:14am UTC](https://discourse.julialang.org/t/workflow-for-forking-an-environment/93660 "2023-01-28T08:14:27Z")

</div>

I have a “main” environment that has a lot of the packages I use. Whenever I want to try something out, I go to a new directory and I want to use those packages plus a couple of other packages. I don’t want to reinstal…

---

## [Is accessing the \`instance\` field of a singleton type supported usage?](https://discourse.julialang.org/t/is-accessing-the-instance-field-of-a-singleton-type-supported-usage/93671)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 2\
**Last updated:** [January 28, 2023, 12:48am UTC](https://discourse.julialang.org/t/is-accessing-the-instance-field-of-a-singleton-type-supported-usage/93671 "2023-01-28T00:48:56Z")

</div>

The above technique is very useful in rare cases, but I wonder whether it’s supported? I don’t think it’s documented. For example; is the below guaranteed to work with future Julia versions? julia\> Tuple{Nothing, Noth…

---

## [Danger of deleting .julia?](https://discourse.julialang.org/t/danger-of-deleting-julia/93372)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 19\
**Last updated:** [January 27, 2023, 9:54pm UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372 "2023-01-27T21:54:42Z")

</div>

From thread Please refrain from doing such dangerous suggestions again. What is the danger of deleting .julia?

---

## [How to see every allocating function call?](https://discourse.julialang.org/t/how-to-see-every-allocating-function-call/93654)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 1\
**Last updated:** [January 27, 2023, 8:34pm UTC](https://discourse.julialang.org/t/how-to-see-every-allocating-function-call/93654 "2023-01-27T20:34:25Z")

</div>

Hello! I have a small simulation program I made in Julia. I have a main function, that when I call it, it runs the whole function - lets call it Main(). Is there a macro similar to @profile for getting how many allocs …

---

## [SymPy: solving a system of equation and replacing the values in the original expression](https://discourse.julialang.org/t/sympy-solving-a-system-of-equation-and-replacing-the-values-in-the-original-expression/93653)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 1\
**Last updated:** [January 27, 2023, 6:06pm UTC](https://discourse.julialang.org/t/sympy-solving-a-system-of-equation-and-replacing-the-values-in-the-original-expression/93653 "2023-01-27T18:06:45Z")

</div>

Hello, I am trying to replicate this (old) simple example on symbolically finding the resolution of a system of equations and replacing an expression with the founded numerical solution: I arrived to it by manually r…

---

## [Broadcasting string $variable](https://discourse.julialang.org/t/broadcasting-string-variable/93488)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 12\
**Last updated:** [January 27, 2023, 5:36pm UTC](https://discourse.julialang.org/t/broadcasting-string-variable/93488 "2023-01-27T17:36:05Z")

</div>

Is it possible to do something like this: ."X$(1:3)" and get @\_ "X$\_".(1:3) = \["X1","X2","X3"\] That is, can a vector variable within a string (via $) create a vector of strings. One for each element.

---

## [How can you modify global variables that are used in functions that are being called with ccall?](https://discourse.julialang.org/t/how-can-you-modify-global-variables-that-are-used-in-functions-that-are-being-called-with-ccall/93644)

<div class="topic-metadata">

**Author:** [@dmmpie](https://discourse.julialang.org/u/dmmpie)\
**Replies:** 4\
**Last updated:** [January 27, 2023, 5:33pm UTC](https://discourse.julialang.org/t/how-can-you-modify-global-variables-that-are-used-in-functions-that-are-being-called-with-ccall/93644 "2023-01-27T17:33:41Z")

</div>

From the documentation, I got that it’s possible to retrieve pointers to global variables by using the cglobal function. However, I wasn’t able to figure out from that how I can set the value of a global variable that is…

---

## [Hatched fill with Plots and GR](https://discourse.julialang.org/t/hatched-fill-with-plots-and-gr/43640)

<div class="topic-metadata">

**Author:** [@Tominapa](https://discourse.julialang.org/u/Tominapa)\
**Replies:** 4\
**Last updated:** [January 27, 2023, 5:14pm UTC](https://discourse.julialang.org/t/hatched-fill-with-plots-and-gr/43640 "2023-01-27T17:14:08Z")

</div>

I am working with a grouped bar graph with plots (and statsplots for the groupedbar() type) using GR as the backend. Here is an example of the type of graph I’m working with: using Plots using StatsPlots using Colors m…

---

## [Type stability bug in compiler?](https://discourse.julialang.org/t/type-stability-bug-in-compiler/93640)

<div class="topic-metadata">

**Author:** [@prittjam](https://discourse.julialang.org/u/prittjam)\
**Replies:** 13\
**Last updated:** [January 27, 2023, 5:08pm UTC](https://discourse.julialang.org/t/type-stability-bug-in-compiler/93640 "2023-01-27T17:08:45Z")

</div>

If I change a line of my code from cost = typemax(Float64) to cost::Float64 = typemax(Float64) then it becomes type stable (Any goes away). How can it be? The rest of the code is somewhat complicated, and I’m not su…

---

## [How do you reference a symbol from a specific module in a fortran shared object library with the ccall utility?](https://discourse.julialang.org/t/how-do-you-reference-a-symbol-from-a-specific-module-in-a-fortran-shared-object-library-with-the-ccall-utility/93580)

<div class="topic-metadata">

**Author:** [@dmmpie](https://discourse.julialang.org/u/dmmpie)\
**Replies:** 7\
**Last updated:** [January 27, 2023, 4:55pm UTC](https://discourse.julialang.org/t/how-do-you-reference-a-symbol-from-a-specific-module-in-a-fortran-shared-object-library-with-the-ccall-utility/93580 "2023-01-27T16:55:48Z")

</div>

When I have a “simple” fortran program with a singular module, I can reference the symbols simply by copying the symbol name from the result of the nm command: x = ccall((:\_\_mod\_julfort\_MOD\_dot, "path/to/my/lib.so"), …

---

## [Save results from nested loop with multiple iterations](https://discourse.julialang.org/t/save-results-from-nested-loop-with-multiple-iterations/93412)

<div class="topic-metadata">

**Author:** [@Filippati](https://discourse.julialang.org/u/Filippati)\
**Replies:** 4\
**Last updated:** [January 27, 2023, 4:31pm UTC](https://discourse.julialang.org/t/save-results-from-nested-loop-with-multiple-iterations/93412 "2023-01-27T16:31:11Z")

</div>

Hello everyone! I am writing a nested loop with a structure that can be summarised with something like this: D = \[\] horizon = 40 for i in 1:7 A = function1(data\[:, i\]) # A is a MxN matrix B = function2(data\[:, …

---

## [Not getting roots using "IntervalRootFinding.jl" package in Pluto.jl notebook](https://discourse.julialang.org/t/not-getting-roots-using-intervalrootfinding-jl-package-in-pluto-jl-notebook/93592)

<div class="topic-metadata">

**Author:** [@Kanishk](https://discourse.julialang.org/u/Kanishk)\
**Replies:** 3\
**Last updated:** [January 27, 2023, 3:46pm UTC](https://discourse.julialang.org/t/not-getting-roots-using-intervalrootfinding-jl-package-in-pluto-jl-notebook/93592 "2023-01-27T15:46:09Z")

</div>

Hello I am trying to find the roots of an equation using “IntervalRootFinding.jl” package in Pluto.jl notebook. But I am not able to get the roots; could you please check the code? using IntervalArithmetic, IntervalRoo…

---

## [Is there an operation like map but with accumulated state?](https://discourse.julialang.org/t/is-there-an-operation-like-map-but-with-accumulated-state/93581)

<div class="topic-metadata">

**Author:** [@taotree](https://discourse.julialang.org/u/taotree)\
**Replies:** 2\
**Last updated:** [January 27, 2023, 2:35pm UTC](https://discourse.julialang.org/t/is-there-an-operation-like-map-but-with-accumulated-state/93581 "2023-01-27T14:35:30Z")

</div>

I want to do a map operation, but have the previous calculated value available to each step. Or put another way, I want to run a foldl but output a collection of the results of each step. It seems like this should be a c…

---

## [Issue with Flux/Optimisers' freeze, thaw and adjust functions](https://discourse.julialang.org/t/issue-with-flux-optimisers-freeze-thaw-and-adjust-functions/93292)

<div class="topic-metadata">

**Author:** [@Naba7](https://discourse.julialang.org/u/Naba7)\
**Replies:** 12\
**Last updated:** [January 27, 2023, 2:22pm UTC](https://discourse.julialang.org/t/issue-with-flux-optimisers-freeze-thaw-and-adjust-functions/93292 "2023-01-27T14:22:19Z")

</div>

I am using Julia v1.7 and Flux as well as Optimisers are updated to date. I want to run the following code but getting a freeze not-defined error. julia\> m = (x = (\[1.0\], 2.0), y = \[3.0\]); julia\> s = Optimisers.setup(…

---

## [Franklin website background error on deployment](https://discourse.julialang.org/t/franklin-website-background-error-on-deployment/93629)

<div class="topic-metadata">

**Author:** [@raman\_kumar](https://discourse.julialang.org/u/raman_kumar)\
**Replies:** 1\
**Last updated:** [January 27, 2023, 2:06pm UTC](https://discourse.julialang.org/t/franklin-website-background-error-on-deployment/93629 "2023-01-27T14:06:48Z")

</div>

Franklin website background image is visible in live server but not on gh-pages. How to make background image visible on gh-pages also ? :unamused: LIVE SERVER look GH pages look below The content of Franklin.…

---

## [Long compilation time of own code](https://discourse.julialang.org/t/long-compilation-time-of-own-code/93618)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 5\
**Last updated:** [January 27, 2023, 12:24pm UTC](https://discourse.julialang.org/t/long-compilation-time-of-own-code/93618 "2023-01-27T12:24:34Z")

</div>

I am getting a very long TTFX on my own code. This is new territory for me. I profiled the compilation and first run, and the profiler reports large amounts of time spent on the call value\_∂{1,Ny}(...) (which does perfe…

---

## [Performance regression with StaticArrays?](https://discourse.julialang.org/t/performance-regression-with-staticarrays/93555)

<div class="topic-metadata">

**Author:** [@melonedo](https://discourse.julialang.org/u/melonedo)\
**Replies:** 5\
**Last updated:** [January 27, 2023, 11:53am UTC](https://discourse.julialang.org/t/performance-regression-with-staticarrays/93555 "2023-01-27T11:53:41Z")

</div>

Why in this example, the @SVector and @MVector macros both make performance worse? Code: (you can copy and paste into REPL) using BenchmarkTools using StaticArrays using Random function g1(T) levels = @SVector T\[.…

---

## [ODEProblem gives error when using symbolic maps for parameters](https://discourse.julialang.org/t/odeproblem-gives-error-when-using-symbolic-maps-for-parameters/92509)

<div class="topic-metadata">

**Author:** [@Lucalino](https://discourse.julialang.org/u/Lucalino)\
**Replies:** 4\
**Last updated:** [January 27, 2023, 11:50am UTC](https://discourse.julialang.org/t/odeproblem-gives-error-when-using-symbolic-maps-for-parameters/92509 "2023-01-27T11:50:13Z")

</div>

Hi, I am trying to solve an ODEProblem for which I want to provide parameters in the form of a dictionary Dict{Symbol, Any}. This used to work in the past but now I get the following error message: ArgumentError: This p…

---

## [What Packages in Julia can Create Piston Moving in a Cylinder Animation?](https://discourse.julialang.org/t/what-packages-in-julia-can-create-piston-moving-in-a-cylinder-animation/93492)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 6\
**Last updated:** [January 27, 2023, 10:49am UTC](https://discourse.julialang.org/t/what-packages-in-julia-can-create-piston-moving-in-a-cylinder-animation/93492 "2023-01-27T10:49:47Z")

</div>

Hi all, I have no MWE or codes at all, but perhaps there is someone who already made it here. I want to create this https://miro.medium.com/max/640/0\*URlUh\_RUelxpA\_QJ.gif How exactly should I start? is Julia able to…

---

## [Pandas value\_counts() equivalent in base Julia or in Data frame package?](https://discourse.julialang.org/t/pandas-value-counts-equivalent-in-base-julia-or-in-data-frame-package/93620)

<div class="topic-metadata">

**Author:** [@dove88](https://discourse.julialang.org/u/dove88)\
**Replies:** 1\
**Last updated:** [January 27, 2023, 10:31am UTC](https://discourse.julialang.org/t/pandas-value-counts-equivalent-in-base-julia-or-in-data-frame-package/93620 "2023-01-27T10:31:43Z")

</div>

Hello I am interested in Datascience and now i am using Julia for Data analysis with python. I have a question, How can we get the count of each categorical values in an array(dataframe subset) in Julia? For. Eg. we…

---

## [Printf with variable number of digits](https://discourse.julialang.org/t/printf-with-variable-number-of-digits/93589)

<div class="topic-metadata">

**Author:** [@Maurizio\_Tomasi](https://discourse.julialang.org/u/Maurizio_Tomasi)\
**Replies:** 6\
**Last updated:** [January 27, 2023, 10:18am UTC](https://discourse.julialang.org/t/printf-with-variable-number-of-digits/93589 "2023-01-27T10:18:19Z")

</div>

I am trying to write some code that computes some number up to some precision and prints it with the correct number of digits. I tried the following: using Printf function print\_number(x, err) numofdigits = ceil(In…

---

## [DiffEqFlux and Lux/Flux](https://discourse.julialang.org/t/diffeqflux-and-lux-flux/82457)

<div class="topic-metadata">

**Author:** [@Adam\_Davis](https://discourse.julialang.org/u/Adam_Davis)\
**Replies:** 7\
**Last updated:** [January 27, 2023, 9:18am UTC](https://discourse.julialang.org/t/diffeqflux-and-lux-flux/82457 "2023-01-27T09:18:29Z")

</div>

I’m getting an error using sciml to train a DiffEqFlux tutorial. I used the same exact code with some modifications last summer with no problems but can’t seem to find a solution. I am using Julia v.1.7.1 using DiffEq…

---

## [Issue while using basic functions in julia](https://discourse.julialang.org/t/issue-while-using-basic-functions-in-julia/93607)

<div class="topic-metadata">

**Author:** [@nethaji8](https://discourse.julialang.org/u/nethaji8)\
**Replies:** 4\
**Last updated:** [January 27, 2023, 8:17am UTC](https://discourse.julialang.org/t/issue-while-using-basic-functions-in-julia/93607 "2023-01-27T08:17:29Z")

</div>

Dear julia community, I am a beginner in julia can you please explain to me why I am facing the following problems…? 1. #code a = \[1 2 3; 4 5 6\] map(x -\> println(a), \[1,2\]) #output in notebook \[1 2 3; 4 5 6\] \[1 2 3; …

---

## [Update stdout while a function is running](https://discourse.julialang.org/t/update-stdout-while-a-function-is-running/86285)

<div class="topic-metadata">

**Author:** [@Ashlin\_Harris](https://discourse.julialang.org/u/Ashlin_Harris)\
**Replies:** 8\
**Last updated:** [January 26, 2023, 10:21pm UTC](https://discourse.julialang.org/t/update-stdout-while-a-function-is-running/86285 "2023-01-26T22:21:00Z")

</div>

I’d like to print to stdout continually while a function is running in parallel. It seems that this isn’t possible with asynchonous programming alone, since the scheduler works by interrupting and resuming tasks that are…

---

## [Force update const in module](https://discourse.julialang.org/t/force-update-const-in-module/93594)

<div class="topic-metadata">

**Author:** [@harsh\_kumar](https://discourse.julialang.org/u/harsh_kumar)\
**Replies:** 1\
**Last updated:** [January 26, 2023, 8:43pm UTC](https://discourse.julialang.org/t/force-update-const-in-module/93594 "2023-01-26T20:43:50Z")

</div>

I have created a module that read some data from files. I tried storing the file content in a variable like shown below. But this method doesn’t update the name variable from the file even if i restart the julia session.…

---

## [Calculation of rolling standard deviation by group](https://discourse.julialang.org/t/calculation-of-rolling-standard-deviation-by-group/93550)

<div class="topic-metadata">

**Author:** [@ejlongman](https://discourse.julialang.org/u/ejlongman)\
**Replies:** 7\
**Last updated:** [January 26, 2023, 4:21pm UTC](https://discourse.julialang.org/t/calculation-of-rolling-standard-deviation-by-group/93550 "2023-01-26T16:21:27Z")

</div>

Hello, I have a dataset with year, quarter, firm and EPS. I want to calculate rolling standard deviation over only the 8 previous quarters, by firm. The following code works to create lags by group, and the really terri…

---

## [Automatic differentiation + mulit-threading?](https://discourse.julialang.org/t/automatic-differentiation-mulit-threading/93576)

<div class="topic-metadata">

**Author:** [@csev](https://discourse.julialang.org/u/csev)\
**Replies:** 5\
**Last updated:** [January 26, 2023, 7:27pm UTC](https://discourse.julialang.org/t/automatic-differentiation-mulit-threading/93576 "2023-01-26T19:27:18Z")

</div>

Hello – Is it possible to use automatic differentiation (specifically in Optim,jl) with multi-threading? I’m getting type conflicts with race-safe Atomic type in my main objective functions (a likelihood) not being compa…

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

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