# General Usage

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

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

**Page:** 534

---

## [Sparse matrix coefficient computation with ForwardDiff and LoopVectorization](https://discourse.julialang.org/t/sparse-matrix-coefficient-computation-with-forwarddiff-and-loopvectorization/69928)

<div class="topic-metadata">

**Author:** [@Gravlax](https://discourse.julialang.org/u/Gravlax)\
**Replies:** 0\
**Last updated:** [October 17, 2021, 12:20pm UTC](https://discourse.julialang.org/t/sparse-matrix-coefficient-computation-with-forwarddiff-and-loopvectorization/69928 "2021-10-17T12:20:20Z")

</div>

Hi everyone, I am trying to write a code that computes both the residual and sparse matrix coefficients for multi-dimensional non-linear Poisson-type problems. The idea is that information about the stencil and boundary…

---

## [How to do custom allocators](https://discourse.julialang.org/t/how-to-do-custom-allocators/69112)

<div class="topic-metadata">

**Author:** [@goerch](https://discourse.julialang.org/u/goerch)\
**Replies:** 22\
**Last updated:** [October 17, 2021, 11:50am UTC](https://discourse.julialang.org/t/how-to-do-custom-allocators/69112 "2021-10-17T11:50:20Z")

</div>

In the everlasting quest to reduce allocations I stumbled about problems with node based data structures. Constructing a test case based on DataStructures.jl’s singly linked list I tried to eliminate allocations in const…

---

## [Usage of vector of arrays](https://discourse.julialang.org/t/usage-of-vector-of-arrays/69882)

<div class="topic-metadata">

**Author:** [@Gravlax](https://discourse.julialang.org/u/Gravlax)\
**Replies:** 4\
**Last updated:** [October 17, 2021, 6:35am UTC](https://discourse.julialang.org/t/usage-of-vector-of-arrays/69882 "2021-10-17T06:35:28Z")

</div>

Hi everyone, I am trying to manipulate data using a vector of arrays. The aim is to store the connectivity of a Poisson finite difference stencil using vector of arrays, rather than storing them into independent vectors…

---

## [Creating functions exposed to the global scope dynamically?](https://discourse.julialang.org/t/creating-functions-exposed-to-the-global-scope-dynamically/69874)

<div class="topic-metadata">

**Author:** [@Chris\_Green](https://discourse.julialang.org/u/Chris_Green)\
**Replies:** 4\
**Last updated:** [October 16, 2021, 9:23pm UTC](https://discourse.julialang.org/t/creating-functions-exposed-to-the-global-scope-dynamically/69874 "2021-10-16T21:23:26Z")

</div>

I wanted to use julia+IJulia to easily add a notebook interface/REPL to my large C++ program. I wanted it to be really easy and non-intrusive on the c++ side, and in particular to add no dependencies to the c++ build pr…

---

## [Advice on Python co-existing with Julia](https://discourse.julialang.org/t/advice-on-python-co-existing-with-julia/69908)

<div class="topic-metadata">

**Author:** [@jim-michael](https://discourse.julialang.org/u/jim-michael)\
**Replies:** 2\
**Last updated:** [October 17, 2021, 1:42am UTC](https://discourse.julialang.org/t/advice-on-python-co-existing-with-julia/69908 "2021-10-17T01:42:54Z")

</div>

For those who use local installations of Julia and Python, especially on a Mac Book, I am looking for advice regarding the best installation options for Python. I’ve used Anaconda for several years, and use JupyterLab f…

---

## [Broadcasting on Vector{SubString{String}} does not work in Julia 1.7.0 rc1?](https://discourse.julialang.org/t/broadcasting-on-vector-substring-string-does-not-work-in-julia-1-7-0-rc1/69913)

<div class="topic-metadata">

**Author:** [@pszufe](https://discourse.julialang.org/u/pszufe)\
**Replies:** 12\
**Last updated:** [October 16, 2021, 10:27pm UTC](https://discourse.julialang.org/t/broadcasting-on-vector-substring-string-does-not-work-in-julia-1-7-0-rc1/69913 "2021-10-16T22:27:15Z")

</div>

I use Julia 1.7.0rc1 and it seems that broadcasting works for Vector{String} and does not work on Vector{SubString{String}}. Is this something intended or I run into a bug? For Vector{String} all works as expected: jul…

---

## [Embarrassingly parallel multi-threading doesn't scale](https://discourse.julialang.org/t/embarrassingly-parallel-multi-threading-doesnt-scale/69843)

<div class="topic-metadata">

**Author:** [@Arnau](https://discourse.julialang.org/u/Arnau)\
**Replies:** 17\
**Last updated:** [October 16, 2021, 10:09pm UTC](https://discourse.julialang.org/t/embarrassingly-parallel-multi-threading-doesnt-scale/69843 "2021-10-16T22:09:12Z")

</div>

A simple embarrassingly parallel code, with 4 threads, only halves in speed. Here is a super simplified case :~$ julia -t4 julia\> N = Int(1e8) 100000000 julia\> @elapsed for i in 1:N rand(100) end 46.246…

---

## [How to Efficiently Index PyArrays?](https://discourse.julialang.org/t/how-to-efficiently-index-pyarrays/69785)

<div class="topic-metadata">

**Author:** [@rewindturtle](https://discourse.julialang.org/u/rewindturtle)\
**Replies:** 25\
**Last updated:** [October 16, 2021, 7:59pm UTC](https://discourse.julialang.org/t/how-to-efficiently-index-pyarrays/69785 "2021-10-16T19:59:01Z")

</div>

I have been trying to rewrite a python script I wrote a while back in julia to increase its performance. The python script used a package called gym-retro which ran a videogame emulator that the script could directly int…

---

## [Scoping in nested functions - Why am I not getting an error?](https://discourse.julialang.org/t/scoping-in-nested-functions-why-am-i-not-getting-an-error/39354)

<div class="topic-metadata">

**Author:** [@StevenWhitaker](https://discourse.julialang.org/u/StevenWhitaker)\
**Replies:** 6\
**Last updated:** [October 16, 2021, 6:41pm UTC](https://discourse.julialang.org/t/scoping-in-nested-functions-why-am-i-not-getting-an-error/39354 "2021-10-16T18:41:33Z")

</div>

I am confused about the behavior of scoping when using a nested function. I am using Julia 1.4.1. MWE: function main() function doit() A = ones(Int, 2) # \<-- I expected this to introduce a new A within the…

---

## [Are there prewritten rulesets for SymbolicUtils.jl?](https://discourse.julialang.org/t/are-there-prewritten-rulesets-for-symbolicutils-jl/69890)

<div class="topic-metadata">

**Author:** [@jedforrest](https://discourse.julialang.org/u/jedforrest)\
**Replies:** 1\
**Last updated:** [October 16, 2021, 1:07pm UTC](https://discourse.julialang.org/t/are-there-prewritten-rulesets-for-symbolicutils-jl/69890 "2021-10-16T13:07:36Z")

</div>

The way I understand SymbolicUtils.jl is that it comes with a basic set of rewriting rules for symbolic expressions, and any other rulesets you want you must provide yourself. For example, you will need to write your own…

---

## [MATLAB.jl question: where to add the Matlab application path?](https://discourse.julialang.org/t/matlab-jl-question-where-to-add-the-matlab-application-path/69872)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 2\
**Last updated:** [October 16, 2021, 9:20am UTC](https://discourse.julialang.org/t/matlab-jl-question-where-to-add-the-matlab-application-path/69872 "2021-10-16T09:20:33Z")

</div>

I have a Macbook Pro and want to install MATLAB.jl. The instructions say this: You may add the following command to .profile:export MATLAB\_HOME=/Applications/MATLAB\_R2012b.app . Should I do this through Julia or my Te…

---

## [Would anyone please help me with this Boolean related error?](https://discourse.julialang.org/t/would-anyone-please-help-me-with-this-boolean-related-error/69856)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 6\
**Last updated:** [October 16, 2021, 3:25am UTC](https://discourse.julialang.org/t/would-anyone-please-help-me-with-this-boolean-related-error/69856 "2021-10-16T03:25:52Z")

</div>

Anyone knows why I keep getting an error for the below simple function: A = \[15, 16, -30\]; B = \[12, 35, 38\]; Ind = A .\> -20 && B .\>= 15 Here is the error: TypeError: non-boolean (BitVector) used in boolean context St…

---

## [Could we make first-class support for packages that are "just files" and not repositories?](https://discourse.julialang.org/t/could-we-make-first-class-support-for-packages-that-are-just-files-and-not-repositories/36931)

<div class="topic-metadata">

**Author:** [@tuckermcclure](https://discourse.julialang.org/u/tuckermcclure)\
**Replies:** 21\
**Last updated:** [October 16, 2021, 2:37am UTC](https://discourse.julialang.org/t/could-we-make-first-class-support-for-packages-that-are-just-files-and-not-repositories/36931 "2021-10-16T02:37:03Z")

</div>

I keep circling around the same issue from a variety of different vantage points, and I think that having first-class support for local, unregistered packages (just local files, not repositories) would solve a lot of pro…

---

## [Do Bool values separated by semi-colon and comma different from each other?](https://discourse.julialang.org/t/do-bool-values-separated-by-semi-colon-and-comma-different-from-each-other/69864)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 2\
**Last updated:** [October 16, 2021, 12:23am UTC](https://discourse.julialang.org/t/do-bool-values-separated-by-semi-colon-and-comma-different-from-each-other/69864 "2021-10-16T00:23:06Z")

</div>

I have a matrix T0 (size: 1334269 x 35). It was created by this: T0 = hcat(A, B, C, D, E, ...); # A, B, C, D, E, .. are all single-column data. My goal is to only get the rows meeting these requirements: Ind = map(A, …

---

## [Hyperlink to Pluto notebook](https://discourse.julialang.org/t/hyperlink-to-pluto-notebook/69818)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 8\
**Last updated:** [October 15, 2021, 11:42pm UTC](https://discourse.julialang.org/t/hyperlink-to-pluto-notebook/69818 "2021-10-15T23:42:14Z")

</div>

Hi all, In Jupyter, it is possible to link one notebook to another using relative paths. However, this does not appear to work with Pluto. Here is what I tried: md""" # \[my link\]("my\_notebook.jl") """ The linked page …

---

## [Clarification of Abstract Type and Specialized Code](https://discourse.julialang.org/t/clarification-of-abstract-type-and-specialized-code/67289)

<div class="topic-metadata">

**Author:** [@anon60034542](https://discourse.julialang.org/u/anon60034542)\
**Replies:** 6\
**Last updated:** [October 15, 2021, 6:06pm UTC](https://discourse.julialang.org/t/clarification-of-abstract-type-and-specialized-code/67289 "2021-10-15T18:06:05Z")

</div>

In the performance tips, under Annotate values taken from untyped locations, it says: Type annotation will not enhance (and can actually hinder) performance if the type is abstract, or constructed at run-time. This is …

---

## [Why does the heatmap() function in Plots.jl flip data?](https://discourse.julialang.org/t/why-does-the-heatmap-function-in-plots-jl-flip-data/69844)

<div class="topic-metadata">

**Author:** [@thompsonmj](https://discourse.julialang.org/u/thompsonmj)\
**Replies:** 1\
**Last updated:** [October 15, 2021, 5:35pm UTC](https://discourse.julialang.org/t/why-does-the-heatmap-function-in-plots-jl-flip-data/69844 "2021-10-15T17:35:52Z")

</div>

julia\> A = \[1 2 3;4 5 6;7 8 9\] 3×3 Matrix{Int64}: 1 2 3 4 5 6 7 8 9 julia\> heatmap(A)

---

## [How to declare type/size of tuple in a struct?](https://discourse.julialang.org/t/how-to-declare-type-size-of-tuple-in-a-struct/69833)

<div class="topic-metadata">

**Author:** [@curious](https://discourse.julialang.org/u/curious)\
**Replies:** 3\
**Last updated:** [October 15, 2021, 4:23pm UTC](https://discourse.julialang.org/t/how-to-declare-type-size-of-tuple-in-a-struct/69833 "2021-10-15T16:23:48Z")

</div>

Hi, I have a struct such as below. I want to know how to declare the type of the field somedict. The keys of somedict will be tuples. Each key will be a tuple of two tuples, first one of length size1 and second one of …

---

## [Why are tuple literals better for constant-propagation than array literals?](https://discourse.julialang.org/t/why-are-tuple-literals-better-for-constant-propagation-than-array-literals/69805)

<div class="topic-metadata">

**Author:** [@jules](https://discourse.julialang.org/u/jules)\
**Replies:** 12\
**Last updated:** [October 15, 2021, 2:35pm UTC](https://discourse.julialang.org/t/why-are-tuple-literals-better-for-constant-propagation-than-array-literals/69805 "2021-10-15T14:35:13Z")

</div>

I need functions that check if a symbol references a specific type of struct field, and this is supposed to compile away through constant propagation. Now, I also had this heuristic that I shouldn’t use huge Tuples beca…

---

## [Parameterizing type by integer value using "where"](https://discourse.julialang.org/t/parameterizing-type-by-integer-value-using-where/69821)

<div class="topic-metadata">

**Author:** [@John\_Gibson](https://discourse.julialang.org/u/John_Gibson)\
**Replies:** 9\
**Last updated:** [October 15, 2021, 1:40pm UTC](https://discourse.julialang.org/t/parameterizing-type-by-integer-value-using-where/69821 "2021-10-15T13:40:08Z")

</div>

This simple GaloisField type is parameterized by the modulus p and the integer type T. It works fine, but note that the test on the type of p buried within an inner constructor. using Primes # Type definition: GaloisFi…

---

## [Dispatching functions and keyword usage](https://discourse.julialang.org/t/dispatching-functions-and-keyword-usage/69825)

<div class="topic-metadata">

**Author:** [@mrVeng](https://discourse.julialang.org/u/mrVeng)\
**Replies:** 2\
**Last updated:** [October 15, 2021, 1:37pm UTC](https://discourse.julialang.org/t/dispatching-functions-and-keyword-usage/69825 "2021-10-15T13:37:28Z")

</div>

Hi there, Is there a way to dispatch on a function and still being able to call eventual keywords? I tried to dispatch a function, but could not call non-default keywords anymore afterwards. MWE: function testfn(a::In…

---

## [Vscode fails with "Starting the Julia Language Server"](https://discourse.julialang.org/t/vscode-fails-with-starting-the-julia-language-server/69816)

<div class="topic-metadata">

**Author:** [@Amirrezz94](https://discourse.julialang.org/u/Amirrezz94)\
**Replies:** 0\
**Last updated:** [October 15, 2021, 10:51am UTC](https://discourse.julialang.org/t/vscode-fails-with-starting-the-julia-language-server/69816 "2021-10-15T10:51:44Z")

</div>

Hi, I’m using Julia 1.6.2 on ubuntu 20.04.3 with vscode 1.61.1. I have a problem with starting Julia in vscode. Every time I try to run Julia, I get these errors in vscode (attached as screenshot). Also, it takes severa…

---

## [Compact vs Scattered Pinning](https://discourse.julialang.org/t/compact-vs-scattered-pinning/69722)

<div class="topic-metadata">

**Author:** [@tkf](https://discourse.julialang.org/u/tkf)\
**Replies:** 3\
**Last updated:** [October 15, 2021, 7:06am UTC](https://discourse.julialang.org/t/compact-vs-scattered-pinning/69722 "2021-10-15T07:06:47Z")

</div>

@carstenbauer Cool package! I want to de derail this further so let me open a new topic :slight\_smile: When I first looked at it, the performance advantage of scattered pinning was puzzling for me. Intuitively, you wou…

---

## [AWS.jl - global\_aws\_config can't find ARN](https://discourse.julialang.org/t/aws-jl-global-aws-config-cant-find-arn/69673)

<div class="topic-metadata">

**Author:** [@Billpete002](https://discourse.julialang.org/u/Billpete002)\
**Replies:** 1\
**Last updated:** [October 15, 2021, 7:04am UTC](https://discourse.julialang.org/t/aws-jl-global-aws-config-cant-find-arn/69673 "2021-10-15T07:04:46Z")

</div>

I have an issue with global\_aws\_config. It works perfectly fine in SageMaker Notebook: aws = global\_aws\_config(; region="us-west-2") AWSConfig(arn:aws:iam::123456789:instance-profile/BaseNotebookInstanceEc2InstanceRole…

---

## [How to use Manifests for a clean environment for reproducibility](https://discourse.julialang.org/t/how-to-use-manifests-for-a-clean-environment-for-reproducibility/69755)

<div class="topic-metadata">

**Author:** [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Replies:** 6\
**Last updated:** [October 15, 2021, 6:10am UTC](https://discourse.julialang.org/t/how-to-use-manifests-for-a-clean-environment-for-reproducibility/69755 "2021-10-15T06:10:58Z")

</div>

Sloppy use of language on my part. My understanding is that the Manifest.toml file is the file you want to keep for reproducibility, as it lists all the packages used, while the Project.toml file is where you specify yo…

---

## [Pointer modification with CxxWrap.jl](https://discourse.julialang.org/t/pointer-modification-with-cxxwrap-jl/69802)

<div class="topic-metadata">

**Author:** [@chkwon](https://discourse.julialang.org/u/chkwon)\
**Replies:** 1\
**Last updated:** [October 15, 2021, 4:48am UTC](https://discourse.julialang.org/t/pointer-modification-with-cxxwrap-jl/69802 "2021-10-15T04:48:19Z")

</div>

Using CxxWrap.jl, I am trying to send a pointer to struct to C++ functions, which will modify the values inside. I did small experiments. C++ side: #include "jlcxx/jlcxx.hpp" struct Point{ float x, y; }; Point\* mov…

---

## [Creating a custom data type for CxxWrap](https://discourse.julialang.org/t/creating-a-custom-data-type-for-cxxwrap/69740)

<div class="topic-metadata">

**Author:** [@chkwon](https://discourse.julialang.org/u/chkwon)\
**Replies:** 2\
**Last updated:** [October 15, 2021, 4:00am UTC](https://discourse.julialang.org/t/creating-a-custom-data-type-for-cxxwrap/69740 "2021-10-15T04:00:15Z")

</div>

I’m trying to write a wrapper for a C++ library using CxxWrap.jl. In C++, there are types like typedef struct { int MyType; int \*List; } MyRecord typedef MyRecord \*MyPointer; typedef MyPointer \*MyList; To create …

---

## [Indexing error?](https://discourse.julialang.org/t/indexing-error/69786)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 6\
**Last updated:** [October 15, 2021, 2:50am UTC](https://discourse.julialang.org/t/indexing-error/69786 "2021-10-15T02:50:49Z")

</div>

X, Y, and E are longitude, latitude and elevation, respectively, on the same 86400 x 43200 grid. My goal is to reduce their resolution by 10 folder. Why does the below code keep throwing out the below error? my script: m…

---

## [Questions related to saving multiple arrays in one variable](https://discourse.julialang.org/t/questions-related-to-saving-multiple-arrays-in-one-variable/69759)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 4\
**Last updated:** [October 14, 2021, 9:14pm UTC](https://discourse.julialang.org/t/questions-related-to-saving-multiple-arrays-in-one-variable/69759 "2021-10-14T21:14:50Z")

</div>

I have a variable “fi”, which stores a global grid of elevations (units: meters), and another variable “DL” that stores 26 depth levels. Below are my scripts for creating some land/sea masks: function f1(fi, DL) A =…

---

## [SOA transform](https://discourse.julialang.org/t/soa-transform/69769)

<div class="topic-metadata">

**Author:** [@goerch](https://discourse.julialang.org/u/goerch)\
**Replies:** 8\
**Last updated:** [October 14, 2021, 8:22pm UTC](https://discourse.julialang.org/t/soa-transform/69769 "2021-10-14T20:22:14Z")

</div>

I’m playing with a SOA transform (AoS and SoA - Wikipedia) via StructArrays.jl. My code: using StructArrays function test1() n = 10 v = Vector{Tuple{Int, Int}}(undef, n) s = 0 for i in 1:n v\[i\] …

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

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