# General Usage

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

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

**Page:** 855

---

## [Precision–agnostic function with powered mathematical constants generated from symbolic SymPy expression](https://discourse.julialang.org/t/precision-agnostic-function-with-powered-mathematical-constants-generated-from-symbolic-sympy-expression/25592)

<div class="topic-metadata">

**Author:** [@tikej](https://discourse.julialang.org/u/tikej)\
**Replies:** 5\
**Last updated:** [June 26, 2019, 5:29pm UTC](https://discourse.julialang.org/t/precision-agnostic-function-with-powered-mathematical-constants-generated-from-symbolic-sympy-expression/25592 "2019-06-26T17:29:18Z")

</div>

Hello Julia users, I use Mathematica to generate analytic expressions for some quite complicated integrals I calculate. In Mathematica I generate tables of indexes and symbolic expression e.g. {{-1, -1, -1, -1, -1, -1…

---

## [Fast logsumexp](https://discourse.julialang.org/t/fast-logsumexp/22827)

<div class="topic-metadata">

**Author:** [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Replies:** 14\
**Last updated:** [June 26, 2019, 3:21pm UTC](https://discourse.julialang.org/t/fast-logsumexp/22827 "2019-06-26T15:21:46Z")

</div>

We recently held a competition among the students in a Julia course we are teaching. The goal of the competition was to profile and optimize a provided particle-filter simulation. After all the obvious things were taken …

---

## [Is there a tool to automatically detect type piracy?](https://discourse.julialang.org/t/is-there-a-tool-to-automatically-detect-type-piracy/25721)

<div class="topic-metadata">

**Author:** [@Diego\_Javier\_Zea](https://discourse.julialang.org/u/Diego_Javier_Zea)\
**Replies:** 2\
**Last updated:** [June 26, 2019, 2:40pm UTC](https://discourse.julialang.org/t/is-there-a-tool-to-automatically-detect-type-piracy/25721 "2019-06-26T14:40:57Z")

</div>

Hi, I think that I read here that someone has written a small script to detect type piracy, but I can not find it. Thanks in advance, Best,

---

## [Error in variable define](https://discourse.julialang.org/t/error-in-variable-define/25717)

<div class="topic-metadata">

**Author:** [@ahmedbulbul52](https://discourse.julialang.org/u/ahmedbulbul52)\
**Replies:** 5\
**Last updated:** [June 26, 2019, 12:52pm UTC](https://discourse.julialang.org/t/error-in-variable-define/25717 "2019-06-26T12:52:14Z")

</div>

ERROR: UndefVarError: view not defined in partboost at /home//Desktop/test.jl:75 in findpartition at /home/Desktop/test.jl:200 Kindly suggest how to solve this problem, I’m new in this programming.

---

## [Julia and Concurrency](https://discourse.julialang.org/t/julia-and-concurrency/25556)

<div class="topic-metadata">

**Author:** [@fraxx001](https://discourse.julialang.org/u/fraxx001)\
**Replies:** 6\
**Last updated:** [June 26, 2019, 9:42am UTC](https://discourse.julialang.org/t/julia-and-concurrency/25556 "2019-06-26T09:42:23Z")

</div>

Hi, iam a bit curious about the plans for concurrency in Julia. As far as I understand the documentation, there is no real and easy support for Multithreading atm. The Task API provides an Interface for batch execution …

---

## [Loading a module outside \`Main\` module](https://discourse.julialang.org/t/loading-a-module-outside-main-module/15282)

<div class="topic-metadata">

**Author:** [@ahmetumutdurmus](https://discourse.julialang.org/u/ahmetumutdurmus)\
**Replies:** 5\
**Last updated:** [June 26, 2019, 7:36am UTC](https://discourse.julialang.org/t/loading-a-module-outside-main-module/15282 "2019-06-26T07:36:25Z")

</div>

Hi, I am currently trying to create a module and load it back again for further use yet having trouble in doing so. Consider the trivial example: module MyModule export x, y x() = "x" y() = "y" p() = "p" end using …

---

## [Surprised that broadcast does not use views?](https://discourse.julialang.org/t/surprised-that-broadcast-does-not-use-views/25662)

<div class="topic-metadata">

**Author:** [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Replies:** 8\
**Last updated:** [June 26, 2019, 7:35am UTC](https://discourse.julialang.org/t/surprised-that-broadcast-does-not-use-views/25662 "2019-06-26T07:35:44Z")

</div>

I am using a simple broadcast expression, and getting a surprising (to me) result depending on whether I use views or not. #setup a = rand(UInt64, 1000, 1000) b = rand(UInt64, 1000, 1000) c = rand(UInt64, 1000); Doing …

---

## [Weird colorbar](https://discourse.julialang.org/t/weird-colorbar/25670)

<div class="topic-metadata">

**Author:** [@wiktorkujawa](https://discourse.julialang.org/u/wiktorkujawa)\
**Replies:** 0\
**Last updated:** [June 25, 2019, 10:56pm UTC](https://discourse.julialang.org/t/weird-colorbar/25670 "2019-06-25T22:56:14Z")

</div>

I generated some plots and wanted to add colorbar to them and it partially works. My code to generate this bar in CImGui is: low=colorant"navyblue"; medium=colorant"limegreen"; high=colorant"yellow"; barImage=Array{R…

---

## [Dealing with images in PDF display from Weave.jl](https://discourse.julialang.org/t/dealing-with-images-in-pdf-display-from-weave-jl/25419)

<div class="topic-metadata">

**Author:** [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Replies:** 2\
**Last updated:** [June 26, 2019, 5:41am UTC](https://discourse.julialang.org/t/dealing-with-images-in-pdf-display-from-weave-jl/25419 "2019-06-26T05:41:18Z")

</div>

I’m using Weave.jl to write up a report using .jmd format. I need to include some images that I’ve already generated, so I included them in my markdown as I normally would: !\[a descriptive caption\](one pair random data.…

---

## [Dispatching on the result of unwrap\_unionall seems weird?](https://discourse.julialang.org/t/dispatching-on-the-result-of-unwrap-unionall-seems-weird/25677)

<div class="topic-metadata">

**Author:** [@marius311](https://discourse.julialang.org/u/marius311)\
**Replies:** 0\
**Last updated:** [June 26, 2019, 5:31am UTC](https://discourse.julialang.org/t/dispatching-on-the-result-of-unwrap-unionall-seems-weird/25677 "2019-06-26T05:31:22Z")

</div>

I’m pretty confused about the following dispatch behavior (Julia 1.1 and 1.2pre): julia\> foo(::Type{V}) where {V\<:Vector} = @isdefined(V) foo (generic function with 1 method) julia\> foo(Base.unwrap\_unionall(Vector)) fa…

---

## [Customize serialization on fetch from worker](https://discourse.julialang.org/t/customize-serialization-on-fetch-from-worker/25637)

<div class="topic-metadata">

**Author:** [@felipenoris](https://discourse.julialang.org/u/felipenoris)\
**Replies:** 6\
**Last updated:** [June 26, 2019, 2:01am UTC](https://discourse.julialang.org/t/customize-serialization-on-fetch-from-worker/25637 "2019-06-26T02:01:19Z")

</div>

I’m working on Mongoc.jl and I would like to make BSON documents serializable between julia workers. mutable struct BSON handle::Ptr{Cvoid} end Since Mongoc.BSON is just a wrapper for a C handle, if I just fetch th…

---

## [Error on incompatibility of matrix multiplications](https://discourse.julialang.org/t/error-on-incompatibility-of-matrix-multiplications/25486)

<div class="topic-metadata">

**Author:** [@ahmadreza-marandi](https://discourse.julialang.org/u/ahmadreza-marandi)\
**Replies:** 4\
**Last updated:** [June 25, 2019, 5:49pm UTC](https://discourse.julialang.org/t/error-on-incompatibility-of-matrix-multiplications/25486 "2019-06-25T17:49:22Z")

</div>

I wrote a code where I have many matrix multiplications. While running the code after opening Julia1.0.4, I got an error that the matrix sizes are incompatible. However, when I ran the code for the second time, the error…

---

## [IJulia & RISE presentation to PDF](https://discourse.julialang.org/t/ijulia-rise-presentation-to-pdf/25599)

<div class="topic-metadata">

**Author:** [@nantonel](https://discourse.julialang.org/u/nantonel)\
**Replies:** 3\
**Last updated:** [June 25, 2019, 4:12pm UTC](https://discourse.julialang.org/t/ijulia-rise-presentation-to-pdf/25599 "2019-06-25T16:12:30Z")

</div>

Hi all, does anyone know the procedure to generate a pdf out of a presentation made with RISE? I’m using Julia 1.1 and IJulia. I’ve installed rise with Conda.jl using the following command: Conda.add("rise") Looking …

---

## [Non-allocating loop over a set of structs](https://discourse.julialang.org/t/non-allocating-loop-over-a-set-of-structs/25643)

<div class="topic-metadata">

**Author:** [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Replies:** 13\
**Last updated:** [June 25, 2019, 3:22pm UTC](https://discourse.julialang.org/t/non-allocating-loop-over-a-set-of-structs/25643 "2019-06-25T15:22:42Z")

</div>

I have a set of structs and I want to loop over them. The following code shows two possible loops together with a sequential one by one access to structs: using BenchmarkTools struct Sample{T\<:AbstractFloat, F\<:Functio…

---

## [Question about JLD2 save/load of RData nested list](https://discourse.julialang.org/t/question-about-jld2-save-load-of-rdata-nested-list/25649)

<div class="topic-metadata">

**Author:** [@floswald](https://discourse.julialang.org/u/floswald)\
**Replies:** 3\
**Last updated:** [June 25, 2019, 1:14pm UTC](https://discourse.julialang.org/t/question-about-jld2-save-load-of-rdata-nested-list/25649 "2019-06-25T13:14:20Z")

</div>

suppose i have this module jldtest using DataFrames using JLD2, FileIO using RData using RCall # make some R data R""" rdata \<- list(a = runif(3), b = letters\[1:3\]) save(rdata, file = 'rr.RData') """ d = D…

---

## [Bounds in function arguments](https://discourse.julialang.org/t/bounds-in-function-arguments/25635)

<div class="topic-metadata">

**Author:** [@fipelle](https://discourse.julialang.org/u/fipelle)\
**Replies:** 4\
**Last updated:** [June 25, 2019, 10:55am UTC](https://discourse.julialang.org/t/bounds-in-function-arguments/25635 "2019-06-25T10:55:00Z")

</div>

Hi, I am writing down a set of functions, and I want to make sure that some of the arguments are bounded within some given values. For the sake of simplicity, say that I only have the following function: function my\_f…

---

## [PackageCompiler dependency issues (1.1; failing with dependency errors)](https://discourse.julialang.org/t/packagecompiler-dependency-issues-1-1-failing-with-dependency-errors/25578)

<div class="topic-metadata">

**Author:** [@srs](https://discourse.julialang.org/u/srs)\
**Replies:** 5\
**Last updated:** [June 24, 2019, 6:10pm UTC](https://discourse.julialang.org/t/packagecompiler-dependency-issues-1-1-failing-with-dependency-errors/25578 "2019-06-24T18:10:47Z")

</div>

What is the correct way to use PackageCompiler in 1.1? I naively tried: using PackageCompiler compile\_incremental(:Plots, force=false) And it keeps throwing dependency errors, like: “LoadError: … Package … is required…

---

## [Insert into postgres from array of dictionaries](https://discourse.julialang.org/t/insert-into-postgres-from-array-of-dictionaries/25563)

<div class="topic-metadata">

**Author:** [@jonjilla](https://discourse.julialang.org/u/jonjilla)\
**Replies:** 4\
**Last updated:** [June 25, 2019, 4:29am UTC](https://discourse.julialang.org/t/insert-into-postgres-from-array-of-dictionaries/25563 "2019-06-25T04:29:01Z")

</div>

I’m trying to use LibPQ to insert data into a Postgres database. I have the data as an array of dictionaries. I’m trying to figure out the correct way to insert this but the documentation and examples are a little bit …

---

## [Add and develope an unregistered local package](https://discourse.julialang.org/t/add-and-develope-an-unregistered-local-package/25632)

<div class="topic-metadata">

**Author:** [@Amin\_Yahyaabadi](https://discourse.julialang.org/u/Amin_Yahyaabadi)\
**Replies:** 1\
**Last updated:** [June 25, 2019, 3:22am UTC](https://discourse.julialang.org/t/add-and-develope-an-unregistered-local-package/25632 "2019-06-25T03:22:34Z")

</div>

I am trying to update a discontinued package called MatlabCompat.jl. First, I ran my forked FemtoCleaner locally to update the deprecated syntax, and here is the result: Updated MatlabCompat.jl. However, as I mentione…

---

## [How to dynamically add/build optional dependencies to improve user experience for our package?](https://discourse.julialang.org/t/how-to-dynamically-add-build-optional-dependencies-to-improve-user-experience-for-our-package/25605)

<div class="topic-metadata">

**Author:** [@PolarizedPoutine](https://discourse.julialang.org/u/PolarizedPoutine)\
**Replies:** 4\
**Last updated:** [June 25, 2019, 12:55am UTC](https://discourse.julialang.org/t/how-to-dynamically-add-build-optional-dependencies-to-improve-user-experience-for-our-package/25605 "2019-06-25T00:55:27Z")

</div>

I’m working on an ocean model with multiple large dependencies for optional features: CUDAnative.jl, CuArrays.jl for GPU support. HDF5.jl and NetCDF.jl if users want output in NetCDF format. MPI.jl for distributed supp…

---

## [Making a type of AbstractDict](https://discourse.julialang.org/t/making-a-type-of-abstractdict/25590)

<div class="topic-metadata">

**Author:** [@wherrera](https://discourse.julialang.org/u/wherrera)\
**Replies:** 1\
**Last updated:** [June 25, 2019, 12:00am UTC](https://discourse.julialang.org/t/making-a-type-of-abstractdict/25590 "2019-06-25T00:00:56Z")

</div>

I am trying to create a fixed dictionary with builtin restore to a default state: module BackedUpImmutable export BackedUpImmutableDict, getindex, setindex!, get!, get, restore! struct BackedUpImmutableDict{K, V} \<: …

---

## [Status of Registrator.jl (getting an invalid Project.toml error)](https://discourse.julialang.org/t/status-of-registrator-jl-getting-an-invalid-project-toml-error/25546)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 11\
**Last updated:** [June 24, 2019, 10:33pm UTC](https://discourse.julialang.org/t/status-of-registrator-jl-getting-an-invalid-project-toml-error/25546 "2019-06-24T22:33:44Z")

</div>

What is the status of package registration? I was under the impression that Registrator.jl works but I’m getting a “Project.toml is invalid” error when attempting to register the package. Leaving aside the unactionable …

---

## [How to adjust legend width to display the entire linestyle?](https://discourse.julialang.org/t/how-to-adjust-legend-width-to-display-the-entire-linestyle/25618)

<div class="topic-metadata">

**Author:** [@biona001](https://discourse.julialang.org/u/biona001)\
**Replies:** 0\
**Last updated:** [June 24, 2019, 6:09pm UTC](https://discourse.julialang.org/t/how-to-adjust-legend-width-to-display-the-entire-linestyle/25618 "2019-06-24T18:09:10Z")

</div>

In the legend below, the linestyle for Neg Bin (nd) and Matrix size is indistinguishable without color. Is there a way to increase the width of the displayed legend? Or is there another line style to choose from? Edit:…

---

## [Matrix (dense) vector (sparse) product improvement](https://discourse.julialang.org/t/matrix-dense-vector-sparse-product-improvement/25579)

<div class="topic-metadata">

**Author:** [@davidbp](https://discourse.julialang.org/u/davidbp)\
**Replies:** 7\
**Last updated:** [June 24, 2019, 4:28pm UTC](https://discourse.julialang.org/t/matrix-dense-vector-sparse-product-improvement/25579 "2019-06-24T16:28:15Z")

</div>

Products W'\*x\_sp seem very slow when W is a dense array and x\_sp is an sparse vector. Odly enough this does not happen if we don’t have and adjoint (W\*x\_sp is fast but W'\*x\_sp is very slow). Is there an easy way to o…

---

## [Gadfly for Julia version 1.1.1](https://discourse.julialang.org/t/gadfly-for-julia-version-1-1-1/25495)

<div class="topic-metadata">

**Author:** [@Julia\_coder](https://discourse.julialang.org/u/Julia_coder)\
**Replies:** 3\
**Last updated:** [June 24, 2019, 2:32pm UTC](https://discourse.julialang.org/t/gadfly-for-julia-version-1-1-1/25495 "2019-06-24T14:32:53Z")

</div>

Is Gadfly be available for Julia version 1.1.1? I have tried various ways of adding it (including pkg"add Gadfly#master", Pkg.clone(“Gadfly”), pkg"dev Gadfly") without success. With the master copy, I receive an error st…

---

## [Does using ccall(...) in a module prevent its precompilation?](https://discourse.julialang.org/t/does-using-ccall-in-a-module-prevent-its-precompilation/22546)

<div class="topic-metadata">

**Author:** [@RonK](https://discourse.julialang.org/u/RonK)\
**Replies:** 7\
**Last updated:** [June 24, 2019, 2:07pm UTC](https://discourse.julialang.org/t/does-using-ccall-in-a-module-prevent-its-precompilation/22546 "2019-06-24T14:07:55Z")

</div>

I’m getting constant warnings for one module among many: ┌ Warning: Module my\_module\_1 with build ID 54547777901434 is missing from the cache. │ This may mean my\_module\_1 \[top-level\] does not support precompilation but…

---

## [Registrator.jl says looking up of tree hash failed?](https://discourse.julialang.org/t/registrator-jl-says-looking-up-of-tree-hash-failed/25583)

<div class="topic-metadata">

**Author:** [@floswald](https://discourse.julialang.org/u/floswald)\
**Replies:** 3\
**Last updated:** [June 24, 2019, 8:23am UTC](https://discourse.julialang.org/t/registrator-jl-says-looking-up-of-tree-hash-failed/25583 "2019-06-24T08:23:07Z")

</div>

i tried to register my package https://github.com/floswald/MomentOpt.jl/releases/tag/v1.4.0 it says ERROR: Looking up the tree hash failed. what does that mean?

---

## [How to dispatch method based on input function argument type](https://discourse.julialang.org/t/how-to-dispatch-method-based-on-input-function-argument-type/25582)

<div class="topic-metadata">

**Author:** [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Replies:** 2\
**Last updated:** [June 24, 2019, 7:32am UTC](https://discourse.julialang.org/t/how-to-dispatch-method-based-on-input-function-argument-type/25582 "2019-06-24T07:32:25Z")

</div>

I know there is FunctionWrapper.jl but is it possible to use some design pattern to workaround this without letting user write the wrapper themselves? e.g I’d like to dispatch the following function sample(f::Function{…

---

## [How to sort eigenvectors from lowest to highest corresponding eigenvalue?](https://discourse.julialang.org/t/how-to-sort-eigenvectors-from-lowest-to-highest-corresponding-eigenvalue/25586)

<div class="topic-metadata">

**Author:** [@fusion809](https://discourse.julialang.org/u/fusion809)\
**Replies:** 3\
**Last updated:** [June 24, 2019, 5:48am UTC](https://discourse.julialang.org/t/how-to-sort-eigenvectors-from-lowest-to-highest-corresponding-eigenvalue/25586 "2019-06-24T05:48:50Z")

</div>

I’m solving a Sturm-Liouville problem numerically, and in order to use the eigenvectors and eigenvalues I get out of it, it would be handy to be able to order the eigenvalues in order of ascending absolute value, and sim…

---

## [Interpolation in macro calls](https://discourse.julialang.org/t/interpolation-in-macro-calls/25530)

<div class="topic-metadata">

**Author:** [@cscherrer](https://discourse.julialang.org/u/cscherrer)\
**Replies:** 10\
**Last updated:** [June 23, 2019, 10:22pm UTC](https://discourse.julialang.org/t/interpolation-in-macro-calls/25530 "2019-06-23T22:22:49Z")

</div>

Now and again, I see macros that are able to interpolate their arguments. Here’s an example with BenchmarkTools: julia\> using BenchmarkTools julia\> ex = :(sin(3)) :(sin(3)) julia\> f(x) = @btime cos($x) f (generic func…

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

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