# General Usage

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

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

**Page:** 452

---

## [Can I change the working directory in a file more than once?](https://discourse.julialang.org/t/can-i-change-the-working-directory-in-a-file-more-than-once/80839)

<div class="topic-metadata">

**Author:** [@00krishna](https://discourse.julialang.org/u/00krishna)\
**Replies:** 2\
**Last updated:** [May 10, 2022, 7:50pm UTC](https://discourse.julialang.org/t/can-i-change-the-working-directory-in-a-file-more-than-once/80839 "2022-05-10T19:50:05Z")

</div>

Hey folks, I was having a little trouble getting some julia file system functions to work. The code seems correct, so I can’t tell if I made a code error, or if it is an issue with the vscode plugin, etc? I have a julia…

---

## [Pluto fails to update to version 0.19.4](https://discourse.julialang.org/t/pluto-fails-to-update-to-version-0-19-4/80825)

<div class="topic-metadata">

**Author:** [@VivMendes](https://discourse.julialang.org/u/VivMendes)\
**Replies:** 2\
**Last updated:** [May 10, 2022, 5:44pm UTC](https://discourse.julialang.org/t/pluto-fails-to-update-to-version-0-19-4/80825 "2022-05-10T17:44:52Z")

</div>

Hi, I am on a Windows 10 machine, Julia 1.7.1, Pluto 0.19.3. When starting a new Pluto notebook, I saw the note thrown out by Pluto: “There is a new Pluto version …”. I tried to update my system, but it failed. Tried to…

---

## [How to mark a function argument for specialization on types while still staying as a generic argument?](https://discourse.julialang.org/t/how-to-mark-a-function-argument-for-specialization-on-types-while-still-staying-as-a-generic-argument/80652)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 8\
**Last updated:** [May 10, 2022, 4:41pm UTC](https://discourse.julialang.org/t/how-to-mark-a-function-argument-for-specialization-on-types-while-still-staying-as-a-generic-argument/80652 "2022-05-10T16:41:01Z")

</div>

This is a follow up question which cristallized from this other discourse topic Problem I am struggeling with improving performance of my package ExtensibleEffects.jl because Julia is not specializing a function on type…

---

## [Faster Alternatives to sortperm](https://discourse.julialang.org/t/faster-alternatives-to-sortperm/80170)

<div class="topic-metadata">

**Author:** [@Josa9321](https://discourse.julialang.org/u/Josa9321)\
**Replies:** 9\
**Last updated:** [May 10, 2022, 4:33pm UTC](https://discourse.julialang.org/t/faster-alternatives-to-sortperm/80170 "2022-05-10T16:33:18Z")

</div>

Hi, I am manipulating an matrix (one or more lines) that has the priority numbers of another one, for example: priority = \[0.1 0.9 0.4 0.7 0.3\] # matrix filled using rand() A = \[col1 col2 col3 col4 col5\] # matrix fille…

---

## [HDF5 cannot compile in M1 pro mac](https://discourse.julialang.org/t/hdf5-cannot-compile-in-m1-pro-mac/71097)

<div class="topic-metadata">

**Author:** [@wzy](https://discourse.julialang.org/u/wzy)\
**Replies:** 12\
**Last updated:** [May 10, 2022, 3:38pm UTC](https://discourse.julialang.org/t/hdf5-cannot-compile-in-m1-pro-mac/71097 "2022-05-10T15:38:46Z")

</div>

The julia version is v1.7.0 rc-2, installed by official dmg. OS: OSX Monterey Hope to learn about how to resolve this problem, thanks! The log: julia\> using HDF5 \[ Info: Precompiling HDF5 \[f67ccb44-e63f-5c2f-98bd-…

---

## [Change endianness in reinterpret](https://discourse.julialang.org/t/change-endianness-in-reinterpret/80815)

<div class="topic-metadata">

**Author:** [@nandoconde](https://discourse.julialang.org/u/nandoconde)\
**Replies:** 3\
**Last updated:** [May 10, 2022, 3:22pm UTC](https://discourse.julialang.org/t/change-endianness-in-reinterpret/80815 "2022-05-10T15:22:16Z")

</div>

Hello! I am trying to reinterpret a Vector of bytes into a predefined type I have. However, primitive types are always intepreted as being little endian. Is there any way I can change this? MWE: julia\> struct P …

---

## [Sum of logs](https://discourse.julialang.org/t/sum-of-logs/80370)

<div class="topic-metadata">

**Author:** [@cscherrer](https://discourse.julialang.org/u/cscherrer)\
**Replies:** 19\
**Last updated:** [May 10, 2022, 2:40pm UTC](https://discourse.julialang.org/t/sum-of-logs/80370 "2022-05-10T14:40:13Z")

</div>

In some statistical applications (and probably many others) we sometimes have to evaluate sum(log.(x)) for some large vector x. The obvious improvement to this is sum(log, x), but this still requires computing log for ea…

---

## [How to write a program as a Julia package?](https://discourse.julialang.org/t/how-to-write-a-program-as-a-julia-package/80574)

<div class="topic-metadata">

**Author:** [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Replies:** 29\
**Last updated:** [May 10, 2022, 1:26pm UTC](https://discourse.julialang.org/t/how-to-write-a-program-as-a-julia-package/80574 "2022-05-10T13:26:20Z")

</div>

All the Julia packages I have encountered export functions to be used as building blocks for other code. The main file looks something like this: module Package using Dependency1, Dependency2 export function1, functi…

---

## [Better way to suppress error/backtrace on SIGPIPE in a pipeline?](https://discourse.julialang.org/t/better-way-to-suppress-error-backtrace-on-sigpipe-in-a-pipeline/80801)

<div class="topic-metadata">

**Author:** [@martin.auer](https://discourse.julialang.org/u/martin.auer)\
**Replies:** 0\
**Last updated:** [May 10, 2022, 10:51am UTC](https://discourse.julialang.org/t/better-way-to-suppress-error-backtrace-on-sigpipe-in-a-pipeline/80801 "2022-05-10T10:51:26Z")

</div>

We are using custom scripts in a Linux/shell/pipeline environment shared by users with different language backgrounds. Julia would be a nice fit to some of the process stages. As any such scripts might later be used and…

---

## [Need help on understanding type inference / performance](https://discourse.julialang.org/t/need-help-on-understanding-type-inference-performance/80600)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 13\
**Last updated:** [May 10, 2022, 9:54am UTC](https://discourse.julialang.org/t/need-help-on-understanding-type-inference-performance/80600 "2022-05-10T09:54:29Z")

</div>

Hi there, I am the author of ExtensibleEffects.jl and several people approached me that it would be great to improve performance (it is currently super slow). I made a first attempt on inspecting and found the followin…

---

## [What did I do wrong when installing my MATLAB.jl package?](https://discourse.julialang.org/t/what-did-i-do-wrong-when-installing-my-matlab-jl-package/73546)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 4\
**Last updated:** [May 10, 2022, 8:10am UTC](https://discourse.julialang.org/t/what-did-i-do-wrong-when-installing-my-matlab-jl-package/73546 "2022-05-10T08:10:06Z")

</div>

Unfortunately, MATLAB.jl has not been working for me. Not sure if it is because I first installed MATLAB.jl by Pkg.add("MATLAB"), then realized I did not set the environment variable as above first. So I set the environ…

---

## [Joinpath() in wsl2 mounted drives](https://discourse.julialang.org/t/joinpath-in-wsl2-mounted-drives/80788)

<div class="topic-metadata">

**Author:** [@huang\_min](https://discourse.julialang.org/u/huang_min)\
**Replies:** 2\
**Last updated:** [May 10, 2022, 6:02am UTC](https://discourse.julialang.org/t/joinpath-in-wsl2-mounted-drives/80788 "2022-05-10T06:02:02Z")

</div>

I would like to read/write files in a folder in D drives say D:\\data. I hope it works for Julia both in windows and wsl2. I tried joinpath() but cannot figure out how to make it. I start Julia in the home dir (or some p…

---

## [Expected julia 1.8 release date](https://discourse.julialang.org/t/expected-julia-1-8-release-date/80785)

<div class="topic-metadata">

**Author:** [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)\
**Replies:** 1\
**Last updated:** [May 10, 2022, 3:41am UTC](https://discourse.julialang.org/t/expected-julia-1-8-release-date/80785 "2022-05-10T03:41:07Z")

</div>

Hello, What is the expected release date for Julia 1.8? Thanks!

---

## [Weird behavior with Atomic](https://discourse.julialang.org/t/weird-behavior-with-atomic/80757)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 1\
**Last updated:** [May 9, 2022, 7:54pm UTC](https://discourse.julialang.org/t/weird-behavior-with-atomic/80757 "2022-05-09T19:54:13Z")

</div>

Hi all :slight\_smile: I’ve got some very weird behavior. Maybe someone knows what’s happening there. Some code I debug with @show. There is nothing between these statements. The code is called in a separate thread. @s…

---

## [How to speed up diagonalization of a Hamiltonian matrix?](https://discourse.julialang.org/t/how-to-speed-up-diagonalization-of-a-hamiltonian-matrix/80777)

<div class="topic-metadata">

**Author:** [@BastienD](https://discourse.julialang.org/u/BastienD)\
**Replies:** 0\
**Last updated:** [May 9, 2022, 7:51pm UTC](https://discourse.julialang.org/t/how-to-speed-up-diagonalization-of-a-hamiltonian-matrix/80777 "2022-05-09T19:51:50Z")

</div>

I would like to diagonalize the following Hamiltonian: \\mathcal{H} = \\begin{pmatrix} H & \\bar{\\Delta}\\\\ \\bar{\\Delta}^\\dagger & -H^\*\\\\ \\end{pmatrix} where H = \\begin{pmatrix} H\_s & H\_b\\\\ H\_b^T & H\_n\\\\ \\end{pmatrix} us…

---

## [Reading archives JLD2](https://discourse.julialang.org/t/reading-archives-jld2/80717)

<div class="topic-metadata">

**Author:** [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Replies:** 1\
**Last updated:** [May 9, 2022, 4:53pm UTC](https://discourse.julialang.org/t/reading-archives-jld2/80717 "2022-05-09T16:53:54Z")

</div>

Dear all, I have the matrix Xa\_heuristico\_1\_MP30.jld2 saved in a JLD2 format. When I run: Xa1\_heuristico\_MP30 = FileIO.load("Xa\_heuristico\_1\_MP30.jld2","RH") appears the folowing: How can I acess the element 1,…

---

## [I have a much faster version of evalpoly. Why is it faster?](https://discourse.julialang.org/t/i-have-a-much-faster-version-of-evalpoly-why-is-it-faster/79899)

<div class="topic-metadata">

**Author:** [@Luapulu](https://discourse.julialang.org/u/Luapulu)\
**Replies:** 14\
**Last updated:** [May 9, 2022, 3:36pm UTC](https://discourse.julialang.org/t/i-have-a-much-faster-version-of-evalpoly-why-is-it-faster/79899 "2022-05-09T15:36:16Z")

</div>

I was playing around with different ways to implement the evalpoly function. TLDR My best version is about twice as fast as the version currently in base and works with custom array indices. In this case while loops s…

---

## [Update packages without restarting](https://discourse.julialang.org/t/update-packages-without-restarting/68417)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 14\
**Last updated:** [May 9, 2022, 3:25pm UTC](https://discourse.julialang.org/t/update-packages-without-restarting/68417 "2022-05-09T15:25:49Z")

</div>

I don’t like having to restart Julia when I update packages because I lose my state and have to wait 10 minutes or more to get back to it, usually once or twice a day. Is it possible to avoid this? Is that a feature Jul…

---

## [Using a keyword argument leads to enormous allocations](https://discourse.julialang.org/t/using-a-keyword-argument-leads-to-enormous-allocations/80354)

<div class="topic-metadata">

**Author:** [@moble](https://discourse.julialang.org/u/moble)\
**Replies:** 8\
**Last updated:** [May 9, 2022, 3:09pm UTC](https://discourse.julialang.org/t/using-a-keyword-argument-leads-to-enormous-allocations/80354 "2022-05-09T15:09:00Z")

</div>

I’ve been running into a bizarre problem with huge allocations, and I’ve just discovered that the problem can be avoided if I don’t use a keyword argument to a function inside my main computation function. The allocatio…

---

## [Is there a \`slices\` function?](https://discourse.julialang.org/t/is-there-a-slices-function/80724)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 4\
**Last updated:** [May 9, 2022, 1:59pm UTC](https://discourse.julialang.org/t/is-there-a-slices-function/80724 "2022-05-09T13:59:08Z")

</div>

Is there a lazy equivalent to mapslices that returns a sliced view into an array? We have sortperm and sortslices, but I’d like to get the permutation that puts slices in order. I’d like to accomplish this with sortperm…

---

## [How to manage versions in my package?](https://discourse.julialang.org/t/how-to-manage-versions-in-my-package/80713)

<div class="topic-metadata">

**Author:** [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Replies:** 5\
**Last updated:** [May 9, 2022, 12:42pm UTC](https://discourse.julialang.org/t/how-to-manage-versions-in-my-package/80713 "2022-05-09T12:42:39Z")

</div>

I am writing my own package, and I want to implement versions. I am using this package in my projects, and I want to make sure that old projects can use an old version of the package while new projects can use the new v…

---

## [Call @enumx macro with NamedTuple constant as input](https://discourse.julialang.org/t/call-enumx-macro-with-namedtuple-constant-as-input/80699)

<div class="topic-metadata">

**Author:** [@FireCrumb](https://discourse.julialang.org/u/FireCrumb)\
**Replies:** 1\
**Last updated:** [May 9, 2022, 11:43am UTC](https://discourse.julialang.org/t/call-enumx-macro-with-namedtuple-constant-as-input/80699 "2022-05-09T11:43:21Z")

</div>

Hi, I have a NamedTuple and would like to create an EnumX from it, how can this be done? CC @fredrikekre Specifically, I’m using ProtoBuf.il to load an enum from Protocol Buffers. And I want to create a new type using…

---

## [Avoid Makie as a dependency?](https://discourse.julialang.org/t/avoid-makie-as-a-dependency/77063)

<div class="topic-metadata">

**Author:** [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Replies:** 8\
**Last updated:** [May 9, 2022, 7:57am UTC](https://discourse.julialang.org/t/avoid-makie-as-a-dependency/77063 "2022-05-09T07:57:22Z")

</div>

I know that in order to avoid having a package depend on Plots I can depend on RecipesBase and write some recipes. In Makie, there is a recipe mechanism too, but in its current form it seems to rely on Makie itself. Th…

---

## [DifferentialEquations.jl package, variable rate jumps with complex variables](https://discourse.julialang.org/t/differentialequations-jl-package-variable-rate-jumps-with-complex-variables/80366)

<div class="topic-metadata">

**Author:** [@TTolppanen](https://discourse.julialang.org/u/TTolppanen)\
**Replies:** 11\
**Last updated:** [May 9, 2022, 7:23am UTC](https://discourse.julialang.org/t/differentialequations-jl-package-variable-rate-jumps-with-complex-variables/80366 "2022-05-09T07:23:02Z")

</div>

Hello, I’m trying to get the following example to work: using DifferentialEquations function f(dx, x,p,t) dx\[1\] = x\[1\] end function rate(x,p,t) t end function affect!(integrator) integrator.u\[1\] = integra…

---

## [Generate a list of functions](https://discourse.julialang.org/t/generate-a-list-of-functions/80691)

<div class="topic-metadata">

**Author:** [@zhaiyusci](https://discourse.julialang.org/u/zhaiyusci)\
**Replies:** 11\
**Last updated:** [May 9, 2022, 7:05am UTC](https://discourse.julialang.org/t/generate-a-list-of-functions/80691 "2022-05-09T07:05:51Z")

</div>

Hello everyone! I want to generate a list of functions, and run into some unexpected behaviour. # Case 1: using anonymous functions fs=\[\] for i in 1:3 f=()-\>i push!(fs,f) end @show \[p() for p in fs\] # Case 2: …

---

## [Apply function By Row without re-stating column names](https://discourse.julialang.org/t/apply-function-by-row-without-re-stating-column-names/65765)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 36\
**Last updated:** [May 9, 2022, 7:01am UTC](https://discourse.julialang.org/t/apply-function-by-row-without-re-stating-column-names/65765 "2022-05-09T07:01:22Z")

</div>

I’d like to apply a function to each row of a DataFrame and have it add columns based on the output names. I would use transform-ByRow but I’d like to avoid restating the column names on input and output. Is there anythi…

---

## [Changing precision for a dual number calculation with ForwardDiff](https://discourse.julialang.org/t/changing-precision-for-a-dual-number-calculation-with-forwarddiff/80723)

<div class="topic-metadata">

**Author:** [@andrew\_s](https://discourse.julialang.org/u/andrew_s)\
**Replies:** 3\
**Last updated:** [May 9, 2022, 5:37am UTC](https://discourse.julialang.org/t/changing-precision-for-a-dual-number-calculation-with-forwarddiff/80723 "2022-05-09T05:37:17Z")

</div>

I am relatively new to Julia, but have a lot of experience with modern Fortran. I am minimising an objective function, and I wish to use ForwardDiff.jl to calculate the derivatives. The issue is that there is one calcula…

---

## [Cross-referencing a function from a submodule defined later](https://discourse.julialang.org/t/cross-referencing-a-function-from-a-submodule-defined-later/80597)

<div class="topic-metadata">

**Author:** [@theogf](https://discourse.julialang.org/u/theogf)\
**Replies:** 1\
**Last updated:** [May 8, 2022, 10:58pm UTC](https://discourse.julialang.org/t/cross-referencing-a-function-from-a-submodule-defined-later/80597 "2022-05-08T22:58:35Z")

</div>

I want to cross ref a function defined in a later submodule. Here is an example: module A """ \[\`foo\`\](@ref) """ module B end module C """ foo """ function foo end end end This SO answer suggests that foo should be im…

---

## [Shadow Base name in REPL](https://discourse.julialang.org/t/shadow-base-name-in-repl/80719)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 1\
**Last updated:** [May 8, 2022, 8:16pm UTC](https://discourse.julialang.org/t/shadow-base-name-in-repl/80719 "2022-05-08T20:16:53Z")

</div>

Inspired by How about to simplify the factorial function name? - #15 by cormullion. Say I want to define !(x) = factorial(x). I can do that in a module julia\> baremodule M import Base !(x) = Base.factoria…

---

## [Logging training loss in Flux](https://discourse.julialang.org/t/logging-training-loss-in-flux/80689)

<div class="topic-metadata">

**Author:** [@bhaveshshrimali](https://discourse.julialang.org/u/bhaveshshrimali)\
**Replies:** 3\
**Last updated:** [May 8, 2022, 2:37pm UTC](https://discourse.julialang.org/t/logging-training-loss-in-flux/80689 "2022-05-08T14:37:23Z")

</div>

Hi all, I had a quick question – seemingly trivial but haven’t managed to figure it out after an hour of trying… What’s the best way to log the training loss and ouput say to a simple text file for visualization using …

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

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