# General Usage

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

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

**Page:** 369

---

## [Unintuitive behavior for iterator of views of a vector](https://discourse.julialang.org/t/unintuitive-behavior-for-iterator-of-views-of-a-vector/90334)

<div class="topic-metadata">

**Author:** [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Replies:** 1\
**Last updated:** [November 16, 2022, 10:00am UTC](https://discourse.julialang.org/t/unintuitive-behavior-for-iterator-of-views-of-a-vector/90334 "2022-11-16T10:00:57Z")

</div>

We are creating a simple iterator whose goal is to generate views of a given vector (something like a sliding window). However, the Julia behavior on this object is rather unituitive to me, with weird type instabilities …

---

## [How to pick random values from an \`Enum\` type?](https://discourse.julialang.org/t/how-to-pick-random-values-from-an-enum-type/90330)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 1\
**Last updated:** [November 16, 2022, 8:11am UTC](https://discourse.julialang.org/t/how-to-pick-random-values-from-an-enum-type/90330 "2022-11-16T08:11:44Z")

</div>

For example, define type Ball: @enum Ball b=1 r=-1 julia\> rand(Ball, 10) ERROR: ArgumentError: Sampler for this object is not defined Stacktrace: \[1\] Random.Sampler(#unused#::Type{Random.TaskLocalRNG}, sp::Random.Samp…

---

## [Type constraint in struct definition](https://discourse.julialang.org/t/type-constraint-in-struct-definition/90328)

<div class="topic-metadata">

**Author:** [@HashBrown](https://discourse.julialang.org/u/HashBrown)\
**Replies:** 0\
**Last updated:** [November 16, 2022, 6:29am UTC](https://discourse.julialang.org/t/type-constraint-in-struct-definition/90328 "2022-11-16T06:29:00Z")

</div>

I want to do something like the following: abstract type Foo{V, S} end # Does not work but the idea is that I want to constrain T and # use whatever U that makes the constraint in the # parameterization of the super …

---

## [Weird syntax error](https://discourse.julialang.org/t/weird-syntax-error/89591)

<div class="topic-metadata">

**Author:** [@pjssilva](https://discourse.julialang.org/u/pjssilva)\
**Replies:** 10\
**Last updated:** [November 16, 2022, 5:58am UTC](https://discourse.julialang.org/t/weird-syntax-error/89591 "2022-11-16T05:58:12Z")

</div>

The code below fails with a syntax error that seems related to the creation of the anonymous function. I don’t see why it is a syntax error. Can anyone explain it? let if 0 == 0 1 elseif 0 == 0 || !all(x…

---

## [AbstractGraph interface assumes a continous set of vertex ids? Alternative Interface?](https://discourse.julialang.org/t/abstractgraph-interface-assumes-a-continous-set-of-vertex-ids-alternative-interface/90268)

<div class="topic-metadata">

**Author:** [@Eulertin](https://discourse.julialang.org/u/Eulertin)\
**Replies:** 3\
**Last updated:** [November 16, 2022, 1:51am UTC](https://discourse.julialang.org/t/abstractgraph-interface-assumes-a-continous-set-of-vertex-ids-alternative-interface/90268 "2022-11-16T01:51:54Z")

</div>

I’ve implemented a custom Graph representation and wanted to use the functionality of the Graphs package, so I’ve implemented the AbstractGraph interface as explained in the packages manual here: https://juliagraphs.org…

---

## [SimpleATsit5?](https://discourse.julialang.org/t/simpleatsit5/90318)

<div class="topic-metadata">

**Author:** [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)\
**Replies:** 2\
**Last updated:** [November 15, 2022, 11:27pm UTC](https://discourse.julialang.org/t/simpleatsit5/90318 "2022-11-15T23:27:25Z")

</div>

I’m just getting started with the DifferentialEquations universe. In the first paragraph after this heading in the documentation, it is stated that SimpleATsit5 is a fast, viable solver for small, non-stiff ODEs. I hav…

---

## [Moving constants to compile-time "lookup" functions with Val](https://discourse.julialang.org/t/moving-constants-to-compile-time-lookup-functions-with-val/90314)

<div class="topic-metadata">

**Author:** [@jacobusmmsmit](https://discourse.julialang.org/u/jacobusmmsmit)\
**Replies:** 5\
**Last updated:** [November 15, 2022, 11:45pm UTC](https://discourse.julialang.org/t/moving-constants-to-compile-time-lookup-functions-with-val/90314 "2022-11-15T23:45:09Z")

</div>

Hi everyone, This may be my most ??? question yet. I read this blog about using Val to use arguments at compile time, and I want to take this a step further by using Val to elide a long string of const declarations. My…

---

## [Arduino with Julia](https://discourse.julialang.org/t/arduino-with-julia/75465)

<div class="topic-metadata">

**Author:** [@davibarreira](https://discourse.julialang.org/u/davibarreira)\
**Replies:** 2\
**Last updated:** [November 15, 2022, 10:51pm UTC](https://discourse.julialang.org/t/arduino-with-julia/75465 "2022-11-15T22:51:49Z")

</div>

I just got an Arduino for my birthday, and I was wondering if there were any tutorials out-there on how to use Julia with Arduino :slight\_smile: I saw @yakir12 has a discussion on the issue, but there is not really a tu…

---

## [Can't compile sysimage in VSCode because of UndefRefError](https://discourse.julialang.org/t/cant-compile-sysimage-in-vscode-because-of-undefreferror/90312)

<div class="topic-metadata">

**Author:** [@brianguenter](https://discourse.julialang.org/u/brianguenter)\
**Replies:** 0\
**Last updated:** [November 15, 2022, 7:54pm UTC](https://discourse.julialang.org/t/cant-compile-sysimage-in-vscode-because-of-undefreferror/90312 "2022-11-15T19:54:27Z")

</div>

I am trying to compile a sysimage using the VSCode Task:Build Task feature. This is for the OpticSim.jl package; it returns an UndefRefError, which I’ve never seen before. The error appears to occur somewhere in the GR p…

---

## [Repeat CuArray (subtract 3 Vector from every row of nx3 matrix)](https://discourse.julialang.org/t/repeat-cuarray-subtract-3-vector-from-every-row-of-nx3-matrix/90291)

<div class="topic-metadata">

**Author:** [@LeN3rd](https://discourse.julialang.org/u/LeN3rd)\
**Replies:** 3\
**Last updated:** [November 15, 2022, 8:36pm UTC](https://discourse.julialang.org/t/repeat-cuarray-subtract-3-vector-from-every-row-of-nx3-matrix/90291 "2022-11-15T20:36:22Z")

</div>

How can i repeat a CuArray in a fast way? I have a 3 vector that is supposed to be subtracted from every row in a n x 3 matrix. The CPU code just transposes and repeats it, but this takes up to 3 seconds on GPU and takes…

---

## [R2r is surprisingly slower than complex fft](https://discourse.julialang.org/t/r2r-is-surprisingly-slower-than-complex-fft/90018)

<div class="topic-metadata">

**Author:** [@photor](https://discourse.julialang.org/u/photor)\
**Replies:** 7\
**Last updated:** [November 15, 2022, 7:43pm UTC](https://discourse.julialang.org/t/r2r-is-surprisingly-slower-than-complex-fft/90018 "2022-11-15T19:43:01Z")

</div>

const m=60 x=randn(m,m,m) y=deepcopy(x) p = FFTW.plan\_r2r(y,FFTW.R2HC,flags=FFTW.MEASURE) @btime mul!($y,$p,$x); gives the result 572.302 μs (138 allocations: 10.16 KiB) while const m=60 x=randn(ComplexF64,m,m,m) y…

---

## [Operations on ComposedFunctions using Symbolics.jl and in Julia in general](https://discourse.julialang.org/t/operations-on-composedfunctions-using-symbolics-jl-and-in-julia-in-general/90309)

<div class="topic-metadata">

**Author:** [@MattM](https://discourse.julialang.org/u/MattM)\
**Replies:** 0\
**Last updated:** [November 15, 2022, 6:31pm UTC](https://discourse.julialang.org/t/operations-on-composedfunctions-using-symbolics-jl-and-in-julia-in-general/90309 "2022-11-15T18:31:56Z")

</div>

Hello, I am using Symbolics.jl for a project, and would like to play around with the Operator structure. In particular, I would like to build operators such as a Lie operator, defined as :f: = \\frac{\\partial f}{\\parti…

---

## [POSIX Shared Memory and different behaviour on Linux/Mac](https://discourse.julialang.org/t/posix-shared-memory-and-different-behaviour-on-linux-mac/90304)

<div class="topic-metadata">

**Author:** [@ErikBuer](https://discourse.julialang.org/u/ErikBuer)\
**Replies:** 0\
**Last updated:** [November 15, 2022, 5:39pm UTC](https://discourse.julialang.org/t/posix-shared-memory-and-different-behaviour-on-linux-mac/90304 "2022-11-15T17:39:35Z")

</div>

Hi. First. I don’t know if this is the right place to ask, but I hope posting here might help others looking at shared memory for Julia in the future. I have attempted to share memory between C++ and Julia in order to …

---

## [Import from a file in current directory using PyCall](https://discourse.julialang.org/t/import-from-a-file-in-current-directory-using-pycall/90287)

<div class="topic-metadata">

**Author:** [@nvenkov1](https://discourse.julialang.org/u/nvenkov1)\
**Replies:** 2\
**Last updated:** [November 15, 2022, 1:38pm UTC](https://discourse.julialang.org/t/import-from-a-file-in-current-directory-using-pycall/90287 "2022-11-15T13:38:26Z")

</div>

I run Julia from a folder which contains a Python file called GramSchmidt.py which I wish to import from using PyCall. I proceed as follows: using PyCall GramSchmidt = pyimport("GramSchmidt") I however get an error tha…

---

## [Performance: Fast way to access numbers in Dataframes or alternatives](https://discourse.julialang.org/t/performance-fast-way-to-access-numbers-in-dataframes-or-alternatives/89884)

<div class="topic-metadata">

**Author:** [@pjuergens](https://discourse.julialang.org/u/pjuergens)\
**Replies:** 12\
**Last updated:** [November 15, 2022, 9:35am UTC](https://discourse.julialang.org/t/performance-fast-way-to-access-numbers-in-dataframes-or-alternatives/89884 "2022-11-15T09:35:43Z")

</div>

Hello together, I’m searching for a fast (or the fastest) way to access datapoints/numbers in a dataframes-like structure. I have 57 timeseries (columns) with 43800 datapoints (rows) each that are read in from a csv-fil…

---

## [DataFrame how to \`groupby\` then index with unspecified keys (merge them)](https://discourse.julialang.org/t/dataframe-how-to-groupby-then-index-with-unspecified-keys-merge-them/90248)

<div class="topic-metadata">

**Author:** [@jling](https://discourse.julialang.org/u/jling)\
**Replies:** 12\
**Last updated:** [November 15, 2022, 3:59am UTC](https://discourse.julialang.org/t/dataframe-how-to-groupby-then-index-with-unspecified-keys-merge-them/90248 "2022-11-15T03:59:22Z")

</div>

gdf = groupby(df, \[:gender, :nationality, :hair\_color\]); we know we can gdf\[(; gender = :X, natiaonlity = :US, hair\_color=:blue)\] to get a specific subdataframe, but this doesn’t work: gdf\[(; gender = :X, natiaonlity =…

---

## [Suppressing location information for @info in Jupyter notebook](https://discourse.julialang.org/t/suppressing-location-information-for-info-in-jupyter-notebook/90260)

<div class="topic-metadata">

**Author:** [@Shuvomoy\_Das\_Gupta](https://discourse.julialang.org/u/Shuvomoy_Das_Gupta)\
**Replies:** 2\
**Last updated:** [November 15, 2022, 2:46am UTC](https://discourse.julialang.org/t/suppressing-location-information-for-info-in-jupyter-notebook/90260 "2022-11-15T02:46:27Z")

</div>

Dear All, Is there a way to suppress the location information for @info in Jupyter notebook? For example, if I type the following in a Jupyter notebook cell @info "hello world" and execute the cell, then the output in…

---

## [Create non-linear structure in higher dimensional space](https://discourse.julialang.org/t/create-non-linear-structure-in-higher-dimensional-space/90204)

<div class="topic-metadata">

**Author:** [@JosieG](https://discourse.julialang.org/u/JosieG)\
**Replies:** 17\
**Last updated:** [November 14, 2022, 11:52pm UTC](https://discourse.julialang.org/t/create-non-linear-structure-in-higher-dimensional-space/90204 "2022-11-14T23:52:03Z")

</div>

Suppose I’m creating a non-linear structure in a 20-dim space. Right now I have a vector m = rand(1) vector = \[cos(m),sin(m),rand(1),rand(1),rand(1),rand(1),rand(1),rand(1),rand(1),rand(1),rand(1),rand(1),rand(1),rand(1…

---

## [Should I believe this Core.Box()?](https://discourse.julialang.org/t/should-i-believe-this-core-box/90263)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 2\
**Last updated:** [November 14, 2022, 10:55pm UTC](https://discourse.julialang.org/t/should-i-believe-this-core-box/90263 "2022-11-14T22:55:05Z")

</div>

In a debug session. Note that D3\_ becomes instantly a Core.Box() but the precedent line, which is virtually equal, gets assigned as expected.

---

## [How to convert a string to ISO-standard datetime?](https://discourse.julialang.org/t/how-to-convert-a-string-to-iso-standard-datetime/90261)

<div class="topic-metadata">

**Author:** [@Hugo](https://discourse.julialang.org/u/Hugo)\
**Replies:** 2\
**Last updated:** [November 14, 2022, 10:33pm UTC](https://discourse.julialang.org/t/how-to-convert-a-string-to-iso-standard-datetime/90261 "2022-11-14T22:33:23Z")

</div>

I have a DataFrame with a column filled with type string for date and time. The strings are formatted as "2017-01-01 00:00:00+00:00", for instance. Searching online I found that this format is the ISO-standard for date a…

---

## [DEV version slower again](https://discourse.julialang.org/t/dev-version-slower-again/90256)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 2\
**Last updated:** [November 14, 2022, 10:14pm UTC](https://discourse.julialang.org/t/dev-version-slower-again/90256 "2022-11-14T22:14:26Z")

</div>

This had happen with v1.8 but v1.9DEV had recovered … until a few day ago (my latest faster 1.9DEV was about 20 days old). Now :cry: | | |\_| | | | (\_| | | Version 1.7.0 (2021-11-30) \_/ |\\\_\_'\_|\_|\_|\\\_\_'\_| | Offici…

---

## [Dependency Error :'(](https://discourse.julialang.org/t/dependency-error/90262)

<div class="topic-metadata">

**Author:** [@chelseas](https://discourse.julialang.org/u/chelseas)\
**Replies:** 2\
**Last updated:** [November 14, 2022, 10:05pm UTC](https://discourse.julialang.org/t/dependency-error/90262 "2022-11-14T22:05:14Z")

</div>

I am getting this error from my use of BlockDiagonals: ERROR: Unsatisfiable requirements detected for package BlockDiagonals \[0a1fb500\]: BlockDiagonals \[0a1fb500\] log: ├─BlockDiagonals \[0a1fb500\] has no known versions…

---

## [Julia nightly is 27 days old](https://discourse.julialang.org/t/julia-nightly-is-27-days-old/90054)

<div class="topic-metadata">

**Author:** [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Replies:** 7\
**Last updated:** [November 14, 2022, 10:01pm UTC](https://discourse.julialang.org/t/julia-nightly-is-27-days-old/90054 "2022-11-14T22:01:23Z")

</div>

Hi, Are there currently issues with the nightly Julia build (windows)? If yes, where can I see the issue affecting the build process? Thank you Kind regards

---

## [Recording an MCMC Chain](https://discourse.julialang.org/t/recording-an-mcmc-chain/90243)

<div class="topic-metadata">

**Author:** [@clinton](https://discourse.julialang.org/u/clinton)\
**Replies:** 9\
**Last updated:** [November 14, 2022, 9:35pm UTC](https://discourse.julialang.org/t/recording-an-mcmc-chain/90243 "2022-11-14T21:35:15Z")

</div>

I’ve written my own MCMC code. MCMCChains provides some helper functions wrt working with already completed chains. As I iterate through the chain, what is the best way to store the each pass? E.g., if I complete non-bu…

---

## [UndefVarError: transform not defined](https://discourse.julialang.org/t/undefvarerror-transform-not-defined/90259)

<div class="topic-metadata">

**Author:** [@JosieG](https://discourse.julialang.org/u/JosieG)\
**Replies:** 1\
**Last updated:** [November 14, 2022, 9:27pm UTC](https://discourse.julialang.org/t/undefvarerror-transform-not-defined/90259 "2022-11-14T21:27:50Z")

</div>

I got this error and my code is using MultivariateStats, RDatasets, Plots # load iris dataset iris = dataset("datasets", "iris") # take half of the dataset X = Matrix(iris\[1:2:end,1:4\])' X\_labels = Vector(iris\[1:2:end…

---

## [Splitting kwargs into specific keyword arguments?](https://discourse.julialang.org/t/splitting-kwargs-into-specific-keyword-arguments/90131)

<div class="topic-metadata">

**Author:** [@TTolppanen](https://discourse.julialang.org/u/TTolppanen)\
**Replies:** 10\
**Last updated:** [November 14, 2022, 9:24pm UTC](https://discourse.julialang.org/t/splitting-kwargs-into-specific-keyword-arguments/90131 "2022-11-14T21:24:54Z")

</div>

Let’s say I have these two functions: function funA(; a=2.0) #something end function funB(; b=4.0) #something end They both take keywords arguments with default values. Now if I want to use these in a third fu…

---

## [Replacing strings in specific position indices as in \`str\_sub()\` in \`stringr\`](https://discourse.julialang.org/t/replacing-strings-in-specific-position-indices-as-in-str-sub-in-stringr/90187)

<div class="topic-metadata">

**Author:** [@Alex\_Tantos](https://discourse.julialang.org/u/Alex_Tantos)\
**Replies:** 9\
**Last updated:** [November 14, 2022, 7:39pm UTC](https://discourse.julialang.org/t/replacing-strings-in-specific-position-indices-as-in-str-sub-in-stringr/90187 "2022-11-14T19:39:24Z")

</div>

Hi. I am tring to duplicate the functionality of the R package stringr in Julia so that I prepare a cheatsheet for string manipulation in Julia. Particularly, I am thinking of how to achieve str\_sub()'s output in Julia.…

---

## [Is calling \`x = @spawn f(x)\` a bad idea?](https://discourse.julialang.org/t/is-calling-x-spawn-f-x-a-bad-idea/89934)

<div class="topic-metadata">

**Author:** [@artemsolod](https://discourse.julialang.org/u/artemsolod)\
**Replies:** 5\
**Last updated:** [November 14, 2022, 4:22pm UTC](https://discourse.julialang.org/t/is-calling-x-spawn-f-x-a-bad-idea/89934 "2022-11-14T16:22:24Z")

</div>

I am a bit unclear on how and when variables are captured in @spawn call. For instance, the following errors julia\> using Base.Threads julia\> let x = 1 x = @spawn x + 3 fetch(x) end ERROR: …

---

## [Equal method to matlab unique in rows](https://discourse.julialang.org/t/equal-method-to-matlab-unique-in-rows/90240)

<div class="topic-metadata">

**Author:** [@Bozaga\_Murat](https://discourse.julialang.org/u/Bozaga_Murat)\
**Replies:** 2\
**Last updated:** [November 14, 2022, 3:37pm UTC](https://discourse.julialang.org/t/equal-method-to-matlab-unique-in-rows/90240 "2022-11-14T15:37:05Z")

</div>

Hello everyboday, I not found the equal method “unique(x,‘rows’)” in Julia to matlab. Does it know anybody ? Thanks.

---

## [Constructor with type parameters and keywords](https://discourse.julialang.org/t/constructor-with-type-parameters-and-keywords/90244)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 0\
**Last updated:** [November 14, 2022, 3:30pm UTC](https://discourse.julialang.org/t/constructor-with-type-parameters-and-keywords/90244 "2022-11-14T15:30:07Z")

</div>

Suppose I have a constructor with some type parameters that do not correspond to fields, which I would like to determine automatically, in addition to getting the rest from keywords. Eg Base.@kwdef struct Foo{K,T} x…

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

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