# General Usage

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

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

**Page:** 597

---

## [In Julia, an array can transform to a matrix, how can I do it?](https://discourse.julialang.org/t/in-julia-an-array-can-transform-to-a-matrix-how-can-i-do-it/61637)

<div class="topic-metadata">

**Author:** [@BYS](https://discourse.julialang.org/u/BYS)\
**Replies:** 4\
**Last updated:** [May 22, 2021, 2:55pm UTC](https://discourse.julialang.org/t/in-julia-an-array-can-transform-to-a-matrix-how-can-i-do-it/61637 "2021-05-22T14:55:54Z")

</div>

Hi, all In Julia, I find,if I use A=zeros(20,1); A can be a array, instead of a vector,but I want it to be a vector and I also want to use function “zeros”, How can I do it? Thanks a lot!

---

## [MethodError Vector{T} for input ::SparseArrays.SparseMatrixCSC{Float64, Int64}](https://discourse.julialang.org/t/methoderror-vector-t-for-input-sparsearrays-sparsematrixcsc-float64-int64/61600)

<div class="topic-metadata">

**Author:** [@Thomas](https://discourse.julialang.org/u/Thomas)\
**Replies:** 4\
**Last updated:** [May 22, 2021, 1:24pm UTC](https://discourse.julialang.org/t/methoderror-vector-t-for-input-sparsearrays-sparsematrixcsc-float64-int64/61600 "2021-05-22T13:24:13Z")

</div>

Does anyone know how to fix this error? using MatrixMarket c=MatrixMarket.mmread(“c.mtx”) Vector(c) gives ERROR: MethodError: no method matching (Vector{T} where T)(::SparseArrays.SparseMatrixCSC{Float64, Int64}) …

---

## [Gridded value at specific coordinate](https://discourse.julialang.org/t/gridded-value-at-specific-coordinate/61427)

<div class="topic-metadata">

**Author:** [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Replies:** 4\
**Last updated:** [May 22, 2021, 12:20pm UTC](https://discourse.julialang.org/t/gridded-value-at-specific-coordinate/61427 "2021-05-22T12:20:10Z")

</div>

I’m quite new to Julia. Suppose you have a 1D gridded data, say, temperature, \[23.5, 20.0, . . . \], defined at gridpoints xs = \[1.0, 2.0, 5.0, . . . \]. Assume that length(temperature) == length(xs) and that xs is monot…

---

## [Resolve sign ambiguity in SVD and Eigendecomposition](https://discourse.julialang.org/t/resolve-sign-ambiguity-in-svd-and-eigendecomposition/61484)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 13\
**Last updated:** [May 22, 2021, 11:46am UTC](https://discourse.julialang.org/t/resolve-sign-ambiguity-in-svd-and-eigendecomposition/61484 "2021-05-22T11:46:29Z")

</div>

Hello, Given a matrix A \\in \\mathbb{R}^{m\\times n}, my goal is to recover the SVD decomposition of A from the eigendecomposition of A^\\top A and A^\\top A. A compact SVD decomposition of matrix A \\in \\mathbb{R}^{m\\times…

---

## [Help with macro to construct truth tables](https://discourse.julialang.org/t/help-with-macro-to-construct-truth-tables/61610)

<div class="topic-metadata">

**Author:** [@savq](https://discourse.julialang.org/u/savq)\
**Replies:** 9\
**Last updated:** [May 22, 2021, 3:46am UTC](https://discourse.julialang.org/t/help-with-macro-to-construct-truth-tables/61610 "2021-05-22T03:46:48Z")

</div>

I’m trying to write a macro to generate truth tables. So far I’ve had success with finding the variables and evaluating the expression. However, I haven’t been able to display the truth value for individual variables. T…

---

## [Scatterplot linewidth does not disappear when render to pdf](https://discourse.julialang.org/t/scatterplot-linewidth-does-not-disappear-when-render-to-pdf/61556)

<div class="topic-metadata">

**Author:** [@andresmz](https://discourse.julialang.org/u/andresmz)\
**Replies:** 1\
**Last updated:** [May 21, 2021, 7:58am UTC](https://discourse.julialang.org/t/scatterplot-linewidth-does-not-disappear-when-render-to-pdf/61556 "2021-05-21T07:58:39Z")

</div>

Hello. I’ve been trying to plot this database and save it on pdf. I’m not really sure why it it still shows the linewidth if I set it 0. This does not happen when I save it as a png file. Here is the code I am using: g…

---

## [Tangent on radix sort](https://discourse.julialang.org/t/tangent-on-radix-sort/61605)

<div class="topic-metadata">

**Author:** [@tkf](https://discourse.julialang.org/u/tkf)\
**Replies:** 2\
**Last updated:** [May 22, 2021, 2:23am UTC](https://discourse.julialang.org/t/tangent-on-radix-sort/61605 "2021-05-22T02:23:31Z")

</div>

By “skewed” and non-“balanced” data, are you referring to the case where the bits that discriminate elements occur at the locations closer to the least significant bits? If so, yes, it’s possible to invoke this case in …

---

## [Not-so-unusual Macro issues](https://discourse.julialang.org/t/not-so-unusual-macro-issues/61570)

<div class="topic-metadata">

**Author:** [@harris-chris](https://discourse.julialang.org/u/harris-chris)\
**Replies:** 2\
**Last updated:** [May 22, 2021, 1:36am UTC](https://discourse.julialang.org/t/not-so-unusual-macro-issues/61570 "2021-05-22T01:36:41Z")

</div>

Hello all. I’m having some macro-related issues. I’d like, if it’s even possible, to store the Expression of a function defined by the user, so I can write it to a file and use it elsewhere. I imagined that this would be…

---

## [Coloring of specific characters in a String](https://discourse.julialang.org/t/coloring-of-specific-characters-in-a-string/61468)

<div class="topic-metadata">

**Author:** [@Jdbeck66](https://discourse.julialang.org/u/Jdbeck66)\
**Replies:** 12\
**Last updated:** [May 21, 2021, 4:52pm UTC](https://discourse.julialang.org/t/coloring-of-specific-characters-in-a-string/61468 "2021-05-21T16:52:46Z")

</div>

I work with RNA and DNA sequences and am interested in determining how to change a particular character in a string to a different color. Specifically, I’d like to sequence = "AUCGCGCA" sequence\[3\] = #Blue copy of C …

---

## [Calculating ULP distance between two floating point numbers (quickly)](https://discourse.julialang.org/t/calculating-ulp-distance-between-two-floating-point-numbers-quickly/61581)

<div class="topic-metadata">

**Author:** [@fellbyyourgun](https://discourse.julialang.org/u/fellbyyourgun)\
**Replies:** 8\
**Last updated:** [May 21, 2021, 3:09pm UTC](https://discourse.julialang.org/t/calculating-ulp-distance-between-two-floating-point-numbers-quickly/61581 "2021-05-21T15:09:59Z")

</div>

I need to compare floating point numbers for near-equality. I would like to compare them based on the ULP distance (see here if you aren’t familiar/need a refresher). The most straightforward way to do this, as far as I…

---

## [Need suggestions on how to convert from OOP library to Julia](https://discourse.julialang.org/t/need-suggestions-on-how-to-convert-from-oop-library-to-julia/60947)

<div class="topic-metadata">

**Author:** [@danilo-bc](https://discourse.julialang.org/u/danilo-bc)\
**Replies:** 9\
**Last updated:** [May 21, 2021, 2:07pm UTC](https://discourse.julialang.org/t/need-suggestions-on-how-to-convert-from-oop-library-to-julia/60947 "2021-05-21T14:07:18Z")

</div>

Hello! I’ve been reading about the one question that always comes up for people using Julia after coming from an OOP language with traditional classes and methods. Is Julia's way of OOP superior to C++/Python? Why Julia…

---

## [Performance decrease after renaming functions](https://discourse.julialang.org/t/performance-decrease-after-renaming-functions/61577)

<div class="topic-metadata">

**Author:** [@Tusike](https://discourse.julialang.org/u/Tusike)\
**Replies:** 2\
**Last updated:** [May 21, 2021, 2:04pm UTC](https://discourse.julialang.org/t/performance-decrease-after-renaming-functions/61577 "2021-05-21T14:04:09Z")

</div>

Hi! A have a function AND which takes a pre-allocated vector and writes in the result of some operations. Following the julia naming convention, I wanted to change its name to AND! so that this behavior is reflected com…

---

## [Simple random walk performance tips](https://discourse.julialang.org/t/simple-random-walk-performance-tips/61553)

<div class="topic-metadata">

**Author:** [@Babou](https://discourse.julialang.org/u/Babou)\
**Replies:** 6\
**Last updated:** [May 21, 2021, 8:39am UTC](https://discourse.julialang.org/t/simple-random-walk-performance-tips/61553 "2021-05-21T08:39:54Z")

</div>

Hi all I have written a small code chunk for a generic random walk, as I am hoping to use julia for dynamic systems simulations this will be a good toy example for me to improve memory usage. function rwalks(T,N,n) …

---

## [Define a function on a remote process only](https://discourse.julialang.org/t/define-a-function-on-a-remote-process-only/61561)

<div class="topic-metadata">

**Author:** [@Eggiverse](https://discourse.julialang.org/u/Eggiverse)\
**Replies:** 2\
**Last updated:** [May 21, 2021, 8:33am UTC](https://discourse.julialang.org/t/define-a-function-on-a-remote-process-only/61561 "2021-05-21T08:33:56Z")

</div>

I am trying to run a job on a remote process. But the job function will not be run on the main process, so I try to avoid defining it on main process. However, it seems impossible to define a function on a child process …

---

## [Trying to save an animation as a gif, but getting error and permission denied](https://discourse.julialang.org/t/trying-to-save-an-animation-as-a-gif-but-getting-error-and-permission-denied/61565)

<div class="topic-metadata">

**Author:** [@eugenetkj98](https://discourse.julialang.org/u/eugenetkj98)\
**Replies:** 0\
**Last updated:** [May 21, 2021, 8:11am UTC](https://discourse.julialang.org/t/trying-to-save-an-animation-as-a-gif-but-getting-error-and-permission-denied/61565 "2021-05-21T08:11:27Z")

</div>

Hi guys, so I’m trying to compile a whole bunch of plots as one moving gif or video using the Plots.jl library alongside ImageMagick. However, whenever I run it, @animate seems to work fine but fails when it tries to inp…

---

## [SORT a Dictionary by Numerical Keys](https://discourse.julialang.org/t/sort-a-dictionary-by-numerical-keys/61547)

<div class="topic-metadata">

**Author:** [@bonnkleiford](https://discourse.julialang.org/u/bonnkleiford)\
**Replies:** 3\
**Last updated:** [May 21, 2021, 5:44am UTC](https://discourse.julialang.org/t/sort-a-dictionary-by-numerical-keys/61547 "2021-05-21T05:44:35Z")

</div>

I have a Dictionary: A = Dict("1" =\> 0.1, "11" =\> 0.1, "13" =\> 0.1, "15" =\> 0.1, "17" =\> 0.1, "19" =\> 0.1, "3" =\> 0.1, "5" =\> 0.1, "7" =\> 0.1, "9" =\> 0.1) I want to sort it according to its numer…

---

## [Creating a function called \*\*](https://discourse.julialang.org/t/creating-a-function-called/61464)

<div class="topic-metadata">

**Author:** [@pg261](https://discourse.julialang.org/u/pg261)\
**Replies:** 10\
**Last updated:** [May 20, 2021, 9:22pm UTC](https://discourse.julialang.org/t/creating-a-function-called/61464 "2021-05-20T21:22:44Z")

</div>

Hi ! I’m trying to define an operator called \*\*, using something like function \*\*(a,b) return a+b+1 # or whatever end but Julia won’t let me – it’s just warning me that \*\* is not used for exponentiation. But \*\* is …

---

## [Counting automatically the number of arithmetic operations of a function](https://discourse.julialang.org/t/counting-automatically-the-number-of-arithmetic-operations-of-a-function/61538)

<div class="topic-metadata">

**Author:** [@pierre-haessig](https://discourse.julialang.org/u/pierre-haessig)\
**Replies:** 3\
**Last updated:** [May 20, 2021, 9:22pm UTC](https://discourse.julialang.org/t/counting-automatically-the-number-of-arithmetic-operations-of-a-function/61538 "2021-05-20T21:22:30Z")

</div>

Hello, Say I have one function with hundreds of lines of code, with a few internal functions and perhaps with calls to some mathematical functions (sqrt, tan…). I’d like to know how many arithmetic operations (e.g. numb…

---

## [Plots and Shape?](https://discourse.julialang.org/t/plots-and-shape/61501)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 6\
**Last updated:** [May 20, 2021, 7:30pm UTC](https://discourse.julialang.org/t/plots-and-shape/61501 "2021-05-20T19:30:21Z")

</div>

I found the following code in this discourse (there seems to be a couple of versions of it): import Plots as plt ang = range(0, 2π, length = 60) ellipse(x, y, w, h) = plt.Shape(w\*sin.(ang).+x, h\*cos.(ang).+y) # Retur…

---

## [Zygote gradient results in slow Tuple getindex calls](https://discourse.julialang.org/t/zygote-gradient-results-in-slow-tuple-getindex-calls/48767)

<div class="topic-metadata">

**Author:** [@roflmaostc](https://discourse.julialang.org/u/roflmaostc)\
**Replies:** 6\
**Last updated:** [May 20, 2021, 6:19pm UTC](https://discourse.julialang.org/t/zygote-gradient-results-in-slow-tuple-getindex-calls/48767 "2021-05-20T18:19:13Z")

</div>

Hey, I’m working on an optimization problem and I’m using Zygote to calculate the gradients (code). Initially a lot of the chain rules were implemented manually by code but then I switched so that Zygote can do this st…

---

## [Elaboration on Parametric Methods](https://discourse.julialang.org/t/elaboration-on-parametric-methods/61531)

<div class="topic-metadata">

**Author:** [@anon60034542](https://discourse.julialang.org/u/anon60034542)\
**Replies:** 2\
**Last updated:** [May 20, 2021, 6:13pm UTC](https://discourse.julialang.org/t/elaboration-on-parametric-methods/61531 "2021-05-20T18:13:25Z")

</div>

I don’t fully grasp when you would use parametric types or abstract types in methods. Before posting my question, I did attempt to read and try and answer the question for myself. Consider the following code: abstract…

---

## [Rayleigh Test circular stats](https://discourse.julialang.org/t/rayleigh-test-circular-stats/60882)

<div class="topic-metadata">

**Author:** [@katdeane](https://discourse.julialang.org/u/katdeane)\
**Replies:** 5\
**Last updated:** [May 20, 2021, 6:12pm UTC](https://discourse.julialang.org/t/rayleigh-test-circular-stats/60882 "2021-05-20T18:12:30Z")

</div>

Dear Julia peeps, I am trying to relate brain activity to an amplitude modulated tone stimulus. As in, does the peak of brain activity occur in synchrony with the phase of the modulated tone? HypothesisTests.jl has this…

---

## [Slicing and merging of CartesianIndices](https://discourse.julialang.org/t/slicing-and-merging-of-cartesianindices/61519)

<div class="topic-metadata">

**Author:** [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Replies:** 2\
**Last updated:** [May 20, 2021, 4:28pm UTC](https://discourse.julialang.org/t/slicing-and-merging-of-cartesianindices/61519 "2021-05-20T16:28:56Z")

</div>

Hello, Let’s assume I have a two-dimensional array and the list of Cartesian indices which allow me to extract some subset of the array elements: A = zeros((6, 9)) ci = CartesianIndices((2:2:6, 3:3:9)) A\[ci\] Now, ha…

---

## [Looking for the correct way to do a clean julia process shutdown](https://discourse.julialang.org/t/looking-for-the-correct-way-to-do-a-clean-julia-process-shutdown/46691)

<div class="topic-metadata">

**Author:** [@attdona](https://discourse.julialang.org/u/attdona)\
**Replies:** 5\
**Last updated:** [May 20, 2021, 3:42pm UTC](https://discourse.julialang.org/t/looking-for-the-correct-way-to-do-a-clean-julia-process-shutdown/46691 "2021-05-20T15:42:26Z")

</div>

I’m not able to capture correctly the SIGINT signal and invoke a controlled shutdown. It seems that atexit should be the answer, but in my (semplified) minimal example, with FileWatching: using FileWatching function w…

---

## [DataFrame eltypes error without using eltypes](https://discourse.julialang.org/t/dataframe-eltypes-error-without-using-eltypes/61473)

<div class="topic-metadata">

**Author:** [@seulberg1](https://discourse.julialang.org/u/seulberg1)\
**Replies:** 4\
**Last updated:** [May 20, 2021, 3:16pm UTC](https://discourse.julialang.org/t/dataframe-eltypes-error-without-using-eltypes/61473 "2021-05-20T15:16:44Z")

</div>

Hello All I am trying to run Julia code on a Linux cluster that works flawlessly on my personal machine. The MWE that fails for me: using Pkg Pkg.activate("/home/path/JuliaEnv/") #Activate Environment using DataFrames …

---

## [Stipple error in German credit demo](https://discourse.julialang.org/t/stipple-error-in-german-credit-demo/61448)

<div class="topic-metadata">

**Author:** [@bww00](https://discourse.julialang.org/u/bww00)\
**Replies:** 4\
**Last updated:** [May 20, 2021, 3:15pm UTC](https://discourse.julialang.org/t/stipple-error-in-german-credit-demo/61448 "2021-05-20T15:15:12Z")

</div>

I am trying to get the German credit demo for STipple running. Getting error and would appreciate any assistance ERROR: UndefVarError: DataFrame! not defined Active env: DEV ┌ Warning: │ No secret token is…

---

## [How to allow Float64 or ForwardDiff.dual in structs and arrays](https://discourse.julialang.org/t/how-to-allow-float64-or-forwarddiff-dual-in-structs-and-arrays/61521)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 0\
**Last updated:** [May 20, 2021, 2:56pm UTC](https://discourse.julialang.org/t/how-to-allow-float64-or-forwarddiff-dual-in-structs-and-arrays/61521 "2021-05-20T14:56:42Z")

</div>

Hello, I have a module that usually operates on Float64 types, but I also sometimes want to allow dual numbers for some initial optimization. How can I achieve that? For example: Now: const SimFloat = Float64 const V…

---

## [Creating a custom registry](https://discourse.julialang.org/t/creating-a-custom-registry/28007)

<div class="topic-metadata">

**Author:** [@ggggggggg](https://discourse.julialang.org/u/ggggggggg)\
**Replies:** 17\
**Last updated:** [May 7, 2021, 8:47am UTC](https://discourse.julialang.org/t/creating-a-custom-registry/28007 "2021-05-07T08:47:27Z")

</div>

I’m trying to create a registry. I’m starting with a simple example before I attempt the real thing. My goal here is to make a registry with two packages TestB which depends on TestA which is also in the registry. Then I…

---

## [\`Pair{A,B}\` vs. \`Tuple{A,B}\`](https://discourse.julialang.org/t/pair-a-b-vs-tuple-a-b/942)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 4\
**Last updated:** [May 20, 2021, 1:07pm UTC](https://discourse.julialang.org/t/pair-a-b-vs-tuple-a-b/942 "2021-05-20T13:07:46Z")

</div>

So what’s the difference between Pair{A,B} and Tuple{A,B}? Why do we have both instead of one?

---

## [Functions from different modules with the same name](https://discourse.julialang.org/t/functions-from-different-modules-with-the-same-name/61505)

<div class="topic-metadata">

**Author:** [@pg261](https://discourse.julialang.org/u/pg261)\
**Replies:** 16\
**Last updated:** [May 20, 2021, 1:03pm UTC](https://discourse.julialang.org/t/functions-from-different-modules-with-the-same-name/61505 "2021-05-20T13:03:32Z")

</div>

Hi ! I have a problem which I thought should never happen with Julia. The result is even worse when using Pluto. I use two modules, which have a function with the same name, but taking parameters of different types. I …

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

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