# General Usage

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

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

**Page:** 661

---

## [Taking an existing type as an argument](https://discourse.julialang.org/t/taking-an-existing-type-as-an-argument/52854)

<div class="topic-metadata">

**Author:** [@ckfinite](https://discourse.julialang.org/u/ckfinite)\
**Replies:** 0\
**Last updated:** [January 4, 2021, 10:32pm UTC](https://discourse.julialang.org/t/taking-an-existing-type-as-an-argument/52854 "2021-01-04T22:32:06Z")

</div>

I’m working on writing a wrapper for an existing sparse linear algebra library using CxxWrap.jl, and one of the functions takes a SuiteSparse (under a different name, but identical by design memory layout) sparse matrix …

---

## [Combinations across arrays](https://discourse.julialang.org/t/combinations-across-arrays/52847)

<div class="topic-metadata">

**Author:** [@danicaratelli](https://discourse.julialang.org/u/danicaratelli)\
**Replies:** 2\
**Last updated:** [January 4, 2021, 10:11pm UTC](https://discourse.julialang.org/t/combinations-across-arrays/52847 "2021-01-04T22:11:51Z")

</div>

I have three arrays: a=\[1,2,3\]; b=\[4,5,6\]; c=\[7,8,9\]; and I want to get all possible combinations across the three arrays with three elements, the first from a, the second from b, and the third from c. That is: result…

---

## [Seeking julia 1.6 binary for linux](https://discourse.julialang.org/t/seeking-julia-1-6-binary-for-linux/52846)

<div class="topic-metadata">

**Author:** [@Alex\_Ellison](https://discourse.julialang.org/u/Alex_Ellison)\
**Replies:** 2\
**Last updated:** [January 4, 2021, 8:56pm UTC](https://discourse.julialang.org/t/seeking-julia-1-6-binary-for-linux/52846 "2021-01-04T20:56:46Z")

</div>

Hey all, I see how one can download stable julia, old julia, or nightly julia. Right now, stable is 1.5.x and nightly appears to be just 1.7 (at least through the nightlies page). I really need 1.6. Is there somewhere t…

---

## [String Interpolation Question](https://discourse.julialang.org/t/string-interpolation-question/52752)

<div class="topic-metadata">

**Author:** [@Bryan\_So](https://discourse.julialang.org/u/Bryan_So)\
**Replies:** 4\
**Last updated:** [January 4, 2021, 7:14pm UTC](https://discourse.julialang.org/t/string-interpolation-question/52752 "2021-01-04T19:14:42Z")

</div>

HI, very simple beginner’s question about string interpolation: If a variable is a struct that has a Base.string method. Does string interpolation use that method? This is most curious: struct Expression\_Symbol d…

---

## [Polar plot gets cropped](https://discourse.julialang.org/t/polar-plot-gets-cropped/52802)

<div class="topic-metadata">

**Author:** [@Tofi](https://discourse.julialang.org/u/Tofi)\
**Replies:** 2\
**Last updated:** [January 4, 2021, 5:09pm UTC](https://discourse.julialang.org/t/polar-plot-gets-cropped/52802 "2021-01-04T17:09:48Z")

</div>

Hello, I’m trying to plot the trajectory of an object falling in a central gravitational potential well. The plot is obtained using the relation between r and θ by running the following code in the Jupyter notebook: us…

---

## [Julia: symbol lookup error: julia: undefined symbol: jl\_uv\_stderr](https://discourse.julialang.org/t/julia-symbol-lookup-error-julia-undefined-symbol-jl-uv-stderr/52823)

<div class="topic-metadata">

**Author:** [@Steven\_Varga](https://discourse.julialang.org/u/Steven_Varga)\
**Replies:** 0\
**Last updated:** [January 4, 2021, 1:39pm UTC](https://discourse.julialang.org/t/julia-symbol-lookup-error-julia-undefined-symbol-jl-uv-stderr/52823 "2021-01-04T13:39:45Z")

</div>

Recently the following error message haphazardly crops up: julia: symbol lookup error: julia: undefined symbol: jl\_uv\_stderr, making everyday work frustrating. Various recent versions 1.5.2 - 1.5.3 of Julia has been comp…

---

## [Vector function representation](https://discourse.julialang.org/t/vector-function-representation/52779)

<div class="topic-metadata">

**Author:** [@shawnfrost](https://discourse.julialang.org/u/shawnfrost)\
**Replies:** 1\
**Last updated:** [January 4, 2021, 12:52pm UTC](https://discourse.julialang.org/t/vector-function-representation/52779 "2021-01-04T12:52:47Z")

</div>

Hi, Some background: I’m new to writing distributed programs and I’m trying to write a variation of the SSA algorithm in Julia. My system has a lot of reactions, and I need to calculate the propensity of these reactions…

---

## [@code\_warntype gives yellow ::Union{Nothing, Tuple{Int64,Int64}} in for loops](https://discourse.julialang.org/t/code-warntype-gives-yellow-union-nothing-tuple-int64-int64-in-for-loops/52814)

<div class="topic-metadata">

**Author:** [@claudio20497](https://discourse.julialang.org/u/claudio20497)\
**Replies:** 1\
**Last updated:** [January 4, 2021, 12:41pm UTC](https://discourse.julialang.org/t/code-warntype-gives-yellow-union-nothing-tuple-int64-int64-in-for-loops/52814 "2021-01-04T12:41:28Z")

</div>

Hello, I’d have the following usage question. If I have a function with a for loop inside, like: function f() for i in 1:2 end end And I call @code\_warntype on it, i get a yellow line: @code\_warntype f() V…

---

## [@nloops with type parameter N](https://discourse.julialang.org/t/nloops-with-type-parameter-n/52733)

<div class="topic-metadata">

**Author:** [@roflmaostc](https://discourse.julialang.org/u/roflmaostc)\
**Replies:** 4\
**Last updated:** [January 4, 2021, 12:19pm UTC](https://discourse.julialang.org/t/nloops-with-type-parameter-n/52733 "2021-01-04T12:19:47Z")

</div>

Hey, I was trying to create a function body which contains @nloops N i A. However, the N depends on the dimension of the array. Following MWE: A = randn((2,2,2)) function foo(A::AbstractArray{T, N}) where {T, N} …

---

## [@btime introduces a new scope?](https://discourse.julialang.org/t/btime-introduces-a-new-scope/52818)

<div class="topic-metadata">

**Author:** [@Gus\_Hart](https://discourse.julialang.org/u/Gus_Hart)\
**Replies:** 1\
**Last updated:** [January 4, 2021, 11:38am UTC](https://discourse.julialang.org/t/btime-introduces-a-new-scope/52818 "2021-01-04T11:38:30Z")

</div>

I was trying to assess the big-O scaling (N vs N^2) for a couple of functions I had written. So I put @btime in a loop like this: But apparently, k is not in the scope of @btime. This is probably obvious to someone that…

---

## [XML to DataFrame (or just to a dict)](https://discourse.julialang.org/t/xml-to-dataframe-or-just-to-a-dict/52656)

<div class="topic-metadata">

**Author:** [@Gus\_Hart](https://discourse.julialang.org/u/Gus_Hart)\
**Replies:** 2\
**Last updated:** [January 4, 2021, 11:27am UTC](https://discourse.julialang.org/t/xml-to-dataframe-or-just-to-a-dict/52656 "2021-01-04T11:27:46Z")

</div>

In a simulation code that I use, the output is stored in a plain text file and in an xml file. I have been parsing the plain text myself, but some things are hard to extract (requiring complex logic). It would be nice if…

---

## [How to provide a macro in a module (package) as it would be used in the user code (i.e. with access to the user current scope)](https://discourse.julialang.org/t/how-to-provide-a-macro-in-a-module-package-as-it-would-be-used-in-the-user-code-i-e-with-access-to-the-user-current-scope/52815)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 1\
**Last updated:** [January 4, 2021, 10:33am UTC](https://discourse.julialang.org/t/how-to-provide-a-macro-in-a-module-package-as-it-would-be-used-in-the-user-code-i-e-with-access-to-the-user-current-scope/52815 "2021-01-04T10:33:00Z")

</div>

Let’s say I want to provide users with the above macro: macro customLoop(controlExpr,workExpr) return quote for i in $controlExpr $workExpr end end end If this macro is evaluated in Main then the user…

---

## [Ghost function surviving between package versions](https://discourse.julialang.org/t/ghost-function-surviving-between-package-versions/52812)

<div class="topic-metadata">

**Author:** [@virgile-baudrot](https://discourse.julialang.org/u/virgile-baudrot)\
**Replies:** 2\
**Last updated:** [January 4, 2021, 9:46am UTC](https://discourse.julialang.org/t/ghost-function-surviving-between-package-versions/52812 "2021-01-04T09:46:32Z")

</div>

Dear all, I made a package with a function called runMCMC returning a DataFrame in version 0.2.0 and an Array in version 0.3.0 (ok, I should have upgrade to 1.0.0 but it’s quite confidential for now). I send 0.2.0 to …

---

## [Type stability when DataType is passed as a keyword argument](https://discourse.julialang.org/t/type-stability-when-datatype-is-passed-as-a-keyword-argument/52770)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 3\
**Last updated:** [January 3, 2021, 8:57pm UTC](https://discourse.julialang.org/t/type-stability-when-datatype-is-passed-as-a-keyword-argument/52770 "2021-01-03T20:57:56Z")

</div>

Hi all- I have a question about type stability when a DataType is passed as a keyword argument. The code below shows all combinations of positional vs keyword arguments and Float64 vs DataType. Why is the DataType keywo…

---

## [Options for developing GUI standalone app](https://discourse.julialang.org/t/options-for-developing-gui-standalone-app/52776)

<div class="topic-metadata">

**Author:** [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Replies:** 8\
**Last updated:** [January 3, 2021, 8:40pm UTC](https://discourse.julialang.org/t/options-for-developing-gui-standalone-app/52776 "2021-01-03T20:40:20Z")

</div>

A lot of what I’ve used Julia for so far has been data analysis with Jupiter or Pluto, or writing command line scripts. Now I want to develop a tool for measuring network performance under various conditions. It should h…

---

## [Defining Sparse Matrix from Scratch using vectors](https://discourse.julialang.org/t/defining-sparse-matrix-from-scratch-using-vectors/52772)

<div class="topic-metadata">

**Author:** [@tgautam03](https://discourse.julialang.org/u/tgautam03)\
**Replies:** 6\
**Last updated:** [January 3, 2021, 6:56pm UTC](https://discourse.julialang.org/t/defining-sparse-matrix-from-scratch-using-vectors/52772 "2021-01-03T18:56:45Z")

</div>

Hi I want to create a custom tridiagonal matrix type whose inputs will be 3 different vectors (c, d and e). These 3 vectors will make the matrix in a format as follows: I tried writing a struct struct tridiag \<: …

---

## [Macro to create structs with custom fields and parametric types](https://discourse.julialang.org/t/macro-to-create-structs-with-custom-fields-and-parametric-types/52781)

<div class="topic-metadata">

**Author:** [@mrVeng](https://discourse.julialang.org/u/mrVeng)\
**Replies:** 0\
**Last updated:** [January 3, 2021, 4:59pm UTC](https://discourse.julialang.org/t/macro-to-create-structs-with-custom-fields-and-parametric-types/52781 "2021-01-03T16:59:36Z")

</div>

Hi there, I am starting to learn about Macros in Julia and have a few difficulties with it. My goal is to create a new struct with some custom fields. After searching and reading here on discourse, I found this useful …

---

## [DimensionMismatch("arrays could not be broadcast to a common size")](https://discourse.julialang.org/t/dimensionmismatch-arrays-could-not-be-broadcast-to-a-common-size/52696)

<div class="topic-metadata">

**Author:** [@marouane1994](https://discourse.julialang.org/u/marouane1994)\
**Replies:** 8\
**Last updated:** [January 3, 2021, 3:32pm UTC](https://discourse.julialang.org/t/dimensionmismatch-arrays-could-not-be-broadcast-to-a-common-size/52696 "2021-01-03T15:32:21Z")

</div>

i have this function for computing a probability function probability(eta,pdc,x::Array,y::Array) P=\[\] for k in 1:length(y) if y\[k\]==0 push!(P,(1-pdc)\*(1-eta\*(1-pdc))^x\[k\]) elseif y\[k\]…

---

## [Parallel independent loops in julia](https://discourse.julialang.org/t/parallel-independent-loops-in-julia/52737)

<div class="topic-metadata">

**Author:** [@Nishan](https://discourse.julialang.org/u/Nishan)\
**Replies:** 5\
**Last updated:** [January 3, 2021, 2:55pm UTC](https://discourse.julialang.org/t/parallel-independent-loops-in-julia/52737 "2021-01-03T14:55:07Z")

</div>

Hello everyone, I am new to julia and currently I am converting my tensor networks codes from python to julia and till now it seems great and I could do it without much pain and just by rewriting it in julia I have gaine…

---

## [Issues in assigning combinations to indices and appending values to arrays](https://discourse.julialang.org/t/issues-in-assigning-combinations-to-indices-and-appending-values-to-arrays/52771)

<div class="topic-metadata">

**Author:** [@mdsa3d](https://discourse.julialang.org/u/mdsa3d)\
**Replies:** 1\
**Last updated:** [January 3, 2021, 1:23pm UTC](https://discourse.julialang.org/t/issues-in-assigning-combinations-to-indices-and-appending-values-to-arrays/52771 "2021-01-03T13:23:45Z")

</div>

I would like to seek advice on this code snippet, results, xi, xj = (\[\] for count in 1:6) for comb in c i, j = comb #assign the rows of comb\[i\] to i and comb\[j\] to j result = algae(xi = df1\[:, i\], xj = df2\[:, j\],…

---

## [What is the alternative to Python gym.spaces.Box() in Julia?](https://discourse.julialang.org/t/what-is-the-alternative-to-python-gym-spaces-box-in-julia/52758)

<div class="topic-metadata">

**Author:** [@ZdM87](https://discourse.julialang.org/u/ZdM87)\
**Replies:** 2\
**Last updated:** [January 3, 2021, 12:52pm UTC](https://discourse.julialang.org/t/what-is-the-alternative-to-python-gym-spaces-box-in-julia/52758 "2021-01-03T12:52:06Z")

</div>

In Python gym’s there is a class called Box that defines a (possibly unbounded) box in R^n. Is there any alternative to this box in Julia? There is IntervalSets.jl but I cannot seem to be able to create a Cartesian prod…

---

## [ERROR: Output should be scalar; gradients are not defined for output](https://discourse.julialang.org/t/error-output-should-be-scalar-gradients-are-not-defined-for-output/52769)

<div class="topic-metadata">

**Author:** [@BaoBaoDeMeng](https://discourse.julialang.org/u/BaoBaoDeMeng)\
**Replies:** 0\
**Last updated:** [January 3, 2021, 9:16am UTC](https://discourse.julialang.org/t/error-output-should-be-scalar-gradients-are-not-defined-for-output/52769 "2021-01-03T09:16:57Z")

</div>

using Flux W\_1 = rand(2) W\_2 = rand(2) W\_3 = rand(2) b\_1 = rand(2) b\_2 = rand(1) function z(x,t) return (W\_1x+W\_2t+b\_1) end function sigmod(u) return 1/(1+exp(-u)) end function g\_u(x,t) return sum(\[sigmod(z…

---

## [Better Alternative to Eval? Building Browser based IDE for Julia](https://discourse.julialang.org/t/better-alternative-to-eval-building-browser-based-ide-for-julia/52155)

<div class="topic-metadata">

**Author:** [@Joe\_Schnetzler](https://discourse.julialang.org/u/Joe_Schnetzler)\
**Replies:** 12\
**Last updated:** [January 2, 2021, 11:45am UTC](https://discourse.julialang.org/t/better-alternative-to-eval-building-browser-based-ide-for-julia/52155 "2021-01-02T11:45:09Z")

</div>

Hello! After months of looking for and waiting for a quality cloud/browser-based IDE that fits my needs and wants for Julia, I have taken it upon myself to build my own. I come from a heavy statistics background so I am …

---

## [Clang.jl wrapper generation warnings/missing parts](https://discourse.julialang.org/t/clang-jl-wrapper-generation-warnings-missing-parts/34093)

<div class="topic-metadata">

**Author:** [@rayegun](https://discourse.julialang.org/u/rayegun)\
**Replies:** 9\
**Last updated:** [January 2, 2021, 10:29pm UTC](https://discourse.julialang.org/t/clang-jl-wrapper-generation-warnings-missing-parts/34093 "2021-01-02T22:29:25Z")

</div>

I’m trying to wrap this this GraphBLAS.h file using Clang.jl (There is already a wrapper package, but I want to try generating it automatically). I used this code: const z = "/usr/lib/clang/9.0.0/include" const y = "/ho…

---

## [Spdiagm allocation madness](https://discourse.julialang.org/t/spdiagm-allocation-madness/52703)

<div class="topic-metadata">

**Author:** [@ctkelley](https://discourse.julialang.org/u/ctkelley)\
**Replies:** 2\
**Last updated:** [January 2, 2021, 10:07pm UTC](https://discourse.julialang.org/t/spdiagm-allocation-madness/52703 "2021-01-02T22:07:14Z")

</div>

I am seeing surprisingly large allocations from spdiagm. The compute times are ok for what I need to do, so perhaps this is a case where large allocations do not harm. Here’s the story. I compute the discrete negative…

---

## [IntelOpenMP Windows installation issue](https://discourse.julialang.org/t/intelopenmp-windows-installation-issue/52724)

<div class="topic-metadata">

**Author:** [@youfangcao](https://discourse.julialang.org/u/youfangcao)\
**Replies:** 2\
**Last updated:** [January 2, 2021, 4:38pm UTC](https://discourse.julialang.org/t/intelopenmp-windows-installation-issue/52724 "2021-01-02T16:38:33Z")

</div>

Hi, and @staticfloat, I am new into Julia and trying to install the DataDrivenDiffEq package on my Windows 10 laptop. However, I got an error message saying unable automatically install ‘IntelOpenMP’ from local Artifacts…

---

## ["contour not defined" when using my package](https://discourse.julialang.org/t/contour-not-defined-when-using-my-package/52727)

<div class="topic-metadata">

**Author:** [@EmadMasroor](https://discourse.julialang.org/u/EmadMasroor)\
**Replies:** 2\
**Last updated:** [January 2, 2021, 8:22am UTC](https://discourse.julialang.org/t/contour-not-defined-when-using-my-package/52727 "2021-01-02T08:22:39Z")

</div>

Hello, I am building a new package for the first time, and I’m running into a problem when I call one of the functions exported by my package, SimpleNavierStokes.jl. The package exports a function, LidDrivenCavity(). T…

---

## [Display(img) prints output additionally to showing image in Atom](https://discourse.julialang.org/t/display-img-prints-output-additionally-to-showing-image-in-atom/52714)

<div class="topic-metadata">

**Author:** [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Replies:** 0\
**Last updated:** [January 1, 2021, 10:44pm UTC](https://discourse.julialang.org/t/display-img-prints-output-additionally-to-showing-image-in-atom/52714 "2021-01-01T22:44:56Z")

</div>

MWE using Colors, TestImages, ImageIO, ImageShow, FileIO img = testimage("cameraman.tif"); display("image/png", img); Additionally to displaying the image in the Plots pane of Atom (which is what I want) it also prints…

---

## [How to stream a large random matrix to a file?](https://discourse.julialang.org/t/how-to-stream-a-large-random-matrix-to-a-file/52673)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 3\
**Last updated:** [January 1, 2021, 7:45pm UTC](https://discourse.julialang.org/t/how-to-stream-a-large-random-matrix-to-a-file/52673 "2021-01-01T19:45:58Z")

</div>

The following attempts to stream a large random array to a file and read it with Mmap, but causes errors: @testset "stream an m x n matrix to a file and read via Mmap" begin m=10 n=10^5 fn="/tmp/mmap.bin" …

---

## [Storage-based array that implements @views?](https://discourse.julialang.org/t/storage-based-array-that-implements-views/52640)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 9\
**Last updated:** [January 1, 2021, 7:41pm UTC](https://discourse.julialang.org/t/storage-based-array-that-implements-views/52640 "2021-01-01T19:41:04Z")

</div>

I would like to do a piece-wise reduction (on sub-arrays) of a large array that is too big to fit into memory. Is there a ‘storage-based array’ that implements @views?

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

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