# General Usage

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

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

**Page:** 908

---

## [Usage of "empty" structs](https://discourse.julialang.org/t/usage-of-empty-structs/18968)

<div class="topic-metadata">

**Author:** [@affans](https://discourse.julialang.org/u/affans)\
**Replies:** 4\
**Last updated:** [December 25, 2018, 4:36am UTC](https://discourse.julialang.org/t/usage-of-empty-structs/18968 "2018-12-25T04:36:55Z")

</div>

Often in packages and Julia source code, I see structs that have no field. For example, abstract type RangeStepStyle end struct RangeStepRegular &lt;: RangeStepStyle end # range with regular step struct RangeStepIrregul…

---

## [Loop Fusion usage between Arrays of custom structs](https://discourse.julialang.org/t/loop-fusion-usage-between-arrays-of-custom-structs/18969)

<div class="topic-metadata">

**Author:** [@algebrato](https://discourse.julialang.org/u/algebrato)\
**Replies:** 1\
**Last updated:** [December 25, 2018, 4:04am UTC](https://discourse.julialang.org/t/loop-fusion-usage-between-arrays-of-custom-structs/18969 "2018-12-25T04:04:45Z")

</div>

Hello, Is possible to use the Loop Fusion between arrays of custom defined structures? For example: struct point{T} x::T y::T end x = rand(100) y = rand(100) p = point{Array{Float64,1}}(x,y) at this point I cre…

---

## [Juno/atom keyboard shortcut for run julia file](https://discourse.julialang.org/t/juno-atom-keyboard-shortcut-for-run-julia-file/2412)

<div class="topic-metadata">

**Author:** [@JeffBApollo](https://discourse.julialang.org/u/JeffBApollo)\
**Replies:** 2\
**Last updated:** [December 25, 2018, 3:10am UTC](https://discourse.julialang.org/t/juno-atom-keyboard-shortcut-for-run-julia-file/2412 "2018-12-25T03:10:00Z")

</div>

It looks like ctrl-shift-enter should do it but nothing happens. I’m on Win7 Settings Keybindings says this: ctrl-shift-enter julia-client:run-file Julia Client .platform-win32 .item-views \> atom-text-editor\[data-gram…

---

## [Modifying a sparse matrix non-zero indices](https://discourse.julialang.org/t/modifying-a-sparse-matrix-non-zero-indices/18950)

<div class="topic-metadata">

**Author:** [@xor0110](https://discourse.julialang.org/u/xor0110)\
**Replies:** 1\
**Last updated:** [December 25, 2018, 1:30am UTC](https://discourse.julialang.org/t/modifying-a-sparse-matrix-non-zero-indices/18950 "2018-12-25T01:30:07Z")

</div>

I’m working in a problem where I have a sparse Jacobian matrix with 16 values in each row. I would like to update the matrix by just modifying its non-zero values. The problem is I would like to update both the non-zero …

---

## [How to search the AST for specific types and functions?](https://discourse.julialang.org/t/how-to-search-the-ast-for-specific-types-and-functions/18934)

<div class="topic-metadata">

**Author:** [@ArjunNarayanan](https://discourse.julialang.org/u/ArjunNarayanan)\
**Replies:** 7\
**Last updated:** [December 25, 2018, 1:15am UTC](https://discourse.julialang.org/t/how-to-search-the-ast-for-specific-types-and-functions/18934 "2018-12-25T01:15:53Z")

</div>

Motivation I am writing a simple differential equation solver using the finite element method. While I have done this in the past, I often find that there is a big chasm between the mathematical form and the implemented …

---

## [TerminalExtensions.jl + iterm2](https://discourse.julialang.org/t/terminalextensions-jl-iterm2/18927)

<div class="topic-metadata">

**Author:** [@monty](https://discourse.julialang.org/u/monty)\
**Replies:** 2\
**Last updated:** [December 24, 2018, 10:00pm UTC](https://discourse.julialang.org/t/terminalextensions-jl-iterm2/18927 "2018-12-24T22:00:57Z")

</div>

TerminalExtensions.jl + iterm2 work nicely under 0.6.4 to visualize Gadfly and Plots.jl plots. using TerminalExtensions, Gadfly, Plots Plots.plot(1:10) Gadfly.plot(x=1:10) commands above generate figures in the xtem2 t…

---

## [For MathProgBase Interface, quadprog function. How can I get an optimal status when limiting iteration](https://discourse.julialang.org/t/for-mathprogbase-interface-quadprog-function-how-can-i-get-an-optimal-status-when-limiting-iteration/18959)

<div class="topic-metadata">

**Author:** [@Balance37](https://discourse.julialang.org/u/Balance37)\
**Replies:** 0\
**Last updated:** [December 24, 2018, 10:09am UTC](https://discourse.julialang.org/t/for-mathprogbase-interface-quadprog-function-how-can-i-get-an-optimal-status-when-limiting-iteration/18959 "2018-12-24T10:09:10Z")

</div>

Hi, I was trying to use the quadprog(objective vector, Hessian matrix, A, sense, b, lower bound, upper bound, solver) function according to this link https://mathprogbasejl.readthedocs.io/en/latest/quadprog.html It ret…

---

## [V1.0.3. Type conversion or ceiling division? One line example](https://discourse.julialang.org/t/v1-0-3-type-conversion-or-ceiling-division-one-line-example/18947)

<div class="topic-metadata">

**Author:** [@xanfus](https://discourse.julialang.org/u/xanfus)\
**Replies:** 0\
**Last updated:** [December 23, 2018, 6:03pm UTC](https://discourse.julialang.org/t/v1-0-3-type-conversion-or-ceiling-division-one-line-example/18947 "2018-12-23T18:03:34Z")

</div>

The last line executes pretty fast in global space. pids=2:13;NN=138000;NN1=18000;NN2=120000;zTop1x=1.0;hLay2=0.2; zut=SharedArray{Float64}(NN, init = S -\> S\[localindices(S)\] .= 0.0,pids=pids) TD2=SharedArray{Int64}( N…

---

## [DataFrame from array of arrays](https://discourse.julialang.org/t/dataframe-from-array-of-arrays/18940)

<div class="topic-metadata">

**Author:** [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Replies:** 4\
**Last updated:** [December 24, 2018, 12:25am UTC](https://discourse.julialang.org/t/dataframe-from-array-of-arrays/18940 "2018-12-24T00:25:42Z")

</div>

Hello, all. I’m trying to create a DataFrame from an array of arrays that is returned from an API, and I’m having a heck of a time getting this coded! The goal is to not have to hard-code the column names, as these may c…

---

## [Specify constraints on type parameters](https://discourse.julialang.org/t/specify-constraints-on-type-parameters/18917)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 4\
**Last updated:** [December 23, 2018, 11:08pm UTC](https://discourse.julialang.org/t/specify-constraints-on-type-parameters/18917 "2018-12-23T23:08:19Z")

</div>

For example, I have 4 labels for parameterizing a type: const POOL = Union{:A, :B, :C, :D} const CANNOT\_BE\_TOGETHER = ( Union{:A, :C}, Union{:B, :D} ) There are 4 constraints on the type parameters: All type…

---

## [Juno docs for remote Julia process](https://discourse.julialang.org/t/juno-docs-for-remote-julia-process/18942)

<div class="topic-metadata">

**Author:** [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Replies:** 5\
**Last updated:** [December 23, 2018, 8:40pm UTC](https://discourse.julialang.org/t/juno-docs-for-remote-julia-process/18942 "2018-12-23T20:40:52Z")

</div>

Hi, Is there a document to explain how to use the new remote functionality from Juno? For example, if I can connect to a computer like ssh lastname@server.com which has Julia installed, can I use this remote computer? …

---

## [Installing Makie on Mac fails tests on release and master](https://discourse.julialang.org/t/installing-makie-on-mac-fails-tests-on-release-and-master/18941)

<div class="topic-metadata">

**Author:** [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Replies:** 3\
**Last updated:** [December 23, 2018, 3:37pm UTC](https://discourse.julialang.org/t/installing-makie-on-mac-fails-tests-on-release-and-master/18941 "2018-12-23T15:37:23Z")

</div>

Freshly installed and built julia 1.0.3. When I try to use Makie, either on the release or on master branch, I get errors during testing, and I can’t do even a simple scatter plot. In the following copy/paste I’ve elided…

---

## [Tips about @inline](https://discourse.julialang.org/t/tips-about-inline/18851)

<div class="topic-metadata">

**Author:** [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Replies:** 7\
**Last updated:** [December 23, 2018, 1:05pm UTC](https://discourse.julialang.org/t/tips-about-inline/18851 "2018-12-23T13:05:31Z")

</div>

Hi guys! I am seeing some of my functions to vastly improve the execution time if I use @inline. For example, consider the following function: function M\_to\_E(e::Number, M::Number, tol::Number = 1e-10) # Compute th…

---

## [Sequencing for distributed for-loop](https://discourse.julialang.org/t/sequencing-for-distributed-for-loop/18930)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 1\
**Last updated:** [December 23, 2018, 11:39am UTC](https://discourse.julialang.org/t/sequencing-for-distributed-for-loop/18930 "2018-12-23T11:39:16Z")

</div>

Is it possible to make @distributed do the work and respect the original order? using Distributed addprocs(2) process\_dates = range(Date(2018, 12, 20), stop = Date(2018, 12, 1), step = -Dates.Day(1)) @sync @distribu…

---

## [\`error\` vs \`throw(ArgumentError(...))\`](https://discourse.julialang.org/t/error-vs-throw-argumenterror/18915)

<div class="topic-metadata">

**Author:** [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Replies:** 3\
**Last updated:** [December 22, 2018, 5:36pm UTC](https://discourse.julialang.org/t/error-vs-throw-argumenterror/18915 "2018-12-22T17:36:00Z")

</div>

Hi guys! I just want to know the best practice here. In my package, if I see an error related to an wrong input argument (like using -1 for orbit eccentricity), then is it better to use error ou throw(ArgumentError(...)…

---

## [Cairo rebuild demands root access?](https://discourse.julialang.org/t/cairo-rebuild-demands-root-access/18898)

<div class="topic-metadata">

**Author:** [@Colin\_Beckingham](https://discourse.julialang.org/u/Colin_Beckingham)\
**Replies:** 4\
**Last updated:** [December 22, 2018, 2:11pm UTC](https://discourse.julialang.org/t/cairo-rebuild-demands-root-access/18898 "2018-12-22T14:11:26Z")

</div>

I was using ImageView fine yesterday in julia 1.0.2, now today it tells me that Cairo is installed but needs a rebuild. During this rebuild Cairo demands sudo root access; it is trying to tell zypper (OpenSUSE package ma…

---

## [Constants in generic code](https://discourse.julialang.org/t/constants-in-generic-code/18920)

<div class="topic-metadata">

**Author:** [@Bernard\_GODARD](https://discourse.julialang.org/u/Bernard_GODARD)\
**Replies:** 1\
**Last updated:** [December 22, 2018, 1:36pm UTC](https://discourse.julialang.org/t/constants-in-generic-code/18920 "2018-12-22T13:36:32Z")

</div>

I am wondering if there is a recommended way to deal with constants in generic code (ie supporting user types). Example adding a rational f(x) = x+2/3 Implementation 1: f(x::T) where T = x + T(2)/T(3) Implementati…

---

## [Are \`SharedArray\`s safe for simultaneous read/write from different processes?](https://discourse.julialang.org/t/are-sharedarray-s-safe-for-simultaneous-read-write-from-different-processes/18855)

<div class="topic-metadata">

**Author:** [@Jasha10](https://discourse.julialang.org/u/Jasha10)\
**Replies:** 2\
**Last updated:** [December 22, 2018, 12:52pm UTC](https://discourse.julialang.org/t/are-sharedarray-s-safe-for-simultaneous-read-write-from-different-processes/18855 "2018-12-22T12:52:25Z")

</div>

In one process I’d like to do S\[1,1\] += 1; sleep(1); on a loop. In the other process I’d like to do print(S\[1,1\]); sleep(0.5); on a loop. Is this safe when S is a SharedArray? What if the attempted read by the second p…

---

## [Cxx and 0.7](https://discourse.julialang.org/t/cxx-and-0-7/18907)

<div class="topic-metadata">

**Author:** [@GlenHenshaw](https://discourse.julialang.org/u/GlenHenshaw)\
**Replies:** 8\
**Last updated:** [December 22, 2018, 8:12am UTC](https://discourse.julialang.org/t/cxx-and-0-7/18907 "2018-12-22T08:12:32Z")

</div>

I’m trying to port some 0.6 code to 1.0 by way of 0.7, and I’m having trouble with the Cxx package. Yes, I know Cxx is in an intermediate state. But this code is mission critical, so I don’t really have a choice but go …

---

## [Rationale for the \`@pure\`ity of \`Rational{T}(x)\`](https://discourse.julialang.org/t/rationale-for-the-pure-ity-of-rational-t-x/18872)

<div class="topic-metadata">

**Author:** [@tkf](https://discourse.julialang.org/u/tkf)\
**Replies:** 15\
**Last updated:** [December 22, 2018, 1:30am UTC](https://discourse.julialang.org/t/rationale-for-the-pure-ity-of-rational-t-x/18872 "2018-12-22T01:30:52Z")

</div>

Looking at some example usages of @pure in Base, I cannot understand why Rational{T}(x::AbstractIrrational) is considered pure. setprecision(BigFloat, \_) mutates a global state and also it may throw. I thought Base.@…

---

## [Print statements in pyjulia](https://discourse.julialang.org/t/print-statements-in-pyjulia/18901)

<div class="topic-metadata">

**Author:** [@michaelkyu](https://discourse.julialang.org/u/michaelkyu)\
**Replies:** 5\
**Last updated:** [December 21, 2018, 11:21pm UTC](https://discourse.julialang.org/t/print-statements-in-pyjulia/18901 "2018-12-21T23:21:24Z")

</div>

In pyjulia, how do I get “print” statements to show up in the Python terminal? For example, this doesn’t print anything \>\>\> Main.eval(“print(123)”) My real use case is to get the results from @benchmark \>\>\> Main.ev…

---

## [Best way to handle a list of arrays (Asking for recommendations)](https://discourse.julialang.org/t/best-way-to-handle-a-list-of-arrays-asking-for-recommendations/18911)

<div class="topic-metadata">

**Author:** [@OvidiusCicero](https://discourse.julialang.org/u/OvidiusCicero)\
**Replies:** 3\
**Last updated:** [December 21, 2018, 8:30pm UTC](https://discourse.julialang.org/t/best-way-to-handle-a-list-of-arrays-asking-for-recommendations/18911 "2018-12-21T20:30:29Z")

</div>

lets say i have a list of coordinates in vectors eg v1 = \[1,2,3\] v2 = \[4,5,6\] v3 = \[7,8,9\] (list is much longer) I can imagine two ways to organise these: Put them in a large matrix as done for example by eigvecs, …

---

## [empty matrix creation](https://discourse.julialang.org/t/empty-matrix-creation/18910)

<div class="topic-metadata">

**Author:** [@kehlert](https://discourse.julialang.org/u/kehlert)\
**Replies:** 2\
**Last updated:** [December 21, 2018, 7:26pm UTC](https://discourse.julialang.org/t/empty-matrix-creation/18910 "2018-12-21T19:26:00Z")

</div>

I am trying to fill a matrix, and currently it takes longer to create it than to fill it. Here is the code for creating it: Array{Int64,2}(undef, 3, 10^3) I profiled it, and it seems to spend all of its time in the Typ…

---

## [Please help me to translate this code](https://discourse.julialang.org/t/please-help-me-to-translate-this-code/18903)

<div class="topic-metadata">

**Author:** [@Gianluca\_Vaccarezza](https://discourse.julialang.org/u/Gianluca_Vaccarezza)\
**Replies:** 1\
**Last updated:** [December 21, 2018, 3:53pm UTC](https://discourse.julialang.org/t/please-help-me-to-translate-this-code/18903 "2018-12-21T15:53:07Z")

</div>

Hi everyone! I was hoping if one of you could please try to write the following python code in Julia code please. This would be a great help # Demans - A,B,C,D # W,X,Y - Supply # Cost matrix is given below costs = {'…

---

## [UnsatisfiableError: The following specifications were found to be in conflict](https://discourse.julialang.org/t/unsatisfiableerror-the-following-specifications-were-found-to-be-in-conflict/18880)

<div class="topic-metadata">

**Author:** [@cailiangliang765](https://discourse.julialang.org/u/cailiangliang765)\
**Replies:** 6\
**Last updated:** [December 21, 2018, 9:08am UTC](https://discourse.julialang.org/t/unsatisfiableerror-the-following-specifications-were-found-to-be-in-conflict/18880 "2018-12-21T09:08:55Z")

</div>

cailiangliang@clldebian:~/.julia/conda/3/bin$ /home/cailiangliang/.julia/conda/3/bin install -y numpy -bash: /home/cailiangliang/.julia/conda/3/bin: Is a directory cailiangliang@clldebian:~/.julia/conda/3/bin$ /home/ca…

---

## [Constructors for different type parameters?](https://discourse.julialang.org/t/constructors-for-different-type-parameters/18867)

<div class="topic-metadata">

**Author:** [@ArjunNarayanan](https://discourse.julialang.org/u/ArjunNarayanan)\
**Replies:** 3\
**Last updated:** [December 21, 2018, 1:39am UTC](https://discourse.julialang.org/t/constructors-for-different-type-parameters/18867 "2018-12-21T01:39:05Z")

</div>

Is there a way to write a constructor for a type that has part of its parameter list specified? For example, consider struct MyType{A,B} end. I would like to write a constructor for the type MyType{Int,B} where B i.e. w…

---

## [Extending methods of pure function](https://discourse.julialang.org/t/extending-methods-of-pure-function/18852)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 7\
**Last updated:** [December 20, 2018, 11:35pm UTC](https://discourse.julialang.org/t/extending-methods-of-pure-function/18852 "2018-12-20T23:35:29Z")

</div>

AFAIU adding methods to @pure functions is not allowed. However I have a function mysin that I want to be able to add methods to later on and I also know that certain methods are pure. Is a purity fence like in the follo…

---

## [How to \`fill\` a part of the array?](https://discourse.julialang.org/t/how-to-fill-a-part-of-the-array/18868)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 1\
**Last updated:** [December 20, 2018, 8:28pm UTC](https://discourse.julialang.org/t/how-to-fill-a-part-of-the-array/18868 "2018-12-20T20:28:21Z")

</div>

For example, I have an array julia\> a = ones(2, 3) 2×3 Array{Float64,2}: 1.0 1.0 1.0 1.0 1.0 1.0 Now I want to fill its first row to be all 3.0, julia\> fill!(a\[1,:\],3) 3-element Array{Float64,1}: 3.0 3.0 3.0 …

---

## [How to switch between plotting packages and backends, or use two simultaneously?](https://discourse.julialang.org/t/how-to-switch-between-plotting-packages-and-backends-or-use-two-simultaneously/18863)

<div class="topic-metadata">

**Author:** [@Juan](https://discourse.julialang.org/u/Juan)\
**Replies:** 2\
**Last updated:** [December 20, 2018, 7:53pm UTC](https://discourse.julialang.org/t/how-to-switch-between-plotting-packages-and-backends-or-use-two-simultaneously/18863 "2018-12-20T19:53:47Z")

</div>

If I’m using Plots.jl I can choose the GR backend by typing gr(). If I’m using Makie how can I change the backend from GL to GR or vice versa? And if I’m using Plots.jl and I load Makie.jl then all new plots will be ge…

---

## [Loading User Modules in wrong order causes a freeze without errors](https://discourse.julialang.org/t/loading-user-modules-in-wrong-order-causes-a-freeze-without-errors/18848)

<div class="topic-metadata">

**Author:** [@stakaz](https://discourse.julialang.org/u/stakaz)\
**Replies:** 9\
**Last updated:** [December 20, 2018, 3:32pm UTC](https://discourse.julialang.org/t/loading-user-modules-in-wrong-order-causes-a-freeze-without-errors/18848 "2018-12-20T15:32:20Z")

</div>

Hello, I have the following problem with my julia setup. I have about 10 user modules and they depend on each other and also on other mackages. Now, when I load specific modules, e. g. with using A using B using C ev…

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

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