# General Usage

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

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

**Page:** 578

---

## [A good way of checking whether a keyword argument is present](https://discourse.julialang.org/t/a-good-way-of-checking-whether-a-keyword-argument-is-present/64199)

<div class="topic-metadata">

**Author:** [@Jan\_Dolinsky](https://discourse.julialang.org/u/Jan_Dolinsky)\
**Replies:** 7\
**Last updated:** [July 9, 2021, 3:10pm UTC](https://discourse.julialang.org/t/a-good-way-of-checking-whether-a-keyword-argument-is-present/64199 "2021-07-09T15:10:24Z")

</div>

Hello, I\`d like to check for a presence of a particular keyword argument. I wanted to cross-check whether I am doing the right thing here. This works but I feel using “filter” is perhaps an overkill and there might be …

---

## [Declarative ylims!](https://discourse.julialang.org/t/declarative-ylims/62504)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 10\
**Last updated:** [July 9, 2021, 1:15pm UTC](https://discourse.julialang.org/t/declarative-ylims/62504 "2021-07-09T13:15:29Z")

</div>

f = draw(layers) ylims!(f.grid\[1,1\].axis, -.4, .4) Is there a declarative way to set the axis limits using the draw function?

---

## [Help with Pkg Error in Julia 1.6.1 (windows)](https://discourse.julialang.org/t/help-with-pkg-error-in-julia-1-6-1-windows/64265)

<div class="topic-metadata">

**Author:** [@Rodrigo\_B](https://discourse.julialang.org/u/Rodrigo_B)\
**Replies:** 2\
**Last updated:** [July 9, 2021, 12:19pm UTC](https://discourse.julialang.org/t/help-with-pkg-error-in-julia-1-6-1-windows/64265 "2021-07-09T12:19:48Z")

</div>

Dear Community, would like to request your help with the following error. Recently I installed Julia 1.6.1 in a windows machine, and for some strange reason the Pkg.add(…) throws the following error: ERROR: KeyError…

---

## [Gathering monomial coefficients of orthogonal polynomials using SpecialPolynomials.jl](https://discourse.julialang.org/t/gathering-monomial-coefficients-of-orthogonal-polynomials-using-specialpolynomials-jl/63554)

<div class="topic-metadata">

**Author:** [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Replies:** 34\
**Last updated:** [July 9, 2021, 11:56am UTC](https://discourse.julialang.org/t/gathering-monomial-coefficients-of-orthogonal-polynomials-using-specialpolynomials-jl/63554 "2021-07-09T11:56:23Z")

</div>

While using SpecialPolynomials.jl I want to gather the monomial coefficients of multiple orthogonal polynomials of increasing size in a matrix. My current implementation is using LinearAlgebra,SpecialPolynomials,Polyno…

---

## [Val type is type unstable?](https://discourse.julialang.org/t/val-type-is-type-unstable/64336)

<div class="topic-metadata">

**Author:** [@shamazmazum](https://discourse.julialang.org/u/shamazmazum)\
**Replies:** 2\
**Last updated:** [July 9, 2021, 10:34am UTC](https://discourse.julialang.org/t/val-type-is-type-unstable/64336 "2021-07-09T10:34:06Z")

</div>

Hello, should I be afraid of ::Val{\_A} where \_A in this situation? f(x, y, ::Val{:x}) = x f(x, y, ::Val{:y}) = y f(x, y, s :: Symbol) = f(x, y, Val(s)) @code\_warntype f(1,2,:x) Variables #self#::Core.Const(f) x::I…

---

## [AlgebraOfGraphics.jl: Combine mappings & data with different unnamed arguments](https://discourse.julialang.org/t/algebraofgraphics-jl-combine-mappings-data-with-different-unnamed-arguments/64258)

<div class="topic-metadata">

**Author:** [@behinger](https://discourse.julialang.org/u/behinger)\
**Replies:** 4\
**Last updated:** [July 8, 2021, 8:52pm UTC](https://discourse.julialang.org/t/algebraofgraphics-jl-combine-mappings-data-with-different-unnamed-arguments/64258 "2021-07-08T20:52:25Z")

</div>

I want to share some mappings (e.g. color, col) between two datasets and two visuals, but the number of unnamed inputs to the visuals is different. A simplified version without any shared mappings: d1 = (;segments=\[Rect…

---

## [CSV reading in mutable struct error reading Int as string](https://discourse.julialang.org/t/csv-reading-in-mutable-struct-error-reading-int-as-string/64323)

<div class="topic-metadata">

**Author:** [@manoj.centura](https://discourse.julialang.org/u/manoj.centura)\
**Replies:** 3\
**Last updated:** [July 9, 2021, 8:51am UTC](https://discourse.julialang.org/t/csv-reading-in-mutable-struct-error-reading-int-as-string/64323 "2021-07-09T08:51:56Z")

</div>

Hi All, While putting csv data in a struct getting the error for the below. localpath = string("D:\\\\crane\_intensity\\\\") mutable struct GeneralDetail B::UInt8 C::UInt8 P::UInt8 T::UInt8 Cs\_m::Array{UInt8,…

---

## [Detect possible exceptions](https://discourse.julialang.org/t/detect-possible-exceptions/64304)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 2\
**Last updated:** [July 9, 2021, 2:55am UTC](https://discourse.julialang.org/t/detect-possible-exceptions/64304 "2021-07-09T02:55:17Z")

</div>

Suppose I want to have more confidence about the control flow in part of my program. Is it possible to detect what exceptions a function might throw? E.g. is that something JET can do? @aviatesk

---

## [Union splitting vs C++](https://discourse.julialang.org/t/union-splitting-vs-c/61772)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 22\
**Last updated:** [July 9, 2021, 12:32am UTC](https://discourse.julialang.org/t/union-splitting-vs-c/61772 "2021-07-09T00:32:18Z")

</div>

This is a continuation from this thread: Performance drawback with subtyping - #31 by paulmelis Here we have two codes, which compute someting simple (the sum of the values of a field of a type in an array of mixed type…

---

## [Row vs. column major for arrays of coordinate vectors](https://discourse.julialang.org/t/row-vs-column-major-for-arrays-of-coordinate-vectors/64297)

<div class="topic-metadata">

**Author:** [@pavanakumar](https://discourse.julialang.org/u/pavanakumar)\
**Replies:** 7\
**Last updated:** [July 8, 2021, 8:47pm UTC](https://discourse.julialang.org/t/row-vs-column-major-for-arrays-of-coordinate-vectors/64297 "2021-07-08T20:47:02Z")

</div>

There is one advantage that I can think of with column major storage for geometry (coordinate storage). 1D, 2D and 3D coordinates can be represented without hassle. A row-major format will require variable stride (1 in 1…

---

## [Building a cubic spline interpolator using points and specifying derivatives](https://discourse.julialang.org/t/building-a-cubic-spline-interpolator-using-points-and-specifying-derivatives/64238)

<div class="topic-metadata">

**Author:** [@donkeysaddle](https://discourse.julialang.org/u/donkeysaddle)\
**Replies:** 6\
**Last updated:** [July 8, 2021, 7:49pm UTC](https://discourse.julialang.org/t/building-a-cubic-spline-interpolator-using-points-and-specifying-derivatives/64238 "2021-07-08T19:49:01Z")

</div>

Is there a way to build a cubic spline in either Interpolations.jl or Dierckx.jl (or somewhere else) where you can set what the derivatives should be at specified points. Ideally, these derivatives would not have to be a…

---

## [Handling functions that have "constant" sub-expressions when looping over arguments](https://discourse.julialang.org/t/handling-functions-that-have-constant-sub-expressions-when-looping-over-arguments/64181)

<div class="topic-metadata">

**Author:** [@nchisholm](https://discourse.julialang.org/u/nchisholm)\
**Replies:** 3\
**Last updated:** [July 8, 2021, 7:26pm UTC](https://discourse.julialang.org/t/handling-functions-that-have-constant-sub-expressions-when-looping-over-arguments/64181 "2021-07-08T19:26:10Z")

</div>

Very commonly, I want to define some function mainfunc and then evaluate it many times in a loop where some of the arguments are constant during looping but others vary with each iteration. Here is an example of what I …

---

## [Multiplying by booleans faster than if/else](https://discourse.julialang.org/t/multiplying-by-booleans-faster-than-if-else/64117)

<div class="topic-metadata">

**Author:** [@PatrickMcFarlane](https://discourse.julialang.org/u/PatrickMcFarlane)\
**Replies:** 23\
**Last updated:** [July 8, 2021, 6:06pm UTC](https://discourse.julialang.org/t/multiplying-by-booleans-faster-than-if-else/64117 "2021-07-08T18:06:41Z")

</div>

I have been using @btime to check the speed of various little functions I’m working on that involve conditionals. I’ve found that multiplying by booleans instead of using if/else statements seems to be much faster. But…

---

## [No figures generated after deploying with Documenter](https://discourse.julialang.org/t/no-figures-generated-after-deploying-with-documenter/64242)

<div class="topic-metadata">

**Author:** [@RaulDurand](https://discourse.julialang.org/u/RaulDurand)\
**Replies:** 5\
**Last updated:** [July 8, 2021, 4:47pm UTC](https://discourse.julialang.org/t/no-figures-generated-after-deploying-with-documenter/64242 "2021-07-08T16:47:16Z")

</div>

I am working on the documentation of an unregistered package (GitHub - NumSoftware/Amaru.jl at gh-pages). I have several examples in the markdown that generate figures using PyPlot. Then I deploy using Actions. On the …

---

## [Combining @eval and @testset macros](https://discourse.julialang.org/t/combining-eval-and-testset-macros/64250)

<div class="topic-metadata">

**Author:** [@ajhynes7](https://discourse.julialang.org/u/ajhynes7)\
**Replies:** 2\
**Last updated:** [July 8, 2021, 4:40pm UTC](https://discourse.julialang.org/t/combining-eval-and-testset-macros/64250 "2021-07-08T16:40:14Z")

</div>

I’m trying to test two types that have similar properties. I want to perform the same set of tests on instances of the two types. If I was using Python, I would use the @pytest.mark.parametrize decorator to accomplish th…

---

## [SparseArray cannot store arbitrary type, but only types which support zero](https://discourse.julialang.org/t/sparsearray-cannot-store-arbitrary-type-but-only-types-which-support-zero/64283)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 6\
**Last updated:** [July 8, 2021, 4:10pm UTC](https://discourse.julialang.org/t/sparsearray-cannot-store-arbitrary-type-but-only-types-which-support-zero/64283 "2021-07-08T16:10:18Z")

</div>

I think this is a bug report to Julia, however I first would like to gather some thoughts. Concretely, I cannot map over a SparseVector of Functions. julia\> a = SparseVector(\[1, 2\]) 2-element SparseVector{Int64, Int64}…

---

## [Kernel density (w/ weights)](https://discourse.julialang.org/t/kernel-density-w-weights/64278)

<div class="topic-metadata">

**Author:** [@juliauser](https://discourse.julialang.org/u/juliauser)\
**Replies:** 1\
**Last updated:** [July 8, 2021, 3:00pm UTC](https://discourse.julialang.org/t/kernel-density-w-weights/64278 "2021-07-08T15:00:06Z")

</div>

Hello, I have a vector of variables x, and a vector of weights y (y sums to 1). How can plot the pdf of the vector x? Something like histogram(x,weights=y) but smoothed out.

---

## [How to pass/use \`julia\_args\` argument to \`Pkg.test()\`?](https://discourse.julialang.org/t/how-to-pass-use-julia-args-argument-to-pkg-test/64274)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 3\
**Last updated:** [July 8, 2021, 1:24pm UTC](https://discourse.julialang.org/t/how-to-pass-use-julia-args-argument-to-pkg-test/64274 "2021-07-08T13:24:36Z")

</div>

I’d like to pass some option(s) to my tests, in particular a flag (or something) that I can pass to include extra (but slow) tests. I can see (12. API Reference · Pkg.jl) that Pkg.test() has keyword arguments julia\_args …

---

## [Converting Pandas DataFrame to Julia DataFrame?](https://discourse.julialang.org/t/converting-pandas-dataframe-to-julia-dataframe/15356)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 19\
**Last updated:** [July 8, 2021, 1:21pm UTC](https://discourse.julialang.org/t/converting-pandas-dataframe-to-julia-dataframe/15356 "2021-07-08T13:21:31Z")

</div>

Pandas.jl is pretty nice. Is there an easy way to convert from Pandas DataFrame to Julia DataFrame? e.g. julia\> df = read\_csv("iris.csv") Unnamed: 0 Sepal.Length Sepal.Width Petal.Length Petal.Width Spec…

---

## [Compat bounds for indirect dependencies](https://discourse.julialang.org/t/compat-bounds-for-indirect-dependencies/64268)

<div class="topic-metadata">

**Author:** [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Replies:** 3\
**Last updated:** [July 8, 2021, 11:48am UTC](https://discourse.julialang.org/t/compat-bounds-for-indirect-dependencies/64268 "2021-07-08T11:48:04Z")

</div>

Sometimes, indirect dependencies of packages will introduce bugs such that they don’t work anymore with our packages. The \[compat\] section of Project.toml allows us to restrict the versions of direct dependencies. Is i…

---

## [Boxing of integer when looping vector over 512 index](https://discourse.julialang.org/t/boxing-of-integer-when-looping-vector-over-512-index/64259)

<div class="topic-metadata">

**Author:** [@dpinol](https://discourse.julialang.org/u/dpinol)\
**Replies:** 2\
**Last updated:** [July 8, 2021, 10:40am UTC](https://discourse.julialang.org/t/boxing-of-integer-when-looping-vector-over-512-index/64259 "2021-07-08T10:40:06Z")

</div>

Weird allocation that depends on array contents · Issue #36751 · JuliaLang/julia · GitHub & memory allocation increases unexpectedly in sparse getindex at a threshold · Issue #18051 · JuliaLang/julia · GitHub mention llv…

---

## ["Literate" leaves behind extraneous #](https://discourse.julialang.org/t/literate-leaves-behind-extraneous/44777)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 8\
**Last updated:** [July 8, 2021, 9:49am UTC](https://discourse.julialang.org/t/literate-leaves-behind-extraneous/44777 "2021-07-08T09:49:12Z")

</div>

I use “cells” in a Julia script. VS code can execute these cells with a single keystroke. The problem is that when I generate the markdown from the script with Literate, the cell markers (##) are interpreted as markdown…

---

## [How to use @\_\_FILE\_\_ and @\_\_LINE\_\_ correctly in my own macro?](https://discourse.julialang.org/t/how-to-use-file-and-line-correctly-in-my-own-macro/64256)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 4\
**Last updated:** [July 8, 2021, 8:36am UTC](https://discourse.julialang.org/t/how-to-use-file-and-line-correctly-in-my-own-macro/64256 "2021-07-08T08:36:00Z")

</div>

Hey all :slight\_smile: I’m writing my own logging package. I want to send strings to two places. function log(s::String, file, line) to\_log = "$(Dates.now(Dates.UTC)) in $file:$line\\n$s\\n" TrinityApi.informatio…

---

## [Suppress Stacktrace when a test fails](https://discourse.julialang.org/t/suppress-stacktrace-when-a-test-fails/19834)

<div class="topic-metadata">

**Author:** [@curious](https://discourse.julialang.org/u/curious)\
**Replies:** 6\
**Last updated:** [July 8, 2021, 4:36am UTC](https://discourse.julialang.org/t/suppress-stacktrace-when-a-test-fails/19834 "2021-07-08T04:36:31Z")

</div>

Is there a way to suppress Stacktrace output when a test fails when using @test macro? I just want to know which test failed and what the expected output was and what the actual output was. The @test macro provides this …

---

## [Why isn't this function type stable?](https://discourse.julialang.org/t/why-isnt-this-function-type-stable/64244)

<div class="topic-metadata">

**Author:** [@Arrigo\_Benedetti](https://discourse.julialang.org/u/Arrigo_Benedetti)\
**Replies:** 1\
**Last updated:** [July 8, 2021, 1:32am UTC](https://discourse.julialang.org/t/why-isnt-this-function-type-stable/64244 "2021-07-08T01:32:10Z")

</div>

Let’s consider the function: using Sobol function fun\_pdf(img1::Matrix{T}, n\_skip) where T \<: Real (nrows, ncols) = size(img1) indx = SobolSeq(\[0, 0\], \[ncols - 1, nrows - 1\]) indx = skip(indx, n\_skip) …

---

## [Addition/Subtraction operations on sparse arrays](https://discourse.julialang.org/t/addition-subtraction-operations-on-sparse-arrays/64241)

<div class="topic-metadata">

**Author:** [@bmit](https://discourse.julialang.org/u/bmit)\
**Replies:** 3\
**Last updated:** [July 7, 2021, 11:58pm UTC](https://discourse.julialang.org/t/addition-subtraction-operations-on-sparse-arrays/64241 "2021-07-07T23:58:33Z")

</div>

If I have a sparse array, is there a way to only broadcast operations onto the non-zero values in that array? I find myself needing this operation quite often. A broadcast will obviously perform the operation on every e…

---

## [Is it possible to create a struct instance without an explicit constructor?](https://discourse.julialang.org/t/is-it-possible-to-create-a-struct-instance-without-an-explicit-constructor/64243)

<div class="topic-metadata">

**Author:** [@Visipi](https://discourse.julialang.org/u/Visipi)\
**Replies:** 1\
**Last updated:** [July 7, 2021, 11:47pm UTC](https://discourse.julialang.org/t/is-it-possible-to-create-a-struct-instance-without-an-explicit-constructor/64243 "2021-07-07T23:47:13Z")

</div>

I have this problem where I’m given a DataType for a mutable struct and I have a lot of values corresponding to all the fields for this struct. Trouble is that these values might be out of order so I have no way of loadi…

---

## [How to start a new Julia session from script](https://discourse.julialang.org/t/how-to-start-a-new-julia-session-from-script/63848)

<div class="topic-metadata">

**Author:** [@Micah\_Mungal](https://discourse.julialang.org/u/Micah_Mungal)\
**Replies:** 27\
**Last updated:** [July 7, 2021, 11:46pm UTC](https://discourse.julialang.org/t/how-to-start-a-new-julia-session-from-script/63848 "2021-07-07T23:46:12Z")

</div>

I am currently working on solving a optimization problem using julia and gurobi. I need to solve this optimizaton problem around 500 times (each time uses a different set of data). However, instead of running a julia scr…

---

## [Scatter plot vector of (Static)vectors with Plots](https://discourse.julialang.org/t/scatter-plot-vector-of-static-vectors-with-plots/64232)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 5\
**Last updated:** [July 7, 2021, 10:15pm UTC](https://discourse.julialang.org/t/scatter-plot-vector-of-static-vectors-with-plots/64232 "2021-07-07T22:15:33Z")

</div>

Is there a more direct way to plot a vector of vectors as a scatter plot with plots? julia\> using Plots, StaticArrays julia\> points = rand(SVector{2,Float64},10); julia\> scatter(\[x\[1\] for x in points\],\[ x\[2\] for x in …

---

## [\`collect\` iterator in reverse](https://discourse.julialang.org/t/collect-iterator-in-reverse/64225)

<div class="topic-metadata">

**Author:** [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Replies:** 11\
**Last updated:** [July 7, 2021, 11:15pm UTC](https://discourse.julialang.org/t/collect-iterator-in-reverse/64225 "2021-07-07T23:15:07Z")

</div>

Is there a generic function for collecting an iterator in reverse? I’m looking for a more efficient version of the following: itr = (i for i = 1:10) # for example vec = reverse(collect(itr)) I don’t think the solution …

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

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