# General Usage

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

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

**Page:** 1021

---

## [Display struct definition](https://discourse.julialang.org/t/display-struct-definition/6564)

<div class="topic-metadata">

**Author:** [@tawheeler](https://discourse.julialang.org/u/tawheeler)\
**Replies:** 1\
**Last updated:** [October 19, 2017, 4:35pm UTC](https://discourse.julialang.org/t/display-struct-definition/6564 "2017-10-19T16:35:59Z")

</div>

Is there an easy way to display a struct definition? I often find myself wanting to see the fieldnames for a type, for which I can call fieldnames(mytype). This doesn’t give me the corresponding types as well. Is there …

---

## [Small, indexable, unique, and statically-sized immutable arrays](https://discourse.julialang.org/t/small-indexable-unique-and-statically-sized-immutable-arrays/6559)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 2\
**Last updated:** [October 19, 2017, 4:23pm UTC](https://discourse.julialang.org/t/small-indexable-unique-and-statically-sized-immutable-arrays/6559 "2017-10-19T16:23:22Z")

</div>

I might be over-thinking this and I know I’m getting greedy here: Is there an array type that is indexable, has only unique members, can not change in size or elements, and is relatively “small” (i.e. shorter than say 2…

---

## [StaticArrays:construct a SMatrix from three vectors](https://discourse.julialang.org/t/staticarrays-construct-a-smatrix-from-three-vectors/6509)

<div class="topic-metadata">

**Author:** [@phlavenk](https://discourse.julialang.org/u/phlavenk)\
**Replies:** 9\
**Last updated:** [October 19, 2017, 11:42am UTC](https://discourse.julialang.org/t/staticarrays-construct-a-smatrix-from-three-vectors/6509 "2017-10-19T11:42:25Z")

</div>

I’m using SMatrix from StaticArrays.jl for calculation of coordinate system transformation. In the hotspot, I’m running following (simplified) code: using StaticArrays, BenchmarkTools a = rand(3) b = rand(3) c = rand…

---

## [Possible bug in broadcasting operation on array of tuples](https://discourse.julialang.org/t/possible-bug-in-broadcasting-operation-on-array-of-tuples/6547)

<div class="topic-metadata">

**Author:** [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Replies:** 5\
**Last updated:** [October 19, 2017, 10:02am UTC](https://discourse.julialang.org/t/possible-bug-in-broadcasting-operation-on-array-of-tuples/6547 "2017-10-19T10:02:10Z")

</div>

Hi all, I just encountered the following behaviour in v0.6 on Ubuntu: julia\> (1,1) .!= \[(1,1), (2,1)\] 2-element BitArray{1}: true true but if I add one more element to the RHS vector I get an error: julia\> (1,1) .!…

---

## [HDF5.jl: How to write type stable code](https://discourse.julialang.org/t/hdf5-jl-how-to-write-type-stable-code/6549)

<div class="topic-metadata">

**Author:** [@tobias.knopp](https://discourse.julialang.org/u/tobias.knopp)\
**Replies:** 8\
**Last updated:** [October 19, 2017, 9:53am UTC](https://discourse.julialang.org/t/hdf5-jl-how-to-write-type-stable-code/6549 "2017-10-19T09:53:10Z")

</div>

Hi, I was wondering how to write type stable code using HDF5 files. I Have code that looks like this getMyArray(filename::String) = hdfread(filename,"/myArray") So if I know that the array is of type Float64 and has th…

---

## [Sparse set-like indexible data structure](https://discourse.julialang.org/t/sparse-set-like-indexible-data-structure/6525)

<div class="topic-metadata">

**Author:** [@Ward9250](https://discourse.julialang.org/u/Ward9250)\
**Replies:** 9\
**Last updated:** [October 19, 2017, 1:21am UTC](https://discourse.julialang.org/t/sparse-set-like-indexible-data-structure/6525 "2017-10-19T01:21:12Z")

</div>

I have a need for a data type in my code which is set-like, so stores only unique values, and can efficiently do intersections and unions and such, but that can also be indexed, and is efficient for sparse sets. My poss…

---

## [ImageView on JuliaPro 0.6 fails to build](https://discourse.julialang.org/t/imageview-on-juliapro-0-6-fails-to-build/6516)

<div class="topic-metadata">

**Author:** [@Alex0573](https://discourse.julialang.org/u/Alex0573)\
**Replies:** 2\
**Last updated:** [October 19, 2017, 12:26am UTC](https://discourse.julialang.org/t/imageview-on-juliapro-0-6-fails-to-build/6516 "2017-10-19T00:26:27Z")

</div>

I installed JuliaPro 0.6 on a Mac and when I tried to build the ImageView package it failed. The error was in the Gtk package: LoadError: SystemError: opening file /Applications/JuliaPro-0.6.0.1.app/Contents/Resources/…

---

## [Help extracting only certain fields of non-array data](https://discourse.julialang.org/t/help-extracting-only-certain-fields-of-non-array-data/6540)

<div class="topic-metadata">

**Author:** [@pawbz](https://discourse.julialang.org/u/pawbz)\
**Replies:** 0\
**Last updated:** [October 18, 2017, 10:45pm UTC](https://discourse.julialang.org/t/help-extracting-only-certain-fields-of-non-array-data/6540 "2017-10-18T22:45:47Z")

</div>

addprocs(4) @everywhere type Temp a::Array{Float64} alarge::Array{Float64} end @everywhere using DistributedArrays work=workers() nwork=length(work) pap=ddata(T=Temp, init=I-\>Temp(\[2.,3.,\], randn(1000)), p…

---

## [Mutable struct with multi dimensional Array as a field](https://discourse.julialang.org/t/mutable-struct-with-multi-dimensional-array-as-a-field/6529)

<div class="topic-metadata">

**Author:** [@ArchieCall](https://discourse.julialang.org/u/ArchieCall)\
**Replies:** 3\
**Last updated:** [October 18, 2017, 9:48pm UTC](https://discourse.julialang.org/t/mutable-struct-with-multi-dimensional-array-as-a-field/6529 "2017-10-18T21:48:13Z")

</div>

The code below is my attempt at creating a mutable struct that has an Array as a field. Does this seem to be the correct method of creating the Array? It seems a little unnatural of how the length and dims are created …

---

## [Convert failure in version 0.7](https://discourse.julialang.org/t/convert-failure-in-version-0-7/6513)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 7\
**Last updated:** [October 18, 2017, 4:02pm UTC](https://discourse.julialang.org/t/convert-failure-in-version-0-7/6513 "2017-10-18T16:02:53Z")

</div>

I don’t have 0.7 installed yet but from the Travis nightly build failures this, that works fine on 0.6, fails with 0.7. Can someone please confirm? julia\> str="blabla"; julia\> convert(Ptr{Void}, pointer(str)) Ptr{Void}…

---

## [Normalizing colored output for comparison?](https://discourse.julialang.org/t/normalizing-colored-output-for-comparison/6486)

<div class="topic-metadata">

**Author:** [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Replies:** 5\
**Last updated:** [October 18, 2017, 3:54pm UTC](https://discourse.julialang.org/t/normalizing-colored-output-for-comparison/6486 "2017-10-18T15:54:51Z")

</div>

Are there any good options for checking colored output in your tests that work across julia versions? I keep coming across this issue where I want to validate that some colored output shows up correctly, but the issue i…

---

## [Effective Solution for transformation Matrix to Vector {Block}](https://discourse.julialang.org/t/effective-solution-for-transformation-matrix-to-vector-block/6037)

<div class="topic-metadata">

**Author:** [@Martin\_Florek](https://discourse.julialang.org/u/Martin_Florek)\
**Replies:** 3\
**Last updated:** [October 18, 2017, 1:42pm UTC](https://discourse.julialang.org/t/effective-solution-for-transformation-matrix-to-vector-block/6037 "2017-10-18T13:42:50Z")

</div>

Hello, I have an exciting problem. Consider type Block and rawData Matrix. struct Block name::String data::Vector{Float64} end headers = \["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"\] rawData = rand(8700, 10) d…

---

## [Pipes and broadcasts](https://discourse.julialang.org/t/pipes-and-broadcasts/3591)

<div class="topic-metadata">

**Author:** [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Replies:** 4\
**Last updated:** [October 18, 2017, 11:48am UTC](https://discourse.julialang.org/t/pipes-and-broadcasts/3591 "2017-10-18T11:48:47Z")

</div>

The following does not work, is this a bug? (3, 3) |\> abs. this one does work of course (3, 3) |\> x -\> abs.(x) but is a bit verbose.

---

## [Make this code fast (median pooling)](https://discourse.julialang.org/t/make-this-code-fast-median-pooling/6405)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 5\
**Last updated:** [October 18, 2017, 10:07am UTC](https://discourse.julialang.org/t/make-this-code-fast-median-pooling/6405 "2017-10-18T10:07:56Z")

</div>

I have an image say of size (1000,1000) and I want to reduce it to size (200,200) by tiling it with (5,5) batches and replacing each batch by its median. (The purpose of median is to remove some salt pepper like artifact…

---

## [Using Deprecations.jl (and more generally on updating syntax)](https://discourse.julialang.org/t/using-deprecations-jl-and-more-generally-on-updating-syntax/6490)

<div class="topic-metadata">

**Author:** [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Replies:** 5\
**Last updated:** [October 17, 2017, 11:50pm UTC](https://discourse.julialang.org/t/using-deprecations-jl-and-more-generally-on-updating-syntax/6490 "2017-10-17T23:50:38Z")

</div>

Hi all, I’m in the process of upgrading some v0.5 code to v0.7. For various reasons this code is on a local machine rather than a GitHub repository, so FemtoCleaner is not an option (that I’m aware of - maybe there is a…

---

## [Query.jl fails - Is WeakRefString string comparison broken?](https://discourse.julialang.org/t/query-jl-fails-is-weakrefstring-string-comparison-broken/6512)

<div class="topic-metadata">

**Author:** [@js135005](https://discourse.julialang.org/u/js135005)\
**Replies:** 0\
**Last updated:** [October 17, 2017, 8:56pm UTC](https://discourse.julialang.org/t/query-jl-fails-is-weakrefstring-string-comparison-broken/6512 "2017-10-17T20:56:33Z")

</div>

I’ve been chasing a strange problem in Query.jl where queries with @where that worked a few days ago now return no results. I’ve been trying to produce a clean MWE and will post it if I succeed. The query in question is: …

---

## [Transpose not working on Array{Any,2}](https://discourse.julialang.org/t/transpose-not-working-on-array-any-2/6510)

<div class="topic-metadata">

**Author:** [@bernhard](https://discourse.julialang.org/u/bernhard)\
**Replies:** 2\
**Last updated:** [October 17, 2017, 5:06pm UTC](https://discourse.julialang.org/t/transpose-not-working-on-array-any-2/6510 "2017-10-17T17:06:56Z")

</div>

transpose is not working for a specific matrix I have. Consider the last line in the code below. Is this deliberate? am I missing anything here? I can work around this, by using permutedims, but I would have expected t…

---

## [Safer Integers](https://discourse.julialang.org/t/safer-integers/6447)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 4\
**Last updated:** [October 17, 2017, 4:34pm UTC](https://discourse.julialang.org/t/safer-integers/6447 "2017-10-17T16:34:34Z")

</div>

Is it possible to throw an exception automatically when something like this happens: print(typemax(UInt) + 2) This returns 1.

---

## [Speed and type-stability of unsafe\_pointer\_to\_objref](https://discourse.julialang.org/t/speed-and-type-stability-of-unsafe-pointer-to-objref/6478)

<div class="topic-metadata">

**Author:** [@foobar\_lv](https://discourse.julialang.org/u/foobar_lv)\
**Replies:** 8\
**Last updated:** [October 17, 2017, 1:09pm UTC](https://discourse.julialang.org/t/speed-and-type-stability-of-unsafe-pointer-to-objref/6478 "2017-10-17T13:09:06Z")

</div>

Hi, I wanted to ask about unsafe\_pointer\_to\_objref, or alternatives. Naively, I would expect this to be a NOP for Ptr{T} if T is not bitstype, and otherwise a single load. Is there a way to get the NOP behaviour? Is th…

---

## [Name of type and module clash](https://discourse.julialang.org/t/name-of-type-and-module-clash/6477)

<div class="topic-metadata">

**Author:** [@plapplop](https://discourse.julialang.org/u/plapplop)\
**Replies:** 4\
**Last updated:** [October 17, 2017, 12:30pm UTC](https://discourse.julialang.org/t/name-of-type-and-module-clash/6477 "2017-10-17T12:30:35Z")

</div>

Hello, I need to write models according to a predefined template, and it contains a type called Parameters. I cannot really rename it as an entire computing platform (for many models) relies on this particular name. Now…

---

## [In the linux terminal, juliapro can't receive argument to -O](https://discourse.julialang.org/t/in-the-linux-terminal-juliapro-cant-receive-argument-to-o/6495)

<div class="topic-metadata">

**Author:** [@111](https://discourse.julialang.org/u/111)\
**Replies:** 0\
**Last updated:** [October 17, 2017, 9:25am UTC](https://discourse.julialang.org/t/in-the-linux-terminal-juliapro-cant-receive-argument-to-o/6495 "2017-10-17T09:25:38Z")

</div>

I installed the free version of juliapro-mkl in manjaro. When using julia from the terminal by typing julia -O3 test.jl I got "ERROR: julia: invalid argument to -O (3 test.jl) when I type julia --math-mode=fast te…

---

## [Best practice for parametric return type declarations in v0.7 (and v1.0)](https://discourse.julialang.org/t/best-practice-for-parametric-return-type-declarations-in-v0-7-and-v1-0/6491)

<div class="topic-metadata">

**Author:** [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Replies:** 2\
**Last updated:** [October 17, 2017, 9:16am UTC](https://discourse.julialang.org/t/best-practice-for-parametric-return-type-declarations-in-v0-7-and-v1-0/6491 "2017-10-17T09:16:20Z")

</div>

Hi all, I just encountered this and this, which indicate that for v0.7 (and therefore v1.0), the best syntax for one-liner functions that include a parametric return type declaration is to write the function inside pare…

---

## [Short form Warnings?](https://discourse.julialang.org/t/short-form-warnings/6489)

<div class="topic-metadata">

**Author:** [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Replies:** 0\
**Last updated:** [October 17, 2017, 2:26am UTC](https://discourse.julialang.org/t/short-form-warnings/6489 "2017-10-17T02:26:47Z")

</div>

I was looking a screenful of warnings, trying to isolate the info I needed, WARNING: Method definition (::Type{Base.Dates.Microsecond})(T\<:NanoTimes.SimpleCloc k) in module NanoTimes at C:\\Users\\jas\\AppData\\Local\\JuliaP…

---

## [Polynomial root finding](https://discourse.julialang.org/t/polynomial-root-finding/6485)

<div class="topic-metadata">

**Author:** [@mgameiro](https://discourse.julialang.org/u/mgameiro)\
**Replies:** 2\
**Last updated:** [October 16, 2017, 9:13pm UTC](https://discourse.julialang.org/t/polynomial-root-finding/6485 "2017-10-16T21:13:24Z")

</div>

What is the best way to find the roots of polynomials in Julia?

---

## [Escaping in nested expr](https://discourse.julialang.org/t/escaping-in-nested-expr/6481)

<div class="topic-metadata">

**Author:** [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Replies:** 3\
**Last updated:** [October 16, 2017, 7:39pm UTC](https://discourse.julialang.org/t/escaping-in-nested-expr/6481 "2017-10-16T19:39:38Z")

</div>

I’m trying to write a simple macro to enable/disable color output within a block (for running tests that capture and compare output) This is what I have so far, but I can’t figure out the right escaping for prev\_color a…

---

## [MetaGraph node indexing w/metadata?](https://discourse.julialang.org/t/metagraph-node-indexing-w-metadata/6439)

<div class="topic-metadata">

**Author:** [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Replies:** 8\
**Last updated:** [October 16, 2017, 4:37pm UTC](https://discourse.julialang.org/t/metagraph-node-indexing-w-metadata/6439 "2017-10-16T16:37:38Z")

</div>

I’m trying to iteratively generate an interaction graph given a table of data, and will often come up on a situation where I need to check an interaction (edge weight) between two nodes is less than some new value, and i…

---

## [How to speed up calculating large array?](https://discourse.julialang.org/t/how-to-speed-up-calculating-large-array/6466)

<div class="topic-metadata">

**Author:** [@Wonki\_Lee](https://discourse.julialang.org/u/Wonki_Lee)\
**Replies:** 11\
**Last updated:** [October 16, 2017, 4:16pm UTC](https://discourse.julialang.org/t/how-to-speed-up-calculating-large-array/6466 "2017-10-16T16:16:08Z")

</div>

Hi, I’m wondering if I could decrease the computation time for calculating large size array. Because I was new to Julia, I almost copied the format of ‘advection\_shared!(q,u)’ in https://docs.julialang.org/en/latest/man…

---

## [How to work with intervals values in julia](https://discourse.julialang.org/t/how-to-work-with-intervals-values-in-julia/6433)

<div class="topic-metadata">

**Author:** [@leaoshark](https://discourse.julialang.org/u/leaoshark)\
**Replies:** 23\
**Last updated:** [October 16, 2017, 1:41pm UTC](https://discourse.julialang.org/t/how-to-work-with-intervals-values-in-julia/6433 "2017-10-16T13:41:34Z")

</div>

my program have a sigma = 0.6 , but i must change to sigma = 0.319 / R , for R in \[0.5:0.5:10\] and in the final line of the program i want to calculate an integral, and this integral depends of the R value … for eac…

---

## [\`tee\`-like pattern for external processes in Julia](https://discourse.julialang.org/t/tee-like-pattern-for-external-processes-in-julia/6462)

<div class="topic-metadata">

**Author:** [@freeboson](https://discourse.julialang.org/u/freeboson)\
**Replies:** 0\
**Last updated:** [October 16, 2017, 7:16am UTC](https://discourse.julialang.org/t/tee-like-pattern-for-external-processes-in-julia/6462 "2017-10-16T07:16:58Z")

</div>

I have a large data stream in a pipeline that does compression and uploading. I would like to do two things with the output of the compression: Upload it as before Compute a hash (or several hashes) In the shell it wo…

---

## [Use a type alias as a function name](https://discourse.julialang.org/t/use-a-type-alias-as-a-function-name/6458)

<div class="topic-metadata">

**Author:** [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Replies:** 2\
**Last updated:** [October 16, 2017, 4:04am UTC](https://discourse.julialang.org/t/use-a-type-alias-as-a-function-name/6458 "2017-10-16T04:04:10Z")

</div>

Hi all, I’m sure this must have been covered somewhere, but a quick google didn’t help me. I’m updating some code to v0.6 and so replaced all instances of, e.g. typealias MyFloatVec Vector{Float64} with MyFloatVec =…

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

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