[julia-users] Re: UndefRefError when deepcopying a nullable abstract type

2015-11-29 Thread Uri Patish
Small correction to the overloaded deepcopy. Seems that the right way to overload deepcopy is to overload deepcopy_internal, and not deepcopy itself. Thus the added function should be, Base.deepcopy_internal{T}(x::Nullable{T}, dict::ObjectIdDict) = isnull(x) ? Nullable{T}() :

[julia-users] Re: UndefRefError when deepcopying a nullable abstract type

2015-11-29 Thread Uri Patish
Small correction to the overloaded deepcopy. Seems that the right way to overload deepcopy is to overload deepcopy_internal, and not deepcopy itself. Thus the added function should be, Base.deepcopy_internal{T}(x::Nullable{T}, dict::ObjectIdDict) = isnull(x) ? Nullable{T}() :

[julia-users] Re: `findmin` with arbitrary comparison operator?

2015-11-29 Thread Júlio Hoffimann
Hi Erik, All you need to do is specialize the < operator for your tuple type. Please check the definition of findmin by running: @edit findmin([1,2,3]) You'll see the implementation is quite trivial. Let us know if you weren't able to make it work. Best, -Júlio Em domingo, 29 de novembro de

Re: [julia-users] float(X) vs. map(Float64, X)

2015-11-29 Thread Yichao Yu
On Sun, Nov 29, 2015 at 6:02 PM, Júlio Hoffimann wrote: > Hi, > > Could you please confirm Xf = float(X) is a shortcut for Xf = map(Float64, > X) on a 64bits machine? No it isn't and it's independ of whether it's 32 or 64bits. Depending one what exactly you are doing,

[julia-users] UndefRefError when deepcopying a nullable abstract type

2015-11-29 Thread Uri Patish
Hi, I came across the following issue. If I instantiate a Nullable{T} where T is an abstract type, and then try call deepcopy on it, I get UndefRefError. For example, julia> a = Nullable{Real}() Nullable{Real}() julia> b = deepcopy(a) ERROR: UndefRefError: access to undefined reference in

Re: [julia-users] Re: slow wordcount

2015-11-29 Thread Milan Bouchet-Valat
Le dimanche 29 novembre 2015 à 08:28 -0800, Cedric St-Jean a écrit : > What I would try: > > 1. ProfileView to pinpoint the bottleneck further > 2. FastAnonymous to fix the lambda > 3. http://julia-demo.readthedocs.org/en/latest/manual/performance-tip > s.html In particular, you may check

Re: [julia-users] Re: Arrays of arrays.

2015-11-29 Thread Dan
comprehension is indeed fine (and fast). should remember to read/search the docs and issues more (as usual). fill(function,dims) is also good. wondering, if it might be productive to make fill warn or even err when there is ambiguity and make versions: `shallowfill`,`copyfill`,`deepcopyfill`.

[julia-users] Re: tip for using Julia on OS X

2015-11-29 Thread James Gilbert
I have ~/bin in my PATH, and a symlink to julia in there.

Re: [julia-users] CUDArt gc

2015-11-29 Thread davidino
Ah, I see -- a newbie error! Adding a CUDArt.device_synchronize() call after the loop shows that indeed it's just the GPU catching up. Many thanks Tim (big fan of your work). David On Saturday, November 28, 2015 at 8:28:12 PM UTC, Tim Holy wrote: > > Are you sure you're not being fooled by

[julia-users] Re: equivalent of fseek?

2015-11-29 Thread James Gilbert
I believe that in seek(s, pos), pos is the absolute position from the start of the stream, and in skip(s, offset), offset is relative to the current position. A "stream" can be any IO type, such as a file on disk or an IOBuffer in memory. On Saturday, November 28, 2015 at 6:00:14 PM UTC, Rajn

[julia-users] Re: Arrays of arrays.

2015-11-29 Thread Aleksandr Mikheev
Thank you, guys. I guess this [Int[] for i = 1:3, j=1:3, k=1:3] is exactly what I need. At the same time, now I understand that I should read more about creating and filling arrays. :) Once again, thanks.

[julia-users] Re: using PyCall on an event stream

2015-11-29 Thread Steven G. Johnson
Is this in the Julia REPL?

Re: [julia-users] Re: Arrays of arrays.

