# General Usage

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

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

**Page:** 308

---

## [DBInterface or MySQL.jl problem?](https://discourse.julialang.org/t/dbinterface-or-mysql-jl-problem/97084)

<div class="topic-metadata">

**Author:** [@Ronneesley](https://discourse.julialang.org/u/Ronneesley)\
**Replies:** 2\
**Last updated:** [April 5, 2023, 2:26am UTC](https://discourse.julialang.org/t/dbinterface-or-mysql-jl-problem/97084 "2023-04-05T02:26:25Z")

</div>

Hello, When I execute two queries, the first result becomes random. Given the database: create database test; use test; create table person ( id int auto\_increment, name varchar(100), primary key (id) ); create …

---

## [Unexpected broadcasting behavior involving eachrow()](https://discourse.julialang.org/t/unexpected-broadcasting-behavior-involving-eachrow/96781)

<div class="topic-metadata">

**Author:** [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Replies:** 86\
**Last updated:** [April 4, 2023, 10:31pm UTC](https://discourse.julialang.org/t/unexpected-broadcasting-behavior-involving-eachrow/96781 "2023-04-04T22:31:35Z")

</div>

in the following, the result of y2 is counter-intuitive: Random.seed!(1); x = randn(6, 4); scale = (1 ./ LinearAlgebra.norm.(eachrow(x)) ); y1 = x .\* scale; y2 = copy(x); y2 .\*= (1 ./ LinearAlgebra.norm.(eachrow(y2)) …

---

## [How to intercept creation or setting of variable in current module?](https://discourse.julialang.org/t/how-to-intercept-creation-or-setting-of-variable-in-current-module/97034)

<div class="topic-metadata">

**Author:** [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Replies:** 7\
**Last updated:** [April 4, 2023, 7:29pm UTC](https://discourse.julialang.org/t/how-to-intercept-creation-or-setting-of-variable-in-current-module/97034 "2023-04-04T19:29:45Z")

</div>

Need help, how to intercept operation on create new variable on current module in Julia 1.8? For example, to intercept MyModule.x = 1 in Julia 1.8 i do this: julia\> module MyModule end; julia\> function Base.setpropert…

---

## [Optim search/convergence speed](https://discourse.julialang.org/t/optim-search-convergence-speed/97083)

<div class="topic-metadata">

**Author:** [@X\_Chen](https://discourse.julialang.org/u/X_Chen)\
**Replies:** 0\
**Last updated:** [April 4, 2023, 8:23pm UTC](https://discourse.julialang.org/t/optim-search-convergence-speed/97083 "2023-04-04T20:23:34Z")

</div>

Hello! I am using Optim.optimize to conduct a MLE algorithm with 6 parameters. The objective function is defined as follows: function r\_obj(r\_para) print(r\_para) df\_y\_1\_p\_0.LL\_1 = cap\_p.((r\_prob\_0(r\_para,df\_0.x3…

---

## [Subtract Vector from Vector of Vectors](https://discourse.julialang.org/t/subtract-vector-from-vector-of-vectors/96913)

<div class="topic-metadata">

**Author:** [@liamfdoherty](https://discourse.julialang.org/u/liamfdoherty)\
**Replies:** 6\
**Last updated:** [April 4, 2023, 7:34pm UTC](https://discourse.julialang.org/t/subtract-vector-from-vector-of-vectors/96913 "2023-04-04T19:34:39Z")

</div>

I’m having a bit of a moment. What is wrong with julia\> x = \[\[1, 2, 3\], \[4, 5, 6\]\] 2-element Vector{Vector{Int64}}: \[1, 2, 3\] \[4, 5, 6\] julia\> x .- \[1, 2, 3\] ERROR: DimensionMismatch: arrays could not be broadcast to …

---

## [\`stacktrace()\` giving back wrong files for some of the frames](https://discourse.julialang.org/t/stacktrace-giving-back-wrong-files-for-some-of-the-frames/97075)

<div class="topic-metadata">

**Author:** [@ashton314](https://discourse.julialang.org/u/ashton314)\
**Replies:** 0\
**Last updated:** [April 4, 2023, 5:50pm UTC](https://discourse.julialang.org/t/stacktrace-giving-back-wrong-files-for-some-of-the-frames/97075 "2023-04-04T17:50:44Z")

</div>

Hi all! I’m noticing some odd behavior around collecting stack traces. When I call stacktrace() I get some frames that look like this: injectable\_region : /Users/ashton/.julia/dev/FloatTracker/src/Injector.jl:164 shou…

---

## [Eltype of structs containing true or false values](https://discourse.julialang.org/t/eltype-of-structs-containing-true-or-false-values/97024)

<div class="topic-metadata">

**Author:** [@Janssena](https://discourse.julialang.org/u/Janssena)\
**Replies:** 12\
**Last updated:** [April 4, 2023, 4:57pm UTC](https://discourse.julialang.org/t/eltype-of-structs-containing-true-or-false-values/97024 "2023-04-04T16:57:46Z")

</div>

Hey All, I am creating a struct and a corresponding iterable. I want to make the eltype of the iterable more specific but am running into an issue since part of the eltype of my struct is true / false: simple example: …

---

## [Pre-allocation for matrices / vectors of matrices of different length](https://discourse.julialang.org/t/pre-allocation-for-matrices-vectors-of-matrices-of-different-length/97071)

<div class="topic-metadata">

**Author:** [@Antomek](https://discourse.julialang.org/u/Antomek)\
**Replies:** 3\
**Last updated:** [April 4, 2023, 4:43pm UTC](https://discourse.julialang.org/t/pre-allocation-for-matrices-vectors-of-matrices-of-different-length/97071 "2023-04-04T16:43:29Z")

</div>

Hi all, I am doing a bunch of simulations, and I want to save the outcome of these N simulations My parameters for each simulation is a p of type Vector{Matrix{Float32}}, and there are M vectors X, Y that I’d like to …

---

## [Expected "end" error while loading a module](https://discourse.julialang.org/t/expected-end-error-while-loading-a-module/97059)

<div class="topic-metadata">

**Author:** [@Sh\_166](https://discourse.julialang.org/u/Sh_166)\
**Replies:** 2\
**Last updated:** [April 4, 2023, 1:45pm UTC](https://discourse.julialang.org/t/expected-end-error-while-loading-a-module/97059 "2023-04-04T13:45:15Z")

</div>

I am having the following problem loading a module: LoadError: syntax: "module" at C:\\Users\\shiha\\LyapunovExponentsWithForwardDiff.jl:1 expected "end", got "LyapunovExponentsResult" in expression starting at C:\\Users\\sh…

---

## [What type to use for 2D arrays in ccall](https://discourse.julialang.org/t/what-type-to-use-for-2d-arrays-in-ccall/97060)

<div class="topic-metadata">

**Author:** [@Alseidon](https://discourse.julialang.org/u/Alseidon)\
**Replies:** 2\
**Last updated:** [April 4, 2023, 12:09pm UTC](https://discourse.julialang.org/t/what-type-to-use-for-2d-arrays-in-ccall/97060 "2023-04-04T12:09:11Z")

</div>

I am experimenting with calls to C functions, and got a bit puzzled when using multi-dimensional arrays as parameters. I have this bit of C code in cfile.c: void f(double array\[2\]\[2\]) { array\[1\]\[1\] = 42.; retur…

---

## [NLSolver speed](https://discourse.julialang.org/t/nlsolver-speed/97057)

<div class="topic-metadata">

**Author:** [@larsudb](https://discourse.julialang.org/u/larsudb)\
**Replies:** 0\
**Last updated:** [April 4, 2023, 10:20am UTC](https://discourse.julialang.org/t/nlsolver-speed/97057 "2023-04-04T10:20:38Z")

</div>

I have written a code for a lid-driven square cavity within gridap and am wondering if the solve time can be decreased easily. using Gridap using LineSearches: BackTracking using TickTock using WriteVTK n = 100 dom…

---

## [Forward Diff and Matrix Operations](https://discourse.julialang.org/t/forward-diff-and-matrix-operations/97042)

<div class="topic-metadata">

**Author:** [@JHall](https://discourse.julialang.org/u/JHall)\
**Replies:** 2\
**Last updated:** [April 4, 2023, 9:29am UTC](https://discourse.julialang.org/t/forward-diff-and-matrix-operations/97042 "2023-04-04T09:29:10Z")

</div>

Hi all, I am new to ForwardDiff and coding up a simple example of minimum distance estimation. I would ideally like to be able to set up the problem in the traditional way of: \[distance between parameter implied momen…

---

## [Distributions fit\_mle of distribution type vs distributions with parameters](https://discourse.julialang.org/t/distributions-fit-mle-of-distribution-type-vs-distributions-with-parameters/75228)

<div class="topic-metadata">

**Author:** [@dmetivie](https://discourse.julialang.org/u/dmetivie)\
**Replies:** 6\
**Last updated:** [April 4, 2023, 8:53am UTC](https://discourse.julialang.org/t/distributions-fit-mle-of-distribution-type-vs-distributions-with-parameters/75228 "2023-04-04T08:53:24Z")

</div>

I try the following, but it does not work. using Distributions p = 0.2 x = rand(Bernoulli(0.2),50) fit\_mle(Bernoulli(p), x) MethodError: no method matching fit\_mle(::Bernoulli{Float64}, ::Vector{Bool}) I know that fi…

---

## [How can I pre-allocate a dict?](https://discourse.julialang.org/t/how-can-i-pre-allocate-a-dict/97000)

<div class="topic-metadata">

**Author:** [@zhijie\_sun](https://discourse.julialang.org/u/zhijie_sun)\
**Replies:** 5\
**Last updated:** [April 4, 2023, 3:23am UTC](https://discourse.julialang.org/t/how-can-i-pre-allocate-a-dict/97000 "2023-04-04T03:23:16Z")

</div>

I have a function 1, contain allocation of some small dict, about two dict with less than 10 elements. And I have function 2 call this function 1 in a for loop about 2^12 times. Then I have call function 2 in a for loop …

---

## [How to load packages in a for loop?](https://discourse.julialang.org/t/how-to-load-packages-in-a-for-loop/97021)

<div class="topic-metadata">

**Author:** [@Hugo](https://discourse.julialang.org/u/Hugo)\
**Replies:** 8\
**Last updated:** [April 3, 2023, 10:12pm UTC](https://discourse.julialang.org/t/how-to-load-packages-in-a-for-loop/97021 "2023-04-03T22:12:23Z")

</div>

I have a Julia project that is growing in number of files. To break it into smaller and easier-to-manage files, I want to have a .jl where I keep a list of all packages required by the project. Then, I will use a for lo…

---

## [How to intercept module variable getting and setting in Julia 1.8 similar to getproperty and setproperty! for structures?](https://discourse.julialang.org/t/how-to-intercept-module-variable-getting-and-setting-in-julia-1-8-similar-to-getproperty-and-setproperty-for-structures/97026)

<div class="topic-metadata">

**Author:** [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Replies:** 6\
**Last updated:** [April 3, 2023, 8:16pm UTC](https://discourse.julialang.org/t/how-to-intercept-module-variable-getting-and-setting-in-julia-1-8-similar-to-getproperty-and-setproperty-for-structures/97026 "2023-04-03T20:16:08Z")

</div>

Please help, how to intercept get and set variable of module in Julia 1.8 ? julia\> module M end; julia\> # in julia 1.9 i can do this: julia\> function Base.setproperty!(m::Module, p::Symbol, v) println("varia…

---

## [Plots breaks incremental compilation](https://discourse.julialang.org/t/plots-breaks-incremental-compilation/96990)

<div class="topic-metadata">

**Author:** [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Replies:** 6\
**Last updated:** [April 3, 2023, 7:40pm UTC](https://discourse.julialang.org/t/plots-breaks-incremental-compilation/96990 "2023-04-03T19:40:00Z")

</div>

I haven’t managed to produce a MWE yet but I’m hoping someone has encountered a similar problem and can advise. Basically I am writing a PackageB that uses RecipesBase, and a PackageA that uses both PackageB and Plots.j…

---

## [Set "0 degree" location in Polar plot?](https://discourse.julialang.org/t/set-0-degree-location-in-polar-plot/96947)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 2\
**Last updated:** [April 3, 2023, 5:54pm UTC](https://discourse.julialang.org/t/set-0-degree-location-in-polar-plot/96947 "2023-04-03T17:54:16Z")

</div>

Hello! In Matlab one can very easily do: Which basically rotates your plot, so that in this case the Theta Zero Location is at the top. How would I do the same thing in Julia? Kind regards

---

## [How to read Parquet files using Parquet2 in a multi-folder structure?](https://discourse.julialang.org/t/how-to-read-parquet-files-using-parquet2-in-a-multi-folder-structure/96957)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 1\
**Last updated:** [April 3, 2023, 5:53pm UTC](https://discourse.julialang.org/t/how-to-read-parquet-files-using-parquet2-in-a-multi-folder-structure/96957 "2023-04-03T17:53:19Z")

</div>

Hello! Suppose I have a folder structure given as: TopFolder A B C Where parquet files are stored inside of A,B and C. I know that if I do: Parquet2.Dataset("TopFolder") Then it will have access to all the parque…

---

## [Weird memory allocation when passing functions as keyword arguments](https://discourse.julialang.org/t/weird-memory-allocation-when-passing-functions-as-keyword-arguments/96920)

<div class="topic-metadata">

**Author:** [@sunoru](https://discourse.julialang.org/u/sunoru)\
**Replies:** 6\
**Last updated:** [April 3, 2023, 3:01pm UTC](https://discourse.julialang.org/t/weird-memory-allocation-when-passing-functions-as-keyword-arguments/96920 "2023-04-03T15:01:28Z")

</div>

I was trying to understand the cause of some unexpected memory allocations and found the program has the following strange behaviors. I am really confused and hope someone can help me figure it out, thanks! I tested on 1…

---

## [Multiple modules in single package](https://discourse.julialang.org/t/multiple-modules-in-single-package/5615)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 15\
**Last updated:** [April 3, 2023, 2:59pm UTC](https://discourse.julialang.org/t/multiple-modules-in-single-package/5615 "2023-04-03T14:59:21Z")

</div>

I found that a rather short function I use in the unit tests of a package would be useful somewhere else. If I don’t want to make a separate package for it, is it possible to put it in a separate module in the same packa…

---

## [Permutedims not working correctly with NamedArray where names are symbols](https://discourse.julialang.org/t/permutedims-not-working-correctly-with-namedarray-where-names-are-symbols/97014)

<div class="topic-metadata">

**Author:** [@Mitch\_Phillipson](https://discourse.julialang.org/u/Mitch_Phillipson)\
**Replies:** 1\
**Last updated:** [April 3, 2023, 2:39pm UTC](https://discourse.julialang.org/t/permutedims-not-working-correctly-with-namedarray-where-names-are-symbols/97014 "2023-04-03T14:39:35Z")

</div>

I’m trying to permute the dimensions of a NamedArray where the names are symbols. However, I’m getting “Method Error: Cannot convert an object of type String to an object of type Symbol” Here is an example of the code I…

---

## ["Packaging" dependencies into a sysimage](https://discourse.julialang.org/t/packaging-dependencies-into-a-sysimage/96548)

<div class="topic-metadata">

**Author:** [@sstroemer](https://discourse.julialang.org/u/sstroemer)\
**Replies:** 4\
**Last updated:** [April 3, 2023, 1:29pm UTC](https://discourse.julialang.org/t/packaging-dependencies-into-a-sysimage/96548 "2023-04-03T13:29:50Z")

</div>

Based on the tutorial of PackageCompiler.jl, I am using the following to create a sysimage: julia --project=. \_create\_sysimage.jl. That file contains: \_create\_sysimage.jl: import Pkg Pkg.add("PackageCompiler") Pkg.add(…

---

## [XLSX.DataTable error](https://discourse.julialang.org/t/xlsx-datatable-error/96993)

<div class="topic-metadata">

**Author:** [@Leon6](https://discourse.julialang.org/u/Leon6)\
**Replies:** 3\
**Last updated:** [April 3, 2023, 12:17pm UTC](https://discourse.julialang.org/t/xlsx-datatable-error/96993 "2023-04-03T12:17:33Z")

</div>

My script was running OK while on Julia V1.7. I recently upgraded my Julia to V1.8.5, now I have trouble reading info out of xlsx files. Would anyone please help me out? Here are the errors: ERROR: LoadError: MethodErr…

---

## [Argument type of higher order functions](https://discourse.julialang.org/t/argument-type-of-higher-order-functions/96989)

<div class="topic-metadata">

**Author:** [@empet](https://discourse.julialang.org/u/empet)\
**Replies:** 4\
**Last updated:** [April 3, 2023, 8:21am UTC](https://discourse.julialang.org/t/argument-type-of-higher-order-functions/96989 "2023-04-03T08:21:17Z")

</div>

If I define: function myfunc(f::T, g::T; b=2.5 ) where T\<:Function #some lines here h(t) = b\*(f(t) +g(t)^2) end f(t; a=2)=a\*t g(t; a=3)=a+exp(t) h=myfunc(f, g) h(1.3) it is thrown the error: MethodError: no me…

---

## [Suggestions needed: diagonalizing large Hermitian sparse matrix](https://discourse.julialang.org/t/suggestions-needed-diagonalizing-large-hermitian-sparse-matrix/96580)

<div class="topic-metadata">

**Author:** [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)\
**Replies:** 4\
**Last updated:** [April 3, 2023, 6:03am UTC](https://discourse.julialang.org/t/suggestions-needed-diagonalizing-large-hermitian-sparse-matrix/96580 "2023-04-03T06:03:37Z")

</div>

I need to find a few eigenvalues and eigenvectors of some large Hermitian sparse matrices. Right now, I am trying Arpack.jl and KrylovKit.jl. Here are some considerations and my experiences. Arpack.jl does not have sp…

---

## [Eigenvalues without sorting LinearAlgrebra.jl](https://discourse.julialang.org/t/eigenvalues-without-sorting-linearalgrebra-jl/96997)

<div class="topic-metadata">

**Author:** [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)\
**Replies:** 6\
**Last updated:** [April 3, 2023, 5:37am UTC](https://discourse.julialang.org/t/eigenvalues-without-sorting-linearalgrebra-jl/96997 "2023-04-03T05:37:41Z")

</div>

Hello! I calculate the equilibrium points for a continuous dynamical system and then calculate it eigenvalues. I don’t need to sort these eigenvalues, otherwise I’ll have to literally search through all the phase variab…

---

## [Using a C++ project in Julia which depends on external libraries](https://discourse.julialang.org/t/using-a-c-project-in-julia-which-depends-on-external-libraries/96995)

<div class="topic-metadata">

**Author:** [@Zachary\_Landry](https://discourse.julialang.org/u/Zachary_Landry)\
**Replies:** 0\
**Last updated:** [April 3, 2023, 3:13am UTC](https://discourse.julialang.org/t/using-a-c-project-in-julia-which-depends-on-external-libraries/96995 "2023-04-03T03:13:45Z")

</div>

I am attempting to allow Julia to use a C++ 3D modeling utility. I have seen examples of running C++ code in Julia using CxxWrap, CxxInterface, etc. but the project I am trying to use depends on an external library (Open…

---

## [How to import a certain module from a package](https://discourse.julialang.org/t/how-to-import-a-certain-module-from-a-package/96963)

<div class="topic-metadata">

**Author:** [@dmtrung14](https://discourse.julialang.org/u/dmtrung14)\
**Replies:** 5\
**Last updated:** [April 2, 2023, 10:23pm UTC](https://discourse.julialang.org/t/how-to-import-a-certain-module-from-a-package/96963 "2023-04-02T22:23:48Z")

</div>

I was trying to import a module from a package to illustrate, using package.ABC: submodule1, submodule2, ... But then when I applied tests to it, it returns: UndefVarError: ABC not defined. How do I go about resolvi…

---

## [Replace symbols within an expression](https://discourse.julialang.org/t/replace-symbols-within-an-expression/96966)

<div class="topic-metadata">

**Author:** [@weymouth](https://discourse.julialang.org/u/weymouth)\
**Replies:** 3\
**Last updated:** [April 2, 2023, 9:48pm UTC](https://discourse.julialang.org/t/replace-symbols-within-an-expression/96966 "2023-04-02T21:48:53Z")

</div>

I want to take an expression like :(structOne.a\[I\] = tanh(structTwo.b\[I\])) and replace all the composite values with other variables so I can make a function like function f(I,a\_new,b\_new) # can't use composite values…

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

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