# General Usage

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

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

**Page:** 530

---

## [How to inverse a Boolean vector?](https://discourse.julialang.org/t/how-to-inverse-a-boolean-vector/70309)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 1\
**Last updated:** [October 24, 2021, 11:06pm UTC](https://discourse.julialang.org/t/how-to-inverse-a-boolean-vector/70309 "2021-10-24T23:06:32Z")

</div>

I have an Index that is generated as below: Flag = \["A", "B", "C"\] Ind = cmp.(Flag, "A") The results: 3-element Vector{Int64}: 0 1 1 However, what I need is to find where the "A"s are, so I want the inverse values…

---

## [Pluto: a conflict with HTTP](https://discourse.julialang.org/t/pluto-a-conflict-with-http/69039)

<div class="topic-metadata">

**Author:** [@VivMendes](https://discourse.julialang.org/u/VivMendes)\
**Replies:** 8\
**Last updated:** [October 24, 2021, 9:43pm UTC](https://discourse.julialang.org/t/pluto-a-conflict-with-http/69039 "2021-10-24T21:43:40Z")

</div>

Hi, I have a series of Pluto notebooks that were working without any problems at all. I have already made a static HTML file of each one of them in the past. I have just updated my Julia environment, and now I have a p…

---

## [Gradient evaluation with ForwardDiff and LoopVectorization](https://discourse.julialang.org/t/gradient-evaluation-with-forwarddiff-and-loopvectorization/70262)

<div class="topic-metadata">

**Author:** [@Gravlax](https://discourse.julialang.org/u/Gravlax)\
**Replies:** 2\
**Last updated:** [October 24, 2021, 6:47pm UTC](https://discourse.julialang.org/t/gradient-evaluation-with-forwarddiff-and-loopvectorization/70262 "2021-10-24T18:47:14Z")

</div>

Hi everyone, I am trying use the ForwardDiff.gradient! function to compute the in-place gradient of a function F with regard to 3 parameters. F has ncx entries and the function has 3 parameters per entry. I explicitly …

---

## [Random warning messages with Catalyst](https://discourse.julialang.org/t/random-warning-messages-with-catalyst/66289)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 11\
**Last updated:** [October 24, 2021, 5:22pm UTC](https://discourse.julialang.org/t/random-warning-messages-with-catalyst/66289 "2021-10-24T17:22:49Z")

</div>

I keep getting, sort of randomly, these warning messages when using Catalyst. I have erased and reinstalled all my Julia packages and the error persisted. Any idea what can it be? WARNING: Method definition Type##kw(Any…

---

## [How to line break a very long 1-row string array?](https://discourse.julialang.org/t/how-to-line-break-a-very-long-1-row-string-array/70287)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 10\
**Last updated:** [October 24, 2021, 5:08pm UTC](https://discourse.julialang.org/t/how-to-line-break-a-very-long-1-row-string-array/70287 "2021-10-24T17:08:18Z")

</div>

I have a unit row like the below. You see “” because some of the units are none. For example, there is no unit for Year. row2 = \["" "" "" "umol/kg" "" "" "kg/m3" "decimal degrees"\]; In reality it is much longer, so I …

---

## [After making some changes, I can no longer import Pkg.CSV](https://discourse.julialang.org/t/after-making-some-changes-i-can-no-longer-import-pkg-csv/70267)

<div class="topic-metadata">

**Author:** [@CBrauer](https://discourse.julialang.org/u/CBrauer)\
**Replies:** 10\
**Last updated:** [October 24, 2021, 4:34pm UTC](https://discourse.julialang.org/t/after-making-some-changes-i-can-no-longer-import-pkg-csv/70267 "2021-10-24T16:34:16Z")

</div>

Hey, My notebook was working fine, but after some changes, I’m now getting an error. Please help me to fix this problem. The first few cells of my Jupyter Notebook are shown below: Charles

---

## [3d bars makie, colors and meshes](https://discourse.julialang.org/t/3d-bars-makie-colors-and-meshes/70283)

<div class="topic-metadata">

**Author:** [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Replies:** 9\
**Last updated:** [October 24, 2021, 3:33pm UTC](https://discourse.julialang.org/t/3d-bars-makie-colors-and-meshes/70283 "2021-10-24T15:33:09Z")

</div>

Probably, the following could be done without to much effort, but I don’t seem to find the right way to do it :smiley: A way to merge all Rect3 meshes? Plotting one by one becomes really slow after a while. Add a color…

---

## [How to add a unit row to a CSV file through dataframe?](https://discourse.julialang.org/t/how-to-add-a-unit-row-to-a-csv-file-through-dataframe/70241)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 7\
**Last updated:** [October 24, 2021, 11:49am UTC](https://discourse.julialang.org/t/how-to-add-a-unit-row-to-a-csv-file-through-dataframe/70241 "2021-10-24T11:49:12Z")

</div>

I need to write my matrix into a CSV file, due to the large size (~200 MB), it will be very hard to open it using Excel later on and manually add a 2nd row for the unit information. Is there a better way to add such a r…

---

## [Count instances of type](https://discourse.julialang.org/t/count-instances-of-type/70279)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 2\
**Last updated:** [October 24, 2021, 6:03am UTC](https://discourse.julialang.org/t/count-instances-of-type/70279 "2021-10-24T06:03:45Z")

</div>

Is it possible to ask Julia how many instances of an arbitrary type T are alive?

---

## [Memory usage of Zygote in list comprehensions](https://discourse.julialang.org/t/memory-usage-of-zygote-in-list-comprehensions/70278)

<div class="topic-metadata">

**Author:** [@tictaccat](https://discourse.julialang.org/u/tictaccat)\
**Replies:** 4\
**Last updated:** [October 24, 2021, 3:06am UTC](https://discourse.julialang.org/t/memory-usage-of-zygote-in-list-comprehensions/70278 "2021-10-24T03:06:08Z")

</div>

Hi! I’ve been running into memory/runtime issues with Zygote when using list comprehensions. I’d like to ask a simple question. Suppose x is an array of length n. When Zygote differentiates backwards through the followin…

---

## [Replacing some elements of an array with corresponding elements from another array](https://discourse.julialang.org/t/replacing-some-elements-of-an-array-with-corresponding-elements-from-another-array/70248)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 17\
**Last updated:** [October 23, 2021, 10:57pm UTC](https://discourse.julialang.org/t/replacing-some-elements-of-an-array-with-corresponding-elements-from-another-array/70248 "2021-10-23T22:57:21Z")

</div>

My goal is to replace any elements in array A that are either NaN or \<0 with the corresponding elements in Array B. Below is my code: A = \[1, 2.1, -5, 6, -3, 8, NaN\]; B = \[8, 8.2, 8, 8, 8, 8, 8\]; C = replace!(x -\> (x\<…

---

## [How to intersect a Cartesian Index with a regular index?](https://discourse.julialang.org/t/how-to-intersect-a-cartesian-index-with-a-regular-index/70270)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 6\
**Last updated:** [October 23, 2021, 9:31pm UTC](https://discourse.julialang.org/t/how-to-intersect-a-cartesian-index-with-a-regular-index/70270 "2021-10-23T21:31:36Z")

</div>

For example, I have an Index1 that is generated from this: A = \[NaN, 2.1, NaN, -3, 8, 65, NaN\]; f1(A) = \[idx for idx in CartesianIndices(A) if @inbounds (isnan(A\[idx\])) \]; Index1 = f1(A); Results of Index1: Index1 = 3…

---

## [Row index in a dataframe](https://discourse.julialang.org/t/row-index-in-a-dataframe/70265)

<div class="topic-metadata">

**Author:** [@corny85](https://discourse.julialang.org/u/corny85)\
**Replies:** 4\
**Last updated:** [October 23, 2021, 5:55pm UTC](https://discourse.julialang.org/t/row-index-in-a-dataframe/70265 "2021-10-23T17:55:09Z")

</div>

Hello, I have a dataframe that i sorted in order to get the maximum (of values in a column). Now, i want to get the index corresponding to this maximum in the initial dataframe. I’ve tried a lot of things with rownumb…

---

## [Performance deviations when summing an integer matrix](https://discourse.julialang.org/t/performance-deviations-when-summing-an-integer-matrix/70260)

<div class="topic-metadata">

**Author:** [@goerch](https://discourse.julialang.org/u/goerch)\
**Replies:** 3\
**Last updated:** [October 23, 2021, 5:29pm UTC](https://discourse.julialang.org/t/performance-deviations-when-summing-an-integer-matrix/70260 "2021-10-23T17:29:07Z")

</div>

The following program using Tables using CSV using BenchmarkTools function process1(a::Matrix{Int}) count = 0 for i in 1:size(a, 1) for j in 1:size(a, 2) count += a\[i, j\] end end…

---

## [What's going on with exp() and --math-mode=fast?](https://discourse.julialang.org/t/whats-going-on-with-exp-and-math-mode-fast/64619)

<div class="topic-metadata">

**Author:** [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Replies:** 29\
**Last updated:** [October 23, 2021, 5:13pm UTC](https://discourse.julialang.org/t/whats-going-on-with-exp-and-math-mode-fast/64619 "2021-10-23T17:13:28Z")

</div>

I was surprised to see results that are significantly different (by much more than I would except when using normal ffast-math optimizations) when running julia with --math-mode=fast. It seems like a very rough approxim…

---

## [Find indices meeting multiple criteria searching from multiple arrays](https://discourse.julialang.org/t/find-indices-meeting-multiple-criteria-searching-from-multiple-arrays/51228)

<div class="topic-metadata">

**Author:** [@dalarev](https://discourse.julialang.org/u/dalarev)\
**Replies:** 6\
**Last updated:** [October 23, 2021, 3:49pm UTC](https://discourse.julialang.org/t/find-indices-meeting-multiple-criteria-searching-from-multiple-arrays/51228 "2021-10-23T15:49:59Z")

</div>

How do I find the indices that meet both A \> 0 and B \> 0? In this MWE, I want the answer CartesianIndex(3,3), since that’s the only location that satisfies both conditions. julia\> A = repeat(-1:1',1,3) 3×3 Array{Int64,…

---

## [Cumulative sum on rows of a dataframe](https://discourse.julialang.org/t/cumulative-sum-on-rows-of-a-dataframe/70242)

<div class="topic-metadata">

**Author:** [@corny85](https://discourse.julialang.org/u/corny85)\
**Replies:** 3\
**Last updated:** [October 23, 2021, 2:35pm UTC](https://discourse.julialang.org/t/cumulative-sum-on-rows-of-a-dataframe/70242 "2021-10-23T14:35:10Z")

</div>

I am a beginner in Julia… I am trying to add a new column with cumulative values in regards with some other columns function weighted\_sum(input\_df::DataFrame, weight::Array{Int64,1}, start\_col=2) somme\_df = deepcop…

---

## [Variable interpolation in string within expression](https://discourse.julialang.org/t/variable-interpolation-in-string-within-expression/70258)

<div class="topic-metadata">

**Author:** [@disberd](https://discourse.julialang.org/u/disberd)\
**Replies:** 2\
**Last updated:** [October 23, 2021, 9:58am UTC](https://discourse.julialang.org/t/variable-interpolation-in-string-within-expression/70258 "2021-10-23T09:58:38Z")

</div>

Hi there, I am experimenting a bit with macros and wanted to know wheter there is a way to interpolate a variable (that is local to the macro) value inside a string within an expression returned by the macro. a MWE is …

---

## [When will a vector of structs be contiguous in memory?](https://discourse.julialang.org/t/when-will-a-vector-of-structs-be-contiguous-in-memory/70181)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 8\
**Last updated:** [October 23, 2021, 4:29am UTC](https://discourse.julialang.org/t/when-will-a-vector-of-structs-be-contiguous-in-memory/70181 "2021-10-23T04:29:38Z")

</div>

Checking if a vector of structs is contiguous in memory gives some tips for how to check, but would like to know the general pattern. My specific use case is a sort of nested dictionary. I have an iterator of key-value …

---

## [Reading a vector string file](https://discourse.julialang.org/t/reading-a-vector-string-file/70247)

<div class="topic-metadata">

**Author:** [@Peter-Jolly](https://discourse.julialang.org/u/Peter-Jolly)\
**Replies:** 4\
**Last updated:** [October 23, 2021, 4:26am UTC](https://discourse.julialang.org/t/reading-a-vector-string-file/70247 "2021-10-23T04:26:27Z")

</div>

Hi I am trying to do a very simple operation dealing with strings (normally I work with numerical data so not too familiar with strings). I want to read in a list of names from a file called Name\_List.txt (each name on o…

---

## [Precompilation, \_\_init\_\_, and eval](https://discourse.julialang.org/t/precompilation-init-and-eval/70188)

<div class="topic-metadata">

**Author:** [@Kurt\_Franke](https://discourse.julialang.org/u/Kurt_Franke)\
**Replies:** 3\
**Last updated:** [October 23, 2021, 3:38am UTC](https://discourse.julialang.org/t/precompilation-init-and-eval/70188 "2021-10-23T03:38:19Z")

</div>

I have some formulas that are loaded from text configuration files. These are used in other places besides my Julia program so I don’t have any control over the format. They are in the form of an expression using the sin…

---

## [How to test functions that operate on abstract types](https://discourse.julialang.org/t/how-to-test-functions-that-operate-on-abstract-types/70246)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 16\
**Last updated:** [October 23, 2021, 1:51am UTC](https://discourse.julialang.org/t/how-to-test-functions-that-operate-on-abstract-types/70246 "2021-10-23T01:51:11Z")

</div>

I have a function f(x::Vector). It’s tested on Vectors and seems to do okay. I looked at the code and think it should also work for all AbstractVectors, but I don’t know how to test this. In general, are there any princi…

---

## [Basic datastructures benchmark](https://discourse.julialang.org/t/basic-datastructures-benchmark/69753)

<div class="topic-metadata">

**Author:** [@goerch](https://discourse.julialang.org/u/goerch)\
**Replies:** 1\
**Last updated:** [October 22, 2021, 9:22pm UTC](https://discourse.julialang.org/t/basic-datastructures-benchmark/69753 "2021-10-22T21:22:41Z")

</div>

With the help of all you here I finished my evaluation of allocators for basic data structures with some at least for me surprising results. Thank you very much again! Please see https://github.com/goerch/Allocators.jl.…

---

## [How to read string arrays out of a MAT file?](https://discourse.julialang.org/t/how-to-read-string-arrays-out-of-a-mat-file/70234)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 0\
**Last updated:** [October 22, 2021, 6:41pm UTC](https://discourse.julialang.org/t/how-to-read-string-arrays-out-of-a-mat-file/70234 "2021-10-22T18:41:55Z")

</div>

I have two string arrays stored in a MAT file named test3.mat. They can be read out easily within Matlab, but I’m having big trouble reading them out in Julia. Below is my code: using MAT F1 = matopen("test3.mat"); a =…

---

## [How can I define functions inside of functions in a performant way?](https://discourse.julialang.org/t/how-can-i-define-functions-inside-of-functions-in-a-performant-way/70213)

<div class="topic-metadata">

**Author:** [@giancarloantonucci](https://discourse.julialang.org/u/giancarloantonucci)\
**Replies:** 9\
**Last updated:** [October 22, 2021, 3:52pm UTC](https://discourse.julialang.org/t/how-can-i-define-functions-inside-of-functions-in-a-performant-way/70213 "2021-10-22T15:52:04Z")

</div>

I want to define functions f1 and f2 (to be inputted inside a struct S) from another function f, defined at global scope, using another auxiliary function fun: mutable struct S f1::Function f2::Function end fun…

---

## [Segmentation Fault Error using Julia LibCurl Wrapper](https://discourse.julialang.org/t/segmentation-fault-error-using-julia-libcurl-wrapper/31201)

<div class="topic-metadata">

**Author:** [@rkapurbh](https://discourse.julialang.org/u/rkapurbh)\
**Replies:** 1\
**Last updated:** [October 22, 2021, 3:41pm UTC](https://discourse.julialang.org/t/segmentation-fault-error-using-julia-libcurl-wrapper/31201 "2021-10-22T15:41:07Z")

</div>

Running the Following Code with Julia LibCurl.jl curl\_header\_list = Cstring\[\] for header in keys(headers) value = headers\[header\] item =Cstring(pointer("$header: $value")) push!(curl\_header…

---

## [Debugging a script to replace NaN or -999 values with missing values](https://discourse.julialang.org/t/debugging-a-script-to-replace-nan-or-999-values-with-missing-values/70214)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 6\
**Last updated:** [October 22, 2021, 2:15pm UTC](https://discourse.julialang.org/t/debugging-a-script-to-replace-nan-or-999-values-with-missing-values/70214 "2021-10-22T14:15:17Z")

</div>

I’m trying to write a program to replace all NaN values or -999 values in my matrix B with missing values (write down nothing) before I use Dataframe to put them into CSV files). Below is my code: B = \[-0 0 1; NaN 0.2 …

---

## [Float32 performance fluctuating over time](https://discourse.julialang.org/t/float32-performance-fluctuating-over-time/70206)

<div class="topic-metadata">

**Author:** [@Chiil](https://discourse.julialang.org/u/Chiil)\
**Replies:** 1\
**Last updated:** [October 22, 2021, 1:20pm UTC](https://discourse.julialang.org/t/float32-performance-fluctuating-over-time/70206 "2021-10-22T13:20:10Z")

</div>

I have coded a CFD code in Julia that has Float32 performance that increases as the simulation progresses, while the Float64 performance is constant in time. My suspicion is that is has to do with underflow in case of th…

---

## [Difference in floating-point results for sqrt vs exponentiation on nightly (possible regression?)](https://discourse.julialang.org/t/difference-in-floating-point-results-for-sqrt-vs-exponentiation-on-nightly-possible-regression/70207)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 1\
**Last updated:** [October 22, 2021, 12:09pm UTC](https://discourse.julialang.org/t/difference-in-floating-point-results-for-sqrt-vs-exponentiation-on-nightly-possible-regression/70207 "2021-10-22T12:09:44Z")

</div>

This used to work on previous versions of Julia, but fails on nightly Julia 1.6 and 1.7rc1 julia\> sqrt(1.5) == 1.5^0.5 true nightly julia\> sqrt(1.5) == 1.5^0.5 false I realize that floating-point results are not gua…

---

## [Multiple Dispatch based on the number of function's arguments that is by itself an argument](https://discourse.julialang.org/t/multiple-dispatch-based-on-the-number-of-functions-arguments-that-is-by-itself-an-argument/52945)

<div class="topic-metadata">

**Author:** [@tiago](https://discourse.julialang.org/u/tiago)\
**Replies:** 8\
**Last updated:** [October 22, 2021, 10:15am UTC](https://discourse.julialang.org/t/multiple-dispatch-based-on-the-number-of-functions-arguments-that-is-by-itself-an-argument/52945 "2021-10-22T10:15:14Z")

</div>

Hello, I’m currently doing a numerical solver for a certain type of PDEs (Neural Field Equations) and these equations accepts functions as inputs (and parameters as well). The equation in study is given by: where I, K…

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

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