# General Usage

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

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

**Page:** 281

---

## [How to get a handle to the Terminal](https://discourse.julialang.org/t/how-to-get-a-handle-to-the-terminal/99592)

<div class="topic-metadata">

**Author:** [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Replies:** 2\
**Last updated:** [June 13, 2023, 11:05am UTC](https://discourse.julialang.org/t/how-to-get-a-handle-to-the-terminal/99592 "2023-06-13T11:05:50Z")

</div>

Let’s say I want to clear my terminal programmatically, i.e. not with Ctrl+l, but by running Julia code. I can do the following: import REPL julia\> t = REPL.Terminals.TTYTerminal(string(), stdin, stdout, stderr) REPL.Te…

---

## [Custom Iterator with one big computation at the begin + in place operation at every iterations](https://discourse.julialang.org/t/custom-iterator-with-one-big-computation-at-the-begin-in-place-operation-at-every-iterations/100045)

<div class="topic-metadata">

**Author:** [@dmetivie](https://discourse.julialang.org/u/dmetivie)\
**Replies:** 2\
**Last updated:** [June 13, 2023, 11:44am UTC](https://discourse.julialang.org/t/custom-iterator-with-one-big-computation-at-the-begin-in-place-operation-at-every-iterations/100045 "2023-06-13T11:44:15Z")

</div>

I am trying to build a custom iterator for the QuasiMonteCarlo.jl package. I did not find an example doing the kind of things I want. I need first to generate 3 big matrices for 1:M “randomize” in place these matr…

---

## [Question on simple performance comparison between Python and Julia](https://discourse.julialang.org/t/question-on-simple-performance-comparison-between-python-and-julia/100225)

<div class="topic-metadata">

**Author:** [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Replies:** 23\
**Last updated:** [June 13, 2023, 8:38am UTC](https://discourse.julialang.org/t/question-on-simple-performance-comparison-between-python-and-julia/100225 "2023-06-13T08:38:12Z")

</div>

I ran the following for loops with Python and Julia respectively on the terminal by commands python test.py and julia test.jl, but it turned out that Python (≈ 37 sec) spent less time than Julia (≈ 52 sec). Why? test.py…

---

## [Why running remote ssh cmd in threads is still blocked?](https://discourse.julialang.org/t/why-running-remote-ssh-cmd-in-threads-is-still-blocked/100262)

<div class="topic-metadata">

**Author:** [@peng](https://discourse.julialang.org/u/peng)\
**Replies:** 8\
**Last updated:** [June 13, 2023, 7:04am UTC](https://discourse.julialang.org/t/why-running-remote-ssh-cmd-in-threads-is-still-blocked/100262 "2023-06-13T07:04:48Z")

</div>

Hi there, I want to run some commands on remote machine. I use julia to manage my commands. To avoid blocking in main threads, I run the commands in a spawned thread.For example: cmd = """ sleep 3 echo Hello """ Threads…

---

## [Why does the following setindex call allocate?](https://discourse.julialang.org/t/why-does-the-following-setindex-call-allocate/100216)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 6\
**Last updated:** [June 12, 2023, 10:15am UTC](https://discourse.julialang.org/t/why-does-the-following-setindex-call-allocate/100216 "2023-06-12T10:15:04Z")

</div>

julia\> function f!(v, A, r) v\[eachindex(r)\] = @view A\[r\] v end f! (generic function with 1 method) julia\> v = zeros(10); A = ones(4,10); julia\> @btime f!($v, $A, 4:3:13); 56.050 ns (2 all…

---

## [DiffEqFlux.initial\_params not defined](https://discourse.julialang.org/t/diffeqflux-initial-params-not-defined/100156)

<div class="topic-metadata">

**Author:** [@Reza\_AO](https://discourse.julialang.org/u/Reza_AO)\
**Replies:** 3\
**Last updated:** [June 13, 2023, 2:08am UTC](https://discourse.julialang.org/t/diffeqflux-initial-params-not-defined/100156 "2023-06-13T02:08:20Z")

</div>

Hi I want to run a PINN code on my GPU. I used to use the code below to run the code on my GPU and I also want to use QuasiRanodmTraining. initθ = DiffEqFlux.initial\_params(chain) |\> gpu I get the error below: ERROR…

---

## [How to pick out selected output components of a named tuple?](https://discourse.julialang.org/t/how-to-pick-out-selected-output-components-of-a-named-tuple/100209)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 13\
**Last updated:** [June 13, 2023, 1:50am UTC](https://discourse.julialang.org/t/how-to-pick-out-selected-output-components-of-a-named-tuple/100209 "2023-06-13T01:50:50Z")

</div>

I have a function f() = (a=1, b=2, c=3) , and I can pick out one of the returned components of the tuple as julia\> f().a 1 Can I select in this way a and at the same time c? In other words, I would l…

---

## [Writing matrix in Julia](https://discourse.julialang.org/t/writing-matrix-in-julia/100253)

<div class="topic-metadata">

**Author:** [@Umishra](https://discourse.julialang.org/u/Umishra)\
**Replies:** 1\
**Last updated:** [June 13, 2023, 1:19am UTC](https://discourse.julialang.org/t/writing-matrix-in-julia/100253 "2023-06-13T01:19:18Z")

</div>

I wanted to write matrix for the total coin angular momentum with the following code mvalues = -j:1:j cardinality = length(mvalues) Jminus is zero except for directly above the diagonal There is an implicit \\hbar & sq…

---

## [Hessian of a buffer array in Zygote](https://discourse.julialang.org/t/hessian-of-a-buffer-array-in-zygote/100249)

<div class="topic-metadata">

**Author:** [@tomkimpson](https://discourse.julialang.org/u/tomkimpson)\
**Replies:** 0\
**Last updated:** [June 12, 2023, 10:25pm UTC](https://discourse.julialang.org/t/hessian-of-a-buffer-array-in-zygote/100249 "2023-06-12T22:25:38Z")

</div>

I have a function which takes some coordinates, a parameter, and creates a 2D array. I want to get the Jacobian and the Hessian of this array w.r.t the input coordinates using Zygote. The Jacobian works fine, but the H…

---

## [What is the correct way to ignore some files/directories in \`walkdir\`](https://discourse.julialang.org/t/what-is-the-correct-way-to-ignore-some-files-directories-in-walkdir/26780)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 4\
**Last updated:** [June 12, 2023, 7:27pm UTC](https://discourse.julialang.org/t/what-is-the-correct-way-to-ignore-some-files-directories-in-walkdir/26780 "2023-06-12T19:27:08Z")

</div>

I am trying to use JLFmt and FilePaths to write a script (~/.julia/config/format.jl) that can format all Julia code under my project root (a typical Julia package). using FilePaths using JLFmt isjuliafile(path::Abstrac…

---

## [Issue with XGBoost.jl and LIBSVM.jl when Julia 1.8.4](https://discourse.julialang.org/t/issue-with-xgboost-jl-and-libsvm-jl-when-julia-1-8-4/92396)

<div class="topic-metadata">

**Author:** [@matnbo](https://discourse.julialang.org/u/matnbo)\
**Replies:** 52\
**Last updated:** [June 12, 2023, 6:37pm UTC](https://discourse.julialang.org/t/issue-with-xgboost-jl-and-libsvm-jl-when-julia-1-8-4/92396 "2023-06-12T18:37:21Z")

</div>

Dear all I am using XGBoost.jl v2.2.0 and LIBSVM.jl v0.8.0, under Windows 11. It works fine with Julia 1.8.3 versioninfo() Julia Version 1.8.3 Commit 0434deb161 (2022-11-14 20:14 UTC) Platform Info: OS: Windows (x86…

---

## [Problem with \`Interpolations.jl\`?](https://discourse.julialang.org/t/problem-with-interpolations-jl/100236)

<div class="topic-metadata">

**Author:** [@frylock](https://discourse.julialang.org/u/frylock)\
**Replies:** 3\
**Last updated:** [June 12, 2023, 4:50pm UTC](https://discourse.julialang.org/t/problem-with-interpolations-jl/100236 "2023-06-12T16:50:08Z")

</div>

I’m running 1.9.1, and trying to follow along with the documentation. xs = 1:0.2:5 A = log.(xs) linear\_interpolation(xs, A) # works fine linear\_interpolation(xs, A,extrapolation\_bc=Line()) # also works fine extrapolate…

---

## [How to choose between \`PyCall.jl\` and \`PythonCall.jl\`?](https://discourse.julialang.org/t/how-to-choose-between-pycall-jl-and-pythoncall-jl/100214)

<div class="topic-metadata">

**Author:** [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Replies:** 6\
**Last updated:** [June 12, 2023, 1:55pm UTC](https://discourse.julialang.org/t/how-to-choose-between-pycall-jl-and-pythoncall-jl/100214 "2023-06-12T13:55:25Z")

</div>

I noticed there exist at least two packages PyCall.jl and PythonCall.jl for calling Python from Julia. What’s the difference between them? Which is better for a new user to choose? Thanks!

---

## [Extending functionality of an Abstract Type in a new repo](https://discourse.julialang.org/t/extending-functionality-of-an-abstract-type-in-a-new-repo/100192)

<div class="topic-metadata">

**Author:** [@weymouth](https://discourse.julialang.org/u/weymouth)\
**Replies:** 12\
**Last updated:** [June 12, 2023, 12:48pm UTC](https://discourse.julialang.org/t/extending-functionality-of-an-abstract-type-in-a-new-repo/100192 "2023-06-12T12:48:44Z")

</div>

How can I define a new type in a new package that extends an abstract type in an old package such that functions in the old package work when passed objects of the new type? I have a type AbstractBody in WaterLily and I…

---

## [Could Someone Explain To Me the Desire for Small Julia Binaries?](https://discourse.julialang.org/t/could-someone-explain-to-me-the-desire-for-small-julia-binaries/96484)

<div class="topic-metadata">

**Author:** [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Replies:** 41\
**Last updated:** [June 12, 2023, 10:55am UTC](https://discourse.julialang.org/t/could-someone-explain-to-me-the-desire-for-small-julia-binaries/96484 "2023-06-12T10:55:17Z")

</div>

Hi folks, I’ve seen this notion pop-up repeatedly about wanting small binaries created within the Julia ecosystem. I personally have been quite confused about this desire due to probably not working in a space where hav…

---

## [PyCall minimal overhead](https://discourse.julialang.org/t/pycall-minimal-overhead/41127)

<div class="topic-metadata">

**Author:** [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Replies:** 15\
**Last updated:** [June 12, 2023, 8:01am UTC](https://discourse.julialang.org/t/pycall-minimal-overhead/41127 "2023-06-12T08:01:00Z")

</div>

Hi, I work on a Julia benchmark Data Base project aiming to compare different implementations of basic computational kernels implemented in various languages. I wonder about the most efficient way to call a Python snip…

---

## [Should I turn a registered package into a package extension? What are the differences between them?](https://discourse.julialang.org/t/should-i-turn-a-registered-package-into-a-package-extension-what-are-the-differences-between-them/100203)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 1\
**Last updated:** [June 12, 2023, 7:53am UTC](https://discourse.julialang.org/t/should-i-turn-a-registered-package-into-a-package-extension-what-are-the-differences-between-them/100203 "2023-06-12T07:53:11Z")

</div>

For example, if I have a base package and an extension package that is loaded only when some criteria are satisfied. And this extension package has been registered in General. Now that v1.9 include the “package extension…

---

## [Run tests with unreleased version of dependency](https://discourse.julialang.org/t/run-tests-with-unreleased-version-of-dependency/100205)

<div class="topic-metadata">

**Author:** [@simonbyrne](https://discourse.julialang.org/u/simonbyrne)\
**Replies:** 1\
**Last updated:** [June 11, 2023, 11:50pm UTC](https://discourse.julialang.org/t/run-tests-with-unreleased-version-of-dependency/100205 "2023-06-11T23:50:46Z")

</div>

I have two packages, A and B (which depends on A): is there an easy way to run Pkg.test on B, but force it to use a specific commit of A (which may not yet be released)?

---

## [Precompiling packages yields an encoding error that repeatedly prints](https://discourse.julialang.org/t/precompiling-packages-yields-an-encoding-error-that-repeatedly-prints/100200)

<div class="topic-metadata">

**Author:** [@johnabs](https://discourse.julialang.org/u/johnabs)\
**Replies:** 0\
**Last updated:** [June 11, 2023, 9:13pm UTC](https://discourse.julialang.org/t/precompiling-packages-yields-an-encoding-error-that-repeatedly-prints/100200 "2023-06-11T21:13:31Z")

</div>

Hi all, I’m witnessing some very strange behavior, which I’ve never seen before. I’m on julia version 1.8.3, and when I run julia, even julia --version, or when I try to run using $package\_name which precompiles it, I k…

---

## [Multivariate polynomial with symbolic values in the coefficients](https://discourse.julialang.org/t/multivariate-polynomial-with-symbolic-values-in-the-coefficients/84311)

<div class="topic-metadata">

**Author:** [@\_stla](https://discourse.julialang.org/u/_stla)\
**Replies:** 18\
**Last updated:** [June 11, 2023, 8:12pm UTC](https://discourse.julialang.org/t/multivariate-polynomial-with-symbolic-values-in-the-coefficients/84311 "2023-06-11T20:12:28Z")

</div>

Hello, With Sympy in Python, it is possible to define a polynomial such as x^2 + a\*x^2 + 2/3\*y + b\*y + x\*z + a\*x\*z with symbolic variables x,y,z and also symbolic numbers a,b in the coefficients. In other words this i…

---

## [How to compute 2D Wasserstein distance](https://discourse.julialang.org/t/how-to-compute-2d-wasserstein-distance/100184)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 12\
**Last updated:** [June 11, 2023, 6:39pm UTC](https://discourse.julialang.org/t/how-to-compute-2d-wasserstein-distance/100184 "2023-06-11T18:39:42Z")

</div>

Hello, I would like to compute the Wasserstein distance between two discrete joint probability distributions. The package ExactOptimalTransport.jl does not appear to support 2D distance, but I wonder whether it can be a…

---

## [How to pass command-line arguments to Jupyter Notebook?](https://discourse.julialang.org/t/how-to-pass-command-line-arguments-to-jupyter-notebook/100148)

<div class="topic-metadata">

**Author:** [@yhchang96](https://discourse.julialang.org/u/yhchang96)\
**Replies:** 1\
**Last updated:** [June 11, 2023, 2:11pm UTC](https://discourse.julialang.org/t/how-to-pass-command-line-arguments-to-jupyter-notebook/100148 "2023-06-11T14:11:30Z")

</div>

How do I pass command line arguments when I run Julia using Jupyter notebook? When I use VS Code to run Julia, I can go to settings and set "julia.additionalArgs": \[ "--heap-size-hint=1G" \], what about J…

---

## [Unpacking a named tuple using field names and slurping?](https://discourse.julialang.org/t/unpacking-a-named-tuple-using-field-names-and-slurping/100035)

<div class="topic-metadata">

**Author:** [@onetonfoot](https://discourse.julialang.org/u/onetonfoot)\
**Replies:** 15\
**Last updated:** [June 11, 2023, 6:24am UTC](https://discourse.julialang.org/t/unpacking-a-named-tuple-using-field-names-and-slurping/100035 "2023-06-11T06:24:07Z")

</div>

I’ve got a named tuple with a bunch of fields and I’d like to unpack certain fields based on the key and slurp the remaining. r = (x=1, y=2, z=3) (y, rest...) = r The trouble with the above is that it will unpack bas…

---

## [Performance of hasmethod vs try-catch on MethodError](https://discourse.julialang.org/t/performance-of-hasmethod-vs-try-catch-on-methoderror/99827)

<div class="topic-metadata">

**Author:** [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)\
**Replies:** 22\
**Last updated:** [June 11, 2023, 4:31am UTC](https://discourse.julialang.org/t/performance-of-hasmethod-vs-try-catch-on-methoderror/99827 "2023-06-11T04:31:24Z")

</div>

To help me better understand Julia’s performance behavior, I am trying to understand the large difference between two strategies for checking for undefined methods: hasmethod vs try-catch. I’ve read through Are exceptio…

---

## [Activation functions in NeuralPDE](https://discourse.julialang.org/t/activation-functions-in-neuralpde/100153)

<div class="topic-metadata">

**Author:** [@Ethan\_Tran](https://discourse.julialang.org/u/Ethan_Tran)\
**Replies:** 5\
**Last updated:** [June 11, 2023, 3:45am UTC](https://discourse.julialang.org/t/activation-functions-in-neuralpde/100153 "2023-06-11T03:45:30Z")

</div>

Hi everyone, I am trying to use NeuralPDE to solve ODE systems. I would like to ask that whether NeuralPDE provide different activation function like Softmax, Tanh or just only Sigmoid? If yes, how could I find the in…

---

## [Why are functions that are never called getting compiled?](https://discourse.julialang.org/t/why-are-functions-that-are-never-called-getting-compiled/100072)

<div class="topic-metadata">

**Author:** [@user664303](https://discourse.julialang.org/u/user664303)\
**Replies:** 8\
**Last updated:** [June 10, 2023, 10:25pm UTC](https://discourse.julialang.org/t/why-are-functions-that-are-never-called-getting-compiled/100072 "2023-06-10T22:25:28Z")

</div>

Previously I asked about, and solved, a problem with compilation of a function inside generated code - the problem was that multiple instances of a function were getting compiled without being called. I would like to avo…

---

## [Tab completion and Unicode names for values not in Julia Documentation](https://discourse.julialang.org/t/tab-completion-and-unicode-names-for-values-not-in-julia-documentation/100152)

<div class="topic-metadata">

**Author:** [@daler6](https://discourse.julialang.org/u/daler6)\
**Replies:** 1\
**Last updated:** [June 10, 2023, 10:17pm UTC](https://discourse.julialang.org/t/tab-completion-and-unicode-names-for-values-not-in-julia-documentation/100152 "2023-06-10T22:17:14Z")

</div>

I am using the book Julia as a Second Language and at points it uses symbols with Unicode points not included in the Julia documentation (see Unicode Input · The Julia Language). Specifically, it uses several from the Bo…

---

## [Inconsistent results when using Threads.@threads in a loop](https://discourse.julialang.org/t/inconsistent-results-when-using-threads-threads-in-a-loop/100134)

<div class="topic-metadata">

**Author:** [@fedcer](https://discourse.julialang.org/u/fedcer)\
**Replies:** 17\
**Last updated:** [June 10, 2023, 8:21pm UTC](https://discourse.julialang.org/t/inconsistent-results-when-using-threads-threads-in-a-loop/100134 "2023-06-10T20:21:05Z")

</div>

Hi all, I’m running into the problem of having inconsistent outputs when using the Threads.@threads macro on a loop and I struggle to understand why it’s happening. Here is a MWE function function coefs(N) v = zero…

---

## [PackageCompiler - Understand how compilation works](https://discourse.julialang.org/t/packagecompiler-understand-how-compilation-works/100142)

<div class="topic-metadata">

**Author:** [@iskyd](https://discourse.julialang.org/u/iskyd)\
**Replies:** 3\
**Last updated:** [June 10, 2023, 6:01pm UTC](https://discourse.julialang.org/t/packagecompiler-understand-how-compilation-works/100142 "2023-06-10T18:01:54Z")

</div>

I’m creating an app using PackageCompiler.jl as described here I’m trying to create an executable of a simple backend application. PackageCompiler works fine since I am able to generate a binary to run my application. W…

---

## [What are the essential differences between \`include\` a file and \`using\` a module?](https://discourse.julialang.org/t/what-are-the-essential-differences-between-include-a-file-and-using-a-module/99798)

<div class="topic-metadata">

**Author:** [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Replies:** 3\
**Last updated:** [June 10, 2023, 11:40am UTC](https://discourse.julialang.org/t/what-are-the-essential-differences-between-include-a-file-and-using-a-module/99798 "2023-06-10T11:40:29Z")

</div>

What are the essential differences between the following two workflows and what are their respective usage scenarios? Or in another word, what’s the necessity for writing a module instead of a plain .jl file? Write som…

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

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