# General Usage

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

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

**Page:** 731

---

## [Is it possible to have an empty array of \>2 dims?](https://discourse.julialang.org/t/is-it-possible-to-have-an-empty-array-of-2-dims/42658)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 4\
**Last updated:** [July 7, 2020, 6:39am UTC](https://discourse.julialang.org/t/is-it-possible-to-have-an-empty-array-of-2-dims/42658 "2020-07-07T06:39:20Z")

</div>

The function show\_nd in arrayshow.jl starts with this: function show\_nd(io::IO, a::AbstractArray, print\_matrix::Function, label\_slices::Bool) limit::Bool = get(io, :limit, false) if isempty(a) return …

---

## [A good way to filter an array with keeping its dimension](https://discourse.julialang.org/t/a-good-way-to-filter-an-array-with-keeping-its-dimension/42603)

<div class="topic-metadata">

**Author:** [@SSU](https://discourse.julialang.org/u/SSU)\
**Replies:** 4\
**Last updated:** [July 7, 2020, 5:58am UTC](https://discourse.julialang.org/t/a-good-way-to-filter-an-array-with-keeping-its-dimension/42603 "2020-07-07T05:58:01Z")

</div>

I want to filter nothing in an array with keeping its dimension. Is there any better way to do this other than using reshape()? x = \[ -0.240487 1.72634 -0.946312 0.915657 0.497511 3.77469 -1.63141…

---

## [Can an array have new elements added to it on the fly?](https://discourse.julialang.org/t/can-an-array-have-new-elements-added-to-it-on-the-fly/42653)

<div class="topic-metadata">

**Author:** [@fusion809](https://discourse.julialang.org/u/fusion809)\
**Replies:** 4\
**Last updated:** [July 7, 2020, 5:19am UTC](https://discourse.julialang.org/t/can-an-array-have-new-elements-added-to-it-on-the-fly/42653 "2020-07-07T05:19:33Z")

</div>

I’m writing a Runge-Kutta-Fehlberg solver (and yes I know that ODE.jl has one already, this is something I’m doing to learn more about both Julia and the method) and as the step sizes are adaptive it is not clear from th…

---

## [Question about TimeSeriesClustering.jl](https://discourse.julialang.org/t/question-about-timeseriesclustering-jl/42650)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 2\
**Last updated:** [July 7, 2020, 2:24am UTC](https://discourse.julialang.org/t/question-about-timeseriesclustering-jl/42650 "2020-07-07T02:24:01Z")

</div>

using TimeSeriesClustering,CSV #input\_data=load\_timeseries\_data(:GEP\_GER1) ts\_input\_data = load\_timeseries\_data(:CEP\_GER1; T=24, years=\[2016\]) When I run the code, Julia always displays the time series in my REPL. How …

---

## [Performance of views vs. explicit index referencing](https://discourse.julialang.org/t/performance-of-views-vs-explicit-index-referencing/42644)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 2\
**Last updated:** [July 7, 2020, 12:07am UTC](https://discourse.julialang.org/t/performance-of-views-vs-explicit-index-referencing/42644 "2020-07-07T00:07:57Z")

</div>

I spent some time trying to understand the advantages and disadvantages of using views in my code. The main reason for using views, in my case, was simplifying the code, by (as one example), having only one method to com…

---

## [Stochastic gradient descent](https://discourse.julialang.org/t/stochastic-gradient-descent/42642)

<div class="topic-metadata">

**Author:** [@A.U.M](https://discourse.julialang.org/u/A.U.M)\
**Replies:** 0\
**Last updated:** [July 6, 2020, 9:32pm UTC](https://discourse.julialang.org/t/stochastic-gradient-descent/42642 "2020-07-06T21:32:20Z")

</div>

Hello, I am working on implementing a function SGD ( Stochastic gradient descent ) I did it like the following but I want to Parallelize the for loop over all batches in the function in an optimum way can anyone help? …

---

## [Can't install "MultivariateMoments", error: unable to automatically install "XML2"](https://discourse.julialang.org/t/cant-install-multivariatemoments-error-unable-to-automatically-install-xml2/42623)

<div class="topic-metadata">

**Author:** [@aliceee](https://discourse.julialang.org/u/aliceee)\
**Replies:** 8\
**Last updated:** [July 6, 2020, 8:46pm UTC](https://discourse.julialang.org/t/cant-install-multivariatemoments-error-unable-to-automatically-install-xml2/42623 "2020-07-06T20:46:47Z")

</div>

Hi, I was trying to install the package “MultivariateMoments”. import Pkg; Pkg.add("MultivariateMoments") It failed with the following error: Unable to automatically install 'XML2' from '/Users/My\_Name/.julia/packages…

---

## [Delayed rejection adaptive metropolis](https://discourse.julialang.org/t/delayed-rejection-adaptive-metropolis/42632)

<div class="topic-metadata">

**Author:** [@Nimpa](https://discourse.julialang.org/u/Nimpa)\
**Replies:** 1\
**Last updated:** [July 6, 2020, 7:39pm UTC](https://discourse.julialang.org/t/delayed-rejection-adaptive-metropolis/42632 "2020-07-06T19:39:36Z")

</div>

I have been trying to write a julia code for the delayed rejection adaptive metropolis algorithm to no avail. Can anyone help

---

## [Optlevel with submodule](https://discourse.julialang.org/t/optlevel-with-submodule/42628)

<div class="topic-metadata">

**Author:** [@matthieu](https://discourse.julialang.org/u/matthieu)\
**Replies:** 2\
**Last updated:** [July 6, 2020, 6:37pm UTC](https://discourse.julialang.org/t/optlevel-with-submodule/42628 "2020-07-06T18:37:01Z")

</div>

I have a package that creates a submodule. I would like to use the optimization level 1 for everything except the submodule. If I use the code module MyPackage if isdefined(Base, :Experimental) && isdefined(Base.Expe…

---

## [How to make interpolated contour plot?](https://discourse.julialang.org/t/how-to-make-interpolated-contour-plot/42616)

<div class="topic-metadata">

**Author:** [@hafez\_ahmad](https://discourse.julialang.org/u/hafez_ahmad)\
**Replies:** 1\
**Last updated:** [July 6, 2020, 3:57pm UTC](https://discourse.julialang.org/t/how-to-make-interpolated-contour-plot/42616 "2020-07-06T15:57:35Z")

</div>

I am sorry and I am posting again, I like to make an interpolated contour plot. I have tried and haven’t work. Inverse distance weighting will be preferred interpolation method. my data looks like that \> first(df,5)…

---

## [Immutable allocation in Julia v1.5?](https://discourse.julialang.org/t/immutable-allocation-in-julia-v1-5/42598)

<div class="topic-metadata">

**Author:** [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Replies:** 2\
**Last updated:** [July 6, 2020, 3:11pm UTC](https://discourse.julialang.org/t/immutable-allocation-in-julia-v1-5/42598 "2020-07-06T15:11:57Z")

</div>

With Julia v1.5, is it correct to say that standalone (not part of an array or mutable struct) local immutable values, and all their immutable fields, are now always stack-allocated? Or are there cases where that might n…

---

## [The tracked parameters are not updated during Flux.training](https://discourse.julialang.org/t/the-tracked-parameters-are-not-updated-during-flux-training/42507)

<div class="topic-metadata">

**Author:** [@yanz4](https://discourse.julialang.org/u/yanz4)\
**Replies:** 2\
**Last updated:** [July 6, 2020, 2:55pm UTC](https://discourse.julialang.org/t/the-tracked-parameters-are-not-updated-during-flux-training/42507 "2020-07-06T14:55:40Z")

</div>

I’m building an oscillator defined by ODE. The purpose is to use Flux training to optimize parameters in ODE, i.e. the R and C value of the oscillator, given loss function. using Flux, DifferentialEquations, DiffEqSensi…

---

## [Question about data analysis](https://discourse.julialang.org/t/question-about-data-analysis/42605)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 5\
**Last updated:** [July 6, 2020, 1:24pm UTC](https://discourse.julialang.org/t/question-about-data-analysis/42605 "2020-07-06T13:24:19Z")

</div>

Does Julia have a Pkg or methods that can process temporal data and extract relevant features? thanks!!!

---

## [Threading: Array comprehension vs. fill](https://discourse.julialang.org/t/threading-array-comprehension-vs-fill/42604)

<div class="topic-metadata">

**Author:** [@jonas-kr](https://discourse.julialang.org/u/jonas-kr)\
**Replies:** 3\
**Last updated:** [July 6, 2020, 1:09pm UTC](https://discourse.julialang.org/t/threading-array-comprehension-vs-fill/42604 "2020-07-06T13:09:25Z")

</div>

I have noticed a very strange issue, which occurs in julia 1.4.2 on Windows 10. I have neither been able to reproduce it on Fedora 32 with julia 1.4.2 nor on Ubuntu 20.04 (WSL2) with julia 1.4.1. Define two functions: f…

---

## [A question about the "K" of kmeans](https://discourse.julialang.org/t/a-question-about-the-k-of-kmeans/42600)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 3\
**Last updated:** [July 6, 2020, 11:20am UTC](https://discourse.julialang.org/t/a-question-about-the-k-of-kmeans/42600 "2020-07-06T11:20:27Z")

</div>

What methods can assist in determining the number of classes in a cluster?what Pkg? thanks!!!

---

## [Using Iterators.rest to iterate over a range](https://discourse.julialang.org/t/using-iterators-rest-to-iterate-over-a-range/42597)

<div class="topic-metadata">

**Author:** [@andrewellis](https://discourse.julialang.org/u/andrewellis)\
**Replies:** 3\
**Last updated:** [July 6, 2020, 10:48am UTC](https://discourse.julialang.org/t/using-iterators-rest-to-iterate-over-a-range/42597 "2020-07-06T10:48:41Z")

</div>

Can anyone explain why Iterators.rest(\[1, 2, 3\], 2) |\> collect results in 2-element Array{Int64,1}: 2 3 but Iterators.rest(1:3, 2) |\> collect returns 1-element Array{Int64,1}: 3 ?

---

## [A question about my Plots.scatter](https://discourse.julialang.org/t/a-question-about-my-plots-scatter/42594)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 2\
**Last updated:** [July 6, 2020, 10:04am UTC](https://discourse.julialang.org/t/a-question-about-my-plots-scatter/42594 "2020-07-06T10:04:33Z")

</div>

using CSV,DataFrames,Statistics,StatsBase,TimeSeries,Plots #Clustering,Gadfly,Statistics,DataFrames,Plots,StatsBase,FFTW,MultivariateStats,BetaML data=CSV.read("D:\\\\mycode\\\\code\\\\数据.csv") MD=data\[96412:96775,:\] load=con…

---

## [Copying files within a a package folder](https://discourse.julialang.org/t/copying-files-within-a-a-package-folder/42593)

<div class="topic-metadata">

**Author:** [@Azzaare](https://discourse.julialang.org/u/Azzaare)\
**Replies:** 1\
**Last updated:** [July 6, 2020, 7:47am UTC](https://discourse.julialang.org/t/copying-files-within-a-a-package-folder/42593 "2020-07-06T07:47:54Z")

</div>

Hello there, Within a package that I am developing now, I have a folder of assets that I would like to copy to the working directory of the user. Is there a way to access the path of a specific package (in used in the …

---

## [Should I use @inbounds on for loop iterating through the values of a Dict?](https://discourse.julialang.org/t/should-i-use-inbounds-on-for-loop-iterating-through-the-values-of-a-dict/42570)

<div class="topic-metadata">

**Author:** [@jchen975](https://discourse.julialang.org/u/jchen975)\
**Replies:** 3\
**Last updated:** [July 6, 2020, 6:03am UTC](https://discourse.julialang.org/t/should-i-use-inbounds-on-for-loop-iterating-through-the-values-of-a-dict/42570 "2020-07-06T06:03:26Z")

</div>

Hello, I’m wondering if it’s appropriate (and necessary) to use @inbounds on a for loop that iterates through the keys/values of a Dict. After a quick search the examples where @inbounds helps are where I’m indexing an A…

---

## [Random Tuple](https://discourse.julialang.org/t/random-tuple/30623)

<div class="topic-metadata">

**Author:** [@martingalemeasure](https://discourse.julialang.org/u/martingalemeasure)\
**Replies:** 8\
**Last updated:** [July 6, 2020, 3:32am UTC](https://discourse.julialang.org/t/random-tuple/30623 "2020-07-06T03:32:16Z")

</div>

How do I create a random Tuple in Julia 1.2. In the docs it says " Support for S as a tuple requires at least Julia 1.1." but when I try rand(Tuple{Int64, Int64}) I get the error “Sampler for this object is not defin…

---

## [StratifiedKfold](https://discourse.julialang.org/t/stratifiedkfold/17957)

<div class="topic-metadata">

**Author:** [@lvoltz](https://discourse.julialang.org/u/lvoltz)\
**Replies:** 7\
**Last updated:** [July 6, 2020, 2:50am UTC](https://discourse.julialang.org/t/stratifiedkfold/17957 "2020-07-06T02:50:55Z")

</div>

Hello, I am new in Julia and I am trying to figure out how to use StratifiedKfold. I am using Julia 0.6 and just Kfold now like: Xdata=readdlm(“data.txt”) Ytarget=readdlm(“taget.txt”) folds = kfolds((Xdata,Ytarget),k=…

---

## [Refer to a function in enclosing module](https://discourse.julialang.org/t/refer-to-a-function-in-enclosing-module/42580)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 2\
**Last updated:** [July 6, 2020, 12:02am UTC](https://discourse.julialang.org/t/refer-to-a-function-in-enclosing-module/42580 "2020-07-06T00:02:24Z")

</div>

This stumps me at the moment: How do I refer to f in the submodule? module A f(x) = 10\*x module SubA g(x) = f(1) end end using .A @show A.SubA.g(3)

---

## [How to parameterize an argument which is either Int64,Int32, etc](https://discourse.julialang.org/t/how-to-parameterize-an-argument-which-is-either-int64-int32-etc/42564)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 3\
**Last updated:** [July 5, 2020, 5:38pm UTC](https://discourse.julialang.org/t/how-to-parameterize-an-argument-which-is-either-int64-int32-etc/42564 "2020-07-05T17:38:21Z")

</div>

I tried this and it stubbornly refuses to accept anything but Int64: function testint(num::Int) print(num) end check = Int8(4) testint(check) ERROR: MethodError: no method matching testint(::Int8) Closest candidat…

---

## [Multidimensional interpolation](https://discourse.julialang.org/t/multidimensional-interpolation/42563)

<div class="topic-metadata">

**Author:** [@IgnacioSuarez](https://discourse.julialang.org/u/IgnacioSuarez)\
**Replies:** 0\
**Last updated:** [July 5, 2020, 4:54pm UTC](https://discourse.julialang.org/t/multidimensional-interpolation/42563 "2020-07-05T16:54:56Z")

</div>

Hi! I would like to fit a dipole moment surface for tri- and tetra-atomic molecules. That means that the dipole moment depends on 3 variables for the first case and on 6 variables for the tetra-atomic case. For that pu…

---

## [Time needed to perform a complete loop](https://discourse.julialang.org/t/time-needed-to-perform-a-complete-loop/42494)

<div class="topic-metadata">

**Author:** [@sergevic](https://discourse.julialang.org/u/sergevic)\
**Replies:** 10\
**Last updated:** [July 4, 2020, 11:56pm UTC](https://discourse.julialang.org/t/time-needed-to-perform-a-complete-loop/42494 "2020-07-04T23:56:06Z")

</div>

I want to measure the total amount of time nedded to perform a complete loop. I tried @time for i in 1:10000 ... ... end and it returned .988083 seconds (57.58 M allocations: 39.867 GiB, 0.14% gc time) when the code ra…

---

## [Linear algebra with array wrapper types](https://discourse.julialang.org/t/linear-algebra-with-array-wrapper-types/42483)

<div class="topic-metadata">

**Author:** [@jonniedie](https://discourse.julialang.org/u/jonniedie)\
**Replies:** 5\
**Last updated:** [July 4, 2020, 5:49pm UTC](https://discourse.julialang.org/t/linear-algebra-with-array-wrapper-types/42483 "2020-07-04T17:49:50Z")

</div>

What is the “correct” way to define multiplication and division for AbstractArray types that are wrappers around other arrays? So let’s say I have an array wrapper type: struct MyArray{T,N,A\<:AbstractArray{T,N}} \<: Abs…

---

## [Julia vs. R Speed for sampling the Wishart distribution](https://discourse.julialang.org/t/julia-vs-r-speed-for-sampling-the-wishart-distribution/21352)

<div class="topic-metadata">

**Author:** [@Donald\_Williams](https://discourse.julialang.org/u/Donald_Williams)\
**Replies:** 28\
**Last updated:** [July 4, 2020, 2:50pm UTC](https://discourse.julialang.org/t/julia-vs-r-speed-for-sampling-the-wishart-distribution/21352 "2020-07-04T14:50:10Z")

</div>

Hi: I was wondering if it is possible to speed up the following. I have found it takes much longer than R. The difference is not small, as in Julia this take 11 seconds and in R it takes only 1.5 seconds. function …

---

## [Adding methods with metaprogramming](https://discourse.julialang.org/t/adding-methods-with-metaprogramming/42518)

<div class="topic-metadata">

**Author:** [@sw72](https://discourse.julialang.org/u/sw72)\
**Replies:** 1\
**Last updated:** [July 4, 2020, 11:58am UTC](https://discourse.julialang.org/t/adding-methods-with-metaprogramming/42518 "2020-07-04T11:58:12Z")

</div>

I have a couple of types defined like this: struct Foo foo end struct Bar foo::Foo bar baz end Then I have a bunch of functions defined for Foo, with additional methods for Bar that just pass through t…

---

## [Alternate BLAS libraries?](https://discourse.julialang.org/t/alternate-blas-libraries/26317)

<div class="topic-metadata">

**Author:** [@Raf](https://discourse.julialang.org/u/Raf)\
**Replies:** 22\
**Last updated:** [July 4, 2020, 11:23am UTC](https://discourse.julialang.org/t/alternate-blas-libraries/26317 "2020-07-04T11:23:20Z")

</div>

I’m running some processor heavy stochastic simulations that are increasingly limited by BLAS matrix dot multiplications on 9\*9 matrices, as I gradually add optimisations for everything else. It seems that MKL (and mayb…

---

## [ImageMagick.jl and PyPlot.jl conflicting libpng](https://discourse.julialang.org/t/imagemagick-jl-and-pyplot-jl-conflicting-libpng/37139)

<div class="topic-metadata">

**Author:** [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Replies:** 3\
**Last updated:** [July 4, 2020, 10:46am UTC](https://discourse.julialang.org/t/imagemagick-jl-and-pyplot-jl-conflicting-libpng/37139 "2020-07-04T10:46:25Z")

</div>

on my macOS machine, I can trigger this with julia\> import ImageMagick julia\> import PyCall; PyCall.pyimport("matplotlib") gives ImportError('dlopen(/Users/goretkin/.julia/conda/3/lib/python3.7/site-packages/matplotl…

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

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