[julia-users] Re: Simple PyPlot Animation fails in IJulia

2014-12-19 Thread Christoph Ortner
I don't really understand the inner workings, but here is a piece of code 
that works fine for me both in REPL and IJulia.


using PyPlot# plot in an external window since it doesn't work yet in 
IJuliapygui(true)# tell PyPlot that the plot is interactivePyPlot.ion()# . . . 
and that previous plots are overwrittenPyPlot.hold(false)# start time-stepping 
loopfor n = 1:nsteps
# plot something

# . . .

# Then force the drawPyPlot.draw()end



You can also embed the figure into IJulia, but it is more tedious. A couple of 
people on this list helped me getting these things to run. I have an example 
implemented in

  
http://nbviewer.ipython.org/url/homepages.warwick.ac.uk/staff/C.Ortner/julia/LennardJones.ipynb


I hope this helps.

Christoph



[julia-users] Re: Can't Define New Functors Using Numeric Extensions 0.6.2 in Julia 0.3.3

2014-12-19 Thread Sam L
Hi Michael, 

I tried your code and got a different error:

julia> map(SqrDiff(),x,y)
ERROR: `result_type` has no method matching result_type(::SqrDiff, 
::Type{Float64}, ::Type{Float64})
 in map at /Users/sam/.julia/v0.3/NumericExtensions/src/map.jl:28


Defining a method of result_type worked though:

julia> NumericExtensions.result_type{T1,T2}(::SqrDiff,::Type{T1}, 
::Type{T2}) = typeof(NumericExtensions.evaluate(SqrDiff(), one(T1), 
one(T2)))
result_type (generic function with 100 methods)

julia> map(SqrDiff(),x,y)
4-element Array{Float64,1}:
 9.0
 9.0
 9.0
 9.0

If I recall correctly, there were some changes to NumericExtensions that 
were not reflected in the docs. Not sure where your error is coming from.

Sam


On Friday, December 19, 2014 5:04:21 PM UTC-8, Michael Wojnowicz wrote:
>
>
> OK, thanks. 
>
> On Friday, December 19, 2014 4:27:31 PM UTC-8, Dahua Lin wrote:
>>
>> NumericExtensions.jl was a stopgap. 
>>
>> Now that we have callable syntax and much more optimized map function in 
>> Julia Base (v0.4), using that package is no longer recommended.
>>
>> Dahua
>>
>>
>> On Saturday, December 20, 2014 7:07:10 AM UTC+8, Michael Wojnowicz wrote:
>>>
>>> Hi Ivar,
>>>
>>> Thanks for your thoughts and ideas.Unfortunately, none of those 
>>> leads seem to be the the root of the problem: 
>>>
>>> * I just reloaded a second session -- and also tried a different name, 
>>> "SqrDiff2()", but got the same error message when trying to apply map.
>>>
>>> * I was pasting everything into REPL, but tried running from script, and 
>>> got the same error message.
>>>
>>> -Mike
>>>  
>>>
>>

[julia-users] Simple PyPlot Animation fails in IJulia

2014-12-19 Thread Thomas Moore
I want to run a very simple animation using PyPlot: I use a for loop to 
cycle through many different pieces of data, and in each iteration I clear 
a plot, plot a new figure, and pause for, say, 0.01 seconds. For instance, 
here's a very simple example, where I attempt to animate a sine wave with 
increasing amplitude:


using PyPlot

#Generate Data
T = zeros(100,100)
x = linspace(0,2*pi,100)

for i = 1:100
T[:,i] = i/100*sin(x)
end

#Plot Data
for i = 1:100
cla()
axis([0,2pi,-1,1])
plot(x,T[:,i])
pause(0.01)
end


This works reasonably well if I copy and paste it straight into the REPL 
(though there is some lag) , but if I run it using IJulia I get some 
problems. If I have set

pygui(false)

then no animation is shown, and I only see the final figure after a few 
seconds (presumably after the loop has finished), and if I have set:

pygui(true)

then it plots the first image, but then gives the following error:


