# General Usage

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

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

**Page:** 584

---

## [ILU preconditioned GMRES inside TRBDF2 for ODEs generated by NetworkDynamics.jl](https://discourse.julialang.org/t/ilu-preconditioned-gmres-inside-trbdf2-for-odes-generated-by-networkdynamics-jl/63385)

<div class="topic-metadata">

**Author:** [@ziolai](https://discourse.julialang.org/u/ziolai)\
**Replies:** 6\
**Last updated:** [June 24, 2021, 4:47pm UTC](https://discourse.julialang.org/t/ilu-preconditioned-gmres-inside-trbdf2-for-odes-generated-by-networkdynamics-jl/63385 "2021-06-24T16:47:29Z")

</div>

We are solving differential equations defined on a graph using NetworkDynamics.jl and DifferentialEquations.jl. In this context we have the two questions outlined below. Thx. Domenico Lahaye. 1/ Switching the automatic…

---

## [Is there a function behaving the same as next\_permutation does in C++?](https://discourse.julialang.org/t/is-there-a-function-behaving-the-same-as-next-permutation-does-in-c/63451)

<div class="topic-metadata">

**Author:** [@AquaIndigo](https://discourse.julialang.org/u/AquaIndigo)\
**Replies:** 13\
**Last updated:** [June 24, 2021, 2:48pm UTC](https://discourse.julialang.org/t/is-there-a-function-behaving-the-same-as-next-permutation-does-in-c/63451 "2021-06-24T14:48:08Z")

</div>

I’m writing algorithms to solve a problem on LeetCode, and I need to find the next permutation of a vector. I wonder there is any function can help me. Many thanks.

---

## [Better way of replacing Matrix values with another Array values](https://discourse.julialang.org/t/better-way-of-replacing-matrix-values-with-another-array-values/63440)

<div class="topic-metadata">

**Author:** [@eduardovrs](https://discourse.julialang.org/u/eduardovrs)\
**Replies:** 6\
**Last updated:** [June 24, 2021, 11:26am UTC](https://discourse.julialang.org/t/better-way-of-replacing-matrix-values-with-another-array-values/63440 "2021-06-24T11:26:45Z")

</div>

Dear Julia community, I want to change some values of an existing Matrix with some values that are on another array, but I find that this part of my code is the bottleneck of what I am doing. Is there a better way to do…

---

## [Weird case of the where's](https://discourse.julialang.org/t/weird-case-of-the-wheres/63491)

<div class="topic-metadata">

**Author:** [@rakeshvar](https://discourse.julialang.org/u/rakeshvar)\
**Replies:** 2\
**Last updated:** [June 24, 2021, 10:22am UTC](https://discourse.julialang.org/t/weird-case-of-the-wheres/63491 "2021-06-24T10:22:03Z")

</div>

julia\> function f(::f) where f f end f (generic function with 0 methods) julia\> function g(::f) where f f end g (generic function with 1 method) Why does the first definition fail to work wh…

---

## [MethodError: no method matching +(::Nothing, ::Array{Float64,1}) in parallel computation](https://discourse.julialang.org/t/methoderror-no-method-matching-nothing-array-float64-1-in-parallel-computation/63492)

<div class="topic-metadata">

**Author:** [@marouane](https://discourse.julialang.org/u/marouane)\
**Replies:** 0\
**Last updated:** [June 24, 2021, 10:16am UTC](https://discourse.julialang.org/t/methoderror-no-method-matching-nothing-array-float64-1-in-parallel-computation/63492 "2021-06-24T10:16:56Z")

</div>

I want to run a code using parallel computing, which it works fine for serial computing @everywhere function relay\_basis(alpha,delta,name::String,n) #n is the number of sources for 1 relay we have 2 sources c…

---

## [What's the best idiom here?](https://discourse.julialang.org/t/whats-the-best-idiom-here/63483)

<div class="topic-metadata">

**Author:** [@harris-chris](https://discourse.julialang.org/u/harris-chris)\
**Replies:** 6\
**Last updated:** [June 24, 2021, 8:52am UTC](https://discourse.julialang.org/t/whats-the-best-idiom-here/63483 "2021-06-24T08:52:18Z")

</div>

Hello all I have a project in which I am using variables to represent sets of local state. For example: path::String end locf = LocalFile("/tmp/myfile") I then want to give the user the opportunity to delete these…

---

## [An escape act in a macro](https://discourse.julialang.org/t/an-escape-act-in-a-macro/63477)

<div class="topic-metadata">

**Author:** [@eliassno](https://discourse.julialang.org/u/eliassno)\
**Replies:** 3\
**Last updated:** [June 24, 2021, 7:34am UTC](https://discourse.julialang.org/t/an-escape-act-in-a-macro/63477 "2021-06-24T07:34:32Z")

</div>

Warning: Yet another post on hygienic macros. I want to annotate the offsets of all interpolated values in a text string (storing the indices of the slices). I found it convenient to do this with a macro, but still str…

---

## [Deterministic tie breaking with a hash function, with desired statistical property](https://discourse.julialang.org/t/deterministic-tie-breaking-with-a-hash-function-with-desired-statistical-property/63472)

<div class="topic-metadata">

**Author:** [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Replies:** 2\
**Last updated:** [June 24, 2021, 6:11am UTC](https://discourse.julialang.org/t/deterministic-tie-breaking-with-a-hash-function-with-desired-statistical-property/63472 "2021-06-24T06:11:08Z")

</div>

Background: I am using a priority queue to search paths on an integer lattice. In general, there is not a unique minimum element in the priority queue, so I augment the priorities with a value that is designed to break …

---

## [Getting warning Cannot declare constant; it already has a value](https://discourse.julialang.org/t/getting-warning-cannot-declare-constant-it-already-has-a-value/63480)

<div class="topic-metadata">

**Author:** [@james-garfield](https://discourse.julialang.org/u/james-garfield)\
**Replies:** 1\
**Last updated:** [June 24, 2021, 5:16am UTC](https://discourse.julialang.org/t/getting-warning-cannot-declare-constant-it-already-has-a-value/63480 "2021-06-24T05:16:02Z")

</div>

I have a mutable struct that is giving me a warning Cannot declare constant; it already has a value. I do not declare const for any values in my struct constructor. I’m still quite new to Julia so I’m not too understand…

---

## [Garbage collector behaviour when memory is almost full](https://discourse.julialang.org/t/garbage-collector-behaviour-when-memory-is-almost-full/28169)

<div class="topic-metadata">

**Author:** [@rssdev10](https://discourse.julialang.org/u/rssdev10)\
**Replies:** 7\
**Last updated:** [June 24, 2021, 4:59am UTC](https://discourse.julialang.org/t/garbage-collector-behaviour-when-memory-is-almost-full/28169 "2021-06-24T04:59:15Z")

</div>

I have a script for calculation of millions of strings distances with StringDistances.jl. I’m using 64 CPUs virtual machine with 240GB RAM and found that my script was killed by out of memory. I cleared the script to min…

---

## [Threads over iterator products](https://discourse.julialang.org/t/threads-over-iterator-products/63407)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 10\
**Last updated:** [June 24, 2021, 4:48am UTC](https://discourse.julialang.org/t/threads-over-iterator-products/63407 "2021-06-24T04:48:19Z")

</div>

It there a way to use @threads over iterator products? I am trying to convert some nested loops like: julia\> r = zeros(Threads.nthreads()) Threads.@threads for i in 0:1 for j in 0:1 r\[Threads.…

---

## [Understanding how one task can block another task](https://discourse.julialang.org/t/understanding-how-one-task-can-block-another-task/63413)

<div class="topic-metadata">

**Author:** [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Replies:** 9\
**Last updated:** [June 23, 2021, 11:17pm UTC](https://discourse.julialang.org/t/understanding-how-one-task-can-block-another-task/63413 "2021-06-23T23:17:23Z")

</div>

I’m utterly inexperienced in the usage of tasks in any programming language. I’m having trouble in my present application and came up with the following example to try and explain to myself what is going wrong. What I’m …

---

## [Dynamically generate DataFrame in function with number of columns determined by length of array arguments](https://discourse.julialang.org/t/dynamically-generate-dataframe-in-function-with-number-of-columns-determined-by-length-of-array-arguments/63446)

<div class="topic-metadata">

**Author:** [@dfa\_julia\_quant](https://discourse.julialang.org/u/dfa_julia_quant)\
**Replies:** 12\
**Last updated:** [June 23, 2021, 8:53pm UTC](https://discourse.julialang.org/t/dynamically-generate-dataframe-in-function-with-number-of-columns-determined-by-length-of-array-arguments/63446 "2021-06-23T20:53:17Z")

</div>

""" I am trying to generate a function that creates a DataFrame dynamically with number of columns determined by length of array arguments (n) to the function. But I failed to generate the DataFrame dynamically because …

---

## [Error in LinearFractional while defining integer variable](https://discourse.julialang.org/t/error-in-linearfractional-while-defining-integer-variable/63449)

<div class="topic-metadata">

**Author:** [@manoj.centura](https://discourse.julialang.org/u/manoj.centura)\
**Replies:** 0\
**Last updated:** [June 23, 2021, 3:23pm UTC](https://discourse.julialang.org/t/error-in-linearfractional-while-defining-integer-variable/63449 "2021-06-23T15:23:39Z")

</div>

How to define Integer variable in LinearFractional. for thebelwo code getting the error MathOptInterface.UnsupportedConstraint{MathOptInterface.SingleVariable,MathOptInterface.Integer}: MathOptInterface.SingleVariable-…

---

## [How to add variable type in variable declaration in JuMP](https://discourse.julialang.org/t/how-to-add-variable-type-in-variable-declaration-in-jump/63444)

<div class="topic-metadata">

**Author:** [@manoj.centura](https://discourse.julialang.org/u/manoj.centura)\
**Replies:** 1\
**Last updated:** [June 23, 2021, 3:23pm UTC](https://discourse.julialang.org/t/how-to-add-variable-type-in-variable-declaration-in-jump/63444 "2021-06-23T15:23:23Z")

</div>

Hi All, I want to add this variable as integer. Please suggest how to modify this. X\_tbp = @variable(mod, \[t in 1:T,b in 1:B, p in 1:P\], base\_name=“X\_tbp”, lower\_bound=0.0) Thanks

---

## [GTK Problems](https://discourse.julialang.org/t/gtk-problems/63366)

<div class="topic-metadata">

**Author:** [@The\_Theory](https://discourse.julialang.org/u/The_Theory)\
**Replies:** 14\
**Last updated:** [June 23, 2021, 3:21pm UTC](https://discourse.julialang.org/t/gtk-problems/63366 "2021-06-23T15:21:48Z")

</div>

Hi! So for classes I have to build a graphic application, and after doing a bit of research I found that Gtk sounded pretty easy to use so I decided to give it a shot. All good so far. However, I found that the document…

---

## [YAML file loading gives an error. Is it possible to ignore a field](https://discourse.julialang.org/t/yaml-file-loading-gives-an-error-is-it-possible-to-ignore-a-field/63447)

<div class="topic-metadata">

**Author:** [@curious](https://discourse.julialang.org/u/curious)\
**Replies:** 0\
**Last updated:** [June 23, 2021, 3:01pm UTC](https://discourse.julialang.org/t/yaml-file-loading-gives-an-error-is-it-possible-to-ignore-a-field/63447 "2021-06-23T15:01:40Z")

</div>

Hi, I am trying to use YAML.jl to load an YAML file. It gives me a big error (included below). It appears (may be I am wrong about this) that it cannot understand one of fields that has value like !!set {}. Is it possib…

---

## [Construct a 2-d column array](https://discourse.julialang.org/t/construct-a-2-d-column-array/30617)

<div class="topic-metadata">

**Author:** [@4aHxKzD](https://discourse.julialang.org/u/4aHxKzD)\
**Replies:** 6\
**Last updated:** [June 23, 2021, 2:51pm UTC](https://discourse.julialang.org/t/construct-a-2-d-column-array/30617 "2021-06-23T14:51:45Z")

</div>

Is there a quick way to create an 3x1 Array{ T , 2} where T is a type ? \[A, B, C, ...\] or \[A; B; C; ...\] construct a 1-d array (vector). \[A B C ...\] constructs a 2-d row array. What about a 2-d column array? Does a…

---

## [Overloading getproperty(::PyObject) - Plotting Measurements.jl errorbars with PyPlot.jl](https://discourse.julialang.org/t/overloading-getproperty-pyobject-plotting-measurements-jl-errorbars-with-pyplot-jl/63382)

<div class="topic-metadata">

**Author:** [@jlbosse](https://discourse.julialang.org/u/jlbosse)\
**Replies:** 6\
**Last updated:** [June 23, 2021, 2:37pm UTC](https://discourse.julialang.org/t/overloading-getproperty-pyobject-plotting-measurements-jl-errorbars-with-pyplot-jl/63382 "2021-06-23T14:37:10Z")

</div>

I want to automatically plot arrays of Measurement’s as scatterplots with errorbars using PyPlot.jl. For the interactive PyPlot interface adding the following method to scatter() works nicely: using PyPlot import PyPlot…

---

## [Multiple environments in Documenter](https://discourse.julialang.org/t/multiple-environments-in-documenter/63436)

<div class="topic-metadata">

**Author:** [@theogf](https://discourse.julialang.org/u/theogf)\
**Replies:** 6\
**Last updated:** [June 23, 2021, 1:52pm UTC](https://discourse.julialang.org/t/multiple-environments-in-documenter/63436 "2021-06-23T13:52:07Z")

</div>

Hi! For KernelFunctions.jl, we are generating examples via Literate.jl, pass them to Documenter.jl and we would like that each example has its own environment/Project.toml. The problem of course is that when running ma…

---

## [KeyError on additional processes while using Distributed](https://discourse.julialang.org/t/keyerror-on-additional-processes-while-using-distributed/63437)

<div class="topic-metadata">

**Author:** [@vedang](https://discourse.julialang.org/u/vedang)\
**Replies:** 0\
**Last updated:** [June 23, 2021, 12:29pm UTC](https://discourse.julialang.org/t/keyerror-on-additional-processes-while-using-distributed/63437 "2021-06-23T12:29:25Z")

</div>

I am new to using Julia. I am trying to solve an EnsembleProblem using EnsembleDistributed() option in DifferentialEquations.jl. I have created multiple processes using: using Distributed addprocs(1,exeflags="--project…

---

## [Error by adding registry](https://discourse.julialang.org/t/error-by-adding-registry/63428)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 1\
**Last updated:** [June 23, 2021, 10:03am UTC](https://discourse.julialang.org/t/error-by-adding-registry/63428 "2021-06-23T10:03:10Z")

</div>

Hi all, I don’t understand that error and don’t know how to prevent it. I want to add a local registry with LocalRegistry.jl. Does anyone know what it means? julia\> path = LocalRegistry.create\_registry( "Tri…

---

## [CASE WHEN style operation on DataFrames](https://discourse.julialang.org/t/case-when-style-operation-on-dataframes/63414)

<div class="topic-metadata">

**Author:** [@Ismam](https://discourse.julialang.org/u/Ismam)\
**Replies:** 7\
**Last updated:** [June 23, 2021, 9:28am UTC](https://discourse.julialang.org/t/case-when-style-operation-on-dataframes/63414 "2021-06-23T09:28:21Z")

</div>

In SQL & R(dplyr) there’s a “case when” style function. I’m trying to do the equivalent in Julia. For example suppose I have: df = DataFrame(A = 1:4, B = \[“M”, “F”, “F”, “M”\]) 4 rows × 2 columns A B Int64 S…

---

## [Trying to understand the return type of an array comprehension if the function being called returns a Union](https://discourse.julialang.org/t/trying-to-understand-the-return-type-of-an-array-comprehension-if-the-function-being-called-returns-a-union/63424)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 1\
**Last updated:** [June 23, 2021, 9:02am UTC](https://discourse.julialang.org/t/trying-to-understand-the-return-type-of-an-array-comprehension-if-the-function-being-called-returns-a-union/63424 "2021-06-23T09:02:43Z")

</div>

On nightly: julia\> f(x) = x \> 3 ? x : nothing f (generic function with 1 method) julia\> g(imax) = \[f(i) for i in 1:imax\] g (generic function with 1 method) julia\> @code\_warntype g(5) MethodInstance for g(::Int64) fr…

---

## [Git package installation fails with permission error on nfs filesystem](https://discourse.julialang.org/t/git-package-installation-fails-with-permission-error-on-nfs-filesystem/63419)

<div class="topic-metadata">

**Author:** [@mfh](https://discourse.julialang.org/u/mfh)\
**Replies:** 0\
**Last updated:** [June 23, 2021, 7:12am UTC](https://discourse.julialang.org/t/git-package-installation-fails-with-permission-error-on-nfs-filesystem/63419 "2021-06-23T07:12:18Z")

</div>

On our compute cluster I have encountered the issue that a simple git-based package installation like Pkg.add(name="DFTK", rev="master") fails with the following stacktrace: ERROR: failed to clone from https://github.co…

---

## [Function compiles every time](https://discourse.julialang.org/t/function-compiles-every-time/63273)

<div class="topic-metadata">

**Author:** [@cadojo](https://discourse.julialang.org/u/cadojo)\
**Replies:** 7\
**Last updated:** [June 23, 2021, 6:58am UTC](https://discourse.julialang.org/t/function-compiles-every-time/63273 "2021-06-23T06:58:11Z")

</div>

I re-wrote my astrodynamics functions with ModelingToolkit. Now, when I call DifferentialEquations.solve(...) in my wrapper function, it compiles every time. Is there any way to check what is compiling? using StaticArra…

---

## [How to parallelize OEIS A319284?](https://discourse.julialang.org/t/how-to-parallelize-oeis-a319284/63220)

<div class="topic-metadata">

**Author:** [@leiteiro](https://discourse.julialang.org/u/leiteiro)\
**Replies:** 1\
**Last updated:** [June 22, 2021, 11:42pm UTC](https://discourse.julialang.org/t/how-to-parallelize-oeis-a319284/63220 "2021-06-22T23:42:48Z")

</div>

Don Knuth, in chapter 7.2.2. ‘Backtrack programming’ of his TAOCP, discusses the backtracking tree for the n queens problem. OEIS A319284 records the profiles of these backtracking trees for n in 0:19 and references a J…

---

## [Long parameter for type seems very slow](https://discourse.julialang.org/t/long-parameter-for-type-seems-very-slow/63290)

<div class="topic-metadata">

**Author:** [@nabla](https://discourse.julialang.org/u/nabla)\
**Replies:** 18\
**Last updated:** [June 22, 2021, 9:57pm UTC](https://discourse.julialang.org/t/long-parameter-for-type-seems-very-slow/63290 "2021-06-22T21:57:02Z")

</div>

I construct millions of objects with some particular associated data (essentially, a transition table). I’d like to avoid storing this data in each object (even if it’s an extra pointer), since I can assume it’s constant…

---

## [Compilation time differences with custom sysimg](https://discourse.julialang.org/t/compilation-time-differences-with-custom-sysimg/63365)

<div class="topic-metadata">

**Author:** [@paulmelis](https://discourse.julialang.org/u/paulmelis)\
**Replies:** 0\
**Last updated:** [June 22, 2021, 1:24pm UTC](https://discourse.julialang.org/t/compilation-time-differences-with-custom-sysimg/63365 "2021-06-22T13:24:00Z")

</div>

I was doing some tests with custom sysimages, based on @kristoffer.carlsson’s JuliaCon video. $ cat genimg.jl using PackageCompiler create\_sysimage(\[:Plots\]; sysimage\_path="sysimage\_plots.so") $ cat precompile\_plots…

---

## [Plot text at location](https://discourse.julialang.org/t/plot-text-at-location/63212)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 7\
**Last updated:** [June 22, 2021, 9:13pm UTC](https://discourse.julialang.org/t/plot-text-at-location/63212 "2021-06-22T21:13:05Z")

</div>

@piever How can I set the location of text in AoG? using AlgebraOfGraphics using CairoMakie using DataFrames n = 500 df = DataFrame(x=1:n, y= collect(1:2:2n) .+ 10randn(n)) df = transform(df, :y =\> ByRow(x-\> x%10==0 ?…

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

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