# General Usage

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

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

**Page:** 166

---

## [Idiom for related types?](https://discourse.julialang.org/t/idiom-for-related-types/114706)

<div class="topic-metadata">

**Author:** [@slawrence](https://discourse.julialang.org/u/slawrence)\
**Replies:** 5\
**Last updated:** [May 24, 2024, 10:40pm UTC](https://discourse.julialang.org/t/idiom-for-related-types/114706 "2024-05-24T22:40:22Z")

</div>

Short version: I want something that serves the role of “methods for structs”, where the content of the struct depends nontrivially on the parameter (just as the content of a method can depend on the type of an argument…

---

## [Is there a way to make a Set of Types that all inherit from a supertype?](https://discourse.julialang.org/t/is-there-a-way-to-make-a-set-of-types-that-all-inherit-from-a-supertype/114705)

<div class="topic-metadata">

**Author:** [@AwesomeQuest](https://discourse.julialang.org/u/AwesomeQuest)\
**Replies:** 1\
**Last updated:** [May 24, 2024, 10:04pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-make-a-set-of-types-that-all-inherit-from-a-supertype/114705 "2024-05-24T22:04:59Z")

</div>

For instance a Set that contains Integer types like UInt8, Int64, and so on. Or a Set that contains Exception types. First instinct would be Set{Type{Exception}}() But that can only store the type Exception You can u…

---

## [Allocations in sparse matrices](https://discourse.julialang.org/t/allocations-in-sparse-matrices/114540)

<div class="topic-metadata">

**Author:** [@clopen](https://discourse.julialang.org/u/clopen)\
**Replies:** 6\
**Last updated:** [May 24, 2024, 8:45pm UTC](https://discourse.julialang.org/t/allocations-in-sparse-matrices/114540 "2024-05-24T20:45:38Z")

</div>

Hello, I have a code where I use ‘normal’ (Array{Float64,2 } type) matrices and SparseMatrixCSC{Float64} matrices. Lets say A::SparseMatrixCSC{Float64} = sparse(1.0I, 100, 100) a::Float64 = 2.0 If I create other matric…

---

## [Iterator yielding tuples vs arrays](https://discourse.julialang.org/t/iterator-yielding-tuples-vs-arrays/114686)

<div class="topic-metadata">

**Author:** [@Marco-Congedo](https://discourse.julialang.org/u/Marco-Congedo)\
**Replies:** 11\
**Last updated:** [May 24, 2024, 6:17pm UTC](https://discourse.julialang.org/t/iterator-yielding-tuples-vs-arrays/114686 "2024-05-24T18:17:07Z")

</div>

This iterator yields n=3 P=Iterators.product(((1, -1) for i=1:n)...) foreach(println, P) (1, 1, 1) (-1, 1, 1) (1, -1, 1) (-1, -1, 1) (1, 1, -1) (-1, 1, -1) (1, -1, -1) (-1, -1, -1) which is what i need for…

---

## [Distributed Computing addprocs onto password enabled ssh connection](https://discourse.julialang.org/t/distributed-computing-addprocs-onto-password-enabled-ssh-connection/114543)

<div class="topic-metadata">

**Author:** [@Teodor\_Tchalakov](https://discourse.julialang.org/u/Teodor_Tchalakov)\
**Replies:** 3\
**Last updated:** [May 24, 2024, 5:15pm UTC](https://discourse.julialang.org/t/distributed-computing-addprocs-onto-password-enabled-ssh-connection/114543 "2024-05-24T17:15:58Z")

</div>

I am attempting to use Distributed.jl to add processes using the SSHManager to a Windows device with an administrative user account that has a password. I am able to run addprocs(\[user@hostname\], :auto), which connects t…

---

## [Macro for implicitly defined NamedTuples](https://discourse.julialang.org/t/macro-for-implicitly-defined-namedtuples/114685)

<div class="topic-metadata">

**Author:** [@pablosanjose](https://discourse.julialang.org/u/pablosanjose)\
**Replies:** 4\
**Last updated:** [May 24, 2024, 5:10pm UTC](https://discourse.julialang.org/t/macro-for-implicitly-defined-namedtuples/114685 "2024-05-24T17:10:32Z")

</div>

I want to write a macro imp that does this julia\> @imp(; a = 2, b = a^2, c = 3) (; a = 2, b = 4, c = 3) Not being any good with metaprogramming I turn to the Julia community: Is there any package that already achiev…

---

## [Passing large julia struct to c](https://discourse.julialang.org/t/passing-large-julia-struct-to-c/114662)

<div class="topic-metadata">

**Author:** [@vincentliu](https://discourse.julialang.org/u/vincentliu)\
**Replies:** 20\
**Last updated:** [May 24, 2024, 3:05pm UTC](https://discourse.julialang.org/t/passing-large-julia-struct-to-c/114662 "2024-05-24T15:05:25Z")

</div>

Hello, I want to pass an extremely large struct to c interface. For example mutable struct LargeStruct size::UInt32 data::NTuple{1024\*1024\*4,UInt32} end And when I try to create such a large struct, stack overf…

---

## [Compilation latency with constant propagation and unreachable branches](https://discourse.julialang.org/t/compilation-latency-with-constant-propagation-and-unreachable-branches/114667)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 7\
**Last updated:** [May 24, 2024, 2:44pm UTC](https://discourse.julialang.org/t/compilation-latency-with-constant-propagation-and-unreachable-branches/114667 "2024-05-24T14:44:46Z")

</div>

With julia\> function f(a, b) if a == 1 return b \* b elseif a == 2 return b \* b' elseif a == 3 return b' \* b else re…

---

## [Stiff VS Non-stiff methods: Differing solutions](https://discourse.julialang.org/t/stiff-vs-non-stiff-methods-differing-solutions/114664)

<div class="topic-metadata">

**Author:** [@Sh\_166](https://discourse.julialang.org/u/Sh_166)\
**Replies:** 9\
**Last updated:** [May 24, 2024, 2:44pm UTC](https://discourse.julialang.org/t/stiff-vs-non-stiff-methods-differing-solutions/114664 "2024-05-24T14:44:25Z")

</div>

Apologies if there has been a trivial mistake or otherwise in what follows. MWE: using Symbolics, Plots, DifferentialEquations, ModelingToolkit, LaTeXStrings, Measures, DynamicalSystems function forced\_osc!(du, u, p,…

---

## [Unitful.jl: type matching dimensions](https://discourse.julialang.org/t/unitful-jl-type-matching-dimensions/114676)

<div class="topic-metadata">

**Author:** [@Joh11](https://discourse.julialang.org/u/Joh11)\
**Replies:** 2\
**Last updated:** [May 24, 2024, 1:51pm UTC](https://discourse.julialang.org/t/unitful-jl-type-matching-dimensions/114676 "2024-05-24T13:51:59Z")

</div>

Hi, Up until now, I have only used Unitful for basic conversion, however I would like now to use it for type checking. However, I cannot make it work. I want ensure (with type safety) that a given variable is an array …

---

## [Is it possible to use environmental variables in YAML.jl?](https://discourse.julialang.org/t/is-it-possible-to-use-environmental-variables-in-yaml-jl/114565)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 4\
**Last updated:** [May 24, 2024, 10:29am UTC](https://discourse.julialang.org/t/is-it-possible-to-use-environmental-variables-in-yaml-jl/114565 "2024-05-24T10:29:25Z")

</div>

I would like to store relative paths in my YAML file. Googling, I saw that the way to do it in other languages is to use environmental variables. So I did try with: scenario\_path = "/some/path/" settings\_path = joinpa…

---

## [Current best practices for Julia dependencies in Python packages](https://discourse.julialang.org/t/current-best-practices-for-julia-dependencies-in-python-packages/109433)

<div class="topic-metadata">

**Author:** [@moble](https://discourse.julialang.org/u/moble)\
**Replies:** 12\
**Last updated:** [May 24, 2024, 10:09am UTC](https://discourse.julialang.org/t/current-best-practices-for-julia-dependencies-in-python-packages/109433 "2024-05-24T10:09:46Z")

</div>

I have a python package that a lot of colleagues use, and I have a julia package that does some of the same things vastly better, so I’d like to use it from the python package, as an optional install. I’m not too worrie…

---

## [Save best model in FluxTraining.jl](https://discourse.julialang.org/t/save-best-model-in-fluxtraining-jl/114591)

<div class="topic-metadata">

**Author:** [@cirobr](https://discourse.julialang.org/u/cirobr)\
**Replies:** 4\
**Last updated:** [May 24, 2024, 8:54am UTC](https://discourse.julialang.org/t/save-best-model-in-fluxtraining-jl/114591 "2024-05-24T08:54:12Z")

</div>

Cheers, is there a built-in way with fit! to save the model parameters (or model state) after each epoch? What about saving the best model only? Thanks in advance.

---

## [How bad is it if x \< y doesn't return a Bool?](https://discourse.julialang.org/t/how-bad-is-it-if-x-y-doesnt-return-a-bool/114611)

<div class="topic-metadata">

**Author:** [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Replies:** 22\
**Last updated:** [May 24, 2024, 6:30am UTC](https://discourse.julialang.org/t/how-bad-is-it-if-x-y-doesnt-return-a-bool/114611 "2024-05-24T06:30:27Z")

</div>

Suppose I define a number type T for which order comparison is not meaningful: \<(x::T, y::T) doesn’t make any mathematical sense, because T actually contains a set. There are good reasons why I’m doing this, see SparseCo…

---

## [Enter numbers in grid of GameZero board](https://discourse.julialang.org/t/enter-numbers-in-grid-of-gamezero-board/114657)

<div class="topic-metadata">

**Author:** [@raman\_kumar](https://discourse.julialang.org/u/raman_kumar)\
**Replies:** 0\
**Last updated:** [May 24, 2024, 5:41am UTC](https://discourse.julialang.org/t/enter-numbers-in-grid-of-gamezero-board/114657 "2024-05-24T05:41:14Z")

</div>

How to type/insert number in grid of GameZero.jl board? I will use keyboard to enter numbers in grid blocks. Is there any function in GameZero.jl to make possible to enter numbers in grid?

---

## [Example of Documenter Vitepress on GitLab?](https://discourse.julialang.org/t/example-of-documenter-vitepress-on-gitlab/114079)

<div class="topic-metadata">

**Author:** [@jling](https://discourse.julialang.org/u/jling)\
**Replies:** 1\
**Last updated:** [May 24, 2024, 3:35am UTC](https://discourse.julialang.org/t/example-of-documenter-vitepress-on-gitlab/114079 "2024-05-24T03:35:30Z")

</div>

As the title says, is there example of deploying Vitepress powered doccs on GitLab pages?

---

## [Parameters modified by events are not captured in ODE the solution](https://discourse.julialang.org/t/parameters-modified-by-events-are-not-captured-in-ode-the-solution/114592)

<div class="topic-metadata">

**Author:** [@valerdam](https://discourse.julialang.org/u/valerdam)\
**Replies:** 1\
**Last updated:** [May 23, 2024, 9:23pm UTC](https://discourse.julialang.org/t/parameters-modified-by-events-are-not-captured-in-ode-the-solution/114592 "2024-05-23T21:23:23Z")

</div>

It seems that parameters modified by callback events are not captured as time dependent in the ODE solution. Using a slight modification of the example in here, parameter k changes from 1.0 to 5.0 at time t=5. However t…

---

## [Basic function usage in Query @filter](https://discourse.julialang.org/t/basic-function-usage-in-query-filter/114642)

<div class="topic-metadata">

**Author:** [@seadoo](https://discourse.julialang.org/u/seadoo)\
**Replies:** 9\
**Last updated:** [May 23, 2024, 9:04pm UTC](https://discourse.julialang.org/t/basic-function-usage-in-query-filter/114642 "2024-05-23T21:04:00Z")

</div>

Is the @filter macro from Query.jl only useful for simple things like \_.a \> 1 and so on? I’ve tried to use ismissing which just returns a boolean and it does not return anything (but also does not return any errors). Br…

---

## [What is \`Ei\` in SymPy.jl?](https://discourse.julialang.org/t/what-is-ei-in-sympy-jl/114636)

<div class="topic-metadata">

**Author:** [@pgbarletta](https://discourse.julialang.org/u/pgbarletta)\
**Replies:** 2\
**Last updated:** [May 23, 2024, 7:18pm UTC](https://discourse.julialang.org/t/what-is-ei-in-sympy-jl/114636 "2024-05-23T19:18:06Z")

</div>

I tried to get this integral: @syms r::real a::real fff = integrate((1/r)\*exp(-2\*a\*r), (r)) and got this: what’s that Ei?

---

## [How to create the set of variables as a matrix in stead of vector?](https://discourse.julialang.org/t/how-to-create-the-set-of-variables-as-a-matrix-in-stead-of-vector/114638)

<div class="topic-metadata">

**Author:** [@Ethan\_Tran](https://discourse.julialang.org/u/Ethan_Tran)\
**Replies:** 2\
**Last updated:** [May 23, 2024, 6:29pm UTC](https://discourse.julialang.org/t/how-to-create-the-set-of-variables-as-a-matrix-in-stead-of-vector/114638 "2024-05-23T18:29:22Z")

</div>

I have used the ModelingToolkit, DifferentialEquations, and OrdinaryDiffEq packages to solve the ODE system. In the past, I have implemented the set of variables x as a vector like: @variables (x(t))\[1:m\] Is there any…

---

## [How to avoid containers of abstract parametric types?](https://discourse.julialang.org/t/how-to-avoid-containers-of-abstract-parametric-types/114583)

<div class="topic-metadata">

**Author:** [@AUK1939](https://discourse.julialang.org/u/AUK1939)\
**Replies:** 12\
**Last updated:** [May 23, 2024, 3:14pm UTC](https://discourse.julialang.org/t/how-to-avoid-containers-of-abstract-parametric-types/114583 "2024-05-23T15:14:02Z")

</div>

I have defined a set of structs representing various financial instruments abstract type Asset end mutable struct Stock \<: Asset symbol::String company::Int64 end mutable struct Bond \<: Asset symbol::Strin…

---

## [A \\ b as Vector{SVector} when b is static along one dimension](https://discourse.julialang.org/t/a-b-as-vector-svector-when-b-is-static-along-one-dimension/114606)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 2\
**Last updated:** [May 23, 2024, 2:00pm UTC](https://discourse.julialang.org/t/a-b-as-vector-svector-when-b-is-static-along-one-dimension/114606 "2024-05-23T14:00:41Z")

</div>

I would like to calculate A \\ b where A is NxN, b is a vector of SVectors that is viewed as a matrix. I want the result to be a Vector{SVector} analogously. MWE for setup: using LinearAlgebra, StaticArrays M = 3 N = 10…

---

## [Zlib error](https://discourse.julialang.org/t/zlib-error/114600)

<div class="topic-metadata">

**Author:** [@mohammad\_amini](https://discourse.julialang.org/u/mohammad_amini)\
**Replies:** 1\
**Last updated:** [May 23, 2024, 8:28am UTC](https://discourse.julialang.org/t/zlib-error/114600 "2024-05-23T08:28:28Z")

</div>

Hi, I ran a code twice and the first time everything was ok, the second time I encountered this error message. Do you know what the problem is? error message: zlib error: (code: -5)

---

## [Write to file and stdout](https://discourse.julialang.org/t/write-to-file-and-stdout/35042)

<div class="topic-metadata">

**Author:** [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Replies:** 12\
**Last updated:** [May 23, 2024, 8:12am UTC](https://discourse.julialang.org/t/write-to-file-and-stdout/35042 "2024-05-23T08:12:36Z")

</div>

I have a number of println statements in a script. I know I can also do println(io,blah) to write to a file. When I do that, output no longer goes to stdout. Can I do both at once?

---

## [Integer equivalent of \`e\` notation](https://discourse.julialang.org/t/integer-equivalent-of-e-notation/114605)

<div class="topic-metadata">

**Author:** [@Alec\_Loudenback](https://discourse.julialang.org/u/Alec_Loudenback)\
**Replies:** 1\
**Last updated:** [May 23, 2024, 4:22am UTC](https://discourse.julialang.org/t/integer-equivalent-of-e-notation/114605 "2024-05-23T04:22:51Z")

</div>

Is there an integer equivalent for powers of 10 like there is for floating point? For example, 7e9 is 7000000000.0. Is there a shorthand for integers?

---

## [Broadcasting functions with multiple arguments in same dimension using Mapslices](https://discourse.julialang.org/t/broadcasting-functions-with-multiple-arguments-in-same-dimension-using-mapslices/114586)

<div class="topic-metadata">

**Author:** [@chihlun](https://discourse.julialang.org/u/chihlun)\
**Replies:** 14\
**Last updated:** [May 22, 2024, 11:41pm UTC](https://discourse.julialang.org/t/broadcasting-functions-with-multiple-arguments-in-same-dimension-using-mapslices/114586 "2024-05-22T23:41:42Z")

</div>

Hi everyone, I have a simple code as shown below. Both a and y are 4D matrices. I want the function f(x, y) to operate on the third dimension, summing the x matrix along the 3rd dimension, summing the y matrix along the…

---

## [How to add a specific PR of a package to an environment using Pkg](https://discourse.julialang.org/t/how-to-add-a-specific-pr-of-a-package-to-an-environment-using-pkg/114585)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 2\
**Last updated:** [May 22, 2024, 5:19pm UTC](https://discourse.julialang.org/t/how-to-add-a-specific-pr-of-a-package-to-an-environment-using-pkg/114585 "2024-05-22T17:19:28Z")

</div>

I think someone said this should be possible. There is a specific PR of a package (bring back TermInterface by shashi · Pull Request #598 · JuliaSymbolics/SymbolicUtils.jl · GitHub) which I would like to try out locally…

---

## [Can I customize tooltip in Plots using Plotly backend?](https://discourse.julialang.org/t/can-i-customize-tooltip-in-plots-using-plotly-backend/114577)

<div class="topic-metadata">

**Author:** [@Josa9321](https://discourse.julialang.org/u/Josa9321)\
**Replies:** 0\
**Last updated:** [May 22, 2024, 2:47pm UTC](https://discourse.julialang.org/t/can-i-customize-tooltip-in-plots-using-plotly-backend/114577 "2024-05-22T14:47:01Z")

</div>

Hi, Is there any way to customize the tooltip message in Plots using Plotly backend? For instance, I have the example below. using Plots plotly(ticks=:native) my\_plot = plot(\[1, 2, 4\], \[3, 4, 10\], title="Meu gráfico")…

---

## [\`hasmethod\` with a "wildcard"](https://discourse.julialang.org/t/hasmethod-with-a-wildcard/114578)

<div class="topic-metadata">

**Author:** [@mrufsvold](https://discourse.julialang.org/u/mrufsvold)\
**Replies:** 2\
**Last updated:** [May 22, 2024, 2:58pm UTC](https://discourse.julialang.org/t/hasmethod-with-a-wildcard/114578 "2024-05-22T14:58:18Z")

</div>

I’d like to check if a type has iterate defined. Of course, iterate needs two methods – iterate(::T) and iterate(::T, state). julia\> hasmethod(iterate, (Vector{Int}, Any)) true julia\> hasmethod(iterate, (Tuple{Int}, An…

---

## [Persistent hash](https://discourse.julialang.org/t/persistent-hash/110001)

<div class="topic-metadata">

**Author:** [@Barvid](https://discourse.julialang.org/u/Barvid)\
**Replies:** 7\
**Last updated:** [May 22, 2024, 2:45pm UTC](https://discourse.julialang.org/t/persistent-hash/110001 "2024-05-22T14:45:09Z")

</div>

Hello everybody I work with continually updated time series and do intensive calculations on that. Say data is in vector x. Sometimes some part of old data changes when an instrument is recalibrated and I need re-do old…

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

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