2015-11-29 Thread Milan Bouchet-Valat
Le dimanche 29 novembre 2015 à 04:21 -0800, Dan a écrit : > Since this situation comes up once in a while, it might be nice to > have a copyfill which does a copy on each cell. In code: > > function copyfill!{T}(a::Array{T}, x) > xT = convert(T, x) > for i in eachindex(a) >

[julia-users] Arrays of arrays.

2015-11-29 Thread Aleksandr Mikheev
Hi all. Once again I have some questions about Julia. I know that there is a possibility to create a list of arrays. For exmple: s = fill(Array(Int64,1),4) And then I can do something like this: s[1] = [1; 2] s[1] = [s[1]; 5] By parity of reasoning I did this: s = fill(Array(Int64,1),4,4,4)

[julia-users] Re: tip for using Julia on OS X

2015-11-29 Thread Sheehan Olver
This won't work in El Capitan as even root is not allowed to write to /usr/bin. You could put it in /usr/local/bin if /usr/local exists, otherwise use the alias version, or add "/Applications/Julia-0.4.1.app/Contents/Resources/ julia/bin/" to PATH On Sunday, November 29, 2015 at 8:00:50 AM

Re: [julia-users] Arrays of arrays.

2015-11-29 Thread Milan Bouchet-Valat
Le dimanche 29 novembre 2015 à 02:51 -0800, Aleksandr Mikheev a écrit : > Hi all. Once again I have some questions about Julia. > > I know that there is a possibility to create a list of arrays. For > exmple: > > s = fill(Array(Int64,1),4) > > And then I can do something like this: > > s[1] =

[julia-users] Re: Arrays of arrays.

2015-11-29 Thread James Gilbert
This code: fill(Array(Int64,1),3,3,3) Constructs a 3D array of length 3 in each dimension where each element is a reference to the same single element array containing a single Int64. The Int64 is uninitialised, so it has the value of whatever that piece of memory happens to hold. You

[julia-users] Re: Arrays of arrays.

2015-11-29 Thread James Gilbert
Sorry, this: fill(Array*{*Int64,1*}*,3,3,3) creates a 3D array of types. So that's just as useless.

[julia-users] Re: Arrays of arrays.

2015-11-29 Thread Kristoffer Carlsson
I guess the simplest would be: [Int[] for i = 1:3, j=1:3, k=1:3] And to repeat what Milan already said, you don't want fill! because then all your arrays point to the same memory location. On Sunday, November 29, 2015 at 11:51:28 AM UTC+1, Aleksandr Mikheev wrote: > > Hi all. Once again I

[julia-users] Re: Need help building Julia on Ubuntu 14.04

2015-11-29 Thread Sisyphuss
My suggestion is not to build it from scratch, because the building process is quite long. On Saturday, November 28, 2015 at 6:19:28 PM UTC+1, Ajay Kumar wrote: > > Dear all > > I am trying to build Julia with more than one processor on my PC. > I am working on an Ubuntu 14.04 OS by using

[julia-users] Re: slow wordcount

2015-11-29 Thread Cedric St-Jean
What I would try: 1. ProfileView to pinpoint the bottleneck further 2. FastAnonymous to fix the lambda 3. http://julia-demo.readthedocs.org/en/latest/manual/performance-tips.html In particular, you may check `code_typed`. I don't have experience with `split` and `eachline`. It's possible that

[julia-users] Is it necessary to manually protect global variables from getting clobbered inside a macro?

2015-11-29 Thread Ray Toal
Hi I have taken the example from the Metaprogramming page on the docs (many of you will know it well): macro time(ex) return quote local t0 = time() local val = $ex local t1 = time() println("elapsed time: ", t1-t0, " seconds") val end end Julia's hygienic behavior

Re: [julia-users] float(X) vs. map(Float64, X)

2015-11-29 Thread David P. Sanders
NaNs are not equal to each other.

[julia-users] Converting String to DataType - don't quite get it!!

2015-11-29 Thread Rajn
Hi, I am trying to read a binary file by doing the following: read(fid, DataType[i], Numelements[i]). I would like to extract DataType from a user input which is read from a column (whose header is 'type') of DataTable which is a string array. For example DataTable[1,:type] = "uint8"

Re: [julia-users] float(X) vs. map(Float64, X)

2015-11-29 Thread Júlio Hoffimann
Hi David, Yes, I got confused for a second. Yichao clarified on the GitHub issue. I still don't know why these two functions are causing different behavior in my package though. -Júlio 2015-11-29 18:44 GMT-08:00 David P. Sanders : > NaNs are not equal to each other.