PyError (:PyObject_Call) 
RuntimeError('Julia exception: ErrorException("function display_figs does not 
accept keyword arguments")',)
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 188, in pause
show(block=False)

while loading In[45], in expression starting on line 9

 in pyerr_check at /home/thomas/.julia/v0.3/PyCall/src/exception.jl:58
 in pycall at /home/thomas/.julia/v0.3/PyCall/src/PyCall.jl:91
 in pause at /home/thomas/.julia/v0.3/PyPlot/src/PyPlot.jl:370
 in anonymous at no file:13


Does anyone have any idea what's happening, and in particular why there'd be a 
difference between the REPL and IJulia? 


Thanks



[julia-users] Integer to Julia Date Value

2014-12-19 Thread Min-Woong Sohn


Date("1960/1/1","/m/d") returns 1960-01-01, whose integer value is 
715510. I want to convert this integer back to Date type. How do I do that? 

Also I noticed that Date(1) returns 0001-01-01 and Date(2) returns 
0002-01-01 and Date(715510) returns 715510-01-01. Isn't this more natural 
that Date(2) returns 0001-01-02 and Date(715510) returns 1960-01-01? Just 
my opinion.


Re: [julia-users] Recompiling ast and document about "uncompressed ast"

2014-12-19 Thread Jameson Nash
It's less meaningful to copy a closure because it's unclear what
environment those closure variables were intended to come from. You could
potentially arrange for the .env field to be copied, however. It's
reasonable to copy a lambda (anonymous function), as you are proposing here.

If you're interested in more of the low level pieces of putting a function
together, I recommend browsing the base/serialize.jl source code and
observe how it passes the Function and LambdaStaticData objects across the
wire and reconstructs them on the other end. That should give you an idea
of how some of the lower level pieces fit together and how they can be
pulled apart and recreated elsewhere.

On Fri Dec 19 2014 at 11:04:35 AM Yichao Yu  wrote:

> On 2014年12月19日 星期五 15:03:51, Jameson Nash  us...@googlegroups.com>> wrote:
> > by that same token, the AST itself is not a stable API. what's much more
> > likely to change however is the ordering and contents of the fields of
> > these, and any type, within Base.
>
> Speaking of API stability, is there any official compatibility grantee?
> I've
> seen a thread on the -dev list about it but didn't find any official
> statement.
>
> In general, I'm aware that these API might change in a new version and I'm
> fine with it as long as it is still possible to do what I need. I'll also
> likely to use LLVM on the remote machine to execute the program and I guess
> that has a much higher API breakage rate than julia.
>
> >
> > .args[2] needs to be regenerated with any changes you've made anyways, so
> > it's easiest to just ignore it. you could manually track all of your
> > updates in there, and put together a new function object manually, but
> it's
>
> Is it possible to do that? Given that evaluating the AST directly does not
> return the function definition itself. (e.g. is it possible to copy the
> closure variables as well by just manipulating some AST's?)
>
> > probably not worthwhile. to be completely safe, I should be checking
> > isempty(.args[2][3]), since it's not meaningful to copy a function that
> > includes closure variables.
> >
>
> I think it is as meaningful as copying a normal function (which is not very
> much in general) but in my case it is probably too complicated to analyse
> (at
> least for a start) Thanks for pointing that out...
>
>


Re: [julia-users] Homebrew issue

2014-12-19 Thread Elliot Saba
Failing that, a `Homebrew.rm("hdf5")` followed by a `Homebrew.add("hdf5")`
should always get rid of one of those "will not force a rebuild of"
errors.  I've just pushed a new version of Homebrew that shouldn't say that
anymore, we'll see how it goes.
-E

On Fri, Dec 19, 2014 at 5:16 PM, Elliot Saba  wrote:

> Can you do a `Pkg.update()`?  I may have just fixed this.
> -E
>
> On Fri, Dec 19, 2014 at 4:55 PM, Tomas Mikoviny 
> wrote:
>
>> sorry this is the repost I've screwed up formatting in previous post...
>>
>> Hi there,
>>
>> I've just got my new Mac and installed the official binary 0.3.3 version
>> (from dmg) and in parallel I have the 0.4 version compiled.
>> Running 0.3 version with clear table (no ~/,julia* initially) and
>> installing Homebrew first and HDF5 second I get weird error I've never seen
>> before:
>>
>> Will not force Homebrew to rebuild dependency "libhdf5".
>>
>> Am I doing something wrong?  I've just spent couple of hours on this
>> today and cannot really see where the problem might be.
>>
>> Tomas
>>
>>
>> for complete picture here is full output:
>>   _
>>_   _ _(_)_ |  A fresh approach to technical computing
>>   (_) | (_) (_)|  Documentation: http://docs.julialang.org
>>_ _   _| |_  __ _   |  Type "help()" for help.
>>   | | | | | | |/ _` |  |
>>   | | |_| | | | (_| |  |  Version 0.3.3 (2014-11-23 20:19 UTC)
>>  _/ |\__'_|_|_|\__'_|  |  'Official http://julialang.org/ release'
>> |__/   |  x86_64-apple-darwin13.3.0
>>
>> julia> Pkg.init()
>> INFO: Initializing package repository /Users/tomik/.julia/v0.3
>> INFO: Cloning METADATA from git://github.com/JuliaLang/METADATA.jl
>>
>> julia> Pkg.add("HDF5")
>> INFO: Cloning cache of BinDeps from git://
>> github.com/JuliaLang/BinDeps.jl.git
>> INFO: Cloning cache of Blosc from git://github.com/stevengj/Blosc.jl.git
>> INFO: Cloning cache of Compat from git://
>> github.com/JuliaLang/Compat.jl.git
>> INFO: Cloning cache of HDF5 from git://github.com/timholy/HDF5.jl.git
>> INFO: Cloning cache of Homebrew from git://
>> github.com/JuliaLang/Homebrew.jl.git
>> INFO: Cloning cache of JSON from git://github.com/JuliaLang/JSON.jl.git
>> INFO: Cloning cache of SHA from git://github.com/staticfloat/SHA.jl.git
>> INFO: Cloning cache of URIParser from git://
>> github.com/JuliaWeb/URIParser.jl.git
>> INFO: Installing BinDeps v0.3.7
>> INFO: Installing Blosc v0.1.0
>> INFO: Installing Compat v0.2.6
>> INFO: Installing HDF5 v0.4.7
>> INFO: Installing Homebrew v0.1.12
>> INFO: Installing JSON v0.3.9
>> INFO: Installing SHA v0.0.3
>> INFO: Installing URIParser v0.0.3
>> INFO: Building Blosc
>>   % Total% Received % Xferd  Average Speed   TimeTime Time
>>  Current
>>  Dload  Upload   Total   SpentLeft
>>  Speed
>> 100 28648  100 286480 0  41977  0 --:--:-- --:--:-- --:--:--
>> 41944
>> INFO: Building Homebrew
>> INFO: Cloning brew from https://github.com/Homebrew/homebrew.git
>> Cloning into '/Users/tomik/.julia/v0.3/Homebrew/deps/usr'...
>> remote: Counting objects: 3472, done.
>> remote: Compressing objects: 100% (3328/3328), done.
>> remote: Total 3472 (delta 48), reused 934 (delta 23)
>> Receiving objects: 100% (3472/3472), 2.46 MiB | 417 KiB/s, done.
>> Resolving deltas: 100% (48/48), done.
>>   % Total% Received % Xferd  Average Speed   TimeTime Time
>>  Current
>>  Dload  Upload   Total   SpentLeft
>>  Speed
>> 100  258k  100  258k0 0   102k  0  0:00:02  0:00:02 --:--:--
>>  102k
>> Cloning into
>> '/Users/tomik/.julia/v0.3/Homebrew/deps/usr/Library/Taps/staticfloat/homebrew-juliadeps'...
>> Tapped 28 formulae
>> HEAD is now at 3d428af fakeroot: add 1.20.2 bottle.
>> HEAD is now at 1431f1c Merge pull request #26 from staticfloat/staging
>> INFO: Building HDF5
>> ===[ ERROR:
>> HDF5 ]
>>
>> Will not force Homebrew to rebuild dependency "libhdf5".
>> Please make any necessary adjustments manually (This might just be a
>> version upgrade)
>> while loading /Users/tomik/.julia/v0.3/HDF5/deps/build.jl, in expression
>> starting on line 23
>>
>>
>> ==
>>
>> ===[ BUILD
>> ERRORS ]===
>>
>> WARNING: HDF5 had build errors.
>>
>>  - packages with build errors remain installed in /Users/tomik/.julia/v0.3
>>  - build a package and all its dependencies with `Pkg.build(pkg)`
>>  - build a single package by running its `deps/build.jl` script
>>
>>
>> ==
>> INFO: Package databa

Re: [julia-users] Homebrew issue

2014-12-19 Thread Elliot Saba
Can you do a `Pkg.update()`?  I may have just fixed this.
-E

On Fri, Dec 19, 2014 at 4:55 PM, Tomas Mikoviny 
wrote:

> sorry this is the repost I've screwed up formatting in previous post...
>
> Hi there,
>
> I've just got my new Mac and installed the official binary 0.3.3 version
> (from dmg) and in parallel I have the 0.4 version compiled.
> Running 0.3 version with clear table (no ~/,julia* initially) and
> installing Homebrew first and HDF5 second I get weird error I've never seen
> before:
>
> Will not force Homebrew to rebuild dependency "libhdf5".
>
> Am I doing something wrong?  I've just spent couple of hours on this today
> and cannot really see where the problem might be.
>
> Tomas
>
>
> for complete picture here is full output:
>   _
>_   _ _(_)_ |  A fresh approach to technical computing
>   (_) | (_) (_)|  Documentation: http://docs.julialang.org
>_ _   _| |_  __ _   |  Type "help()" for help.
>   | | | | | | |/ _` |  |
>   | | |_| | | | (_| |  |  Version 0.3.3 (2014-11-23 20:19 UTC)
>  _/ |\__'_|_|_|\__'_|  |  'Official http://julialang.org/ release'
> |__/   |  x86_64-apple-darwin13.3.0
>
> julia> Pkg.init()
> INFO: Initializing package repository /Users/tomik/.julia/v0.3
> INFO: Cloning METADATA from git://github.com/JuliaLang/METADATA.jl
>
> julia> Pkg.add("HDF5")
> INFO: Cloning cache of BinDeps from git://
> github.com/JuliaLang/BinDeps.jl.git
> INFO: Cloning cache of Blosc from git://github.com/stevengj/Blosc.jl.git
> INFO: Cloning cache of Compat from git://
> github.com/JuliaLang/Compat.jl.git
> INFO: Cloning cache of HDF5 from git://github.com/timholy/HDF5.jl.git
> INFO: Cloning cache of Homebrew from git://
> github.com/JuliaLang/Homebrew.jl.git
> INFO: Cloning cache of JSON from git://github.com/JuliaLang/JSON.jl.git
> INFO: Cloning cache of SHA from git://github.com/staticfloat/SHA.jl.git
> INFO: Cloning cache of URIParser from git://
> github.com/JuliaWeb/URIParser.jl.git
> INFO: Installing BinDeps v0.3.7
> INFO: Installing Blosc v0.1.0
> INFO: Installing Compat v0.2.6
> INFO: Installing HDF5 v0.4.7
> INFO: Installing Homebrew v0.1.12
> INFO: Installing JSON v0.3.9
> INFO: Installing SHA v0.0.3
> INFO: Installing URIParser v0.0.3
> INFO: Building Blosc
>   % Total% Received % Xferd  Average Speed   TimeTime Time
>  Current
>  Dload  Upload   Total   SpentLeft
>  Speed
> 100 28648  100 286480 0  41977  0 --:--:-- --:--:-- --:--:--
> 41944
> INFO: Building Homebrew
> INFO: Cloning brew from https://github.com/Homebrew/homebrew.git
> Cloning into '/Users/tomik/.julia/v0.3/Homebrew/deps/usr'...
> remote: Counting objects: 3472, done.
> remote: Compressing objects: 100% (3328/3328), done.
> remote: Total 3472 (delta 48), reused 934 (delta 23)
> Receiving objects: 100% (3472/3472), 2.46 MiB | 417 KiB/s, done.
> Resolving deltas: 100% (48/48), done.
>   % Total% Received % Xferd  Average Speed   TimeTime Time
>  Current
>  Dload  Upload   Total   SpentLeft
>  Speed
> 100  258k  100  258k0 0   102k  0  0:00:02  0:00:02 --:--:--
>  102k
> Cloning into
> '/Users/tomik/.julia/v0.3/Homebrew/deps/usr/Library/Taps/staticfloat/homebrew-juliadeps'...
> Tapped 28 formulae
> HEAD is now at 3d428af fakeroot: add 1.20.2 bottle.
> HEAD is now at 1431f1c Merge pull request #26 from staticfloat/staging
> INFO: Building HDF5
> ===[ ERROR:
> HDF5 ]
>
> Will not force Homebrew to rebuild dependency "libhdf5".
> Please make any necessary adjustments manually (This might just be a
> version upgrade)
> while loading /Users/tomik/.julia/v0.3/HDF5/deps/build.jl, in expression
> starting on line 23
>
>
> ==
>
> ===[ BUILD
> ERRORS ]===
>
> WARNING: HDF5 had build errors.
>
>  - packages with build errors remain installed in /Users/tomik/.julia/v0.3
>  - build a package and all its dependencies with `Pkg.build(pkg)`
>  - build a single package by running its `deps/build.jl` script
>
>
> ==
> INFO: Package database updated
>
>


[julia-users] Re: Can't Define New Functors Using Numeric Extensions 0.6.2 in Julia 0.3.3

2014-12-19 Thread Michael Wojnowicz

OK, thanks. 

On Friday, December 19, 2014 4:27:31 PM UTC-8, Dahua Lin wrote:
>
> NumericExtensions.jl was a stopgap. 
>
> Now that we have callable syntax and much more optimized map function in 
> Julia Base (v0.4), using that package is no longer recommended.
>
> Dahua
>
>
> On Saturday, December 20, 2014 7:07:10 AM UTC+8, Michael Wojnowicz wrote:
>>
>> Hi Ivar,
>>
>> Thanks for your thoughts and ideas.Unfortunately, none of those leads 
>> seem to be the the root of the problem: 
>>
>> * I just reloaded a second session -- and also tried a different name, 
>> "SqrDiff2()", but got the same error message when trying to apply map.
>>
>> * I was pasting everything into REPL, but tried running from script, and 
>> got the same error message.
>>
>> -Mike
>>  
>>
>

[julia-users] Homebrew issue

2014-12-19 Thread Tomas Mikoviny
sorry this is the repost I've screwed up formatting in previous post...

Hi there, 

I've just got my new Mac and installed the official binary 0.3.3 version 
(from dmg) and in parallel I have the 0.4 version compiled.
Running 0.3 version with clear table (no ~/,julia* initially) and 
installing Homebrew first and HDF5 second I get weird error I've never seen 
before:

Will not force Homebrew to rebuild dependency "libhdf5".

Am I doing something wrong?  I've just spent couple of hours on this today 
and cannot really see where the problem might be.

Tomas


for complete picture here is full output:
  _
   _   _ _(_)_ |  A fresh approach to technical computing
  (_) | (_) (_)|  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "help()" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.3.3 (2014-11-23 20:19 UTC)
 _/ |\__'_|_|_|\__'_|  |  'Official http://julialang.org/ release'
|__/   |  x86_64-apple-darwin13.3.0

julia> Pkg.init()
INFO: Initializing package repository /Users/tomik/.julia/v0.3
INFO: Cloning METADATA from git://github.com/JuliaLang/METADATA.jl

julia> Pkg.add("HDF5")
INFO: Cloning cache of BinDeps from 
git://github.com/JuliaLang/BinDeps.jl.git
INFO: Cloning cache of Blosc from git://github.com/stevengj/Blosc.jl.git
INFO: Cloning cache of Compat from git://github.com/JuliaLang/Compat.jl.git
INFO: Cloning cache of HDF5 from git://github.com/timholy/HDF5.jl.git
INFO: Cloning cache of Homebrew from 
git://github.com/JuliaLang/Homebrew.jl.git
INFO: Cloning cache of JSON from git://github.com/JuliaLang/JSON.jl.git
INFO: Cloning cache of SHA from git://github.com/staticfloat/SHA.jl.git
INFO: Cloning cache of URIParser from 
git://github.com/JuliaWeb/URIParser.jl.git
INFO: Installing BinDeps v0.3.7
INFO: Installing Blosc v0.1.0
INFO: Installing Compat v0.2.6
INFO: Installing HDF5 v0.4.7
INFO: Installing Homebrew v0.1.12
INFO: Installing JSON v0.3.9
INFO: Installing SHA v0.0.3
INFO: Installing URIParser v0.0.3
INFO: Building Blosc
  % Total% Received % Xferd  Average Speed   TimeTime Time 
 Current
 Dload  Upload   Total   SpentLeft 
 Speed
100 28648  100 286480 0  41977  0 --:--:-- --:--:-- --:--:-- 
41944
INFO: Building Homebrew
INFO: Cloning brew from https://github.com/Homebrew/homebrew.git
Cloning into '/Users/tomik/.julia/v0.3/Homebrew/deps/usr'...
remote: Counting objects: 3472, done.
remote: Compressing objects: 100% (3328/3328), done.
remote: Total 3472 (delta 48), reused 934 (delta 23)
Receiving objects: 100% (3472/3472), 2.46 MiB | 417 KiB/s, done.
Resolving deltas: 100% (48/48), done.
  % Total% Received % Xferd  Average Speed   TimeTime Time 
 Current
 Dload  Upload   Total   SpentLeft 
 Speed
100  258k  100  258k0 0   102k  0  0:00:02  0:00:02 --:--:-- 
 102k
Cloning into 
'/Users/tomik/.julia/v0.3/Homebrew/deps/usr/Library/Taps/staticfloat/homebrew-juliadeps'...
Tapped 28 formulae
HEAD is now at 3d428af fakeroot: add 1.20.2 bottle.
HEAD is now at 1431f1c Merge pull request #26 from staticfloat/staging
INFO: Building HDF5
===[ ERROR: 
HDF5 ]

Will not force Homebrew to rebuild dependency "libhdf5".
Please make any necessary adjustments manually (This might just be a 
version upgrade)
while loading /Users/tomik/.julia/v0.3/HDF5/deps/build.jl, in expression 
starting on line 23

==

===[ BUILD 
ERRORS ]===

WARNING: HDF5 had build errors.

 - packages with build errors remain installed in /Users/tomik/.julia/v0.3
 - build a package and all its dependencies with `Pkg.build(pkg)`
 - build a single package by running its `deps/build.jl` script

==
INFO: Package database updated



[julia-users] Is there any problem with Homebrew?

2014-12-19 Thread Tomas Mikoviny
Hi there, 

I've just got my new Mac and installed the official binary 0.3.3 version 
(from dmg) and in parallel I have the 0.4 version compiled.
Running 0.3 version with clear table (no ~/,julia* initially) and 
installing Homebrew first and HDF5 second I get weird error I've never seen 
before:

Will not force Homebrew to rebuild dependency "libhdf5".

Am I doing something wrong?  I've just spent couple of hours on this today 
and cannot really see where the problem might be.

Tomas


for complete picture here is full output:

   _

   _   _ _(_)_ |  A fresh approach to technical computing

  (_) | (_) (_)|  Documentation: http://docs.julialang.org

   _ _   _| |_  __ _   |  Type "help()" for help.

  | | | | | | |/ _` |  |

  | | |_| | | | (_| |  |  Version 0.3.3 (2014-11-23 20:19 UTC)

 _/ |\__'_|_|_|\__'_|  |  'Official http://julialang.org/ release'

|__/   |  x86_64-apple-darwin13.3.0


julia> Pkg.init()

INFO: Initializing package repository /Users/tomik/.julia/v0.3

INFO: Cloning METADATA from git://github.com/JuliaLang/METADATA.jl


julia> Pkg.add("Homebrew")

INFO: Cloning cache of BinDeps from 
git://github.com/JuliaLang/BinDeps.jl.git

INFO: Cloning cache of Compat from git://github.com/JuliaLang/Compat.jl.git

INFO: Cloning cache of Homebrew from 
git://github.com/JuliaLang/Homebrew.jl.git

INFO: Cloning cache of JSON from git://github.com/JuliaLang/JSON.jl.git

INFO: Cloning cache of SHA from git://github.com/staticfloat/SHA.jl.git

INFO: Cloning cache of URIParser from 
git://github.com/JuliaWeb/URIParser.jl.git

INFO: Installing BinDeps v0.3.7

INFO: Installing Compat v0.2.6

INFO: Installing Homebrew v0.1.12

INFO: Installing JSON v0.3.9

INFO: Installing SHA v0.0.3

INFO: Installing URIParser v0.0.3

INFO: Building Homebrew

INFO: Cloning brew from https://github.com/Homebrew/homebrew.git

Cloning into '/Users/tomik/.julia/v0.3/Homebrew/deps/usr'...

remote: Counting objects: 3472, done.

remote: Compressing objects: 100% (3328/3328), done.

remote: Total 3472 (delta 48), reused 934 (delta 23)

Receiving objects: 100% (3472/3472), 2.46 MiB | 1024 KiB/s, done.

Resolving deltas: 100% (48/48), done.

  % Total% Received % Xferd  Average Speed   TimeTime Time  
Current

 Dload  Upload   Total   SpentLeft  
Speed

100  258k  100  258k0 0  89796  0  0:00:02  0:00:02 --:--:-- 
89778

Cloning into 
'/Users/tomik/.julia/v0.3/Homebrew/deps/usr/Library/Taps/staticfloat/homebrew-juliadeps'...

Tapped 28 formulae

HEAD is now at 3d428af fakeroot: add 1.20.2 bottle.

HEAD is now at 1431f1c Merge pull request #26 from staticfloat/staging

INFO: Package database updated


julia> Pkg.add("HDF5")

INFO: Cloning cache of Blosc from git://github.com/stevengj/Blosc.jl.git

INFO: Cloning cache of HDF5 from git://github.com/timholy/HDF5.jl.git

INFO: Installing Blosc v0.1.0

INFO: Installing HDF5 v0.4.7

INFO: Building Blosc

  % Total% Received % Xferd  Average Speed   TimeTime Time  
Current

 Dload  Upload   Total   SpentLeft  
Speed

100 28648  100 286480 0  36393  0 --:--:-- --:--:-- --:--:-- 
36355

INFO: Building Homebrew

HEAD is now at 3d428af fakeroot: add 1.20.2 bottle.

HEAD is now at 1431f1c Merge pull request #26 from staticfloat/staging

INFO: Building HDF5

===[ ERROR: 
HDF5 ]


Will not force Homebrew to rebuild dependency "libhdf5".

Please make any necessary adjustments manually (This might just be a 
version upgrade)

while loading /Users/tomik/.julia/v0.3/HDF5/deps/build.jl, in expression 
starting on line 23


==


===[ BUILD 
ERRORS ]===


WARNING: HDF5 had build errors.


 - packages with build errors remain installed in /Users/tomik/.julia/v0.3

 - build a package and all its dependencies with `Pkg.build(pkg)`

 - build a single package by running its `deps/build.jl` script


==

INFO: Package database updated








[julia-users] Re: Package development - best practices

2014-12-19 Thread David van Leeuwen
Hi, 

On Wednesday, December 17, 2014 11:21:44 PM UTC+1, Seth wrote:
>
> I'm wondering whether folks are actually basing their repos in ~/.julia 
> and doing their development and commits from there, or whether there's some 
> other process that allows development to happen in a more standard location 
> than a hidden directory off of ~ while still allowing use of Pkg. I'm 
> probably overlooking something trivial.
>
> What's a recommended setup/process for creating packages using Pkg to 
> manage them?
>

I'm not sure what the right answer would be, but I have been struggling 
with it a lot.  This is my set-up for most of the stuff I do.  

 - I develop packages in their own directories on the user filesystem.  For 
me, that would be `.../julia//` .  
 - from there, in `./src/` I have the various source files.  One, 
specifically is called "nomodule.jl".  This contains a 
   - "require()"
   - "include()"
   - ...
 - Each time I change something in the code, I do a `reload("nomodule.jl`) 
from the REPL.  This replaces all functions, except for the type 
definitions---they can't be updated
 - When I need to change the types, I need to do a `ctrl-D; julia; 
reload("nomodule.jl")` which can be a bit of a pain
 - When I am happy with the functionality, I make this code into a module, 
using a file ".jl", very similar to the "nomodule.jl" but with the 
"require" replaced by "include"
 - I sync this then with github
 - If I need the functionality from another working directory, I do a 
`Pkg.clone()` to load a sort-of-stable version into ~/.julia
 - When I am really happy with the code, I do a pull request to METADATA.jl 
for my package to be included in the standard set of Julia packages. 

 - If I need functionality on some other machines, I sync using git, either 
through github or directly.

 Cheers, 

---david


[julia-users] Re: Can't Define New Functors Using Numeric Extensions 0.6.2 in Julia 0.3.3

2014-12-19 Thread Dahua Lin
NumericExtensions.jl was a stopgap. 

Now that we have callable syntax and much more optimized map function in 
Julia Base (v0.4), using that package is no longer recommended.

Dahua


On Saturday, December 20, 2014 7:07:10 AM UTC+8, Michael Wojnowicz wrote:
>
> Hi Ivar,
>
> Thanks for your thoughts and ideas.Unfortunately, none of those leads 
> seem to be the the root of the problem: 
>
> * I just reloaded a second session -- and also tried a different name, 
> "SqrDiff2()", but got the same error message when trying to apply map.
>
> * I was pasting everything into REPL, but tried running from script, and 
> got the same error message.
>
> -Mike
>  
>


Re: [julia-users] Random Draw from Gaussian Mixture

2014-12-19 Thread David van Leeuwen
Hi, 

Did you look into GaussianMixtures?  This has a random sampling function. 

---david

On Friday, December 19, 2014 1:42:38 PM UTC+1, Andreas Noack wrote:
>
> Hi Bradley
>
> I was able to construct an GMM instance with
>
> julia> Σnew = 
> Triangular{Float64,Matrix{Float64},:U,false}[chol(sigma[:,:,i], :U) for i = 
> 1:2]
>
> julia> GMM(p, mu, Σnew, [], 0)
> GMM{Float64} with 2 components in 2 dimensions and full covariance
> Mix 1: weight 0.90
> mean: 1x2 Array{Float64,2}:
>  0.0  25.0
> covariance: 2x2 Array{Float64,2}:
>   5.26316  -4.73684
>  -4.73684   5.26316
> Mix 2: weight 0.10
> mean: 1x2 Array{Float64,2}:
>  0.0  25.0
> covariance: 2x2 Array{Float64,2}:
>  0.13  0.0 
>  0.0   0.13
>
> but I don't understant the last two arguments to the constructor.
>
> 2014-12-18 1:06 GMT+01:00 Bradley Setzler  >:
> >
> > Hi,
> >
> > I wish to work with the Gaussian Mixture distribution (especially rand 
> and pdf), exactly as in this example: 
> >
> > mu = [0.0 25.0; 0.0 25.0] 
> > sigma = Array(Float64, 2, 2, 2) 
> > sigma[:, :, 1] = [1.0 0.9; 0.9 1.0] 
> > sigma[:, :, 2] = 7.5 * [1.0 0.0; 0.0 1.0] 
> > p = [0.9, 0.1] 
> >
> > distr = MixtureMultivariateNormals(mu, sigma, p) 
> > X = rand(distr, 10_000)
> >
> >
> > However, the method MixtureMultivariateNormals(mu, sigma, p) used in 
> that example no longer exists. The maintained version of MixtureModels.jl 
> has no examples or methods in the documentation of basic usage, and it is 
> far from obvious how to use it for a Gaussian mixture.
> >
> > Separately, the package GaussianMixtures.jl, does not successfully work 
> in what would seem to be the obvious method:
> >
> > julia> GMM(p,mu,sigma)
> > ERROR: `GMM{T<:FloatingPoint,CT<:Union(Array{T,2},Array{T,1})}` has no 
> method matching 
> GMM{T<:FloatingPoint,CT<:Union(Array{T,2},Array{T,1})}(::Array{Float64,1}, 
> ::Array{Float64,2}, ::Array{Float64,2})
> >
> > Could someone show me a working example analogous to the one above, 
> using whichever package you wish?
> >
> > Thank you,
> > Bradley
>


[julia-users] Re: Can't Define New Functors Using Numeric Extensions 0.6.2 in Julia 0.3.3

2014-12-19 Thread Michael Wojnowicz
Hi Ivar,

Thanks for your thoughts and ideas.Unfortunately, none of those leads 
seem to be the the root of the problem: 

* I just reloaded a second session -- and also tried a different name, 
"SqrDiff2()", but got the same error message when trying to apply map.

* I was pasting everything into REPL, but tried running from script, and 
got the same error message.

-Mike
 


[julia-users] Re: Can't Define New Functors Using Numeric Extensions 0.6.2 in Julia 0.3.3

2014-12-19 Thread Ivar Nesje
Yes, everything is fine now. I noticed only 5 people were following 
NumericExtensions.jl, so it's probably better to ask here.

The error seems really strange. Do you load some code from a file, or do you 
paste everything directly in the REPL? Have you defined the type multiple times 
in the same session?

Re: [julia-users] R version of microbenchmarks

2014-12-19 Thread Milan Bouchet-Valat
Le vendredi 19 décembre 2014 à 10:08 -0800, Douglas Bates a écrit :
> Perhaps the R version of the microbenchmarks could be run on
> Revolution R Open, http://mran.revolutionanalytics.com/download/. The
> major difference between RRO and other versions is that RRO
> incorporates MKL.  For one or two of the benchmarks this could make a
> difference.
This could be interesting to take as a separate implementation from R,
but not to replace R IMO. The official R download uses a the reference
BLAS, this is what most users get and this choice is fully assumed
(recently on the R list a developer stated that most R users wouldn't
benefit from using a more efficient version than the reference BLAS).
Using a tuned version wouldn't be representative of the default
experience, and it would be misleading because MKL isn't free but people
may expect that R is.


Regards

> By the way, I was also going to suggest applying the byte compiler to
> the functions being timed but I see that this has already been done.
> 
> 



[julia-users] Re: Can't Define New Functors Using Numeric Extensions 0.6.2 in Julia 0.3.3

2014-12-19 Thread Michael Wojnowicz
Sorry about that.   I found the Numeric Extensions forum second.  But I see 
what you mean about double answering.So are they now considered linked?

On Friday, December 19, 2014 2:13:02 PM UTC-8, Ivar Nesje wrote:
>
> Please don't double post your questions without linking between them. It's 
> really annoying to answer a question, just to find out that it was answered 
> 1 hour ago another place. 
>
>  https://github.com/lindahua/NumericExtensions.jl/issues/49



[julia-users] Can't Define New Functors Using Numeric Extensions 0.6.2 in Julia 0.3.3

2014-12-19 Thread Ivar Nesje
Please don't double post your questions without linking between them. It's 
really annoying to answer a question, just to find out that it was answered 1 
hour ago another place.

 https://github.com/lindahua/NumericExtensions.jl/issues/49

[julia-users] 5 clicks to a Julia REPL ...

2014-12-19 Thread cdm

for those whom have not stumbled upon this, anyone with a browser
and an internet connection can launch a Julie REPL in five clicks ...

   point a browser to tmpnb.org (click 1)

   click the "File" menu link (click 2)

   select "Open" (click 3)

   click the "Terminals" menu link (click 4)

   click the "New Terminal" button in the upper right (click 5)

   enter "julia" at the linux prompt.



enjoy !!!

cdm


Re: [julia-users] any clarification of bytes allocated in @time?

2014-12-19 Thread Jason Merrill
On Friday, December 19, 2014 12:10:31 PM UTC-8, Jim Garrison wrote:
>
>
>
> On Friday, December 19, 2014 10:12:42 AM UTC-8, Tim Holy wrote:
>>
>> Julia's arrays grow by doubling, see 
>> http://en.wikipedia.org/wiki/Dynamic_array 
>>
>
> Is it strictly true that arrays in Julia grow by a factor of two on each 
> reallocation?  It has been argued (see e.g. 
> https://github.com/facebook/folly/blob/master/folly/docs/FBVector.md#memory-handling)
>  
> that a growth factor of two is actually the worst possible one for 
> performance (though it is of course better than non-exponential growth). 
>  I'm left wondering whether details of Julia's allocator may mean that the 
> linked considerations do not apply here... 
>

There's a ticket for this: https://github.com/JuliaLang/julia/issues/8269

Here's how I found it: 
https://github.com/JuliaLang/julia/search?q=grow+arrays&type=Issues&utf8=%E2%9C%93
 
but I had a vague recollection that it existed before I went searching. 


Re: [julia-users] any clarification of bytes allocated in @time?

2014-12-19 Thread Jim Garrison


On Friday, December 19, 2014 10:12:42 AM UTC-8, Tim Holy wrote:
>
> Julia's arrays grow by doubling, see 
> http://en.wikipedia.org/wiki/Dynamic_array 
>

Is it strictly true that arrays in Julia grow by a factor of two on each 
reallocation?  It has been argued (see e.g. 
https://github.com/facebook/folly/blob/master/folly/docs/FBVector.md#memory-handling)
 
that a growth factor of two is actually the worst possible one for 
performance (though it is of course better than non-exponential growth). 
 I'm left wondering whether details of Julia's allocator may mean that the 
linked considerations do not apply here... 


Re: [julia-users] any clarification of bytes allocated in @time?

2014-12-19 Thread Tim Holy
On Friday, December 19, 2014 10:34:32 AM John Drummond wrote:
> And will increasing the size beyond the maximum always copy the whole array?

Yes, because Arrays are required to be contiguous. But if you don't need that,
https://github.com/tanmaykm/ChainedVectors.jl
might be of some interest to you.

--Tim



Re: [julia-users] recommended performant approach of expanding a large array

2014-12-19 Thread John Drummond
Yes you're right - sorry for the duplication.
Thanks.

On Friday, December 19, 2014 6:15:45 PM UTC, Stefan Karpinski wrote:
>
> On Fri, Dec 19, 2014 at 1:13 PM, John Drummond  > wrote:
>
>> pre initializing myArray and then checking the length each time to see 
>> whether to expand by a another 20%?
>
>
> This is already done under the hood – see the other thread that's about 
> basically the same thing.
>


Re: [julia-users] any clarification of bytes allocated in @time?

2014-12-19 Thread John Drummond
Great, thank you.

On Friday, December 19, 2014 6:37:03 PM UTC, John Myles White wrote:
>
> The problem is that your let block is not a proper function body. You need 
> to time things inside of a function body: 
>
> julia> function foo() 
>   @time a1 = zeros(Int64,1000) 
>   @time resize!(a1, 1000) 
>   @time resize!(a1, 1000) 
>   @time resize!(a1, 1000) 
>   @time resize!(a1, 2000) 
>end 
> foo (generic function with 1 method) 
>
> julia> foo() 
> elapsed time: 0.039935728 seconds (8048 bytes allocated) 
> elapsed time: 8.61e-6 seconds (0 bytes allocated) 
> elapsed time: 4.45e-7 seconds (0 bytes allocated) 
> elapsed time: 2.71e-7 seconds (0 bytes allocated) 
> elapsed time: 0.000365734 seconds (16000 bytes allocated) 
>
>  -- John 
>
> On Dec 19, 2014, at 1:34 PM, John Drummond > 
> wrote: 
>
> > Sorry to be stupid - but this also helps me understand things for 
> another question: 
> > So bytes allocated would be the underlying usage of memory. 
> > 
> > in which case with 
> > julia> let 
> >@time a1 = zeros(Int64,1000) 
> >@time resize!(a1, 1000) 
> >@time resize!(a1, 1000) 
> >@time resize!(a1, 1000) 
> >@time resize!(a1, 2000) 
> >end 
> > elapsed time: 0.015554722 seconds (8152 bytes allocated) 
> > elapsed time: 5.735e-6 seconds (80 bytes allocated) 
> > elapsed time: 2.113e-6 seconds (80 bytes allocated) 
> > elapsed time: 2.113e-6 seconds (80 bytes allocated) 
> > elapsed time: 0.027380439 seconds (16080 bytes allocated) 
> > 2000-element Array{Int64,1}: 
> > 
> > what's the 80 bytes allocated when I'm just changing the length I'm 
> using? 
> > 
> > And will increasing the size beyond the maximum always copy the whole 
> array? 
> > 
> > Many thanks for clarifying this. 
> > 
> > 
> > 
> > 
> > 
> > On Friday, December 19, 2014 6:12:42 PM UTC, Tim Holy wrote: 
> > Julia's arrays grow by doubling, see 
> > http://en.wikipedia.org/wiki/Dynamic_array 
> > 
> > Since you're appending elements to an array, julia has to have somewhere 
> to 
> > put them---and when there's no spare capacity, julia has to allocate a 
> new 
> > array and copy the entire thing. So some allocations are much bigger 
> than what 
> > you're adding, but others (as you can see) are 0. 
> > 
> > This is a marked improvement over Matlab, which makes a copy of your 
> entire 
> > array each time you add 1 element. 
> > 
> > Best, 
> > --Tim 
> > 
> > On Friday, December 19, 2014 10:00:28 AM John Drummond wrote: 
> > > For the following code (julia 0.3.3 in windows 7 ) I don't understand 
> what 
> > > the bytes allocated in @time means 
> > > 
> > > All I'm doing each time is adding 10  8 byte integers 
> > > 
> > > Thanks for any thoughts 
> > > 
> > > julia> @time c = [1,2] 
> > > elapsed time: 3.32e-6 seconds (144 bytes allocated) 
> > > 2-element Array{Int64,1}: 
> > >  1 
> > >  2 
> > > 
> > > julia> sizeof(c) 
> > > 16 
> > > 
> > > 
> > > julia> @time for x in 30:39 push!(c, x) end 
> > > elapsed time: 2.717e-6 seconds (256 bytes allocated) 
> > > 
> > > julia> @time for x in 30:39 push!(c, x) end 
> > > elapsed time: 2.717e-6 seconds (288 bytes allocated) 
> > > 
> > > julia> @time for x in 30:39 push!(c, x) end 
> > > elapsed time: 2.112e-6 seconds (0 bytes allocated) 
> > > 
> > > julia> @time for x in 30:39 push!(c, x) end 
> > > elapsed time: 3.321e-6 seconds (640 bytes allocated) 
> > > 
> > > julia> sizeof(c) 
> > > 336 
> > 
>
>

Re: [julia-users] any clarification of bytes allocated in @time?

2014-12-19 Thread John Myles White
The problem is that your let block is not a proper function body. You need to 
time things inside of a function body:

julia> function foo()
  @time a1 = zeros(Int64,1000)
  @time resize!(a1, 1000)
  @time resize!(a1, 1000)
  @time resize!(a1, 1000)
  @time resize!(a1, 2000)
   end
foo (generic function with 1 method)

julia> foo()
elapsed time: 0.039935728 seconds (8048 bytes allocated)
elapsed time: 8.61e-6 seconds (0 bytes allocated)
elapsed time: 4.45e-7 seconds (0 bytes allocated)
elapsed time: 2.71e-7 seconds (0 bytes allocated)
elapsed time: 0.000365734 seconds (16000 bytes allocated)

 -- John

On Dec 19, 2014, at 1:34 PM, John Drummond  wrote:

> Sorry to be stupid - but this also helps me understand things for another 
> question:
> So bytes allocated would be the underlying usage of memory.
> 
> in which case with
> julia> let
>@time a1 = zeros(Int64,1000)
>@time resize!(a1, 1000)
>@time resize!(a1, 1000)
>@time resize!(a1, 1000)
>@time resize!(a1, 2000)
>end
> elapsed time: 0.015554722 seconds (8152 bytes allocated)
> elapsed time: 5.735e-6 seconds (80 bytes allocated)
> elapsed time: 2.113e-6 seconds (80 bytes allocated)
> elapsed time: 2.113e-6 seconds (80 bytes allocated)
> elapsed time: 0.027380439 seconds (16080 bytes allocated)
> 2000-element Array{Int64,1}:
> 
> what's the 80 bytes allocated when I'm just changing the length I'm using?
> 
> And will increasing the size beyond the maximum always copy the whole array?
> 
> Many thanks for clarifying this.
> 
> 
> 
> 
> 
> On Friday, December 19, 2014 6:12:42 PM UTC, Tim Holy wrote:
> Julia's arrays grow by doubling, see 
> http://en.wikipedia.org/wiki/Dynamic_array 
> 
> Since you're appending elements to an array, julia has to have somewhere to 
> put them---and when there's no spare capacity, julia has to allocate a new 
> array and copy the entire thing. So some allocations are much bigger than 
> what 
> you're adding, but others (as you can see) are 0. 
> 
> This is a marked improvement over Matlab, which makes a copy of your entire 
> array each time you add 1 element. 
> 
> Best, 
> --Tim 
> 
> On Friday, December 19, 2014 10:00:28 AM John Drummond wrote: 
> > For the following code (julia 0.3.3 in windows 7 ) I don't understand what 
> > the bytes allocated in @time means 
> > 
> > All I'm doing each time is adding 10  8 byte integers 
> > 
> > Thanks for any thoughts 
> > 
> > julia> @time c = [1,2] 
> > elapsed time: 3.32e-6 seconds (144 bytes allocated) 
> > 2-element Array{Int64,1}: 
> >  1 
> >  2 
> > 
> > julia> sizeof(c) 
> > 16 
> > 
> > 
> > julia> @time for x in 30:39 push!(c, x) end 
> > elapsed time: 2.717e-6 seconds (256 bytes allocated) 
> > 
> > julia> @time for x in 30:39 push!(c, x) end 
> > elapsed time: 2.717e-6 seconds (288 bytes allocated) 
> > 
> > julia> @time for x in 30:39 push!(c, x) end 
> > elapsed time: 2.112e-6 seconds (0 bytes allocated) 
> > 
> > julia> @time for x in 30:39 push!(c, x) end 
> > elapsed time: 3.321e-6 seconds (640 bytes allocated) 
> > 
> > julia> sizeof(c) 
> > 336 
> 



Re: [julia-users] any clarification of bytes allocated in @time?

2014-12-19 Thread John Drummond
Sorry to be stupid - but this also helps me understand things for another 
question:
So bytes allocated would be the underlying usage of memory.

in which case with
julia> let
   @time a1 = zeros(Int64,1000)
   @time resize!(a1, 1000)
   @time resize!(a1, 1000)
   @time resize!(a1, 1000)
   @time resize!(a1, 2000)
   end
elapsed time: 0.015554722 seconds (8152 bytes allocated)
elapsed time: 5.735e-6 seconds (80 bytes allocated)
elapsed time: 2.113e-6 seconds (80 bytes allocated)
elapsed time: 2.113e-6 seconds (80 bytes allocated)
elapsed time: 0.027380439 seconds (16080 bytes allocated)
2000-element Array{Int64,1}:

what's the 80 bytes allocated when I'm just changing the length I'm using?

And will increasing the size beyond the maximum always copy the whole array?

Many thanks for clarifying this.





On Friday, December 19, 2014 6:12:42 PM UTC, Tim Holy wrote:
>
> Julia's arrays grow by doubling, see 
> http://en.wikipedia.org/wiki/Dynamic_array 
> 
>  
>
> Since you're appending elements to an array, julia has to have somewhere 
> to 
> put them---and when there's no spare capacity, julia has to allocate a new 
> array and copy the entire thing. So some allocations are much bigger than 
> what 
> you're adding, but others (as you can see) are 0. 
>
> This is a marked improvement over Matlab, which makes a copy of your 
> entire 
> array each time you add 1 element. 
>
> Best, 
> --Tim 
>
> On Friday, December 19, 2014 10:00:28 AM John Drummond wrote: 
> > For the following code (julia 0.3.3 in windows 7 ) I don't understand 
> what 
> > the bytes allocated in @time means 
> > 
> > All I'm doing each time is adding 10  8 byte integers 
> > 
> > Thanks for any thoughts 
> > 
> > julia> @time c = [1,2] 
> > elapsed time: 3.32e-6 seconds (144 bytes allocated) 
> > 2-element Array{Int64,1}: 
> >  1 
> >  2 
> > 
> > julia> sizeof(c) 
> > 16 
> > 
> > 
> > julia> @time for x in 30:39 push!(c, x) end 
> > elapsed time: 2.717e-6 seconds (256 bytes allocated) 
> > 
> > julia> @time for x in 30:39 push!(c, x) end 
> > elapsed time: 2.717e-6 seconds (288 bytes allocated) 
> > 
> > julia> @time for x in 30:39 push!(c, x) end 
> > elapsed time: 2.112e-6 seconds (0 bytes allocated) 
> > 
> > julia> @time for x in 30:39 push!(c, x) end 
> > elapsed time: 3.321e-6 seconds (640 bytes allocated) 
> > 
> > julia> sizeof(c) 
> > 336 
>
>

Re: [julia-users] any clarification of bytes allocated in @time?

2014-12-19 Thread John Drummond
Ah. Yes.
Though I was only really interested initially in what happened with the 
memory.
putting it in a let clause gives me
julia> let
   @time c = [1,2]
   sizeof(c)
   @time for x in 30:39 push!(c, x) end
   @time for x in 30:39 push!(c, x) end
   @time for x in 30:39 push!(c, x) end
   @time for x in 30:39 push!(c, x) end
   sizeof(c)
   end
elapsed time: 1.811e-6 seconds (64 bytes allocated)
elapsed time: 3.018e-6 seconds (256 bytes allocated)
elapsed time: 1.207e-6 seconds (288 bytes allocated)
elapsed time: 6.03e-7 seconds (0 bytes allocated)
elapsed time: 2.113e-6 seconds (640 bytes allocated)
336

with a difference only for the initial creation which is presumably the 
global versus local difference.


On Friday, December 19, 2014 6:01:24 PM UTC, John Myles White wrote:
>
> Are you timing things in the global scope? 
>
>  -- John 
>
> On Dec 19, 2014, at 1:00 PM, John Drummond > 
> wrote: 
>
> > For the following code (julia 0.3.3 in windows 7 ) I don't understand 
> what the bytes allocated in @time means 
> > 
> > All I'm doing each time is adding 10  8 byte integers 
> > 
> > Thanks for any thoughts 
> > 
> > julia> @time c = [1,2] 
> > elapsed time: 3.32e-6 seconds (144 bytes allocated) 
> > 2-element Array{Int64,1}: 
> >  1 
> >  2 
> > 
> > julia> sizeof(c) 
> > 16 
> > 
> > 
> > julia> @time for x in 30:39 push!(c, x) end 
> > elapsed time: 2.717e-6 seconds (256 bytes allocated) 
> > 
> > julia> @time for x in 30:39 push!(c, x) end 
> > elapsed time: 2.717e-6 seconds (288 bytes allocated) 
> > 
> > julia> @time for x in 30:39 push!(c, x) end 
> > elapsed time: 2.112e-6 seconds (0 bytes allocated) 
> > 
> > julia> @time for x in 30:39 push!(c, x) end 
> > elapsed time: 3.321e-6 seconds (640 bytes allocated) 
> > 
> > julia> sizeof(c) 
> > 336 
>
>

Re: [julia-users] recommended performant approach of expanding a large array

2014-12-19 Thread Stefan Karpinski
On Fri, Dec 19, 2014 at 1:13 PM, John Drummond  wrote:

> pre initializing myArray and then checking the length each time to see
> whether to expand by a another 20%?


This is already done under the hood – see the other thread that's about
basically the same thing.


[julia-users] recommended performant approach of expanding a large array

2014-12-19 Thread John Drummond
Hi,
I'm parsing some log files of a few million lines. 
I'm pulling out two or three numeric values and a code into an array of a 
custom type.

a simple approach would be something like

for line in eachline(myInFile)
push!(myArray, myType(Int64(line[1:4]), Int64(line[5:8]), line[15:16] )end

What would be a more idiomatic performant approach?

pre initializing myArray and then checking the length each time to see whether 
to expand by a another 20%?

Obviously I'll benchmark it but I was hoping for a push in the right direction.

Many thanks.John.





Re: [julia-users] any clarification of bytes allocated in @time?

2014-12-19 Thread Tim Holy
Julia's arrays grow by doubling, see 
http://en.wikipedia.org/wiki/Dynamic_array

Since you're appending elements to an array, julia has to have somewhere to 
put them---and when there's no spare capacity, julia has to allocate a new 
array and copy the entire thing. So some allocations are much bigger than what 
you're adding, but others (as you can see) are 0.

This is a marked improvement over Matlab, which makes a copy of your entire 
array each time you add 1 element.

Best,
--Tim

On Friday, December 19, 2014 10:00:28 AM John Drummond wrote:
> For the following code (julia 0.3.3 in windows 7 ) I don't understand what
> the bytes allocated in @time means
> 
> All I'm doing each time is adding 10  8 byte integers
> 
> Thanks for any thoughts
> 
> julia> @time c = [1,2]
> elapsed time: 3.32e-6 seconds (144 bytes allocated)
> 2-element Array{Int64,1}:
>  1
>  2
> 
> julia> sizeof(c)
> 16
> 
> 
> julia> @time for x in 30:39 push!(c, x) end
> elapsed time: 2.717e-6 seconds (256 bytes allocated)
> 
> julia> @time for x in 30:39 push!(c, x) end
> elapsed time: 2.717e-6 seconds (288 bytes allocated)
> 
> julia> @time for x in 30:39 push!(c, x) end
> elapsed time: 2.112e-6 seconds (0 bytes allocated)
> 
> julia> @time for x in 30:39 push!(c, x) end
> elapsed time: 3.321e-6 seconds (640 bytes allocated)
> 
> julia> sizeof(c)
> 336



[julia-users] R version of microbenchmarks

2014-12-19 Thread Douglas Bates
Perhaps the R version of the microbenchmarks could be run on Revolution R 
Open, http://mran.revolutionanalytics.com/download/. The major difference 
between RRO and other versions is that RRO incorporates MKL.  For one or 
two of the benchmarks this could make a difference.

By the way, I was also going to suggest applying the byte compiler to the 
functions being timed but I see that this has already been done.



[julia-users] Can't Define New Functors Using Numeric Extensions 0.6.2 in Julia 0.3.3

2014-12-19 Thread Michael Wojnowicz

Hi everyone,
I am an R and MATLAB user who is moving to Julia.   I am trying the Numeric 
Extensions package. In the documentation (
http://numericextensionsjl.readthedocs.org/en/latest/functors.html), they 
show an example of how to define a new functor:

type SqrDiff <: Functor{2} end

 

NumericExtensions.evaluate(::SqrDiff, x, y) = abs2(x - y)


However, when I try to apply this new functor, I get this result:

*julia> **type SqrDiff <: Functor{2} end*

*julia> **NumericExtensions.evaluate(::SqrDiff, x, y) = abs2(x - y)*

*evaluate (generic function with 143 methods)*

*julia> **x=ones(4)*5*

*julia> **y=ones(4)*2*

*julia> **map(SqrDiff(),x,y)*

*ERROR: SqrDiff not defined*

*julia> **map(NumericExtensions.SqrDiff(),x,y)*

*ERROR: SqrDiff not defined*


Any ideas about what the problem is?  I have no problem with


*julia> **map(NumericExtensions.Multiply(),x,y)*




Re: [julia-users] any clarification of bytes allocated in @time?

2014-12-19 Thread John Myles White
Are you timing things in the global scope?

 -- John

On Dec 19, 2014, at 1:00 PM, John Drummond  wrote:

> For the following code (julia 0.3.3 in windows 7 ) I don't understand what 
> the bytes allocated in @time means
> 
> All I'm doing each time is adding 10  8 byte integers
> 
> Thanks for any thoughts
> 
> julia> @time c = [1,2]
> elapsed time: 3.32e-6 seconds (144 bytes allocated)
> 2-element Array{Int64,1}:
>  1
>  2
> 
> julia> sizeof(c)
> 16
> 
> 
> julia> @time for x in 30:39 push!(c, x) end
> elapsed time: 2.717e-6 seconds (256 bytes allocated)
> 
> julia> @time for x in 30:39 push!(c, x) end
> elapsed time: 2.717e-6 seconds (288 bytes allocated)
> 
> julia> @time for x in 30:39 push!(c, x) end
> elapsed time: 2.112e-6 seconds (0 bytes allocated)
> 
> julia> @time for x in 30:39 push!(c, x) end
> elapsed time: 3.321e-6 seconds (640 bytes allocated)
> 
> julia> sizeof(c)
> 336



[julia-users] any clarification of bytes allocated in @time?

2014-12-19 Thread John Drummond
For the following code (julia 0.3.3 in windows 7 ) I don't understand what 
the bytes allocated in @time means

All I'm doing each time is adding 10  8 byte integers

Thanks for any thoughts

julia> @time c = [1,2]
elapsed time: 3.32e-6 seconds (144 bytes allocated)
2-element Array{Int64,1}:
 1
 2

julia> sizeof(c)
16


julia> @time for x in 30:39 push!(c, x) end
elapsed time: 2.717e-6 seconds (256 bytes allocated)

julia> @time for x in 30:39 push!(c, x) end
elapsed time: 2.717e-6 seconds (288 bytes allocated)

julia> @time for x in 30:39 push!(c, x) end
elapsed time: 2.112e-6 seconds (0 bytes allocated)

julia> @time for x in 30:39 push!(c, x) end
elapsed time: 3.321e-6 seconds (640 bytes allocated)

julia> sizeof(c)
336


[julia-users] Re: Security issue in Git: Update your git clients

2014-12-19 Thread Tony Kelman
What Ivar said. This isn't really a problem if you only ever clone things 
from github, but it's a better reason than usual for updating our 
dependency versions so I fixed it on master anyway. We'll be sure to 
backport it so the next bugfix release of Julia will come with updated Git 
binaries. I would have updated the OSX binaries even further to the very 
latest 2.2.1 release of Git, except that I don't have a Mac to test on and 
I don't want to accidentally break Pkg in some obscure way. Staying within 
the 1.8 branch should be relatively safe, one would think, and there was a 
maintenance release for that branch that includes the fix for this 
vulnerability.


On Friday, December 19, 2014 1:23:42 AM UTC-8, Ivar Nesje wrote:
>
> This is indeed a serious bug, but Pkg is already a system for distributing 
> and executing arbitrary code, so it does not create any additional risk in 
> our context. Pkg executes anything it finds in `deps/build.jl`, and that is 
> a known and deliberate risc we take in order for packages to be able to 
> install binary dependencies. We need to trust the package author to not put 
> malicious code in his repo. Also almost all our packages are hosted on 
> github, and they know about the problem, are blocking new attempts, and is 
> scanning its existing repos for this exploit, so if you pull repos from 
> github you should be safe.
>
> There are good reasons to upgrade and it is great that the git community 
> takes this serious, but your time is probably better spent actually 
> reviewing the code you pull from random guys github repos than to worry 
> about the ability to own your system 10 seconds earlier because you get 
> hacked when typing 
>
> > git clone
> # instead of 10 seconds later, when you type
> > make
>
> If you use git to access data, or to actually review code and diffs 
> *before* executing it, and you use OSX or Windows and a less serious git 
> host that Github, you should definitely update ASAP, but that's not a very 
> common case for Julia users of Pkg.
>
> Regards Ivar
>
> kl. 09:06:40 UTC+1 fredag 19. desember 2014 skrev Tomas Lycken følgende:
>>
>> Some of you may already have seen this, but a critical git security 
>> vulnerability has just been announced. In short, the vulnerability allows 
>> *arbitrary 
>> command execution on clients*, and affects *all case-insensitive file 
>> systems*.
>>
>> Github published a nice summary [1] with links to a whole bunch of client 
>> vendors who have released patches that fix this problem, as well as a 
>> little more details (and links to a lot more details) on what the problem 
>> was.
>>
>> I think it would be a good idea to update Julia to make sure that 
>> whatever git version Pkg uses isn't exposed, although I'm not quite sure 
>> what is required to do so.
>>
>> [1]: 
>> https://github.com/blog/1938-vulnerability-announced-update-your-git-clients
>>
>> // Tomas
>>
>

Re: [julia-users] Recompiling ast and document about "uncompressed ast"

2014-12-19 Thread Yichao Yu
On 2014年12月19日 星期五 15:03:51, Jameson Nash > wrote:
> by that same token, the AST itself is not a stable API. what's much more
> likely to change however is the ordering and contents of the fields of
> these, and any type, within Base.

Speaking of API stability, is there any official compatibility grantee? I've 
seen a thread on the -dev list about it but didn't find any official 
statement.

In general, I'm aware that these API might change in a new version and I'm 
fine with it as long as it is still possible to do what I need. I'll also 
likely to use LLVM on the remote machine to execute the program and I guess 
that has a much higher API breakage rate than julia.

> 
> .args[2] needs to be regenerated with any changes you've made anyways, so
> it's easiest to just ignore it. you could manually track all of your
> updates in there, and put together a new function object manually, but it's

Is it possible to do that? Given that evaluating the AST directly does not 
return the function definition itself. (e.g. is it possible to copy the 
closure variables as well by just manipulating some AST's?)

> probably not worthwhile. to be completely safe, I should be checking
> isempty(.args[2][3]), since it's not meaningful to copy a function that
> includes closure variables.
> 

I think it is as meaningful as copying a normal function (which is not very 
much in general) but in my case it is probably too complicated to analyse (at 
least for a start) Thanks for pointing that out...

> 
> 
> On Fri Dec 19 2014 at 9:28:49 AM Stefan Karpinski 
> 
> wrote:
> > I would add some fair warning: lowered code is not an official API.
> > Documenting it and stabilizing it would be nice, but for now any code that
> > relies on details of code lowering could be fragile.
> > 
> > On Thu, Dec 18, 2014 at 12:01 PM, Yichao Yu  wrote:
> >> Hi,
> >> 
> >> I'm wondering if there's a way to recompile the lowered AST back into a
> >> function and what additional information (other than the module it should
> >> be
> >> evaluate in) is necessary to do that what I've tried and would like to do
> >> is
> >> demonstrated with the code attached. The idea is that I would like to
> >> modify
> >> the code of a function/method before calling it (in this case, I am
> >> replacing
> >> it with the code from another function with the same signature). (In
> >> another
> >> word, the question is how to construct a function from code1 with ast2
> >> and run
> >> it.)
> >> 
> >> It will also be nice if there's more documentation on this "lowered AST"
> >> since
> >> it seems to be very different form the one you get in a function
> >> definition.
> >> (e.g. what is the array in `code_lowered(+, (Float64,
> >> Float64))[1].args[2]`
> >> mean)
> >> 
> >> A brief description of what I want to do. I'm writing a control system
> >> with
> >> dynamic logic. However, since the code might not be running on a single
> >> host,
> >> it is hard to use an existing interpreter to do what I want. Trying to
> >> avoid
> >> inventing yet another language, I hope to use a subset of an existing
> >> language
> >> and somehow transform it into a representation that can be run somewhere
> >> else
> >> and it seems that the inspection and meta programming feature in julia is
> >> very
> >> useful for this. It might be possible to just apply a macro to every
> >> function
> >> / method definition but it will be much harder to write. I would rather
> >> try to
> >> "trace" the excution and use the AST acquired at runtime. For that I
> >> would
> >> like to know more about the lowered AST and possibly how to execute a
> >> modified
> >> version in order to trace recursive / nested function calls. This might
> >> not be
> >> the best way to do it and I'm still in planning stage so any suggestions
> >> on
> >> the design is also welcome.
> >> 
> >> Cheers,
> >> 
> >> Yichao Yu


signature.asc
Description: This is a digitally signed message part.


Re: [julia-users] int

2014-12-19 Thread Hans W Borchers
Well, you are probably right. I expected them to print the same, because
*mathematically* they are the same value, and because I was used to it.

Sorry for the noise.

On Friday, December 19, 2014 4:23:57 PM UTC+1, Tamas Papp wrote:
>
> I don't know why you expect them to print the same, when they are not 
> the same value. 
>
> -0.0 is a Float64, so IEEE arithmetic applies and sqrt(-0.0) is -0.0. 
>
> sqrt(-0) is equal to sqrt(0), because 0 is an Int64 so it is negated 
> first. 
>
> Best, 
>
> Tamas 
>
>
>

Re: [julia-users] int

2014-12-19 Thread Tamas Papp
I don't know why you expect them to print the same, when they are not
the same value.

-0.0 is a Float64, so IEEE arithmetic applies and sqrt(-0.0) is -0.0.

sqrt(-0) is equal to sqrt(0), because 0 is an Int64 so it is negated
first.

Best,

Tamas



On Fri, Dec 19 2014, Hans W Borchers  wrote:

> Oh, you're right. I was afraid my remembrance would not be right.
> I'm not so happy that -0.0 is not printed as -0.0 because mathematically
> there is no difference, and the Julia community puts much emphasis on this.
>
> And especially I feel uneasy with these returns:
>
> julia> sign(-0.0)
> -0.0
>
> julia> sqrt(-0)
> 0.0
>
> where `sqrt(-0.0)` and `sqrt(-0)` should print the same?
>
>
> On Friday, December 19, 2014 3:52:46 PM UTC+1, Tamas Papp wrote:
>>
>> Nope, as far as I can see Julia is IEEE-compliant. So is R, under the
>> hood, it just does not display signed zeros as such. I prefer that Julia
>> does it.
>>
>> Best,
>>
>> Tamas
>>
>> On Fri, Dec 19 2014, Stefan Karpinski >
>> wrote:
>>
>> > So is there anything here we're not doing correctly?
>> >
>> > On Fri, Dec 19, 2014 at 7:54 AM, Tamas Papp > > wrote:
>> >
>> >> On Fri, Dec 19 2014, Hans W Borchers >
>> wrote:
>> >>
>> >> > The expression -0.0 means the floating point number that in memory
>> has
>> >> the
>> >> > same
>> >> > bit representation as 0.0, but the sign bit set to 1. One can see
>> this
>> >> > applying
>> >> > the 'bits' function to 0.0 and -0.0.
>> >> >
>> >> > I seem to remember that the IEEE floating point convention says that
>> for
>> >> > `sqrt(-0.0)` the sign bit has to be reset, so that
>> >> >
>> >> > julia> sqrt(-0.0)
>> >> > -0.0
>> >> >
>> >> > would be wrong while MATLAB, R,... returning 0.0 are correct.
>> >>
>> >> I don't think so. Section 6.3 of the IEEE Std 754TM-2008 says that
>> >>
>> >> "Except that squareRoot(−0) shall be −0, every numeric squareRoot
>> result
>> >> shall have a positive sign.
>> >>
>> >> Furthermore, you can't rely on R to display the sign bit, eg
>> >>
>> >> > 1/(-Inf)
>> >> [1] 0
>> >>
>> >> Best,
>> >>
>> >> Tamas
>> >>
>> >>
>> >> > The expression -0.0 means the floating point number that in memory
>> has
>> >> the
>> >> > same
>> >> > bit representation as 0.0, but the sign bit set to 1. One can see
>> this
>> >> > applying
>> >> > the 'bits' function to 0.0 and -0.0.
>> >> >
>> >> > I seem to remember that the IEEE floating point convention says that
>> for
>> >> > `sqrt(-0.0)` the sign bit has to be reset, so that
>> >> >
>> >> > julia> sqrt(-0.0)
>> >> > -0.0
>> >> >
>> >> > would be wrong while MATLAB, R,... returning 0.0 are correct.
>> >> >
>> >> > For `1/-Inf` the sign bit is not reset because this expression should
>> be
>> >> > the
>> >> > limit of 1/-x for very large numbers x, i.e. approaching 0 from left.
>> >> >
>> >> >
>> >> > On Friday, December 19, 2014 12:13:57 PM UTC+1, Tamas Papp wrote:
>> >> >>
>> >> >> Hmmm, did you read the whole blog post, including the update at the
>> end?
>> >> >> Julia does handle signed zeroes correctly when working with floats.
>> >> >>
>> >> >> As to what signed zeros "mean" -- they have some applications,
>> including
>> >> >> indicating the direction of underflow. Probably you don't need to
>> worry
>> >> >> about them much since 0.0 == -0.0 (unless you specifically want to
>> use
>> >> >> them).
>> >> >>
>> >> >> I usually think about -0.0 as equivalent to 0.0 except for +, -, *,
>> and
>> >> >> /, especially when Inf is involved. Thinking about it as some limit
>> is
>> >> >> not very intuitive for IEEE floats, eg
>> >> >>
>> >> >> julia> log(-0.0)
>> >> >> -Inf
>> >> >>
>> >> >> julia> sqrt(-0.0)
>> >> >> -0.0
>> >> >>
>> >> >> all of which are correct IEEE.
>> >> >>
>> >> >> Best,
>> >> >>
>> >> >> Tamas
>> >> >>
>> >> >>
>> >> >> On Fri, Dec 19 2014, cdm > wrote:
>> >> >>
>> >> >> > i stumbled across a post and got to wondering what Julians thought
>> of
>> >> it
>> >> >> ...
>> >> >> >
>> >> >> >   http://www.walkingrandomly.com/?p=5152
>> >> >> >
>> >> >> >
>> >> >> > the author presents the case that Python is not IEEE compliant,
>> but
>> >> >> > MATLAB is and Julia is close:
>> >> >> >
>> >> >> > "From the wikipedia page on Division by Zero
>> >> >> > : *“The IEEE 754
>> >> >> > standard specifies that every floating point arithmetic operation,
>> >> >> > including division by zero, has a well-defined result”.*
>> >> >> >
>> >> >> >
>> >> >> > the author reports that in Julia
>> >> >> >
>> >> >> > julia> 1/(-0)
>> >> >> > Inf
>> >> >> >
>> >> >> >
>> >> >> > but MATLAB "correctly" returns -Inf ...
>> >> >> >
>> >> >> >
>> >> >> > i am not sure that signed zero (-0)
>> >> >> > means anything to me ...
>> >> >> >
>> >> >> > should it?
>> >> >> >
>> >> >> > many thanks,
>> >> >> >
>> >> >> > cdm
>> >> >>
>> >>
>>


Re: [julia-users] int

2014-12-19 Thread Milan Bouchet-Valat
Le vendredi 19 décembre 2014 à 07:11 -0800, Hans W Borchers a écrit :
> Oh, you're right. I was afraid my remembrance would not be right.
> I'm not so happy that -0.0 is not printed as -0.0 because
> mathematically
> there is no difference, and the Julia community puts much emphasis on
> this.
Given that 0.0 and -0.0 can be distinguished and do not always give the
same result (as shown in this thread), it makes sense to print them
differently. The opposite behavior would be terribly confusing.

> And especially I feel uneasy with these returns:
> 
> 
> julia> sign(-0.0)
> -0.0
> 
> 
> julia> sqrt(-0)
> 0.0
> 
> 
> where `sqrt(-0.0)` and `sqrt(-0)` should print the same?
No, because they're not the same. The second one is equivalent to
`sqrt(0)`, as -0 is stricly equal to 0 (there is no negative zero for
integers). Same for `sign()`.


Regards

> On Friday, December 19, 2014 3:52:46 PM UTC+1, Tamas Papp wrote:
> Nope, as far as I can see Julia is IEEE-compliant. So is R,
> under the 
> hood, it just does not display signed zeros as such. I prefer
> that Julia 
> does it. 
> 
> Best, 
> 
> Tamas 
> 
> On Fri, Dec 19 2014, Stefan Karpinski 
> wrote: 
> 
> > So is there anything here we're not doing correctly? 
> > 
> > On Fri, Dec 19, 2014 at 7:54 AM, Tamas Papp
>  wrote: 
> > 
> >> On Fri, Dec 19 2014, Hans W Borchers 
> wrote: 
> >> 
> >> > The expression -0.0 means the floating point number that
> in memory has 
> >> the 
> >> > same 
> >> > bit representation as 0.0, but the sign bit set to 1. One
> can see this 
> >> > applying 
> >> > the 'bits' function to 0.0 and -0.0. 
> >> > 
> >> > I seem to remember that the IEEE floating point
> convention says that for 
> >> > `sqrt(-0.0)` the sign bit has to be reset, so that 
> >> > 
> >> > julia> sqrt(-0.0) 
> >> > -0.0 
> >> > 
> >> > would be wrong while MATLAB, R,... returning 0.0 are
> correct. 
> >> 
> >> I don't think so. Section 6.3 of the IEEE Std 754TM-2008
> says that 
> >> 
> >> "Except that squareRoot(−0) shall be −0, every numeric
> squareRoot result 
> >> shall have a positive sign. 
> >> 
> >> Furthermore, you can't rely on R to display the sign bit,
> eg 
> >> 
> >> > 1/(-Inf) 
> >> [1] 0 
> >> 
> >> Best, 
> >> 
> >> Tamas 
> >> 
> >> 
> >> > The expression -0.0 means the floating point number that
> in memory has 
> >> the 
> >> > same 
> >> > bit representation as 0.0, but the sign bit set to 1. One
> can see this 
> >> > applying 
> >> > the 'bits' function to 0.0 and -0.0. 
> >> > 
> >> > I seem to remember that the IEEE floating point
> convention says that for 
> >> > `sqrt(-0.0)` the sign bit has to be reset, so that 
> >> > 
> >> > julia> sqrt(-0.0) 
> >> > -0.0 
> >> > 
> >> > would be wrong while MATLAB, R,... returning 0.0 are
> correct. 
> >> > 
> >> > For `1/-Inf` the sign bit is not reset because this
> expression should be 
> >> > the 
> >> > limit of 1/-x for very large numbers x, i.e. approaching
> 0 from left. 
> >> > 
> >> > 
> >> > On Friday, December 19, 2014 12:13:57 PM UTC+1, Tamas
> Papp wrote: 
> >> >> 
> >> >> Hmmm, did you read the whole blog post, including the
> update at the end? 
> >> >> Julia does handle signed zeroes correctly when working
> with floats. 
> >> >> 
> >> >> As to what signed zeros "mean" -- they have some
> applications, including 
> >> >> indicating the direction of underflow. Probably you
> don't need to worry 
> >> >> about them much since 0.0 == -0.0 (unless you
> specifically want to use 
> >> >> them). 
> >> >> 
> >> >> I usually think about -0.0 as equivalent to 0.0 except
> for +, -, *, and 
> >> >> /, especially when Inf is involved. Thinking about it as
> some limit is 
> >> >> not very intuitive for IEEE floats, eg 
> >> >> 
> >> >> julia> log(-0.0) 
> >> >> -Inf 
> >> >> 
> >> >> julia> sqrt(-0.0) 
> >> >> -0.0 
> >> >> 
> >> >> all of which are correct IEEE. 
> >> >> 
> >> >> Best, 
> >> >> 
> >> >> Tamas 
> >> >> 
> >> >> 
> >> >> On Fri, Dec 19 2014, cdm  > wrote: 
> >> >> 
> >> >> > 

[julia-users] Re: home page content

2014-12-19 Thread Ivar Nesje
kl. 13:01:36 UTC+1 fredag 19. desember 2014 skrev Bas Dirks følgende:
>
> Where do I send my technical (front-end) suggestions?
>

For simple changes a Pull Request at 
https://github.com/JuliaLang/julialang.github.com would be great. For more 
drastic changes it's probably a good idea to open an issue for discussion 
first.



Re: [julia-users] int

2014-12-19 Thread Hans W Borchers
Oh, you're right. I was afraid my remembrance would not be right.
I'm not so happy that -0.0 is not printed as -0.0 because mathematically
there is no difference, and the Julia community puts much emphasis on this.

And especially I feel uneasy with these returns:

julia> sign(-0.0)
-0.0

julia> sqrt(-0)
0.0

where `sqrt(-0.0)` and `sqrt(-0)` should print the same?


On Friday, December 19, 2014 3:52:46 PM UTC+1, Tamas Papp wrote:
>
> Nope, as far as I can see Julia is IEEE-compliant. So is R, under the 
> hood, it just does not display signed zeros as such. I prefer that Julia 
> does it. 
>
> Best, 
>
> Tamas 
>
> On Fri, Dec 19 2014, Stefan Karpinski > 
> wrote: 
>
> > So is there anything here we're not doing correctly? 
> > 
> > On Fri, Dec 19, 2014 at 7:54 AM, Tamas Papp  > wrote: 
> > 
> >> On Fri, Dec 19 2014, Hans W Borchers > 
> wrote: 
> >> 
> >> > The expression -0.0 means the floating point number that in memory 
> has 
> >> the 
> >> > same 
> >> > bit representation as 0.0, but the sign bit set to 1. One can see 
> this 
> >> > applying 
> >> > the 'bits' function to 0.0 and -0.0. 
> >> > 
> >> > I seem to remember that the IEEE floating point convention says that 
> for 
> >> > `sqrt(-0.0)` the sign bit has to be reset, so that 
> >> > 
> >> > julia> sqrt(-0.0) 
> >> > -0.0 
> >> > 
> >> > would be wrong while MATLAB, R,... returning 0.0 are correct. 
> >> 
> >> I don't think so. Section 6.3 of the IEEE Std 754TM-2008 says that 
> >> 
> >> "Except that squareRoot(−0) shall be −0, every numeric squareRoot 
> result 
> >> shall have a positive sign. 
> >> 
> >> Furthermore, you can't rely on R to display the sign bit, eg 
> >> 
> >> > 1/(-Inf) 
> >> [1] 0 
> >> 
> >> Best, 
> >> 
> >> Tamas 
> >> 
> >> 
> >> > The expression -0.0 means the floating point number that in memory 
> has 
> >> the 
> >> > same 
> >> > bit representation as 0.0, but the sign bit set to 1. One can see 
> this 
> >> > applying 
> >> > the 'bits' function to 0.0 and -0.0. 
> >> > 
> >> > I seem to remember that the IEEE floating point convention says that 
> for 
> >> > `sqrt(-0.0)` the sign bit has to be reset, so that 
> >> > 
> >> > julia> sqrt(-0.0) 
> >> > -0.0 
> >> > 
> >> > would be wrong while MATLAB, R,... returning 0.0 are correct. 
> >> > 
> >> > For `1/-Inf` the sign bit is not reset because this expression should 
> be 
> >> > the 
> >> > limit of 1/-x for very large numbers x, i.e. approaching 0 from left. 
> >> > 
> >> > 
> >> > On Friday, December 19, 2014 12:13:57 PM UTC+1, Tamas Papp wrote: 
> >> >> 
> >> >> Hmmm, did you read the whole blog post, including the update at the 
> end? 
> >> >> Julia does handle signed zeroes correctly when working with floats. 
> >> >> 
> >> >> As to what signed zeros "mean" -- they have some applications, 
> including 
> >> >> indicating the direction of underflow. Probably you don't need to 
> worry 
> >> >> about them much since 0.0 == -0.0 (unless you specifically want to 
> use 
> >> >> them). 
> >> >> 
> >> >> I usually think about -0.0 as equivalent to 0.0 except for +, -, *, 
> and 
> >> >> /, especially when Inf is involved. Thinking about it as some limit 
> is 
> >> >> not very intuitive for IEEE floats, eg 
> >> >> 
> >> >> julia> log(-0.0) 
> >> >> -Inf 
> >> >> 
> >> >> julia> sqrt(-0.0) 
> >> >> -0.0 
> >> >> 
> >> >> all of which are correct IEEE. 
> >> >> 
> >> >> Best, 
> >> >> 
> >> >> Tamas 
> >> >> 
> >> >> 
> >> >> On Fri, Dec 19 2014, cdm > wrote: 
> >> >> 
> >> >> > i stumbled across a post and got to wondering what Julians thought 
> of 
> >> it 
> >> >> ... 
> >> >> > 
> >> >> >   http://www.walkingrandomly.com/?p=5152 
> >> >> > 
> >> >> > 
> >> >> > the author presents the case that Python is not IEEE compliant, 
> but 
> >> >> > MATLAB is and Julia is close: 
> >> >> > 
> >> >> > "From the wikipedia page on Division by Zero 
> >> >> > : *“The IEEE 754 
> >> >> > standard specifies that every floating point arithmetic operation, 
> >> >> > including division by zero, has a well-defined result”.* 
> >> >> > 
> >> >> > 
> >> >> > the author reports that in Julia 
> >> >> > 
> >> >> > julia> 1/(-0) 
> >> >> > Inf 
> >> >> > 
> >> >> > 
> >> >> > but MATLAB "correctly" returns -Inf ... 
> >> >> > 
> >> >> > 
> >> >> > i am not sure that signed zero (-0) 
> >> >> > means anything to me ... 
> >> >> > 
> >> >> > should it? 
> >> >> > 
> >> >> > many thanks, 
> >> >> > 
> >> >> > cdm 
> >> >> 
> >> 
>


Re: [julia-users] Recompiling ast and document about "uncompressed ast"

2014-12-19 Thread Jameson Nash
by that same token, the AST itself is not a stable API. what's much more
likely to change however is the ordering and contents of the fields of
these, and any type, within Base.

.args[2] needs to be regenerated with any changes you've made anyways, so
it's easiest to just ignore it. you could manually track all of your
updates in there, and put together a new function object manually, but it's
probably not worthwhile. to be completely safe, I should be checking
isempty(.args[2][3]), since it's not meaningful to copy a function that
includes closure variables.



On Fri Dec 19 2014 at 9:28:49 AM Stefan Karpinski 
wrote:

> I would add some fair warning: lowered code is not an official API.
> Documenting it and stabilizing it would be nice, but for now any code that
> relies on details of code lowering could be fragile.
>
>
>
> On Thu, Dec 18, 2014 at 12:01 PM, Yichao Yu  wrote:
>
>> Hi,
>>
>> I'm wondering if there's a way to recompile the lowered AST back into a
>> function and what additional information (other than the module it should
>> be
>> evaluate in) is necessary to do that what I've tried and would like to do
>> is
>> demonstrated with the code attached. The idea is that I would like to
>> modify
>> the code of a function/method before calling it (in this case, I am
>> replacing
>> it with the code from another function with the same signature). (In
>> another
>> word, the question is how to construct a function from code1 with ast2
>> and run
>> it.)
>>
>> It will also be nice if there's more documentation on this "lowered AST"
>> since
>> it seems to be very different form the one you get in a function
>> definition.
>> (e.g. what is the array in `code_lowered(+, (Float64,
>> Float64))[1].args[2]`
>> mean)
>>
>> A brief description of what I want to do. I'm writing a control system
>> with
>> dynamic logic. However, since the code might not be running on a single
>> host,
>> it is hard to use an existing interpreter to do what I want. Trying to
>> avoid
>> inventing yet another language, I hope to use a subset of an existing
>> language
>> and somehow transform it into a representation that can be run somewhere
>> else
>> and it seems that the inspection and meta programming feature in julia is
>> very
>> useful for this. It might be possible to just apply a macro to every
>> function
>> / method definition but it will be much harder to write. I would rather
>> try to
>> "trace" the excution and use the AST acquired at runtime. For that I would
>> like to know more about the lowered AST and possibly how to execute a
>> modified
>> version in order to trace recursive / nested function calls. This might
>> not be
>> the best way to do it and I'm still in planning stage so any suggestions
>> on
>> the design is also welcome.
>>
>> Cheers,
>>
>> Yichao Yu
>>
>
>


Re: [julia-users] int

2014-12-19 Thread Tamas Papp
Nope, as far as I can see Julia is IEEE-compliant. So is R, under the
hood, it just does not display signed zeros as such. I prefer that Julia
does it.

Best,

Tamas

On Fri, Dec 19 2014, Stefan Karpinski  wrote:

> So is there anything here we're not doing correctly?
>
> On Fri, Dec 19, 2014 at 7:54 AM, Tamas Papp  wrote:
>
>> On Fri, Dec 19 2014, Hans W Borchers  wrote:
>>
>> > The expression -0.0 means the floating point number that in memory has
>> the
>> > same
>> > bit representation as 0.0, but the sign bit set to 1. One can see this
>> > applying
>> > the 'bits' function to 0.0 and -0.0.
>> >
>> > I seem to remember that the IEEE floating point convention says that for
>> > `sqrt(-0.0)` the sign bit has to be reset, so that
>> >
>> > julia> sqrt(-0.0)
>> > -0.0
>> >
>> > would be wrong while MATLAB, R,... returning 0.0 are correct.
>>
>> I don't think so. Section 6.3 of the IEEE Std 754TM-2008 says that
>>
>> "Except that squareRoot(−0) shall be −0, every numeric squareRoot result
>> shall have a positive sign.
>>
>> Furthermore, you can't rely on R to display the sign bit, eg
>>
>> > 1/(-Inf)
>> [1] 0
>>
>> Best,
>>
>> Tamas
>>
>>
>> > The expression -0.0 means the floating point number that in memory has
>> the
>> > same
>> > bit representation as 0.0, but the sign bit set to 1. One can see this
>> > applying
>> > the 'bits' function to 0.0 and -0.0.
>> >
>> > I seem to remember that the IEEE floating point convention says that for
>> > `sqrt(-0.0)` the sign bit has to be reset, so that
>> >
>> > julia> sqrt(-0.0)
>> > -0.0
>> >
>> > would be wrong while MATLAB, R,... returning 0.0 are correct.
>> >
>> > For `1/-Inf` the sign bit is not reset because this expression should be
>> > the
>> > limit of 1/-x for very large numbers x, i.e. approaching 0 from left.
>> >
>> >
>> > On Friday, December 19, 2014 12:13:57 PM UTC+1, Tamas Papp wrote:
>> >>
>> >> Hmmm, did you read the whole blog post, including the update at the end?
>> >> Julia does handle signed zeroes correctly when working with floats.
>> >>
>> >> As to what signed zeros "mean" -- they have some applications, including
>> >> indicating the direction of underflow. Probably you don't need to worry
>> >> about them much since 0.0 == -0.0 (unless you specifically want to use
>> >> them).
>> >>
>> >> I usually think about -0.0 as equivalent to 0.0 except for +, -, *, and
>> >> /, especially when Inf is involved. Thinking about it as some limit is
>> >> not very intuitive for IEEE floats, eg
>> >>
>> >> julia> log(-0.0)
>> >> -Inf
>> >>
>> >> julia> sqrt(-0.0)
>> >> -0.0
>> >>
>> >> all of which are correct IEEE.
>> >>
>> >> Best,
>> >>
>> >> Tamas
>> >>
>> >>
>> >> On Fri, Dec 19 2014, cdm > wrote:
>> >>
>> >> > i stumbled across a post and got to wondering what Julians thought of
>> it
>> >> ...
>> >> >
>> >> >   http://www.walkingrandomly.com/?p=5152
>> >> >
>> >> >
>> >> > the author presents the case that Python is not IEEE compliant, but
>> >> > MATLAB is and Julia is close:
>> >> >
>> >> > "From the wikipedia page on Division by Zero
>> >> > : *“The IEEE 754
>> >> > standard specifies that every floating point arithmetic operation,
>> >> > including division by zero, has a well-defined result”.*
>> >> >
>> >> >
>> >> > the author reports that in Julia
>> >> >
>> >> > julia> 1/(-0)
>> >> > Inf
>> >> >
>> >> >
>> >> > but MATLAB "correctly" returns -Inf ...
>> >> >
>> >> >
>> >> > i am not sure that signed zero (-0)
>> >> > means anything to me ...
>> >> >
>> >> > should it?
>> >> >
>> >> > many thanks,
>> >> >
>> >> > cdm
>> >>
>>


Re: [julia-users] int

2014-12-19 Thread Stefan Karpinski
So is there anything here we're not doing correctly?

On Fri, Dec 19, 2014 at 7:54 AM, Tamas Papp  wrote:

> On Fri, Dec 19 2014, Hans W Borchers  wrote:
>
> > The expression -0.0 means the floating point number that in memory has
> the
> > same
> > bit representation as 0.0, but the sign bit set to 1. One can see this
> > applying
> > the 'bits' function to 0.0 and -0.0.
> >
> > I seem to remember that the IEEE floating point convention says that for
> > `sqrt(-0.0)` the sign bit has to be reset, so that
> >
> > julia> sqrt(-0.0)
> > -0.0
> >
> > would be wrong while MATLAB, R,... returning 0.0 are correct.
>
> I don't think so. Section 6.3 of the IEEE Std 754TM-2008 says that
>
> "Except that squareRoot(−0) shall be −0, every numeric squareRoot result
> shall have a positive sign.
>
> Furthermore, you can't rely on R to display the sign bit, eg
>
> > 1/(-Inf)
> [1] 0
>
> Best,
>
> Tamas
>
>
> > The expression -0.0 means the floating point number that in memory has
> the
> > same
> > bit representation as 0.0, but the sign bit set to 1. One can see this
> > applying
> > the 'bits' function to 0.0 and -0.0.
> >
> > I seem to remember that the IEEE floating point convention says that for
> > `sqrt(-0.0)` the sign bit has to be reset, so that
> >
> > julia> sqrt(-0.0)
> > -0.0
> >
> > would be wrong while MATLAB, R,... returning 0.0 are correct.
> >
> > For `1/-Inf` the sign bit is not reset because this expression should be
> > the
> > limit of 1/-x for very large numbers x, i.e. approaching 0 from left.
> >
> >
> > On Friday, December 19, 2014 12:13:57 PM UTC+1, Tamas Papp wrote:
> >>
> >> Hmmm, did you read the whole blog post, including the update at the end?
> >> Julia does handle signed zeroes correctly when working with floats.
> >>
> >> As to what signed zeros "mean" -- they have some applications, including
> >> indicating the direction of underflow. Probably you don't need to worry
> >> about them much since 0.0 == -0.0 (unless you specifically want to use
> >> them).
> >>
> >> I usually think about -0.0 as equivalent to 0.0 except for +, -, *, and
> >> /, especially when Inf is involved. Thinking about it as some limit is
> >> not very intuitive for IEEE floats, eg
> >>
> >> julia> log(-0.0)
> >> -Inf
> >>
> >> julia> sqrt(-0.0)
> >> -0.0
> >>
> >> all of which are correct IEEE.
> >>
> >> Best,
> >>
> >> Tamas
> >>
> >>
> >> On Fri, Dec 19 2014, cdm > wrote:
> >>
> >> > i stumbled across a post and got to wondering what Julians thought of
> it
> >> ...
> >> >
> >> >   http://www.walkingrandomly.com/?p=5152
> >> >
> >> >
> >> > the author presents the case that Python is not IEEE compliant, but
> >> > MATLAB is and Julia is close:
> >> >
> >> > "From the wikipedia page on Division by Zero
> >> > : *“The IEEE 754
> >> > standard specifies that every floating point arithmetic operation,
> >> > including division by zero, has a well-defined result”.*
> >> >
> >> >
> >> > the author reports that in Julia
> >> >
> >> > julia> 1/(-0)
> >> > Inf
> >> >
> >> >
> >> > but MATLAB "correctly" returns -Inf ...
> >> >
> >> >
> >> > i am not sure that signed zero (-0)
> >> > means anything to me ...
> >> >
> >> > should it?
> >> >
> >> > many thanks,
> >> >
> >> > cdm
> >>
>


Re: [julia-users] Recompiling ast and document about "uncompressed ast"

2014-12-19 Thread Stefan Karpinski
I would add some fair warning: lowered code is not an official API.
Documenting it and stabilizing it would be nice, but for now any code that
relies on details of code lowering could be fragile.



On Thu, Dec 18, 2014 at 12:01 PM, Yichao Yu  wrote:

> Hi,
>
> I'm wondering if there's a way to recompile the lowered AST back into a
> function and what additional information (other than the module it should
> be
> evaluate in) is necessary to do that what I've tried and would like to do
> is
> demonstrated with the code attached. The idea is that I would like to
> modify
> the code of a function/method before calling it (in this case, I am
> replacing
> it with the code from another function with the same signature). (In
> another
> word, the question is how to construct a function from code1 with ast2 and
> run
> it.)
>
> It will also be nice if there's more documentation on this "lowered AST"
> since
> it seems to be very different form the one you get in a function
> definition.
> (e.g. what is the array in `code_lowered(+, (Float64, Float64))[1].args[2]`
> mean)
>
> A brief description of what I want to do. I'm writing a control system with
> dynamic logic. However, since the code might not be running on a single
> host,
> it is hard to use an existing interpreter to do what I want. Trying to
> avoid
> inventing yet another language, I hope to use a subset of an existing
> language
> and somehow transform it into a representation that can be run somewhere
> else
> and it seems that the inspection and meta programming feature in julia is
> very
> useful for this. It might be possible to just apply a macro to every
> function
> / method definition but it will be much harder to write. I would rather
> try to
> "trace" the excution and use the AST acquired at runtime. For that I would
> like to know more about the lowered AST and possibly how to execute a
> modified
> version in order to trace recursive / nested function calls. This might
> not be
> the best way to do it and I'm still in planning stage so any suggestions on
> the design is also welcome.
>
> Cheers,
>
> Yichao Yu
>


[julia-users] Re: home page content

2014-12-19 Thread Bas Dirks
Where do I send my technical (front-end) suggestions?

Greetings,
Bas

On Tuesday, December 9, 2014 11:23:26 PM UTC+1, Stefan Karpinski wrote:
>
> We're looking to redesign the JuliaLang.org home page and try to give it a 
> little more focus than it currently has. Which raises the question of what 
> to focus on. We could certainly have better code examples and maybe 
> highlight features of the language and its ecosystem better. What do people 
> think we should include?
>


Re: [julia-users] Recompiling ast and document about "uncompressed ast"

2014-12-19 Thread Yichao Yu
On 2014年12月19日 星期五 04:38:50, Jameson Nash  
wrote:
> The lowered AST is what you get when you call expand on any other AST. It
> is a simplified format that is easier to analyze, type-infer, and execute.
> However, it is still a regular AST object, so you can modify it and
> recreate another function with it just like the pre-expanded version (in
> fact, this is what inference.jl does). The first few arrays in the lambda
> provide information to the compiler. The first is the argument list. The
> next is a list of (local variables list, variable info, captured variable
> list)

So does it mean that .args[2] of the AST can be ignored when recompiling the 
function and it will be automatically generated again (which I assume is what 
you did below)? I guess what confuses me is that I've tried to just eval the 
AST but it basically constructs a function that returnes the "useless" 
args[2].

```
julia> eval(Base.uncompressed_ast((() -> ()).code))()
3-element Array{Any,1}:
 Any[]
 Any[]
 Any[]
```

> 
> The problem with your code is that you are trying to mutate internal
> compiler state, and it has no idea that you are trying to do so. It has
> already optimized the call for that function, and no longer cares about the
> code.ast field for that lambda. What you really want is a new function
> entirely:

I C.

> 
> julia> function recompile(func1, func2, args)
>code1 = get_code(func1, args)
>code2 = get_code(func2, args)
> 
>@assert code1.module == code2.module
> 
>eval_code1 = code1.module.eval(code1)
>eval_res1 = eval_code1(args...)
>@assert eval_res1 == func1(args...)
>println("eval_code: $(eval_res1)")
> 
>eval_code2 = code2.module.eval(code2)
>eval_res2 = eval_code2(args...)
>@assert eval_res2 == func2(args...)
>println("eval_code: $(eval_res2)")
> 
>ast1 = ccall(:jl_uncompress_ast, Any, (Any, Any), code1,
> code1.ast) println("ast1: $(ast1.args[3])")
> 
>ast2 = ccall(:jl_uncompress_ast, Any, (Any, Any), code2,
> code2.ast)
> 
>code3 = Expr(:function, Expr(:tuple, ast2.args[1]...),
> Expr(:block, ast2.args[3].args...))
> # what did we construct? how does it compare to `:(
> function(a,b) a+b end )|>dump`?
> # dump(code3); Meta.show_sexpr(code3); println()
>eval_new_code = code1.module.eval(code3)
>eval_new_res = eval_new_code(args...)
> 
>@assert eval_new_res == func2(args...)
>println("eval_new_code: $(eval_new_res)")
>end
> recompile (generic function with 1 method)
> 
> julia> recompile(+, -, (1.2, 3.4))
> eval_code: 4.6
> eval_code: -2.2
> ast1: begin  # float.jl, line 192:
> return box(Float64,sub_float(unbox(Float64,x),unbox(Float64,y)))
> end
> Expr
>   head: Symbol function
>   args: Array(Any,(2,))
> 1: Expr
>   head: Symbol tuple
>   args: Array(Any,(2,))
> 1: Symbol x
> 2: Symbol y
>   typ: Any
> 2: Expr
>   head: Symbol block
>   args: Array(Any,(2,))
> 1: Expr
>   head: Symbol line
>   args: Array(Any,(2,))
>   typ: Any
> 2: Expr
>   head: Symbol return
>   args: Array(Any,(1,))
>   typ: Any
>   typ: Any
>   typ: Any
> (:function, (:tuple, :x, :y), (:block,
> (:line, 192, symbol("float.jl")),
> (:return, (:call, :box, :Float64, (:call, :sub_float, (:call,
> 
> :unbox, :Float64, :x), (:call, :unbox, :Float64, :y
> 
>   ))
> eval_new_code: -2.2

Thank you very  much.

Yichao Yu

> 
> On Thu Dec 18 2014 at 1:14:32 PM Yichao Yu  wrote:
> 
> Hi,
> 
> > I'm wondering if there's a way to recompile the lowered AST back into a
> > function and what additional information (other than the module it should
> > be
> > evaluate in) is necessary to do that what I've tried and would like to do
> > is
> > demonstrated with the code attached. The idea is that I would like to
> > modify
> > the code of a function/method before calling it (in this case, I am
> > replacing
> > it with the code from another function with the same signature). (In
> > another
> > word, the question is how to construct a function from code1 with ast2 and
> > run
> > it.)
> > 
> > It will also be nice if there's more documentation on this "lowered AST"
> > since
> > it seems to be very different form the one you get in a function
> > definition.
> > (e.g. what is the array in `code_lowered(+, (Float64,
> > Float64))[1].args[2]`
> > mean)
> > 
> > A brief description of what I want to do. I'm writing a control system
> > with
> > dynamic logic. However, since the code might not be running on a single
> > host,
> > it is hard to use an existing interpreter to do what I want. Trying to
> > avoid
> > inventing yet another language, I hope to use a subset of an existing
> > language
> > and somehow transform it into a representation that can be run somewhere
> > else
> > and it 

Re: [julia-users] int

2014-12-19 Thread Tamas Papp
On Fri, Dec 19 2014, Hans W Borchers  wrote:

> The expression -0.0 means the floating point number that in memory has the
> same
> bit representation as 0.0, but the sign bit set to 1. One can see this
> applying
> the 'bits' function to 0.0 and -0.0.
>
> I seem to remember that the IEEE floating point convention says that for
> `sqrt(-0.0)` the sign bit has to be reset, so that
>
> julia> sqrt(-0.0)
> -0.0
>
> would be wrong while MATLAB, R,... returning 0.0 are correct.

I don't think so. Section 6.3 of the IEEE Std 754TM-2008 says that

"Except that squareRoot(−0) shall be −0, every numeric squareRoot result
shall have a positive sign.

Furthermore, you can't rely on R to display the sign bit, eg

> 1/(-Inf)
[1] 0

Best,

Tamas


> The expression -0.0 means the floating point number that in memory has the
> same
> bit representation as 0.0, but the sign bit set to 1. One can see this
> applying
> the 'bits' function to 0.0 and -0.0.
>
> I seem to remember that the IEEE floating point convention says that for
> `sqrt(-0.0)` the sign bit has to be reset, so that
>
> julia> sqrt(-0.0)
> -0.0
>
> would be wrong while MATLAB, R,... returning 0.0 are correct.
>
> For `1/-Inf` the sign bit is not reset because this expression should be
> the
> limit of 1/-x for very large numbers x, i.e. approaching 0 from left.
>
>
> On Friday, December 19, 2014 12:13:57 PM UTC+1, Tamas Papp wrote:
>>
>> Hmmm, did you read the whole blog post, including the update at the end?
>> Julia does handle signed zeroes correctly when working with floats.
>>
>> As to what signed zeros "mean" -- they have some applications, including
>> indicating the direction of underflow. Probably you don't need to worry
>> about them much since 0.0 == -0.0 (unless you specifically want to use
>> them).
>>
>> I usually think about -0.0 as equivalent to 0.0 except for +, -, *, and
>> /, especially when Inf is involved. Thinking about it as some limit is
>> not very intuitive for IEEE floats, eg
>>
>> julia> log(-0.0)
>> -Inf
>>
>> julia> sqrt(-0.0)
>> -0.0
>>
>> all of which are correct IEEE.
>>
>> Best,
>>
>> Tamas
>>
>>
>> On Fri, Dec 19 2014, cdm > wrote:
>>
>> > i stumbled across a post and got to wondering what Julians thought of it
>> ...
>> >
>> >   http://www.walkingrandomly.com/?p=5152
>> >
>> >
>> > the author presents the case that Python is not IEEE compliant, but
>> > MATLAB is and Julia is close:
>> >
>> > "From the wikipedia page on Division by Zero
>> > : *“The IEEE 754
>> > standard specifies that every floating point arithmetic operation,
>> > including division by zero, has a well-defined result”.*
>> >
>> >
>> > the author reports that in Julia
>> >
>> > julia> 1/(-0)
>> > Inf
>> >
>> >
>> > but MATLAB "correctly" returns -Inf ...
>> >
>> >
>> > i am not sure that signed zero (-0)
>> > means anything to me ...
>> >
>> > should it?
>> >
>> > many thanks,
>> >
>> > cdm
>>


Re: [julia-users] Random Draw from Gaussian Mixture

2014-12-19 Thread Andreas Noack
Hi Bradley

I was able to construct an GMM instance with

julia> Σnew =
Triangular{Float64,Matrix{Float64},:U,false}[chol(sigma[:,:,i], :U) for i =
1:2]

julia> GMM(p, mu, Σnew, [], 0)
GMM{Float64} with 2 components in 2 dimensions and full covariance
Mix 1: weight 0.90
mean: 1x2 Array{Float64,2}:
 0.0  25.0
covariance: 2x2 Array{Float64,2}:
  5.26316  -4.73684
 -4.73684   5.26316
Mix 2: weight 0.10
mean: 1x2 Array{Float64,2}:
 0.0  25.0
covariance: 2x2 Array{Float64,2}:
 0.13  0.0
 0.0   0.13

but I don't understant the last two arguments to the constructor.

2014-12-18 1:06 GMT+01:00 Bradley Setzler :
>
> Hi,
>
> I wish to work with the Gaussian Mixture distribution (especially rand
and pdf), exactly as in this example:
>
> mu = [0.0 25.0; 0.0 25.0]
> sigma = Array(Float64, 2, 2, 2)
> sigma[:, :, 1] = [1.0 0.9; 0.9 1.0]
> sigma[:, :, 2] = 7.5 * [1.0 0.0; 0.0 1.0]
> p = [0.9, 0.1]
>
> distr = MixtureMultivariateNormals(mu, sigma, p)
> X = rand(distr, 10_000)
>
>
> However, the method MixtureMultivariateNormals(mu, sigma, p) used in that
example no longer exists. The maintained version of MixtureModels.jl has no
examples or methods in the documentation of basic usage, and it is far from
obvious how to use it for a Gaussian mixture.
>
> Separately, the package GaussianMixtures.jl, does not successfully work
in what would seem to be the obvious method:
>
> julia> GMM(p,mu,sigma)
> ERROR: `GMM{T<:FloatingPoint,CT<:Union(Array{T,2},Array{T,1})}` has no
method matching
GMM{T<:FloatingPoint,CT<:Union(Array{T,2},Array{T,1})}(::Array{Float64,1},
::Array{Float64,2}, ::Array{Float64,2})
>
> Could someone show me a working example analogous to the one above, using
whichever package you wish?
>
> Thank you,
> Bradley


Re: [julia-users] int

2014-12-19 Thread Hans W Borchers
The expression -0.0 means the floating point number that in memory has the 
same 
bit representation as 0.0, but the sign bit set to 1. One can see this 
applying 
the 'bits' function to 0.0 and -0.0.

I seem to remember that the IEEE floating point convention says that for 
`sqrt(-0.0)` the sign bit has to be reset, so that

julia> sqrt(-0.0)
-0.0

would be wrong while MATLAB, R,... returning 0.0 are correct.

The expression -0.0 means the floating point number that in memory has the 
same 
bit representation as 0.0, but the sign bit set to 1. One can see this 
applying 
the 'bits' function to 0.0 and -0.0.

I seem to remember that the IEEE floating point convention says that for 
`sqrt(-0.0)` the sign bit has to be reset, so that

julia> sqrt(-0.0)
-0.0

would be wrong while MATLAB, R,... returning 0.0 are correct.

For `1/-Inf` the sign bit is not reset because this expression should be 
the 
limit of 1/-x for very large numbers x, i.e. approaching 0 from left.


On Friday, December 19, 2014 12:13:57 PM UTC+1, Tamas Papp wrote:
>
> Hmmm, did you read the whole blog post, including the update at the end? 
> Julia does handle signed zeroes correctly when working with floats. 
>
> As to what signed zeros "mean" -- they have some applications, including 
> indicating the direction of underflow. Probably you don't need to worry 
> about them much since 0.0 == -0.0 (unless you specifically want to use 
> them). 
>
> I usually think about -0.0 as equivalent to 0.0 except for +, -, *, and 
> /, especially when Inf is involved. Thinking about it as some limit is 
> not very intuitive for IEEE floats, eg 
>
> julia> log(-0.0) 
> -Inf 
>
> julia> sqrt(-0.0) 
> -0.0 
>
> all of which are correct IEEE. 
>
> Best, 
>
> Tamas 
>
>
> On Fri, Dec 19 2014, cdm > wrote: 
>
> > i stumbled across a post and got to wondering what Julians thought of it 
> ... 
> > 
> >   http://www.walkingrandomly.com/?p=5152 
> > 
> > 
> > the author presents the case that Python is not IEEE compliant, but 
> > MATLAB is and Julia is close: 
> > 
> > "From the wikipedia page on Division by Zero 
> > : *“The IEEE 754 
> > standard specifies that every floating point arithmetic operation, 
> > including division by zero, has a well-defined result”.* 
> > 
> > 
> > the author reports that in Julia 
> > 
> > julia> 1/(-0) 
> > Inf 
> > 
> > 
> > but MATLAB "correctly" returns -Inf ... 
> > 
> > 
> > i am not sure that signed zero (-0) 
> > means anything to me ... 
> > 
> > should it? 
> > 
> > many thanks, 
> > 
> > cdm 
>


Re: [julia-users] int

2014-12-19 Thread Tamas Papp
Hmmm, did you read the whole blog post, including the update at the end?
Julia does handle signed zeroes correctly when working with floats.

As to what signed zeros "mean" -- they have some applications, including
indicating the direction of underflow. Probably you don't need to worry
about them much since 0.0 == -0.0 (unless you specifically want to use
them).

I usually think about -0.0 as equivalent to 0.0 except for +, -, *, and
/, especially when Inf is involved. Thinking about it as some limit is
not very intuitive for IEEE floats, eg

julia> log(-0.0)
-Inf

julia> sqrt(-0.0)
-0.0

all of which are correct IEEE.

Best,

Tamas


On Fri, Dec 19 2014, cdm  wrote:

> i stumbled across a post and got to wondering what Julians thought of it ...
>
>   http://www.walkingrandomly.com/?p=5152
>
>
> the author presents the case that Python is not IEEE compliant, but
> MATLAB is and Julia is close:
>
> "From the wikipedia page on Division by Zero
> : *“The IEEE 754
> standard specifies that every floating point arithmetic operation,
> including division by zero, has a well-defined result”.*
>
>
> the author reports that in Julia
>
> julia> 1/(-0)
> Inf
>
>
> but MATLAB "correctly" returns -Inf ...
>
>
> i am not sure that signed zero (-0)
> means anything to me ...
>
> should it?
>
> many thanks,
>
> cdm


Re: [julia-users] int

2014-12-19 Thread cdm

thanks ... somehow, i missed that.

clearly, i should have been off to
bed by now.

apologies for the noise.


On Friday, December 19, 2014 3:00:48 AM UTC-8, Andreas Noack wrote:
>
> Did you see the update on the first post? Integer zero is not signed. In 
> MATLAB, 0 is parsed as a floating point number so it is similar to our 
> 1.0/(-0.0). If you force MATLAB to use integers, the result is a bit 
> different
>
> >> int64(1)/int64(0)
>
> ans =
>
>   9223372036854775807
>
> 2014-12-19 11:56 GMT+01:00 cdm >:
>>
>>
>> incidentally, wolfram alpha, agrees with Julia ...
>>
>> http://www.wolframalpha.com/input/?i=1%2F%28-0%29
>>
>

Re: [julia-users] int

2014-12-19 Thread cdm

incidentally, Wolfram|Alpha, agrees with Julia ...

http://www.wolframalpha.com/input/?i=1%2F%28-0%29


Re: [julia-users] int

2014-12-19 Thread Andreas Noack
Did you see the update on the first post? Integer zero is not signed. In
MATLAB, 0 is parsed as a floating point number so it is similar to our
1.0/(-0.0). If you force MATLAB to use integers, the result is a bit
different

>> int64(1)/int64(0)

ans =

  9223372036854775807

2014-12-19 11:56 GMT+01:00 cdm :
>
>
> incidentally, wolfram alpha, agrees with Julia ...
>
> http://www.wolframalpha.com/input/?i=1%2F%28-0%29
>


Re: [julia-users] int

2014-12-19 Thread cdm

incidentally, wolfram alpha, agrees with Julia ...

http://www.wolframalpha.com/input/?i=1%2F%28-0%29


Re: [julia-users] int

2014-12-19 Thread cdm

i stumbled across a post and got to wondering what Julians thought of it ...

  http://www.walkingrandomly.com/?p=5152


the author presents the case that Python is not IEEE compliant, but
MATLAB is and Julia is close:

"From the wikipedia page on Division by Zero 
: *“The IEEE 754 
standard specifies that every floating point arithmetic operation, 
including division by zero, has a well-defined result”.*


the author reports that in Julia

julia> 1/(-0)
Inf


but MATLAB "correctly" returns -Inf ...


i am not sure that signed zero (-0)
means anything to me ...

should it?

many thanks,

cdm




Re: [julia-users] Re: home page content

2014-12-19 Thread cdm

not sure how new this feature is, but over on tmpnb.org each session is 
served
with access to terminal ... Julia is installed.

long live the REPL,

cdm



On Wednesday, December 10, 2014 12:59:02 AM UTC-8, Jan Niklas Hasse wrote: 
>
>
> 
> Unfortunately http://forio.com/julia/repl/ doesn't work anymore, in my 
> opinion it was excellent and a link to it on the front page would be enough.
>


Re: [julia-users] Re: home page content

2014-12-19 Thread cdm

the wise individuals @tmpnb have made a

   "Julia - Intro to Gadfly.ipynb" 

file available with every session ...


sweet sauce, yo.

cdm


On Tuesday, December 9, 2014 11:14:41 PM UTC-8, Valentin Churavy wrote:
>
> 
> For the runnable part. Maybe we could use tmpnb/juliabox to host an 
> example notebook. We should probably use a docker image with an userimages 
> otherwise the attention span will be over before Gadfly is loaded.
>
>>

[julia-users] Re: Security issue in Git: Update your git clients

2014-12-19 Thread Ivar Nesje
This is indeed a serious bug, but Pkg is already a system for distributing 
and executing arbitrary code, so it does not create any additional risk in 
our context. Pkg executes anything it finds in `deps/build.jl`, and that is 
a known and deliberate risc we take in order for packages to be able to 
install binary dependencies. We need to trust the package author to not put 
malicious code in his repo. Also almost all our packages are hosted on 
github, and they know about the problem, are blocking new attempts, and is 
scanning its existing repos for this exploit, so if you pull repos from 
github you should be safe.

There are good reasons to upgrade and it is great that the git community 
takes this serious, but your time is probably better spent actually 
reviewing the code you pull from random guys github repos than to worry 
about the ability to own your system 10 seconds earlier because you get 
hacked when typing 

> git clone
# instead of 10 seconds later, when you type
> make

If you use git to access data, or to actually review code and diffs *before* 
executing 
it, and you use OSX or Windows and a less serious git host that Github, you 
should definitely update ASAP, but that's not a very common case for Julia 
users of Pkg.

Regards Ivar

kl. 09:06:40 UTC+1 fredag 19. desember 2014 skrev Tomas Lycken følgende:
>
> Some of you may already have seen this, but a critical git security 
> vulnerability has just been announced. In short, the vulnerability allows 
> *arbitrary 
> command execution on clients*, and affects *all case-insensitive file 
> systems*.
>
> Github published a nice summary [1] with links to a whole bunch of client 
> vendors who have released patches that fix this problem, as well as a 
> little more details (and links to a lot more details) on what the problem 
> was.
>
> I think it would be a good idea to update Julia to make sure that whatever 
> git version Pkg uses isn't exposed, although I'm not quite sure what is 
> required to do so.
>
> [1]: 
> https://github.com/blog/1938-vulnerability-announced-update-your-git-clients
>
> // Tomas
>


Re: [julia-users] Rust and Julia - Together? Advice

2014-12-19 Thread Uwe Fechner
As far as I know they can talk to each other, as long as you use the same 
major version.

Uwe

On Friday, December 19, 2014 12:57:12 AM UTC+1, Eric Forgy wrote:
>
> Hi Jake, 
>
> That is awesome. Thank you for sharing. I'll give it a try next time I'm 
> in my (second) office. 
>
> Assuming they work, would you consider adding them to the ZGuide? All 
> examples in the ZGuide are given in many different languages, but there are 
> no Julia examples. It would be a great exercise and a great contribution to 
> implement all examples and add them there. 
>
> By the way, the Julia ZMQ and Java JeroMQ I have are based on different 
> versioms of libzmq, i.e. 3.2.4 vs 3.2.2. I guess I'll find out next time 
> I'm in front of my dev laptop, but should I be optimistic the two can still 
> talk to each other? 
>
> Best regards, 
> Eric 
>
>

Re: [julia-users] Re: Return value from let block

2014-12-19 Thread Andreas Noack
Thanks

2014-12-19 10:01 GMT+01:00 :
>
>
>
> On Friday, December 19, 2014 6:38:29 PM UTC+10, Andreas Noack wrote:
>>
>> I was surprised to see get a Float64 return value from
>>
>> let
>> x::Int = 1.0
>> end
>> 1.0
>>
>> Could anyone explain the reasoning behind this? Why is it not returning
>> the value of the variable, i.e. after the conversion to Int?
>>
>
> To quote Jeff here https://github.com/JuliaLang/julia/issues/7341
>
> "= returns the right-hand side every time. No exceptions."
>
> Cheers
> Lex
>


[julia-users] Re: Return value from let block

2014-12-19 Thread elextr


On Friday, December 19, 2014 6:38:29 PM UTC+10, Andreas Noack wrote:
>
> I was surprised to see get a Float64 return value from
>
> let
> x::Int = 1.0
> end
> 1.0
>
> Could anyone explain the reasoning behind this? Why is it not returning 
> the value of the variable, i.e. after the conversion to Int?
>

To quote Jeff here https://github.com/JuliaLang/julia/issues/7341

"= returns the right-hand side every time. No exceptions."

Cheers
Lex 


[julia-users] Return value from let block

2014-12-19 Thread Andreas Noack
I was surprised to see get a Float64 return value from

let
x::Int = 1.0
end
1.0

Could anyone explain the reasoning behind this? Why is it not returning the 
value of the variable, i.e. after the conversion to Int?


[julia-users] Security issue in Git: Update your git clients

2014-12-19 Thread Tomas Lycken
Some of you may already have seen this, but a critical git security 
vulnerability has just been announced. In short, the vulnerability allows 
*arbitrary 
command execution on clients*, and affects *all case-insensitive file 
systems*.

Github published a nice summary [1] with links to a whole bunch of client 
vendors who have released patches that fix this problem, as well as a 
little more details (and links to a lot more details) on what the problem 
was.

I think it would be a good idea to update Julia to make sure that whatever 
git version Pkg uses isn't exposed, although I'm not quite sure what is 
required to do so.

[1]: 
https://github.com/blog/1938-vulnerability-announced-update-your-git-clients

// Tomas


[julia-users] Re: Designing a macro to do something before and after an expression

2014-12-19 Thread yfractal
I think you can do like this


```

macro wrap(expr)
:(global a=1;
  r = (() -> $(esc(expr)))();
  global a=0;
  r)
end

@wrap (if a==1 return 3 else 0 end)

```


Erik Schnetter於 2014年12月19日星期五UTC+8上午11時41分39秒寫道:
>
> I want to write a macro that performs certain actions before and after 
> an expression, returning the value of the expression. Here is my first 
> try: 
>
> macro wrap(expr) 
> :(global a=1; 
>   r = $(esc(expr)); 
>   global a=0; 
>   r) 
> end 
>
> Obviously, setting the global variable `a` to 1 and 0 are just 
> placeholder actions. 
>
> This works for expressions, but doesn't work when `return` statements 
> are involved. 
>
> julia> @wrap 3 
> 3 
>
> julia> @wrap (if true return 3 else 0 end) 
> ERROR: syntax: misplaced return statement 
>
> This simpler case demonstrates the problem: 
>
> julia> @wrap (return 3) 
> => ERROR: syntax: misplaced return statement 
>
> The problem goes away if I don't try to conserve the result into a 
> variable `r`. However, I really need to do that. How? 
>
> -erik 
>
> PS: The macro `@inbounds` in Base has the same issue -- I assume this 
> is the reason why it doesn't return a value. 
>
> -- 
> Erik Schnetter > 
> http://www.perimeterinstitute.ca/personal/eschnetter/ 
>