Re: [julia-users] How to enter a file using gallium?

2016-11-21 Thread Michele Zaffalon
How would you do that in MATLAB?

On Mon, Nov 21, 2016 at 5:00 PM,   wrote:
> Well, if A is a complicated object/structure, it'll be almost impossible to
> first make up an A and call @enter function_to_debug(A).
>
>
>
> On Monday, November 21, 2016 at 2:32:16 PM UTC, Isaiah wrote:
>>>
>>> Any other means without resorting to breakpoints??
>>
>>
>> Use `@enter function_to_debug( ... )` with the value of A that you are
>> interested in.
>>
>> On Mon, Nov 21, 2016 at 6:30 AM,  wrote:
>>>
>>> Bump up for the following question:
>>>
>>> Suppose I have the following code where the variable A is defined
>>> multiple times and after each definition it is used by the same function
>>> function_to_debug. How can I step in function_to_debug with the first
>>> definition/instantiation of A?
>>> A = ...
>>> function_to_debug(A)
>>> ...
>>> ...
>>> A = ...
>>> function_to_debug(A)
>>>
>>> Seems that the only choice is to use breakpoint. Any other means without
>>> resorting to breakpoints??
>>
>>
>


Re: [julia-users] How to enter a file using gallium?

2016-11-19 Thread Michele Zaffalon
I don't know the answer to the first question.

