# General Usage

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

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

**Page:** 734

---

## [Optional processor flags in jll packages](https://discourse.julialang.org/t/optional-processor-flags-in-jll-packages/42215)

<div class="topic-metadata">

**Author:** [@hros](https://discourse.julialang.org/u/hros)\
**Replies:** 1\
**Last updated:** [June 29, 2020, 12:03am UTC](https://discourse.julialang.org/t/optional-processor-flags-in-jll-packages/42215 "2020-06-29T00:03:42Z")

</div>

I’m building a jll package of a c library. The library has some processor specific configuration flags, namely setting AVX512 for processors that support it. Is it possible to generate several versions (e.g. with/withou…

---

## [Help improving a function that constructs 3D matrix](https://discourse.julialang.org/t/help-improving-a-function-that-constructs-3d-matrix/42208)

<div class="topic-metadata">

**Author:** [@ycrichard](https://discourse.julialang.org/u/ycrichard)\
**Replies:** 3\
**Last updated:** [June 28, 2020, 11:24pm UTC](https://discourse.julialang.org/t/help-improving-a-function-that-constructs-3d-matrix/42208 "2020-06-28T23:24:48Z")

</div>

Hi Everyone! I am recently porting some functions from Matlab to Julia. Julia is mostly amazing except this function that I cannot get it to a similar speed as Matlab. It basically takes a few input vectors and constru…

---

## [Different results when running on CPU or GPU](https://discourse.julialang.org/t/different-results-when-running-on-cpu-or-gpu/42200)

<div class="topic-metadata">

**Author:** [@natema](https://discourse.julialang.org/u/natema)\
**Replies:** 6\
**Last updated:** [June 28, 2020, 11:15pm UTC](https://discourse.julialang.org/t/different-results-when-running-on-cpu-or-gpu/42200 "2020-06-28T23:15:09Z")

</div>

If I do using Flux x = rand(Float32, 10000); W = rand(Float32, 10000,10000); y = W\*x; gx = x |\> gpu; gW = W |\> gpu; gy = gW\*gx; (gy\[1:10\] |\> cpu) .- y\[1:10\] I get something like 10-element Array{Float32,1}: -0.001…

---

## [Julia (with compile time) about 5.6 times faster than SAS](https://discourse.julialang.org/t/julia-with-compile-time-about-5-6-times-faster-than-sas/42159)

<div class="topic-metadata">

**Author:** [@ajsagit](https://discourse.julialang.org/u/ajsagit)\
**Replies:** 23\
**Last updated:** [June 28, 2020, 6:57pm UTC](https://discourse.julialang.org/t/julia-with-compile-time-about-5-6-times-faster-than-sas/42159 "2020-06-28T18:57:11Z")

</div>

\[Original title: Julia benchmark against SAS only 50% We need a faster Julia please\] I have read the article :BENCHMARKING JULIA AGAINST PYTHON https://juliacomputing.com/assets/pdf/JuliaVsPython.pdf So Amazing! Then …

---

## [Error when using CuArrays in the VSCode Julia REPL](https://discourse.julialang.org/t/error-when-using-cuarrays-in-the-vscode-julia-repl/42197)

<div class="topic-metadata">

**Author:** [@natema](https://discourse.julialang.org/u/natema)\
**Replies:** 2\
**Last updated:** [June 28, 2020, 6:01pm UTC](https://discourse.julialang.org/t/error-when-using-cuarrays-in-the-vscode-julia-repl/42197 "2020-06-28T18:01:45Z")

</div>

If I run using CuArrays cu(rand(3)) I get 3-element CuArray{Float32,1,Nothing}: 0.59194994 0.6101809 0.8896474 but if I evaluate the two lines above from VSCode with the Julia extension I get the following error 1…

---

## [Whats the easiest way to set a ceiling to column values in a DataFrame](https://discourse.julialang.org/t/whats-the-easiest-way-to-set-a-ceiling-to-column-values-in-a-dataframe/42174)

<div class="topic-metadata">

**Author:** [@Julia1](https://discourse.julialang.org/u/Julia1)\
**Replies:** 2\
**Last updated:** [June 28, 2020, 3:16pm UTC](https://discourse.julialang.org/t/whats-the-easiest-way-to-set-a-ceiling-to-column-values-in-a-dataframe/42174 "2020-06-28T15:16:21Z")

</div>

Hi how’s it going? I want to set a ceiling value to a column in my dataframe so that every value greater than 1.0 is equal to 1.0, everything else remains untouched. What’s the easiest way to do this?

---

## [Is python pandas faster than julia CSV?](https://discourse.julialang.org/t/is-python-pandas-faster-than-julia-csv/42183)

<div class="topic-metadata">

**Author:** [@hafez\_ahmad](https://discourse.julialang.org/u/hafez_ahmad)\
**Replies:** 3\
**Last updated:** [June 28, 2020, 5:23am UTC](https://discourse.julialang.org/t/is-python-pandas-faster-than-julia-csv/42183 "2020-06-28T05:23:24Z")

</div>

I have a CSV file which is 40.0kb. I tried both in pandas(python3.7) and CSV(julia1.4.2). I found python pandas is much faster than Julia CSV. however, Julia is faster than python in every case. why reading CSV is slower…

---

## [I keep getting worldage errors](https://discourse.julialang.org/t/i-keep-getting-worldage-errors/42177)

<div class="topic-metadata">

**Author:** [@affans](https://discourse.julialang.org/u/affans)\
**Replies:** 2\
**Last updated:** [June 28, 2020, 2:50am UTC](https://discourse.julialang.org/t/i-keep-getting-worldage-errors/42177 "2020-06-28T02:50:08Z")

</div>

Last few days I’ve been getting random world age errors. Here is the code that triggers it now (the last line). using DataFrames using CSV using GLM using RCall using Plots #using PyPlot using Mamba using StatsPlots d…

---

## [Best choices for AMD 3970x when compiling from source](https://discourse.julialang.org/t/best-choices-for-amd-3970x-when-compiling-from-source/42180)

<div class="topic-metadata">

**Author:** [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)\
**Replies:** 0\
**Last updated:** [June 28, 2020, 2:50am UTC](https://discourse.julialang.org/t/best-choices-for-amd-3970x-when-compiling-from-source/42180 "2020-06-28T02:50:07Z")

</div>

When compiling from source there are various environment variables that can be set. For instance, there are various architecture options, thread counts, etcetera. What are the optimal choices for these for an AMD 3970x…

---

## [Memory allocation within loop](https://discourse.julialang.org/t/memory-allocation-within-loop/23999)

<div class="topic-metadata">

**Author:** [@drarnau](https://discourse.julialang.org/u/drarnau)\
**Replies:** 7\
**Last updated:** [June 28, 2020, 2:17am UTC](https://discourse.julialang.org/t/memory-allocation-within-loop/23999 "2020-06-28T02:17:32Z")

</div>

I have a for loop in which I create a function that I optimize, something like: using Interpolations, Optim function PolicyFunction() V = Array{Float64}(undef, 201, 40) n = Array{Float64}(undef, 201, 40) gr…

---

## [Using JuliaRegistrator: difficulty registering new releases](https://discourse.julialang.org/t/using-juliaregistrator-difficulty-registering-new-releases/42178)

<div class="topic-metadata">

**Author:** [@fusion809](https://discourse.julialang.org/u/fusion809)\
**Replies:** 3\
**Last updated:** [June 28, 2020, 2:01am UTC](https://discourse.julialang.org/t/using-juliaregistrator-difficulty-registering-new-releases/42178 "2020-06-28T02:01:09Z")

</div>

My FunctionIntegrator.jl package is now officially in the General registry and I’m having a little difficulty with getting JuliaRegistrator to register a new release of my package. I created a comment on the commit tagge…

---

## [Compiler optimizations with broadcast or map](https://discourse.julialang.org/t/compiler-optimizations-with-broadcast-or-map/42119)

<div class="topic-metadata">

**Author:** [@kschurter](https://discourse.julialang.org/u/kschurter)\
**Replies:** 5\
**Last updated:** [June 27, 2020, 10:11pm UTC](https://discourse.julialang.org/t/compiler-optimizations-with-broadcast-or-map/42119 "2020-06-27T22:11:34Z")

</div>

I come to Julia from R and have never thought much about compilation or compiler optimizations. As far as I am aware, a simple optimization that a compiler can implement is to take an operation outside of a loop, e.g. d…

---

## [DataFrame groupby-aggregate strategy](https://discourse.julialang.org/t/dataframe-groupby-aggregate-strategy/42156)

<div class="topic-metadata">

**Author:** [@POKIN\_CHAN](https://discourse.julialang.org/u/POKIN_CHAN)\
**Replies:** 7\
**Last updated:** [June 27, 2020, 8:16pm UTC](https://discourse.julialang.org/t/dataframe-groupby-aggregate-strategy/42156 "2020-06-27T20:16:11Z")

</div>

Python: df.groupby(\["Z"\])\["A","B"\].agg({"A":"max"}) I want to groupby “Z” column and take the maximum of “A” in each group. Values of Column “B” is the row when A is max. I have used the following way but it is not t…

---

## [Combine a "plot" object with a "scatter" object in an animation](https://discourse.julialang.org/t/combine-a-plot-object-with-a-scatter-object-in-an-animation/42140)

<div class="topic-metadata">

**Author:** [@Gus\_Hart](https://discourse.julialang.org/u/Gus_Hart)\
**Replies:** 3\
**Last updated:** [June 27, 2020, 2:22pm UTC](https://discourse.julialang.org/t/combine-a-plot-object-with-a-scatter-object-in-an-animation/42140 "2020-06-27T14:22:26Z")

</div>

I’m creating an animation by combining multiple scatter plots (using Animation() and frame()). It all works fine. But I would like my scatter plots to be overlaid on a plot that shows the trajectories I expect the partic…

---

## [How to crop or zoom into a plot area](https://discourse.julialang.org/t/how-to-crop-or-zoom-into-a-plot-area/42151)

<div class="topic-metadata">

**Author:** [@Alireza\_Ghavaminia](https://discourse.julialang.org/u/Alireza_Ghavaminia)\
**Replies:** 4\
**Last updated:** [June 27, 2020, 1:14pm UTC](https://discourse.julialang.org/t/how-to-crop-or-zoom-into-a-plot-area/42151 "2020-06-27T13:14:44Z")

</div>

Hello, I have a polar plot, and I want to zoom into one section of it, How can I do that. using Plots x = \[0,pi/6,pi/4,pi/3,pi/2\] # theta y = \[0,0.1, 0.2, 0.3, 0.4\] # r p = plot(x,y,axis=false,legend=false,proj =:pola…

---

## [Function parameter speculation in runtime](https://discourse.julialang.org/t/function-parameter-speculation-in-runtime/41523)

<div class="topic-metadata">

**Author:** [@dinskid](https://discourse.julialang.org/u/dinskid)\
**Replies:** 3\
**Last updated:** [June 27, 2020, 11:50am UTC](https://discourse.julialang.org/t/function-parameter-speculation-in-runtime/41523 "2020-06-27T11:50:57Z")

</div>

I need a way to imitate the functionality of the inspect module from python. I want to know the list of parameters of a functions, check if there are default values or not, and check if it accepts kwargs or not. Sample…

---

## [Operator equivalent to pipeline function?](https://discourse.julialang.org/t/operator-equivalent-to-pipeline-function/42137)

<div class="topic-metadata">

**Author:** [@derekmahar](https://discourse.julialang.org/u/derekmahar)\
**Replies:** 1\
**Last updated:** [June 27, 2020, 11:44am UTC](https://discourse.julialang.org/t/operator-equivalent-to-pipeline-function/42137 "2020-06-27T11:44:46Z")

</div>

Does there exist an operator that is equivalent to the pipeline function for creating external command chains?

---

## [Cryptic error message in constructing an NTuple](https://discourse.julialang.org/t/cryptic-error-message-in-constructing-an-ntuple/42149)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 4\
**Last updated:** [June 27, 2020, 11:16am UTC](https://discourse.julialang.org/t/cryptic-error-message-in-constructing-an-ntuple/42149 "2020-06-27T11:16:41Z")

</div>

I’m on Julia 1.4.2. This works julia\> NTuple{1}(3) (3,) This doesn’t, and doesn’t say why julia\> NTuple(3) ERROR: UndefVarError: E not defined Stacktrace: \[1\] \_totuple(::Type{Tuple{Vararg{T,N}} where T where N}, ::…

---

## [Extra allocation when trying to reuse pre-allocated vector](https://discourse.julialang.org/t/extra-allocation-when-trying-to-reuse-pre-allocated-vector/42112)

<div class="topic-metadata">

**Author:** [@v-i-s-h](https://discourse.julialang.org/u/v-i-s-h)\
**Replies:** 6\
**Last updated:** [June 27, 2020, 9:13am UTC](https://discourse.julialang.org/t/extra-allocation-when-trying-to-reuse-pre-allocated-vector/42112 "2020-06-27T09:13:45Z")

</div>

Hi, I am trying to generate data for logistic regression y (which is {0, 1}) from X and β. I already allocate the space for y and then wrote function to computing the same in two different ways. I then use TimerOutputs…

---

## [Number of months between two dates](https://discourse.julialang.org/t/number-of-months-between-two-dates/42128)

<div class="topic-metadata">

**Author:** [@atteson](https://discourse.julialang.org/u/atteson)\
**Replies:** 2\
**Last updated:** [June 27, 2020, 8:25am UTC](https://discourse.julialang.org/t/number-of-months-between-two-dates/42128 "2020-06-27T08:25:38Z")

</div>

Is there a convenient way to calculate the number of months between two dates? I can’t seem to find anything in the Dates package.

---

## [Colouring the output of println](https://discourse.julialang.org/t/colouring-the-output-of-println/42136)

<div class="topic-metadata">

**Author:** [@fusion809](https://discourse.julialang.org/u/fusion809)\
**Replies:** 2\
**Last updated:** [June 27, 2020, 7:26am UTC](https://discourse.julialang.org/t/colouring-the-output-of-println/42136 "2020-06-27T07:26:34Z")

</div>

My new package’s tests include println lines to explain the tests being run so that their output is more helpful. It would be nice to be able to distinguish println line outputs from the other outputs using colour coding…

---

## [VS Code Julia:Execute File workflow](https://discourse.julialang.org/t/vs-code-julia-execute-file-workflow/42145)

<div class="topic-metadata">

**Author:** [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)\
**Replies:** 2\
**Last updated:** [June 27, 2020, 6:19am UTC](https://discourse.julialang.org/t/vs-code-julia-execute-file-workflow/42145 "2020-06-27T06:19:22Z")

</div>

I have this test file: include("simc.jl") using .Simc push!(Base.DL\_LOAD\_PATH, pwd()) function f() println(say42()) end f() The library I’m loading is defective, but when I run the whole file with Julia:Execute Fil…

---

## [Truncated Singular Value Decomposition](https://discourse.julialang.org/t/truncated-singular-value-decomposition/42124)

<div class="topic-metadata">

**Author:** [@Vasily\_Ilin](https://discourse.julialang.org/u/Vasily_Ilin)\
**Replies:** 2\
**Last updated:** [June 27, 2020, 4:03am UTC](https://discourse.julialang.org/t/truncated-singular-value-decomposition/42124 "2020-06-27T04:03:42Z")

</div>

Hi. Given a matrix M I would like to compute its SVD truncated to rank k. I think this is possible without doing the full SVD. For example, Python has this: sklearn.decomposition.TruncatedSVD — scikit-learn 1.1.2 documen…

---

## [Printing in for loop](https://discourse.julialang.org/t/printing-in-for-loop/42127)

<div class="topic-metadata">

**Author:** [@ehamid](https://discourse.julialang.org/u/ehamid)\
**Replies:** 6\
**Last updated:** [June 26, 2020, 11:57pm UTC](https://discourse.julialang.org/t/printing-in-for-loop/42127 "2020-06-26T23:57:08Z")

</div>

In the following for loop, the cases i = 10,20 for d = 1 are not printed: using LinearAlgebra, Random, Distributions p = 1000 Σ = I(p) X = zeros((p,p)) for d in 1:5 println("\\nd: $d") for i in 1:20 if i …

---

## [OffsetArrays do not work in let blocks as expected](https://discourse.julialang.org/t/offsetarrays-do-not-work-in-let-blocks-as-expected/42130)

<div class="topic-metadata">

**Author:** [@Bogo](https://discourse.julialang.org/u/Bogo)\
**Replies:** 2\
**Last updated:** [June 26, 2020, 10:54pm UTC](https://discourse.julialang.org/t/offsetarrays-do-not-work-in-let-blocks-as-expected/42130 "2020-06-26T22:54:12Z")

</div>

Hi all, I am using OffsetArrays in my work and recently ran into the issue when using let blocks. MWE without OffsetArrays let b = zeros(20,20) a = ones(20) global test function test(p) b .= a .\* p end end o = ones(…

---

## [Memory allocation and performance](https://discourse.julialang.org/t/memory-allocation-and-performance/42110)

<div class="topic-metadata">

**Author:** [@Joao\_Barata](https://discourse.julialang.org/u/Joao_Barata)\
**Replies:** 7\
**Last updated:** [June 26, 2020, 5:56pm UTC](https://discourse.julialang.org/t/memory-allocation-and-performance/42110 "2020-06-26T17:56:39Z")

</div>

Hi guys, I’m using Julia to compute a dynamic programming model. There is one particular part of the model that takes a long time to run (about 15 seconds, which is a lot, given that there is an iterative procedure invo…

---

## [DifferentialEquations.jl Matrix ODE error](https://discourse.julialang.org/t/differentialequations-jl-matrix-ode-error/42074)

<div class="topic-metadata">

**Author:** [@teamtelefunken](https://discourse.julialang.org/u/teamtelefunken)\
**Replies:** 4\
**Last updated:** [June 26, 2020, 3:53pm UTC](https://discourse.julialang.org/t/differentialequations-jl-matrix-ode-error/42074 "2020-06-26T15:53:22Z")

</div>

Hi. I’m trying to use DifferentialEquations.jl, but I’m running into an elementary problem of setting up the ODE (i’m probably incompetent, as i’m new to Julia). I have as my test function a simple system of ODEs. I’m ru…

---

## [A question about PCA and visualization](https://discourse.julialang.org/t/a-question-about-pca-and-visualization/42111)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 1\
**Last updated:** [June 26, 2020, 3:04pm UTC](https://discourse.julialang.org/t/a-question-about-pca-and-visualization/42111 "2020-06-26T15:04:46Z")

</div>

How do I draw a scatter plot using the projection matrix obtained from PCA? thanks!!

---

## [Splat a named tuple before vs after ; in a function call](https://discourse.julialang.org/t/splat-a-named-tuple-before-vs-after-in-a-function-call/42102)

<div class="topic-metadata">

**Author:** [@kschurter](https://discourse.julialang.org/u/kschurter)\
**Replies:** 1\
**Last updated:** [June 26, 2020, 2:43pm UTC](https://discourse.julialang.org/t/splat-a-named-tuple-before-vs-after-in-a-function-call/42102 "2020-06-26T14:43:04Z")

</div>

I did not find this behavior precisely documented elsewhere: f(args...) = sum(args) f(;kwargs...) = typeof(kwargs) f(args...;kwargs...) = args\[1\] + kwargs\[1\] x = (a=1, b=2, c=3) f(x...) # = 6 f(;x...) # = Base.Iterato…

---

## [Is Julia REPL supposed to choke on this?](https://discourse.julialang.org/t/is-julia-repl-supposed-to-choke-on-this/42089)

<div class="topic-metadata">

**Author:** [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)\
**Replies:** 13\
**Last updated:** [June 26, 2020, 1:26pm UTC](https://discourse.julialang.org/t/is-julia-repl-supposed-to-choke-on-this/42089 "2020-06-26T13:26:17Z")

</div>

Julia 1.4.2 REPL completely chokes on this expression: let n = 10\_000 struct Sensors depth::NTuple{n, Float32} bottom::Float32 top::Float32 end s = Sensors(ntuple(x-\>0, n), 0, 0) end What is w…

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

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