# General Usage

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

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

**Page:** 529

---

## [Getting the real or imaginary part with SymPy.jl](https://discourse.julialang.org/t/getting-the-real-or-imaginary-part-with-sympy-jl/70400)

<div class="topic-metadata">

**Author:** [@sijo](https://discourse.julialang.org/u/sijo)\
**Replies:** 1\
**Last updated:** [October 26, 2021, 12:51pm UTC](https://discourse.julialang.org/t/getting-the-real-or-imaginary-part-with-sympy-jl/70400 "2021-10-26T12:51:30Z")

</div>

How can I get the symbolic real or imaginary part of a Sym expression? real gives a BigFloat instead: julia\> sqrt(Sym(5))+im √5 + ⅈ julia\> sqrt(Sym(5))+im |\> real 2.23606797749978969640917366873127623544061835961152572…

---

## [Transforming string columns in DataFrame with (regex) match](https://discourse.julialang.org/t/transforming-string-columns-in-dataframe-with-regex-match/70395)

<div class="topic-metadata">

**Author:** [@DorianT](https://discourse.julialang.org/u/DorianT)\
**Replies:** 3\
**Last updated:** [October 26, 2021, 12:09pm UTC](https://discourse.julialang.org/t/transforming-string-columns-in-dataframe-with-regex-match/70395 "2021-10-26T12:09:20Z")

</div>

using DataFrames using DataFramesMeta # This is the data df = DataFrame(A = 1:5, B = \["Th32is","i35s","124my","test775","var23ia5ble"\]) # This is what the output should be @transform!(df, :B = match.(r"\\d+", :B)) @tran…

---

## [Unexpected Error. How would I dig deeper?](https://discourse.julialang.org/t/unexpected-error-how-would-i-dig-deeper/70399)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 0\
**Last updated:** [October 26, 2021, 11:49am UTC](https://discourse.julialang.org/t/unexpected-error-how-would-i-dig-deeper/70399 "2021-10-26T11:49:05Z")

</div>

Internal error: encountered unexpected error in runtime: BoundsError(a=Array{Core.Compiler.BasicBlock, (47,)}\[Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(start=1, stop=9), preds=Array{Int64, (1,)}\[27\], succs=A…

---

## [Bug in replace! function](https://discourse.julialang.org/t/bug-in-replace-function/70388)

<div class="topic-metadata">

**Author:** [@Cevheriferd](https://discourse.julialang.org/u/Cevheriferd)\
**Replies:** 3\
**Last updated:** [October 26, 2021, 9:30am UTC](https://discourse.julialang.org/t/bug-in-replace-function/70388 "2021-10-26T09:30:25Z")

</div>

See the following MWE: a = "Hello World" #"Hello World" b = replace(a,"Hello" =\> "Bye") #"Bye World" replace!(a, "Hello" =\> "Bye") #ERROR: LoadError: MethodError: no method matching \_replace!(::Base.var"#new#295"{Tupl…

---

## [Package KeyError on a remote process](https://discourse.julialang.org/t/package-keyerror-on-a-remote-process/70387)

<div class="topic-metadata">

**Author:** [@Azzaare](https://discourse.julialang.org/u/Azzaare)\
**Replies:** 3\
**Last updated:** [October 26, 2021, 11:21am UTC](https://discourse.julialang.org/t/package-keyerror-on-a-remote-process/70387 "2021-10-26T11:21:38Z")

</div>

I have been facing some trouble with remote calls on PerfChecker.jl#alloc I can’t find the origin of the KeyError (as it is the key in Project.toml). Any idea? The code is from the test in runtests.jl PerfChecker.jl: E…

---

## [Is the AWS S3 Pkg Thread Safe and production ready?](https://discourse.julialang.org/t/is-the-aws-s3-pkg-thread-safe-and-production-ready/70390)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 0\
**Last updated:** [October 26, 2021, 8:59am UTC](https://discourse.julialang.org/t/is-the-aws-s3-pkg-thread-safe-and-production-ready/70390 "2021-10-26T08:59:57Z")

</div>

Hi all :slight\_smile: Is s3\_put and s3\_get thread-safe and ready for production? https://github.com/JuliaCloud/AWSS3.jl

---

## [Flux.BatchNorm doesn't accept Int32 as argument](https://discourse.julialang.org/t/flux-batchnorm-doesnt-accept-int32-as-argument/70379)

<div class="topic-metadata">

**Author:** [@RedDocMD](https://discourse.julialang.org/u/RedDocMD)\
**Replies:** 1\
**Last updated:** [October 26, 2021, 7:57am UTC](https://discourse.julialang.org/t/flux-batchnorm-doesnt-accept-int32-as-argument/70379 "2021-10-26T07:57:53Z")

</div>

Using Flux 0.12.7, I am trying to use the BatchNorm layer, via the following statement: Flux.BatchNorm(n\_layers) # I know that n\_layers will have type Int32 However, I get the following error: ERROR: LoadError: Method…

---

## [About this: Error: curl\_easy\_setopt: 48](https://discourse.julialang.org/t/about-this-error-curl-easy-setopt-48/70368)

<div class="topic-metadata">

**Author:** [@iiisoo](https://discourse.julialang.org/u/iiisoo)\
**Replies:** 3\
**Last updated:** [October 26, 2021, 7:06am UTC](https://discourse.julialang.org/t/about-this-error-curl-easy-setopt-48/70368 "2021-10-26T07:06:45Z")

</div>

Why I cant import package on a website’s providing terminal with GPU. I could do it under the environment of CPU.

---

## [Concatenate each](https://discourse.julialang.org/t/concatenate-each/70369)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 4\
**Last updated:** [October 26, 2021, 6:25am UTC](https://discourse.julialang.org/t/concatenate-each/70369 "2021-10-26T06:25:49Z")

</div>

Given \[\[0,0,0\],\[1,1,1\]\] and \[\[4,5,6\],\[7,8,9\],\[10,11,12\]\], how can I get \[ \[\[0,0,0\],\[4,5,6\],\[7,8,9\],\[10,11,12\]\], \[\[1,1,1\],\[4,5,6\],\[7,8,9\],\[10,11,12\]\], \] Not quite right: julia\> vcat.((\[\[0,0,0\],\[1,1,1\]\]), Ref(\[\[4,5…

---

## [Loading package on newly added processors](https://discourse.julialang.org/t/loading-package-on-newly-added-processors/70362)

<div class="topic-metadata">

**Author:** [@tictaccat](https://discourse.julialang.org/u/tictaccat)\
**Replies:** 1\
**Last updated:** [October 26, 2021, 12:53am UTC](https://discourse.julialang.org/t/loading-package-on-newly-added-processors/70362 "2021-10-26T00:53:16Z")

</div>

I’m developing a package MyModule that uses distributed operations internally. The following code works perfectly fine, using Distributed addprocs(10) using MyModule function\_that\_uses\_pmap\_inside(); # imported from MyM…

---

## [Best Way to Initialize this Struct](https://discourse.julialang.org/t/best-way-to-initialize-this-struct/70313)

<div class="topic-metadata">

**Author:** [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Replies:** 4\
**Last updated:** [October 26, 2021, 12:13am UTC](https://discourse.julialang.org/t/best-way-to-initialize-this-struct/70313 "2021-10-26T00:13:27Z")

</div>

I would appreciate any opinions or thoughts on the following. I want to create a struct and I want one of the fields of the struct to be dependent on the others. Below is how I’ve accomplished this as a first pass. stru…

---

## [How to assign the diagonal elements of part of matrix to a value?](https://discourse.julialang.org/t/how-to-assign-the-diagonal-elements-of-part-of-matrix-to-a-value/70243)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 11\
**Last updated:** [October 25, 2021, 10:52pm UTC](https://discourse.julialang.org/t/how-to-assign-the-diagonal-elements-of-part-of-matrix-to-a-value/70243 "2021-10-25T22:52:09Z")

</div>

I know that diagind() returns the index of the diagonal elements of matrix, in which we can assign them to a specific value such as in the below aa=rand(9,9); aa\[diagind(aa)\] .= 1 However, lets say I am working on a pa…

---

## [How to get the number out of a date?](https://discourse.julialang.org/t/how-to-get-the-number-out-of-a-date/70355)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 11\
**Last updated:** [October 25, 2021, 10:44pm UTC](https://discourse.julialang.org/t/how-to-get-the-number-out-of-a-date/70355 "2021-10-25T22:44:27Z")

</div>

I tried the below, it was able to generate the number I want, i.e., 730824, but how can I extract this number out? My code: using Dates A = dump(Date(2001, 12, 5)) Results: Date instant: Dates.UTInstant{Day} pe…

---

## [Turing: Sampling from posterior parameters](https://discourse.julialang.org/t/turing-sampling-from-posterior-parameters/70318)

<div class="topic-metadata">

**Author:** [@amit1](https://discourse.julialang.org/u/amit1)\
**Replies:** 2\
**Last updated:** [October 25, 2021, 8:23pm UTC](https://discourse.julialang.org/t/turing-sampling-from-posterior-parameters/70318 "2021-10-25T20:23:07Z")

</div>

I am bit new to probabilistic programming and following the Statistical Rethinking book. I want to know how to draw samples from posterior parameters distributions? (equivalent to “simulation” in R, as shown in that book…

---

## [Global variables](https://discourse.julialang.org/t/global-variables/70347)

<div class="topic-metadata">

**Author:** [@dmgoldschmidt](https://discourse.julialang.org/u/dmgoldschmidt)\
**Replies:** 9\
**Last updated:** [October 25, 2021, 7:09pm UTC](https://discourse.julialang.org/t/global-variables/70347 "2021-10-25T19:09:32Z")

</div>

The inaccessibility inside loops of variables defined in the global scope is driving me nuts. Do I really have to use the keyword global every time I refer to one in a “local” scope? I’d like to have a statement in glo…

---

## [Specificity of binary method with diagonal type specification for dispatch](https://discourse.julialang.org/t/specificity-of-binary-method-with-diagonal-type-specification-for-dispatch/70281)

<div class="topic-metadata">

**Author:** [@serenity4](https://discourse.julialang.org/u/serenity4)\
**Replies:** 6\
**Last updated:** [October 25, 2021, 6:31pm UTC](https://discourse.julialang.org/t/specificity-of-binary-method-with-diagonal-type-specification-for-dispatch/70281 "2021-10-25T18:31:39Z")

</div>

I am having trouble understanding why the following code does not dispatch on Base.convert(::Type{T}, ::T) as I would expect: abstract type SuperType end struct MyType{T} \<: SuperType end function Base.convert(::Type{\<…

---

## [Overwrite part of baseline array in a for loop meeting certain conditions](https://discourse.julialang.org/t/overwrite-part-of-baseline-array-in-a-for-loop-meeting-certain-conditions/70348)

<div class="topic-metadata">

**Author:** [@dalarev](https://discourse.julialang.org/u/dalarev)\
**Replies:** 3\
**Last updated:** [October 25, 2021, 6:31pm UTC](https://discourse.julialang.org/t/overwrite-part-of-baseline-array-in-a-for-loop-meeting-certain-conditions/70348 "2021-10-25T18:31:04Z")

</div>

Question perhaps best posed in a MWE: function foo() A = zeros(3) A\[2\] = 1 for i = 2:3 ind = findall(A .== 1) A\[ind\] .= i @show(A) end end julia\> foo() A = \[0.0, 2.0, 0.0\] A = \[0…

---

## [Evaluation into the closed module \`\_\_anon\_\_\` breaks incremental compilation because the side effects will not be permanent](https://discourse.julialang.org/t/evaluation-into-the-closed-module-anon-breaks-incremental-compilation-because-the-side-effects-will-not-be-permanent/70346)

<div class="topic-metadata">

**Author:** [@Maxim\_Lubov](https://discourse.julialang.org/u/Maxim_Lubov)\
**Replies:** 1\
**Last updated:** [October 25, 2021, 5:18pm UTC](https://discourse.julialang.org/t/evaluation-into-the-closed-module-anon-breaks-incremental-compilation-because-the-side-effects-will-not-be-permanent/70346 "2021-10-25T17:18:10Z")

</div>

I try to compile my project: julia --project=@. --startup-file=no --trace-compile=sysimage/precompile.jl test/runtests.jl This compilation gives me the following error: LoadError: Evaluation into the closed module \`\_\_…

---

## [Initiating a Tuple of Arrays](https://discourse.julialang.org/t/initiating-a-tuple-of-arrays/70325)

<div class="topic-metadata">

**Author:** [@mrVeng](https://discourse.julialang.org/u/mrVeng)\
**Replies:** 6\
**Last updated:** [October 25, 2021, 4:35pm UTC](https://discourse.julialang.org/t/initiating-a-tuple-of-arrays/70325 "2021-10-25T16:35:12Z")

</div>

Dear all, I would like to initiate a Tuple of Vectors. I usually use map in this case as the return type is often of type Tuple, but for some reason the following MWE outputs a Vector of Vector instead of a Tuple of Vec…

---

## [Package status expectation](https://discourse.julialang.org/t/package-status-expectation/70341)

<div class="topic-metadata">

**Author:** [@Eric](https://discourse.julialang.org/u/Eric)\
**Replies:** 0\
**Last updated:** [October 25, 2021, 3:40pm UTC](https://discourse.julialang.org/t/package-status-expectation/70341 "2021-10-25T15:40:02Z")

</div>

I started a package, and it seemed natural to begin with “alpha” status, which I thought conveyed that it is new and should be tested carefully before choosing to depend on it. Now I am trying to look ahead and hope tha…

---

## [Using the package AxisArrays.jl : how to keep the type AxisArray when making operations?](https://discourse.julialang.org/t/using-the-package-axisarrays-jl-how-to-keep-the-type-axisarray-when-making-operations/70338)

<div class="topic-metadata">

**Author:** [@gqn](https://discourse.julialang.org/u/gqn)\
**Replies:** 0\
**Last updated:** [October 25, 2021, 3:23pm UTC](https://discourse.julialang.org/t/using-the-package-axisarrays-jl-how-to-keep-the-type-axisarray-when-making-operations/70338 "2021-10-25T15:23:49Z")

</div>

Hello, I would like to make descriptive statistics on an AxisArray{Float64,3,…}. For instance, my AxisArray has 3 axes (N, V and T) and I am looking for an operation allowing to divide each component at T=t by its value…

---

## [Avoiding global variables while using DataFrames](https://discourse.julialang.org/t/avoiding-global-variables-while-using-dataframes/70314)

<div class="topic-metadata">

**Author:** [@George9000](https://discourse.julialang.org/u/George9000)\
**Replies:** 3\
**Last updated:** [October 25, 2021, 3:15pm UTC](https://discourse.julialang.org/t/avoiding-global-variables-while-using-dataframes/70314 "2021-10-25T15:15:49Z")

</div>

How does one follow the manual’s guidance for performance and avoid global variables while working with DataFrames? For small tables, one could take an approach like this: construct1() = DataFrame(A=1:3, B=5:7, fixed=1)…

---

## [Can't figure out how to dev-install unregistered package](https://discourse.julialang.org/t/cant-figure-out-how-to-dev-install-unregistered-package/70298)

<div class="topic-metadata">

**Author:** [@goerz](https://discourse.julialang.org/u/goerz)\
**Replies:** 4\
**Last updated:** [October 25, 2021, 12:06pm UTC](https://discourse.julialang.org/t/cant-figure-out-how-to-dev-install-unregistered-package/70298 "2021-10-25T12:06:50Z")

</div>

I’ve created folder test with the following Project.toml: \[deps\] QuantumControlBase = "f10a33bc-5a64-497c-be7b-6f86b4f0c2aa" GRAPELinesearchAnalysis = "290eba36-e2d8-4488-81b6-f66cc44f2186" \[compat\] julia = "1.6" The…

---

## [Error writing into a view of an array using CartesianIndices](https://discourse.julialang.org/t/error-writing-into-a-view-of-an-array-using-cartesianindices/16738)

<div class="topic-metadata">

**Author:** [@fabiangans](https://discourse.julialang.org/u/fabiangans)\
**Replies:** 0\
**Last updated:** [October 24, 2018, 2:18pm UTC](https://discourse.julialang.org/t/error-writing-into-a-view-of-an-array-using-cartesianindices/16738 "2018-10-24T14:18:10Z")

</div>

In Julia 0.7 I get an error in the following code: a=rand(10,10) index1 = CartesianIndices((1:2,1:2)) index2 = CartesianIndices((1:2,1:2)) a1 = view(a,index1) a1\[index2\]=rand(2,2) ArgumentError: an array of type \`Carte…

---

## [Assigning vector fields from a struct to a vector](https://discourse.julialang.org/t/assigning-vector-fields-from-a-struct-to-a-vector/70259)

<div class="topic-metadata">

**Author:** [@Peter-Jolly](https://discourse.julialang.org/u/Peter-Jolly)\
**Replies:** 8\
**Last updated:** [October 25, 2021, 9:38am UTC](https://discourse.julialang.org/t/assigning-vector-fields-from-a-struct-to-a-vector/70259 "2021-10-25T09:38:53Z")

</div>

Hi I am have trouble assigning vector fields from a struct (myStruct) to a vector (Base\_Case). Please find code below. Essentially, I want to match the numerical values of the vector fields in the struct that match my “…

---

## [See Franklin site without using a web server](https://discourse.julialang.org/t/see-franklin-site-without-using-a-web-server/70306)

<div class="topic-metadata">

**Author:** [@nielsls](https://discourse.julialang.org/u/nielsls)\
**Replies:** 5\
**Last updated:** [October 25, 2021, 9:03am UTC](https://discourse.julialang.org/t/see-franklin-site-without-using-a-web-server/70306 "2021-10-25T09:03:22Z")

</div>

Hey - thanks for the awesome Franklin.jl! Is it possible to generate a site which can be accessed locally without a webserver - i.e. using just a local URL like file:///C:/Users/foo/bar/index.html. Currently, it seems …

---

## [Do really multiple versions of Julia need multiple JULIA\_DEPOT\_PATH?](https://discourse.julialang.org/t/do-really-multiple-versions-of-julia-need-multiple-julia-depot-path/70319)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 2\
**Last updated:** [October 25, 2021, 7:33am UTC](https://discourse.julialang.org/t/do-really-multiple-versions-of-julia-need-multiple-julia-depot-path/70319 "2021-10-25T07:33:34Z")

</div>

Hello, on SO there is a conversation about multiple versions of Julia and the need to have a separate JULIA\_DEPOT\_PATH environmental variable for each of them. The fact is that I have been using Julia for several years …

---

## [LinearAlgebra.inv matrix inversion slower than MATLAB?](https://discourse.julialang.org/t/linearalgebra-inv-matrix-inversion-slower-than-matlab/70066)

<div class="topic-metadata">

**Author:** [@pitsianis](https://discourse.julialang.org/u/pitsianis)\
**Replies:** 21\
**Last updated:** [October 25, 2021, 7:04am UTC](https://discourse.julialang.org/t/linearalgebra-inv-matrix-inversion-slower-than-matlab/70066 "2021-10-25T07:04:12Z")

</div>

Why a matrix inversion is slower than MATLAB? I am comparing julia 1.6.3 (2021-09-23) Built by Homebrew (v1.6.3\_1) and MATLAB 9.11.0.1769968 (R2021b) on a late 2013 MacBook Pro 2.6 GHz Dual-Core Intel Core i5 with 16 GB…

---

## [How to read a large TSV file using Julia?](https://discourse.julialang.org/t/how-to-read-a-large-tsv-file-using-julia/70300)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 9\
**Last updated:** [October 25, 2021, 1:32am UTC](https://discourse.julialang.org/t/how-to-read-a-large-tsv-file-using-julia/70300 "2021-10-25T01:32:28Z")

</div>

I have a very large TSV file, about 10GB, it has ~10,000 text lines for metadata information (different versions can have different total number of metadata lines), followed by a row of header information for about 20 pa…

---

## [BoundsError when solving non linear system of equations](https://discourse.julialang.org/t/boundserror-when-solving-non-linear-system-of-equations/70180)

<div class="topic-metadata">

**Author:** [@Namitha\_Suresh](https://discourse.julialang.org/u/Namitha_Suresh)\
**Replies:** 7\
**Last updated:** [October 24, 2021, 11:40pm UTC](https://discourse.julialang.org/t/boundserror-when-solving-non-linear-system-of-equations/70180 "2021-10-24T23:40:17Z")

</div>

Hi I’ve been trying to solve a non linear system of equations, but I have 4 equations and two variables so I guess the system is overdetermined and maybe that is the issue, but Mathematica doesn’t seem to have any issue…

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

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