# General Usage

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

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

**Page:** 335

---

## [Is there a way to limit memory as reported by Sys.total\_memory()?](https://discourse.julialang.org/t/is-there-a-way-to-limit-memory-as-reported-by-sys-total-memory/93909)

<div class="topic-metadata">

**Author:** [@evanderveer](https://discourse.julialang.org/u/evanderveer)\
**Replies:** 2\
**Last updated:** [February 2, 2023, 9:29am UTC](https://discourse.julialang.org/t/is-there-a-way-to-limit-memory-as-reported-by-sys-total-memory/93909 "2023-02-02T09:29:32Z")

</div>

I am trying to run my Julia code on a computing cluster running SLURM. It runs just fine on my own pc, but whenever I try to run it on the cluster (even when I give it the same amount of total memory), my job gets cancel…

---

## [Solving linear equations in Laplacians and SDD matrices](https://discourse.julialang.org/t/solving-linear-equations-in-laplacians-and-sdd-matrices/93911)

<div class="topic-metadata">

**Author:** [@ahmad88](https://discourse.julialang.org/u/ahmad88)\
**Replies:** 0\
**Last updated:** [February 2, 2023, 9:13am UTC](https://discourse.julialang.org/t/solving-linear-equations-in-laplacians-and-sdd-matrices/93911 "2023-02-02T09:13:31Z")

</div>

I am trying to solve linear equations for SDD matrix as follows a= ring\_graph(5) la=lap(a) b = randn(size(la,1)) sddm = copy(la); # doing it with a SDDM matrix sddm\[1,1\] += 1; sol = approxchol\_sddm(sddm,verbose=true) x …

---

## [How do I see errors encountered in async coroutines/tasks?](https://discourse.julialang.org/t/how-do-i-see-errors-encountered-in-async-coroutines-tasks/44134)

<div class="topic-metadata">

**Author:** [@coldinjection](https://discourse.julialang.org/u/coldinjection)\
**Replies:** 3\
**Last updated:** [February 2, 2023, 5:48am UTC](https://discourse.julialang.org/t/how-do-i-see-errors-encountered-in-async-coroutines-tasks/44134 "2023-02-02T05:48:27Z")

</div>

There will be no error message in the RPEL if an error is encountered in an async task, unless you check the state of the task. I find it super difficult to detect errors in async tasks when the tasks are not in the top …

---

## [Avoiding Allocations with User provided Closures](https://discourse.julialang.org/t/avoiding-allocations-with-user-provided-closures/31279)

<div class="topic-metadata">

**Author:** [@cshenton](https://discourse.julialang.org/u/cshenton)\
**Replies:** 12\
**Last updated:** [February 2, 2023, 3:29am UTC](https://discourse.julialang.org/t/avoiding-allocations-with-user-provided-closures/31279 "2023-02-02T03:29:41Z")

</div>

I’m writing a query API that allows a user to pass in a closure to be run on every entry satisfying the query, however this usually results in undesirable boxing. For example, here’s the kind of API I want to offer, with…

---

## [Subtype for UnionAll](https://discourse.julialang.org/t/subtype-for-unionall/93896)

<div class="topic-metadata">

**Author:** [@romatead](https://discourse.julialang.org/u/romatead)\
**Replies:** 1\
**Last updated:** [February 2, 2023, 1:10am UTC](https://discourse.julialang.org/t/subtype-for-unionall/93896 "2023-02-02T01:10:10Z")

</div>

Dear all, I would like to define ab abstract type T1{T} as a UnionAll and to be a subtype of an abstract type T0{T}. How can I define a type with the const syntax as a subtype of an abstract type ? The following does n…

---

## [How do you correctly align array memory when using unsafe\_store! to write a struct array to a c or fortran program?](https://discourse.julialang.org/t/how-do-you-correctly-align-array-memory-when-using-unsafe-store-to-write-a-struct-array-to-a-c-or-fortran-program/93868)

<div class="topic-metadata">

**Author:** [@dmmpie](https://discourse.julialang.org/u/dmmpie)\
**Replies:** 4\
**Last updated:** [February 2, 2023, 12:19am UTC](https://discourse.julialang.org/t/how-do-you-correctly-align-array-memory-when-using-unsafe-store-to-write-a-struct-array-to-a-c-or-fortran-program/93868 "2023-02-02T00:19:17Z")

</div>

I have a julia program, which opens a fortran shared object library, writes to a global type(struct) array and then calls a function, which accesses this variable. The problem is that the values entered in the julia str…

---

## [Is it correct as I defined my delays?](https://discourse.julialang.org/t/is-it-correct-as-i-defined-my-delays/90889)

<div class="topic-metadata">

**Author:** [@renesw](https://discourse.julialang.org/u/renesw)\
**Replies:** 2\
**Last updated:** [February 1, 2023, 10:33pm UTC](https://discourse.julialang.org/t/is-it-correct-as-i-defined-my-delays/90889 "2023-02-01T22:33:06Z")

</div>

I have been getting into Julia for a while now, however, sometimes I am left with some doubts. This time I am not 100% sure if this is the way to declare and use two different delays with DDE. I have a Metzler system wh…

---

## [Is there a function to clip an array to a maximum value? e.g. set values in an arr](https://discourse.julialang.org/t/is-there-a-function-to-clip-an-array-to-a-maximum-value-e-g-set-values-in-an-arr/56412)

<div class="topic-metadata">

**Author:** [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Replies:** 8\
**Last updated:** [February 1, 2023, 5:59pm UTC](https://discourse.julialang.org/t/is-there-a-function-to-clip-an-array-to-a-maximum-value-e-g-set-values-in-an-arr/56412 "2023-02-01T17:59:38Z")

</div>

Is there a function to clip an array to a maximum value? e.g. set values in an array greater than 1.0 to 1.0 Note that the original poster on Slack cannot see your response here on Discourse. Consider transcribing the a…

---

## [General use of GLMakie and Interact in Voilà](https://discourse.julialang.org/t/general-use-of-glmakie-and-interact-in-voila/93667)

<div class="topic-metadata">

**Author:** [@mmj](https://discourse.julialang.org/u/mmj)\
**Replies:** 5\
**Last updated:** [February 1, 2023, 7:25pm UTC](https://discourse.julialang.org/t/general-use-of-glmakie-and-interact-in-voila/93667 "2023-02-01T19:25:19Z")

</div>

Hello. I have many questions. Please be patient and forgive my ignorance, this is the first time I dive deep into Julia. I am attempting to use GLMakie to make interactive plots in a Jupyter Notebook. However, I have ha…

---

## [FemtoCleaner in 1.x (or even 0.6)](https://discourse.julialang.org/t/femtocleaner-in-1-x-or-even-0-6/93882)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 0\
**Last updated:** [February 1, 2023, 5:33pm UTC](https://discourse.julialang.org/t/femtocleaner-in-1-x-or-even-0-6/93882 "2023-02-01T17:33:23Z")

</div>

FemtoCleaner.jl isn’t registered, nor would install, so I tried to install it in Julia 0.6 that it’s made for. I wanted to migrate some Julia 0.6 code, and believe it’s for that (the only such tool?): julia\> Pkg.add("ht…

---

## ['BoundsError' on ODEProblem accelerated with ModelingToolkit.jl](https://discourse.julialang.org/t/boundserror-on-odeproblem-accelerated-with-modelingtoolkit-jl/86287)

<div class="topic-metadata">

**Author:** [@luismunozheinen](https://discourse.julialang.org/u/luismunozheinen)\
**Replies:** 16\
**Last updated:** [February 1, 2023, 5:37pm UTC](https://discourse.julialang.org/t/boundserror-on-odeproblem-accelerated-with-modelingtoolkit-jl/86287 "2023-02-01T17:37:36Z")

</div>

Hi, I have tried to update my ODE problem to run on the lastest versions of OrdinaryDiffEq and ModelingToolkit, however I now encounter a ‘ERROR: BoundsError’ within OrdinaryDiffEq… I have included a reduced version of…

---

## [Why are duplicate entries in sparse matrices allowed?](https://discourse.julialang.org/t/why-are-duplicate-entries-in-sparse-matrices-allowed/2159)

<div class="topic-metadata">

**Author:** [@mirestrepo](https://discourse.julialang.org/u/mirestrepo)\
**Replies:** 7\
**Last updated:** [February 1, 2023, 4:26pm UTC](https://discourse.julialang.org/t/why-are-duplicate-entries-in-sparse-matrices-allowed/2159 "2023-02-01T16:26:12Z")

</div>

Why does the representation of sparse matrices allow for duplicates? a = spzeros(2, 3) a\[\[1,1\],2\]=1 a\[\[1\],2\]=2 Leads to 2×3 sparse matrix with 2 Float64 nonzero entries: \[1, 2\] = 2.0 \[1, 2\] = 1.0 This behavior …

---

## [Find position of Array elements in another Array](https://discourse.julialang.org/t/find-position-of-array-elements-in-another-array/39977)

<div class="topic-metadata">

**Author:** [@sergevic](https://discourse.julialang.org/u/sergevic)\
**Replies:** 16\
**Last updated:** [February 1, 2023, 2:59pm UTC](https://discourse.julialang.org/t/find-position-of-array-elements-in-another-array/39977 "2023-02-01T14:59:16Z")

</div>

Suppose I have the Array a=\[0.5, 0.6, 0.5, 0.4, 0.5, 0.6\] and a reference Array b=\[0.4, 0.5, 0.6\]. I want to to find the position in b of each element of a. I want then to obtain the output \[2, 3, 2, 1, 2, 3\]. I tried …

---

## [How can you insert a julia struct into an array of a type in fortran?](https://discourse.julialang.org/t/how-can-you-insert-a-julia-struct-into-an-array-of-a-type-in-fortran/93775)

<div class="topic-metadata">

**Author:** [@dmmpie](https://discourse.julialang.org/u/dmmpie)\
**Replies:** 5\
**Last updated:** [February 1, 2023, 2:28pm UTC](https://discourse.julialang.org/t/how-can-you-insert-a-julia-struct-into-an-array-of-a-type-in-fortran/93775 "2023-02-01T14:28:30Z")

</div>

I am currently trying to create a unittest for a function I have defined in my shared fortran library. This function receives an integer value and inserts it into a previously allocated and declared array of a specific f…

---

## [Automatic differentiation of function with special points](https://discourse.julialang.org/t/automatic-differentiation-of-function-with-special-points/93780)

<div class="topic-metadata">

**Author:** [@rpgowers](https://discourse.julialang.org/u/rpgowers)\
**Replies:** 4\
**Last updated:** [February 1, 2023, 9:50am UTC](https://discourse.julialang.org/t/automatic-differentiation-of-function-with-special-points/93780 "2023-02-01T09:50:06Z")

</div>

I am using ForwardDiff.jl to compute derivatives of functions which often contain functions of the form: f(x,y) = x/\[exp(x/y)-1\] which one can show using L’Hôpital’s rule has the value f(0,y) = y. One way to construc…

---

## [Why are two functions behave differently?](https://discourse.julialang.org/t/why-are-two-functions-behave-differently/93848)

<div class="topic-metadata">

**Author:** [@hungpham3112](https://discourse.julialang.org/u/hungpham3112)\
**Replies:** 2\
**Last updated:** [February 1, 2023, 5:53am UTC](https://discourse.julialang.org/t/why-are-two-functions-behave-differently/93848 "2023-02-01T05:53:30Z")

</div>

I’m doing some exercises in the ThinkJulia book. Specifically, I try to solve the exercise 10-10: Write a function that reads the file words.txt and builds an array with one element per word. Write two versions of thi…

---

## [Offline package installation with download URL via Artifacts.toml](https://discourse.julialang.org/t/offline-package-installation-with-download-url-via-artifacts-toml/55501)

<div class="topic-metadata">

**Author:** [@Kihang](https://discourse.julialang.org/u/Kihang)\
**Replies:** 1\
**Last updated:** [February 1, 2023, 3:00am UTC](https://discourse.julialang.org/t/offline-package-installation-with-download-url-via-artifacts-toml/55501 "2023-02-01T03:00:39Z")

</div>

Hello All, I have some questions for installation package offline environments. First, I can get package jl folder through Git using PC that can use Internet and I moved the folder to offline system then I installed su…

---

## [Updating an old project to modern broadcasting](https://discourse.julialang.org/t/updating-an-old-project-to-modern-broadcasting/93843)

<div class="topic-metadata">

**Author:** [@kiranshila](https://discourse.julialang.org/u/kiranshila)\
**Replies:** 2\
**Last updated:** [February 1, 2023, 12:14am UTC](https://discourse.julialang.org/t/updating-an-old-project-to-modern-broadcasting/93843 "2023-02-01T00:14:33Z")

</div>

I’ve been tasked with updating an old 0.6 project to modern Julia and am having a really hard time working with the new broadcasting interface. The old code defined Base.broadcast!(f, output::BroadcastTypes, args...) =…

---

## [Forecasting time series data with neural ordinary differential equations in Julia](https://discourse.julialang.org/t/forecasting-time-series-data-with-neural-ordinary-differential-equations-in-julia/92977)

<div class="topic-metadata">

**Author:** [@dmjalal90](https://discourse.julialang.org/u/dmjalal90)\
**Replies:** 27\
**Last updated:** [January 31, 2023, 11:50pm UTC](https://discourse.julialang.org/t/forecasting-time-series-data-with-neural-ordinary-differential-equations-in-julia/92977 "2023-01-31T23:50:03Z")

</div>

Dear all, I am a new user of Julia and following a tutorial on NeuralODE (please see the tutorial: Experiments with Neural ODEs in Julia). How can I forecast ENSO data (time series data in a CSV file) using the above t…

---

## [How do I define my own type based on Julia's pre-existing type?](https://discourse.julialang.org/t/how-do-i-define-my-own-type-based-on-julias-pre-existing-type/93835)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 4\
**Last updated:** [January 31, 2023, 8:54pm UTC](https://discourse.julialang.org/t/how-do-i-define-my-own-type-based-on-julias-pre-existing-type/93835 "2023-01-31T20:54:49Z")

</div>

Hello! I am trying to perform a simple experiment and need some help. I wish to make a copy of the AbstractVector type as such: struct AbstractVectorCopy{T} \<: AbstractVector{T} field::AbstractVector{T} end Then…

---

## [Create polygon in LibGEOS.jl](https://discourse.julialang.org/t/create-polygon-in-libgeos-jl/93483)

<div class="topic-metadata">

**Author:** [@SDA](https://discourse.julialang.org/u/SDA)\
**Replies:** 4\
**Last updated:** [January 31, 2023, 7:35pm UTC](https://discourse.julialang.org/t/create-polygon-in-libgeos-jl/93483 "2023-01-31T19:35:39Z")

</div>

I am trying to create a polygon using LibGEOS.jl. The docs give an example for the case where the polygon vertices are input manually: using LibGEOS p1 = readgeom(“POLYGON((0 0,1 0,1 1,0 0))”) I would like to instea…

---

## [How do I update an environment in Julia?](https://discourse.julialang.org/t/how-do-i-update-an-environment-in-julia/93826)

<div class="topic-metadata">

**Author:** [@danielsoutar](https://discourse.julialang.org/u/danielsoutar)\
**Replies:** 2\
**Last updated:** [January 31, 2023, 5:32pm UTC](https://discourse.julialang.org/t/how-do-i-update-an-environment-in-julia/93826 "2023-01-31T17:32:03Z")

</div>

Hi, a colleague of mine and I were arguing about environments in Julia in a project we have. Let’s say we have a standard project: $ ls Project.toml ... Manifest.toml ... src test ... I might have some version restric…

---

## [Making an efficient function for ignoring unsupported kwargs](https://discourse.julialang.org/t/making-an-efficient-function-for-ignoring-unsupported-kwargs/93794)

<div class="topic-metadata">

**Author:** [@tictaccat](https://discourse.julialang.org/u/tictaccat)\
**Replies:** 4\
**Last updated:** [January 31, 2023, 4:45pm UTC](https://discourse.julialang.org/t/making-an-efficient-function-for-ignoring-unsupported-kwargs/93794 "2023-01-31T16:45:59Z")

</div>

Given a function f that may accept some keyword arguments, I want to make a function g that accepts any keyword arguments and ignores those that are unsupported by f. Below is code that achieves this goal: function igno…

---

## [\`rrule\` for \`StructArrays\`](https://discourse.julialang.org/t/rrule-for-structarrays/93820)

<div class="topic-metadata">

**Author:** [@theogf](https://discourse.julialang.org/u/theogf)\
**Replies:** 1\
**Last updated:** [January 31, 2023, 3:07pm UTC](https://discourse.julialang.org/t/rrule-for-structarrays/93820 "2023-01-31T15:07:50Z")

</div>

Hi! I am trying to write the correct rrule for StructArray. However I struggle quite a lot with some of the errors returned by test\_rrule. Here is what I got so far: ProjectTo(::StructArray{T}) where {T} = ProjectTo{S…

---

## [@test\_logs behavior when using with\_logger](https://discourse.julialang.org/t/test-logs-behavior-when-using-with-logger/80239)

<div class="topic-metadata">

**Author:** [@jdlara-berkeley](https://discourse.julialang.org/u/jdlara-berkeley)\
**Replies:** 3\
**Last updated:** [January 31, 2023, 10:09am UTC](https://discourse.julialang.org/t/test-logs-behavior-when-using-with-logger/80239 "2023-01-31T10:09:17Z")

</div>

When trying to test for logging inside of a custom logger, the @test\_logs macro seems to be unable to capture the logs. Here is an MWE using Test using Logging @test\_logs (:error, "test") match\_mode = :any Logging.with…

---

## [Trying to translate a symbolic differentiation performance benchmark to Julia](https://discourse.julialang.org/t/trying-to-translate-a-symbolic-differentiation-performance-benchmark-to-julia/15735)

<div class="topic-metadata">

**Author:** [@Olof\_Salberger](https://discourse.julialang.org/u/Olof_Salberger)\
**Replies:** 3\
**Last updated:** [September 9, 2019, 1:23am UTC](https://discourse.julialang.org/t/trying-to-translate-a-symbolic-differentiation-performance-benchmark-to-julia/15735 "2019-09-09T01:23:58Z")

</div>

Hi, I was interested in translating Jon Harrop’s symbolic derivatives benchmark to Julia, but since the original code is really heavy on ADT’s and pattern matching I don’t really have a good intuition for what style woul…

---

## [Getting rid of memory allocations in nested functions](https://discourse.julialang.org/t/getting-rid-of-memory-allocations-in-nested-functions/93812)

<div class="topic-metadata">

**Author:** [@p-gw](https://discourse.julialang.org/u/p-gw)\
**Replies:** 3\
**Last updated:** [January 31, 2023, 9:31am UTC](https://discourse.julialang.org/t/getting-rid-of-memory-allocations-in-nested-functions/93812 "2023-01-31T09:31:06Z")

</div>

Hi, I am trying to minimize memory allocations of a function in my package. However, it displays some mysterious behaviour - at least for me. Since there are many experts here, maybe somebody can shed some light on wh…

---

## [Add .exe file in Julia PATH - Bellhop package](https://discourse.julialang.org/t/add-exe-file-in-julia-path-bellhop-package/93808)

<div class="topic-metadata">

**Author:** [@Students](https://discourse.julialang.org/u/Students)\
**Replies:** 0\
**Last updated:** [January 31, 2023, 3:43am UTC](https://discourse.julialang.org/t/add-exe-file-in-julia-path-bellhop-package/93808 "2023-01-31T03:43:25Z")

</div>

Hi everyone, I am trying to run the “UnderwaterAcoustics” package in Julia. In the installation manual they have provided the following statement: Bellhop will only be available if you have a working copy of OALIB bell…

---

## [Plotting a vector of vector in julia](https://discourse.julialang.org/t/plotting-a-vector-of-vector-in-julia/93797)

<div class="topic-metadata">

**Author:** [@shaurya](https://discourse.julialang.org/u/shaurya)\
**Replies:** 2\
**Last updated:** [January 31, 2023, 12:53am UTC](https://discourse.julialang.org/t/plotting-a-vector-of-vector-in-julia/93797 "2023-01-31T00:53:46Z")

</div>

I have a vector of vector elements, given as follows: sol=\[\[1,2,3\],\[1,1,1\],\[4,3,2\],\[5,1,3\],\[9,4,1\]\]; plot(sol) The above code snippet plots in julia assuming that sol has 3 measurements, and each measurement has 5…

---

## [Automatic resizing of struct internal array when value changes?](https://discourse.julialang.org/t/automatic-resizing-of-struct-internal-array-when-value-changes/93790)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 14\
**Last updated:** [January 30, 2023, 10:43pm UTC](https://discourse.julialang.org/t/automatic-resizing-of-struct-internal-array-when-value-changes/93790 "2023-01-30T22:43:41Z")

</div>

Hello! Suppose I have a struct as such: mutable struct TheStruct N::Int x::AbstractVector{Float32} end And at different times “N” might change, for example from 5 to 7. When this happens I want to resize!(…

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

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