# General Usage

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

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

**Page:** 752

---

## [Fast in.(x, Ref(y))](https://discourse.julialang.org/t/fast-in-x-ref-y/39701)

<div class="topic-metadata">

**Author:** [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Replies:** 4\
**Last updated:** [May 18, 2020, 3:26pm UTC](https://discourse.julialang.org/t/fast-in-x-ref-y/39701 "2020-05-18T15:26:50Z")

</div>

I often want to filter a large Dataframe by checking whether the values of a column are elements of another large vector. Naively broadcasting in across the first vector is very slow: julia\> n = 10^5; @time in.(rand(1:…

---

## [Best practices for implicit function parameters](https://discourse.julialang.org/t/best-practices-for-implicit-function-parameters/39699)

<div class="topic-metadata">

**Author:** [@hessammehr](https://discourse.julialang.org/u/hessammehr)\
**Replies:** 1\
**Last updated:** [May 18, 2020, 2:55pm UTC](https://discourse.julialang.org/t/best-practices-for-implicit-function-parameters/39699 "2020-05-18T14:55:04Z")

</div>

Often packages require passing callbacks with a fixed signature f(x) where my implementation of f will need to refer to an auxiliary variable in the surrounding context called a. Given how the use of global variables is …

---

## [Help make my ideal gas simulation ideally fast](https://discourse.julialang.org/t/help-make-my-ideal-gas-simulation-ideally-fast/39141)

<div class="topic-metadata">

**Author:** [@jgreener64](https://discourse.julialang.org/u/jgreener64)\
**Replies:** 13\
**Last updated:** [May 18, 2020, 11:10am UTC](https://discourse.julialang.org/t/help-make-my-ideal-gas-simulation-ideally-fast/39141 "2020-05-18T11:10:04Z")

</div>

I have been meaning to speed up some of the non-bonded force calculation in Molly.jl and I had a play with it today, but found I hit a ceiling. I have extracted a simplistic molecular dynamics simulation of a Lennard Jo…

---

## [What should be an argument of this function?](https://discourse.julialang.org/t/what-should-be-an-argument-of-this-function/39660)

<div class="topic-metadata">

**Author:** [@wiktorkujawa](https://discourse.julialang.org/u/wiktorkujawa)\
**Replies:** 3\
**Last updated:** [May 18, 2020, 9:13am UTC](https://discourse.julialang.org/t/what-should-be-an-argument-of-this-function/39660 "2020-05-18T09:13:15Z")

</div>

Here’e the code error. julia\> name(15) ERROR: MethodError: no method matching name(::Int64) Closest candidates are: name(::DataType) I tried also this: julia\> name(typeof(Int)) ERROR: MethodError: Cannot \`convert\` a…

---

## [Is there a way to reference an arbitrary array-like object as 0-based array?](https://discourse.julialang.org/t/is-there-a-way-to-reference-an-arbitrary-array-like-object-as-0-based-array/39680)

<div class="topic-metadata">

**Author:** [@astrojhgu](https://discourse.julialang.org/u/astrojhgu)\
**Replies:** 1\
**Last updated:** [May 18, 2020, 7:52am UTC](https://discourse.julialang.org/t/is-there-a-way-to-reference-an-arbitrary-array-like-object-as-0-based-array/39680 "2020-05-18T07:52:16Z")

</div>

There is such a customized indexing array in Julia, but its type is different from the built-in array type. It is annoying to handle different types so is it possible to (at least when writing a function argument list) …

---

## [How to implement a plugin system in Julia](https://discourse.julialang.org/t/how-to-implement-a-plugin-system-in-julia/39591)

<div class="topic-metadata">

**Author:** [@tisztamo](https://discourse.julialang.org/u/tisztamo)\
**Replies:** 4\
**Last updated:** [May 17, 2020, 7:27pm UTC](https://discourse.julialang.org/t/how-to-implement-a-plugin-system-in-julia/39591 "2020-05-17T19:27:55Z")

</div>

TL;DR: Does multiple dispatch allow for a better alternative to plugins? If no, then a code generation gimmick is needed. I am working on a framework and I would like to move most of the code into plugins. A plugin alte…

---

## [Adding environment to library LOAD\_PATH](https://discourse.julialang.org/t/adding-environment-to-library-load-path/39597)

<div class="topic-metadata">

**Author:** [@yoh-meyers](https://discourse.julialang.org/u/yoh-meyers)\
**Replies:** 6\
**Last updated:** [May 17, 2020, 12:55pm UTC](https://discourse.julialang.org/t/adding-environment-to-library-load-path/39597 "2020-05-17T12:55:44Z")

</div>

Hello, I am possibly trying something impossible by design of Julia. Am trying to load a dependency of a project into a library that project is using. By trying so, I get following error: ┌ Warning: Package Dance doe…

---

## [How do I speed this up?](https://discourse.julialang.org/t/how-do-i-speed-this-up/39577)

<div class="topic-metadata">

**Author:** [@scotts](https://discourse.julialang.org/u/scotts)\
**Replies:** 6\
**Last updated:** [May 17, 2020, 11:22am UTC](https://discourse.julialang.org/t/how-do-i-speed-this-up/39577 "2020-05-17T11:22:57Z")

</div>

I’ve translated some code from a Matlab script into Julia, but I’m finding it running much slower… The culprit loop is: for i::Int16 = 1 : n\_acts n\_ages::Int16 = m\["max\_age"\]\[i\] if n\_ages \> 1 idx…

---

## [Fast floating point quantisation / rounding](https://discourse.julialang.org/t/fast-floating-point-quantisation-rounding/39439)

<div class="topic-metadata">

**Author:** [@jackf](https://discourse.julialang.org/u/jackf)\
**Replies:** 3\
**Last updated:** [May 17, 2020, 8:51am UTC](https://discourse.julialang.org/t/fast-floating-point-quantisation-rounding/39439 "2020-05-17T08:51:07Z")

</div>

I have a large number of Float32s in an array. I want to apply the transformation f(x) = round(Int16, x \* a + b, RoundToZero) where a and b are constants. I also need to apply the inverse transform (but multiplication by…

---

## [Potential memory leakage in function definition using multiple threads in linux?](https://discourse.julialang.org/t/potential-memory-leakage-in-function-definition-using-multiple-threads-in-linux/39613)

<div class="topic-metadata">

**Author:** [@samuel\_okon](https://discourse.julialang.org/u/samuel_okon)\
**Replies:** 0\
**Last updated:** [May 17, 2020, 3:15am UTC](https://discourse.julialang.org/t/potential-memory-leakage-in-function-definition-using-multiple-threads-in-linux/39613 "2020-05-17T03:15:39Z")

</div>

julia\> versioninfo() Julia Version 1.4.1 Commit 381693d3df\* (2020-04-14 17:20 UTC) Platform Info: OS: Linux (x86\_64-pc-linux-gnu) CPU: Intel(R) Core(TM) i3-5005U CPU @ 2.00GHz WORD\_SIZE: 64 LIBM: libopenlibm LL…

---

## [Error in compiling DifferentialEquantions on chromebook](https://discourse.julialang.org/t/error-in-compiling-differentialequantions-on-chromebook/38834)

<div class="topic-metadata">

**Author:** [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Replies:** 32\
**Last updated:** [May 17, 2020, 6:35am UTC](https://discourse.julialang.org/t/error-in-compiling-differentialequantions-on-chromebook/38834 "2020-05-17T06:35:07Z")

</div>

I upgraded to julia 1.4.1 in chromebook, but I got a problem with DifferentialEquations: julia\> Pkg.add("DifferentialEquations") Resolving package versions... Updating \`~/.julia/environments/v1.4/Project.toml\` \[no…

---

## [Numerical instability of partial differential equations](https://discourse.julialang.org/t/numerical-instability-of-partial-differential-equations/39603)

<div class="topic-metadata">

**Author:** [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)\
**Replies:** 6\
**Last updated:** [May 17, 2020, 5:15am UTC](https://discourse.julialang.org/t/numerical-instability-of-partial-differential-equations/39603 "2020-05-17T05:15:40Z")

</div>

Probably I should have asked this on a mathematical forum, but since I will present julia code and there are a lot of experts in this forum, probably I can get better help here. I am trying to solve a differential equat…

---

## [Running macros with expression as an argument](https://discourse.julialang.org/t/running-macros-with-expression-as-an-argument/39584)

<div class="topic-metadata">

**Author:** [@wiktorkujawa](https://discourse.julialang.org/u/wiktorkujawa)\
**Replies:** 4\
**Last updated:** [May 16, 2020, 10:45pm UTC](https://discourse.julialang.org/t/running-macros-with-expression-as-an-argument/39584 "2020-05-16T22:45:36Z")

</div>

I’ve got errors on “local first\_parameter”. If I try to mess something without any sense, sometimes I get error at “local arg1” line. macro howToRunThis(fun::Expr) local first\_parameter = fun.args\[1\] local name = fi…

---

## [How to debug \`Pkg.build("....")\`?](https://discourse.julialang.org/t/how-to-debug-pkg-build/39601)

<div class="topic-metadata">

**Author:** [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Replies:** 0\
**Last updated:** [May 16, 2020, 9:47pm UTC](https://discourse.julialang.org/t/how-to-debug-pkg-build/39601 "2020-05-16T21:47:32Z")

</div>

I have some trouble building a package ArbNumberics.jl. (See here.) So I tried to use Debugger.jl to debug it by Using Debugger, Pkg @enter Pkg.build("ArbNumercis") 1|debug\> bp on error 1|debug\> c But this seems to ta…

---

## [Can the preexisting uuid for a package be calculated with Julia 1.4?](https://discourse.julialang.org/t/can-the-preexisting-uuid-for-a-package-be-calculated-with-julia-1-4/39573)

<div class="topic-metadata">

**Author:** [@wherrera](https://discourse.julialang.org/u/wherrera)\
**Replies:** 5\
**Last updated:** [May 16, 2020, 8:43pm UTC](https://discourse.julialang.org/t/can-the-preexisting-uuid-for-a-package-be-calculated-with-julia-1-4/39573 "2020-05-16T20:43:42Z")

</div>

It seems that in Julia 1.4 that Pkg.METADATA\_compatible\_uuid is dropped in favor of just creating a UUID randomly with UUIDs.uuid4(). However, when creating a Project.toml file for a package, we need to know the uuid t…

---

## [Why start domain-specific scientific projects as Packages?](https://discourse.julialang.org/t/why-start-domain-specific-scientific-projects-as-packages/34752)

<div class="topic-metadata">

**Author:** [@ElectronicTeaCup](https://discourse.julialang.org/u/ElectronicTeaCup)\
**Replies:** 16\
**Last updated:** [May 16, 2020, 6:28pm UTC](https://discourse.julialang.org/t/why-start-domain-specific-scientific-projects-as-packages/34752 "2020-05-16T18:28:23Z")

</div>

Hi everyone, I’ve been trying to establish a good workflow while using Julia (Coming over from MATLAB) for my doctoral work. I’m at the beginning so I have some time set things up. So far I’ve been quite comfortable wit…

---

## [Defining a function using the output of another function](https://discourse.julialang.org/t/defining-a-function-using-the-output-of-another-function/39589)

<div class="topic-metadata">

**Author:** [@Himanshu\_Chaudhary](https://discourse.julialang.org/u/Himanshu_Chaudhary)\
**Replies:** 1\
**Last updated:** [May 16, 2020, 4:00pm UTC](https://discourse.julialang.org/t/defining-a-function-using-the-output-of-another-function/39589 "2020-05-16T16:00:24Z")

</div>

I have a function that takes an array and returns its derivative. function dy(y, δx) N = length(y) dy = zeros(N) for j = 4:N-3 dy\[j\]=( 5\*(y\[j+1\] - y\[j-1\]) + 4\*(y\[j+2\] - y\[j-2\]) …

---

## [Is this a bug? \`\`Some(\[\]) != Some(\[\])\`\`](https://discourse.julialang.org/t/is-this-a-bug-some-some/39541)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 7\
**Last updated:** [May 16, 2020, 3:45pm UTC](https://discourse.julialang.org/t/is-this-a-bug-some-some/39541 "2020-05-16T15:45:42Z")

</div>

I know that there are a couple of open discussions about how to compare general structs by default. However for the concrete type Some, Some(\[\]) == Some(\[\]) should return true, shouldn’t it? But it returns false… Usi…

---

## [Deactivate REPL](https://discourse.julialang.org/t/deactivate-repl/39525)

<div class="topic-metadata">

**Author:** [@Diego](https://discourse.julialang.org/u/Diego)\
**Replies:** 2\
**Last updated:** [May 16, 2020, 2:29pm UTC](https://discourse.julialang.org/t/deactivate-repl/39525 "2020-05-16T14:29:06Z")

</div>

Team there is a library I load in a parallel execution process that prints something into REPL once succesfully loaded. The problem is that when I run 100 parallel process I get a pretty much unusable REPL. Is there a…

---

## [To factor or not to factor? Functions with small differences within loops](https://discourse.julialang.org/t/to-factor-or-not-to-factor-functions-with-small-differences-within-loops/39532)

<div class="topic-metadata">

**Author:** [@Dr.Merkwuedigliebe](https://discourse.julialang.org/u/Dr.Merkwuedigliebe)\
**Replies:** 4\
**Last updated:** [May 16, 2020, 1:25pm UTC](https://discourse.julialang.org/t/to-factor-or-not-to-factor-functions-with-small-differences-within-loops/39532 "2020-05-16T13:25:18Z")

</div>

I have a number of functions that perform updates on a number of large arrays in the same loop. Previously, I learned that this is often a good idea for performance. Now, I am facing another issue: I need a few variants …

---

## [Zygote gradients for functions with Array output](https://discourse.julialang.org/t/zygote-gradients-for-functions-with-array-output/39560)

<div class="topic-metadata">

**Author:** [@lwhitefox](https://discourse.julialang.org/u/lwhitefox)\
**Replies:** 2\
**Last updated:** [May 16, 2020, 1:17pm UTC](https://discourse.julialang.org/t/zygote-gradients-for-functions-with-array-output/39560 "2020-05-16T13:17:50Z")

</div>

My basic task is to get derivatives of a function that outputs an array, wrt each of the input parameters. Below I copy a toy MWE to try to illustrate the point. The desired result of taking a gradient will be the grad…

---

## [RData. UndefVarError: identifier not defined](https://discourse.julialang.org/t/rdata-undefvarerror-identifier-not-defined/39276)

<div class="topic-metadata">

**Author:** [@marinooss](https://discourse.julialang.org/u/marinooss)\
**Replies:** 2\
**Last updated:** [May 16, 2020, 1:02pm UTC](https://discourse.julialang.org/t/rdata-undefvarerror-identifier-not-defined/39276 "2020-05-16T13:02:50Z")

</div>

load(“working\_data//hospital\_demand\_other\_jl.RData”) got the error: UndefVarError: identifier not defined Also, when loading the package RData I got: WARNING: could not import DataFrames.identifier into RData How to…

---

## [Best Practice for Lookup Table Definition](https://discourse.julialang.org/t/best-practice-for-lookup-table-definition/39543)

<div class="topic-metadata">

**Author:** [@forever\_learning](https://discourse.julialang.org/u/forever_learning)\
**Replies:** 3\
**Last updated:** [May 16, 2020, 8:53am UTC](https://discourse.julialang.org/t/best-practice-for-lookup-table-definition/39543 "2020-05-16T08:53:58Z")

</div>

Hello, I am looking for some guidance on what the idiomatic way to define a small database of objects/materials might be. For example, this might pertain to a small set of materials and their associated material propert…

---

## [@distributed @sync @async](https://discourse.julialang.org/t/distributed-sync-async/39504)

<div class="topic-metadata">

**Author:** [@Jing\_Zhang](https://discourse.julialang.org/u/Jing_Zhang)\
**Replies:** 5\
**Last updated:** [May 16, 2020, 8:05am UTC](https://discourse.julialang.org/t/distributed-sync-async/39504 "2020-05-16T08:05:59Z")

</div>

Dear Julia peers, I got three questions regarding @distributed @sync @async, as follows. I am parallel running 5 layers of for loops using 5 @distributed for. However, from the output, I found some operations within t…

---

## [Revise error stack trace](https://discourse.julialang.org/t/revise-error-stack-trace/39557)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 3\
**Last updated:** [May 16, 2020, 6:58am UTC](https://discourse.julialang.org/t/revise-error-stack-trace/39557 "2020-05-16T06:58:24Z")

</div>

My error stack traces are impossible to read. It’s a major pain point and a huge waste of time. Besides the fact that everything is dumped on screen, the line throwing the error is actually lost so I have to blindly debu…

---

## [Unexpected response to syntax error in function definition](https://discourse.julialang.org/t/unexpected-response-to-syntax-error-in-function-definition/39548)

<div class="topic-metadata">

**Author:** [@portig](https://discourse.julialang.org/u/portig)\
**Replies:** 3\
**Last updated:** [May 16, 2020, 6:55am UTC](https://discourse.julialang.org/t/unexpected-response-to-syntax-error-in-function-definition/39548 "2020-05-16T06:55:28Z")

</div>

Here is a REPL session demonstrating the issue. The function definition contains an error, but Julia’s response is puzzling and not helpful. -\> function ff(a; b::Int64=0.5) println(a) println(b) end…

---

## [Matrix multiplication - inconsistent behaviour](https://discourse.julialang.org/t/matrix-multiplication-inconsistent-behaviour/36640)

<div class="topic-metadata">

**Author:** [@compleat](https://discourse.julialang.org/u/compleat)\
**Replies:** 50\
**Last updated:** [May 16, 2020, 6:06am UTC](https://discourse.julialang.org/t/matrix-multiplication-inconsistent-behaviour/36640 "2020-05-16T06:06:08Z")

</div>

If I multiply a 1 by m matrix by an m by 1 matrix, that should give a number. Unfortunately, not in Julia. Consider below: julia\> mat1=randn(3,3); mat2=randn(3,2); julia\> mat1\*mat2 3×2 Array{Float64,2}: 1.55168 …

---

## [Reducing allocations for repeatedly generating MvNormal distributions](https://discourse.julialang.org/t/reducing-allocations-for-repeatedly-generating-mvnormal-distributions/39483)

<div class="topic-metadata">

**Author:** [@ArnoStrouwen](https://discourse.julialang.org/u/ArnoStrouwen)\
**Replies:** 2\
**Last updated:** [May 16, 2020, 2:25am UTC](https://discourse.julialang.org/t/reducing-allocations-for-repeatedly-generating-mvnormal-distributions/39483 "2020-05-16T02:25:25Z")

</div>

I have to repeatedly generate few random numbers from many different bivariate normal distributions. I want to do this with as few allocations as possible. A simplified example of my code: using Distributions using Rand…

---

## [Explanation of .julia/packages/\* directory](https://discourse.julialang.org/t/explanation-of-julia-packages-directory/39562)

<div class="topic-metadata">

**Author:** [@joemiller](https://discourse.julialang.org/u/joemiller)\
**Replies:** 2\
**Last updated:** [May 16, 2020, 1:30am UTC](https://discourse.julialang.org/t/explanation-of-julia-packages-directory/39562 "2020-05-16T01:30:03Z")

</div>

I’m trying to install Julia and a bunch of packages on an edge node in a cluster without internet access and ended up exploring the ~/.julia/packages directory a little and am curious about the following. $ pwd /Users/m…

---

## [Reinterpret packed data which is already in memory?](https://discourse.julialang.org/t/reinterpret-packed-data-which-is-already-in-memory/39549)

<div class="topic-metadata">

**Author:** [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Replies:** 3\
**Last updated:** [May 15, 2020, 8:09pm UTC](https://discourse.julialang.org/t/reinterpret-packed-data-which-is-already-in-memory/39549 "2020-05-15T20:09:03Z")

</div>

I have a quite trivial question. I have read large arrays of bytes from different source into a single array (sometimes 2e9 bytes and more) and now I need to make it pretty for the user and thought utilising reinterpret …

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

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