For the second, you should check
https://github.com/Keno/ASTInterpreter.jl and in particular the
command `stuff.

On Sat, Nov 19, 2016 at 4:08 PM,  <chobbes...@gmail.com> wrote:
> Thanks! It now works for me. Two more quick questions:
>
> 1. Suppose I have the following code where the variable A is defined
> multiple times and after each definition it is used by the same function
> function_to_debug. How can I step in function_to_debug with the first
> definition/instantiation of A?
>
> A = ...
> function_to_debug(A)
> ...
> ...
> A = ...
> function_to_debug(A)
>
>
> 2. As I'm step through the function_to_debug(), how can I print the value of
> some variables. I know that I can use 'fr v' which prints everything. How
> can I print just a single variable that I'm looking at?
>
> Thanks!!
>
>
> On Saturday, November 19, 2016 at 12:26:38 PM UTC, Michele Zaffalon wrote:
>>
>> The @enter should be prepended to the function in the REPL, not in the
>> file itself. It should be something like this:
>>
>> julia> include("/home/calvin/Documents/git/codes/fc.jl/examples/test.jl")
>>
>> julia> @enter function_to_debug(args_to_function)
>>
>> On Sat, Nov 19, 2016 at 11:43 AM,  <chobb...@gmail.com> wrote:
>> > Thanks for the comments. I tried what you suggested by adding @enter at
>> > the
>> > beginning of a line where a function is called. But an error was thrown.
>> >
>> > julia>
>> > include("/home/calvin/Documents/git/codes/fc.jl/examples/test.jl")
>> > ERROR: LoadError: AssertionError: isa(arg,Expr) && arg.head == :call
>> >  in include_from_node1(::String) at ./loading.jl:488
>> > while loading /home/calvin/Documents/git/codes/fc.jl/examples/test.jl,
>> > in
>> > expression starting on line 19
>> >
>> > Am I missing anything? Thanks!
>> >
>> >
>> > On Friday, November 18, 2016 at 8:11:45 PM UTC, Michele Zaffalon wrote:
>> >>
>> >> You @enter the function, not the file. What function would you call
>> >> once
>> >> you include test.jl? That is the function to which you should prepend
>> >> @enter.
>> >>
>> >> On Fri, Nov 18, 2016 at 6:49 PM, <chobb...@gmail.com> wrote:
>> >>>
>> >>>
>> >>>
>> >>> Hi there,
>> >>>
>> >>> I'm totally new to the new debuggers. What I'm aiming at is to go
>> >>> through
>> >>> a file (it's a file calling other packages and functions therein.)
>> >>> line by
>> >>> line, just like in matlab. The first step is to step in the file using
>> >>> gallium. I know how to traverse a function in terminal using Gallium.
>> >>> But it
>> >>> seems that I can't enter a file by doing the same thing like:
>> >>>
>> >>> julia> @enter test.jl
>> >>> ERROR: BoundsError: attempt to access 0-element Array{Int64,1} at
>> >>> index
>> >>> [0]
>> >>>
>> >>>
>> >>> How can I enter a file via Gallium? Is it possible at all? Thanks.
>> >>
>> >>
>> >


Re: [julia-users] How to enter a file using gallium?

2016-11-19 Thread Michele Zaffalon
The @enter should be prepended to the function in the REPL, not in the
file itself. It should be something like this:

julia> include("/home/calvin/Documents/git/codes/fc.jl/examples/test.jl")

julia> @enter function_to_debug(args_to_function)

On Sat, Nov 19, 2016 at 11:43 AM,  <chobbes...@gmail.com> wrote:
> Thanks for the comments. I tried what you suggested by adding @enter at the
> beginning of a line where a function is called. But an error was thrown.
>
> julia> include("/home/calvin/Documents/git/codes/fc.jl/examples/test.jl")
> ERROR: LoadError: AssertionError: isa(arg,Expr) && arg.head == :call
>  in include_from_node1(::String) at ./loading.jl:488
> while loading /home/calvin/Documents/git/codes/fc.jl/examples/test.jl, in
> expression starting on line 19
>
> Am I missing anything? Thanks!
>
>
> On Friday, November 18, 2016 at 8:11:45 PM UTC, Michele Zaffalon wrote:
>>
>> You @enter the function, not the file. What function would you call once
>> you include test.jl? That is the function to which you should prepend
>> @enter.
>>
>> On Fri, Nov 18, 2016 at 6:49 PM, <chobb...@gmail.com> wrote:
>>>
>>>
>>>
>>> Hi there,
>>>
>>> I'm totally new to the new debuggers. What I'm aiming at is to go through
>>> a file (it's a file calling other packages and functions therein.) line by
>>> line, just like in matlab. The first step is to step in the file using
>>> gallium. I know how to traverse a function in terminal using Gallium. But it
>>> seems that I can't enter a file by doing the same thing like:
>>>
>>> julia> @enter test.jl
>>> ERROR: BoundsError: attempt to access 0-element Array{Int64,1} at index
>>> [0]
>>>
>>>
>>> How can I enter a file via Gallium? Is it possible at all? Thanks.
>>
>>
>


Re: [julia-users] How to enter a file using gallium?

2016-11-18 Thread Michele Zaffalon
You @enter the function, not the file. What function would you call once
you include test.jl? That is the function to which you should prepend
@enter.

On Fri, Nov 18, 2016 at 6:49 PM,  wrote:

>
>
> Hi there,
>
> I'm totally new to the new debuggers. What I'm aiming at is to go through
> a file (it's a file calling other packages and functions therein.) line by
> line, just like in matlab. The first step is to step in the file using
> gallium. I know how to traverse a function in terminal using Gallium. But
> it seems that I can't enter a file by doing the same thing like:
>
> julia> @enter test.jl
> ERROR: BoundsError: attempt to access 0-element Array{Int64,1} at index [0
> ]
>
>
> How can I enter a file via Gallium? Is it possible at all? Thanks.
>


[julia-users] Re: How to stop program execution at some point

2016-11-07 Thread Michele Zaffalon
If I understand correctly and die raises an exception in Perl, then error() 
is the equivalent in Julia.
`break` can only be used inside a loop, for instance when a condition is 
met:

while true
  cond && break
end




On Monday, November 7, 2016 at 11:21:14 AM UTC+1, Fred wrote:
>
> Hi,
>
> I search in Julia the equivalent of Perl 
> die;
> to stop the execution of a program.
>
> I tried "break" but it produces an error :
> ERROR: LoadError: syntax: break or continue outside loop
> I did not found "stop" as well.
>
> Thanks !
>


Re: [julia-users] anonymous function

2016-10-28 Thread Michele Zaffalon
Thank you for the clarification.

On Fri, Oct 28, 2016 at 8:23 PM, Yichao Yu <yyc1...@gmail.com> wrote:

> On Fri, Oct 28, 2016 at 2:19 PM, Michele Zaffalon
> <michele.zaffa...@gmail.com> wrote:
> > I have read somewhere that your second approach is doing two things at
> the
> > same time: defining an anonymous function and assigning the name f to it.
>
> No it's not. It defines a function named `f`
>
> f = function ()
> end
>
> defines an anonymous function and assigns it to a variable f.
>
> >
> >
> > On Fri, Oct 28, 2016 at 8:12 PM, digxx <diger_d...@hotmail.com> wrote:
> >>
> >> So an anonymous function I can write like this
> >>
> >> f=x->x^2
> >>
> >> is it also possible to make an anonymous function out of this:
> >>
> >> function f(x)
> >>
> >> x^2
> >>
> >> end
> >
> >
>


Re: [julia-users] anonymous function

2016-10-28 Thread Michele Zaffalon
I have read somewhere that your second approach is doing two things at the
same time: defining an anonymous function and assigning the name f to it.


On Fri, Oct 28, 2016 at 8:12 PM, digxx  wrote:

> So an anonymous function I can write like this
>
> f=x->x^2
>
> is it also possible to make an anonymous function out of this:
>
> function f(x)
>
> x^2
>
> end
>


Re: [julia-users] Binary read

2016-10-25 Thread Michele Zaffalon
The three read commands are reading the first, the second and the third
element of the file (and interpret them as Int32). That the values are in
general different should not be a surprise.

Yes, after you finish reading the file, you should close it:
f = open("numbers.dat")
anInt = read(f, Int32)
a_million_floats = read(f, Float64, 1_000_000)
close(f)





On Tue, Oct 25, 2016 at 10:46 PM, Aleksandr Mikheev <al.mikhee...@gmail.com>
wrote:

> Thank you very much, Michele! One more question, if you do not mind. If I
> do something like this:
>
> f = open("numbers.dat")
>
> a = read(f, Int32)
>
> a = read(f, Int32)
>
> a = read(f, Int32)
>
>
> then a is different each time. I believe I read something about that you
> should use command close() each you opened something. Is this correct?
>
>
> вторник, 25 октября 2016 г., 23:11:01 UTC+3 пользователь Michele Zaffalon
> написал:
>>
>> You open the file in the correct way. To read the integer, do read(f,
>> Int32) followed by read(f, Float64, 1_000_000) to read the million floats.
>> See the manual at http://docs.julialang.org/en/r
>> elease-0.5/stdlib/io-network/
>>
>> On Tue, Oct 25, 2016 at 10:05 PM, Aleksandr Mikheev <al.mik...@gmail.com>
>> wrote:
>>
>>> Hello, sorry if this question have already been asked, but I could not
>>> find a similar thread. So, I have a .dat ("numbers.dat") file, which I
>>> should open. I believe I should do something like this:
>>>
>>> f = open("numbers.dat")
>>>
>>>
>>> And after that I tried to read it:
>>>
>>> readlines(f)
>>>
>>>
>>> However, Julia writes the Error: "UnicodeError: invalid character
>>> index". My tutor told me that this is a binary file, so what I need is a
>>> binary read, such as fread in C/C++. I tried to read  the
>>> documentation, tried to google, but still cannot understand what should I
>>> do. Also, a quote from my tutor, which can probably help you to understand
>>> the problem better: "The first 4 bytes contain an integer (in this
>>> case, 1,000,000) and then 1,000,000 floats of 8 bytes each".
>>>
>>> Thank you in advance!
>>>
>>
>>


Re: [julia-users] Binary read

2016-10-25 Thread Michele Zaffalon
You open the file in the correct way. To read the integer, do read(f,
Int32) followed by read(f, Float64, 1_000_000) to read the million floats.
See the manual at
http://docs.julialang.org/en/release-0.5/stdlib/io-network/

On Tue, Oct 25, 2016 at 10:05 PM, Aleksandr Mikheev 
wrote:

> Hello, sorry if this question have already been asked, but I could not
> find a similar thread. So, I have a .dat ("numbers.dat") file, which I
> should open. I believe I should do something like this:
>
> f = open("numbers.dat")
>
>
> And after that I tried to read it:
>
> readlines(f)
>
>
> However, Julia writes the Error: "UnicodeError: invalid character index".
> My tutor told me that this is a binary file, so what I need is a binary
> read, such as fread in C/C++. I tried to read  the documentation, tried
> to google, but still cannot understand what should I do. Also, a quote from
> my tutor, which can probably help you to understand the problem better: "The
> first 4 bytes contain an integer (in this case, 1,000,000) and then
> 1,000,000 floats of 8 bytes each".
>
> Thank you in advance!
>


Re: [julia-users] How to save an object of a defined type

2016-10-24 Thread Michele Zaffalon
Can you post a bit more of the code? From the error message, it looks like
you are trying to open an already opened file...

On Sat, Oct 22, 2016 at 7:42 PM,  wrote:

> I have a module defined as module *Core* within which I have defined
> several types (*Node*, *Edge*, *Res*). Now what I intend to do is that I
> want to save the output of a function which is an object (*res1*) of type
> *Res* onto a JLD file so that I can retrieve it later on. I am calling
> the function iteratively and hence at each iteration, I would like to store
> the object in the JLD file. I'm not sure how the syntax of this snippet is
> but here is my attempt at it
>
> using HDF5, JLD
>>> z = jldopen("sample.jld", "w")
>>> write(z, "res1", res1)
>>>
>>>
>>>
> Can you please correct my code? I tried the code on the terminal but I get
> an error for the very first line saying
>
> HDF5-DIAG: Error detected in HDF5 (1.8.11) thread 140049981197376:
>   #000: ../../../src/H5F.c line 1504 in H5Fcreate(): unable to create file
> major: File accessibilty
> minor: Unable to open file
>   #001: ../../../src/H5F.c line 1307 in H5F_open(): unable to truncate a
> file which is already open
> major: File accessibilty
> minor: Unable to open file
>
>
>


Re: [julia-users] Re: canonical binary representation for Array

2016-10-23 Thread Michele Zaffalon
Thank you, Tobi.
michele

On Sun, Oct 23, 2016 at 7:35 PM, 'Tobias Knopp' via julia-users <
julia-users@googlegroups.com> wrote:

> Dear Michele,
>
> yes the assumption is absolutely valid. Julia arrays are stored
> column-major ordered in memory and this will not change. Since write does
> only dump the memory on disk this is also not going to change.
>
> Cheers,
>
> Tobi
>
>
> Am Mittwoch, 19. Oktober 2016 09:03:49 UTC+2 schrieb Michele Zaffalon:
>>
>> On Thursday, October 13, 2016 at 3:38:36 PM UTC+2, Steven G. Johnson
>> wrote:
>>>
>>> write on a numeric array will output the raw bytes, i.e. Column-major
>>> data in the native byte order.
>>>
>>>
>>> Would it be a reasonable assumption that reshaping will not change the
>> ordering in future Julia implementations?
>>
>


Re: [julia-users] Re: Float64: 1.0 vs. 1.

2016-10-23 Thread Michele Zaffalon
See also here:
https://groups.google.com/d/msg/julia-users/hIVawSgFvOs/9EpbqwWWBgAJ and
the conclusion was: avoid writing 1. (which will not be allowed by the
parser some time) and write 1.0 instead.


On Mon, Oct 24, 2016 at 3:40 AM, J Luis  wrote:

> It parses .+ as broadcasting of two Ints. Do instead
>
> typeof(1. +1)
> Float64
>
>
>
> segunda-feira, 24 de Outubro de 2016 às 02:33:15 UTC+1,
> christop...@unibas.ch escreveu:
>>
>> What is the difference between 1.0 and 1. ?
>> Both are of type Float64, but adding 1 leads to the result 2.0, i.e.,
>> Float64, in the first case,
>> and 2, i.e., Int64 in the second.
>>
>>   _
>>_   _ _(_)_ |  A fresh approach to technical computing
>>   (_) | (_) (_)|  Documentation: http://docs.julialang.org
>>_ _   _| |_  __ _   |  Type "?help" for help.
>>   | | | | | | |/ _` |  |
>>   | | |_| | | | (_| |  |  Version 0.5.0 (2016-09-19 18:14 UTC)
>>  _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
>> |__/   |  x86_64-apple-darwin13.4.0
>>
>> julia> typeof(1.0)
>> Float64
>>
>> julia> typeof(1.)
>> Float64
>>
>> julia> typeof(1.0+1)
>> Float64
>>
>> julia> typeof(1.+1)
>> Int64
>>
>> Many thanks in advance, Christoph
>>
>


Re: [julia-users] Julia 0.5 precompilation failures

2016-10-21 Thread Michele Zaffalon
I am not sure if this is the reason, but the manual (
http://docs.julialang.org/en/release-0.5/manual/modules/) says you should
put _precompile_() before the module starts.

On Fri, Oct 21, 2016 at 10:56 PM, Rohit Varkey Thankachan <
rohitvar...@gmail.com> wrote:

> Hi,
>
> I've been trying to use julia on one of my university machines and having
> precompilation issues. The machine runs Linux x84_46 and I'm using the 0.5
> generic linux binary.
>
> I was trying to use JLD.jl and kept getting precompilation failures for
> HFD5. On trying to do `using HDF5` in the REPL, it was giving me the same
> error for Compat.jl. By running `using ` for all modules for which
> precompilation was failing when trying to use JLD(HDF5->(Compat, Blosc),
> FileIO) I got them all precompiled successfully. However JLD also needed
> LegacyStrings to be precompiled, which does not have precompilation enabled
> and has to be precompiled from another module. At which point I was stuck
> and I decided to just go with `julia --compilecache=no`.
>
> julia> using JLD
> INFO: Precompiling module JLD.
> ERROR: LoadError: LoadError: Failed to precompile LegacyStrings to
> /nethome/rvt7/.julia/lib/v0.5/LegacyStrings.ji.
>  in compilecache(::String) at ./loading.jl:593
>  in require(::Symbol) at ./loading.jl:393
>  in include_from_node1(::String) at ./loading.jl:488 (repeats 2 times)
>  in macro expansion; at ./none:2 [inlined]
>  in anonymous at ./:?
>  in eval(::Module, ::Any) at ./boot.jl:234
>  in process_options(::Base.JLOptions) at ./client.jl:239
>  in _start() at ./client.jl:318
> while loading /nethome/rvt7/.julia/v0.5/JLD/src/jld_types.jl, in
> expression starting on line 1
> while loading /nethome/rvt7/.julia/v0.5/JLD/src/JLD.jl, in expression
> starting on line 130
> ERROR: Failed to precompile JLD to /nethome/rvt7/.julia/lib/v0.5/JLD.ji.
>  in compilecache(::String) at ./loading.jl:593
>  in require(::Symbol) at ./loading.jl:422
>
> julia> using LegacyStrings
> WARNING: could not import Base.lastidx into LegacyStrings
> WARNING: using LegacyStrings.utf8 in module Main conflicts with an
> existing identifier.
> WARNING: using LegacyStrings.ascii in module Main conflicts with an
> existing identifier.
>
> julia> using JLD
> INFO: Precompiling module JLD.
> WARNING: Module LegacyStrings with uuid 25677385416258011 is missing from
> the cache.
> This may mean module LegacyStrings does not support precompilation but is
> imported by a module that does.
> ERROR: LoadError: LoadError: Declaring __precompile__(false) is not
> allowed in files that are being precompiled.
>  in require(::Symbol) at ./loading.jl:385
>  in include_from_node1(::String) at ./loading.jl:488 (repeats 2 times)
>  in macro expansion; at ./none:2 [inlined]
>  in anonymous at ./:?
>  in eval(::Module, ::Any) at ./boot.jl:234
>  in process_options(::Base.JLOptions) at ./client.jl:239
>  in _start() at ./client.jl:318
> while loading /nethome/rvt7/.julia/v0.5/JLD/src/jld_types.jl, in
> expression starting on line 1
> while loading /nethome/rvt7/.julia/v0.5/JLD/src/JLD.jl, in expression
> starting on line 130
> ERROR: Failed to precompile JLD to /nethome/rvt7/.julia/lib/v0.5/JLD.ji.
>  in compilecache(::String) at ./loading.jl:593
>  in require(::Symbol) at ./loading.jl:422
>
> On a hunch that this was occurring due to a package with precompilation
> enabled trying to use another precompilation enabled package which hadn't
> been precompiled yet, I tried making a minimal example to check this. I
> created 2 packages Foo and Bar, both of which have precompilation enabled.
>
> ~/.julia/v0.5/Foo/Foo.jl:
> module Foo
>
> __precompile__()
> using Bar
>
> import Bar: bar
>
> end
>
> ~/.julia/v0.5/Bar/src/Bar.jl:
>
> module Bar
>
> __precompile__()
>
> export bar
>
> const bar = "foo"
>
> end
>
> Now when I try using Foo, I get a precompilation failed error for Bar. Foo
> does precompile when Bar is already precompiled though!
>
>_
>_   _ _(_)_ |  A fresh approach to technical computing
>   (_) | (_) (_)|  Documentation: http://docs.julialang.org
>_ _   _| |_  __ _   |  Type "?help" for help.
>   | | | | | | |/ _` |  |
>   | | |_| | | | (_| |  |  Version 0.5.0 (2016-09-19 18:14 UTC)
>  _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
> |__/   |  x86_64-pc-linux-gnu
>
> julia> using Foo
> INFO: Precompiling module Foo.
> ERROR: LoadError: Failed to precompile Bar to
> /nethome/rvt7/.julia/lib/v0.5/Bar.ji.
>  in compilecache(::String) at ./loading.jl:593
>  in require(::Symbol) at ./loading.jl:393
>  in include_from_node1(::String) at ./loading.jl:488
>  in macro expansion; at ./none:2 [inlined]
>  in anonymous at ./:?
>  in eval(::Module, ::Any) at ./boot.jl:234
>  in process_options(::Base.JLOptions) at ./client.jl:239
>  in _start() at ./client.jl:318
> while loading /nethome/rvt7/.julia/v0.5/Foo/src/Foo.jl, in expression
> starting on line 4
> ERROR: Failed to precompile Foo to 

Re: [julia-users] Testing uncommitted changes to a package

2016-10-21 Thread Michele Zaffalon
And that command would be push!(LOAD_PATH, $PWD/src)

On Fri, Oct 21, 2016 at 5:36 PM, Yichao Yu  wrote:

> Add $PWD/src to LOAD_PATH instead. This way you can also make sure you are
> not using Pkg incorrectly in your package.
>
>
> On Fri, Oct 21, 2016 at 11:11 AM, Chandrakant G <
> chandrakant.gopa...@gmail.com> wrote:
>
>> Hi guys,
>> I am getting my feet wet with Julia and its pretty nice so far.
>> I am testing an external Julia package (not something I wrote). I have
>> already cloned it and made some changes.
>> I have started the julia repl inside the directory where i cloned the
>> package repo.
>>
>> Here's my workflow.
>>
>> # Remove existing copy
>> Pkg.rm(extpkg)
>>
>> # Add the new copy with my changes
>> Pkg.clone(pwd())
>>
>> # Run tests
>> Pkg.test(mypkg)
>>
>> My question is: My changes dont get picked up by clone unless I commit
>> them. Is there a way to test uncommitted changes?
>>
>> Thanks
>> Chandrakant
>>
>
>


Re: [julia-users] congratulations to Indian dost

2016-10-19 Thread Michele Zaffalon
Tim Holy: I had hoped you learnt to be more careful with untested versions. 
See what happened this time around: 
https://www.theguardian.com/science/2016/oct/20/bad-day-for-space-probes-one-lost-on-mars-another-in-safe-mode-at-jupiter?

On Wednesday, September 24, 2014 at 5:27:52 PM UTC+2, Tim Holy wrote:
>
> "Sorry, sir, but our Mars probe crashed. It's a complete loss." 
>
> "Oh no! Why?" 
>
> "Well, just before it was about to dock, Tim Holy tagged a new version of 
> Images. Turns out it had a bug in it that prevented the cameras from 
> saving 
> images to disk. So we were flying blind. We tried rolling back to an 
> earlier 
> version, but recent changes to Pkg meant that `pin` wasn't working either. 
> So 
> we hit the planet." 
>
> "Next time, don't run master." 
>
> --Tim 
>
> On Wednesday, September 24, 2014 08:12:35 AM John Myles White wrote: 
> > Not that I’m aware of. I’d say the thread is probably off-topic. 
> > 
> >  — John 
> > 
> > On Sep 24, 2014, at 8:10 AM, Stefan Karpinski  > wrote: 
> > > Is there any evidence that Julia was used to accomplish that? 
> > > 
> > > On Wed, Sep 24, 2014 at 11:05 AM, John Myles White 
> > >  wrote: I think this is the 
> flight to Mars that 
> > > India just finsihed. 
> > > 
> > >  — John 
> > > 
> > > On Sep 24, 2014, at 8:04 AM, Stefan Karpinski  > 
> wrote: 
> > >> I have no idea what this is about. Can you clarify? 
> > >> 
> > >> On Wed, Sep 24, 2014 at 3:47 AM, K Leo  > wrote: 
> > >> for the wonderful achievement with Mangalyaan! 
> > >> 
> > >> With a budget less than a Hollywood movie, I bet they must have 
> largely 
> > >> used (and supported?) open sources - Julia included? 
>
>

Re: [julia-users] Re: product of Int64 and Float64 is Int64

2016-10-19 Thread Michele Zaffalon
A bad habit learnt using Python...

On Wed, Oct 19, 2016 at 3:53 PM, Krisztián Pintér <pinte...@gmail.com>
wrote:

>
> i know i shouldn't, but i'm kinda angry at this "1." notation. saving one
> character really worth losing readability? also leading to errors like
> this. personally, i would not even allow this syntax at all.
>
> On Wednesday, October 19, 2016 at 1:11:38 PM UTC+2, Michele Zaffalon wrote:
>>
>> I am confused by the type of the result of `1.*80`, which is `Int64`,
>> despite the fact that `1.` is `Float64`, and that `Float64(1)*80` is a
>> `Float64`:
>>
>


Re: [julia-users] product of Int64 and Float64 is Int64

2016-10-19 Thread Michele Zaffalon
Thanks.

On Wed, Oct 19, 2016 at 1:46 PM, <lapeyre.math1...@gmail.com> wrote:

> Or include a space.
>
> parse("1. * 80") --> :(1.0 * 80)
>
> parse("1.* 80")  --> :(1 .* 80)
>
> On Wednesday, October 19, 2016 at 1:30:27 PM UTC+2, Mauro wrote:
>>
>> On Wed, 2016-10-19 at 13:11, Michele Zaffalon <michele@gmail.com>
>> wrote:
>> > I am confused by the type of the result of `1.*80`, which is `Int64`,
>> despite
>> > the fact that `1.` is `Float64`, and that `Float64(1)*80` is a
>> `Float64`:
>>
>> No this is parsed as 1 .* 80.  Try 1.0*80
>>
>> > julia> typeof(1.), typeof(80), typeof(1.*80), typeof(Float64(1.)*80)
>> > (Float64,Int64,Int64,Float64)
>> >
>> > Does it have to do with the fact that both 1 and 80 have an exact
>> Float64
>> > representation?
>> >
>> > julia> bits(1.)
>> > "0011"
>> >
>> > julia> bits(80.)
>> > "010001010100"
>> >
>> >
>> > Thank you,
>> > michele
>>
>


Re: [julia-users] product of Int64 and Float64 is Int64

2016-10-19 Thread Michele Zaffalon
And

julia> parse("1.*80")
:(1 .* 80)
julia> parse("1.0*80")
:(1.0 * 80)


On Wednesday, October 19, 2016 at 1:36:00 PM UTC+2, Michele Zaffalon wrote:
>
> I should have realized that:
>
> julia> promote(1., 80)
> (1.0,80.0)
> julia> 80*1.
> 80.0
>
> Thank you.
>
> On Wednesday, October 19, 2016 at 1:30:27 PM UTC+2, Mauro wrote:
>>
>> On Wed, 2016-10-19 at 13:11, Michele Zaffalon <michele@gmail.com> 
>> wrote: 
>> > I am confused by the type of the result of `1.*80`, which is `Int64`, 
>> despite 
>> > the fact that `1.` is `Float64`, and that `Float64(1)*80` is a 
>> `Float64`: 
>>
>> No this is parsed as 1 .* 80.  Try 1.0*80 
>>
>> > julia> typeof(1.), typeof(80), typeof(1.*80), typeof(Float64(1.)*80) 
>> > (Float64,Int64,Int64,Float64) 
>> > 
>> > Does it have to do with the fact that both 1 and 80 have an exact 
>> Float64 
>> > representation? 
>> > 
>> > julia> bits(1.) 
>> > "0011" 
>> > 
>> > julia> bits(80.) 
>> > "010001010100" 
>> > 
>> > 
>> > Thank you, 
>> > michele 
>>
>

Re: [julia-users] product of Int64 and Float64 is Int64

2016-10-19 Thread Michele Zaffalon
I should have realized that:

julia> promote(1., 80)
(1.0,80.0)
julia> 80*1.
80.0

Thank you.

On Wednesday, October 19, 2016 at 1:30:27 PM UTC+2, Mauro wrote:
>
> On Wed, 2016-10-19 at 13:11, Michele Zaffalon <michele@gmail.com 
> > wrote: 
> > I am confused by the type of the result of `1.*80`, which is `Int64`, 
> despite 
> > the fact that `1.` is `Float64`, and that `Float64(1)*80` is a 
> `Float64`: 
>
> No this is parsed as 1 .* 80.  Try 1.0*80 
>
> > julia> typeof(1.), typeof(80), typeof(1.*80), typeof(Float64(1.)*80) 
> > (Float64,Int64,Int64,Float64) 
> > 
> > Does it have to do with the fact that both 1 and 80 have an exact 
> Float64 
> > representation? 
> > 
> > julia> bits(1.) 
> > "0011" 
> > 
> > julia> bits(80.) 
> > "010001010100" 
> > 
> > 
> > Thank you, 
> > michele 
>


[julia-users] product of Int64 and Float64 is Int64

2016-10-19 Thread Michele Zaffalon
I am confused by the type of the result of `1.*80`, which is `Int64`, 
despite the fact that `1.` is `Float64`, and that `Float64(1)*80` is a 
`Float64`:

julia> typeof(1.), typeof(80), typeof(1.*80), typeof(Float64(1.)*80)
(Float64,Int64,Int64,Float64)

Does it have to do with the fact that both 1 and 80 have an exact Float64 
representation?

julia> bits(1.)
"0011"

julia> bits(80.)
"010001010100"


Thank you,
michele


Re: [julia-users] Re: canonical binary representation for Array

2016-10-19 Thread Michele Zaffalon
On Thursday, October 13, 2016 at 3:38:36 PM UTC+2, Steven G. Johnson wrote:
>
> write on a numeric array will output the raw bytes, i.e. Column-major data 
> in the native byte order. 
>
>
> Would it be a reasonable assumption that reshaping will not change the 
ordering in future Julia implementations?


Re: [julia-users] Re: quadgk with 2 arguments

2016-10-19 Thread Michele Zaffalon
You are right.

On Wed, Oct 19, 2016 at 12:37 AM, Steven G. Johnson <stevenj@gmail.com>
wrote:

>
>
> On Tuesday, October 18, 2016 at 4:34:38 PM UTC-4, Michele Zaffalon wrote:
>>
>> quadgk(t -> cis(gamma(t)), 0, 1)
>>
>
> No, this is wrong because you forgot the Jacobian factor.
>


Re: [julia-users] Re: quadgk with 2 arguments

2016-10-18 Thread Michele Zaffalon
quadgk(t -> cis(gamma(t)), 0, 1)

On Tue, Oct 18, 2016 at 10:27 PM, digxx  wrote:

> do u have an example for how to use a contour?
> quadgk(cis,0,1+1*im)
> probably integrates over the straight line so how can I integrate over the
> line gamma(t)=t+im*t^2
>


Re: [julia-users] How to debug julia v0.5 code? Debug.jl is down, how to use Gallium.jl

2016-10-13 Thread Michele Zaffalon
No worries, I had the same question and I happened to have that web page
open.

On Fri, Oct 14, 2016 at 1:05 AM, Florian Oswald <florian.osw...@gmail.com>
wrote:

> Oh! Sorry I didn't get that. Thanks!
>
>
> On Thursday, 13 October 2016, Michele Zaffalon <michele.zaffa...@gmail.com>
> wrote:
>
>> From ASTInterpreter's README:
>>
>>- `stuff runs stuff in the current frame's context
>>
>>
>> On Thu, Oct 13, 2016 at 5:47 PM, Florian Oswald <florian.osw...@gmail.com
>> > wrote:
>>
>>> how can I print the value of a variable while in debug mode?
>>>
>>>
>>>
>>> On Thursday, 13 October 2016 17:19:12 UTC+2, Michele Zaffalon wrote:
>>>>
>>>> Aside from Gallium.jl, you should also check ASTInterpreter.jl
>>>> <https://github.com/Keno/ASTInterpreter.jl>'s README which gives the
>>>> list of commands. The documentation seems to be spread across the two
>>>> packages.
>>>>
>>>>
>>>> On Thu, Oct 13, 2016 at 5:15 PM, Florian Oswald <florian...@gmail.com>
>>>> wrote:
>>>>
>>>>> hi,
>>>>>
>>>>> i usually used Debug.jl to debug code, which is great, but errors on
>>>>> julia 0.5: https://github.com/toivoh/Debug.jl/issues/80
>>>>>
>>>>> I have no idea how to use Gallium.jl just from looking at the
>>>>> examples. Anyone? thanks.
>>>>>
>>>>
>>>>
>>


Re: [julia-users] How to debug julia v0.5 code? Debug.jl is down, how to use Gallium.jl

2016-10-13 Thread Michele Zaffalon
>From ASTInterpreter's README:

   - `stuff runs stuff in the current frame's context


On Thu, Oct 13, 2016 at 5:47 PM, Florian Oswald <florian.osw...@gmail.com>
wrote:

> how can I print the value of a variable while in debug mode?
>
>
>
> On Thursday, 13 October 2016 17:19:12 UTC+2, Michele Zaffalon wrote:
>>
>> Aside from Gallium.jl, you should also check ASTInterpreter.jl
>> <https://github.com/Keno/ASTInterpreter.jl>'s README which gives the
>> list of commands. The documentation seems to be spread across the two
>> packages.
>>
>>
>> On Thu, Oct 13, 2016 at 5:15 PM, Florian Oswald <florian...@gmail.com>
>> wrote:
>>
>>> hi,
>>>
>>> i usually used Debug.jl to debug code, which is great, but errors on
>>> julia 0.5: https://github.com/toivoh/Debug.jl/issues/80
>>>
>>> I have no idea how to use Gallium.jl just from looking at the examples.
>>> Anyone? thanks.
>>>
>>
>>


Re: [julia-users] How to debug julia v0.5 code? Debug.jl is down, how to use Gallium.jl

2016-10-13 Thread Michele Zaffalon
Aside from Gallium.jl, you should also check ASTInterpreter.jl
's README which gives the list
of commands. The documentation seems to be spread across the two packages.


On Thu, Oct 13, 2016 at 5:15 PM, Florian Oswald 
wrote:

> hi,
>
> i usually used Debug.jl to debug code, which is great, but errors on julia
> 0.5: https://github.com/toivoh/Debug.jl/issues/80
>
> I have no idea how to use Gallium.jl just from looking at the examples.
> Anyone? thanks.
>


Re: [julia-users] Re: canonical binary representation for Array

2016-10-13 Thread Michele Zaffalon
I wish there was documentation for the file format aside from the MATLAB
implementation which also just uses `reshape`.

The only sure thing about the format is that the first byte of the file is
the endianness.



On Thu, Oct 13, 2016 at 3:38 PM, Steven G. Johnson 
wrote:

> write on a numeric array will output the raw bytes, i.e. Column-major data
> in the native byte order.
>
> Matlab arrays are also column major, so reading a Matlab-produced binary
> format is probably straightforward, but you have to be careful of the byte
> order. Obviously, you'll have to read the documentation on your file format
> carefully. Whatever the format is, however, Julia offers enough low-level
> control to read and write it efficiently.


Re: [julia-users] Re: canonical binary representation for Array

2016-10-13 Thread Michele Zaffalon
I guess I was not clear enough: I cannot change the file format, so a
Julia-specific solution is not going to work.

On Thu, Oct 13, 2016 at 2:54 PM, FANG Colin  wrote:

> Are you trying to serialise Julia objects? Why don't you try json or
> msgpack or so as your encoding?
>
> The default serialize could also work but you need to be careful it
> doesn't guarantee version safe.
>


Re: [julia-users] How to write data to new line in outfile.txt

2016-10-13 Thread Michele Zaffalon
What about a newline with write(f, "\n") before writing the next block of
data into the file?

On Thu, Oct 13, 2016 at 1:08 PM,  wrote:

> How to write data to new line in outfile.txt file, in this script data i
> still writing in the same line
>
> io=open("outfile.txt", "w"
> o=open("dump.txt")
> for i=1:100
> temp=readline(o)
> poz=findin(temp,",")[3]
> write(io, temp[1:poz-1])
> end
> close(o)
> close(io)
>
> Paul
>


[julia-users] Re: Dictionary type inference

2016-10-13 Thread Michele Zaffalon
With one element only, type inference gives:

julia> typeof(Dict(sin => sin))
Dict{Base.#sin,Base.#sin}


On Thursday, October 13, 2016 at 9:26:37 AM UTC+2, David van Leeuwen wrote:
>
> Hello, 
>
> I have stumbled across the following type inference issue for `Dict`s in 
> julia-v0.5:
>
> julia> typeof(Dict(sin => sin, cos => cos))
>
> Dict{Any,Any}
>
> julia> typeof(Dict(x => x for x in [sin, cos]))
>
> Dict{Function,Function}
>
> In Julia-0.5, functions got their own type.  I was surprised to see that 
> the type inference in the `Dict(:a => sin, :b => cos)` for the value of the 
> dict is `Any` and not `Function`.  In the comprehension syntax, the type of 
> the value _is_ generalised to `Function`.  
>
> Is this intended behavior?
>
>
>

[julia-users] canonical binary representation for Array

2016-10-13 Thread Michele Zaffalon
I need to write a 4 dimensional a array to file and use

write(f, a).

What is the canonical binary representation of a 
? 
It looks like the the line above is equivalent to

write(f, reshape(a, prod(size(a

Is the canonical binary representation going to be machine and OS 
independent (except for the endianness)? What about reshape?

I am porting code from MATLAB and the specs for the file format are defined 
by the MATLAB code implementation.

michele




Re: [julia-users] Re: read binary file with endianness

2016-10-07 Thread Michele Zaffalon
Thank you.


On Thu, Oct 6, 2016 at 8:42 PM, Steven G. Johnson 
wrote:

> Yes, just read in the first byte, and then read in the rest of the data,
> calling ntoh or hton as needed on each datum.
>


[julia-users] read binary file with endianness

2016-10-06 Thread Michele Zaffalon
I am porting MATLAB code to read a binary file for which the endianness is 
encoded in the first byte of the file.
The MATLAB code opens the file to read the first byte, and reopens the file 
with `fopen` which takes as one of the arguments the endianness. What is 
the Julian equivalent? So far I have `endian(read(stream, T))` where endian 
is either ntoh or ltoh?

Thank you,
michele


Re: [julia-users] Generators vs Comprehensions, Type-stability?

2016-09-25 Thread Michele Zaffalon
In an email a few days back, Steven Johnson wrote: "We could use type
inference on the function t -> t^2 (which is buried in the generator) to
determine a more specific eltype." A feature request, maybe?

On Sun, Sep 25, 2016 at 11:29 PM, Christoph Ortner <
christophortn...@gmail.com> wrote:

>
> I didn't quite follow what the conclusion is: is it a bug that should be
> fixed (i.e. open an issue?), or is it expected behaviour and I should stop
> using generators when I need type inference?
>
> Thanks.
>


Re: [julia-users] Generators vs Comprehensions, Type-stability?

2016-09-25 Thread Michele Zaffalon
On Sat, Sep 24, 2016 at 8:54 PM, Steven G. Johnson 
wrote:

>
> julia> (begin;println(t);t^2;end for t=1:10)
>> Base.Generator{UnitRange{Int64},##37#38}(#37,1:10)
>>
>
> Julia knows that the input to the generator is a UnitRange{Int64}, i.e.
> 1:10, so the input elements are Int64.   It knows that the function being
> computed is t -> t^2.   The compiler is smart enough that it can figure out
> that if t is an Int64, then t^2 is an Int64 too, because that function is
> type stable.   So, it can figure out that the eltype of the output (i.e.
> the Generator) is Int64, all at compile time without actually evaluating
> the function.
>

It just feels like magic. Thank you for the explanation.


Re: [julia-users] Generators vs Comprehensions, Type-stability?

2016-09-24 Thread Michele Zaffalon
On Fri, Sep 23, 2016 at 1:14 PM, Steven G. Johnson <stevenj@gmail.com>
wrote:

>
>
> On Friday, September 23, 2016 at 2:42:00 AM UTC-4, Michele Zaffalon wrote:
>>
>> On Fri, Sep 23, 2016 at 2:23 AM, Steven G. Johnson <steve...@gmail.com>
>> wrote:
>>>
>>>
>>> We could use type inference on the function t -> t^2 (which is buried in
>>> the generator) to determine a more specific eltype.
>>>
>>
>> Does this not require evaluating the function on all inputs thereby
>> losing the advantage of having a generator?
>>
>
> No, not if the eltype of the thing the generator iterates over (in this
> case, an Array{Float64}) is known.
>


Sorry for being slow: the input array rand(10) or the output array, the
square of each element of rand(10)?

julia> (begin;println(t);t^2;end for t=1:10)
Base.Generator{UnitRange{Int64},##37#38}(#37,1:10)


Re: [julia-users] Generators vs Comprehensions, Type-stability?

2016-09-23 Thread Michele Zaffalon
>From reading the manual
<http://docs.julialang.org/en/release-0.5/manual/arrays/#generator-expressions>,
producing a value is delayed until that value is required. Is my
understanding wrong?

On Fri, Sep 23, 2016 at 10:14 AM, Christoph Ortner <
christophortn...@gmail.com> wrote:

> why would type inference for sum(t^2 for t in r) be different from [t^2
> for t in r] ?
>

> On Friday, 23 September 2016 07:42:00 UTC+1, Michele Zaffalon wrote:
>>
>> On Fri, Sep 23, 2016 at 2:23 AM, Steven G. Johnson <steve...@gmail.com>
>> wrote:
>>>
>>>
>>> We could use type inference on the function t -> t^2 (which is buried in
>>> the generator) to determine a more specific eltype.
>>>
>>
>> Does this not require evaluating the function on all inputs thereby
>> losing the advantage of having a generator?
>>
>>


Re: [julia-users] Generators vs Comprehensions, Type-stability?

2016-09-23 Thread Michele Zaffalon
On Fri, Sep 23, 2016 at 2:23 AM, Steven G. Johnson 
wrote:
>
>
> We could use type inference on the function t -> t^2 (which is buried in
> the generator) to determine a more specific eltype.
>

Does this not require evaluating the function on all inputs thereby losing
the advantage of having a generator?


Re: [julia-users] Strange behavior of push! and pop! for an array of array elements

2016-09-13 Thread Michele Zaffalon
Apologies, I did not want to insult or be rude. Thank you again for the
clear explanation.

On Tue, Sep 13, 2016 at 8:38 AM, Tamas Papp <tkp...@gmail.com> wrote:

> Please don't put words in my mouth, I did not say that. In general, I
> find "use case" an elusive concept. I prefer simple building blocks with
> clear semantics that I can combine easily to solve problems.
>
> Also, whether something "makes sense" is also somewhat subjective and
> depends on your expectations and prior experience. Coming from, say,
> Common Lisp, Julia's semantics in this case make perfect sense. Coming
> from other languages, you may find it surprising, but that's always part
> of learning a new language. My own preference is to write quite a bit of
> code in a language before commenting on whether certain features "make
> sense", but YMMV.
>
> On Tue, Sep 13 2016, Michele Zaffalon wrote:
>
> > Thank you for your explanation.
> >
> > In practice you are saying that consistency has led to this consequence
> > even though there is no use case, and therefore it makes little sense? I
> am
> > not trying to provoke, it is that I find it easier to internalize the
> > concept, once I know the reason behind that concept.
> >
> >
> > On Tue, Sep 13, 2016 at 7:24 AM, Tamas Papp <tkp...@gmail.com> wrote:
> >
> >> Fill behaves this way not because of a specific design choice based on a
> >> compelling use case, but because of consistency with other language
> >> features. fill does not copy, and arrays are passed by reference in
> >> Julia, consequently you have the behavior described below.
> >>
> >> IMO it is best to learn about this and internalize the fact that arrays
> >> and structures are passed by reference. The alternative would be some
> >> DWIM-style solution where fill tries to figure out whether to copy its
> >> first argument or not, which would be a mess.
> >>
> >> On Tue, Sep 13 2016, Michele Zaffalon wrote:
> >>
> >> > I have been bitten by this myself. Is there a user case for having an
> >> array
> >> > filled with references to the same object? Why would one want this
> >> > behaviour?
> >> >
> >> > On Tue, Sep 13, 2016 at 4:45 AM, Yichao Yu <yyc1...@gmail.com> wrote:
> >> >
> >> >>
> >> >>
> >> >> On Mon, Sep 12, 2016 at 10:33 PM, Zhilong Liu <
> lzl200102...@gmail.com>
> >> >> wrote:
> >> >>
> >> >>> Hello all,
> >> >>>
> >> >>> I am pretty new to Julia, and I am trying to perform push and pop
> >> inside
> >> >>> an array of 1D array elements. For example, I created the following
> >> array
> >> >>> with 1000 empty arrays.
> >> >>>
> >> >>> julia> vring = fill([], 1000)
> >> >>>
> >> >>
> >> >>
> >> >> This creates an array with 1000 identical object, if you want to make
> >> them
> >> >> different (but initially equal) object, you can use `[[] for i in
> >> 1:1000]`
> >> >>
> >> >>>
> >> >>> Then, when I push an element to vring[2],
> >> >>>
> >> >>>
> >> >>> julia> push!(vring[2],1)
> >> >>>
> >> >>>
> >> >>> I got the following result. Every array element inside vring gets
> the
> >> >>> value 1. But I only want the 1 to be pushed to the 2nd array element
> >> >>> inside vring. Anybody knows how to do that efficiently?
> >> >>>
> >> >>>
> >> >>> julia> vring
> >> >>>
> >> >>> 1000x1 Array{Array{Any,1},2}:
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>  ⋮
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>  Any[1]
> >> >>>
> >> >>>
> >> >>>
> >> >>> Thanks!
> >> >>>
> >> >>> Zhilong Liu
> >> >>>
> >> >>>
> >> >>>
> >> >>>
> >> >>
> >>
> >>
>


Re: [julia-users] Strange behavior of push! and pop! for an array of array elements

2016-09-13 Thread Michele Zaffalon
Thank you for your explanation.

In practice you are saying that consistency has led to this consequence
even though there is no use case, and therefore it makes little sense? I am
not trying to provoke, it is that I find it easier to internalize the
concept, once I know the reason behind that concept.


On Tue, Sep 13, 2016 at 7:24 AM, Tamas Papp <tkp...@gmail.com> wrote:

> Fill behaves this way not because of a specific design choice based on a
> compelling use case, but because of consistency with other language
> features. fill does not copy, and arrays are passed by reference in
> Julia, consequently you have the behavior described below.
>
> IMO it is best to learn about this and internalize the fact that arrays
> and structures are passed by reference. The alternative would be some
> DWIM-style solution where fill tries to figure out whether to copy its
> first argument or not, which would be a mess.
>
> On Tue, Sep 13 2016, Michele Zaffalon wrote:
>
> > I have been bitten by this myself. Is there a user case for having an
> array
> > filled with references to the same object? Why would one want this
> > behaviour?
> >
> > On Tue, Sep 13, 2016 at 4:45 AM, Yichao Yu <yyc1...@gmail.com> wrote:
> >
> >>
> >>
> >> On Mon, Sep 12, 2016 at 10:33 PM, Zhilong Liu <lzl200102...@gmail.com>
> >> wrote:
> >>
> >>> Hello all,
> >>>
> >>> I am pretty new to Julia, and I am trying to perform push and pop
> inside
> >>> an array of 1D array elements. For example, I created the following
> array
> >>> with 1000 empty arrays.
> >>>
> >>> julia> vring = fill([], 1000)
> >>>
> >>
> >>
> >> This creates an array with 1000 identical object, if you want to make
> them
> >> different (but initially equal) object, you can use `[[] for i in
> 1:1000]`
> >>
> >>>
> >>> Then, when I push an element to vring[2],
> >>>
> >>>
> >>> julia> push!(vring[2],1)
> >>>
> >>>
> >>> I got the following result. Every array element inside vring gets the
> >>> value 1. But I only want the 1 to be pushed to the 2nd array element
> >>> inside vring. Anybody knows how to do that efficiently?
> >>>
> >>>
> >>> julia> vring
> >>>
> >>> 1000x1 Array{Array{Any,1},2}:
> >>>
> >>>  Any[1]
> >>>
> >>>  Any[1]
> >>>
> >>>  Any[1]
> >>>
> >>>  Any[1]
> >>>
> >>>  Any[1]
> >>>
> >>>  Any[1]
> >>>
> >>>  Any[1]
> >>>
> >>>  Any[1]
> >>>
> >>>  Any[1]
> >>>
> >>>  Any[1]
> >>>
> >>>  ⋮
> >>>
> >>>  Any[1]
> >>>
> >>>  Any[1]
> >>>
> >>>  Any[1]
> >>>
> >>>  Any[1]
> >>>
> >>>  Any[1]
> >>>
> >>>  Any[1]
> >>>
> >>>  Any[1]
> >>>
> >>>  Any[1]
> >>>
> >>>  Any[1]
> >>>
> >>>
> >>>
> >>> Thanks!
> >>>
> >>> Zhilong Liu
> >>>
> >>>
> >>>
> >>>
> >>
>
>


Re: [julia-users] Strange behavior of push! and pop! for an array of array elements

2016-09-12 Thread Michele Zaffalon
I have been bitten by this myself. Is there a user case for having an array
filled with references to the same object? Why would one want this
behaviour?

On Tue, Sep 13, 2016 at 4:45 AM, Yichao Yu  wrote:

>
>
> On Mon, Sep 12, 2016 at 10:33 PM, Zhilong Liu 
> wrote:
>
>> Hello all,
>>
>> I am pretty new to Julia, and I am trying to perform push and pop inside
>> an array of 1D array elements. For example, I created the following array
>> with 1000 empty arrays.
>>
>> julia> vring = fill([], 1000)
>>
>
>
> This creates an array with 1000 identical object, if you want to make them
> different (but initially equal) object, you can use `[[] for i in 1:1000]`
>
>>
>> Then, when I push an element to vring[2],
>>
>>
>> julia> push!(vring[2],1)
>>
>>
>> I got the following result. Every array element inside vring gets the
>> value 1. But I only want the 1 to be pushed to the 2nd array element
>> inside vring. Anybody knows how to do that efficiently?
>>
>>
>> julia> vring
>>
>> 1000x1 Array{Array{Any,1},2}:
>>
>>  Any[1]
>>
>>  Any[1]
>>
>>  Any[1]
>>
>>  Any[1]
>>
>>  Any[1]
>>
>>  Any[1]
>>
>>  Any[1]
>>
>>  Any[1]
>>
>>  Any[1]
>>
>>  Any[1]
>>
>>  ⋮
>>
>>  Any[1]
>>
>>  Any[1]
>>
>>  Any[1]
>>
>>  Any[1]
>>
>>  Any[1]
>>
>>  Any[1]
>>
>>  Any[1]
>>
>>  Any[1]
>>
>>  Any[1]
>>
>>
>>
>> Thanks!
>>
>> Zhilong Liu
>>
>>
>>
>>
>


Re: [julia-users] [JuliaOpt] Beginner questions?

2016-09-10 Thread Michele Zaffalon
There is the julia-opt forum:
https://groups.google.com/forum/#!forum/julia-opt

On Sat, Sep 10, 2016 at 2:38 PM, Colin Beckingham 
wrote:

> OK for Optim beginner questions here?
>


Re: [julia-users] different Eigenvalue results Julia vs Matlab

2016-09-10 Thread Michele Zaffalon
You mean they are not simply permuted? Can you report the MATLAB and Julia
results in the two cases for a small covX matrix?

On Sat, Sep 10, 2016 at 1:34 PM, Dennis Eckmeier <
dennis.eckme...@neuro.fchampalimaud.org> wrote:

> Hi,
>
> I am new to Julia and rather lay in math. For practice, I am translating a
> Matlab script (written by somebody else) and compare the result of each
> step in Matlab and Julia.
>
> The Matlab script uses  [V,D] = eig(covX);
>
> which I translated to Julia as: (D,V) = eig(covX)
>
> However, the outcomes don't match, although covX is the same.
>
> D.
>
>
>


Re: [julia-users] Julia equivalent to Matlab's [Q, R, P] = qr(A)?

2016-09-06 Thread Michele Zaffalon
I think you should use qrfact(A,value{true}):
http://docs.julialang.org/en/release-0.4/stdlib/linalg/?highlight=qrfact#Base.qrfact

On Wed, Sep 7, 2016 at 3:37 AM, Stuart Brorson  wrote:

> Hello Julia users,
>
> Matlab has a variant of the QR decomposition invoked like this:
>
> [Q,R,P] = qr(A)
>
> This variant of qr() returns matrix R where the diagonal elements are
> sorted from largest to smallest magnitude as you go from upper left to
> lower right.  The matrix P is the permutation matrix which permutes
> the rows/cols of A to give this ordering of the diagonal elements of
> R.  That is, Q*R = A*P.
>
> I tried doing the naive, analogous thing in Julia, but get an error:
>
> julia> A = rand(3,3)
> 3x3 Array{Float64,2}:
>  0.243071  0.454947   0.89657
>  0.112843  0.802457   0.375417
>  0.154241  0.0182734  0.992542
>
> julia> Q,R,P = qr(A)
> ERROR: BoundsError: attempt to access (
> 3x3 Array{Float64,2}:
>  -0.786117   0.0985642  -0.610168
>  -0.364946  -0.8707630.329523
>  -0.498833   0.4817230.720492,
>
> 3x3 Array{Float64,2}:
>  -0.309204  -0.659611  -1.33693
>   0.0   -0.645106   0.2396
>   0.00.00.29177)
>   at index [3]
>  in indexed_next at tuple.jl:21
>
> My question:  What's the best way to get the equivalent of Matlab's
> [Q,R,P] = qr(A) in Julia?  Should I write my own qr() (not too
> difficult)?  Or just do some row/col permutation of the output of
> regular qr()?
>
> Thanks for any advice,
>
> Stuart
>
> p.s.  I am using Version 0.4.3-pre+6 (2015-12-11 00:38 UTC)
>


Re: [julia-users] How to avoid LOAD_PATH at each julia session

2016-09-06 Thread Michele Zaffalon
And here:
http://docs.julialang.org/en/release-0.4/manual/modules/?highlight=juliarc

On Tue, Sep 6, 2016 at 4:05 PM, Michele Zaffalon <michele.zaffa...@gmail.com
> wrote:

> Put that line in .juliarc as described in the docs: http://docs.julialang.
> org/en/release-0.4/manual/getting-started/?highlight=juliarc
>
> On Tue, Sep 6, 2016 at 4:00 PM, Ahmed Mazari <ahmedmazari...@gmail.com>
> wrote:
>
>> hello
>> push!(LOAD_PATH," the path")
>>
>> how can l avoid putting this line of code at each julia session. each
>> time l went to julia l should do that and it's really boring
>>
>> thank you
>>
>
>


Re: [julia-users] How to avoid LOAD_PATH at each julia session

2016-09-06 Thread Michele Zaffalon
Put that line in .juliarc as described in the docs:
http://docs.julialang.org/en/release-0.4/manual/getting-started/?highlight=juliarc

On Tue, Sep 6, 2016 at 4:00 PM, Ahmed Mazari 
wrote:

> hello
> push!(LOAD_PATH," the path")
>
> how can l avoid putting this line of code at each julia session. each time
> l went to julia l should do that and it's really boring
>
> thank you
>


Re: [julia-users] Julia with fewer dependencies?

2016-09-06 Thread Michele Zaffalon
Is this maybe what you are looking for
https://groups.google.com/d/msg/julia-users/WStpLtrKiFA/JhiAbc-vAwAJ?

On Mon, Sep 5, 2016 at 11:10 PM, Joaquim Masset Lacombe Dias Garcia <
joaquimdgar...@gmail.com> wrote:

>
> The basic question is "Can I compile a smaller version of julia?"
>
> For instance, I want to ship some program as an executable, something
> similar to what BuildExecutable.jl does, btw its very nice!
> The only problem is that with BuildExecutable.jl or even with the pure
> usrimg.jl trick create a huge folder with all the julia main libs.
>
> I looked for an existing post but all I could find is this archived old
> post: https://www.reddit.com/r/Julia/comments/2da03c/julia_
> with_fewer_dependencies/
>
> Can I compile julia without some of those libs?
>
> One nice use would be if I have a program with no use of libopenblas that
> I could ship without having to send a 40Mb lib...
>
> Thanks in advance!
>


Re: [julia-users] Re: another new 2D plotting library for Julia

2016-08-25 Thread Michele Zaffalon
Did you notice that Igor said Windows 7 x64 only for the moment?

On Thu, Aug 25, 2016 at 1:27 PM, Henri Girard  wrote:
> That's what I got in julia, I put the so lib in /usr/lib/
> The linux app qwtw is working properly.
>
>
>
> julia> using qwtwplot
> ERROR: LoadError: KeyError: key "ALLUSERSPROFILE" not found
>  in access_env(::Base.##339#340, ::String) at ./env.jl:45
>  in getindex(::Base.EnvHash, ::String) at ./env.jl:73
>  in include_from_node1(::String) at ./loading.jl:426
>  in eval(::Module, ::Any) at ./boot.jl:234
>  in require(::Symbol) at ./loading.jl:357
> while loading /home/pi/.julia/v0.5/qwtwplot/src/qwtwplot.jl, in expression
> starting on line 4
>
> julia> Pkg.clone("https://github.com/ig-or/qwtwplot;)
> INFO: Cloning qwtwplot from https://github.com/ig-or/qwtwplot
> ERROR: qwtwplot already exists
>  in clone(::String, ::SubString{String}) at ./pkg/entry.jl:193
>  in clone(::String) at ./pkg/entry.jl:221
>  in
> (::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#clone,Tuple{String}})()
> at ./pkg/dir.jl:31
>  in
> cd(::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#clone,Tuple{String}},
> ::String) at ./file.jl:59
>  in #cd#1(::Array{Any,1}, ::Function, ::Function, ::String, ::Vararg{Any,N})
> at ./pkg/dir.jl:31
>  in clone(::String) at ./pkg/pkg.jl:151
>
> julia> Pkg.checkout("qwtwplot")
> INFO: Checking out qwtwplot master...
> INFO: Pulling qwtwplot latest master...
> INFO: No packages to install, update or remove
>
> julia> using qwtwplot
>
> julia> using qwtwplot
>
> julia> qwtwStart() # start 'qwtwc' library
> ERROR: UndefVarError: qwtwStart not defined
>
> julia> # draw thin blue 'sinus':
>tMax = 10.
> 10.0
>
> julia> t = Array(linspace(0.,tMax, 1));
>
> julia> n = length(t)
> 1
>
> julia> y = sin(t);
>
> julia> qfigure(1); # "1" the number of the first plot window
> ERROR: UndefVarError: qfigure not defined
>
> julia> # parameters: 'x' and 'y' data vectors, then 'name of this line',
> then 'style description', then 'line width'
>qplot(t, y, "blue line", "-b", 1)
> ERROR: UndefVarError: qplot not defined
>
> julia>
>
>
> Le jeudi 25 août 2016 12:01:30 UTC+2, Igor a écrit :
>>
>> Hello!
>> I made another 2D plotting library for Julia. Please try to test it if you
>> have some free time. Current version works only for Windows7 x64, but I'm
>> planning to make everything work for Fedora Linux also.
>>
>> It is located here: https://github.com/ig-or/qwtwplot
>> you'll have to read its description before the installation.
>>
>> It is based on underlying "C" library, which I used to use for data
>> analysis for many years, but now I tried to make a Julia package out of it.
>> I'm new to github, so your comments will be very appreciated.
>>
>> Best regards, Igor
>>
>>
>>
>>
>>
>>
>>
>


Re: [julia-users] New to Julia - Need some basic help

2016-08-19 Thread Michele Zaffalon
What code did you download?

On Fri, Aug 19, 2016 at 10:24 AM, Pigskin Ablanket <
pigskinablan...@gmail.com> wrote:

> Ok, I am trying to familiarize myself with a study published using Julia.
> I have Julia up and running, but cant seep to get the actual code open.
>
> Here is what I done so far:
>
> julia> Pkg.add("JuMP")
> julia> Pkg.add("DataFrames")
> julia> Pkg.add("GLPKMathProgInterface")
>
> I believe I successfully added the requisite programs.  all good.  Now I 
> downloaded the code via CSV.
>
> It contains the Code in a .jl file, license file, readme file and a couple 
> excel CSV files needed.
>
> I tried top open the file using Julia> Open("Filename.jl") and got the 
> following error:
>
> *No such file or directory in open at iostream.jl:90  **in open at 
> **iostream.jl:99*
>
> My sense is that I dont have the file in the right directory, but this is 
> where I get over my skis.
>
> Is that the issue?  How do I make Julia find the file?  Sorry or such basic 
> questions 
>
>


Re: [julia-users] PyCall: keyword arguments that are reserved in Julia

2016-07-13 Thread Michele Zaffalon
ase_build.graphene_nanoribbon(3, 4, kind="armchair")?

On Wed, Jul 13, 2016 at 10:19 AM, Christoph Ortner <
christophortn...@gmail.com> wrote:

> I was recently trying to
> ```julia
> @pyimport ase.build as ase_build
> ase_build.graphene_nanoribbon(3, 4, type="armchair")
> ```
> which throws the error `ERROR: syntax: unexpected "="`
>
> I assume that the problem is that `type` is a reserved keyword for Julia?
> Is there a workaround?
>
> Thank you
> Christoph
>


Re: [julia-users] Re: integrate.odeint(f,t)

2016-06-20 Thread Michele Zaffalon
And remember to change your f(y,t) because Julia has 1-based arrays.

On Mon, Jun 20, 2016 at 9:32 PM, Michele Zaffalon <
michele.zaffa...@gmail.com> wrote:

> Also linspace(0.01,0) is not the same as [0.01,0]
>
> On Mon, Jun 20, 2016 at 8:15 PM, Henri Girard <henri.gir...@gmail.com>
> wrote:
>
>> After correction still doesn't work.
>> I have this function from another programme which is working, i wonder if
>> it's not my odeint(f,y,t) which is wrong ?
>>
>>
>> Le lundi 20 juin 2016 17:32:07 UTC+2, Henri Girard a écrit :
>>>
>>> I am trying to convert from python to julia, but I don't know how to use
>>> y1=integrate.odeint(f,t), apparently I should have add a derivativ ?
>>>
>>> --python--
>>> from scipy.integrate import odeint
>>> def f(y,t):
>>> if t<25:
>>> return [y[1],-8*y[0]+0.1*y[1]]
>>> elif 25<t<45:
>>> return [y[1],-8*y[0]]
>>> else:
>>> return [y[1],-8*y[0]-0.1*y[1]]
>>> t=np.linspace(0,35,1000)
>>> # start from  y=0.01, y’=0
>>> y1=odeint(f,[0.01,0],t)
>>> plt.plot(t,y1[:,0])
>>> plt.title("Evolution temporelle")
>>> plt.xlabel("Temps t (s)")
>>> plt.ylabel("Intensite i (A)")
>>> plt.plot(0,0.01,"ro")
>>> #plt.savefig("RLC-demarrage.eps")
>>> plt.show()
>>> --ijulia
>>> @pyimport scipy.integrate as odeint
>>> function f(y,t)
>>>   if t<25
>>> return [y[1],-8*y[0]+0.1*y[1]]
>>>   elseif 25<t<45
>>> return [y[1],-8*y[0]]
>>>   else
>>> return [y[1],-8*y[0]-0.1*y[1]]
>>>   end
>>> end;
>>> t=linspace(0,35,1000)
>>> y=linspace(0.01,0)
>>> y1=integrate.odeint(f,y,t)
>>>
>>
>


Re: [julia-users] Re: integrate.odeint(f,t)

2016-06-20 Thread Michele Zaffalon
Also linspace(0.01,0) is not the same as [0.01,0]

On Mon, Jun 20, 2016 at 8:15 PM, Henri Girard 
wrote:

> After correction still doesn't work.
> I have this function from another programme which is working, i wonder if
> it's not my odeint(f,y,t) which is wrong ?
>
>
> Le lundi 20 juin 2016 17:32:07 UTC+2, Henri Girard a écrit :
>>
>> I am trying to convert from python to julia, but I don't know how to use
>> y1=integrate.odeint(f,t), apparently I should have add a derivativ ?
>>
>> --python--
>> from scipy.integrate import odeint
>> def f(y,t):
>> if t<25:
>> return [y[1],-8*y[0]+0.1*y[1]]
>> elif 25> return [y[1],-8*y[0]]
>> else:
>> return [y[1],-8*y[0]-0.1*y[1]]
>> t=np.linspace(0,35,1000)
>> # start from  y=0.01, y’=0
>> y1=odeint(f,[0.01,0],t)
>> plt.plot(t,y1[:,0])
>> plt.title("Evolution temporelle")
>> plt.xlabel("Temps t (s)")
>> plt.ylabel("Intensite i (A)")
>> plt.plot(0,0.01,"ro")
>> #plt.savefig("RLC-demarrage.eps")
>> plt.show()
>> --ijulia
>> @pyimport scipy.integrate as odeint
>> function f(y,t)
>>   if t<25
>> return [y[1],-8*y[0]+0.1*y[1]]
>>   elseif 25> return [y[1],-8*y[0]]
>>   else
>> return [y[1],-8*y[0]-0.1*y[1]]
>>   end
>> end;
>> t=linspace(0,35,1000)
>> y=linspace(0.01,0)
>> y1=integrate.odeint(f,y,t)
>>
>


Re: [julia-users] integrate.odeint(f,t)

2016-06-20 Thread Michele Zaffalon
Your first line should be @pyimport scipy.integrate as integrate.

On Mon, Jun 20, 2016 at 5:32 PM, Henri Girard 
wrote:

> I am trying to convert from python to julia, but I don't know how to use
> y1=integrate.odeint(f,t), apparently I should have add a derivativ ?
>
> --python--
> from scipy.integrate import odeint
> def f(y,t):
> if t<25:
> return [y[1],-8*y[0]+0.1*y[1]]
> elif 25 return [y[1],-8*y[0]]
> else:
> return [y[1],-8*y[0]-0.1*y[1]]
> t=np.linspace(0,35,1000)
> # start from  y=0.01, y’=0
> y1=odeint(f,[0.01,0],t)
> plt.plot(t,y1[:,0])
> plt.title("Evolution temporelle")
> plt.xlabel("Temps t (s)")
> plt.ylabel("Intensite i (A)")
> plt.plot(0,0.01,"ro")
> #plt.savefig("RLC-demarrage.eps")
> plt.show()
> --ijulia
> @pyimport scipy.integrate as odeint
> function f(y,t)
>   if t<25
> return [y[1],-8*y[0]+0.1*y[1]]
>   elseif 25 return [y[1],-8*y[0]]
>   else
> return [y[1],-8*y[0]-0.1*y[1]]
>   end
> end;
> t=linspace(0,35,1000)
> y=linspace(0.01,0)
> y1=integrate.odeint(f,y,t)
>


Re: [julia-users] ComplexPhasePortrait

2016-06-18 Thread Michele Zaffalon
What is it? Is it a function in a package?

On Sat, Jun 18, 2016 at 8:52 AM, Henri Girard 
wrote:

> HI,
> I would like to use  complexphaseportrait but I can't find any examples,
> somebody can guide me to these ?
> Regards
> HG
>


Re: [julia-users] Re: Plots 2 pic ?

2016-06-16 Thread Michele Zaffalon
Henri,

you gave two examples with two different values of R: 40 in the first case
and 1000 in the second. In the case with R=1000, the resonance is so damped
that the peak at 1 / sqrt(LC) has disappeared, and the curve simply bends
downwards.

You should define your frequency correctly, like fr=
2*pi*linspace(0,2ω,1000) or you should define your formula correctly y =
abs(1 ./ (1+im*2*pi*fr*R*C-(2*pi*fr).^2*L*C)). Please do not mix angular
frequency and frequency, because you are in troubles: I have been there.

michele

On Thu, Jun 16, 2016 at 3:13 PM, Henri Girard 
wrote:

> My new tentative (which is not working)
> using Plots
> R=1000;L=1/pi*360E-2;C=1/(pi*360E+2)
> w=1/sqrt(L*C)
> f=1/(2*pi*sqrt(L*C))
> omega=linspace(-f,f)
> y=abs(1./(1+im.*omega.*R.*C-omega.*omega.*L.*C));
> plot(omega,y,title="Fréquence de résonance",
> bg=RGB(.2,.2,.2),xlabel ="Hz",ylabel = "Ω")
> ---
> Working plot in sage,( I think the difference is var("f") and omega
>  which is a symbolic variable
> R=30;L=1/pi*360E-2;C=1/(pi*360E+2)
> var("f")
> omega=2*pi*f
> w=1/(sqrt(L*C))
> Fr=1/(2*pi*sqrt(L*C))
> q=plot(abs(1/(1+i*omega*R*C-omega*omega*L*C)),
> omega,0,100,figsize=4,frame=True,
>  fontsize=8,axes=False,color="red")
> show(q)
> print"Fréquence de résonance = ",round(Fr)," Hz"
> Le jeudi 16 juin 2016 09:22:12 UTC+2, Henri Girard a écrit :
>>
>> Hi,
>> When I make my plots I have two plots, but before I hadn't this...
>> w is the resoning frequency, but it should appear at 0 (zéro) not at
>> extrem ?
>> Any help, I already ask for help with pyplot, this link :
>> https://groups.google.com/forum/#!topic/julia-users/EJSvutfdEus, which
>> works fine for angular pulsation, but I want frequency resonance with Plots
>> because I guess I can make more beautifull graphic (anyway I don't know
>> well PyPlot or Plots). I succeeded once with pyplot but after an error I
>> couldn't find it back !
>> Bad luck :)
>> Kind regards
>> HG
>>
>> using Plots
>> pyplot(reuse=true)
>> z=10;u=0.02;s=0.02;w=1/(2*pi*sqrt(u*s))
>> f=linspace(-30,30)
>> y=abs(1./(1+im.*f.*z.*s-f.*f.*u.*s));
>> #fig = figure("Angle")
>> plot(f, y)
>>
>


Re: [julia-users] how to plot a point in julia with pyplot

2016-06-16 Thread Michele Zaffalon
using PyPlot
# in 2D
plot([1.], [2.], "o")
# in 3D
plot3D([1.], [2.], [3.], "o")

On Thu, Jun 16, 2016 at 12:37 PM, SHORE SHEN 
wrote:

> how to plot a point in julia with pyplot
>


Re: [julia-users] Re: Plots 2 pic ?

2016-06-16 Thread Michele Zaffalon
2*pi*R*C does not have the same value as z*s.

On Thu, Jun 16, 2016 at 10:36 AM, Henri Girard 
wrote:

> Angular pulsation with pyplot works as whishes :
>
> using PyPlot
> plt=PyPlot
> R=40;L=1/pi*360E-2;C=1/(pi*360E+2);ω=1/(sqrt(L*C))
> fr=linspace(0,2ω)
> y=abs(1./(1+im.*fr.*R.*C-fr.*fr.*L.*C));
> fig = figure("Angle")
> plt.plot(omega, y);
> plt.ylabel("z");
> plt.xlabel("w");
> ax = plt.gca() # get current axes
> ax[:set_xlim]((50,500));
> ax[:set_ylim]((0,10));
> plt.grid("on")
> plt.title("Pulsation angulaire");
> round(ω)
> I am doing it with plots ...
> But I wish frequency resonance with plots (or even pyplot because I didn't
> make it work properly).
>
> Le jeudi 16 juin 2016 09:22:12 UTC+2, Henri Girard a écrit :
>
>> Hi,
>> When I make my plots I have two plots, but before I hadn't this...
>> w is the resoning frequency, but it should appear at 0 (zéro) not at
>> extrem ?
>> Any help, I already ask for help with pyplot, this link :
>> https://groups.google.com/forum/#!topic/julia-users/EJSvutfdEus, which
>> works fine for angular pulsation, but I want frequency resonance with Plots
>> because I guess I can make more beautifull graphic (anyway I don't know
>> well PyPlot or Plots). I succeeded once with pyplot but after an error I
>> couldn't find it back !
>> Bad luck :)
>> Kind regards
>> HG
>>
>> using Plots
>> pyplot(reuse=true)
>> z=10;u=0.02;s=0.02;w=1/(2*pi*sqrt(u*s))
>> f=linspace(-30,30)
>> y=abs(1./(1+im.*f.*z.*s-f.*f.*u.*s));
>> #fig = figure("Angle")
>> plot(f, y)
>>
>


Re: [julia-users] Plots 2 pic ?

2016-06-16 Thread Michele Zaffalon
Maybe because you are missing factors of 2pi and (2pi)^2in your formula for
y?

On Thu, Jun 16, 2016 at 9:22 AM, Henri Girard 
wrote:

> Hi,
> When I make my plots I have two plots, but before I hadn't this...
> w is the resoning frequency, but it should appear at 0 (zéro) not at
> extrem ?
> Any help, I already ask for help with pyplot, this link :
> https://groups.google.com/forum/#!topic/julia-users/EJSvutfdEus, which
> works fine for angular pulsation, but I want frequency resonance with Plots
> because I guess I can make more beautifull graphic (anyway I don't know
> well PyPlot or Plots). I succeeded once with pyplot but after an error I
> couldn't find it back !
> Bad luck :)
> Kind regards
> HG
>
> using Plots
> pyplot(reuse=true)
> z=10;u=0.02;s=0.02;w=1/(2*pi*sqrt(u*s))
> f=linspace(-30,30)
> y=abs(1./(1+im.*f.*z.*s-f.*f.*u.*s));
> #fig = figure("Angle")
> plot(f, y)
>


[julia-users] plans to add an extended standard library section?

2016-06-02 Thread Michele Zaffalon
Related to the recent discussion 
https://groups.google.com/d/msg/julia-users/IV4ulyX_dCc/fseYrc7xPgAJ

Are there any plans to add the documentation for StatsBase.jl to 
http://docs.julialang.org/, maybe as an "extended standard library" 
section? I for myself, use DataStructures often and the first place I tend 
to search is the standard library, only to remember that it is a separate 
package.

I found the python documentation at 
https://docs.python.org/3/library/index.html very convenient, especially 
when browsing.

michele


Re: [julia-users] random number generation

2016-06-01 Thread Michele Zaffalon
shuffle(collect(1:14))[1:6] but I remember seeing a method that picks n
random elements from an array.

By the way, shuffle(1:14) does not seem to work.

On Wed, Jun 1, 2016 at 8:32 PM, El suisse  wrote:

> I think like this:
>
> `rand(1:14, 6)`
>
> 2016-06-01 15:24 GMT-03:00 Michela Di Lullo :
>
>> How can I do to generate 6 *different* integer random numbers between 1
>> and 14?
>>
>> Thanks in advance to who will answer,
>>
>> M.
>>
>> ___
>> INVESTI SUL FUTURO, FAI CRESCERE L’UNIVERSITÀ:
>>
>> *DONA IL 5 PER MILLE ALLA SAPIENZA*
>>
>> CODICE FISCALE *80209930587*
>>
>
>


Re: [julia-users] Re: julia equivalent of python [] (Part II)

2016-06-01 Thread Michele Zaffalon
What is OP?

On Wed, Jun 1, 2016 at 12:14 PM, Milan Bouchet-Valat 
wrote:

> Le mercredi 01 juin 2016 à 02:35 -0700, Lutfullah Tomak a écrit :
> > julia> b_prime = ["8",9,10,c]
> >
> > This works with Any.
> >
> > julia> Any["3", 4, 14, c]
> > 4-element Array{Any,1}:
> >"3"
> >   4
> >  14
> >Any[10,"c"]
> >
> Yes, for now you need to use that syntax. In 0.5, the OP's code works
> fine too since the deprecation path has been removed.
>
>
> Regards
>


Re: [julia-users] Re: Quadratic equation solver ?

2016-05-31 Thread Michele Zaffalon
JuMP is a modeling language for linear and quadratic optimization problems,
see http://www.juliaopt.org/

On Tue, May 31, 2016 at 1:26 PM, Mosè Giordano 
wrote:

> which one is a good  solver(open source) for quadratic equation using jump
>> ? Thank you
>>
>
> What is jump?
>
> PolynomialRoots.jl is a
> package to find all roots (real and complex, they will have always Complex
> type) of polynomials of any degree, with a specialized function for
> quadratic equations.  Though, I don't know if this is what you're looking
> for.
>
> Bye,
> Mosè
>


Re: [julia-users] This application has requested the Runtime to terminate it in an unusual way

2016-05-27 Thread Michele Zaffalon
As said in the previous email, the output of versioninfo() and a minimal
script to reproduce the problem that crashes julia.

On Fri, May 27, 2016 at 1:40 PM, <tannir...@gmail.com> wrote:

>
> This is the whole message which I get on the console. you needed this
> information or any other ?
>
>
> "This application has requested the Runtime to terminate it in an unusual
> way.
> Please contact the application's support team for more information.
> Assertion failed
> Program:C:\User\Tanveer Iqbal\AppData\Local\Julia-0.4.3\bin\julia.exe.
> File:
> User/x86_64-w64-mingw32/sys-root/mingw/include/Line3934
> Expression: i <numberparameter"
>
>
>
> On Friday, May 27, 2016 at 5:41:54 AM UTC+2, Michele Zaffalon wrote:
>>
>> You should at least provide some information on the system (e.g. what
>> Julia version you were using by copying the output of versioninfo()) and a
>> minimal script to reproduce the problem.
>>
>> On Thu, May 26, 2016 at 10:47 PM, <tann...@gmail.com> wrote:
>>
>>> When i execute the problem . This message appears on the julia window.
>>> How can I fix it ? Thank you
>>>
>>>
>>> "This application has requested the Runtime to terminate it in an
>>> unusual way.
>>> Please contact the application's support team for more information."
>>>
>>>
>>>
>>


Re: [julia-users] This application has requested the Runtime to terminate it in an unusual way

2016-05-26 Thread Michele Zaffalon
You should at least provide some information on the system (e.g. what Julia
version you were using by copying the output of versioninfo()) and a
minimal script to reproduce the problem.

On Thu, May 26, 2016 at 10:47 PM,  wrote:

> When i execute the problem . This message appears on the julia window. How
> can I fix it ? Thank you
>
>
> "This application has requested the Runtime to terminate it in an unusual
> way.
> Please contact the application's support team for more information."
>
>
>


Re: [julia-users] Redefine constant

2016-05-26 Thread Michele Zaffalon
At the REPL, you can use workspace()


On Thu, May 26, 2016 at 12:10 PM,  wrote:

> when  i defined the const like
>
> Const a_max = [30,30]
> Const a_min = [0,10]
>
> I fined the warning
>
> WARNING: redefining constant a_max
> WARNING: redefining constant a_min
>
>
>
> how can I resolve this issue ?? Thank you
>
>
>
>


Re: [julia-users] Set PATH in windows 10

2016-05-09 Thread Michele Zaffalon
When Julia installs, it creates a link in the Start menu. If you right
click on the Julia icon, you should be able to figure out the path to the
Julia executable, julia.exe. That path should be ending with
...\bin\julia.exe.


On Fri, May 6, 2016 at 6:56 AM, Yu Tony  wrote:

> Hello everyone!
> I'm a beginner in programming; i have trouble finding the bin folder and
> setting PATH environment variales for Julia;
> Can anyone please tell me where to find the bin folder and what is the
> directory to set the PATH environment variable to ?
>
> Thankyou for your help,
> Tony
>


[julia-users] TensorSpace in ApproxFun

2016-05-03 Thread Michele Zaffalon
Hello,

I am confused by `ApproxFun.TensorSpace`. I understand the following.

dom1, dom2 = Fourier(), Chebyshev()
dom = dom1 ⊗ dom2
@assert TensorSpace(Fourier(), Chebyshev()) == dom1 ⊗ dom2
d1, d2 = Derivative(dom1), Derivative(dom2)
@assert Derivative(dom1, 1) == Derivative(dom1)


Here are the parts I do not understand:

1) Why doesn't the following evaluate to either error or 0? `dom1` is a 
single variable space

Derivative(dom1, 2) * Fun([0,0,1], dom1)

2) Why isn't this statement true? `d1` is the partial derivative with 
respect to the first variable of `dom`

Derivative(dom1) ⊗ I == Derivative(dom, 1) # --> false

3) Sorry for the dumb question but what is `Derivative(dom)`? Is 
`Derivative(dom)==Derivative(dom, 1)`? It looks like the following is true 
for all `f`

(Derivative(dom1) ⊗ I) * f == Derivative(dom) * f == Derivative(dom, 1) * f # 
--> true

whose first part seems to contradict 2).


It looks like negation of derivative for the tensor space is not defined:

(-Derivative(dom1)) * Fun([0,0,1],dom1) # valid expression for single 
variable function
(-Derivative(dom)) * Fun([0,0,1],dom) # invalid expression for the tensor 
space

Also, I would like to define the divergence and I expect div rot = 0 
identically. I fail to define \partial_1\partial_2 but \partial_2\partial_1 
works

stream_fun = Fun(randn(5), dom)
jϕ = Derivative(dom, 2) * stream_fun
jz = Derivative(dom, 1) * stream_fun
#Derivative(dom, 1) * jϕ #  ∂_1∂_2(stream_fun) --> error
Derivative(dom, 2) * jz # ∂_2∂_1(stream_fun) --> OK 


Last: `ApproxFun.transform(dom, y)` changes the values of `y` invalidating 
the convention about functions modifying its arguments.


michele


Re: [julia-users] sparse function

2016-05-02 Thread Michele Zaffalon
Are you sure? The error message seems to be generated by a different
function call.

On Tue, May 3, 2016 at 6:16 AM, new to Julia <weining1...@gmail.com> wrote:

> Thanks for your reply.
> A=sparse(nrow,ncol,vals_final);
> nrow, ncol, vals_final are all 1 dimensional vector.
>
> On Monday, May 2, 2016 at 11:10:12 PM UTC-5, Michele Zaffalon wrote:
>>
>> Can you post the code that generate the error?
>>
>> On Tue, May 3, 2016 at 5:47 AM, new to Julia <weini...@gmail.com> wrote:
>>
>>> Hi all:
>>>
>>> when I use sparse function in Julia coding, I have the following error:
>>>
>>> LoadError: MethodError: `sparse` has no method matching
>>> sparse(::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Int64,
>>> ::Int64, ::Base.AddFun)
>>> Closest candidates are:
>>> sparse(::Any, ::Any, ::AbstractArray{T,1}, ::Any, ::Any)
>>> sparse(::Any, ::Any, !Matched::Number, ::Any, ::Any,
>>> ::Union{Base.Func{N},Function})
>>> sparse(::Any, ::Any, !Matched::AbstractArray{Bool,1}, ::Any, ::Any)
>>> ...
>>> in sparse at sparse/sparsematrix.jl:380
>>>
>>> I am wondering that how can I fix the bug? Thank you very much.
>>>
>>> Best
>>>
>>>
>>>
>>>
>>


Re: [julia-users] sparse function

2016-05-02 Thread Michele Zaffalon
Can you post the code that generate the error?

On Tue, May 3, 2016 at 5:47 AM, new to Julia  wrote:

> Hi all:
>
> when I use sparse function in Julia coding, I have the following error:
>
> LoadError: MethodError: `sparse` has no method matching
> sparse(::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Int64,
> ::Int64, ::Base.AddFun)
> Closest candidates are:
> sparse(::Any, ::Any, ::AbstractArray{T,1}, ::Any, ::Any)
> sparse(::Any, ::Any, !Matched::Number, ::Any, ::Any,
> ::Union{Base.Func{N},Function})
> sparse(::Any, ::Any, !Matched::AbstractArray{Bool,1}, ::Any, ::Any)
> ...
> in sparse at sparse/sparsematrix.jl:380
>
> I am wondering that how can I fix the bug? Thank you very much.
>
> Best
>
>
>
>


Re: [julia-users] Strange Behavior Whereby Shared Arrays Requires Indexing

2016-04-27 Thread Michele Zaffalon
Can you update Julia to the current 0.4.5? Your version is year old.

(I keep asking the same question over and over.)

On Wed, Apr 27, 2016 at 6:56 PM, Michael Wojnowicz  wrote:

>
> Here's some behavior using Julia's parallel processing that really
> surprised me. I'm not sure if this behavior is a bug (in which case I
> should report it), or if I'm just missing something.  Really stupid but
> minimal example:
>
> This code fails:
> @everywhere function doit(vec::Array{Int64,1})
>   AccumulateVectorEntries=SharedArray(Int64,1,1)
>   pmap(enumerate(vec)) do index_pair #note: this works in parallel
> (i,entry) = index_pair
> AccumulateVectorEntries+=entry
>   end
>   return sdata(AccumulateVectorEntries)
> end
>
> result=doit([1,2,3,4,5])
>
> This code works as intended:
> @everywhere function doit(vec::Array{Int64,1})
>   AccumulateVectorEntries=SharedArray(Int64,1,1)
>   pmap(enumerate(vec)) do index_pair #note: this works in parallel
> (i,entry) = index_pair
> AccumulateVectorEntries[1,1]+=entry
>   end
>   return sdata(AccumulateVectorEntries)
> end
>
> result=doit([1,2,3,4,5])
>
> Is this sensible based on some principles of how parallel processing
> works, or am I just missing something?  PS - I'm trained as a statistician,
> so please excuse any naivete re: computing principles.
>
> BTW  --  I'm using
>
> *julia> **versioninfo()*
>
> Julia Version 0.3.8-pre+22
>
> Commit 5078421* (2015-04-28 09:05 UTC)
>
> Platform Info:
>
>   System: Linux (x86_64-amazon-linux)
>
>   CPU: Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz
>
>   WORD_SIZE: 64
>
>   BLAS: libmkl_rt
>
>   LAPACK: libmkl_rt
>
>   LIBM: libimf
>
>   LLVM: libLLVM-3.3
>
>


Re: [julia-users] Re: build issue on v0.4.2

2016-04-25 Thread Michele Zaffalon
Would it not be better to update to 0.4.5 first?

On Mon, Apr 25, 2016 at 1:57 PM,  wrote:

> it seems that
>
> /home/vagrant/julia-0.4.2/base/precompile.jl
>
> crashed because of memory overflow (i watched htop).
>
> i'll try the build with more memory on my test virtual machine (500Mb -> 1
> Gb).
>
>
>
> Le lundi 25 avril 2016 13:50:21 UTC+2, ming...@irt-systemx.fr a écrit :
>>
>> hello,
>>
>> there a build issue on a Vagrant virtual machine (i am actually debugging
>> my Ansible automation) :
>>
>> require.jl
>> docs/helpdb.jl
>> docs/basedocs.jl
>> /home/vagrant/julia-0.4.2/base/precompile.jl
>> Killed
>> *** This error is usually fixed by running `make clean`. If the error
>> persists, try `make cleanall`. ***
>> make[1]: *** [/home/vagrant/julia-0.4.2/usr/lib/julia/sys.o] Error 1
>> make: *** [julia-sysimg-release] Error 2
>> vagrant@vagrant-ubuntu-trusty-64:~/julia-0.4.2$ make
>> LINK usr/lib/julia/sys.so
>> /home/vagrant/julia-0.4.2/usr/lib/julia/sys.o: file not recognized: File
>> truncated
>> collect2: error: ld returned 1 exit status
>> make[1]: *** [/home/vagrant/julia-0.4.2/usr/lib/julia/sys.so] Error 1
>>
>>
>> and here is the sys.o file :
>>
>> vagrant@vagrant-ubuntu-trusty-64:~/julia-0.4.2/usr/lib/julia$ ll
>> total 3788
>> drwxrwxr-x 2 vagrant vagrant4096 Apr 25 13:27 ./
>> drwxrwxr-x 4 vagrant vagrant4096 Apr 25 13:23 ../
>> -rw-r--r-- 1 vagrant vagrant 1966777 Apr 25 13:23 inference0.ji
>> -rw-r--r-- 1 vagrant vagrant 1898851 Apr 25 13:24 inference.ji
>> -rw-rw-r-- 1 vagrant vagrant   0 Apr 25 13:25 sys.o
>>
>>
>> i did :
>> make -j 1
>> in order to be sure that it is not a parallel make issue.
>>
>>
>> bests,
>>
>


Re: [julia-users] bounds error / inexacterror

2016-04-18 Thread Michele Zaffalon
It looks like your `ratio` is a scalar number and you are trying to get the
k-th element of it.

On Sun, Apr 17, 2016 at 3:32 PM, Yichao Yu  wrote:

> On Sun, Apr 17, 2016 at 9:14 AM, Emeline Lépine
>  wrote:
> > Hi,
> >
> > According the index line 37 I have either "Bounds error" and "Inexact
> error"
> > (line in red). What's the matter, is it the type ?
>
> Where do you see it?
>
> P.S. Also make sure you are not doing this in global scope for
> performance reasons.
>
> >
> > Thanks !
> >
> > Emi
> >
> > #split step fourier method
> > #16/03/2016
> >
> > using Gadfly
> >
> > 
> >
> > cputime=0
> > tic();
> > ln=1;
> > Po=.00064; #input power in watts
> > L = 12 # lenght of the fiber
> > Α=0;# fiber loss value in dB/km
> > α =Α/4.343;#ref page %55 GP Agrawal
> > γ=0.003; #fiber non linearity in /W/m
> > to=125e-12;  #initial pulse width in second
> > C= -2; # Input chirp parameter for first calculation
> > b2=20e-27 # 2nd order disp. (s2/m)
> > Ld=(to^2)/(abs(b2)); # dispersion length in meter
> > Ao=sqrt(Po); # Amplitude
> > i = complex(1, pi/2);
> > start = 0.1;
> > step = 0.1;
> > stop = 1.5;
> > nb_points = 14; # a recalculer à la main à chaque fois
> > iim = linspace(start, stop, nb_points);
> > ###
> >
> > τ= - 4096e-12:1e-12:4095e-12; #dt=t/to
> > dt=1e-12;
> > rel_error=1e-5;
> > h=1000;#step size
> >
> > u=Ao*exp(-((1+im.*(-C))/2).*(τ/to).^2);
> > plot(x=τ,y=abs(u),Geom.line,Guide.xlabel("Time"),
> Guide.ylabel("Amplitude"),
> > Guide.title("Input pulse"));
> >
> > for k = 1:nb_points # the various fiber lengths can be varied and this
> > vector can be changed
> > ii = iim[k];
> > l=maximum(size(u));
> > fwhm1=find(abs(u).>(maxabs(u)./2));
> > fwhm1=length(fwhm1);
> > dw = 1/1/dt*2*pi;
> > w = (-1*1/2:1:1/2-1)*dw;
> > u = fftshift(u);
> > w = fftshift(w);
> > spectrum = fft(fftshift(u)); #Pulse spectrum
> > for jj=h:h:1
> >   spectrum = spectrum.*exp(-α*(h/2) + i*b2/2*w.^2*(h/2));
> >   f = ifft(spectrum);
> >   f = f.*exp(i*γ*((abs(f).^2)*h));
> >   spectrum = fft(f);
> >   spectrum = spectrum.*exp(-α*(h/2)+i*b2*w.^2*(h/2));
> > end
> > f = ifft(spectrum);
> > op_pulse(ln)= abs(f);
> > fwmh = find((abs(f)).>(abs(maxabs(f)./2)));
> > fwmh = length(fwmh);
> > ratio = fwmh./fwhm1;
> > pbratio = ratio[k];
> > dd = atand((abs(imag(f)))/(abs(f)));
> > phadisp = dd[k];
> > end
> > toc;
> > cputime = toc;
> > plot(x=ln,y=pbratio,Geom.line,Guide.xlabel("Number of steps"),
> > Guide.ylabel("Pulse Broadening ratio"));
> > plot(x=ln,y=phadisp,Geom.line,Guide.xlabel("Distance travelled"),
> > Guide.ylabel("Phase change"));
> > draw(PDF("split_step_fourier_method.pdf", 6inch, 6inch),
> vstack(p1,p2,p3));
> >
> >
> >
>


Re: [julia-users] Failed process

2016-04-15 Thread Michele Zaffalon
Changing the global git config used to work:
https://groups.google.com/d/msg/julia-users/nI7CgwGEd3A/AUZ-10J_04cJ


On Fri, Apr 15, 2016 at 9:49 AM,  wrote:

>
> Hello,
>
> I have installed Julia 0.4.5 on Windows 7.
>
> When I run *Pkg.init(),* I get the following error message:
>
>
> julia> Pkg.init()
> INFO: Initializing package repository D:\users\myname\.julia\v0.4
> INFO: Cloning METADATA from git://github.com/JuliaLang/METADATA.jl
> fatal: unable to connect to github.com:
> github.com[0: 192.30.252.121]: errno=No error
>
> ERROR: failed process: Process(`git clone -q -b metadata-v2 git://
> github.com/JuliaLang/METADATA.jl METADATA`, ProcessExited(128)) [128]
>  in run at process.jl:531
>
>
>
> Here's my version info:
>
> julia> versioninfo()
> Julia Version 0.4.5
> Commit 2ac304d (2016-03-18 00:58 UTC)
> Platform Info:
>   System: Windows (x86_64-w64-mingw32)
>   CPU: Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz
>   WORD_SIZE: 64
>   BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
>   LAPACK: libopenblas64_
>   LIBM: libopenlibm
>   LLVM: libLLVM-3.3
>
>
>
> Any help would be much appreciated.
>
> Philippe
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


Re: [julia-users] append! multiple collections

2016-03-19 Thread Michele Zaffalon
Cedric,

Feel free to contribute the PR, since you have a better understanding than
I do.


On Thu, Mar 17, 2016 at 2:48 PM, Stefan Karpinski <ste...@karpinski.org>
wrote:

> Yes, that would be better written to pre-extend the array only once.
> Another good PR/issue to open.
>
> On Wed, Mar 16, 2016 at 10:58 PM, Cedric St-Jean <cedric.stj...@gmail.com>
> wrote:
>
>> Not part of Michele's PR, but I just saw this definition:
>>
>> push!(A, a, b, c...) = push!(push!(A, a, b), c...)
>>
>> Doesn't it make the vector reallocate+copy many times instead of just
>> once?
>>
>> On Wednesday, March 16, 2016 at 9:45:02 AM UTC-4, Stefan Karpinski wrote:
>>>
>>> Yes, wonderful! Thanks for contributing it. If you add a test, it'll get
>>> merged rapidamente.
>>>
>>> On Wed, Mar 16, 2016 at 4:03 AM, Michele Zaffalon <michele@gmail.com
>>> > wrote:
>>>
>>>> Something like this <https://github.com/JuliaLang/julia/pull/15529>?
>>>>
>>>> On Tue, Mar 15, 2016 at 7:28 PM, Stefan Karpinski <ste...@karpinski.org
>>>> > wrote:
>>>>
>>>>> It's just an absent feature – if you'd open an issue, I'm sure someone
>>>>> will add it shortly. It would make a pretty good intro issue.
>>>>>
>>>>> On Tue, Mar 15, 2016 at 12:43 PM, Michele Zaffalon <
>>>>> michele@gmail.com> wrote:
>>>>>
>>>>>> I have some arrays I would like to `append!` to the first. At the
>>>>>> moment I do
>>>>>>
>>>>>> reduce(append!, array_1, [array_2, array_3, ...]),
>>>>>>
>>>>>> but I would like to write
>>>>>>
>>>>>> append!(array_1, array_2, array_3, ...)
>>>>>>
>>>>>> just like for `push!`ing several items into the collection. Why is
>>>>>> this not allowed?
>>>>>>
>>>>>> Thank you,
>>>>>> michele
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>


Re: [julia-users] append! multiple collections

2016-03-16 Thread Michele Zaffalon
Something like this <https://github.com/JuliaLang/julia/pull/15529>?

On Tue, Mar 15, 2016 at 7:28 PM, Stefan Karpinski <ste...@karpinski.org>
wrote:

> It's just an absent feature – if you'd open an issue, I'm sure someone
> will add it shortly. It would make a pretty good intro issue.
>
> On Tue, Mar 15, 2016 at 12:43 PM, Michele Zaffalon <
> michele.zaffa...@gmail.com> wrote:
>
>> I have some arrays I would like to `append!` to the first. At the moment
>> I do
>>
>> reduce(append!, array_1, [array_2, array_3, ...]),
>>
>> but I would like to write
>>
>> append!(array_1, array_2, array_3, ...)
>>
>> just like for `push!`ing several items into the collection. Why is this
>> not allowed?
>>
>> Thank you,
>> michele
>>
>>
>>
>


Re: [julia-users] Status of Plots.jl?

2016-03-10 Thread Michele Zaffalon
On Thu, Mar 10, 2016 at 4:54 PM, Daniel Carrera  wrote:

>
> On 10 March 2016 at 14:18, Tom Breloff  wrote:
>
>> Yes it's come a long way.  Documentation is coming slower than
>> functionality (typical open source...).  However I added this yesterday,
>> which should help answer a few questions:
>> http://plots.readthedocs.org/en/latest/backends/
>>
>
>
> According to your table PyPlot can do everything :-)  I never thought
> PyPot was fast. I thought Matplotlib was famous for being slow. Ok. I
> updated Plots.jl and installed a few backends to play with (damn.. gadfly
> seems to depend on everything). Some scattered comments / questions:
>
> - It's looking great! Good job.
>
> - On my computer PyPlot is the default. Is that true for everyone or just
> me?
>
> - GR is 100x faster than PyPlot, but it's ugly. The plot is all pixelated.
> Is there a setting to make it look nice? The plots on the documentation
> look nice.
>
> - How do I try the unicode plots? I tried `unicode()` but that function
> doesn't exist.
>
> - Are Plotly and Gadfly supposed to just open a static plot (SVG?) on my
> browser? That seems weird.
>

It looks like that only GR, Immerse, PyPlot and PlotlyJS have a GUI
http://plots.readthedocs.org/en/latest/backends/#for-the-impatient

>
> - I tried Immerse, but it just died on me. :-(
>
> INFO: Precompiling module Immerse...
> ERROR: LoadError: LoadError: UndefVarError: absolute_native_units not
> defined
> ...
> ERROR: Failed to precompile Immerse to
> /home/daniel/.julia/lib/v0.4/Immerse.ji
>
>
> - It's weird that the heatmap() makes hexagons on PyPlot but a regular
> grid on the other backends.
>
>
> I'll play more with Plots.jl later. But it's nice to see an attempt at a
> unified plotting package for Julia.
>
> Cheers,
> Daniel.
>
>
>
> If you want to follow the latest and greatest, the issues list is where to
>> go.  Let me know if you have any questions... I'm happy to help.
>>
>> Tom
>>
>> On Thu, Mar 10, 2016 at 8:11 AM, Daniel Carrera 
>> wrote:
>>
>>> Hello,
>>>
>>> Does anyone know the status of Plots.jl? It seems to have come a long
>>> way. At least the documentation makes it look pretty complete:
>>>
>>> http://plots.readthedocs.org/en/latest/
>>>
>>> I'm looking at the backends. Does anyone know what "Gr", "Qwt", and
>>> "unicodeplots" are? Apparently support for Winston was dropped?
>>>
>>> https://github.com/tbreloff/Plots.jl/issues/152
>>>
>>> I don't use Winston, but I'm curious to know what happened. Was Winston
>>> hard to support?
>>>
>>> I am currently using PyPlot because I need the maturity of Matplotlib,
>>> but I am happy to see all the effort that's going into making a native
>>> plotting library for Julia.
>>>
>>> Cheers,
>>> Daniel.
>>>
>>
>>
>


Re: [julia-users] 3D scatter / meshed surface color map

2016-03-02 Thread Michele Zaffalon
Is https://github.com/stevengj/PyPlot.jl#3d-plotting not what your need?


On Thu, Mar 3, 2016 at 4:52 AM,  wrote:

> Hello Julia users,
>
> I would like to know if anyone knows how we can have 3D scatter plots or
> meshed surfaces color plots using Julia.
>
> My problem is based on four variables, so I'm trying to visualize the data
> according to these options.
>
> Any idea or example code will be really helpful.
>
> Thanks!
>


Re: [julia-users] Re: Googling the functions I need in Julia is hard

2016-02-12 Thread Michele Zaffalon
But the original point is still valid: using the search box in the official
documentation page http://docs.julialang.org/en/release-0.4, searching for
"standard deviation" does not bring up any useful hit, despite the fact
that Base.std is fairly well documented and contains the words standard
deviation.
Is there a reason why it should work at the REPL but not in the webpage?


On Fri, Feb 12, 2016 at 9:25 AM, Mauro  wrote:

> Also at the Julia REPL:
>
> julia> apropos("standard deviation")
> randn!
> stdm
> std
> randn
>
> help?> std
> search: std stdm STDIN STDOUT STDERR setdiff setdiff! hist2d hist2d!
> stride strides StridedArray StridedVector StridedMatrix StridedVecOrMat
> redirect_stdin
>
>   std(v[, region])
>
>   Compute the sample standard deviation of a vector or array v,
> optionally along dimensions in region. The algorithm returns an estimator
> of the generative
>   distribution's standard deviation under the assumption that each
> entry of v is an IID drawn from that generative distribution. This
> computation is equivalent to
>   calculating sqrt(sum((v - mean(v)).^2) / (length(v) - 1)). Note:
> Julia does not ignore NaN values in the computation. For applications
> requiring the handling of
>   missing data, the DataArray package is recommended.
>
> Having said this, documentation always needs improvements and is
> certainly not on Matlab's level of completeness.  Please contribute
> where you find it lacking.  See
>
> https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md#improving-documentation
>
>
> On Fri, 2016-02-12 at 09:18, NotSoRecentConvert  wrote:
> > You can even download the entire thing as a PDF, HTML, or EPUB if you
> want
> > to highlight, annotate, or bookmark your most searched functions. Look in
> > the lower right of the page for "v: latest" and click it for more
> options.
> >
> > On Friday, February 12, 2016 at 8:03:27 AM UTC+1, Lutfullah Tomak wrote:
> >>
> >> There is this one
> >>
> >> http://docs.julialang.org/en/release-0.4/stdlib/math/#Base.std
> >>
> >> Instead of google, I use this manual for search.
> >>
> >>
>


Re: [julia-users] Re: Googling the functions I need in Julia is hard

2016-02-12 Thread Michele Zaffalon
On mine, it points to the functions randn and randn!

On Fri, Feb 12, 2016 at 11:48 AM, Lutfullah Tomak 
wrote:

> For reference, it shows up in my search.
>
>
> http://docs.julialang.org/en/release-0.4/search/?q=standard+deviation_keywords=yes=default
>
> About google side, I think that MATLAB and R are used for years and thus
> results are indexed better for them.


Re: [julia-users] Re: ANN: Julia v0.4.3 released

2016-01-19 Thread Michele Zaffalon
Under Debian (at least), the generic Linux binaries work fine.

On Tue, Jan 19, 2016 at 1:06 PM, Kacper Kornet  wrote:

>
>
> On Thursday, January 14, 2016 at 6:27:48 PM UTC, Tony Kelman wrote:
>>
>> Hello all! The latest bugfix release of the Julia 0.4.x line has been
>> released. Binaries are available from the usual place
>> , and as is typical with such things,
>> please report all issues to either the issue tracker
>> , or email the julia-users
>> list. (If you reply to this message on julia-users, please do not cc
>> julia-news which is intended to be low-volume.)
>>
>
> The webpage with packages for Ubuntu/Debian still have 0.4.2. as the
> latest version. Are you planning to release debs for 0.4.3 any time soon?
>
> Best wishes,
> Kacper
>


Re: [julia-users] Nicer syntax collect(linspace(0,1,n))?

2015-11-22 Thread Michele Zaffalon
Thank you, I should have checked the issues list first.

On Fri, Nov 20, 2015 at 4:13 PM, Milan Bouchet-Valat <nalimi...@club.fr>
wrote:

> Le vendredi 20 novembre 2015 à 04:54 -0800, Michele Zaffalon a écrit :
> > Should `linspace` act as an array for `repeat`?
> Yes, the signature of repeat() is clearly too strict. This has been
> discussed at
> https://github.com/JuliaLang/julia/issues/12953
>
> There was a clear support for this, but a decision would have to be
> taken regarding whether to use positional arguments instead of keyword
> arguments.
>
>
> Regards
>
> > On Wednesday, October 21, 2015 at 10:00:46 PM UTC+2, Art Kuo wrote:
> > > I don't think there is much to argue about, except perhaps names.
> > > `linspace` returns a range, but is otherwise a drop-in replacement
> > > for an array, and should act as one for any naive user, other than
> > > sometimes being faster and taking less memory. This is not hidden
> > > from the user, yet they need not be concerned about it. It just
> > > works. (The array might be better in some cases, I suspect rarely.)
> > > One might expect a `linspace` to show an array when typed into the
> > > REPL. With #13615, post-0.4 the user will see that it is a range
> > > and also "what they expect."
> > > It is true that `logspace` is an array and `linspace` is a range,
> > > and this is ugly. Perhaps there should be a `logrange` to go with
> > > `linrange`, or `logspace` should be modified to be a range. I do
> > > agree with these complaints.
> > > The name `logspace` probably comes from Matlab, but otherwise has
> > > no significance and is not a great name. Perhaps it's worth keeping
> > > around for that reason; perhaps it should be stashed into a Matlab
> > > module.
> > > As much as I was attracted here by the Matlab-alikeness, that can
> > > be a detriment. For example, Matlab overloads `diag` so you get two
> > > very different things for two different inputs. Whereas Mathematica
> > > has long, clear names, and `DiagonalMatrix` and `Diagonal` give a
> > > better clue what will happen. And as much as I love `eye`,
> > > `IdentityMatrix` is clearer. Other Matlab-isms:  `tril`, `pcg`,
> > > `alim`, `shg`.
> > >
> > >
> > > On Wednesday, October 21, 2015 at 3:16:58 PM UTC-4, Stefan
> > > Karpinski wrote:
> > > > This thread is tragically long on opinions and short on arguments
> > > > backing them up. It occurs to me that we can write specialized
> > > > methods for collect(::LinSpace) that generate the collected
> > > > version more efficiently than generic iteration does, which
> > > > eliminates one of the potential arguments for just generating an
> > > > array.
> > > >
> > > > On Wednesday, October 21, 2015, Gabriel Gellner <
> > > > gabriel...@gmail.com> wrote:
> > > > > I agree with this downvote so much it hurts. The
> > > > > logspace/linspace is painfully ugly. linrange is the right name
> > > > > in my find for the iterator version.
> > > > >
> > > > > On Wednesday, 30 September 2015 10:31:55 UTC-7, Alex Ames
> > > > > wrote:
> > > > > > Another downvote on linspace returning a range object. It
> > > > > > seems odd for linspace and logspace to return different
> > > > > > types, and linrange provides the low-memory option where
> > > > > > needed. Numpy's `linspace` also returns an array object.
> > > > > >  I ran into errors when trying to plot a function over a
> > > > > > linspace of x values, since plotting libs currently expect
> > > > > > vectors as arguments, not range objects. Easily fixed if you
> > > > > > know Julia well, but Matlab/Python converts may be stymied.
> > > > > >
> > > > > > On Wednesday, September 30, 2015 at 12:19:22 PM UTC-5, J Luis
> > > > > > wrote:
> > > > > > > I want to add my voice to the dislikers. Those are the type
> > > > > > > of surprises that are not welcome mainly for matlab users.
> > > > > > >
> > > > > > > quarta-feira, 30 de Setembro de 2015 às 16:53:57 UTC+1,
> > > > > > > Christoph Ortner escreveu:
> > > > > > > > I also strongly dislike the `linspace` change; I like the
> > > > > > > > idea though of having `linspace` and `linra

Re: [julia-users] Nicer syntax collect(linspace(0,1,n))?

2015-11-20 Thread Michele Zaffalon
Should `linspace` act as an array for `repeat`?

On Wednesday, October 21, 2015 at 10:00:46 PM UTC+2, Art Kuo wrote:
>
> I don't think there is much to argue about, except perhaps names. 
>
>1. `linspace` returns a range, but is otherwise a drop-in replacement 
>for an array, and should act as one for any naive user, other than 
>sometimes being faster and taking less memory. This is not hidden from the 
>user, yet they need not be concerned about it. It just works. (The array 
>might be better in some cases, I suspect rarely.)
>2. One might expect a `linspace` to show an array when typed into the 
>REPL. With #13615 
>
> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2FJuliaLang%2Fjulia%2Fpull%2F13615=D=1=AFQjCNESdEGtUlN_sTr8NTxWkldQaBZhYg>,
>  post-0.4 
>the user will see that it is a range and also "what they expect."
>3. It is true that `logspace` is an array and `linspace` is a range, 
>and this is ugly. Perhaps there should be a `logrange` to go with 
>`linrange`, or `logspace` should be modified to be a range. I do agree 
> with 
>these complaints.
>4. The name `logspace` probably comes from Matlab, but otherwise has 
>no significance and is not a great name. Perhaps it's worth keeping around 
>for that reason; perhaps it should be stashed into a Matlab module.
>5. As much as I was attracted here by the Matlab-alikeness, that can 
>be a detriment. For example, Matlab overloads `diag` so you get two very 
>different things for two different inputs. Whereas Mathematica has long, 
>clear names, and `DiagonalMatrix` and `Diagonal` give a better clue what 
>will happen. And as much as I love `eye`, `IdentityMatrix` is clearer. 
>Other Matlab-isms:  `tril`, `pcg`, `alim`, `shg`.
>
>
>
> On Wednesday, October 21, 2015 at 3:16:58 PM UTC-4, Stefan Karpinski wrote:
>>
>> This thread is tragically long on opinions and short on arguments backing 
>> them up. It occurs to me that we can write specialized methods for 
>> collect(::LinSpace) that generate the collected version more efficiently 
>> than generic iteration does, which eliminates one of the potential 
>> arguments for just generating an array.
>>
>> On Wednesday, October 21, 2015, Gabriel Gellner <gabriel...@gmail.com> 
>> wrote:
>>
>>> I agree with this downvote so much it hurts. The logspace/linspace is 
>>> painfully ugly. linrange is the right name in my find for the iterator 
>>> version.
>>>
>>> On Wednesday, 30 September 2015 10:31:55 UTC-7, Alex Ames wrote:
>>>>
>>>> Another downvote on linspace returning a range object. It seems odd for 
>>>> linspace and logspace to return different types, and linrange provides the 
>>>> low-memory option where needed. Numpy's `linspace` also returns an array 
>>>> object.
>>>>  I ran into errors when trying to plot a function over a linspace of x 
>>>> values, since plotting libs currently expect vectors as arguments, not 
>>>> range objects. Easily fixed if you know Julia well, but Matlab/Python 
>>>> converts may be stymied.
>>>>
>>>> On Wednesday, September 30, 2015 at 12:19:22 PM UTC-5, J Luis wrote:
>>>>>
>>>>> I want to add my voice to the dislikers. Those are the type of 
>>>>> surprises that are not welcome mainly for matlab users. 
>>>>>
>>>>> quarta-feira, 30 de Setembro de 2015 às 16:53:57 UTC+1, Christoph 
>>>>> Ortner escreveu:
>>>>>>
>>>>>> I also strongly dislike the `linspace` change; I like the idea though 
>>>>>> of having `linspace` and `linrange`, where the former should give the 
>>>>>> array.
>>>>>> Christoph
>>>>>>
>>>>>>
>>>>>> On Wednesday, 30 September 2015 10:21:36 UTC+1, Michele Zaffalon 
>>>>>> wrote:
>>>>>>>
>>>>>>> I just realize that the thread is about 0.3.11 and I am showing 
>>>>>>> output for 0.4.0-rc2. Sorry for the noise.
>>>>>>>
>>>>>>> On Wed, Sep 30, 2015 at 11:17 AM, Michele Zaffalon <
>>>>>>> michele@gmail.com> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>> On Wed, Sep 30, 2015 at 9:50 AM, Milan Bouchet-Valat <
>>>>>>>> nali...@club.fr> wrote:
>>>>>>>>
>>>>>>>>> Le mercredi 30 septembre 2015 à 08:55 +0200, 

[julia-users] rand under Windows returns almost always 1

2015-11-18 Thread Michele Zaffalon
Hi all,

I would be glad if somebody could explain to me why the following function 
which generates a pair of random integer between 1 and 6 and if they are 
equal generates another pair

function fun()
d, N = 6, 50
for n = 1:N
a, b = rand(1:d), rand(1:d)
if a == b
c, d = rand(1:d), rand(1:d)
println("$a, $b, $c, $d")
end
end
end


under Windows 7 64 bits and Julia 0.4.1 returns mostly 1s.

julia> fun()
1, 1, 3, 3
3, 3, 3, 2
2, 2, 2, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1

For small N, the output is more random though.

Thank you,
michele


Re: [julia-users] rand under Windows returns almost always 1

2015-11-18 Thread Michele Zaffalon
On Wed, Nov 18, 2015 at 5:43 PM, Yichao Yu <yyc1...@gmail.com> wrote:

> On Wed, Nov 18, 2015 at 11:37 AM, Michele Zaffalon
> <michele.zaffa...@gmail.com> wrote:
> > Hi all,
> >
> > I would be glad if somebody could explain to me why the following
> function
> > which generates a pair of random integer between 1 and 6 and if they are
> > equal generates another pair
> >
> > function fun()
> > d, N = 6, 50
> > for n = 1:N
> > a, b = rand(1:d), rand(1:d)
> > if a == b
> > c, d = rand(1:d), rand(1:d)
>
> You realize you are overriding d to a smaller and smaller number until
> you end up always calling rand(1:1) right?
>

This is very very embarrassing.


> > println("$a, $b, $c, $d")
> > end
> > end
> > end
> >
> >
> > under Windows 7 64 bits and Julia 0.4.1 returns mostly 1s.
> >
> > julia> fun()
> > 1, 1, 3, 3
> > 3, 3, 3, 2
> > 2, 2, 2, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> > 1, 1, 1, 1
> >
> > For small N, the output is more random though.
> >
> > Thank you,
> > michele
>


Re: [julia-users] rand under Windows returns almost always 1

2015-11-18 Thread Michele Zaffalon
On Wed, Nov 18, 2015 at 8:33 PM, Yichao Yu  wrote:

> On Wed, Nov 18, 2015 at 2:28 PM, Stefan Karpinski 
> wrote:
> > Sometimes you've looked at your own code too long to see these things.
> > Someone else sees it right away.
>
> Disclaimer, I didn't see it right away either before running your code.
>

Thank you for trying to make me feel better...


[julia-users] find element in sorted list

2015-11-07 Thread Michele Zaffalon
What is the best way of telling whether an element `x` is present in a 
sorted list `a`?

Using `searchsortedlist`, I also need to check that the element is present 
in the list. This is what I do

function isinsortedlist(a, x)
n = searchsortedfirst(a, x)
n <= length(a) && a[n] == x
end

Shouldn't `searchsortedlist` return also a bool to tell whether the element 
is already in the list?

Thank you,
michele


Re: [julia-users] find element in sorted list

2015-11-07 Thread Michele Zaffalon
On Sat, Nov 7, 2015 at 4:34 PM, Milan Bouchet-Valat <nalimi...@club.fr>
wrote:

> Le samedi 07 novembre 2015 à 06:37 -0800, Michele Zaffalon a écrit :
> > What is the best way of telling whether an element `x` is present in
> > a sorted list `a`?
> >
> > Using `searchsortedlist`, I also need to check that the element is
> > present in the list. This is what I do
> >
> > function isinsortedlist(a, x)
> > n = searchsortedfirst(a, x)
> > n <= length(a) && a[n] == x
> > end
> >
> > Shouldn't `searchsortedlist` return also a bool to tell whether the
> > element is already in the list?
> Just use searchsorted(), which (as the docs say) "Returns an empty
> range located at the insertion point if a does not contain values equal
> to x".
>
Now that you mention it, it is obvious. Thank you.

>
>
> Regards
>
> > Thank you,
> > michele
>


Re: [julia-users] Re: How to fill a (general) subarray with a single object

2015-11-04 Thread Michele Zaffalon
What Matt is saying is that the first option is probably what you do _not_
want: all elements of the matrix z point to the same location in memory.
Just try to change one of them!

On Tue, Nov 3, 2015 at 4:10 PM, Ján Dolinský 
wrote:

> Hi Matt,
>
> Thanks for the tips. The 1st example is quite neat and compact (similar to
> sub & fill!). the for loop is obviously a good option too.
>
> Best Regards,
> Jan
>
> Dňa utorok, 3. novembra 2015 15:59:37 UTC+1 Matt Bauman napísal(-a):
>
>> The ability to assign a single element into multiple locations like this
>> is called scalar broadcasting.  When you have an array of arrays, however,
>> each element isn't a scalar.  So it's trying to assign the elements of the
>> right side (Float64s) to the elements of the right side (matrices).  You
>> can work around this several ways:
>>
>> Wrap the right had side in an array of the appropriate size.  Note that,
>> like using sub and fill! above, this puts exactly the same matrix (with
>> shared data) in all four locations:
>>
>> julia> z[2:5] = fill(rand(2,2), 4); z
>> 10-element Array{Array{Float64,2},1}:
>>  #undef
>> [0.144618,0.285725,0.415011,0.232808]
>> [0.144618,0.285725,0.415011,0.232808]
>> [0.144618,0.285725,0.415011,0.232808]
>> [0.144618,0.285725,0.415011,0.232808]
>>  #undef
>>  #undef
>>  #undef
>>  #undef
>>  #undef
>>
>> Alternatively, the best solution is probably to use a for loop.  This
>> probably has the semantics that you want, with different uncoupled arrays
>> in each spot, and it'll be fast, too:
>>
>> julia> for idx = 2:5
>>z[idx] = rand(2,2)
>>end
>>z
>> 10-element Array{Array{Float64,2},1}:
>>  #undef
>> [0.691373,0.130612,0.837506,0.255362]
>> [0.471128,0.492608,0.602753,0.119473]
>> [0.133986,0.793537,0.800129,0.433915]
>> [0.922652,0.645796,0.997629,0.982244]
>>  #undef
>>  #undef
>>  #undef
>>  #undef
>>  #undef
>>
>> Matt
>>
>> On Tuesday, November 3, 2015 at 9:26:49 AM UTC-5, Ján Dolinský wrote:
>>>
>>> Hi guys,
>>>
>>> I came across a problem of setting up a (general) subarray with an
>>> object (value which is not an ordinary number) e.g.
>>>
>>> julia> z = Array(Matrix{Float64}, 10)
>>> 10-element Array{Array{Float64,2},1}:
>>>  #undef
>>>  #undef
>>>  #undef
>>>  #undef
>>>  #undef
>>>  #undef
>>>  #undef
>>>  #undef
>>>  #undef
>>>  #undef
>>>
>>> julia> z[2:5] = rand(2,2)
>>> ERROR: MethodError: `convert` has no method matching convert(::Type{
>>> Array{Float64,2}}, ::Float64)
>>> This may have arisen from a call to the constructor Array{Float64,2
>>> }(...),
>>> since type constructors fall back to convert methods.
>>> Closest candidates are:
>>>   call{T}(::Type{T}, ::Any)
>>>   convert{T,S,N}(::Type{Array{T,N}}, ::SubArray{S,N,P<:AbstractArray{T,N
>>> },I<:Tuple{Vararg{Union{AbstractArray{T,1},Colon,Int64}}},LD})
>>>   convert{T,n}(::Type{Array{T,n}}, ::Array{T,n})
>>>   ...
>>>  in setindex! at array.jl:339
>>>
>>>  What is a "correct" way of doing this ? I can do it via "sub" and
>>> "fill!" e.g.
>>>
>>> julia> zz = sub(z, 2:5)
>>> 4-element SubArray{Array{Float64,2},1,Array{Array{Float64,2},1},Tuple{
>>> UnitRange{Int64}},1}:
>>>  #undef
>>>  #undef
>>>  #undef
>>>  #undef
>>>
>>> julia> fill!(zz, rand(2,2))
>>> 4-element SubArray{Array{Float64,2},1,Array{Array{Float64,2},1},Tuple{
>>> UnitRange{Int64}},1}:
>>>  2x2 Array{Float64,2}:
>>>  0.313155  0.553893
>>>  0.74854   0.997401
>>>  2x2 Array{Float64,2}:
>>>  0.313155  0.553893
>>>  0.74854   0.997401
>>>  2x2 Array{Float64,2}:
>>>  0.313155  0.553893
>>>  0.74854   0.997401
>>>  2x2 Array{Float64,2}:
>>>  0.313155  0.553893
>>>  0.74854   0.997401
>>>
>>> julia> z
>>> 10-element Array{Array{Float64,2},1}:
>>>  #undef
>>> 2x2 Array{Float64,2}:
>>>  0.313155  0.553893
>>>  0.74854   0.997401
>>> 2x2 Array{Float64,2}:
>>>  0.313155  0.553893
>>>  0.74854   0.997401
>>> 2x2 Array{Float64,2}:
>>>  0.313155  0.553893
>>>  0.74854   0.997401
>>> 2x2 Array{Float64,2}:
>>>  0.313155  0.553893
>>>  0.74854   0.997401
>>>  #undef
>>>  #undef
>>>  #undef
>>>  #undef
>>>  #undef
>>>
>>> Thanks,
>>> Jan
>>>
>>


Re: [julia-users] How to get first number from Int64

2015-10-24 Thread Michele Zaffalon
There is also the builtin
http://docs.julialang.org/en/latest/stdlib/numbers/#Base.digits

On Sat, Oct 24, 2015 at 3:51 PM, Tamas Papp  wrote:

> A trivial (but not necessarily the fastest) solution is
>
> function firstdigit(i,base=10)
> while (i >= base)
> i = div(i,base)
> end
> i
> end
>
> Best,
>
> Tamas
>
> On Sat, Oct 24 2015, paul analyst  wrote:
>
> > How to get first number from Int64
> >
> > julia> lista[3]
> > 464
> >
> > julia> eltype(lista[3])
> > Int64
> >
> > julia> length(lista[3])
> > 1
> >
> > julia> lista[3][]
> > 464
> >
> > julia> lista[3][1]
> >
> > I need the first "4"
> > Paul
>
>


Re: [julia-users] Nicer syntax collect(linspace(0,1,n))?

2015-09-30 Thread Michele Zaffalon
Just curious: linspace returns a Range object, but logspace returns a
vector because there is no much use case for a LogRange object?

@feza: I have also seen the deprecation warning going away after a couple
of calls, but I am not sure why. If you restart Julia, the deprecations
reappear.

On Wed, Sep 30, 2015 at 5:40 AM, feza  wrote:

> Strange it *was* giving me an error saying deprecated and that I should
> use collect, but now it's fine.
>
>
> On Tuesday, September 29, 2015 at 10:28:12 PM UTC-4, Sheehan Olver wrote:
>>
>> fez, I'm pretty sure the code works fine without the collect: when exp is
>> called on linspace it converts it to a vector.  Though the returned t will
>> be linspace object.
>>
>> On Wednesday, September 30, 2015 at 12:10:55 PM UTC+10, feza wrote:
>>>
>>> Here's the code I was using where I needed to use collect (I've been
>>> playing around with Julia, so any suggestions on this code for perf is
>>> welcome ;) ) . In general linspace (or the : notation)  is also used
>>> commonly to lay  a grid in space for solving a PDE for some other use
>>> cases.
>>>
>>> function gp(n)
>>> n = convert(Int,n)
>>> t0 = 0
>>> tf = 5
>>> t = collect( linspace(t0, tf, n+1) )
>>> sigma = exp( -(t - t[1]) )
>>>
>>> c = [sigma; sigma[(end-1):-1:2]]
>>> lambda = fft(c)
>>> eta = sqrt(lambda./(2*n))
>>>
>>> Z = randn(2*n) + im*randn(2*n)
>>> x = real( fft( Z.*eta ) )
>>> return (x, t)
>>> end
>>>
>>>
>>> On Tuesday, September 29, 2015 at 8:59:52 PM UTC-4, Stefan Karpinski
>>> wrote:

 I'm curious why you need a vector rather than an object. Do you mutate
 it after creating it? Having linspace return an object instead of a
 vector was a bit of a unclear judgement call so getting feedback would
 be good.

 On Tuesday, September 29, 2015, Patrick Kofod Mogensen <
 patrick@gmail.com> wrote:

> No:
>
> julia> logspace(0,3,5)
> 5-element Array{Float64,1}:
> 1.0
> 5.62341
>31.6228
>   177.828
>  1000.0
>
> On Tuesday, September 29, 2015 at 8:50:47 PM UTC-4, Luke Stagner wrote:
>>
>> Thats interesting. Does logspace also return a range?
>>
>> On Tuesday, September 29, 2015 at 5:43:28 PM UTC-7, Chris wrote:
>>>
>>> In 0.4 the linspace function returns a range object, and you need to
>>> use collect() to expand it. I'm also interested in nicer syntax.
>>
>>


Re: [julia-users] Nicer syntax collect(linspace(0,1,n))?

2015-09-30 Thread Michele Zaffalon
On Wed, Sep 30, 2015 at 9:50 AM, Milan Bouchet-Valat <nalimi...@club.fr>
wrote:

> Le mercredi 30 septembre 2015 à 08:55 +0200, Michele Zaffalon a écrit :
> > Just curious: linspace returns a Range object, but logspace returns a
> > vector because there is no much use case for a LogRange object?
> >
> > @feza: I have also seen the deprecation warning going away after a
> > couple of calls, but I am not sure why. If you restart Julia, the
> > deprecations reappear.
> Deprecation warnings are only printed once for each call place. The
> idea is that once you're aware of it, there's no point in nagging you.
>
> Anyway, that warning is most probably not related to linspace at all,
> but rather to the array concatenation syntax resulting in an effect
> equivalent to collect(). If you show us a piece of code that prints the
> warning, we can give you more details.
>
>
> Regards
>