[julia-users] Re: equivalent of fseek?

2015-11-29 Thread Rajn
Thanks James for pointing it out. It did work. Is there a need for a C++ like function fseek in that case at all? On Saturday, November 28, 2015 at 1:00:14 PM UTC-5, Rajn wrote: > > Is there an fseek in Julia which returns to an offset from the beginning > of the buffer during a binary file

Re: [julia-users] Is it necessary to manually protect global variables from getting clobbered inside a macro?

2015-11-29 Thread Yichao Yu
On Sun, Nov 29, 2015 at 6:35 PM, Ray Toal wrote: > Hi > > I have taken the example from the Metaprogramming page on the docs (many of > you will know it well): Please finish reading the metaprogramming doc and especially about the esc function. > > macro time(ex) > return

[julia-users] Re: Converting String to DataType - don't quite get it!!

2015-11-29 Thread Rajn
Ok, I got it! It is just a matter of converting array to an element read(fid, reshape(T[1])[1] ,keyNumElem[1])... Now it works but I have a follow on question. What are the overheads in doing this conversion. I am reading a 2Terabyte data fileand want to make it really efficient by

Re: [julia-users] float(X) vs. map(Float64, X)

2015-11-29 Thread Júlio Hoffimann
It has something to do with NaN representation: # 64bits a = ones(10,10) a[:,5] = NaN b = float(a) c = map(Float64, a) b == c # this should be true, but it's not I'll open an issue on GitHub. -Júlio 2015-11-29 15:14 GMT-08:00 Júlio Hoffimann : > Hi Yichao, > > What

Re: [julia-users] Is it necessary to manually protect global variables from getting clobbered inside a macro?

2015-11-29 Thread Isaiah Norton
> > how do I work around the fact that I might want to call @time with an > expression involving variables and I don't want my expression's result to > be wrong just because it happens to share variables with those in the macro > body? Use `esc` in the macro definition. See the example regarding

Re: [julia-users] Is it necessary to manually protect global variables from getting clobbered inside a macro?

2015-11-29 Thread Isaiah Norton
> > Regarding your question on StackOverflow > > http://stackoverflow.com/questions/33989020/macro-call-vs-macro-definition-environment-in-julia Actually, I misunderstood the problem. This looks like an open issue: https://github.com/JuliaLang/julia/issues/4873 On Sun, Nov 29, 2015 at 9:01 PM,

[julia-users] Re: Concatenation without splatting

2015-11-29 Thread Tomas Lycken
For hcat, what shape would you want the output to have? With your example input, the result of vcat is straightforward: v = [[1],[2,3],[4,5]] vcat(v...) # -> [1, 2, 3, 4, 5] But for hcat, what output would you want? hcat(v...) throws a DimensionMismatch error stating that vectors must have

Re: [julia-users] float(X) vs. map(Float64, X)

2015-11-29 Thread Eric Forgy
Hi Julio, I'm not sure if this helps (I'm still learning the ropes), but you can find the definition of "float(x)" in base/float.jl on line 121: float(x) = convert(AbstractFloat, x) I found this from the following command: julia>

Re: [julia-users] float(X) vs. map(Float64, X)

2015-11-29 Thread Júlio Hoffimann
Hi Eric, I did all those steps, but thanks for spending time with it. :) -Jùlio 2015-11-29 20:56 GMT-08:00 Eric Forgy : > Hi Julio, > > I'm not sure if this helps (I'm still learning the ropes), but you can > find the definition of "float(x)" in base/float.jl >

[julia-users] Re: Versioning for unregistered Packages

2015-11-29 Thread Leonardo
Issue closed. I've omitted to register "offline" package (git repo is on local disk) with command: Pkg.register("", "git://.git") Thanks for all suggestions Leonardo Il giorno lunedì 23 novembre 2015 09:06:47 UTC+1, Leonardo ha scritto: > > Moreover, digging into Pkg code, I've found that

Re: [julia-users] Re: slow wordcount

2015-11-29 Thread Yichao Yu
On Sun, Nov 29, 2015 at 11:42 AM, Milan Bouchet-Valat wrote: > Le dimanche 29 novembre 2015 à 08:28 -0800, Cedric St-Jean a écrit : >> What I would try: >> >> 1. ProfileView to pinpoint the bottleneck further >> 2. FastAnonymous to fix the lambda >> 3.