# General Usage

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

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

**Page:** 438

---

## [Matrix indexing and manipulation](https://discourse.julialang.org/t/matrix-indexing-and-manipulation/82563)

<div class="topic-metadata">

**Author:** [@Emilio](https://discourse.julialang.org/u/Emilio)\
**Replies:** 2\
**Last updated:** [June 10, 2022, 1:15pm UTC](https://discourse.julialang.org/t/matrix-indexing-and-manipulation/82563 "2022-06-10T13:15:11Z")

</div>

Hello there! I’m quite new to Julia and facing following issue: assume that we have a matrix: mat = \[1 2 3 4; 2 3 4 5\] and I want to manipulate a single value from a part of the matrix like this: mat\[1:3,1:3\]\[1\] = 2 t…

---

## [Application does not load all artifacts during compilation](https://discourse.julialang.org/t/application-does-not-load-all-artifacts-during-compilation/82493)

<div class="topic-metadata">

**Author:** [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Replies:** 4\
**Last updated:** [June 10, 2022, 11:52am UTC](https://discourse.julialang.org/t/application-does-not-load-all-artifacts-during-compilation/82493 "2022-06-10T11:52:50Z")

</div>

I’m currently trying to compile an app using PackageCompiler. The associated project App depends on two packages Foo and Bar. Foo itself depends on MKL which depends on MKL\_jll (which are present in the Manifest.toml of…

---

## [View or copy: looking for an overview](https://discourse.julialang.org/t/view-or-copy-looking-for-an-overview/82495)

<div class="topic-metadata">

**Author:** [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Replies:** 8\
**Last updated:** [June 9, 2022, 8:29pm UTC](https://discourse.julialang.org/t/view-or-copy-looking-for-an-overview/82495 "2022-06-09T20:29:42Z")

</div>

I am looking for an overview/recommendations on the classical view or copy issue. Any links? Background: even in a simple case like sum(x\[ind\]) versus sum(view(x,ind)), the former seems to be faster in many cases (eg.…

---

## [Undesired and inconsistent returning of NaN when instantiating a custom structure several times](https://discourse.julialang.org/t/undesired-and-inconsistent-returning-of-nan-when-instantiating-a-custom-structure-several-times/82529)

<div class="topic-metadata">

**Author:** [@klaus.68](https://discourse.julialang.org/u/klaus.68)\
**Replies:** 5\
**Last updated:** [June 10, 2022, 3:31am UTC](https://discourse.julialang.org/t/undesired-and-inconsistent-returning-of-nan-when-instantiating-a-custom-structure-several-times/82529 "2022-06-10T03:31:16Z")

</div>

Hi, This is my first post to the boards about a behavior I haven’t seen yet in a forum (appreciate any direction to a post if it exists!). I was attempting to build a b-spline structure atop a polynomial structure, and …

---

## [Successful Static Compilation of Julia Code for use in Production](https://discourse.julialang.org/t/successful-static-compilation-of-julia-code-for-use-in-production/79318)

<div class="topic-metadata">

**Author:** [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Replies:** 9\
**Last updated:** [June 10, 2022, 2:11am UTC](https://discourse.julialang.org/t/successful-static-compilation-of-julia-code-for-use-in-production/79318 "2022-06-10T02:11:36Z")

</div>

The StaticCompiler package was recently registered. This post records a successful experiment to statically compile a piece of Julia code into a small .so library on Linux, which is then loaded from Python and used in tr…

---

## [Is this a good illustration of the principle "Don't store fields you can compute on demand"?](https://discourse.julialang.org/t/is-this-a-good-illustration-of-the-principle-dont-store-fields-you-can-compute-on-demand/82496)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 6\
**Last updated:** [June 9, 2022, 10:26pm UTC](https://discourse.julialang.org/t/is-this-a-good-illustration-of-the-principle-dont-store-fields-you-can-compute-on-demand/82496 "2022-06-09T22:26:17Z")

</div>

Motivation I was reading @jakobnissen 's blog post about optimizing Julia code and came across this interesting tip: Do not store fields that can easily be computed on demand. In my code, I am working on a numerical …

---

## [Differences of Core.eval vs. running the code directly in other modules then Main](https://discourse.julialang.org/t/differences-of-core-eval-vs-running-the-code-directly-in-other-modules-then-main/82489)

<div class="topic-metadata">

**Author:** [@sfuerst](https://discourse.julialang.org/u/sfuerst)\
**Replies:** 4\
**Last updated:** [June 9, 2022, 9:27pm UTC](https://discourse.julialang.org/t/differences-of-core-eval-vs-running-the-code-directly-in-other-modules-then-main/82489 "2022-06-09T21:27:47Z")

</div>

While writing the documentation of a package I’m currently developing, I did ran into a problem with Documenter.jl which I could track down to the sandboxing mechanism of Documenter in combination with Core.eval. Withou…

---

## [\[ANN\] Sparspak: suite of solvers for linear algebraic equations in Julia](https://discourse.julialang.org/t/ann-sparspak-suite-of-solvers-for-linear-algebraic-equations-in-julia/82461)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 8\
**Last updated:** [June 9, 2022, 8:45pm UTC](https://discourse.julialang.org/t/ann-sparspak-suite-of-solvers-for-linear-algebraic-equations-in-julia/82461 "2022-06-09T20:45:36Z")

</div>

\# Sparspak.jl Translation into Julia of the well-known sparse matrix software Sparspak (Waterloo Sparse Matrix Package) for solving large sparse systems of linear algebraic equations. Sparspak was composed originally o…

---

## [Interpolation using $ with @cfunction in a macro reported as a closure, thus won't work on Apple Silicon](https://discourse.julialang.org/t/interpolation-using-with-cfunction-in-a-macro-reported-as-a-closure-thus-wont-work-on-apple-silicon/75984)

<div class="topic-metadata">

**Author:** [@jackbeagley](https://discourse.julialang.org/u/jackbeagley)\
**Replies:** 8\
**Last updated:** [June 9, 2022, 8:44pm UTC](https://discourse.julialang.org/t/interpolation-using-with-cfunction-in-a-macro-reported-as-a-closure-thus-wont-work-on-apple-silicon/75984 "2022-06-09T20:44:08Z")

</div>

I’m still learning about macros and only recently learnt about closures. I am trying to use the ArchGDAL package on my Apple Silicon Macbook, but it reported an error during precompilation: ERROR: LoadError: cfunction: c…

---

## [Juliaup breaks after failed auto upgrade](https://discourse.julialang.org/t/juliaup-breaks-after-failed-auto-upgrade/82521)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 1\
**Last updated:** [June 9, 2022, 6:54pm UTC](https://discourse.julialang.org/t/juliaup-breaks-after-failed-auto-upgrade/82521 "2022-06-09T18:54:35Z")

</div>

I’m getting this error when trying to start Julia from juliaup. A few days ago it worked. Note that I get back to the shell, then julia starts, but soon later I get those “IOError” stream errors. Any idea? ~% julia The…

---

## [How to make Julia code faster than python code?](https://discourse.julialang.org/t/how-to-make-julia-code-faster-than-python-code/82381)

<div class="topic-metadata">

**Author:** [@YitaoCai](https://discourse.julialang.org/u/YitaoCai)\
**Replies:** 10\
**Last updated:** [June 9, 2022, 6:02pm UTC](https://discourse.julialang.org/t/how-to-make-julia-code-faster-than-python-code/82381 "2022-06-09T18:02:36Z")

</div>

I found my Juila code is way slower than python code, it keeps running for more than 2 hours and no results, so I terminated it. Python code gave results in 1 hour. Here is the original python code: def ImageTiler(file…

---

## [Application compilation does not account for required code](https://discourse.julialang.org/t/application-compilation-does-not-account-for-required-code/82515)

<div class="topic-metadata">

**Author:** [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Replies:** 1\
**Last updated:** [June 9, 2022, 4:59pm UTC](https://discourse.julialang.org/t/application-compilation-does-not-account-for-required-code/82515 "2022-06-09T16:59:39Z")

</div>

I’m currently trying to compile an app using PackageCompiler. The associated project App depends on two packages Foo and Bar. Foo contains a bit of glue code to link with Bar-provided functionnalities. These portion of…

---

## [Understanding NLSolvers Package through the Given Documentation](https://discourse.julialang.org/t/understanding-nlsolvers-package-through-the-given-documentation/82512)

<div class="topic-metadata">

**Author:** [@MJF](https://discourse.julialang.org/u/MJF)\
**Replies:** 0\
**Last updated:** [June 9, 2022, 4:22pm UTC](https://discourse.julialang.org/t/understanding-nlsolvers-package-through-the-given-documentation/82512 "2022-06-09T16:22:07Z")

</div>

I am quite new to Julia and trying to figure out how to use the NLSolvers package as given in the following link: NLSolvers In the README file, they provide an example for a nonlinear system of equations for the Rosenbr…

---

## [Using eval within a function](https://discourse.julialang.org/t/using-eval-within-a-function/82487)

<div class="topic-metadata">

**Author:** [@flobe](https://discourse.julialang.org/u/flobe)\
**Replies:** 7\
**Last updated:** [June 9, 2022, 2:31pm UTC](https://discourse.julialang.org/t/using-eval-within-a-function/82487 "2022-06-09T14:31:52Z")

</div>

I’m trying to build a statement for an if case within a function. Something like: function build\_string(test\_value, comparator, value) if eval(Meta.parse("test\_value" \* "comparator" \* "value")) \[...\] end … I ge…

---

## [Run two repls on the same project](https://discourse.julialang.org/t/run-two-repls-on-the-same-project/81620)

<div class="topic-metadata">

**Author:** [@taotree](https://discourse.julialang.org/u/taotree)\
**Replies:** 2\
**Last updated:** [June 9, 2022, 2:25pm UTC](https://discourse.julialang.org/t/run-two-repls-on-the-same-project/81620 "2022-06-09T14:25:14Z")

</div>

I have a project with lots of modules I’m actively developing. But I also want to run some long running tasks based on it and occasionally update that, so I’ve been running a repl in vscode to develop, and a second one i…

---

## [TOML Parser error](https://discourse.julialang.org/t/toml-parser-error/82474)

<div class="topic-metadata">

**Author:** [@ga72kud](https://discourse.julialang.org/u/ga72kud)\
**Replies:** 1\
**Last updated:** [June 9, 2022, 9:34am UTC](https://discourse.julialang.org/t/toml-parser-error/82474 "2022-06-09T09:34:41Z")

</div>

Hi I have a weird error. I don’t know how to handle it. TOML Parser error: none:3373:1 error: invalid bare key character: ‘\\0’ \[\[“/home/michael/.julia/environments/v1.6/Manifest.toml”\]\] ^ parse at toml\_parser.jl:441 …

---

## [Flux.jl confusion matrix](https://discourse.julialang.org/t/flux-jl-confusion-matrix/19740)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 13\
**Last updated:** [June 9, 2022, 9:19am UTC](https://discourse.julialang.org/t/flux-jl-confusion-matrix/19740 "2022-06-09T09:19:10Z")

</div>

I’m using Flux to implement a handwritten digit classifier based on the MNIST dataset (ex https://github.com/FluxML/model-zoo/blob/master/vision/mnist/mlp.jl). Is there any way to compute the confusion matrix in order t…

---

## [OutOfMemoryError() instead of allocating too much resources in the job scheduler](https://discourse.julialang.org/t/outofmemoryerror-instead-of-allocating-too-much-resources-in-the-job-scheduler/45575)

<div class="topic-metadata">

**Author:** [@fgerick](https://discourse.julialang.org/u/fgerick)\
**Replies:** 5\
**Last updated:** [June 9, 2022, 7:27am UTC](https://discourse.julialang.org/t/outofmemoryerror-instead-of-allocating-too-much-resources-in-the-job-scheduler/45575 "2022-06-09T07:27:27Z")

</div>

Hi everyone, I’ve encountered a few times that my code running interactively on an LSF cluster reaches the maximum of the (by me) allocated memory. This memory is not the memory limit of the node and instead of Julia th…

---

## [Test of expand and substitute in Symbolics.jl, SymEngine.jl and Mathematica](https://discourse.julialang.org/t/test-of-expand-and-substitute-in-symbolics-jl-symengine-jl-and-mathematica/77470)

<div class="topic-metadata">

**Author:** [@gangchern](https://discourse.julialang.org/u/gangchern)\
**Replies:** 18\
**Last updated:** [June 9, 2022, 2:38am UTC](https://discourse.julialang.org/t/test-of-expand-and-substitute-in-symbolics-jl-symengine-jl-and-mathematica/77470 "2022-06-09T02:38:24Z")

</div>

My computer is Mac Pro M1, 2020. General Comments: for expand, SymEngine is nearly as good as Mathematica, Symbolics‘s “expand” function still needs to be greatly improved. substitute are similar for the three CAS in pe…

---

## [How can I determine the name of an enum value?](https://discourse.julialang.org/t/how-can-i-determine-the-name-of-an-enum-value/82394)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 3\
**Last updated:** [June 9, 2022, 1:55am UTC](https://discourse.julialang.org/t/how-can-i-determine-the-name-of-an-enum-value/82394 "2022-06-09T01:55:53Z")

</div>

How can I get the name of an enum value? @enum Animal dog cat Int(cat) # works String(cat) # not working How can I get the string representation of a variable of type Animal? I want to get the string “cat” or “dog”…

---

## [Extending broadcasts to matrix exponentials?](https://discourse.julialang.org/t/extending-broadcasts-to-matrix-exponentials/80384)

<div class="topic-metadata">

**Author:** [@g2g](https://discourse.julialang.org/u/g2g)\
**Replies:** 7\
**Last updated:** [June 8, 2022, 11:18pm UTC](https://discourse.julialang.org/t/extending-broadcasts-to-matrix-exponentials/80384 "2022-06-08T23:18:07Z")

</div>

I’m fairly new to Julia and I have not yet looked at Julia’s source code. I’m wondering whether extending broadcasts to approximate matrix exponentials would be an improvement to the language, and whether the code chan…

---

## [Drop phase of Factor?](https://discourse.julialang.org/t/drop-phase-of-factor/80913)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 15\
**Last updated:** [June 8, 2022, 9:18pm UTC](https://discourse.julialang.org/t/drop-phase-of-factor/80913 "2022-06-08T21:18:03Z")

</div>

How can I reserve the symb. phase?

---

## [How to remove columns from Dataframe](https://discourse.julialang.org/t/how-to-remove-columns-from-dataframe/82459)

<div class="topic-metadata">

**Author:** [@bicepjai](https://discourse.julialang.org/u/bicepjai)\
**Replies:** 1\
**Last updated:** [June 8, 2022, 7:37pm UTC](https://discourse.julialang.org/t/how-to-remove-columns-from-dataframe/82459 "2022-06-08T19:37:33Z")

</div>

I have a parquet dataset with 32 million rows read using read\_parquet Complex processing gets completed in seconds. But when I try to ignore some columns using select!(data, Not(\[:column1, :column2\])) This does not c…

---

## [Any easy way to debug when a function is compiled?](https://discourse.julialang.org/t/any-easy-way-to-debug-when-a-function-is-compiled/82456)

<div class="topic-metadata">

**Author:** [@marius311](https://discourse.julialang.org/u/marius311)\
**Replies:** 2\
**Last updated:** [June 8, 2022, 6:45pm UTC](https://discourse.julialang.org/t/any-easy-way-to-debug-when-a-function-is-compiled/82456 "2022-06-08T18:45:06Z")

</div>

A typical pattern in Jax to check when a function gets compiled (useful for debugging excessive recompliation) is, @jax.jit def f(): print("compiling") return 0 f() # prints "compiling" f() # doesnt print anyth…

---

## [Debugging julia code](https://discourse.julialang.org/t/debugging-julia-code/21246)

<div class="topic-metadata">

**Author:** [@Suraj\_Pawar](https://discourse.julialang.org/u/Suraj_Pawar)\
**Replies:** 27\
**Last updated:** [June 8, 2022, 6:34pm UTC](https://discourse.julialang.org/t/debugging-julia-code/21246 "2022-06-08T18:34:27Z")

</div>

What are good strategies for debugging Julia code? Can I debug the Julia code using gdb? I mainly want to see the variables at various points in the program. Thank you.

---

## [Simple BinaryBuilder use](https://discourse.julialang.org/t/simple-binarybuilder-use/82434)

<div class="topic-metadata">

**Author:** [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Replies:** 1\
**Last updated:** [June 8, 2022, 2:02pm UTC](https://discourse.julialang.org/t/simple-binarybuilder-use/82434 "2022-06-08T14:02:38Z")

</div>

I would like to create a DLL package from some C code and headers. The code in question, from the cgranges repository, consists of a simple C source file, with no exotic dependencies, and two header files. (This code i…

---

## [Reinterpret to non bits type](https://discourse.julialang.org/t/reinterpret-to-non-bits-type/82307)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 41\
**Last updated:** [June 8, 2022, 11:38am UTC](https://discourse.julialang.org/t/reinterpret-to-non-bits-type/82307 "2022-06-08T11:38:58Z")

</div>

I have a Vector{UInt8} and I want to get a Vector{T} for an arbitrary type T without or with minimal runtime penalty and without allocating. The actual contents of the input and output are unspecified. The use case is i…

---

## [How to add values to vector with repeated indices?](https://discourse.julialang.org/t/how-to-add-values-to-vector-with-repeated-indices/82422)

<div class="topic-metadata">

**Author:** [@Minimum-Pollution-96](https://discourse.julialang.org/u/Minimum-Pollution-96)\
**Replies:** 4\
**Last updated:** [June 8, 2022, 10:31am UTC](https://discourse.julialang.org/t/how-to-add-values-to-vector-with-repeated-indices/82422 "2022-06-08T10:31:42Z")

</div>

I’ll explain my need with an example. a = \[1:5;\] indices = \[1,1,3,3\]; values = \[2,3,4,5\]; I need to add values to the original vector a as per the indices. The solution for above example should be, \>\>\> \[6,2,12,4,5\] I…

---

## [Type Sudoku (test if object is a struct)](https://discourse.julialang.org/t/type-sudoku-test-if-object-is-a-struct/66139)

<div class="topic-metadata">

**Author:** [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Replies:** 21\
**Last updated:** [June 8, 2022, 9:43am UTC](https://discourse.julialang.org/t/type-sudoku-test-if-object-is-a-struct/66139 "2022-06-08T09:43:32Z")

</div>

This is NOT to complain about Julia, rather a learning experience, so bear with me… Dispatching to a struct type seems like the match of the last resort - after a lot of not this, not that, not really testable. And cont…

---

## [Julia equivalence tf.nn.l2\_loss(x) in Flux](https://discourse.julialang.org/t/julia-equivalence-tf-nn-l2-loss-x-in-flux/82420)

<div class="topic-metadata">

**Author:** [@HerAdri](https://discourse.julialang.org/u/HerAdri)\
**Replies:** 1\
**Last updated:** [June 8, 2022, 9:39am UTC](https://discourse.julialang.org/t/julia-equivalence-tf-nn-l2-loss-x-in-flux/82420 "2022-06-08T09:39:08Z")

</div>

Which is the function inside the Flux package that is equivalent to Python tensorflow.python.ops.nn.l2\_loss()?

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

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