# General Usage

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

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

**Page:** 968

---

## [How to get the type of a symbol in a macro?](https://discourse.julialang.org/t/how-to-get-the-type-of-a-symbol-in-a-macro/12016)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 7\
**Last updated:** [June 28, 2018, 5:28am UTC](https://discourse.julialang.org/t/how-to-get-the-type-of-a-symbol-in-a-macro/12016 "2018-06-28T05:28:22Z")

</div>

I want to write a macro where i can convert the symbols to types and do some type based programming? How can i do that for ex: @linearize Type1 Type2 Type3 Type1-3 will be accessible as a symbol within the macro but i…

---

## [Using @formula() on a dataframe with a categorical variable for Linear Mixed Models](https://discourse.julialang.org/t/using-formula-on-a-dataframe-with-a-categorical-variable-for-linear-mixed-models/11976)

<div class="topic-metadata">

**Author:** [@sarah-ji](https://discourse.julialang.org/u/sarah-ji)\
**Replies:** 5\
**Last updated:** [June 28, 2018, 1:39am UTC](https://discourse.julialang.org/t/using-formula-on-a-dataframe-with-a-categorical-variable-for-linear-mixed-models/11976 "2018-06-28T01:39:42Z")

</div>

Hi, I’m trying to find a way to run a Linear Mixed Model with certain fixed effects using the : μ = @formula(T ~ X\_cts + X\_categorical) mixed\_effect\_model = MixedEffectModel(μ, Σ, IdentityLink(), NormalResponse(0.000…

---

## [Union of Nothing and Parametric Types](https://discourse.julialang.org/t/union-of-nothing-and-parametric-types/11986)

<div class="topic-metadata">

**Author:** [@jdlara-berkeley](https://discourse.julialang.org/u/jdlara-berkeley)\
**Replies:** 16\
**Last updated:** [June 27, 2018, 8:40pm UTC](https://discourse.julialang.org/t/union-of-nothing-and-parametric-types/11986 "2018-06-27T20:40:24Z")

</div>

Hi, I am trying to define a struct that can take an Array of type T or a nothing, as recommended since Nullables has been deprecated. using Compat struct bar{T \<: Real, M \<: String} a::Union{Nothing,Array{T}} b:…

---

## [Saving values from GPU during Euler stepping in ODE](https://discourse.julialang.org/t/saving-values-from-gpu-during-euler-stepping-in-ode/7406)

<div class="topic-metadata">

**Author:** [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Replies:** 23\
**Last updated:** [June 27, 2018, 4:53pm UTC](https://discourse.julialang.org/t/saving-values-from-gpu-during-euler-stepping-in-ode/7406 "2018-06-27T16:53:40Z")

</div>

Dear all, I have written a simple Euler stepping algorithm for a particular problem which runs on GPU. The vector y\_current is big (~200\_000) and it is updated like y\_current .= y\_current .+ dt \* RHS. A working example…

---

## ["?" expression error message is not unambiguous](https://discourse.julialang.org/t/expression-error-message-is-not-unambiguous/11994)

<div class="topic-metadata">

**Author:** [@jraikisto](https://discourse.julialang.org/u/jraikisto)\
**Replies:** 1\
**Last updated:** [June 27, 2018, 12:01pm UTC](https://discourse.julialang.org/t/expression-error-message-is-not-unambiguous/11994 "2018-06-27T12:01:51Z")

</div>

k = x -\> x \> 5 ? "foo" : "bar" works perfectly fine, but k = x -\> x \> 5 ? return "foo" : return "bar" returns ERROR: syntax: colon expected in "?" expression I’m running julia 0.6.2. I just spent 10 minutes wonderi…

---

## [Problem with Base.push! in 0.7.0-alpha (?)](https://discourse.julialang.org/t/problem-with-base-push-in-0-7-0-alpha/11921)

<div class="topic-metadata">

**Author:** [@f-fathurrahman](https://discourse.julialang.org/u/f-fathurrahman)\
**Replies:** 14\
**Last updated:** [June 27, 2018, 1:55pm UTC](https://discourse.julialang.org/t/problem-with-base-push-in-0-7-0-alpha/11921 "2018-06-27T13:55:58Z")

</div>

Dear all, I am a computational physicist and a novice Julia programmer.I have written several simple codes using Julia, although mostly they still look like Fortran :sweat\_smile:. With the release of Julia 0.7.0-alpha,…

---

## [Why does Julia install to AppData on Windows even if you have admin privileges?](https://discourse.julialang.org/t/why-does-julia-install-to-appdata-on-windows-even-if-you-have-admin-privileges/11967)

<div class="topic-metadata">

**Author:** [@NiclasMattsson](https://discourse.julialang.org/u/NiclasMattsson)\
**Replies:** 4\
**Last updated:** [June 27, 2018, 11:11am UTC](https://discourse.julialang.org/t/why-does-julia-install-to-appdata-on-windows-even-if-you-have-admin-privileges/11967 "2018-06-27T11:11:03Z")

</div>

Maybe it’s just my OCD speaking, but I dislike the idea of polluting the AppData folder with gigabyte-sized program installs. I think AppData is intended for (surprise) application data only and should be easy to backup.…

---

## [Overload zero for a parametric type](https://discourse.julialang.org/t/overload-zero-for-a-parametric-type/11991)

<div class="topic-metadata">

**Author:** [@stakaz](https://discourse.julialang.org/u/stakaz)\
**Replies:** 4\
**Last updated:** [June 27, 2018, 9:42am UTC](https://discourse.julialang.org/t/overload-zero-for-a-parametric-type/11991 "2018-06-27T09:42:18Z")

</div>

Hello, I would like to add a zero function for a custom parametric type. This code for example struct Point{T} p::T end Point{T}() where T = Point(zero(T)) Point() = Point(0) can produce “zero” elements with Point(…

---

## [World Cup - Russia 2018 thread](https://discourse.julialang.org/t/world-cup-russia-2018-thread/11988)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 0\
**Last updated:** [June 27, 2018, 5:32am UTC](https://discourse.julialang.org/t/world-cup-russia-2018-thread/11988 "2018-06-27T05:32:13Z")

</div>

Has anyone done any World Cup analysis using Julia?

---

## [Global JULIA\_PKGDIR but install packages locally](https://discourse.julialang.org/t/global-julia-pkgdir-but-install-packages-locally/11857)

<div class="topic-metadata">

**Author:** [@madprogrammer](https://discourse.julialang.org/u/madprogrammer)\
**Replies:** 2\
**Last updated:** [June 26, 2018, 8:56pm UTC](https://discourse.julialang.org/t/global-julia-pkgdir-but-install-packages-locally/11857 "2018-06-26T20:56:03Z")

</div>

Hi all, I wanted to see if I could have the following configuration in Julia in regards to the package structure. The goal is to have julia and the package source code installed into a directory mounted on a NFS mounte…

---

## [Why can't i write such a function?](https://discourse.julialang.org/t/why-cant-i-write-such-a-function/11953)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 6\
**Last updated:** [June 26, 2018, 7:33pm UTC](https://discourse.julialang.org/t/why-cant-i-write-such-a-function/11953 "2018-06-26T19:33:09Z")

</div>

function get\_typparam(::Type{X{Q1,Q2,Q3}}) where X where {Q1,Q2,Q3} \[Q1,Q2,Q3\] end ERROR: TypeError: Type{…} expression: expected UnionAll, got TypeVar Thanks

---

## [A good way to iterate through sequences?](https://discourse.julialang.org/t/a-good-way-to-iterate-through-sequences/11718)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 19\
**Last updated:** [June 26, 2018, 6:02pm UTC](https://discourse.julialang.org/t/a-good-way-to-iterate-through-sequences/11718 "2018-06-26T18:02:06Z")

</div>

I need to iterate through all sequences of integers between 1 and A, and of length L. Here A,L are positive integers. For example, if A = 2, L = 2, the sequences are: \[1, 1\] \[2, 1\] \[1, 2\] \[2, 2\] The iteration shoul…

---

## [Epoll\_wait occupying 40% cpu](https://discourse.julialang.org/t/epoll-wait-occupying-40-cpu/11977)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 0\
**Last updated:** [June 26, 2018, 7:04pm UTC](https://discourse.julialang.org/t/epoll-wait-occupying-40-cpu/11977 "2018-06-26T19:04:08Z")

</div>

I used Jupyter and finished some work few days ago. I forgot to shut down the kernel but I notice something strange today. Apparently, the julia process is occupying 40% cpu even though nothing is running. I diagnosed…

---

## [Why has subtypes function been moved to module InteractiveUtils? (v0.7.0)](https://discourse.julialang.org/t/why-has-subtypes-function-been-moved-to-module-interactiveutils-v0-7-0/11975)

<div class="topic-metadata">

**Author:** [@jandehaan](https://discourse.julialang.org/u/jandehaan)\
**Replies:** 6\
**Last updated:** [June 26, 2018, 7:03pm UTC](https://discourse.julialang.org/t/why-has-subtypes-function-been-moved-to-module-interactiveutils-v0-7-0/11975 "2018-06-26T19:03:32Z")

</div>

I noticed that function subtypes has been moved to module InteractiveUtils. However the supertype function remained in Base.operators.jl. Why is that? In my opinion subtypes should have remained in Base. If supertype ha…

---

## [dot syntax in pyjulia](https://discourse.julialang.org/t/dot-syntax-in-pyjulia/11974)

<div class="topic-metadata">

**Author:** [@atombear](https://discourse.julialang.org/u/atombear)\
**Replies:** 4\
**Last updated:** [June 26, 2018, 6:45pm UTC](https://discourse.julialang.org/t/dot-syntax-in-pyjulia/11974 "2018-06-26T18:45:39Z")

</div>

Hello, I have a question about using dot syntax in python. In trying to write a broadcast-able function in julia that I can call from python, i have found it convenient to do the following: export func function func(x:…

---

## [This should be documented in performance tips if not a temporary bug](https://discourse.julialang.org/t/this-should-be-documented-in-performance-tips-if-not-a-temporary-bug/11894)

<div class="topic-metadata">

**Author:** [@Jean\_Michel](https://discourse.julialang.org/u/Jean_Michel)\
**Replies:** 19\
**Last updated:** [June 26, 2018, 4:42pm UTC](https://discourse.julialang.org/t/this-should-be-documented-in-performance-tips-if-not-a-temporary-bug/11894 "2018-06-26T16:42:38Z")

</div>

Here is a drastically simplified and self-contained fragment of code dealing with permutation groups. The point of my post is that without the line let s=s, i=i, e=i^s the compiler cannot infer the type of either s, i or…

---

## [Quoting numbers vs quoting names](https://discourse.julialang.org/t/quoting-numbers-vs-quoting-names/11958)

<div class="topic-metadata">

**Author:** [@Robert\_Honig](https://discourse.julialang.org/u/Robert_Honig)\
**Replies:** 5\
**Last updated:** [June 26, 2018, 3:13pm UTC](https://discourse.julialang.org/t/quoting-numbers-vs-quoting-names/11958 "2018-06-26T15:13:15Z")

</div>

julia\> Meta.parse(":1") :($(QuoteNode(1))) julia\> Meta.parse(":a") :(:a) Quoting the name a gives me what I expect: The symbol :a. Quoting the number 1, however, resolves to $(QuoteNode(1)), which is not what I expect…

---

## [Trouble defining a function working on both a type and its Arrays](https://discourse.julialang.org/t/trouble-defining-a-function-working-on-both-a-type-and-its-arrays/11941)

<div class="topic-metadata">

**Author:** [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Replies:** 6\
**Last updated:** [June 26, 2018, 2:35pm UTC](https://discourse.julialang.org/t/trouble-defining-a-function-working-on-both-a-type-and-its-arrays/11941 "2018-06-26T14:35:40Z")

</div>

Dear all, I took about a year of a break on Julia. In my old code I used a lot of functions that worked both on a Type and an Array of the type (you may discuss whether that’s good, I’d like to have something that “auto…

---

## [Meaning of package manager prompt](https://discourse.julialang.org/t/meaning-of-package-manager-prompt/11965)

<div class="topic-metadata">

**Author:** [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Replies:** 2\
**Last updated:** [June 26, 2018, 2:30pm UTC](https://discourse.julialang.org/t/meaning-of-package-manager-prompt/11965 "2018-06-26T14:30:52Z")

</div>

The Julia Manual when describing package manager prompt states: The part inside the parenthesis of the prompt shows the name of the current project. However, I am not sure about what is the meaning of word “current” …

---

## [Calling pmap inside of a loop with varying parameters](https://discourse.julialang.org/t/calling-pmap-inside-of-a-loop-with-varying-parameters/11912)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 6\
**Last updated:** [June 26, 2018, 12:22am UTC](https://discourse.julialang.org/t/calling-pmap-inside-of-a-loop-with-varying-parameters/11912 "2018-06-26T00:22:14Z")

</div>

I am trying to do a parameter study on an ODE type problem, varying both a parameter in the equation, and the choice of time step. The problem lays out like: function v(x,k) return cos(k \* x) end Dt\_vals = logspac…

---

## [Argument checking in user defined types](https://discourse.julialang.org/t/argument-checking-in-user-defined-types/11950)

<div class="topic-metadata">

**Author:** [@drbenvincent](https://discourse.julialang.org/u/drbenvincent)\
**Replies:** 6\
**Last updated:** [June 25, 2018, 10:56pm UTC](https://discourse.julialang.org/t/argument-checking-in-user-defined-types/11950 "2018-06-25T22:56:16Z")

</div>

Hi. Sorry if this is obvious or belies a complete misunderstanding of the Julia way… but I was trying to figure out how to do argument checking in a user defined type. For example, to enforce that a value be a positive …

---

## [Accessing variables and values from the optimization output report for plotting graphs](https://discourse.julialang.org/t/accessing-variables-and-values-from-the-optimization-output-report-for-plotting-graphs/11949)

<div class="topic-metadata">

**Author:** [@Vondoe79](https://discourse.julialang.org/u/Vondoe79)\
**Replies:** 0\
**Last updated:** [June 25, 2018, 9:18pm UTC](https://discourse.julialang.org/t/accessing-variables-and-values-from-the-optimization-output-report-for-plotting-graphs/11949 "2018-06-25T21:18:12Z")

</div>

Hi team Julia, I would like to access the variables (‘x’, ‘u’, etc.) and their respective values from the JuMP optimization report and use them for plotting. Wondering if anyone can assist me in doing this task. I have …

---

## [Confusion about new Pkg: What happens to a package when I update the top level project?](https://discourse.julialang.org/t/confusion-about-new-pkg-what-happens-to-a-package-when-i-update-the-top-level-project/11947)

<div class="topic-metadata">

**Author:** [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Replies:** 4\
**Last updated:** [June 25, 2018, 8:48pm UTC](https://discourse.julialang.org/t/confusion-about-new-pkg-what-happens-to-a-package-when-i-update-the-top-level-project/11947 "2018-06-25T20:48:00Z")

</div>

Hello, I am confused about something and I’d like to read the solution to my confusion: Every package is now a project. Since every package is a project, every package has written down the dependent packages versions i…

---

## [Display of unicode accents in REPL](https://discourse.julialang.org/t/display-of-unicode-accents-in-repl/11928)

<div class="topic-metadata">

**Author:** [@CarloLucibello](https://discourse.julialang.org/u/CarloLucibello)\
**Replies:** 9\
**Last updated:** [June 25, 2018, 4:31pm UTC](https://discourse.julialang.org/t/display-of-unicode-accents-in-repl/11928 "2018-06-25T16:31:14Z")

</div>

If I tab complete n\\tilde in the REPL I visualize something as n and then a tilde on its right side, instead of ñ. If I then copy it in this forum it gets correctly displayed instead… Do you know if this issue as alr…

---

## [Getting IOBuffer data after close method is called](https://discourse.julialang.org/t/getting-iobuffer-data-after-close-method-is-called/11873)

<div class="topic-metadata">

**Author:** [@Ward9250](https://discourse.julialang.org/u/Ward9250)\
**Replies:** 1\
**Last updated:** [June 25, 2018, 3:21pm UTC](https://discourse.julialang.org/t/getting-iobuffer-data-after-close-method-is-called/11873 "2018-06-25T15:21:55Z")

</div>

Hi All. I’ve been working with some code that writes data to an IOBuffer, calls the close, method on said buffer. i = IOBuffer() write(i, "Wooo look at meeeee!") close(i) Obv the above is a really dumb toy example, bu…

---

## [DateFrame.jl slow, convert one string-column to UTC time (Int)](https://discourse.julialang.org/t/dateframe-jl-slow-convert-one-string-column-to-utc-time-int/11904)

<div class="topic-metadata">

**Author:** [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Replies:** 14\
**Last updated:** [June 25, 2018, 3:16pm UTC](https://discourse.julialang.org/t/dateframe-jl-slow-convert-one-string-column-to-utc-time-int/11904 "2018-06-25T15:16:34Z")

</div>

I have one DataFrame with a column of Time in the format of String. I want to convert this column to UTC time in second (Int). The code is as follows. However, it is quite slow. Could anyone give some advice to improve t…

---

## [Sum(i for i in Vector{Int}()) raises error instead of returning 0?](https://discourse.julialang.org/t/sum-i-for-i-in-vector-int-raises-error-instead-of-returning-0/1705)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 7\
**Last updated:** [June 25, 2018, 11:15am UTC](https://discourse.julialang.org/t/sum-i-for-i-in-vector-int-raises-error-instead-of-returning-0/1705 "2018-06-25T11:15:49Z")

</div>

sum(i for i in Vector{Int}()) raises an error: ERROR: MethodError: no method matching zero(::Type{Any}) Closest candidates are: zero(::Type{Base.LibGit2.Oid}) at libgit2/oid.jl:88 zero(::Type{Base.Pkg.Resolve.Versi…

---

## [Works in Atom/Juno not in REPL](https://discourse.julialang.org/t/works-in-atom-juno-not-in-repl/7534)

<div class="topic-metadata">

**Author:** [@Daneel](https://discourse.julialang.org/u/Daneel)\
**Replies:** 8\
**Last updated:** [June 19, 2018, 8:33am UTC](https://discourse.julialang.org/t/works-in-atom-juno-not-in-repl/7534 "2018-06-19T08:33:03Z")

</div>

I’m in the process of updating a module I’ve been working on due to breaking changes in DataFrames. Using Pkg.test to call the tests that I had setup before the breaking changes works when I run it through the Atom/Juno …

---

## [Symmetry in arguments and default behavior](https://discourse.julialang.org/t/symmetry-in-arguments-and-default-behavior/11924)

<div class="topic-metadata">

**Author:** [@stakaz](https://discourse.julialang.org/u/stakaz)\
**Replies:** 7\
**Last updated:** [June 25, 2018, 9:45am UTC](https://discourse.julialang.org/t/symmetry-in-arguments-and-default-behavior/11924 "2018-06-25T09:45:26Z")

</div>

Hello, suppose I have the following types abstract type Food end struct Milk \<: Food end struct Berries \<: Food end struct Fish \<: Food end Now, I want to introduce a function mix with 1) a default behavior for unkno…

---

## [Weird parsing inside \[...\]](https://discourse.julialang.org/t/weird-parsing-inside/11910)

<div class="topic-metadata">

**Author:** [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Replies:** 3\
**Last updated:** [June 25, 2018, 6:48am UTC](https://discourse.julialang.org/t/weird-parsing-inside/11910 "2018-06-25T06:48:02Z")

</div>

The following is a really hard to spot parsing nuance: julia\> \[0 -1\] 1×2 Array{Int64,2}: 0 -1 julia\> \[0-1\] 1-element Array{Int64,1}: -1 julia\> \[0 - 1\] 1-element Array{Int64,1}: -1 julia\> 0 -1 -1

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

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