Sorry, you are right, I was referring to the concatenation.
It prints it exaclty twice if I type it in the REPL, it always prints it if
I define it within a function e.g. a() = [1:3].

C:\Users\michele.zaffalon>julia
   _
   _   _ _(_)_ |  A fresh approach to technical computing
  (_) | (_) (_)|  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.0-rc2 (2015-09-18 17:51 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/   |  x86_64-w64-mingw32

julia> [1:3]
WARNING: [a] concatenation is deprecated; use collect(a) instead
 in depwarn at deprecated.jl:73
 in oldstyle_vcat_warning at abstractarray.jl:29
 in vect at abstractarray.jl:32
while loading no file, in expression starting on line 0
3-element Array{Int64,1}:
 1
 2
 3

julia> [1:3]
WARNING: [a] concatenation is deprecated; use collect(a) instead
 in depwarn at deprecated.jl:73
 in oldstyle_vcat_warning at abstractarray.jl:29
 in vect at abstractarray.jl:32
while loading no file, in expression starting on line 0
3-element Array{Int64,1}:
 1
 2
 3

julia> [1:3]
3-element Array{Int64,1}:
 1
 2
 3

julia> a() = [1:3]
a (generic function with 1 method)

julia> a()
WARNING: [a] concatenation is deprecated; use collect(a) instead
 in depwarn at deprecated.jl:73
 in oldstyle_vcat_warning at abstractarray.jl:29
 in a at none:1
while loading no file, in expression starting on line 0
3-element Array{Int64,1}:
 1
 2
 3

julia> a()
WARNING: [a] concatenation is deprecated; use collect(a) instead
 in depwarn at deprecated.jl:73
 in oldstyle_vcat_warning at abstractarray.jl:29
 in a at none:1
while loading no file, in expression starting on line 0
3-element Array{Int64,1}:
 1
 2
 3

julia> a()
WARNING: [a] concatenation is deprecated; use collect(a) instead
 in depwarn at deprecated.jl:73
 in oldstyle_vcat_warning at abstractarray.jl:29
 in a at none:1
while loading no file, in expression starting on line 0
3-element Array{Int64,1}:
 1
 2
 3


>
> > On Wed, Sep 30, 2015 at 5:40 AM, feza <mohamad...@gmail.com> wrote:
> > > Strange it *was* giving me an error saying deprecated and that I
> > > should use collect, but now it's fine.
> > >
> > >
> > > On Tuesday, September 29, 2015 at 10:28:12 PM UTC-4, Sheehan Olver
> > > wrote:
> > > > fez, I'm pretty sure the code works fine without the collect:
> > > > when exp is called on linspace it converts it to a vector.
> > > > Though the returned t will be linspace object.
> > > >
> > > > On Wednesday, September 30, 2015 at 12:10:55 PM UTC+10, feza
> > > > wrote:
> > > > > Here's the code I was using where I needed to use collect (I've
> > > > > been playing around with Julia, so any suggestions on this code
> > > > > for perf is welcome ;) ) . In general linspace (or the :
> > > > > notation)  is also used commonly to lay  a grid in space for
> > > > > solving a PDE for some other use cases.
> > > > >
> > > > > function gp(n)
> > > > > n = convert(Int,n)
> > > > > t0 = 0
> > > > > tf = 5
> > > > > t = collect( linspace(t0, tf, n+1) )
> > > > > sigma = exp( -(t - t[1]) )
> > > > >
> > > > > c = [sigma; sigma[(end-1):-1:2]]
> > > > > lambda = fft(c)
> > > > > eta = sqrt(lambda./(2*n))
> > > > >
> > > > > Z = randn(2*n) + im*randn(2*n)
> > > > > x = real( fft( Z.*eta ) )
> > > > > return (x, t)
> > > > > end
> > > > >
> > &g

