# General Usage

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

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

**Page:** 736

---

## [Diff! (in-place or preallocated output version of diff)](https://discourse.julialang.org/t/diff-in-place-or-preallocated-output-version-of-diff/41949)

<div class="topic-metadata">

**Author:** [@JeffFessler](https://discourse.julialang.org/u/JeffFessler)\
**Replies:** 2\
**Last updated:** [June 24, 2020, 3:16am UTC](https://discourse.julialang.org/t/diff-in-place-or-preallocated-output-version-of-diff/41949 "2020-06-24T03:16:31Z")

</div>

The Julia manual nicely makes the case for pre-allocating outputs: https://docs.julialang.org/en/latest/manual/performance-tips/#Pre-allocating-outputs-1 Yet the function diff that is used extensively in scientific com…

---

## [Is it possible to use an image (eg. jpg) as a 'marker' in plots?](https://discourse.julialang.org/t/is-it-possible-to-use-an-image-eg-jpg-as-a-marker-in-plots/41491)

<div class="topic-metadata">

**Author:** [@mantzaris](https://discourse.julialang.org/u/mantzaris)\
**Replies:** 2\
**Last updated:** [June 24, 2020, 1:52am UTC](https://discourse.julialang.org/t/is-it-possible-to-use-an-image-eg-jpg-as-a-marker-in-plots/41491 "2020-06-24T01:52:16Z")

</div>

I have a plot with a time series and another with a shapefile, and would like to plot some markers to highlight some parts of the figure. I would like those markers to be ‘images’ loaded from a file; eg png or jpg. Is th…

---

## [Register in General without GitHub](https://discourse.julialang.org/t/register-in-general-without-github/41958)

<div class="topic-metadata">

**Author:** [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Replies:** 1\
**Last updated:** [June 23, 2020, 9:52pm UTC](https://discourse.julialang.org/t/register-in-general-without-github/41958 "2020-06-23T21:52:27Z")

</div>

What’s the plan to register packages without GitHub? With the way GitHub is changing things up with a less useful website layout, I am anticipating moving on from the GitHub platform eventually. At the moment, I am pus…

---

## [Julia 1.3 and IJulia -- how to find Julia 1.3 as kernel?](https://discourse.julialang.org/t/julia-1-3-and-ijulia-how-to-find-julia-1-3-as-kernel/31689)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 9\
**Last updated:** [June 23, 2020, 8:55pm UTC](https://discourse.julialang.org/t/julia-1-3-and-ijulia-how-to-find-julia-1-3-as-kernel/31689 "2020-06-23T20:55:12Z")

</div>

I just removed Julia 1.2 and installed Julia 1.3 + renamed v1.2 to v1.3 in .julia\\environments + did \]instantiate and updated packages. When I fire up IJulia, Julia 1.2 shows up as the only available kernel (together wi…

---

## [How do I use \`@view\` correctly?](https://discourse.julialang.org/t/how-do-i-use-view-correctly/41955)

<div class="topic-metadata">

**Author:** [@affans](https://discourse.julialang.org/u/affans)\
**Replies:** 4\
**Last updated:** [June 23, 2020, 8:17pm UTC](https://discourse.julialang.org/t/how-do-i-use-view-correctly/41955 "2020-06-23T20:17:41Z")

</div>

I have a function that looked like the following. The explanation follows (which is fairly simple and probably easier to digest than the code). function main(mydat) for t = 1:141 daily\_sum = 0 …

---

## [Weird error: \`SystemError: memory mapping failed: Too many open files in system\`](https://discourse.julialang.org/t/weird-error-systemerror-memory-mapping-failed-too-many-open-files-in-system/41944)

<div class="topic-metadata">

**Author:** [@affans](https://discourse.julialang.org/u/affans)\
**Replies:** 2\
**Last updated:** [June 23, 2020, 7:36pm UTC](https://discourse.julialang.org/t/weird-error-systemerror-memory-mapping-failed-too-many-open-files-in-system/41944 "2020-06-23T19:36:41Z")

</div>

I am trying to run something in parallel. Suppose I have the following module loaded and that I am using ClusterManagers.jl to connect to a cluster. @everywhere module ldf using some packages... function read\_d…

---

## [How calculate time between two date?](https://discourse.julialang.org/t/how-calculate-time-between-two-date/41941)

<div class="topic-metadata">

**Author:** [@LancelacDulot](https://discourse.julialang.org/u/LancelacDulot)\
**Replies:** 2\
**Last updated:** [June 23, 2020, 3:00pm UTC](https://discourse.julialang.org/t/how-calculate-time-between-two-date/41941 "2020-06-23T15:00:29Z")

</div>

Hi all, I search to have the duration between tow date create by now(). I’m new julia’s user. I don’t know do this. Please help me!! Thank you for your help. :slight\_smile:

---

## [Writing compound structs with variable length strings to HDF5](https://discourse.julialang.org/t/writing-compound-structs-with-variable-length-strings-to-hdf5/29449)

<div class="topic-metadata">

**Author:** [@bender9000](https://discourse.julialang.org/u/bender9000)\
**Replies:** 1\
**Last updated:** [June 23, 2020, 2:49pm UTC](https://discourse.julialang.org/t/writing-compound-structs-with-variable-length-strings-to-hdf5/29449 "2020-06-23T14:49:19Z")

</div>

I am trying to write a compound type that contains a variable length string as a field to HDF5. Following is the approach that I took but the strings written to the H5 file are garbled as shown below: Creating compound …

---

## [Flux: different activation functions for different outputs](https://discourse.julialang.org/t/flux-different-activation-functions-for-different-outputs/41938)

<div class="topic-metadata">

**Author:** [@jmurray](https://discourse.julialang.org/u/jmurray)\
**Replies:** 0\
**Last updated:** [June 23, 2020, 2:30pm UTC](https://discourse.julialang.org/t/flux-different-activation-functions-for-different-outputs/41938 "2020-06-23T14:30:37Z")

</div>

I need to apply different activation functions to different outputs of a Flux layer. This requires a custom layer. I can modify an existing custom layer so that its only job is to apply a per-output activation function a…

---

## [Findfirst on sorted array](https://discourse.julialang.org/t/findfirst-on-sorted-array/4928)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 14\
**Last updated:** [June 23, 2020, 2:28pm UTC](https://discourse.julialang.org/t/findfirst-on-sorted-array/4928 "2020-06-23T14:28:32Z")

</div>

I have a sorted array of numbers: A = \[1, 4, 10, 15, 18\] I want to determine the first index where a value, v, occurs in this array (or 0 if it does not occur), like findfirst(A, v). But I want to exploit the fact that…

---

## [Pass cache to function](https://discourse.julialang.org/t/pass-cache-to-function/41934)

<div class="topic-metadata">

**Author:** [@jamblejoe](https://discourse.julialang.org/u/jamblejoe)\
**Replies:** 4\
**Last updated:** [June 23, 2020, 1:22pm UTC](https://discourse.julialang.org/t/pass-cache-to-function/41934 "2020-06-23T13:22:49Z")

</div>

Hi! I have a function which allocates a cache for calculations as function f(x::AbstractArray) cache = zeros(length(x)) # do some calculations end I now want to call this function very often (not in parallel) so I…

---

## [ArchGDAL, getfeature() error](https://discourse.julialang.org/t/archgdal-getfeature-error/41913)

<div class="topic-metadata">

**Author:** [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Replies:** 2\
**Last updated:** [June 23, 2020, 1:12pm UTC](https://discourse.julialang.org/t/archgdal-getfeature-error/41913 "2020-06-23T13:12:45Z")

</div>

hotspot\_path = "zoneforhotspot.geojson" d = ArchGDAL.read(hotspot\_path) layer = ArchGDAL.getlayer(d, 0) fs = ArchGDAL.getfeature(layer, 1) do f ArchGDAL.getgeom(f) end fs d = ArchGDAL.read(hotspot\_path) layer = …

---

## [How to debug memory issues when working with an external C library](https://discourse.julialang.org/t/how-to-debug-memory-issues-when-working-with-an-external-c-library/41927)

<div class="topic-metadata">

**Author:** [@sloede](https://discourse.julialang.org/u/sloede)\
**Replies:** 1\
**Last updated:** [June 23, 2020, 12:02pm UTC](https://discourse.julialang.org/t/how-to-debug-memory-issues-when-working-with-an-external-c-library/41927 "2020-06-23T12:02:26Z")

</div>

Has anyone here experience in interfacing Julia to a C++ library via library-provided C bindings, specifically in debugging memory issues? I am trying to recreate (or at least mimic) the C++ interface in Julia by writin…

---

## [How to load with Julia a h5 file created from Keras in Python ? With Flux.jl or with another ML package?](https://discourse.julialang.org/t/how-to-load-with-julia-a-h5-file-created-from-keras-in-python-with-flux-jl-or-with-another-ml-package/41903)

<div class="topic-metadata">

**Author:** [@steph\_de\_paris](https://discourse.julialang.org/u/steph_de_paris)\
**Replies:** 1\
**Last updated:** [June 23, 2020, 11:11am UTC](https://discourse.julialang.org/t/how-to-load-with-julia-a-h5-file-created-from-keras-in-python-with-flux-jl-or-with-another-ml-package/41903 "2020-06-23T11:11:39Z")

</div>

Hi, Is there a simple way to load with Julia a h5 file created with Python3-Keras without rebuilding this h5 model ? More precisely, what should be the Julia version of this simple Python3 script : # Python3 code of t…

---

## [Custom IO performance - loading variables from byte array](https://discourse.julialang.org/t/custom-io-performance-loading-variables-from-byte-array/41814)

<div class="topic-metadata">

**Author:** [@sairus7](https://discourse.julialang.org/u/sairus7)\
**Replies:** 2\
**Last updated:** [June 23, 2020, 9:39am UTC](https://discourse.julialang.org/t/custom-io-performance-loading-variables-from-byte-array/41814 "2020-06-23T09:39:46Z")

</div>

I want to load several variables of different bitstypes from a packed byte vector. For example, Int16, Int32, Int16 from 8-byte chunk of memory. I’ve tried several approaches to find a most efficient way: Using IOBuf…

---

## [EOFError: read end of file](https://discourse.julialang.org/t/eoferror-read-end-of-file/41921)

<div class="topic-metadata">

**Author:** [@benoitseron](https://discourse.julialang.org/u/benoitseron)\
**Replies:** 1\
**Last updated:** [June 23, 2020, 9:17am UTC](https://discourse.julialang.org/t/eoferror-read-end-of-file/41921 "2020-06-23T09:17:50Z")

</div>

Hello, I’ve started using Atom and everything went fine for the couple of times but then I got stuck at this repeating error: EOFError: read end of file in require at base/loading.jl:922 in require at base/loading.jl:…

---

## [Display("text.html", "\<script\>\</script\>") error](https://discourse.julialang.org/t/display-text-html-script-script-error/41919)

<div class="topic-metadata">

**Author:** [@Sijun](https://discourse.julialang.org/u/Sijun)\
**Replies:** 0\
**Last updated:** [June 23, 2020, 8:13am UTC](https://discourse.julialang.org/t/display-text-html-script-script-error/41919 "2020-06-23T08:13:28Z")

</div>

I used to use display("text.html", "\<script\>\</script\>") to include javascript plot or a raw HTML in Weave doc. But today I encountered the following error: ERROR: MethodError: no method matching show(::IOContext{Base.G…

---

## [How to use a flag in Regex()?](https://discourse.julialang.org/t/how-to-use-a-flag-in-regex/41917)

<div class="topic-metadata">

**Author:** [@Fred](https://discourse.julialang.org/u/Fred)\
**Replies:** 2\
**Last updated:** [June 23, 2020, 8:38am UTC](https://discourse.julialang.org/t/how-to-use-a-flag-in-regex/41917 "2020-06-23T08:38:24Z")

</div>

Hi, I wan’t to use a variable interpolation and a regex flag at the same time, is it possible ? For example julia\> x="StRinG" "StRinG" julia\> Regex("$x") r"StRinG" # if I wan to ignore to ignore case with a flag : j…

---

## [Allowable fields for Project.toml](https://discourse.julialang.org/t/allowable-fields-for-project-toml/41885)

<div class="topic-metadata">

**Author:** [@fusion809](https://discourse.julialang.org/u/fusion809)\
**Replies:** 2\
**Last updated:** [June 23, 2020, 7:35am UTC](https://discourse.julialang.org/t/allowable-fields-for-project-toml/41885 "2020-06-23T07:35:29Z")

</div>

I’d just like to know what fields are allowed in the Project.toml file of a package. I’ve conducted DuckDuckGo searches for documentation regarding the Project.toml of Julia packages and so far I have not found anything.…

---

## [LoadError: ArgumentError: Package XXX not found in current path](https://discourse.julialang.org/t/loaderror-argumenterror-package-xxx-not-found-in-current-path/41886)

<div class="topic-metadata">

**Author:** [@eichhoernchen](https://discourse.julialang.org/u/eichhoernchen)\
**Replies:** 1\
**Last updated:** [June 23, 2020, 7:27am UTC](https://discourse.julialang.org/t/loaderror-argumenterror-package-xxx-not-found-in-current-path/41886 "2020-06-23T07:27:35Z")

</div>

Hello ! I work with Ubuntu 14.04 LTS. I worked with Julia (Version 0.2.1) but suddenly encountered problems when I asked for a connection between Gurobi (newly installed) and Julia. The message is: julia\> import Pkg; …

---

## [How to uninstall properly Julia under Unbuntu 14.04 LTS](https://discourse.julialang.org/t/how-to-uninstall-properly-julia-under-unbuntu-14-04-lts/41888)

<div class="topic-metadata">

**Author:** [@eichhoernchen](https://discourse.julialang.org/u/eichhoernchen)\
**Replies:** 1\
**Last updated:** [June 23, 2020, 7:26am UTC](https://discourse.julialang.org/t/how-to-uninstall-properly-julia-under-unbuntu-14-04-lts/41888 "2020-06-23T07:26:49Z")

</div>

Hello! I encounter issues with Julia. I work with Ubuntu 14.04 LTS. I worked with Julia (Version 0.2.1) but suddenly encountered problems when I asked for a connection between Gurobi (newly installed) and Julia. The m…

---

## [Pointer error, related to variable scope](https://discourse.julialang.org/t/pointer-error-related-to-variable-scope/41910)

<div class="topic-metadata">

**Author:** [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Replies:** 2\
**Last updated:** [June 23, 2020, 6:34am UTC](https://discourse.julialang.org/t/pointer-error-related-to-variable-scope/41910 "2020-06-23T06:34:45Z")

</div>

I create a struct as a global variable named g\_preload\_data which contains a member variable hotspot\_area in preload.jl. The member variable hotspot\_area is initialized by creating a ArchGDAL geometry object. When I u…

---

## [Packaging: why can't Julia find Test in Travis?](https://discourse.julialang.org/t/packaging-why-cant-julia-find-test-in-travis/41907)

<div class="topic-metadata">

**Author:** [@fusion809](https://discourse.julialang.org/u/fusion809)\
**Replies:** 2\
**Last updated:** [June 23, 2020, 5:48am UTC](https://discourse.julialang.org/t/packaging-why-cant-julia-find-test-in-travis/41907 "2020-06-23T05:48:26Z")

</div>

I’ve got these really basic .travis.yml and test/runtests.jl files and in the Travis log I’m getting the error: $ julia --check-bounds=yes --color=yes -e "if VERSION \< v\\"0.7.0-DEV.5183\\"; Pkg.test(\\"${JL\_PKG}\\", covera…

---

## [Safe loop with push! multi-threading](https://discourse.julialang.org/t/safe-loop-with-push-multi-threading/41892)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 7\
**Last updated:** [June 23, 2020, 2:36am UTC](https://discourse.julialang.org/t/safe-loop-with-push-multi-threading/41892 "2020-06-23T02:36:01Z")

</div>

Hello, I would like to use multi-threading to speed-up a for loop. For each instance, an expensive computation is done and then the result is pushed at the end of an array. Here is toy example: x = collect(1:10) f(x)…

---

## [Random.seed!() doesn't work in Ubuntu machine for parallel running?](https://discourse.julialang.org/t/random-seed-doesnt-work-in-ubuntu-machine-for-parallel-running/41904)

<div class="topic-metadata">

**Author:** [@Jing\_Zhang](https://discourse.julialang.org/u/Jing_Zhang)\
**Replies:** 0\
**Last updated:** [June 23, 2020, 1:02am UTC](https://discourse.julialang.org/t/random-seed-doesnt-work-in-ubuntu-machine-for-parallel-running/41904 "2020-06-23T01:02:48Z")

</div>

I was doing parallel running using multi-cores. Codes are as below. I ran twice of the below codes and Mac gave me the same results. However, when I tried to run the same codes in a Ubuntu machine, different runs gave me…

---

## [Best way to express this algebra between Types](https://discourse.julialang.org/t/best-way-to-express-this-algebra-between-types/41891)

<div class="topic-metadata">

**Author:** [@francesco.alemanno](https://discourse.julialang.org/u/francesco.alemanno)\
**Replies:** 1\
**Last updated:** [June 22, 2020, 10:32pm UTC](https://discourse.julialang.org/t/best-way-to-express-this-algebra-between-types/41891 "2020-06-22T22:32:45Z")

</div>

struct Perturbator rng::AbstractRNG end function (a::Perturbator)() randn(a.rng) end const MultiLike = Union{Tuple,Array} +′(a,b) = a + b -′(a,b) = a - b \*′(a,b) = a \* b /′(a,b) = a / b +′(a::T,b) where T \<: …

---

## [Performance of value type construction](https://discourse.julialang.org/t/performance-of-value-type-construction/41603)

<div class="topic-metadata">

**Author:** [@mtfishman](https://discourse.julialang.org/u/mtfishman)\
**Replies:** 1\
**Last updated:** [June 22, 2020, 8:11pm UTC](https://discourse.julialang.org/t/performance-of-value-type-construction/41603 "2020-06-22T20:11:35Z")

</div>

I noticed the following performance discrepancy between making a value type and making the instance of a value type using a runtime value: julia\> using BenchmarkTools julia\> x = "x" "x" julia\> f(x::String) = Val{Symbo…

---

## [LIFO Channels](https://discourse.julialang.org/t/lifo-channels/31343)

<div class="topic-metadata">

**Author:** [@jtackm](https://discourse.julialang.org/u/jtackm)\
**Replies:** 3\
**Last updated:** [June 22, 2020, 7:47pm UTC](https://discourse.julialang.org/t/lifo-channels/31343 "2020-06-22T19:47:03Z")

</div>

I have a parallel computation workflow that uses RemoteChannel-\>Channel to communicate results between master and worker nodes. Channels by default work like a queue (FIFO): using Distributed julia\> shared\_job\_q = Remo…

---

## [Specifying column type efficiently in CSV.read for large datasets](https://discourse.julialang.org/t/specifying-column-type-efficiently-in-csv-read-for-large-datasets/41866)

<div class="topic-metadata">

**Author:** [@bray2016](https://discourse.julialang.org/u/bray2016)\
**Replies:** 4\
**Last updated:** [June 22, 2020, 6:07pm UTC](https://discourse.julialang.org/t/specifying-column-type-efficiently-in-csv-read-for-large-datasets/41866 "2020-06-22T18:07:47Z")

</div>

Hello all, Complete Julia noob here. I am trying to figure out how to work with large datasets in Julia. I am trying to import a dataset that has missing values. It seems that Julia defaults to importing all these colum…

---

## [CUDNNError when using Flux within a Task](https://discourse.julialang.org/t/cudnnerror-when-using-flux-within-a-task/39199)

<div class="topic-metadata">

**Author:** [@jonathan-laurent](https://discourse.julialang.org/u/jonathan-laurent)\
**Replies:** 15\
**Last updated:** [June 22, 2020, 5:33pm UTC](https://discourse.julialang.org/t/cudnnerror-when-using-flux-within-a-task/39199 "2020-06-22T17:33:40Z")

</div>

I have been trying to release a Flux backend for my AlphaZero.jl library, but I am encountering a mysterious CUDNN error (CUDNN\_STATUS\_INTERNAL\_ERROR). Here is some info: The error happens consistently at every run, a…

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

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