# General Usage

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

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

**Page:** 979

---

## [Finding the path to the file being executed](https://discourse.julialang.org/t/finding-the-path-to-the-file-being-executed/10905)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 2\
**Last updated:** [May 15, 2018, 10:20am UTC](https://discourse.julialang.org/t/finding-the-path-to-the-file-being-executed/10905 "2018-05-15T10:20:48Z")

</div>

I am creating a install.jl script to install my software on my user’s computer: all necessary stuff is packed in a zip file, the user can unzip it into some folder Drive:\\path, and is invited to execute Drive:\\path\\insta…

---

## [Sum performance for Array{Float64,2} elements](https://discourse.julialang.org/t/sum-performance-for-array-float64-2-elements/10873)

<div class="topic-metadata">

**Author:** [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Replies:** 13\
**Last updated:** [May 15, 2018, 7:02am UTC](https://discourse.julialang.org/t/sum-performance-for-array-float64-2-elements/10873 "2018-05-15T07:02:14Z")

</div>

Hi, I try to implement efficiently the sum of 2D arrays of size (4,N). I fail to obtain good performance with different implementations: msum\_native corresponds to the std Julia sum method, msum\_2D1D corresponds to a…

---

## [Adding new column to DataFrame with Query.jl](https://discourse.julialang.org/t/adding-new-column-to-dataframe-with-query-jl/10889)

<div class="topic-metadata">

**Author:** [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Replies:** 2\
**Last updated:** [May 14, 2018, 9:22pm UTC](https://discourse.julialang.org/t/adding-new-column-to-dataframe-with-query-jl/10889 "2018-05-14T21:22:43Z")

</div>

Is there a way to use Query to just add a new column? In the docs there’s this example: using Query, DataFrames df = DataFrame(name=\["John", "Sally", "Kirk"\], age=\[23., 42., 59.\], children=\[3,5,2\]) x = @from i in df b…

---

## [Type stability for returning abstract types](https://discourse.julialang.org/t/type-stability-for-returning-abstract-types/10890)

<div class="topic-metadata">

**Author:** [@mbesancon](https://discourse.julialang.org/u/mbesancon)\
**Replies:** 1\
**Last updated:** [May 14, 2018, 8:09pm UTC](https://discourse.julialang.org/t/type-stability-for-returning-abstract-types/10890 "2018-05-14T20:09:18Z")

</div>

I’m trying to define the return status of a function as an empty struct which type depends on the symbol passed to the function: abstract type ABS end struct A \<: ABS end struct B \<: ABS end struct C \<: ABS end f(::Typ…

---

## [Find out size of computer's memory?](https://discourse.julialang.org/t/find-out-size-of-computers-memory/10888)

<div class="topic-metadata">

**Author:** [@magzpavz](https://discourse.julialang.org/u/magzpavz)\
**Replies:** 1\
**Last updated:** [May 14, 2018, 7:32pm UTC](https://discourse.julialang.org/t/find-out-size-of-computers-memory/10888 "2018-05-14T19:32:50Z")

</div>

tldr: Is there a way to find out how much memory the computer has? There are environment variables for the processor properties, so something similar? So why do I want to do this? I’ve got a big file of data which I ne…

---

## [Improving Speed for a Novice](https://discourse.julialang.org/t/improving-speed-for-a-novice/10886)

<div class="topic-metadata">

**Author:** [@Donald\_Williams](https://discourse.julialang.org/u/Donald_Williams)\
**Replies:** 7\
**Last updated:** [May 14, 2018, 5:47pm UTC](https://discourse.julialang.org/t/improving-speed-for-a-novice/10886 "2018-05-14T17:47:22Z")

</div>

Hi: I am mostly a R user, but am currently developing a package that has the primary functions written in Julia. This package is for estimating very large (inverse) co-variance matrices. I have considerable speed gains …

---

## [Attobot did not delete a PR when I removed the tag](https://discourse.julialang.org/t/attobot-did-not-delete-a-pr-when-i-removed-the-tag/10884)

<div class="topic-metadata">

**Author:** [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Replies:** 5\
**Last updated:** [May 14, 2018, 1:52pm UTC](https://discourse.julialang.org/t/attobot-did-not-delete-a-pr-when-i-removed-the-tag/10884 "2018-05-14T13:52:56Z")

</div>

Hi guys! I submitted yesterday a package to METADATA (https://github.com/JuliaLang/METADATA.jl/pull/14635) and, after some discussion, I decided to move it from my personal account to an Organization. Hence, I deleted t…

---

## [Ptr{Ptr{Cint}}](https://discourse.julialang.org/t/ptr-ptr-cint/10883)

<div class="topic-metadata">

**Author:** [@tobias.knopp](https://discourse.julialang.org/u/tobias.knopp)\
**Replies:** 4\
**Last updated:** [May 14, 2018, 1:10pm UTC](https://discourse.julialang.org/t/ptr-ptr-cint/10883 "2018-05-14T13:10:16Z")

</div>

Hi, does someone know how to replace Ptr{Ptr{Cint}} by a Ref based solution? Example code is: https://github.com/JuliaIO/HDF5.jl/blob/88a80661357844ccf0bc0e6a46e419e7bf8a68e5/src/HDF5.jl#L1602 Definition of C functi…

---

## [How to get the commit of HEAD of a Julia package?](https://discourse.julialang.org/t/how-to-get-the-commit-of-head-of-a-julia-package/10877)

<div class="topic-metadata">

**Author:** [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Replies:** 11\
**Last updated:** [May 14, 2018, 11:16am UTC](https://discourse.julialang.org/t/how-to-get-the-commit-of-head-of-a-julia-package/10877 "2018-05-14T11:16:38Z")

</div>

Is there a way to get the commit of HEAD of a Julia package from within Julia without using git commands in shell? Googling gave the following command git rev-parse HEAD in git, so is there an equivalent in LibGit2 or Pk…

---

## [Calling Julia shared library from Python, linking libraries](https://discourse.julialang.org/t/calling-julia-shared-library-from-python-linking-libraries/9169)

<div class="topic-metadata">

**Author:** [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Replies:** 2\
**Last updated:** [May 14, 2018, 8:23am UTC](https://discourse.julialang.org/t/calling-julia-shared-library-from-python-linking-libraries/9169 "2018-05-14T08:23:20Z")

</div>

Hi all, I’m trying to get PackageCompiler to emit Python wrappers for shared libraries compiled from Julia packages. I got as far as this minimal test: https://github.com/JuliaLang/PackageCompiler.jl/tree/sd/py\_so/tes…

---

## [System commands](https://discourse.julialang.org/t/system-commands/10618)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 7\
**Last updated:** [May 14, 2018, 7:44am UTC](https://discourse.julialang.org/t/system-commands/10618 "2018-05-14T07:44:21Z")

</div>

Hi, I am want to run a system command (executing a file) from inside a code written in Julia. However, writing run(\`echo Hello\`) throws an error could not spawn \`echo Hello\`: no such file or directory (ENOENT) in ru…

---

## [What is a SimpleVector? How to convert it to a String](https://discourse.julialang.org/t/what-is-a-simplevector-how-to-convert-it-to-a-string/10875)

<div class="topic-metadata">

**Author:** [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Replies:** 2\
**Last updated:** [May 13, 2018, 11:58pm UTC](https://discourse.julialang.org/t/what-is-a-simplevector-how-to-convert-it-to-a-string/10875 "2018-05-13T23:58:32Z")

</div>

I find that DocStr uses SimpleVector to store the text, I would like to convert it back to a String, is it possible? How?

---

## [Mapreduce over selected indices](https://discourse.julialang.org/t/mapreduce-over-selected-indices/10866)

<div class="topic-metadata">

**Author:** [@jekyllstein](https://discourse.julialang.org/u/jekyllstein)\
**Replies:** 3\
**Last updated:** [May 13, 2018, 5:26pm UTC](https://discourse.julialang.org/t/mapreduce-over-selected-indices/10866 "2018-05-13T17:26:24Z")

</div>

I was writing a program involving a lot of mapreduce operations over pieces of arrays. To make things concrete here I’ll use the example of a sum over squared elements of an array: using BenchmarkTools x = rand(10000) …

---

## [Print reports of all nested tests](https://discourse.julialang.org/t/print-reports-of-all-nested-tests/10863)

<div class="topic-metadata">

**Author:** [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Replies:** 1\
**Last updated:** [May 13, 2018, 2:31am UTC](https://discourse.julialang.org/t/print-reports-of-all-nested-tests/10863 "2018-05-13T02:31:21Z")

</div>

Hi guys! I have a lot of nested tests, something like @testset "Test Set" begin @testset "Test Sub Set" ... end However, the reports of the subtests are only printed if something fails. How can I make Julia pr…

---

## [Function which returns an immutable type using Metaprogramming](https://discourse.julialang.org/t/function-which-returns-an-immutable-type-using-metaprogramming/10824)

<div class="topic-metadata">

**Author:** [@bkang119](https://discourse.julialang.org/u/bkang119)\
**Replies:** 4\
**Last updated:** [May 12, 2018, 3:49pm UTC](https://discourse.julialang.org/t/function-which-returns-an-immutable-type-using-metaprogramming/10824 "2018-05-12T15:49:51Z")

</div>

Hi I have a question on defining a function that returns an immutable type. To be specific, let me define two immutable types: immutable test1 a::Int64 b::Int64 end immutable test2 a::Int64 b::Bool end…

---

## [Recursive \`fieldnames()\`?](https://discourse.julialang.org/t/recursive-fieldnames/10852)

<div class="topic-metadata">

**Author:** [@chobbes](https://discourse.julialang.org/u/chobbes)\
**Replies:** 2\
**Last updated:** [May 12, 2018, 8:23am UTC](https://discourse.julialang.org/t/recursive-fieldnames/10852 "2018-05-12T08:23:01Z")

</div>

Is there a way to apply fieldnames() resursively so that all fieldnames can be printed in cascade? I know that dump() sort of does this, but it prints literally everything - it’s hard to pick ham from peas.

---

## [Submatrix replacement error in a matrix](https://discourse.julialang.org/t/submatrix-replacement-error-in-a-matrix/10849)

<div class="topic-metadata">

**Author:** [@paulobuchsbaum](https://discourse.julialang.org/u/paulobuchsbaum)\
**Replies:** 6\
**Last updated:** [May 12, 2018, 4:05am UTC](https://discourse.julialang.org/t/submatrix-replacement-error-in-a-matrix/10849 "2018-05-12T04:05:23Z")

</div>

In this below code there is a weird error message: joja = \[1 2 3; 4 5 6; 7 8 9\] joja\[2:3,2:3\] = \[1 2; 3 4 \] # ok joja2 = reshape(1:9,3,3) joja2\[2:3,2:3\] = \[1 2; 3 4 \] # error (reshaped array) joja3 = copy(joja2) joj…

---

## [Modifying Julia struct from C](https://discourse.julialang.org/t/modifying-julia-struct-from-c/10847)

<div class="topic-metadata">

**Author:** [@dm3](https://discourse.julialang.org/u/dm3)\
**Replies:** 2\
**Last updated:** [May 11, 2018, 10:08pm UTC](https://discourse.julialang.org/t/modifying-julia-struct-from-c/10847 "2018-05-11T22:08:47Z")

</div>

I want to drive a Julia program from Java. There’s a lot of communication going Java-\>Julia on a known and very limited number of elements. I’ve come up with a zero-copy approach that I think could work, but need some gu…

---

## [How to refactor code which is using the fallback constructor](https://discourse.julialang.org/t/how-to-refactor-code-which-is-using-the-fallback-constructor/10841)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 2\
**Last updated:** [May 11, 2018, 1:20pm UTC](https://discourse.julialang.org/t/how-to-refactor-code-which-is-using-the-fallback-constructor/10841 "2018-05-11T13:20:29Z")

</div>

Per the v0.7 what’s new: The fallback constructor that calls convert is deprecated. Instead, new types should prefer to define constructors, and add convert methods that call those constructors only as necessary What…

---

## [How to assign real/imaginary part of complex array](https://discourse.julialang.org/t/how-to-assign-real-imaginary-part-of-complex-array/10818)

<div class="topic-metadata">

**Author:** [@bhawkins](https://discourse.julialang.org/u/bhawkins)\
**Replies:** 12\
**Last updated:** [May 11, 2018, 11:54am UTC](https://discourse.julialang.org/t/how-to-assign-real-imaginary-part-of-complex-array/10818 "2018-05-11T11:54:48Z")

</div>

I’m wondering if it’s possible to assign to the real or imaginary part of a complex array without an explicit loop. For example, I thought this might work, but it doesn’t julia\> z = rand(Complex64, 5); julia\> imag.(z) …

---

## [Sum of array as an others array value](https://discourse.julialang.org/t/sum-of-array-as-an-others-array-value/10827)

<div class="topic-metadata">

**Author:** [@St0n](https://discourse.julialang.org/u/St0n)\
**Replies:** 4\
**Last updated:** [May 11, 2018, 8:34am UTC](https://discourse.julialang.org/t/sum-of-array-as-an-others-array-value/10827 "2018-05-11T08:34:45Z")

</div>

Hi everyone, im new and this is my first question here. I’m wondering why this is not possible: If i Type: A=\[1.0, 2.0, 3.0, 4.0, 5.0\]; B=zeros(5); and then sum(A)=B\[1\] i get the error Message: error in method def…

---

## [Pkg.add() fails on 0.6.2 in Linux with certificate error behind proxy](https://discourse.julialang.org/t/pkg-add-fails-on-0-6-2-in-linux-with-certificate-error-behind-proxy/10826)

<div class="topic-metadata">

**Author:** [@sparrowhawk](https://discourse.julialang.org/u/sparrowhawk)\
**Replies:** 1\
**Last updated:** [May 11, 2018, 7:37am UTC](https://discourse.julialang.org/t/pkg-add-fails-on-0-6-2-in-linux-with-certificate-error-behind-proxy/10826 "2018-05-11T07:37:29Z")

</div>

Hi, I think we have something going on with our corporate proxy sever. I can’t do Pkg.add for any package any more. Pkg.add("MXNet") gives the following error: X509 - Certificate verification failed, e.g. CRL, CA or s…

---

## [Can Pkg.build on the canonical terminal REPL and inside VSCode REPL, but not with Atom/Juno's REPL](https://discourse.julialang.org/t/can-pkg-build-on-the-canonical-terminal-repl-and-inside-vscode-repl-but-not-with-atom-junos-repl/10760)

<div class="topic-metadata">

**Author:** [@zygmuntszpak](https://discourse.julialang.org/u/zygmuntszpak)\
**Replies:** 3\
**Last updated:** [May 11, 2018, 4:34am UTC](https://discourse.julialang.org/t/can-pkg-build-on-the-canonical-terminal-repl-and-inside-vscode-repl-but-not-with-atom-junos-repl/10760 "2018-05-11T04:34:22Z")

</div>

I’m unable to use or build certain packages when using Atom’s REPL (Juno), but can use/build the packages when launching Julia from my terminal or when using the REPL from inside VSCode. For example, issuing the followi…

---

## [Is "Data" a reserved keyword in Julia?](https://discourse.julialang.org/t/is-data-a-reserved-keyword-in-julia/10804)

<div class="topic-metadata">

**Author:** [@Yunde](https://discourse.julialang.org/u/Yunde)\
**Replies:** 5\
**Last updated:** [May 10, 2018, 8:46pm UTC](https://discourse.julialang.org/t/is-data-a-reserved-keyword-in-julia/10804 "2018-05-10T20:46:58Z")

</div>

I traced a problem of my project down to the keyword “Data”. I did not see any declaration in the documents that “Data” is reserved. Here is an example: # it works for "Data2" abstract type Data2 end; typeof(Data2) #…

---

## [How to reinterpret Float64 as two Float32's](https://discourse.julialang.org/t/how-to-reinterpret-float64-as-two-float32s/10808)

<div class="topic-metadata">

**Author:** [@magzpavz](https://discourse.julialang.org/u/magzpavz)\
**Replies:** 4\
**Last updated:** [May 10, 2018, 6:36pm UTC](https://discourse.julialang.org/t/how-to-reinterpret-float64-as-two-float32s/10808 "2018-05-10T18:36:38Z")

</div>

reinterpret can slice an Int64 into two Int32’s. Is there a way to do this for floats? Relatedly, is there an inverse of bits?

---

## [How to know which function calls a given function (without using debugger)?](https://discourse.julialang.org/t/how-to-know-which-function-calls-a-given-function-without-using-debugger/10810)

<div class="topic-metadata">

**Author:** [@chobbes](https://discourse.julialang.org/u/chobbes)\
**Replies:** 2\
**Last updated:** [May 10, 2018, 8:58am UTC](https://discourse.julialang.org/t/how-to-know-which-function-calls-a-given-function-without-using-debugger/10810 "2018-05-10T08:58:08Z")

</div>

I wonder if there is a way in which I can insert a couple lines of code in a function to know which function calls this one, e.g. by printing out some basic information of the caller, like location etc. I’m trying to und…

---

## [Ok to nuke the Pkg .cache directory?](https://discourse.julialang.org/t/ok-to-nuke-the-pkg-cache-directory/10805)

<div class="topic-metadata">

**Author:** [@rsrock](https://discourse.julialang.org/u/rsrock)\
**Replies:** 2\
**Last updated:** [May 10, 2018, 3:17am UTC](https://discourse.julialang.org/t/ok-to-nuke-the-pkg-cache-directory/10805 "2018-05-10T03:17:02Z")

</div>

I’ve exceeded my quota on a cluster, for the number of files allowed in my shared group directory. I noticed from the Package docs that all installed packages are downloaded into .cache/ within Pkg.dir. Is there any ha…

---

## [Memory allocation of user defined type](https://discourse.julialang.org/t/memory-allocation-of-user-defined-type/10803)

<div class="topic-metadata">

**Author:** [@bkang119](https://discourse.julialang.org/u/bkang119)\
**Replies:** 5\
**Last updated:** [May 9, 2018, 9:19pm UTC](https://discourse.julialang.org/t/memory-allocation-of-user-defined-type/10803 "2018-05-09T21:19:40Z")

</div>

I am using an array of a type that I define, but this seems to take bigger memory than I have thought. For example, if I check the memory allocated to ‘a = Int8\[1,1,1\]’, ‘Base.summarysize(a)’ gives 3 as expected. But t…

---

## [Why Builtin Dict \`ht\_keyindex\` use & rather than %?](https://discourse.julialang.org/t/why-builtin-dict-ht-keyindex-use-rather-than/10681)

<div class="topic-metadata">

**Author:** [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Replies:** 1\
**Last updated:** [May 9, 2018, 5:37pm UTC](https://discourse.julialang.org/t/why-builtin-dict-ht-keyindex-use-rather-than/10681 "2018-05-09T17:37:51Z")

</div>

I was reading the implementation of Dict, I don’t know why ht\_keyindex use (index & (sz-1)) + 1 rather than index % sz + 1, won’t the compiler optimize it? I use BenchmarkTools to check whether the previous implementatio…

---

## [Saving workspace to file](https://discourse.julialang.org/t/saving-workspace-to-file/10781)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 3\
**Last updated:** [May 9, 2018, 4:00pm UTC](https://discourse.julialang.org/t/saving-workspace-to-file/10781 "2018-05-09T16:00:48Z")

</div>

Commonly I run a large set of simulations over night/weekend. All of this information exists in a Jupyter notebook and if the browser/jupyter crashes everything is lost and needs to be redone for the next day. After this…

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

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