# General Usage

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

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

**Page:** 626

---

## [Threads and stdlib Random](https://discourse.julialang.org/t/threads-and-stdlib-random/57539)

<div class="topic-metadata">

**Author:** [@evanfields](https://discourse.julialang.org/u/evanfields)\
**Replies:** 4\
**Last updated:** [March 19, 2021, 4:27pm UTC](https://discourse.julialang.org/t/threads-and-stdlib-random/57539 "2021-03-19T16:27:25Z")

</div>

What’s the state of the Random stdlib and thread safety? I thought I remembered some notes on this from several Julia releases back, but the Random docs have almost nothing on the topic. The only reference to threads is …

---

## [3D camera movements in Makie](https://discourse.julialang.org/t/3d-camera-movements-in-makie/57530)

<div class="topic-metadata">

**Author:** [@weymouth](https://discourse.julialang.org/u/weymouth)\
**Replies:** 3\
**Last updated:** [March 19, 2021, 3:17pm UTC](https://discourse.julialang.org/t/3d-camera-movements-in-makie/57530 "2021-03-19T15:17:26Z")

</div>

Are there any examples for 3D camera movements using the new Figure() set up for Makie and GLMakie?

---

## [Using @warn like @assert?](https://discourse.julialang.org/t/using-warn-like-assert/57545)

<div class="topic-metadata">

**Author:** [@markmbaum](https://discourse.julialang.org/u/markmbaum)\
**Replies:** 1\
**Last updated:** [March 19, 2021, 2:56pm UTC](https://discourse.julialang.org/t/using-warn-like-assert/57545 "2021-03-19T14:56:28Z")

</div>

Short question! Is there a way to conditionally produce a warning without writing the if-end block? It would look like @warn x \< y "you should know that x is less than y" similar to the way that @assert works.

---

## [Convert png image into base64 string?](https://discourse.julialang.org/t/convert-png-image-into-base64-string/57515)

<div class="topic-metadata">

**Author:** [@Ravinder\_Ram](https://discourse.julialang.org/u/Ravinder_Ram)\
**Replies:** 1\
**Last updated:** [March 19, 2021, 12:21pm UTC](https://discourse.julialang.org/t/convert-png-image-into-base64-string/57515 "2021-03-19T12:21:08Z")

</div>

how to convert png image into base64 string and vice versa?

---

## [JSON.jl output undecorated/unquoted string](https://discourse.julialang.org/t/json-jl-output-undecorated-unquoted-string/57527)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 2\
**Last updated:** [March 19, 2021, 10:15am UTC](https://discourse.julialang.org/t/json-jl-output-undecorated-unquoted-string/57527 "2021-03-19T10:15:41Z")

</div>

Hi, I have a singleton type Undefined which is meant to match JavaScript’s undefined primitive. As such, when JSON rendered, this should output as undefined instead of the default "undefined" (not wrapped in double quot…

---

## [Hey, does anybody know why a generator does allocate memory while an iterator does](https://discourse.julialang.org/t/hey-does-anybody-know-why-a-generator-does-allocate-memory-while-an-iterator-does/57504)

<div class="topic-metadata">

**Author:** [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Replies:** 1\
**Last updated:** [March 19, 2021, 9:00am UTC](https://discourse.julialang.org/t/hey-does-anybody-know-why-a-generator-does-allocate-memory-while-an-iterator-does/57504 "2021-03-19T09:00:49Z")

</div>

Hey, does anybody know why a generator does allocate memory while an iterator doesn’t when assigned to an existing location? julia&gt; x = randn((1000)); julia&gt; y = 1:1000 1:1000 julia&gt; g = (i for i=1:1000) Base…

---

## [Discrete event simulation framework for discrete time](https://discourse.julialang.org/t/discrete-event-simulation-framework-for-discrete-time/55436)

<div class="topic-metadata">

**Author:** [@manuka](https://discourse.julialang.org/u/manuka)\
**Replies:** 4\
**Last updated:** [March 19, 2021, 8:56am UTC](https://discourse.julialang.org/t/discrete-event-simulation-framework-for-discrete-time/55436 "2021-03-19T08:56:57Z")

</div>

I would like to receive feedback on my simulation model. I have posted it in codereview.stackexchange but recieved almost no feedback (Discrete event simulation framework for discrete times in Julia - Code Review Stack E…

---

## [How to do an operation like object.method() in Python](https://discourse.julialang.org/t/how-to-do-an-operation-like-object-method-in-python/57445)

<div class="topic-metadata">

**Author:** [@zhangqian](https://discourse.julialang.org/u/zhangqian)\
**Replies:** 2\
**Last updated:** [March 19, 2021, 5:47am UTC](https://discourse.julialang.org/t/how-to-do-an-operation-like-object-method-in-python/57445 "2021-03-19T05:47:24Z")

</div>

I am currently using Julia to do some fluid computation. Since I want to see the influence of some variables, like time steps, I need to store and prepare other persistent variables at first, and then pass the variable I…

---

## [Garbage collector, C malloc and performance](https://discourse.julialang.org/t/garbage-collector-c-malloc-and-performance/57320)

<div class="topic-metadata">

**Author:** [@KZiemian](https://discourse.julialang.org/u/KZiemian)\
**Replies:** 2\
**Last updated:** [March 19, 2021, 5:40am UTC](https://discourse.julialang.org/t/garbage-collector-c-malloc-and-performance/57320 "2021-03-19T05:40:50Z")

</div>

I recently read very old blog post by Joel Spolsky Back to Basics from 2002 (side effect of reading about floating-point numbers, you know how this work). He stated that C code that use malloc can suffer for problems ver…

---

## [Macro for generating struct](https://discourse.julialang.org/t/macro-for-generating-struct/57479)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 4\
**Last updated:** [March 19, 2021, 5:40am UTC](https://discourse.julialang.org/t/macro-for-generating-struct/57479 "2021-03-19T05:40:00Z")

</div>

I have written a macro that generates a new struct. It all works as intended when I test the macro from the REPL or from a script. Then of course, I want to call the macro in a function that does some cooking and retur…

---

## [Writing tests in VS Code: workflow, autocomplete, and tooltips](https://discourse.julialang.org/t/writing-tests-in-vs-code-workflow-autocomplete-and-tooltips/57488)

<div class="topic-metadata">

**Author:** [@tpgillam](https://discourse.julialang.org/u/tpgillam)\
**Replies:** 8\
**Last updated:** [March 18, 2021, 9:41pm UTC](https://discourse.julialang.org/t/writing-tests-in-vs-code-workflow-autocomplete-and-tooltips/57488 "2021-03-18T21:41:26Z")

</div>

Hello all! I’m currently writing a package for the purpose of learning Julia, and am finding that autocomplete & hover-tooltips for types defined in the package do not seem to appear when in a test file. Problem Speci…

---

## [How to propagate @inbounds properly](https://discourse.julialang.org/t/how-to-propagate-inbounds-properly/57487)

<div class="topic-metadata">

**Author:** [@Uroc327](https://discourse.julialang.org/u/Uroc327)\
**Replies:** 8\
**Last updated:** [March 18, 2021, 8:47pm UTC](https://discourse.julialang.org/t/how-to-propagate-inbounds-properly/57487 "2021-03-18T20:47:08Z")

</div>

I have a bunch of more or less complex functions that have arrays and indices as arguments. I’d like to specify @inbounds once at the top-level function and propagate this down through all nested and standalone functions…

---

## [Counting How Many Times a Point Passes Through a Grid of Coordinates](https://discourse.julialang.org/t/counting-how-many-times-a-point-passes-through-a-grid-of-coordinates/57229)

<div class="topic-metadata">

**Author:** [@PJoynt](https://discourse.julialang.org/u/PJoynt)\
**Replies:** 4\
**Last updated:** [March 18, 2021, 6:49pm UTC](https://discourse.julialang.org/t/counting-how-many-times-a-point-passes-through-a-grid-of-coordinates/57229 "2021-03-18T18:49:45Z")

</div>

Hi Everyone, I am currently trying to figure out how to count the number of times an object passes through each grid point defined by a set of coordinates. My grid is defined by x-coordinates and y-coordinates as: long…

---

## [Optimizing the calculation of many distances](https://discourse.julialang.org/t/optimizing-the-calculation-of-many-distances/57343)

<div class="topic-metadata">

**Author:** [@jsbyrnes](https://discourse.julialang.org/u/jsbyrnes)\
**Replies:** 28\
**Last updated:** [March 18, 2021, 5:11pm UTC](https://discourse.julialang.org/t/optimizing-the-calculation-of-many-distances/57343 "2021-03-18T17:11:08Z")

</div>

Hey everyone, I’m translating some code from Julia to MATLAB and I have a seismic imaging program that now works in Julia and is a bit faster than MATLAB - but not a ton. The profiler says that the function pasted below …

---

## [Getfield from package / module](https://discourse.julialang.org/t/getfield-from-package-module/57432)

<div class="topic-metadata">

**Author:** [@stephenll](https://discourse.julialang.org/u/stephenll)\
**Replies:** 5\
**Last updated:** [March 18, 2021, 3:41pm UTC](https://discourse.julialang.org/t/getfield-from-package-module/57432 "2021-03-18T15:41:54Z")

</div>

In a package I created, I am trying to call a function with a string, and using getfield, return a function from another package. The other package has been properly added to my package, and I could use the functions if…

---

## [REPL and monitor width](https://discourse.julialang.org/t/repl-and-monitor-width/57256)

<div class="topic-metadata">

**Author:** [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Replies:** 6\
**Last updated:** [March 18, 2021, 3:29pm UTC](https://discourse.julialang.org/t/repl-and-monitor-width/57256 "2021-03-18T15:29:21Z")

</div>

Considering buying one of those ultra-wide monitors. To those that have one already (because I’m sure someone here does), does the REPL scale the full width? Could I just immerse myself in Julia? Bonus points for screen…

---

## [How to provide two versions of some quantities to the user. Can they unload a module?](https://discourse.julialang.org/t/how-to-provide-two-versions-of-some-quantities-to-the-user-can-they-unload-a-module/57325)

<div class="topic-metadata">

**Author:** [@aramirezreyes](https://discourse.julialang.org/u/aramirezreyes)\
**Replies:** 3\
**Last updated:** [March 18, 2021, 3:15pm UTC](https://discourse.julialang.org/t/how-to-provide-two-versions-of-some-quantities-to-the-user-can-they-unload-a-module/57325 "2021-03-18T15:15:37Z")

</div>

Hi! I wrote this on the Slack but I think here may be a good fit. I have a package that contains some physical constants (for example g, the acceleration of gravity). I provide units with the constants through Unitful.j…

---

## [Variables when passed to functions](https://discourse.julialang.org/t/variables-when-passed-to-functions/57476)

<div class="topic-metadata">

**Author:** [@anon60034542](https://discourse.julialang.org/u/anon60034542)\
**Replies:** 1\
**Last updated:** [March 18, 2021, 1:43pm UTC](https://discourse.julialang.org/t/variables-when-passed-to-functions/57476 "2021-03-18T13:43:27Z")

</div>

function add!(character\_storage ::Dict{String,Int32}, acquired :: Pair{String,Int32}) push!(character\_storage,acquired) end items = Dict{String,Int32}() orb\_of\_health :: Pair = ("Orb" =\> 10) According to the documenta…

---

## [Examples of a database to manage simulation result files](https://discourse.julialang.org/t/examples-of-a-database-to-manage-simulation-result-files/55063)

<div class="topic-metadata">

**Author:** [@Olivier\_Merchiers](https://discourse.julialang.org/u/Olivier_Merchiers)\
**Replies:** 4\
**Last updated:** [March 18, 2021, 2:43pm UTC](https://discourse.julialang.org/t/examples-of-a-database-to-manage-simulation-result-files/55063 "2021-03-18T14:43:33Z")

</div>

Hello everyone, I use DrWatson.jl to manage my scientific projects. The default way to manage files containing simulation results, is to put the list of parameters in the filename. This works well for small projects, b…

---

## [Help speeding up FFT processing code](https://discourse.julialang.org/t/help-speeding-up-fft-processing-code/57219)

<div class="topic-metadata">

**Author:** [@mihalybaci](https://discourse.julialang.org/u/mihalybaci)\
**Replies:** 9\
**Last updated:** [March 18, 2021, 2:24pm UTC](https://discourse.julialang.org/t/help-speeding-up-fft-processing-code/57219 "2021-03-18T14:24:01Z")

</div>

Hi all, I have a three functions that I have translated from Python and would like some assistance in improving their performance. The full working code is: using FFTW """ Implementation of numpy.roll """ roll(vec, num…

---

## [@edit does not work on my system](https://discourse.julialang.org/t/edit-does-not-work-on-my-system/57431)

<div class="topic-metadata">

**Author:** [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Replies:** 4\
**Last updated:** [March 18, 2021, 1:49pm UTC](https://discourse.julialang.org/t/edit-does-not-work-on-my-system/57431 "2021-03-18T13:49:00Z")

</div>

I want to try the macro @edit but I got julia\> @edit 3+5 ERROR: could not find source file for function Stacktrace: \[1\] edit(::Nothing, ::Int32) at /build/julia/src/julia-1.5.3/usr/share/julia/stdlib/v1.5/InteractiveUt…

---

## [Is it possible to do a \`mapreduce\` with multiple arrays while broadcasting over so](https://discourse.julialang.org/t/is-it-possible-to-do-a-mapreduce-with-multiple-arrays-while-broadcasting-over-so/57433)

<div class="topic-metadata">

**Author:** [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Replies:** 4\
**Last updated:** [March 18, 2021, 1:44pm UTC](https://discourse.julialang.org/t/is-it-possible-to-do-a-mapreduce-with-multiple-arrays-while-broadcasting-over-so/57433 "2021-03-18T13:44:57Z")

</div>

Is it possible to do a mapreduce with multiple arrays while broadcasting over some dimensions? Something like this U = rand(5, 5, 5) Δ = rand(1, 1, 5) mapreduce((u, Δx) -\> u / Δx, max, U, Δ) where I really want to find…

---

## [Contour plot for non-rectangular domain](https://discourse.julialang.org/t/contour-plot-for-non-rectangular-domain/57381)

<div class="topic-metadata">

**Author:** [@Gus\_Hart](https://discourse.julialang.org/u/Gus_Hart)\
**Replies:** 6\
**Last updated:** [March 18, 2021, 1:25pm UTC](https://discourse.julialang.org/t/contour-plot-for-non-rectangular-domain/57381 "2021-03-18T13:25:24Z")

</div>

There was a previous thread on this, but the use case was too different from mine to be informative. I have a function defined over a triangle and would like to plot it as a contour plot but only in the triangular domai…

---

## [Is there a simple way to get the logging macros to print timestamps?i.e.\`\`\`julia](https://discourse.julialang.org/t/is-there-a-simple-way-to-get-the-logging-macros-to-print-timestamps-i-e-julia/57472)

<div class="topic-metadata">

**Author:** [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Replies:** 1\
**Last updated:** [March 18, 2021, 1:12pm UTC](https://discourse.julialang.org/t/is-there-a-simple-way-to-get-the-logging-macros-to-print-timestamps-i-e-julia/57472 "2021-03-18T13:12:37Z")

</div>

Is there a simple way to get the logging macros to print timestamps? i.e. julia&gt; @info "hello" 2021-03-18T09:08:24.462 \[ Info: hello Note that the original poster on Slack cannot see your response here on Discourse…

---

## [Browser problems displaying maths Unicode characters](https://discourse.julialang.org/t/browser-problems-displaying-maths-unicode-characters/56948)

<div class="topic-metadata">

**Author:** [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Replies:** 23\
**Last updated:** [March 18, 2021, 10:39am UTC](https://discourse.julialang.org/t/browser-problems-displaying-maths-unicode-characters/56948 "2021-03-18T10:39:58Z")

</div>

After keno uploaded a short code snippet to a github gist I noticed that my browser (Safari on macOS) wasn’t rendering some of his code correctly there, particularly the glyph compositions (eg where two characters such a…

---

## [Making a custom distribution with value as parametric type](https://discourse.julialang.org/t/making-a-custom-distribution-with-value-as-parametric-type/57454)

<div class="topic-metadata">

**Author:** [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Replies:** 2\
**Last updated:** [March 18, 2021, 10:38am UTC](https://discourse.julialang.org/t/making-a-custom-distribution-with-value-as-parametric-type/57454 "2021-03-18T10:38:26Z")

</div>

Hello, I’m trying to get my head around types with a value parameter. Here I’m trying to implement a wrapper to the Normal distribution type where two distributions must have the same Coefficient of Variability (CV) to b…

---

## [Best implementation for semiclassical dynamics in Julia](https://discourse.julialang.org/t/best-implementation-for-semiclassical-dynamics-in-julia/57423)

<div class="topic-metadata">

**Author:** [@ErikPillon](https://discourse.julialang.org/u/ErikPillon)\
**Replies:** 5\
**Last updated:** [March 18, 2021, 10:20am UTC](https://discourse.julialang.org/t/best-implementation-for-semiclassical-dynamics-in-julia/57423 "2021-03-18T10:20:53Z")

</div>

Dear all, I’m a Julia user since 2017 and after getting familiar with multiple dispatch and mutable structures, I finally found the courage to interact for the first time with the Julia community. Here’s my question. D…

---

## [How to sum the chunks of a distributed array using a binary reduction tree?](https://discourse.julialang.org/t/how-to-sum-the-chunks-of-a-distributed-array-using-a-binary-reduction-tree/57288)

<div class="topic-metadata">

**Author:** [@matthiasbe](https://discourse.julialang.org/u/matthiasbe)\
**Replies:** 1\
**Last updated:** [March 18, 2021, 9:56am UTC](https://discourse.julialang.org/t/how-to-sum-the-chunks-of-a-distributed-array-using-a-binary-reduction-tree/57288 "2021-03-18T09:56:06Z")

</div>

Hi, I use the reduce() function to sum all the parts of a distributed array. function reduce(A::DArray{Float64,2})::Int # Sum reduction : sums all partitions of A # The result is on aggregator\_worker aggregator\_w…

---

## [Error installing GR in Julia 1.6 RC2 (Windows x64)](https://discourse.julialang.org/t/error-installing-gr-in-julia-1-6-rc2-windows-x64/57443)

<div class="topic-metadata">

**Author:** [@mobius-eng](https://discourse.julialang.org/u/mobius-eng)\
**Replies:** 6\
**Last updated:** [March 18, 2021, 8:54am UTC](https://discourse.julialang.org/t/error-installing-gr-in-julia-1-6-rc2-windows-x64/57443 "2021-03-18T08:54:40Z")

</div>

I realize things will probably break in the transition from 1.5 to 1.6, but I didn’t see anyone reporting an issue like this on GitHub. So, I am just checking whether it is something specific to my case and if there is s…

---

## [Conditional evaluation of lines](https://discourse.julialang.org/t/conditional-evaluation-of-lines/57426)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 8\
**Last updated:** [March 18, 2021, 7:57am UTC](https://discourse.julialang.org/t/conditional-evaluation-of-lines/57426 "2021-03-18T07:57:50Z")

</div>

I have a function f that creates and filsl a vector of n components with the result of expensive functions gi. I am interested in having f depend on n. I have tried the following, but I’m wondering if there is a better, …

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

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