# General Usage

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

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

**Page:** 315

---

## [CxxWrap and finalizers for specific instances](https://discourse.julialang.org/t/cxxwrap-and-finalizers-for-specific-instances/96254)

<div class="topic-metadata">

**Author:** [@peremato](https://discourse.julialang.org/u/peremato)\
**Replies:** 0\
**Last updated:** [March 17, 2023, 5:06pm UTC](https://discourse.julialang.org/t/cxxwrap-and-finalizers-for-specific-instances/96254 "2023-03-17T17:06:02Z")

</div>

I am using CxxWrap.jl and need to relinquish ownership for some particular instances, but not all, which is transferred to some other objects. CxxWrap has the possibility to disable the finalizer by adding the argument f…

---

## [How to center the horizontal axis to the graph in Plots.jl](https://discourse.julialang.org/t/how-to-center-the-horizontal-axis-to-the-graph-in-plots-jl/96252)

<div class="topic-metadata">

**Author:** [@KZ-Spectra](https://discourse.julialang.org/u/KZ-Spectra)\
**Replies:** 2\
**Last updated:** [March 17, 2023, 4:29pm UTC](https://discourse.julialang.org/t/how-to-center-the-horizontal-axis-to-the-graph-in-plots-jl/96252 "2023-03-17T16:29:41Z")

</div>

using NonlinearSolve, LinearAlgebra, Plots N₂=14 g₂(u,p) = p\[1\]\*Tridiagonal(fill(1,N₂), fill(-2,N₂+1), fill(1,N₂))\*u - u.^3 - p\[2\]\*u probg₂ = NonlinearProblem{false}(g₂, \[0.1; fill(0.3, N₂-1); 0.1\], \[0.6, 1\]) solver₂…

---

## [Creating data bins with numeric labels with cut()](https://discourse.julialang.org/t/creating-data-bins-with-numeric-labels-with-cut/81281)

<div class="topic-metadata">

**Author:** [@DWSchulze](https://discourse.julialang.org/u/DWSchulze)\
**Replies:** 12\
**Last updated:** [March 17, 2023, 3:05pm UTC](https://discourse.julialang.org/t/creating-data-bins-with-numeric-labels-with-cut/81281 "2023-03-17T15:05:18Z")

</div>

This is Python code to bin data into bins with a numerical label: pd.cut(housing\["median\_income"\], bins=\[0., 1.5, 3.0, 4.5, 6., np.inf\], labels=\[1, 2, 3, 4, 5\]) I want to do this in Julia, but it seems that Julia’s cut…

---

## [Outlining paths with polygons](https://discourse.julialang.org/t/outlining-paths-with-polygons/96243)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 2\
**Last updated:** [March 17, 2023, 2:01pm UTC](https://discourse.julialang.org/t/outlining-paths-with-polygons/96243 "2023-03-17T14:01:21Z")

</div>

Hi all, I was wondering whether if Julia has packages with similar functionality to Shapely. Suppose I have a list of coordinates and want to define a path with a buffer, plot it and test whether specific points fall wi…

---

## [Strange memory allocations with structs containing functions](https://discourse.julialang.org/t/strange-memory-allocations-with-structs-containing-functions/96007)

<div class="topic-metadata">

**Author:** [@ocp](https://discourse.julialang.org/u/ocp)\
**Replies:** 6\
**Last updated:** [March 17, 2023, 12:23pm UTC](https://discourse.julialang.org/t/strange-memory-allocations-with-structs-containing-functions/96007 "2023-03-17T12:23:26Z")

</div>

I’m working on a piece of code that takes a struct containing a Function and then calls that function. However, I’m fighting allocation issues. Ideally, I would think that the ability to specify the function signature,…

---

## [Step Detection](https://discourse.julialang.org/t/step-detection/96217)

<div class="topic-metadata">

**Author:** [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Replies:** 10\
**Last updated:** [March 17, 2023, 9:16am UTC](https://discourse.julialang.org/t/step-detection/96217 "2023-03-17T09:16:44Z")

</div>

I would like to detect steps in a signal. I wonder, if a Julia package exists that can do this job. I found the Python package ruptures that does the job, but it has two shortcomings: It is slow It can not handle larg…

---

## [How to skip output for \`nothing\` during ternary evaluation in one-liner list comprehension?](https://discourse.julialang.org/t/how-to-skip-output-for-nothing-during-ternary-evaluation-in-one-liner-list-comprehension/96211)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 2\
**Last updated:** [March 16, 2023, 11:15pm UTC](https://discourse.julialang.org/t/how-to-skip-output-for-nothing-during-ternary-evaluation-in-one-liner-list-comprehension/96211 "2023-03-16T23:15:49Z")

</div>

Suppose I only want to know success but not failure in a statement like: julia\> \[i%2==1 && "even" for i in 1:10\] 10-element Vector{Any}: "even" false "even" false "even" false "even" false …

---

## [Error loading model parameters with BSON](https://discourse.julialang.org/t/error-loading-model-parameters-with-bson/96136)

<div class="topic-metadata">

**Author:** [@JuliaQ123](https://discourse.julialang.org/u/JuliaQ123)\
**Replies:** 1\
**Last updated:** [March 17, 2023, 8:17am UTC](https://discourse.julialang.org/t/error-loading-model-parameters-with-bson/96136 "2023-03-17T08:17:36Z")

</div>

I’m running into an error when trying to load saved model parameters using BSON. I am saving the model parameters with @save model\_path model\_params\_save and then trying to load them as per the examples with @load mod…

---

## [How to speed up the numerical integration with interpolation](https://discourse.julialang.org/t/how-to-speed-up-the-numerical-integration-with-interpolation/96223)

<div class="topic-metadata">

**Author:** [@J\_I](https://discourse.julialang.org/u/J_I)\
**Replies:** 7\
**Last updated:** [March 17, 2023, 7:40am UTC](https://discourse.julialang.org/t/how-to-speed-up-the-numerical-integration-with-interpolation/96223 "2023-03-17T07:40:41Z")

</div>

Hi, I have performance problem regarding numerical integration and interpolation. I want to perform numerical integration with interpolation like below. using Dierckx using QuadGK function test() x = 0:0.01:1000 …

---

## [In vscode, how to open julia's REPL on the current compute node and run code with ctrl+shift](https://discourse.julialang.org/t/in-vscode-how-to-open-julias-repl-on-the-current-compute-node-and-run-code-with-ctrl-shift/96113)

<div class="topic-metadata">

**Author:** [@Yanjj1](https://discourse.julialang.org/u/Yanjj1)\
**Replies:** 5\
**Last updated:** [March 17, 2023, 7:33am UTC](https://discourse.julialang.org/t/in-vscode-how-to-open-julias-repl-on-the-current-compute-node-and-run-code-with-ctrl-shift/96113 "2023-03-17T07:33:44Z")

</div>

In vscode, how to open julia’s REPL on the current compute node and run code with ctrl+shift

---

## [Is there a "gap" between acquire and try in the acquire-try-finally idiom?](https://discourse.julialang.org/t/is-there-a-gap-between-acquire-and-try-in-the-acquire-try-finally-idiom/96224)

<div class="topic-metadata">

**Author:** [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Replies:** 0\
**Last updated:** [March 17, 2023, 5:58am UTC](https://discourse.julialang.org/t/is-there-a-gap-between-acquire-and-try-in-the-acquire-try-finally-idiom/96224 "2023-03-17T05:58:11Z")

</div>

The prime motivation for finally clauses is to guarantee clean-up of resources like open files, locks, etc. For example, the Julia docs on finally clauses present the following example. f = open("file") try # operat…

---

## [Create a vector accepting different datatypes at specific index positions](https://discourse.julialang.org/t/create-a-vector-accepting-different-datatypes-at-specific-index-positions/96222)

<div class="topic-metadata">

**Author:** [@Name1](https://discourse.julialang.org/u/Name1)\
**Replies:** 3\
**Last updated:** [March 17, 2023, 4:53am UTC](https://discourse.julialang.org/t/create-a-vector-accepting-different-datatypes-at-specific-index-positions/96222 "2023-03-17T04:53:34Z")

</div>

Hi all, I’m wondering how to initialize a vector that requires different datatypes at specific positions. I want the first element in the array to be of type Int64, and the second element in the array to be of type Floa…

---

## [\[ANN\] New tools for fixing performance problems in Julia](https://discourse.julialang.org/t/ann-new-tools-for-fixing-performance-problems-in-julia/95773)

<div class="topic-metadata">

**Author:** [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Replies:** 3\
**Last updated:** [March 17, 2023, 2:51am UTC](https://discourse.julialang.org/t/ann-new-tools-for-fixing-performance-problems-in-julia/95773 "2023-03-17T02:51:46Z")

</div>

Many questions on discourse center around performance, and one common category of problems is “type instability” (aka, poor inferrability triggering runtime dispatch). While the @code\_typed and similar macros are powerfu…

---

## [How to debug a multithreaded code in VS code?](https://discourse.julialang.org/t/how-to-debug-a-multithreaded-code-in-vs-code/96078)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 3\
**Last updated:** [March 16, 2023, 11:33pm UTC](https://discourse.julialang.org/t/how-to-debug-a-multithreaded-code-in-vs-code/96078 "2023-03-16T23:33:41Z")

</div>

I am using VS code with Julia extension. I debug the code normally by putting breakpoints at specific locations. However, putting these breakpoints inside @threads macro with a for loop (or inside a multithreaded code wi…

---

## [How many fillable elements in an AbstractMatrix?](https://discourse.julialang.org/t/how-many-fillable-elements-in-an-abstractmatrix/96174)

<div class="topic-metadata">

**Author:** [@pgoulart](https://discourse.julialang.org/u/pgoulart)\
**Replies:** 3\
**Last updated:** [March 16, 2023, 11:30pm UTC](https://discourse.julialang.org/t/how-many-fillable-elements-in-an-abstractmatrix/96174 "2023-03-16T23:30:51Z")

</div>

It seems like it should be possible to count the number of “fillable” entries in a matrix, but I can’t work out how to do so for any AbstractMatrix. What I want: Some function foo that returns: nnz(A) when A is Spar…

---

## [Preallocating Interpolation object](https://discourse.julialang.org/t/preallocating-interpolation-object/96207)

<div class="topic-metadata">

**Author:** [@tradler](https://discourse.julialang.org/u/tradler)\
**Replies:** 3\
**Last updated:** [March 16, 2023, 9:40pm UTC](https://discourse.julialang.org/t/preallocating-interpolation-object/96207 "2023-03-16T21:40:02Z")

</div>

I am solving a dynamic programing value function using backward induction, and would like to be able to update an Interpolations.jl object (or something similar) which holds an approximation of the value function in each…

---

## [Julia Plots title escaping '\\'](https://discourse.julialang.org/t/julia-plots-title-escaping/96198)

<div class="topic-metadata">

**Author:** [@joeynelson](https://discourse.julialang.org/u/joeynelson)\
**Replies:** 6\
**Last updated:** [March 16, 2023, 7:44pm UTC](https://discourse.julialang.org/t/julia-plots-title-escaping/96198 "2023-03-16T19:44:22Z")

</div>

I’m putting a windows path into a plot title. But it looks like it is trying to treat the \\ as the start of some LaTeX keyword, and reporting an undefined symbol Is there a way to disable this behavior or a standard way…

---

## [\`all(isdigit, empty\_string)\`](https://discourse.julialang.org/t/all-isdigit-empty-string/96038)

<div class="topic-metadata">

**Author:** [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Replies:** 13\
**Last updated:** [March 16, 2023, 4:16pm UTC](https://discourse.julialang.org/t/all-isdigit-empty-string/96038 "2023-03-16T16:16:00Z")

</div>

Is the first result expected? all(isdigit, "") # true given that: any(isdigit, "") # false Thanks.

---

## [Can Makie plots be dimension agnostic?](https://discourse.julialang.org/t/can-makie-plots-be-dimension-agnostic/92124)

<div class="topic-metadata">

**Author:** [@g2g](https://discourse.julialang.org/u/g2g)\
**Replies:** 16\
**Last updated:** [March 16, 2023, 12:35pm UTC](https://discourse.julialang.org/t/can-makie-plots-be-dimension-agnostic/92124 "2023-03-16T12:35:12Z")

</div>

Makie is new to me and I’m hoping to use it to plot the results of my port of bivector.net’s C++ reference implementation of projective geometric algebra to a Julia reference implementation of projective geometric algebr…

---

## [Makie / GLMakie: Plot image into an axis object](https://discourse.julialang.org/t/makie-glmakie-plot-image-into-an-axis-object/95996)

<div class="topic-metadata">

**Author:** [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Replies:** 4\
**Last updated:** [March 16, 2023, 2:21pm UTC](https://discourse.julialang.org/t/makie-glmakie-plot-image-into-an-axis-object/95996 "2023-03-16T14:21:15Z")

</div>

Regarding the function image() I have two questions If I use space=:pixel, how can I get the current upper offset / padding? Is it possible to plot a SVG-figure into a GLMakie-figure? I had to struggle to understand t…

---

## [How to repeat the format in @printf?](https://discourse.julialang.org/t/how-to-repeat-the-format-in-printf/66695)

<div class="topic-metadata">

**Author:** [@CRquantum](https://discourse.julialang.org/u/CRquantum)\
**Replies:** 27\
**Last updated:** [March 16, 2023, 12:14pm UTC](https://discourse.julialang.org/t/how-to-repeat-the-format-in-printf/66695 "2023-03-16T12:14:52Z")

</div>

Sorry for another stupid question. Not proud of asking these kind questions :sweat\_smile:. I am sure it is stupid, however I searched google and stack overflow but still not sure how to do this. The question is very si…

---

## [Multi-arguments mapslices](https://discourse.julialang.org/t/multi-arguments-mapslices/96172)

<div class="topic-metadata">

**Author:** [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Replies:** 3\
**Last updated:** [March 16, 2023, 1:19pm UTC](https://discourse.julialang.org/t/multi-arguments-mapslices/96172 "2023-03-16T13:19:09Z")

</div>

Hello, I am looking for an efficient way to do this kind of operation (not that one, it’s an MWE): julia\> A = rand(3,3,5); julia\> B = rand(3,3,5); julia\> mult\_sum(a::AbstractMatrix, b::AbstractMatrix) = sum(a\*b, dims…

---

## [Finding neighbouring cells in \`ExtendableGrids.jl\`](https://discourse.julialang.org/t/finding-neighbouring-cells-in-extendablegrids-jl/96179)

<div class="topic-metadata">

**Author:** [@mm-crj](https://discourse.julialang.org/u/mm-crj)\
**Replies:** 0\
**Last updated:** [March 16, 2023, 11:51am UTC](https://discourse.julialang.org/t/finding-neighbouring-cells-in-extendablegrids-jl/96179 "2023-03-16T11:51:58Z")

</div>

Hey Everyone! This is a follow-up question to my previous question here. I would like to find the Neighbouring cells of a given cell(a matrix of all cells would be even nicer) of a grid in ExtendableGrids.jl. What would …

---

## [How can I extend a primitive type](https://discourse.julialang.org/t/how-can-i-extend-a-primitive-type/96135)

<div class="topic-metadata">

**Author:** [@this\_josh](https://discourse.julialang.org/u/this_josh)\
**Replies:** 29\
**Last updated:** [March 16, 2023, 10:29am UTC](https://discourse.julialang.org/t/how-can-i-extend-a-primitive-type/96135 "2023-03-16T10:29:56Z")

</div>

I’d like to implement a Percent type, which will be a subtype of Float64 and can utilise Float64. Ideally I’d like to something like this: struct Percent \<: Float64 v::Float64 @assert 0≤v≤1 # I'm not sure if th…

---

## [Weird behaviour when replace the empty string in row with DataFramesMeta.jl](https://discourse.julialang.org/t/weird-behaviour-when-replace-the-empty-string-in-row-with-dataframesmeta-jl/96165)

<div class="topic-metadata">

**Author:** [@hungpham3112](https://discourse.julialang.org/u/hungpham3112)\
**Replies:** 4\
**Last updated:** [March 16, 2023, 8:20am UTC](https://discourse.julialang.org/t/weird-behaviour-when-replace-the-empty-string-in-row-with-dataframesmeta-jl/96165 "2023-03-16T08:20:28Z")

</div>

I have a snippet string\_number\_df2 = DataFrame( A = \["1", "", "3"\], B = \["4", "5", ""\], ) result = @chain string\_number\_df2 begin @rtransform :B = replace(:B, "" =\> missing) end Expectation: A | B…

---

## [How to change form using InMemoryDatasets package?](https://discourse.julialang.org/t/how-to-change-form-using-inmemorydatasets-package/95989)

<div class="topic-metadata">

**Author:** [@akshdfyehd](https://discourse.julialang.org/u/akshdfyehd)\
**Replies:** 7\
**Last updated:** [March 16, 2023, 6:37am UTC](https://discourse.julialang.org/t/how-to-change-form-using-inmemorydatasets-package/95989 "2023-03-16T06:37:33Z")

</div>

I’ve got a dataset from kaggle, which is relate to travel, and there is a column called “accommodation cost” which have some value like these: so there are three types, how to change the one with dollar sign and one …

---

## [How to create a reversed view that allows for growing arrays?](https://discourse.julialang.org/t/how-to-create-a-reversed-view-that-allows-for-growing-arrays/96148)

<div class="topic-metadata">

**Author:** [@g-gundam](https://discourse.julialang.org/u/g-gundam)\
**Replies:** 3\
**Last updated:** [March 16, 2023, 5:31am UTC](https://discourse.julialang.org/t/how-to-create-a-reversed-view-that-allows-for-growing-arrays/96148 "2023-03-16T05:31:34Z")

</div>

Forgive me for resurrecting an old thread, but being able to get an inverted view of an array is amazing to me as someone who is new to Julia but had to write a lot of code to get this kind of functionality in another la…

---

## [Solving for only half the solution in NonlinearSolve.jl](https://discourse.julialang.org/t/solving-for-only-half-the-solution-in-nonlinearsolve-jl/96163)

<div class="topic-metadata">

**Author:** [@KZ-Spectra](https://discourse.julialang.org/u/KZ-Spectra)\
**Replies:** 1\
**Last updated:** [March 16, 2023, 4:50am UTC](https://discourse.julialang.org/t/solving-for-only-half-the-solution-in-nonlinearsolve-jl/96163 "2023-03-16T04:50:19Z")

</div>

using NonlinearSolve, LinearAlgebra, Plots # Parameters: p = \[h, \\omega\] N=15 g(u,p) = p\[1\]\*Tridiagonal(fill(1,N), fill(-2,N+1), fill(1,N))\*u - u.^3 - p\[2\]\*u probg = NonlinearProblem{false}(g, \[0.3; fill(0.3, N-1); 0…

---

## [Remove redundant folders in a filepath](https://discourse.julialang.org/t/remove-redundant-folders-in-a-filepath/96154)

<div class="topic-metadata">

**Author:** [@Dale\_James\_Black](https://discourse.julialang.org/u/Dale_James_Black)\
**Replies:** 1\
**Last updated:** [March 16, 2023, 2:56am UTC](https://discourse.julialang.org/t/remove-redundant-folders-in-a-filepath/96154 "2023-03-16T02:56:09Z")

</div>

Is there a way to remove redundant folders in a file path? Given a file system like ├── folder1 │ ├── subfolder1 │ │ ├── /images1/redundant1/redundant2/file.txt │ │ ├── /images2/redundant1/redundant2/file.…

---

## [Broadcast raising a matrix to a specific power](https://discourse.julialang.org/t/broadcast-raising-a-matrix-to-a-specific-power/96159)

<div class="topic-metadata">

**Author:** [@Justin\_Booth](https://discourse.julialang.org/u/Justin_Booth)\
**Replies:** 2\
**Last updated:** [March 16, 2023, 1:17am UTC](https://discourse.julialang.org/t/broadcast-raising-a-matrix-to-a-specific-power/96159 "2023-03-16T01:17:31Z")

</div>

Hi, new to Julia here. I’m trying to model the accumulation of mutations in a population using a Markov chain, I’ve got a transition matrix and an initial state vector, basically what I want to do is raise the transition…

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

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