# General Usage

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

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

**Page:** 58

---

## [Measuring stats (cpu time etc.) for external program](https://discourse.julialang.org/t/measuring-stats-cpu-time-etc-for-external-program/130017)

<div class="topic-metadata">

**Author:** [@bubaya](https://discourse.julialang.org/u/bubaya)\
**Replies:** 0\
**Last updated:** [June 19, 2025, 8:03am UTC](https://discourse.julialang.org/t/measuring-stats-cpu-time-etc-for-external-program/130017 "2025-06-19T08:03:15Z")

</div>

I have a an external program prog, and I am writing a julia program that prepares various data sets and measures the run time of prog for each of the data sets. My question is about how to run prog. Of course, I am aware…

---

## [ForwardDiff Allocations](https://discourse.julialang.org/t/forwarddiff-allocations/130006)

<div class="topic-metadata">

**Author:** [@elenev](https://discourse.julialang.org/u/elenev)\
**Replies:** 3\
**Last updated:** [June 19, 2025, 2:26am UTC](https://discourse.julialang.org/t/forwarddiff-allocations/130006 "2025-06-19T02:26:15Z")

</div>

I ran into a strange issue where very small changes to a non-allocating function affect whether it’s ForwardDiff.gradient! is allocating or not. Here is an MWE. It’s a vastly simplified version of my original structure,…

---

## [VS Code: clickable paths for unit test failures](https://discourse.julialang.org/t/vs-code-clickable-paths-for-unit-test-failures/130000)

<div class="topic-metadata">

**Author:** [@Ken\_Williams](https://discourse.julialang.org/u/Ken_Williams)\
**Replies:** 0\
**Last updated:** [June 18, 2025, 6:32pm UTC](https://discourse.julialang.org/t/vs-code-clickable-paths-for-unit-test-failures/130000 "2025-06-18T18:32:31Z")

</div>

In VS Code, having clickable and color-highlighted paths for stack traces is incredibly helpful in the REPL and some other contexts - but unfortunately for unit test failures (when running from the Testing pane), the err…

---

## [Formatting rules for Symbolic.arguments](https://discourse.julialang.org/t/formatting-rules-for-symbolic-arguments/129993)

<div class="topic-metadata">

**Author:** [@lukketotte](https://discourse.julialang.org/u/lukketotte)\
**Replies:** 3\
**Last updated:** [June 18, 2025, 2:53pm UTC](https://discourse.julialang.org/t/formatting-rules-for-symbolic-arguments/129993 "2025-06-18T14:53:03Z")

</div>

Hi everyone. New to symbolic algebra in Julia and have a question about getting arguments from Symbolic.jl (using v. 6.41.0) expression. Is there any reason for the following differing formatting behavior in \`Symbolics.a…

---

## [Sharing Julia Depots on Multi-User Platforms](https://discourse.julialang.org/t/sharing-julia-depots-on-multi-user-platforms/129961)

<div class="topic-metadata">

**Author:** [@Mini4Ever](https://discourse.julialang.org/u/Mini4Ever)\
**Replies:** 10\
**Last updated:** [June 18, 2025, 12:42pm UTC](https://discourse.julialang.org/t/sharing-julia-depots-on-multi-user-platforms/129961 "2025-06-18T12:42:43Z")

</div>

On a multi-user Linux platform, you want to install a Julia environment once while it is being used by many users (possibly at the same time). One can create a central installation of a Julia environment by exploiting th…

---

## [JupyterLab \*\*Lite\*\* and status of Julia running WASM](https://discourse.julialang.org/t/jupyterlab-lite-and-status-of-julia-running-wasm/129957)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 3\
**Last updated:** [June 18, 2025, 12:11pm UTC](https://discourse.julialang.org/t/jupyterlab-lite-and-status-of-julia-running-wasm/129957 "2025-06-18T12:11:28Z")

</div>

Hello, I have just discovered JupyterLab Lite \[repo\] - \[live\], where Python or R kernels can be run in the browser using WASM. This can be interesting in some didactical contexts, and as Julia is missing, I just wonder …

---

## [Macro-defined callable structs \`ArgumentError: invalid type for argument number 1 in method definition\`](https://discourse.julialang.org/t/macro-defined-callable-structs-argumenterror-invalid-type-for-argument-number-1-in-method-definition/129971)

<div class="topic-metadata">

**Author:** [@user664303](https://discourse.julialang.org/u/user664303)\
**Replies:** 3\
**Last updated:** [June 17, 2025, 6:07pm UTC](https://discourse.julialang.org/t/macro-defined-callable-structs-argumenterror-invalid-type-for-argument-number-1-in-method-definition/129971 "2025-06-17T18:07:39Z")

</div>

Running macro definestruct(name, ndims) return quote struct $name{T} v::Vector{T} end $name(v::Vector{T}) where T = $name{T}(v) nvars(::$name) = $ndims end end @define…

---

## [Matlab to Julia: Random number generators](https://discourse.julialang.org/t/matlab-to-julia-random-number-generators/129937)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 19\
**Last updated:** [June 17, 2025, 1:33pm UTC](https://discourse.julialang.org/t/matlab-to-julia-random-number-generators/129937 "2025-06-17T13:33:34Z")

</div>

I am writing unit tests for Matlab and Julia functions (Julia translated from Matlab), and both use the randn() function. Is there a way to get the same sequence of random numbers both in Matlab and Julia? Without that …

---

## [Nested indentation in show](https://discourse.julialang.org/t/nested-indentation-in-show/7191)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 5\
**Last updated:** [June 17, 2025, 11:32am UTC](https://discourse.julialang.org/t/nested-indentation-in-show/7191 "2025-06-17T11:32:02Z")

</div>

When writing some methods for show for types in a package, I was wondering if there is any mechanism (or package) for reusing show methods for fields but nesting the indentation. Eg suppose a type prints as This is a F…

---

## [Metaprogramming with list comprehensions](https://discourse.julialang.org/t/metaprogramming-with-list-comprehensions/129943)

<div class="topic-metadata">

**Author:** [@rokke](https://discourse.julialang.org/u/rokke)\
**Replies:** 11\
**Last updated:** [June 17, 2025, 11:29am UTC](https://discourse.julialang.org/t/metaprogramming-with-list-comprehensions/129943 "2025-06-17T11:29:47Z")

</div>

I feel like I’m always writing \[foo(a,b,c) for a, b, c in 1:n\] when I mean \[foo(a,b,c) for a in 1:n, b in 1:n, c in 1:n\], so I’d like to add something to my startup.jl to make it so. I feel like I’ve seen conflicting in…

---

## [File zipping taking longer for large files](https://discourse.julialang.org/t/file-zipping-taking-longer-for-large-files/115963)

<div class="topic-metadata">

**Author:** [@Sandy45](https://discourse.julialang.org/u/Sandy45)\
**Replies:** 16\
**Last updated:** [June 28, 2024, 2:34am UTC](https://discourse.julialang.org/t/file-zipping-taking-longer-for-large-files/115963 "2024-06-28T02:34:15Z")

</div>

I am trying to zip files in the directory which is around 300 - 400 MB and it’s taking more than 15 mins to finish. Initially I was using custom function written using ZipFile package. I have tried using Base.zip which i…

---

## [How to Manage Memory with Sequential, GPU-Intensive (e.g., PyTorch) Python Calls via PythonCall.jl](https://discourse.julialang.org/t/how-to-manage-memory-with-sequential-gpu-intensive-e-g-pytorch-python-calls-via-pythoncall-jl/129951)

<div class="topic-metadata">

**Author:** [@Dale\_James\_Black](https://discourse.julialang.org/u/Dale_James_Black)\
**Replies:** 0\
**Last updated:** [June 17, 2025, 1:07am UTC](https://discourse.julialang.org/t/how-to-manage-memory-with-sequential-gpu-intensive-e-g-pytorch-python-calls-via-pythoncall-jl/129951 "2025-06-17T01:07:18Z")

</div>

My Question I’m running into an issue where a long-running Python function seems to be terminated mid-execution. My question is: Are there any lower-level features or design patterns within PythonCall.jl that could help…

---

## [SymbolicUtils rules behave differenty for some trigonometric functions](https://discourse.julialang.org/t/symbolicutils-rules-behave-differenty-for-some-trigonometric-functions/129438)

<div class="topic-metadata">

**Author:** [@pmc4](https://discourse.julialang.org/u/pmc4)\
**Replies:** 4\
**Last updated:** [June 16, 2025, 1:52pm UTC](https://discourse.julialang.org/t/symbolicutils-rules-behave-differenty-for-some-trigonometric-functions/129438 "2025-06-16T13:52:40Z")

</div>

Hello. I’m trying to use SymbolicUtils to transform a product of simple trigonometric functions using some trigonometric identities. I have found some problems when applying the rules I define. I would like to understand…

---

## [Can we have pre-release versions in the registry? (v2)](https://discourse.julialang.org/t/can-we-have-pre-release-versions-in-the-registry-v2/129887)

<div class="topic-metadata">

**Author:** [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)\
**Replies:** 31\
**Last updated:** [June 16, 2025, 12:50pm UTC](https://discourse.julialang.org/t/can-we-have-pre-release-versions-in-the-registry-v2/129887 "2025-06-16T12:50:18Z")

</div>

TLDR: Problem: there is no way to register a pre-release of a package, which causes too much friction for potential early testers Goal: the general registry should allow pre-release candidates along the specification o…

---

## [Computed supertypes](https://discourse.julialang.org/t/computed-supertypes/129913)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 2\
**Last updated:** [June 16, 2025, 12:08pm UTC](https://discourse.julialang.org/t/computed-supertypes/129913 "2025-06-16T12:08:21Z")

</div>

I am wondering if supertypes that are computed are explicitly supported. Eg consider using Enzyme struct MockEnzymeMode \<: supertype(typeof(Enzyme.Reverse)) end where I construct an Enzyme.jl mode for testing an API (i…

---

## [Using preallocated arrays of unknown type](https://discourse.julialang.org/t/using-preallocated-arrays-of-unknown-type/129895)

<div class="topic-metadata">

**Author:** [@Miroboru](https://discourse.julialang.org/u/Miroboru)\
**Replies:** 6\
**Last updated:** [June 16, 2025, 10:26am UTC](https://discourse.julialang.org/t/using-preallocated-arrays-of-unknown-type/129895 "2025-06-16T10:26:11Z")

</div>

I have an optimization problem where I have a function f(x) that is given to the optimizer (I use Optim.jl with the LBFGS() method). Inside this function f, I have another function g(x, y) that returns an array v. funct…

---

## [Solving a complex second order PDEs coupling with ODEs](https://discourse.julialang.org/t/solving-a-complex-second-order-pdes-coupling-with-odes/128792)

<div class="topic-metadata">

**Author:** [@k\_zhou](https://discourse.julialang.org/u/k_zhou)\
**Replies:** 23\
**Last updated:** [June 16, 2025, 8:01am UTC](https://discourse.julialang.org/t/solving-a-complex-second-order-pdes-coupling-with-odes/128792 "2025-06-16T08:01:45Z")

</div>

Hi, I try to solve a system including two 2nd order PDEs (as shown in the figure) coupling with six 1st ODEs. When I set the k’’ to zero, the PDEs transform to the 1st PDEs, and i can solve it using the ROCK4 in GPU. …

---

## [Getting my Julia package into the Julia General Registry](https://discourse.julialang.org/t/getting-my-julia-package-into-the-julia-general-registry/129908)

<div class="topic-metadata">

**Author:** [@pvkabaila](https://discourse.julialang.org/u/pvkabaila)\
**Replies:** 4\
**Last updated:** [June 16, 2025, 7:31am UTC](https://discourse.julialang.org/t/getting-my-julia-package-into-the-julia-general-registry/129908 "2025-06-16T07:31:49Z")

</div>

My Julia package CustomGaussQuadrature.jl is in a repository on my GitHub account. Using the description “How to develop a Julia package”, by Chris Rackauskas, I created a new Issue for this repository and entered the c…

---

## [How to actually make a main function](https://discourse.julialang.org/t/how-to-actually-make-a-main-function/129881)

<div class="topic-metadata">

**Author:** [@The\_Mastermage](https://discourse.julialang.org/u/The_Mastermage)\
**Replies:** 7\
**Last updated:** [June 15, 2025, 11:01pm UTC](https://discourse.julialang.org/t/how-to-actually-make-a-main-function/129881 "2025-06-15T23:01:02Z")

</div>

Whilst trying to write a small HTTP server just for fun. I was trying to figure out how to use an actual main function. I am most of the time usualy just scripting, so I havent realy used the new @main syntax yet. The f…

---

## [How to use NumPy slices in 2d for PyPlot's GridSpec](https://discourse.julialang.org/t/how-to-use-numpy-slices-in-2d-for-pyplots-gridspec/40023)

<div class="topic-metadata">

**Author:** [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Replies:** 3\
**Last updated:** [June 15, 2025, 1:06pm UTC](https://discourse.julialang.org/t/how-to-use-numpy-slices-in-2d-for-pyplots-gridspec/40023 "2025-06-15T13:06:52Z")

</div>

I am trying to create a plot with multiple subplots in PyPlot. For that I am using matplotlib’s GridSpec . Some of the usage is given by NumPy slices as seen in their example from the docs: fig8 = plt.figure(constraine…

---

## [Yet another language benchmark](https://discourse.julialang.org/t/yet-another-language-benchmark/127924)

<div class="topic-metadata">

**Author:** [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Replies:** 9\
**Last updated:** [June 15, 2025, 12:13pm UTC](https://discourse.julialang.org/t/yet-another-language-benchmark/127924 "2025-06-15T12:13:00Z")

</div>

I like the visuals in this one. As usual, Julia compilation seems to be included in the results: P.S.: we don’t have a HPC category on discourse. Should it be created? The GPU and Julia at Scale categories could be su…

---

## [Read!( ) not working for HDF5 file](https://discourse.julialang.org/t/read-not-working-for-hdf5-file/129722)

<div class="topic-metadata">

**Author:** [@raman\_kumar](https://discourse.julialang.org/u/raman_kumar)\
**Replies:** 1\
**Last updated:** [June 15, 2025, 11:46am UTC](https://discourse.julialang.org/t/read-not-working-for-hdf5-file/129722 "2025-06-15T11:46:24Z")

</div>

I have an HDF5 file. I want to read or allocate its data in variable r repeatedly instead of allocating in different places :seat: in memory. using HDF5 fname = tempname(); # temporary file fid = h5open(fname, "w") cre…

---

## [Looking for DiffEQArrayOperator replacement](https://discourse.julialang.org/t/looking-for-diffeqarrayoperator-replacement/128494)

<div class="topic-metadata">

**Author:** [@cardoza2](https://discourse.julialang.org/u/cardoza2)\
**Replies:** 2\
**Last updated:** [June 14, 2025, 7:54pm UTC](https://discourse.julialang.org/t/looking-for-diffeqarrayoperator-replacement/128494 "2025-06-14T19:54:00Z")

</div>

Hi, I got asked to maintain a package that someone else in my research group developed, so I apologize if this question is off topic. The package I’m working on uses SciMLBase v1, but I’m looking to update to v2. Previ…

---

## [Efficiency of abstract types vs \`Any\`](https://discourse.julialang.org/t/efficiency-of-abstract-types-vs-any/129518)

<div class="topic-metadata">

**Author:** [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)\
**Replies:** 13\
**Last updated:** [June 13, 2025, 11:02pm UTC](https://discourse.julialang.org/t/efficiency-of-abstract-types-vs-any/129518 "2025-06-13T23:02:21Z")

</div>

This is a subtle point I wanted to learn a bit more about. I want to know all reasons why I might wish to write: # assume we have \`abstract type MyType end\` MyType\[x...\] Rather than Any\[x...\] Assuming we have: abst…

---

## [Parametric constructor where type being constructed is parameter](https://discourse.julialang.org/t/parametric-constructor-where-type-being-constructed-is-parameter/129866)

<div class="topic-metadata">

**Author:** [@luke-kiernan](https://discourse.julialang.org/u/luke-kiernan)\
**Replies:** 2\
**Last updated:** [June 13, 2025, 8:19pm UTC](https://discourse.julialang.org/t/parametric-constructor-where-type-being-constructed-is-parameter/129866 "2025-06-13T20:19:02Z")

</div>

I have multiple structs (FooKey and BarKey), each of which has its own type parameter (FooType and BarType). Can I write the constructor for these structs in a parametrized manner? Here’s my attempt: abstract type AllTy…

---

## [Translating Matlab to Julia](https://discourse.julialang.org/t/translating-matlab-to-julia/129864)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 4\
**Last updated:** [June 13, 2025, 5:39pm UTC](https://discourse.julialang.org/t/translating-matlab-to-julia/129864 "2025-06-13T17:39:14Z")

</div>

I am translating some code from Matlab to Julia. I found out that the author is using a lot of Matlab functions with the same name but different functionality, which are stored in different folders. Before using these …

---

## [Unable to calculate the gradient of opnorm/svdvals/svd on gpu?](https://discourse.julialang.org/t/unable-to-calculate-the-gradient-of-opnorm-svdvals-svd-on-gpu/129852)

<div class="topic-metadata">

**Author:** [@camilodlt](https://discourse.julialang.org/u/camilodlt)\
**Replies:** 9\
**Last updated:** [June 13, 2025, 2:39pm UTC](https://discourse.julialang.org/t/unable-to-calculate-the-gradient-of-opnorm-svdvals-svd-on-gpu/129852 "2025-06-13T14:39:13Z")

</div>

Hello, I’m able to calculate the gradients of the spectral norm in CPU but not in GPU :disappointed: This works fine : julia\> using CUDA, Zygote, LinearAlgebra julia\> X = randn(Float32, 5, 1); julia\> function snorm(…

---

## [Documentation Formats - epub mobi pdf](https://discourse.julialang.org/t/documentation-formats-epub-mobi-pdf/7700)

<div class="topic-metadata">

**Author:** [@guslen](https://discourse.julialang.org/u/guslen)\
**Replies:** 11\
**Last updated:** [June 13, 2025, 1:51pm UTC](https://discourse.julialang.org/t/documentation-formats-epub-mobi-pdf/7700 "2025-06-13T13:51:12Z")

</div>

Hi, I was wondering, if there is any chance that you could publish an ebook-version for the documentation (docs.julialang.org) which is automatically generated? possible formats like: epub, pdf or mobi This would be u…

---

## [Nothing == absence of keyword argument?](https://discourse.julialang.org/t/nothing-absence-of-keyword-argument/108119)

<div class="topic-metadata">

**Author:** [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Replies:** 15\
**Last updated:** [June 13, 2025, 1:35pm UTC](https://discourse.julialang.org/t/nothing-absence-of-keyword-argument/108119 "2025-06-13T13:35:30Z")

</div>

Is there a convenient idiom to indicate that a keyword argument is absent? I imagine that somebody may have already invented a macro or something to do this . . . There are library functions, typically from graphics pa…

---

## [Is it possible to reinterpret and reshape without allocating?](https://discourse.julialang.org/t/is-it-possible-to-reinterpret-and-reshape-without-allocating/129842)

<div class="topic-metadata">

**Author:** [@AwesomeQuest](https://discourse.julialang.org/u/AwesomeQuest)\
**Replies:** 11\
**Last updated:** [June 13, 2025, 9:18am UTC](https://discourse.julialang.org/t/is-it-possible-to-reinterpret-and-reshape-without-allocating/129842 "2025-06-13T09:18:28Z")

</div>

So I have data I’m getting over HTTP, r = rand(UInt8, 847296) It is arraigned in 3 8 byte chunks, where the first chunk is unwanted metadata, so every 3n -2 chunks is unwanted. I have written a function that does this…

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

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