# General Usage

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

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

**Page:** 272

---

## [Customize a random function to sample 3 out of a list of 4097 real numbers](https://discourse.julialang.org/t/customize-a-random-function-to-sample-3-out-of-a-list-of-4097-real-numbers/100876)

<div class="topic-metadata">

**Author:** [@Lian\_Yunlong](https://discourse.julialang.org/u/Lian_Yunlong)\
**Replies:** 5\
**Last updated:** [July 7, 2023, 6:42am UTC](https://discourse.julialang.org/t/customize-a-random-function-to-sample-3-out-of-a-list-of-4097-real-numbers/100876 "2023-07-07T06:42:28Z")

</div>

I need a very fast random sampler to choose n numbers from a precomputed 1D array, say X. We can assume that n is much smaller than length(X). I have tried rand(X,n), \[rand(X) for i=1:n\] , but neither gives satisfactory …

---

## [Very slow "Updating registry at 'C:\\Users\\me\\.julia\\registries\\General'"](https://discourse.julialang.org/t/very-slow-updating-registry-at-c-users-me-julia-registries-general/51614)

<div class="topic-metadata">

**Author:** [@devel-chm](https://discourse.julialang.org/u/devel-chm)\
**Replies:** 19\
**Last updated:** [July 7, 2023, 4:14am UTC](https://discourse.julialang.org/t/very-slow-updating-registry-at-c-users-me-julia-registries-general/51614 "2023-07-07T04:14:18Z")

</div>

I’m using win10 and julia-1.5.3 from the REPL. When I use Pkg mode to add a new package (or other operations) it starts by updating the registries\\General: (@v1.5) pkg\> add Pluto Updating registry at C:\\Users\\me\\.jul…

---

## [Report of environment package versions and hardware resources](https://discourse.julialang.org/t/report-of-environment-package-versions-and-hardware-resources/101279)

<div class="topic-metadata">

**Author:** [@jddorellanao](https://discourse.julialang.org/u/jddorellanao)\
**Replies:** 1\
**Last updated:** [July 6, 2023, 11:12pm UTC](https://discourse.julialang.org/t/report-of-environment-package-versions-and-hardware-resources/101279 "2023-07-06T23:12:43Z")

</div>

I would like to get a report of my environment package versions and hardware resources like Scooby does in Python (image below), but for Julia, is there a package or a way to do that?

---

## [Assignment into array of arrays by broadcasting](https://discourse.julialang.org/t/assignment-into-array-of-arrays-by-broadcasting/91072)

<div class="topic-metadata">

**Author:** [@adannenberg](https://discourse.julialang.org/u/adannenberg)\
**Replies:** 12\
**Last updated:** [July 6, 2023, 9:45pm UTC](https://discourse.julialang.org/t/assignment-into-array-of-arrays-by-broadcasting/91072 "2023-07-06T21:45:19Z")

</div>

I want to simulate a process with 3 discrete outcomes. Let’s say they have probabilities .2, .3 and .5 and I want to run nSim = 10 simulations, each of which is a series of nDraw = 5 draws from the discrete distribution…

---

## [Sysimage creation example with plots does not seem to work](https://discourse.julialang.org/t/sysimage-creation-example-with-plots-does-not-seem-to-work/101269)

<div class="topic-metadata">

**Author:** [@rdiaz02](https://discourse.julialang.org/u/rdiaz02)\
**Replies:** 2\
**Last updated:** [July 6, 2023, 7:10pm UTC](https://discourse.julialang.org/t/sysimage-creation-example-with-plots-does-not-seem-to-work/101269 "2023-07-06T19:10:44Z")

</div>

The example given in Creating a sysimage for fast plotting with Plots.jl · PackageCompiler does not finish after more than 25 minutes. I am running Julia 1.9.2 under Debian Linux. This is what I have done: Create fil…

---

## [Non greedy regex match](https://discourse.julialang.org/t/non-greedy-regex-match/101268)

<div class="topic-metadata">

**Author:** [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Replies:** 4\
**Last updated:** [July 6, 2023, 5:46pm UTC](https://discourse.julialang.org/t/non-greedy-regex-match/101268 "2023-07-06T17:46:18Z")

</div>

How can I match non-greedily a regex in julia ? A general stackoverflow post mentions .\*? but it doesn’t work. Julia docs point to pcre2 site that mentions (?U) default ungreedy (lazy) but I am not sure how to use it…

---

## [Error when using a df load from a CSV and nthreads \> 1](https://discourse.julialang.org/t/error-when-using-a-df-load-from-a-csv-and-nthreads-1/101250)

<div class="topic-metadata">

**Author:** [@mariok90](https://discourse.julialang.org/u/mariok90)\
**Replies:** 1\
**Last updated:** [July 6, 2023, 12:28pm UTC](https://discourse.julialang.org/t/error-when-using-a-df-load-from-a-csv-and-nthreads-1/101250 "2023-07-06T12:28:22Z")

</div>

Hi, I encountered an error when I load a CSV file into a DataFrame and use stack. I narrowed it down that it only occurs if I run Julia --threads=auto (Threads.nthreads() \> 1). I was able to reproduce the error in this…

---

## [Create temporary local namespace?](https://discourse.julialang.org/t/create-temporary-local-namespace/101227)

<div class="topic-metadata">

**Author:** [@hatmatrix](https://discourse.julialang.org/u/hatmatrix)\
**Replies:** 10\
**Last updated:** [July 6, 2023, 9:59am UTC](https://discourse.julialang.org/t/create-temporary-local-namespace/101227 "2023-07-06T09:59:10Z")

</div>

In R you can use the following syntax to access variables within a data frame. df = data.frame(x = 1:10, y = 1) z = with(df, x + y) # =\> \[2, 3, ..., 11\] The with function is very powerful in that it also allows you to …

---

## [Distributed.@everywhere alters random generator state?](https://discourse.julialang.org/t/distributed-everywhere-alters-random-generator-state/101230)

<div class="topic-metadata">

**Author:** [@pitsianis](https://discourse.julialang.org/u/pitsianis)\
**Replies:** 2\
**Last updated:** [July 6, 2023, 9:04am UTC](https://discourse.julialang.org/t/distributed-everywhere-alters-random-generator-state/101230 "2023-07-06T09:04:37Z")

</div>

\_ \_ \_ \_(\_)\_ | Documentation: https://docs.julialang.org (\_) | (\_) (\_) | \_ \_ \_| |\_ \_\_ \_ | Type "?" for help, "\]?" for Pkg help. | | | | | | |/ \_\` | | | | |\_| | | | (\_| |…

---

## [About modifying the .m file in MATLAB](https://discourse.julialang.org/t/about-modifying-the-m-file-in-matlab/101210)

<div class="topic-metadata">

**Author:** [@lzq-zbc](https://discourse.julialang.org/u/lzq-zbc)\
**Replies:** 5\
**Last updated:** [July 6, 2023, 7:30am UTC](https://discourse.julialang.org/t/about-modifying-the-m-file-in-matlab/101210 "2023-07-06T07:30:43Z")

</div>

Does Julia have a toolkit that enables reading and modifying .m files in MATLAB?

---

## [How to take two exisitng plots and inset one inside the other](https://discourse.julialang.org/t/how-to-take-two-exisitng-plots-and-inset-one-inside-the-other/101226)

<div class="topic-metadata">

**Author:** [@NegativeOne](https://discourse.julialang.org/u/NegativeOne)\
**Replies:** 1\
**Last updated:** [July 5, 2023, 8:25pm UTC](https://discourse.julialang.org/t/how-to-take-two-exisitng-plots-and-inset-one-inside-the-other/101226 "2023-07-05T20:25:14Z")

</div>

In want to take the outputs of two separate plot commands and inset one inside the other. I’m using the GR backend. I have two plots, one created as p = plot(t, cohs, lw=\[3 1 1 1 1\], ls=\[:solid :dash :dash :dash :dash…

---

## [How to get current x and y limits of a plot? (Plots.jl)](https://discourse.julialang.org/t/how-to-get-current-x-and-y-limits-of-a-plot-plots-jl/101029)

<div class="topic-metadata">

**Author:** [@leespen1](https://discourse.julialang.org/u/leespen1)\
**Replies:** 3\
**Last updated:** [July 5, 2023, 6:41pm UTC](https://discourse.julialang.org/t/how-to-get-current-x-and-y-limits-of-a-plot-plots-jl/101029 "2023-07-05T18:41:52Z")

</div>

Given that I have already made a plot using, say pl = plot(\[1,2,3\]), is there a way to query what the current x and y limits of the plot are? E.g. something like pl.xlims which would return (1.0,3.0). I often find myse…

---

## [Calling a julia script from within another script](https://discourse.julialang.org/t/calling-a-julia-script-from-within-another-script/100989)

<div class="topic-metadata">

**Author:** [@clairem](https://discourse.julialang.org/u/clairem)\
**Replies:** 9\
**Last updated:** [July 5, 2023, 6:31pm UTC](https://discourse.julialang.org/t/calling-a-julia-script-from-within-another-script/100989 "2023-07-05T18:31:17Z")

</div>

I have a julia file that contains functions and code that uses those functions. I would like to create a separate julia script that is able to execute this script (and obtain one of the values that is created at the end …

---

## [Where is the DifferentialEquations finite element tutorial?](https://discourse.julialang.org/t/where-is-the-differentialequations-finite-element-tutorial/101216)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 4\
**Last updated:** [July 5, 2023, 5:14pm UTC](https://discourse.julialang.org/t/where-is-the-differentialequations-finite-element-tutorial/101216 "2023-07-05T17:14:41Z")

</div>

Can someone please point me to the tutorial mentioned here that creates this demo? (Can’t find it in that page) Thanks

---

## [Check that compilation time = 0](https://discourse.julialang.org/t/check-that-compilation-time-0/101215)

<div class="topic-metadata">

**Author:** [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Replies:** 8\
**Last updated:** [July 5, 2023, 4:41pm UTC](https://discourse.julialang.org/t/check-that-compilation-time-0/101215 "2023-07-05T16:41:34Z")

</div>

Hi, When I use @time, Julia displays the number of allocation, gc time, compilation time, (recompilation time I think?)… Is there a way to test that the compilation time is equal to 0, i.e. that no compilation happens? …

---

## [Combining elements from multiple rows by conditionals into columns with DataFramesMeta](https://discourse.julialang.org/t/combining-elements-from-multiple-rows-by-conditionals-into-columns-with-dataframesmeta/101097)

<div class="topic-metadata">

**Author:** [@alequa](https://discourse.julialang.org/u/alequa)\
**Replies:** 10\
**Last updated:** [July 5, 2023, 3:41pm UTC](https://discourse.julialang.org/t/combining-elements-from-multiple-rows-by-conditionals-into-columns-with-dataframesmeta/101097 "2023-07-05T15:41:49Z")

</div>

Hello, I want to create a new dataframe with a column computed from one or more columns of the initial dataframe. using DataFramesMeta df1 = DataFrame(category = \[1,0,1,0\], group=\[1,1,0,0\], measure = \[401, 402, 200, 3…

---

## [How to insert Integral in a NonLinearProblem](https://discourse.julialang.org/t/how-to-insert-integral-in-a-nonlinearproblem/101183)

<div class="topic-metadata">

**Author:** [@Xx-Seth-xX](https://discourse.julialang.org/u/Xx-Seth-xX)\
**Replies:** 4\
**Last updated:** [July 5, 2023, 2:52pm UTC](https://discourse.julialang.org/t/how-to-insert-integral-in-a-nonlinearproblem/101183 "2023-07-05T14:52:40Z")

</div>

If I want to have an integral inside a Non Linear System of equations how would I do it with ModelingToolkit.jl and NonLinearSolver.jl? e.x. I have an integral from 0 to 1 of sin(a\*x) which equals to 1, how would I sol…

---

## [Faster isapprox()](https://discourse.julialang.org/t/faster-isapprox/101202)

<div class="topic-metadata">

**Author:** [@user\_231578](https://discourse.julialang.org/u/user_231578)\
**Replies:** 14\
**Last updated:** [July 5, 2023, 2:51pm UTC](https://discourse.julialang.org/t/faster-isapprox/101202 "2023-07-05T14:51:14Z")

</div>

I have to run (possibly) millions of times the function isapprox(A, A\_, rtol=1e-4), where A and A\_ are two matrices. To improve efficiency, I defined a custom isapprox() function using a more efficient norm: using LoopV…

---

## [Help me improve this simple function](https://discourse.julialang.org/t/help-me-improve-this-simple-function/101198)

<div class="topic-metadata">

**Author:** [@laborg](https://discourse.julialang.org/u/laborg)\
**Replies:** 12\
**Last updated:** [July 5, 2023, 2:08pm UTC](https://discourse.julialang.org/t/help-me-improve-this-simple-function/101198 "2023-07-05T14:08:10Z")

</div>

Hi, The following function is used to apply a calibration captured in correction to a matrix of 3D sample points. using BenchmarkTools function correct(points, correction) epoints = hcat(points, ones(size(points, 1…

---

## [Hash of enum from module gives inconsistent values run to run](https://discourse.julialang.org/t/hash-of-enum-from-module-gives-inconsistent-values-run-to-run/101192)

<div class="topic-metadata">

**Author:** [@sandsq](https://discourse.julialang.org/u/sandsq)\
**Replies:** 3\
**Last updated:** [July 5, 2023, 1:39pm UTC](https://discourse.julialang.org/t/hash-of-enum-from-module-gives-inconsistent-values-run-to-run/101192 "2023-07-05T13:39:43Z")

</div>

Hi everyone! I’m running into some weird behaviour regarding Enums. Here is a small code example: module FakeletterModule export Fakeletter, \_A, \_B, \_C @enum Fakeletter \_A \_B \_C end # module import .FakeletterModul…

---

## [Develop "Julian" API for a C++ library?](https://discourse.julialang.org/t/develop-julian-api-for-a-c-library/101127)

<div class="topic-metadata">

**Author:** [@frylock](https://discourse.julialang.org/u/frylock)\
**Replies:** 3\
**Last updated:** [July 5, 2023, 12:37pm UTC](https://discourse.julialang.org/t/develop-julian-api-for-a-c-library/101127 "2023-07-05T12:37:32Z")

</div>

I have an vendor-produced C++ library that I would like to write a Julia wrapper for (I only have headers and shared objects for it). The typical use case is that the library is called from a user-created file that just …

---

## [Select ssh true in PkgTemplates.jl](https://discourse.julialang.org/t/select-ssh-true-in-pkgtemplates-jl/101205)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 1\
**Last updated:** [July 5, 2023, 11:12am UTC](https://discourse.julialang.org/t/select-ssh-true-in-pkgtemplates-jl/101205 "2023-07-05T11:12:23Z")

</div>

Hello, I am trying to create a new package with PkgTemplates for a repo that uses ssh. After going through the documentation, It is not clear how to set ssh to true for the Git plugin. How can this be accomplished? Tha…

---

## [Julia workflow for research](https://discourse.julialang.org/t/julia-workflow-for-research/101166)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 8\
**Last updated:** [July 5, 2023, 9:56am UTC](https://discourse.julialang.org/t/julia-workflow-for-research/101166 "2023-07-05T09:56:38Z")

</div>

I currently have a position as researcher, where I mainly write software that is being used just by myself. So what is a good workflow for doing this? I mainly: create models run simulations plot the simulation resul…

---

## [Solving and ODE depending on external disturbances](https://discourse.julialang.org/t/solving-and-ode-depending-on-external-disturbances/101162)

<div class="topic-metadata">

**Author:** [@Maria\_Adelaide\_Loffa](https://discourse.julialang.org/u/Maria_Adelaide_Loffa)\
**Replies:** 2\
**Last updated:** [July 5, 2023, 7:38am UTC](https://discourse.julialang.org/t/solving-and-ode-depending-on-external-disturbances/101162 "2023-07-05T07:38:04Z")

</div>

Hi everyone, I am new to Julia and I was trying to solve and ODE which depends on an exeternal disturbance vector. For every timestep, it needs to evaluate a different values from that vector. Initially, I tried with a …

---

## [How can this code be faster than MATLAB?](https://discourse.julialang.org/t/how-can-this-code-be-faster-than-matlab/101196)

<div class="topic-metadata">

**Author:** [@XuJingye2022](https://discourse.julialang.org/u/XuJingye2022)\
**Replies:** 12\
**Last updated:** [July 5, 2023, 6:22am UTC](https://discourse.julialang.org/t/how-can-this-code-be-faster-than-matlab/101196 "2023-07-05T06:22:04Z")

</div>

using BenchmarkTools zvec, δvec = randn(10000) \* 1e-2, randn(10000) \* 1e-3 # Physical constant const restenergy = 0.511e6 const clight = 3e8 # Computation settings nturns = 10001 # Machine parameter struct Par v1…

---

## [Why does Pkg.activate(".") require compilation? Time to first project activation](https://discourse.julialang.org/t/why-does-pkg-activate-require-compilation-time-to-first-project-activation/101193)

<div class="topic-metadata">

**Author:** [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Replies:** 2\
**Last updated:** [July 5, 2023, 3:00am UTC](https://discourse.julialang.org/t/why-does-pkg-activate-require-compilation-time-to-first-project-activation/101193 "2023-07-05T03:00:18Z")

</div>

Pkg.activate(".") seems to to take about 200 milliseconds, mostly due to compilation. It still takes 40 milliseconds even after activating the same environment again. $ julia -e 'using Pkg; for i in 1:5; @time Pkg.activ…

---

## [Runtime arguments for \_\_init\_\_?](https://discourse.julialang.org/t/runtime-arguments-for-init/101170)

<div class="topic-metadata">

**Author:** [@alan](https://discourse.julialang.org/u/alan)\
**Replies:** 6\
**Last updated:** [July 4, 2023, 9:52pm UTC](https://discourse.julialang.org/t/runtime-arguments-for-init/101170 "2023-07-04T21:52:07Z")

</div>

I thought at first that this was a general way to write an application that would be precompiled and would therefore load fast. However, I think I see a problem. There seems to be no way to pass arguments to a module’s \_…

---

## [Installation on managed cluster](https://discourse.julialang.org/t/installation-on-managed-cluster/100145)

<div class="topic-metadata">

**Author:** [@VictorEijkhout](https://discourse.julialang.org/u/VictorEijkhout)\
**Replies:** 25\
**Last updated:** [July 4, 2023, 8:46pm UTC](https://discourse.julialang.org/t/installation-on-managed-cluster/100145 "2023-07-04T20:46:45Z")

</div>

I install scientific software on a big supercomputer cluster, and we have occasional requests for Julia. So I thought I’d make an installation that contains a bunch of popular packages such as HDF5 and MPI. Installing …

---

## [Need help understanding allocations while calling external C library (Proj)](https://discourse.julialang.org/t/need-help-understanding-allocations-while-calling-external-c-library-proj/101133)

<div class="topic-metadata">

**Author:** [@disberd](https://discourse.julialang.org/u/disberd)\
**Replies:** 3\
**Last updated:** [July 4, 2023, 5:15pm UTC](https://discourse.julialang.org/t/need-help-understanding-allocations-while-calling-external-c-library-proj/101133 "2023-07-04T17:15:33Z")

</div>

Hello everyone, I have been scratching my head around allocations I have in a package I am developing that I can’t seem to eliminate. Moreover it seems that the allocation results I get from @allocations and @btime fro…

---

## [\[GLMakie\] volume method](https://discourse.julialang.org/t/glmakie-volume-method/101115)

<div class="topic-metadata">

**Author:** [@fdekerme](https://discourse.julialang.org/u/fdekerme)\
**Replies:** 1\
**Last updated:** [July 4, 2023, 3:03pm UTC](https://discourse.julialang.org/t/glmakie-volume-method/101115 "2023-07-04T15:03:56Z")

</div>

Hello ! Does anyone know how to use GLMakie’s volume method volume - Makie with “optional physical dimensions x, y, z” as described in the doc? For exemple, volume(1.0,2.0,3.0, rand(100,100,100)) doesn’t work. Thanks …

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

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