Re: [julia-users] Nicer syntax collect(linspace(0,1,n))?

2015-09-30 Thread Michele Zaffalon
I just realize that the thread is about 0.3.11 and I am showing output for
0.4.0-rc2. Sorry for the noise.

On Wed, Sep 30, 2015 at 11:17 AM, Michele Zaffalon <
michele.zaffa...@gmail.com> wrote:

>
> On Wed, Sep 30, 2015 at 9:50 AM, Milan Bouchet-Valat <nalimi...@club.fr>
> wrote:
>
>> Le mercredi 30 septembre 2015 à 08:55 +0200, Michele Zaffalon a écrit :
>> > Just curious: linspace returns a Range object, but logspace returns a
>> > vector because there is no much use case for a LogRange object?
>> >
>> > @feza: I have also seen the deprecation warning going away after a
>> > couple of calls, but I am not sure why. If you restart Julia, the
>> > deprecations reappear.
>> Deprecation warnings are only printed once for each call place. The
>> idea is that once you're aware of it, there's no point in nagging you.
>>
>> Anyway, that warning is most probably not related to linspace at all,
>> but rather to the array concatenation syntax resulting in an effect
>> equivalent to collect(). If you show us a piece of code that prints the
>> warning, we can give you more details.
>>
>>
>> Regards
>>
>
> Sorry, you are right, I was referring to the concatenation.
> It prints it exaclty twice if I type it in the REPL, it always prints it
> if I define it within a function e.g. a() = [1:3].
>
> C:\Users\michele.zaffalon>julia
>_
>_   _ _(_)_ |  A fresh approach to technical computing
>   (_) | (_) (_)|  Documentation: http://docs.julialang.org
>_ _   _| |_  __ _   |  Type "?help" for help.
>   | | | | | | |/ _` |  |
>   | | |_| | | | (_| |  |  Version 0.4.0-rc2 (2015-09-18 17:51 UTC)
>  _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
> |__/   |  x86_64-w64-mingw32
>
> julia> [1:3]
> WARNING: [a] concatenation is deprecated; use collect(a) instead
>  in depwarn at deprecated.jl:73
>  in oldstyle_vcat_warning at abstractarray.jl:29
>  in vect at abstractarray.jl:32
> while loading no file, in expression starting on line 0
> 3-element Array{Int64,1}:
>  1
>  2
>  3
>
> julia> [1:3]
> WARNING: [a] concatenation is deprecated; use collect(a) instead
>  in depwarn at deprecated.jl:73
>  in oldstyle_vcat_warning at abstractarray.jl:29
>  in vect at abstractarray.jl:32
> while loading no file, in expression starting on line 0
> 3-element Array{Int64,1}:
>  1
>  2
>  3
>
> julia> [1:3]
> 3-element Array{Int64,1}:
>  1
>  2
>  3
>
> julia> a() = [1:3]
> a (generic function with 1 method)
>
> julia> a()
> WARNING: [a] concatenation is deprecated; use collect(a) instead
>  in depwarn at deprecated.jl:73
>  in oldstyle_vcat_warning at abstractarray.jl:29
>  in a at none:1
> while loading no file, in expression starting on line 0
> 3-element Array{Int64,1}:
>  1
>  2
>  3
>
> julia> a()
> WARNING: [a] concatenation is deprecated; use collect(a) instead
>  in depwarn at deprecated.jl:73
>  in oldstyle_vcat_warning at abstractarray.jl:29
>  in a at none:1
> while loading no file, in expression starting on line 0
> 3-element Array{Int64,1}:
>  1
>  2
>  3
>
> julia> a()
> WARNING: [a] concatenation is deprecated; use collect(a) instead
>  in depwarn at deprecated.jl:73
>  in oldstyle_vcat_warning at abstractarray.jl:29
>  in a at none:1
> while loading no file, in expression starting on line 0
> 3-element Array{Int64,1}:
>  1
>  2
>  3
>
>
>>
>> > On Wed, Sep 30, 2015 at 5:40 AM, feza <mohamad...@gmail.com> wrote:
>> > > Strange it *was* giving me an error saying deprecated and that I
>> > > should use collect, but now it's fine.
>> > >
>> > >
>> > > On Tuesday, September 29, 2015 at 10:28:12 PM UTC-4, Sheehan Olver
>> > > wrote:
>> > > > fez, I'm pretty sure the code works fine without the collect:
>> > > > when exp is called on linspace it converts it to a vector.
>> > > > Though the returned t will be linspace object.
>> > > >
>> > > > On Wednesday, September 30, 2015 at 12:10:55 PM UTC+10, feza
>> > > > wrote:
>> > > > > Here's the code I was using where I needed to use collect (I've
>> > > > > been playing around with Julia, so any suggestions on this code
>> > > > > for perf is welcome ;) ) . In general linspace (or the :
>> > > > > notation)  is also used commonly to lay  a grid in space for
>> > > > > solving a PDE for some other use cases.
>> > > &g

Re: [julia-users] Re: What's the reason of the Success of Python?

2015-09-30 Thread Michele Zaffalon
On Wed, Sep 30, 2015 at 4:32 PM, Tamas Papp  wrote:

> On Wed, Sep 30 2015, Christian Peel  wrote:
>
> > 1) Matlab has great high-level vectorized notation.  If you're a student
> or
> > engineer, it's dramatically easier to solve a linear system in Matlab
> > (x=inv(A)*b) than it is in many other languages.  Julia has at least this
>
> You shouldn't ever do this (in either Julia or Matlab, or any language),
> it is ill-conditioned for general matrices. I think the Matlab function
> is linsolve.
>
> There is some literature supporting the opposite:
http://arxiv.org/pdf/1201.6035.pdf


Re: [julia-users] @code_warntype and for loops

2015-09-24 Thread Michele Zaffalon


On Thursday, September 24, 2015 at 9:21:47 AM UTC+2, Mauro wrote:
>
> >> This is the lowered and typed abstract syntax tree that you're seeing, 
> >> so two steps removed from what you've typed already (and another two 
> >> steps to go to get to machine code).  Thus it gets more verbose.  I 
> >> guess it would be nice to translate this typed code back to what you 
> >> wrote but with type annotations and display that.  But that is not 
> >> possible (yet?).  Have you seen this short and sweet JuliaCon 
> >> presentation by Jacob: 
> >> 
> >> 
> >> 
> https://www.youtube.com/watch?v=RYZkHudRTvI=PLP8iPy9hna6Sdx4soiGrSefrmOPdUWixM=16
>  
> >> 
> > 
> > Yes, you worded better than I could: whether it is possible to get a 
> sort 
> > of breadth first view of the code. From the nice (and too short, thanks 
> for 
> > the link) presentation, it seems that this is not possible. Is there any 
> > hope that the "yet?" will become reality? I understand thought that this 
> > may be a request from somebody unable to read quickly the output of 
> > code_typed. 
>
> If I understand correctly, this issue is requesting this feature 
> https://github.com/jakebolewski/JuliaParser.jl/issues/22 . By the sounds 
> of it, it's not going to happen tomorrow but maybe the day after. 
>

Just wow. 


Re: [julia-users] @code_warntype and for loops

2015-09-24 Thread Michele Zaffalon


On Wednesday, September 23, 2015 at 11:06:51 AM UTC+2, Mauro wrote:
>
> > Thank you, Kristoffer. I have read the manual and your post about not 
> > getting carried away by the red == bad assumption 
> > <
> https://groups.google.com/forum/#!searchin/julia-users/@code_warntype$20red$20bad/julia-users/g9O9Ik5OAJA/uSGNDyCDEuEJ>.
>  
>
> > Yet, for a for loop, one would not expect so much output. 
>
> This is the lowered and typed abstract syntax tree that you're seeing, 
> so two steps removed from what you've typed already (and another two 
> steps to go to get to machine code).  Thus it gets more verbose.  I 
> guess it would be nice to translate this typed code back to what you 
> wrote but with type annotations and display that.  But that is not 
> possible (yet?).  Have you seen this short and sweet JuliaCon 
> presentation by Jacob: 
>
>
> https://www.youtube.com/watch?v=RYZkHudRTvI=PLP8iPy9hna6Sdx4soiGrSefrmOPdUWixM=16
>  
>

Yes, you worded better than I could: whether it is possible to get a sort 
of breadth first view of the code. From the nice (and too short, thanks for 
the link) presentation, it seems that this is not possible. Is there any 
hope that the "yet?" will become reality? I understand thought that this 
may be a request from somebody unable to read quickly the output of 
code_typed.


Re: [julia-users] @code_warntype and for loops

2015-09-23 Thread Michele Zaffalon
Thank you, Kristoffer. I have read the manual and your post about not
getting carried away by the red == bad assumption
.
Yet, for a for loop, one would not expect so much output.

On Wed, Sep 23, 2015 at 10:05 AM, Kristoffer Carlsson  wrote:

> It can be a bit difficult to read the output from code_warntype. A good
> heuristic is to just look at the variables on the top and the final return
> type. If these are concrete then you are fine. If not, then you can look at
> the messy code in between to find where the instability occurs.
>
> For your examples, everything is OK.


Re: [julia-users] Deprecation of require

2015-09-17 Thread Michele Zaffalon
I answer your first question only:

>
> First, where can I find the .juliarc.jl file?
>

It's in the HOME directory. Alternatively in Windows in the directory
pointed to by HOMEDRIVE\HOMEPATH


> Second, is there an easier way to load a .jl file from my working
> directory into Julia onto a local computer or cluster of computers that
> does not require editing the .juliarc.fil file? (Editing this file for
> every project seems a little inconvenient).
>
> Third, will the code loaded from a .jl  always be precompiled in .4? If
> not, how do I choose whether it is precompiled or not?
>
> Thanks in advance (and my apologies for the basic questions;I'm not a
> programmer per se)
>
> Chris
>
> On Friday, July 31, 2015 at 7:30:44 AM UTC-4, Tim Holy wrote:
>>
>> If MyModule.jl is on your LOAD_PATH,
>>
>> @everywhere import MyModule
>>
>> should work. You can add
>>
>> push!(LOAD_PATH,"/my/code/repository")
>>
>> to your .juliarc.jl file.
>>
>> This has been deprecated because of precompilation; it was felt that the
>> string version left it too ambiguous about whether you wanted to load the
>> raw
>> file or the cached version.
>>
>> Best,
>> --Tim
>>
>> On Thursday, July 23, 2015 11:58:58 AM Eduardo Lenz wrote:
>> > Hi
>> > I just downloaded the last nightly build  and I am receiving a new
>> > deprecation message:
>> >
>> > Warning, "require" is deprecated, use "using" or "import" instead.
>> >
>> > My question is: I am using "require" due to the need to automatically
>> > import these functions for all workers in a cluster. As long as I know,
>> to
>> > accomplish this task I have to use "require" and also provide the
>> correct
>> > path of the corresponding .jl files. How can I do this same thing using
>> > "using" or "import" ? I tried to use it as I was using "require" and it
>> is
>> > not working as expected.
>> >
>> > Thanks for your help and sorry for the dumb question.
>>
>>


Re: [julia-users] ANN: graphics video tutorials

2015-09-16 Thread Michele Zaffalon
Nice tutorial and very useful. Could you please also post the file
julia_gui.jl mentioned at the end of your video?
michele

On Fri, Sep 11, 2015 at 8:08 PM, Tom Breloff  wrote:

> Thanks Tim... this was a very easy to follow video.
>
> On Fri, Sep 11, 2015 at 1:39 PM, Tim Holy  wrote:
>
>> In anticipation of the 0.4 release, I'm intending to post a few videos
>> demonstrating some new graphics capabilities I'll be releasing in the
>> next few
>> days. I've just posted the first installment:
>> https://youtu.be/WmMzqKMZdsI.
>>
>> This is an 11-minute video. This first video introduces the GtkUtilities
>> package and---in contrast with most of the rest of the tutorials I'm
>> hoping to
>> make---focuses on a relatively low-level detail: how to add panning and
>> zooming to a canvas. This is something that's important for other things,
>> so I
>> thought I'd start there. The panning and zooming code was basically
>> lifted out
>> of ImageView and made suitable for general consumption. As a direct
>> benefit to
>> users, I just released a new version of ProfileView based on
>> Gtk/GtkUtilities
>> that supports panning. It also starts up much faster, thanks to package
>> precompilation!
>>
>> Best,
>> --Tim
>>
>>
>


Re: [julia-users] Re: abs() returning negative numbers??

2015-09-07 Thread Michele Zaffalon
Thank you.

On Mon, Sep 7, 2015 at 1:48 PM, Yichao Yu <yyc1...@gmail.com> wrote:

> On Mon, Sep 7, 2015 at 12:05 AM, Michele Zaffalon
> <michele.zaffa...@gmail.com> wrote:
> > Why does
> > input_len::Uint = sizeof(bytes_input)
> > work in the body of the function but not at the REPL?
>
> We don't have typed global yet.
>
> https://github.com/JuliaLang/julia/issues/8870
>
> >
> > Inside the function, it is converted to
> > _var0 = sizeof(bytes_input::Array{Uint8,1})::Int64
> > input_len = (top(box))(Uint64,_var0::Int64)::Uint64 # line 3:
> >
> >
> > On Sunday, September 6, 2015 at 4:31:35 AM UTC+2, Corey Moncure wrote:
> >>
> >> Can someone help me understand what's going on here?
> >> Maybe I've been sitting at my desk too long?
> >>
> >> julia> arr = hex2bytes("14fb9c03")
> >> 4-element Array{Uint8,1}:
> >>  0x14
> >>  0xfb
> >>  0x9c
> >>  0x03
> >>
> >> julia> f(x) = abs((x % 3) - 3)
> >> f (generic function with 1 method)
> >>
> >> julia> function test_abs(bytes_input::Array{Uint8})
> >>input_len::Uint = sizeof(bytes_input)
> >>a::Int = f(input_len)
> >>println("a: ", a, " input len: ", input_len)
> >>end
> >> test_abs (generic function with 1 method)
> >>
> >> julia> test_abs(arr)
> >> a: -2 input len: 4  <-- minus 2
> >>
> >> julia> sizeof(arr)
> >> 4
> >>
> >> julia> f(4)
> >> 2   <-- expected
> >>
> >>
> >>
> >>
> >
>


[julia-users] Re: abs() returning negative numbers??

2015-09-06 Thread Michele Zaffalon
Why does 
input_len::Uint = sizeof(bytes_input)
work in the body of the function but not at the REPL?

Inside the function, it is converted to
_var0 = sizeof(bytes_input::Array{Uint8,1})::Int64
input_len = (top(box))(Uint64,_var0::Int64)::Uint64 # line 3:


On Sunday, September 6, 2015 at 4:31:35 AM UTC+2, Corey Moncure wrote:
>
> Can someone help me understand what's going on here?
> Maybe I've been sitting at my desk too long?
>
> julia> arr = hex2bytes("14fb9c03")
> 4-element Array{Uint8,1}:
>  0x14
>  0xfb
>  0x9c
>  0x03
>
> julia> f(x) = abs((x % 3) - 3)
> f (generic function with 1 method)
>
> julia> function test_abs(bytes_input::Array{Uint8})
>input_len::Uint = sizeof(bytes_input)
>a::Int = f(input_len)
>println("a: ", a, " input len: ", input_len)
>end
> test_abs (generic function with 1 method)
>
> julia> test_abs(arr)
> a: -2 input len: 4  <-- minus 2
>
> julia> sizeof(arr)
> 4
>
> julia> f(4)
> 2   <-- expected
>
>
>
>
>

  1   2   >