# General Usage

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

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

**Page:** 678

---

## [Sorting names. Surprise](https://discourse.julialang.org/t/sorting-names-surprise/50198)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 7\
**Last updated:** [November 15, 2020, 10:09pm UTC](https://discourse.julialang.org/t/sorting-names-surprise/50198 "2020-11-15T22:09:55Z")

</div>

What I’m I missing here? This is wrong. julia\> sort(\["Vila Flor", "Vila da Flor"\]) 2-element Vector{String}: "Vila Flor" "Vila da Flor" correct output should be "Vila da Flor" "Vila Flor"

---

## [Put an underscore before all digits in a string](https://discourse.julialang.org/t/put-an-underscore-before-all-digits-in-a-string/50195)

<div class="topic-metadata">

**Author:** [@fusion809](https://discourse.julialang.org/u/fusion809)\
**Replies:** 1\
**Last updated:** [November 15, 2020, 6:13pm UTC](https://discourse.julialang.org/t/put-an-underscore-before-all-digits-in-a-string/50195 "2020-11-15T18:13:05Z")

</div>

I’ve tried reading these docs Introducing Julia/Strings and characters - Wikibooks, open books for an open world and these docs Strings · The Julia Language and I’ve tried several things, such as: replace("x1", r"\\d+" =\>…

---

## [Write to a particular line in a file](https://discourse.julialang.org/t/write-to-a-particular-line-in-a-file/50179)

<div class="topic-metadata">

**Author:** [@fusion809](https://discourse.julialang.org/u/fusion809)\
**Replies:** 4\
**Last updated:** [November 15, 2020, 4:39pm UTC](https://discourse.julialang.org/t/write-to-a-particular-line-in-a-file/50179 "2020-11-15T16:39:47Z")

</div>

Is there a native Julia command to write to a particular line of a file? I know how to open a file, namely using open, but it seems like the options are to overwrite the entire file (with the “w” and write commands/optio…

---

## [Can be visualized clustering with the heatmap()?](https://discourse.julialang.org/t/can-be-visualized-clustering-with-the-heatmap/49903)

<div class="topic-metadata">

**Author:** [@HerAdri](https://discourse.julialang.org/u/HerAdri)\
**Replies:** 8\
**Last updated:** [November 15, 2020, 2:48pm UTC](https://discourse.julialang.org/t/can-be-visualized-clustering-with-the-heatmap/49903 "2020-11-15T14:48:12Z")

</div>

With this code I get the desired heatmap. using Plots dataMatrix=rand(40,10) heatmap(dataMatrix,levels=10,colorbar=false) But I would like to achieve the image of the heatmap with cluster, as shown in the figure: H…

---

## [Conditional Logit MLP in Flux](https://discourse.julialang.org/t/conditional-logit-mlp-in-flux/50140)

<div class="topic-metadata">

**Author:** [@compleat](https://discourse.julialang.org/u/compleat)\
**Replies:** 4\
**Last updated:** [November 15, 2020, 1:03pm UTC](https://discourse.julialang.org/t/conditional-logit-mlp-in-flux/50140 "2020-11-15T13:03:56Z")

</div>

I have been trying for awhile to get Conditional Logistic Regression (mathematically equivalent to Cox Proportional Hazards model) working with MLP’s in Flux, and have found a way, though it is clumsy. I am wondering i…

---

## [Cannot compute gradient/apply back method to solve function](https://discourse.julialang.org/t/cannot-compute-gradient-apply-back-method-to-solve-function/50082)

<div class="topic-metadata">

**Author:** [@TomCif](https://discourse.julialang.org/u/TomCif)\
**Replies:** 3\
**Last updated:** [November 15, 2020, 12:07pm UTC](https://discourse.julialang.org/t/cannot-compute-gradient-apply-back-method-to-solve-function/50082 "2020-11-15T12:07:54Z")

</div>

Hi, I’m facing an issue which avoids me to train my model using sciml\_train. I have the following training data: model = Normal(5., 0.1) raw\_data = rand(model, (1, 100)) x = rand(model, (1; 100)) u0 = \[x; 0\] I have…

---

## [Struct Parameterized by One Dimension of StaticArray Matrix Members](https://discourse.julialang.org/t/struct-parameterized-by-one-dimension-of-staticarray-matrix-members/50115)

<div class="topic-metadata">

**Author:** [@tawheeler](https://discourse.julialang.org/u/tawheeler)\
**Replies:** 9\
**Last updated:** [November 15, 2020, 9:38am UTC](https://discourse.julialang.org/t/struct-parameterized-by-one-dimension-of-staticarray-matrix-members/50115 "2020-11-15T09:38:51Z")

</div>

I would like to preallocate some static arrays for use with DifferentialEquations.jl. My problem uses a lot of matrices that are 3 x N, where N is not known ahead of time. I would like to use StaticArrays.jl and do somet…

---

## [How do I debug this in diffeqflux?](https://discourse.julialang.org/t/how-do-i-debug-this-in-diffeqflux/49845)

<div class="topic-metadata">

**Author:** [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Replies:** 38\
**Last updated:** [November 15, 2020, 3:08am UTC](https://discourse.julialang.org/t/how-do-i-debug-this-in-diffeqflux/49845 "2020-11-15T03:08:05Z")

</div>

This is my first attempt at using diffeq. I just don’t get much help from the stacktrace. I’m trying to train a neural network that is inside a differential equation like a reinforcement learning problem. I get a war…

---

## [Adding more HTML code to an Interact.jl app](https://discourse.julialang.org/t/adding-more-html-code-to-an-interact-jl-app/50160)

<div class="topic-metadata">

**Author:** [@Jojo\_Dad](https://discourse.julialang.org/u/Jojo_Dad)\
**Replies:** 0\
**Last updated:** [November 14, 2020, 8:45pm UTC](https://discourse.julialang.org/t/adding-more-html-code-to-an-interact-jl-app/50160 "2020-11-14T20:45:46Z")

</div>

I have created a simple Interact.jl browser-based app: using Mux, WebIO, Interact, Plots; function app(req) @manipulate for omega=0.1:0.2:3 x=0:0.01:2\*π; y=sin.(omega\*x); plot(x,y); end; end webio\_s…

---

## [MPI not working with PackageCompiler?](https://discourse.julialang.org/t/mpi-not-working-with-packagecompiler/50159)

<div class="topic-metadata">

**Author:** [@kirklong](https://discourse.julialang.org/u/kirklong)\
**Replies:** 0\
**Last updated:** [November 14, 2020, 8:21pm UTC](https://discourse.julialang.org/t/mpi-not-working-with-packagecompiler/50159 "2020-11-14T20:21:31Z")

</div>

I’ve been recently playing with the MPI wrappers for Julia (MPI.jl) – yesterday I built a dumb test problem in both C and Julia and was comparing performance, and Julia is pretty close to C which is impressive! I thoug…

---

## [DiffEq: Flux.train crashes mid-training and requests larger maxiter](https://discourse.julialang.org/t/diffeq-flux-train-crashes-mid-training-and-requests-larger-maxiter/50154)

<div class="topic-metadata">

**Author:** [@Gregor](https://discourse.julialang.org/u/Gregor)\
**Replies:** 3\
**Last updated:** [November 14, 2020, 7:16pm UTC](https://discourse.julialang.org/t/diffeq-flux-train-crashes-mid-training-and-requests-larger-maxiter/50154 "2020-11-14T19:16:14Z")

</div>

Hello everyone, I’m trying to optimize the parameters in a nonlinear differential equation towards some known parameters using the ADAMs optimizer (benchmarking different optimizers for later usage). For some initial co…

---

## [Builtin argmin is slower than manual](https://discourse.julialang.org/t/builtin-argmin-is-slower-than-manual/50127)

<div class="topic-metadata">

**Author:** [@endremborza](https://discourse.julialang.org/u/endremborza)\
**Replies:** 13\
**Last updated:** [November 14, 2020, 3:57pm UTC](https://discourse.julialang.org/t/builtin-argmin-is-slower-than-manual/50127 "2020-11-14T15:57:27Z")

</div>

I don’t understand how this is possible. I tried it many times, targmin always wins, and by quite a significant margin (1.5.2) using BenchmarkTools function targmin(a) m = Inf ind = 0 for i in 1:length(a) …

---

## [Think Julia Exercise 10.1](https://discourse.julialang.org/t/think-julia-exercise-10-1/50098)

<div class="topic-metadata">

**Author:** [@AKL](https://discourse.julialang.org/u/AKL)\
**Replies:** 36\
**Last updated:** [November 14, 2020, 2:39pm UTC](https://discourse.julialang.org/t/think-julia-exercise-10-1/50098 "2020-11-14T14:39:19Z")

</div>

Hey, I am fairly new to Julia and coding. Thus, i still struggle on a lot of things in Julia. I am trying to solve the exercise 10.1 and would like some help on this, at least where to start. \*Write a function called n…

---

## [MethodError with @](https://discourse.julialang.org/t/methoderror-with/50131)

<div class="topic-metadata">

**Author:** [@nebula](https://discourse.julialang.org/u/nebula)\
**Replies:** 3\
**Last updated:** [November 14, 2020, 6:37am UTC](https://discourse.julialang.org/t/methoderror-with/50131 "2020-11-14T06:37:18Z")

</div>

I define a function with multiple parameters, but it throws a MethodError when @. is not the last parameter. Example: julia\> function f(x, y) println(x, y) end f (generic function with 1 method) juli…

---

## [Correct use of convert](https://discourse.julialang.org/t/correct-use-of-convert/50096)

<div class="topic-metadata">

**Author:** [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)\
**Replies:** 11\
**Last updated:** [November 13, 2020, 6:11pm UTC](https://discourse.julialang.org/t/correct-use-of-convert/50096 "2020-11-13T18:11:36Z")

</div>

The last line in the program below fails with the error ERROR: LoadError: MethodError: Cannot convert an object of type String to an object of type Symbol The message is misleading, because it certainly can do such a c…

---

## [Using ControlSystems; c2d usage](https://discourse.julialang.org/t/using-controlsystems-c2d-usage/50110)

<div class="topic-metadata">

**Author:** [@panditabupesh](https://discourse.julialang.org/u/panditabupesh)\
**Replies:** 5\
**Last updated:** [November 13, 2020, 10:04pm UTC](https://discourse.julialang.org/t/using-controlsystems-c2d-usage/50110 "2020-11-13T22:04:05Z")

</div>

I am new to Julia. I am trying to use ControlSystems. using ControlSystems sys = tf(1,\[1,1\]) sys\_d = c2d(sys,1) How can I pass zoh or foh as input to c2d? Thanks, Bupesh c2d(sys,1,:zoh) ERROR: MethodError: no metho…

---

## [Alternative for \`searchsortedfirst\` for repeatedly searching the same array with concentrated values](https://discourse.julialang.org/t/alternative-for-searchsortedfirst-for-repeatedly-searching-the-same-array-with-concentrated-values/50063)

<div class="topic-metadata">

**Author:** [@malacroi](https://discourse.julialang.org/u/malacroi)\
**Replies:** 6\
**Last updated:** [November 13, 2020, 3:44pm UTC](https://discourse.julialang.org/t/alternative-for-searchsortedfirst-for-repeatedly-searching-the-same-array-with-concentrated-values/50063 "2020-11-13T15:44:51Z")

</div>

I have a sorted array a, of positive integers (related to integer partitions), and need to repeatedly find the first index with a value \>= k for various k uniformly distributed between 1 and a\[end\]. This is exactly the …

---

## [Tuples of CartesianIndex and broadcasting](https://discourse.julialang.org/t/tuples-of-cartesianindex-and-broadcasting/50093)

<div class="topic-metadata">

**Author:** [@Sleort](https://discourse.julialang.org/u/Sleort)\
**Replies:** 9\
**Last updated:** [November 13, 2020, 3:15pm UTC](https://discourse.julialang.org/t/tuples-of-cartesianindex-and-broadcasting/50093 "2020-11-13T15:15:19Z")

</div>

While I can broadcast scalars, like julia\> 1 .+ (2, 3) (3, 4) I can’t do the same with CartesianIndexs: julia\> CartesianIndex(1,1) .+ (CartesianIndex(2,2), CartesianIndex(3,3)) ERROR: iteration is deliberately unsuppo…

---

## [Storing an array in CSV file](https://discourse.julialang.org/t/storing-an-array-in-csv-file/49824)

<div class="topic-metadata">

**Author:** [@marouane](https://discourse.julialang.org/u/marouane)\
**Replies:** 4\
**Last updated:** [November 13, 2020, 11:44am UTC](https://discourse.julialang.org/t/storing-an-array-in-csv-file/49824 "2020-11-13T11:44:34Z")

</div>

i’m getting confused with this simple working example, for some reason i do not get my array stored in the CSV file: arr=\[0,1\] open("out.csv","a") CSV.write("out.csv",(arr=arr)) CSV.read("out.csv") and as an output i g…

---

## [Wrong order in push! operator](https://discourse.julialang.org/t/wrong-order-in-push-operator/50086)

<div class="topic-metadata">

**Author:** [@FrootLoops](https://discourse.julialang.org/u/FrootLoops)\
**Replies:** 2\
**Last updated:** [November 13, 2020, 10:54am UTC](https://discourse.julialang.org/t/wrong-order-in-push-operator/50086 "2020-11-13T10:54:54Z")

</div>

Hi, I have a problem using the push! operator. It seems that it does not push the next elements at the end of the arrays. Can someone confirm my result: using Distributions e = 1 \* 10^(-2) n\_data = 2 x = rand(Uniform…

---

## [Unable to parse julia date \[duyyyy\]](https://discourse.julialang.org/t/unable-to-parse-julia-date-duyyyy/50080)

<div class="topic-metadata">

**Author:** [@Rodrigo\_Zepeda](https://discourse.julialang.org/u/Rodrigo_Zepeda)\
**Replies:** 6\
**Last updated:** [November 13, 2020, 8:05am UTC](https://discourse.julialang.org/t/unable-to-parse-julia-date-duyyyy/50080 "2020-11-13T08:05:18Z")

</div>

I am trying to read dates in the format such as “09Aug2015”. From my understanding of datetime objects the format is duyyyy. In fact when converting a date to that format it looks quite like what I want: date\_august = D…

---

## [Symbolic spectra radius of matrix?](https://discourse.julialang.org/t/symbolic-spectra-radius-of-matrix/50058)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 8\
**Last updated:** [November 13, 2020, 8:05am UTC](https://discourse.julialang.org/t/symbolic-spectra-radius-of-matrix/50058 "2020-11-13T08:05:02Z")

</div>

I’m looking for the spectral radius of matrix M given by: M =\\left(\\begin{array}{ccc}0 & k & r\\\\1 & 0 & 0\\\\0 & 1-n & 0\\end{array}\\right) where all of k,r,n are non-negative reals. WolframAlpha can compute the eigenva…

---

## [Saving Probabilities in Log Domain (Constructor Issues)](https://discourse.julialang.org/t/saving-probabilities-in-log-domain-constructor-issues/49968)

<div class="topic-metadata">

**Author:** [@rakeshvar](https://discourse.julialang.org/u/rakeshvar)\
**Replies:** 6\
**Last updated:** [November 13, 2020, 8:01am UTC](https://discourse.julialang.org/t/saving-probabilities-in-log-domain-constructor-issues/49968 "2020-11-13T08:01:35Z")

</div>

I am working with probabilities that can get really low. So I am going to (optionally) store them in log domain and operate there. I do not want my function code to change whether I am using log domain or not. Note that …

---

## [Operation on columns of a matrix](https://discourse.julialang.org/t/operation-on-columns-of-a-matrix/50060)

<div class="topic-metadata">

**Author:** [@nhavt](https://discourse.julialang.org/u/nhavt)\
**Replies:** 3\
**Last updated:** [November 13, 2020, 7:51am UTC](https://discourse.julialang.org/t/operation-on-columns-of-a-matrix/50060 "2020-11-13T07:51:45Z")

</div>

Hello there, I would like to ask a question regarding an operation on two columns of a matrix as you can see below. Here I proposed two functions to perform the task. The function f1 has two allocations even though I us…

---

## [Advice for package naming](https://discourse.julialang.org/t/advice-for-package-naming/50073)

<div class="topic-metadata">

**Author:** [@Azzaare](https://discourse.julialang.org/u/Azzaare)\
**Replies:** 5\
**Last updated:** [November 13, 2020, 6:42am UTC](https://discourse.julialang.org/t/advice-for-package-naming/50073 "2020-11-13T06:42:59Z")

</div>

Hi there! I am working on a package for different Constraint-Based Local Search (CBLS) Solvers. I am a bit at a loss on how to name it. CBLS.jl is hard to understand outside of the community. Same for CBLSSolvers.jl C…

---

## [Vectorized updating operator?](https://discourse.julialang.org/t/vectorized-updating-operator/50079)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 3\
**Last updated:** [November 13, 2020, 6:29am UTC](https://discourse.julialang.org/t/vectorized-updating-operator/50079 "2020-11-13T06:29:12Z")

</div>

Is it possible to vectorize an updating operator? This gives an error a,b,c = (10,20,30) a,b,c ./=10

---

## [Specifying a set of algorithms](https://discourse.julialang.org/t/specifying-a-set-of-algorithms/50061)

<div class="topic-metadata">

**Author:** [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Replies:** 14\
**Last updated:** [November 13, 2020, 6:06am UTC](https://discourse.julialang.org/t/specifying-a-set-of-algorithms/50061 "2020-11-13T06:06:18Z")

</div>

Suppose I have a function f and I need to specify which algorithms to use inside f (e.g. different optimization methods to combine together). What is the best (i.e. most performant) way to do that? MWE: A(x) = 2x B(x)…

---

## [ERROR: GitError(Code:ERROR, Class:Submodule, cannot get submodules without a working tree)](https://discourse.julialang.org/t/error-giterror-code-error-class-submodule-cannot-get-submodules-without-a-working-tree/49926)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 6\
**Last updated:** [November 12, 2020, 7:16pm UTC](https://discourse.julialang.org/t/error-giterror-code-error-class-submodule-cannot-get-submodules-without-a-working-tree/49926 "2020-11-12T19:16:57Z")

</div>

Hello, I would like to add one of my package AdaptiveTransportMap to a project but I get the following error message: (NlVortexAssim) pkg\> add AdaptiveTransportMap/ Updating git-repo \`/media/mat/HDD/AdaptiveTranspor…

---

## [Conversion of Vector{UInt8} to String without copy](https://discourse.julialang.org/t/conversion-of-vector-uint8-to-string-without-copy/49837)

<div class="topic-metadata">

**Author:** [@JuergenD](https://discourse.julialang.org/u/JuergenD)\
**Replies:** 7\
**Last updated:** [November 12, 2020, 6:32pm UTC](https://discourse.julialang.org/t/conversion-of-vector-uint8-to-string-without-copy/49837 "2020-11-12T18:32:03Z")

</div>

Hi, use case: large files with a binary structure and embedded “text” elements. Depending on the file size, we either read them fully into mem, or mmap them. Hence in both cases, the data are fully available in memory…

---

## [Operation on an RObject{RealSxp} Created Using RCall](https://discourse.julialang.org/t/operation-on-an-robject-realsxp-created-using-rcall/50059)

<div class="topic-metadata">

**Author:** [@atparedes](https://discourse.julialang.org/u/atparedes)\
**Replies:** 1\
**Last updated:** [November 12, 2020, 5:27pm UTC](https://discourse.julialang.org/t/operation-on-an-robject-realsxp-created-using-rcall/50059 "2020-11-12T17:27:45Z")

</div>

Hello All, New to Julia: I am using Julia to develop a large Monte Carlo simulation investigating the robustness of several statistical procedures. I created a couple of variables (vector) from the skew-normal distribut…

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

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