[julia-users] translation python/ijulia

2016-06-14 Thread Henri Girard
Hi,

I would like to transform this python working example into a ijulia program 
,
Any help
HG

var("w")
u=1/pi*360;s=1/(pi*360)
R=100;L=10;C=10E-6
w=1/(sqrt(L*C));var('omega')
p=plot(abs(1/(1+i*omega*R*C-omega*omega*L*C)),omega,0,2*w,figsize=4,frame=True,
fontsize=8,axes=False,color="green") ;show(p)
print"Pulsation angulaire = ",round(w)," Rad/s"

I tried this but got errors :
R=100;L=10;C=10E-6;w=1/(sqrt(L*C));omega=0;
x=linspace(0,2pi)
y=(abs(1/(1+im*omega*R*C-omega*omega*L*C)));
fig = figure("Angle")
plt.plot(x, y);
plt.ylabel("z");
plt.xlabel("w");
ax = plt.gca() # get current axes
ax[:set_xlim]((0,2*w));
ax[:set_ylim]((0,10));
plt.grid("on")
plt.title("Pulsation");


LoadError: PyError (:PyObject_Call) 
ValueError(u'x and y must have same first dimension',)
  File 
"/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/pyplot.py",
 line 3154, in plot
ret = ax.plot(*args, **kwargs)
  File 
"/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/__init__.py",
 line 1812, in inner
return func(ax, *args, **kwargs)
  File 
"/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_axes.py",
 line 1424, in plot
for line in self._get_lines(*args, **kwargs):
  File 
"/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_base.py",
 line 386, in _grab_next_args
for seg in self._plot_args(remaining, kwargs):
  File 
"/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_base.py",
 line 364, in _plot_args
x, y = self._xy_from_xy(x, y)
  File 
"/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_base.py",
 line 223, in _xy_from_xy
raise ValueError("x and y must have same first dimension")

while loading In[38], in expression starting on line 2

 [inlined code] from /home/pi/.julia/v0.4/PyCall/src/exception.jl:81
 in pycall at /home/pi/.julia/v0.4/PyCall/src/PyCall.jl:502




Re: [julia-users] Re: PyPlot: LineCollection help needed

2016-06-14 Thread David P. Sanders
Great stuff, Tom! 

[julia-users] Re: Require a package not in METADATA

2016-06-14 Thread Tony Kelman
Not in the current incarnation of Pkg, no. This functionality is planned 
for future revamps of the package manager though.


On Tuesday, June 14, 2016 at 2:40:03 PM UTC-7, Chris Rackauckas wrote:
>
> Is there a way to add a package to REQUIRES that's not in METADATA?
>


[julia-users] Abstract type and parametric type in multiple dispatch

2016-06-14 Thread Po Choi
julia> abstract Human

julia> immutable Man <: Human
   x::ASCIIString
   end

julia>

julia> john = Man("John")
Man("John")

julia> function yo(h::Human)
   println("yo ", h.x)
   end
yo (generic function with 1 method)

julia> yo(john)
yo John

julia> function yo{T <: Human}(h::T)
   println("yo yo yo ", h.x)
   end
yo (generic function with 2 methods)

julia> yo(john)
yo yo yo John


The two definitions
yo(h::Human)
yo{T <: Human}(h::T)
which one is prefered?

The second definition has higher priority.
Are those two definitions actually the same?



Re: [julia-users] I can enter the same keyword argument twice, and the second over-rules the first.

2016-06-14 Thread colintbowers
I see your point, but the counter argument is that it makes it fairly easy 
to introduce a bug into your code, ie typing out a couple of keyword 
arguments, mind still on the previous entry, and you accidentally type in 
the same name twice - I know it can happen, because it is exactly how I 
stumbled onto this :-)

I've filed an issue here: https://github.com/JuliaLang/julia/issues/16937, 
so it might be worthwhile if you head over and make your point there, as I 
agree this is definitely arguable for either side.

Cheers,

Colin

On Sunday, 12 June 2016 23:50:32 UTC+10, Tom Breloff wrote:
>
> I just want to point out that this is a feature in my eyes, not a bug. 
> It's very useful as a keyword override when splatting keywords. 
>
> On Sunday, June 12, 2016, Milan Bouchet-Valat  > wrote:
>
>> Le samedi 11 juin 2016 à 19:46 -0700, colintbow...@gmail.com a écrit :
>> > I can enter the same keyword argument twice, and the second entry is
>> > the one that gets used. A short example follows:
>> >
>> > f(x::Int ; kw::Int=0) = x * kw
>> > f(2)
>> > f(2, kw=3) #evaluates to 6
>> > f(2, kw=3, kw=4) #evaluates to 8
>> >
>> > Is this desired behaviour or is it a bug? Based on a quick scan, I
>> > can't quite tell if this is the same bug as issue 9535
>> > (https://github.com/JuliaLang/julia/issues/9535), so thought I would
>> > post here before filing anything. Also, I'm on v0.4, so I don't want
>> > to file if this is already taken care of in v0.5.
>> It also happens on 0.5. This sounds like a different (and simpler) bug
>> than #9535, so filing a new issue would likely be useful. Even if it
>> was done on purpose, the manual doesn't seem to mention it.
>>
>>
>> Regards
>>
>

Re: [julia-users] I can enter the same keyword argument twice, and the second over-rules the first.

2016-06-14 Thread colintbowers
Thanks, I think I'll file an issue later today. It may be deliberate 
behaviour, but maybe not...

On Sunday, 12 June 2016 19:05:39 UTC+10, Milan Bouchet-Valat wrote:
>
> Le samedi 11 juin 2016 à 19:46 -0700, colint...@gmail.com  a 
> écrit : 
> > I can enter the same keyword argument twice, and the second entry is 
> > the one that gets used. A short example follows: 
> > 
> > f(x::Int ; kw::Int=0) = x * kw 
> > f(2) 
> > f(2, kw=3) #evaluates to 6 
> > f(2, kw=3, kw=4) #evaluates to 8 
> > 
> > Is this desired behaviour or is it a bug? Based on a quick scan, I 
> > can't quite tell if this is the same bug as issue 9535 
> > (https://github.com/JuliaLang/julia/issues/9535), so thought I would 
> > post here before filing anything. Also, I'm on v0.4, so I don't want 
> > to file if this is already taken care of in v0.5. 
> It also happens on 0.5. This sounds like a different (and simpler) bug 
> than #9535, so filing a new issue would likely be useful. Even if it 
> was done on purpose, the manual doesn't seem to mention it. 
>
>
> Regards 
>


[julia-users] Re: @parallel while?

2016-06-14 Thread digxx
Maybe just to clarify: I suppose it is possible to spawn a while process on 
each worker separately. The problem is that when one worker finds a 
solution the other workers should stop too.


[julia-users] @parallel while?

2016-06-14 Thread digxx
Is there sth like @parallel while loop?
Or is that even possible?


Re: [julia-users] How to launch a Julia cluster under Torque scheduler

2016-06-14 Thread Erik Schnetter
On Sun, Jun 12, 2016 at 6:54 PM, David Parks  wrote:

> Nice idea Erik, I appreciate it!
> Though if I'm not wrong this locks me into only using MPI as the only
> transport mechanism and I want to use julias remotecall and other built in
> functionality rather than just MPI constructs.
>
> I see that the latest documentation for julia shows a --bind-to option
> that looks like it allows you to launch remote processes and have them
> connect back to the master rather than the other way around. The
> documentation was a little unspecific, so I wasn't completely sure this is
> how it works, but that would be perfect if it did.
>
> If anyone has any information on this new functionality I'd love to hear
> more details about it.
>

You can use the MPI package while still using TCP (i.e. ssh) as transport
mechanism. See the `test_cman_tcp.jl` test case.

-erik

-- 
Erik Schnetter 
http://www.perimeterinstitute.ca/personal/eschnetter/


Re: [julia-users] Plots/pyplot

2016-06-14 Thread digxx
I see. Ok Thank you

Am Mittwoch, 15. Juni 2016 00:16:54 UTC+2 schrieb Tom Breloff:
>
> For the first one, you'll need to wrap that tuple:  `plot(rand(10), 
> xaxis=((0,5),))`  Lesson... axis is expecting a tuple of args, so if you 
> give it one it'll try to do something with each arg.
>
> For the second one, it's updating the tick marks, because that's what it 
> assumes a list of numbers represent.
>
> You should probably avoid the "magic args" for this case:  `plot(rand(10), 
> xlims = (0,5))`
>
> See: http://plots.readthedocs.io/en/latest/attributes/#magic-arguments
>
> On Tue, Jun 14, 2016 at 6:04 PM, digxx 
> > wrote:
>
>> HEy, Sorry for the maybe stupid question but apparently I'm not capable 
>> of setting the range when plotting with plots
>>
>> so e.g.
>>
>> x=0:0.1:1
>> y=2*x
>>
>> plots(x,y,xaxis=(0,0.5)
>> this does not work.
>>
>>
>>
>> and this deletes my xaxis labeling?
>> plots(x,y,xasis=0:0.5)
>>
>>
>> Anyway I just want to set range without changing the input vector.
>>
>>
>

Re: [julia-users] Plots/pyplot

2016-06-14 Thread Tom Breloff
For the first one, you'll need to wrap that tuple:  `plot(rand(10),
xaxis=((0,5),))`  Lesson... axis is expecting a tuple of args, so if you
give it one it'll try to do something with each arg.

For the second one, it's updating the tick marks, because that's what it
assumes a list of numbers represent.

You should probably avoid the "magic args" for this case:  `plot(rand(10),
xlims = (0,5))`

See: http://plots.readthedocs.io/en/latest/attributes/#magic-arguments

On Tue, Jun 14, 2016 at 6:04 PM, digxx  wrote:

> HEy, Sorry for the maybe stupid question but apparently I'm not capable of
> setting the range when plotting with plots
>
> so e.g.
>
> x=0:0.1:1
> y=2*x
>
> plots(x,y,xaxis=(0,0.5)
> this does not work.
>
>
>
> and this deletes my xaxis labeling?
> plots(x,y,xasis=0:0.5)
>
>
> Anyway I just want to set range without changing the input vector.
>
>


[julia-users] Plots/pyplot

2016-06-14 Thread digxx
HEy, Sorry for the maybe stupid question but apparently I'm not capable of 
setting the range when plotting with plots

so e.g.

x=0:0.1:1
y=2*x

plots(x,y,xaxis=(0,0.5)
this does not work.



and this deletes my xaxis labeling?
plots(x,y,xasis=0:0.5)


Anyway I just want to set range without changing the input vector.



[julia-users] Require a package not in METADATA

2016-06-14 Thread Chris Rackauckas
Is there a way to add a package to REQUIRES that's not in METADATA?


Re: [julia-users] Problems with MySQL sample code

2016-06-14 Thread Jacob Quinn
Yep, it's just like I said above, in the "mysql_execute(con"
command/line, you'll even notice the code highlighting in your email shows
that "John" is highlighted as a value instead of a text. That's because the
double quote right before John is ending the string that starts with
"INSERT...".

You need to escape the double quotes there or, as I said, use single
quotes, so that line would be:

mysql_execute(con, "INSERT INTO Employee (Name, Salary, JoinDate)
values ('John', 25000.00, '2015-12-12'), ('Sam', 35000.00,
'2012-18-17), ('Tom', 5.00, '2013-12-14');")

Also feel free to checkout https://github.com/JuliaDB/ODBC.jl, it's a
great package for interacting with a variety of databases through the
common ODBC framework, most heavily tested against MySQL.

-Jacob


On Tue, Jun 14, 2016 at 1:53 PM, Ingemar Skarpås  wrote:

> Well - it is this sample code- direct from Github for MySQL.jl -only
> modification i adrress username et c in the con=mysql_connect(). And the
> same works for the MySQL test suite. And the code works up until row 14 in
> this case. I my code I have a few more comments I've added but teh
> executable code is the same!
>
> using MySQL
> con = mysql_connect("192.168.23.24", "username", "password", "db_name")
> command = """CREATE TABLE Employee
>  (
>  ID INT NOT NULL AUTO_INCREMENT,
>  Name VARCHAR(255),
>  Salary FLOAT,
>  JoinDate DATE,
>  PRIMARY KEY (ID)
>  );"""
> mysql_execute(con, command)
>
> # Insert some values
> mysql_execute(con, "INSERT INTO Employee (Name, Salary, JoinDate) values 
> ("John", 25000.00, '2015-12-12'), ("Sam", 35000.00, '2012-18-17), ("Tom", 
> 5.00, '2013-12-14');")
>
> # Get SELECT results
> command = "SELECT * FROM Employee;"
> dframe = mysql_execute(con, command)
>
> # Close connection
> mysql_disconnect(con)
>
>
>
>
> Den tisdag 14 juni 2016 kl. 19:01:49 UTC+2 skrev Stefan Karpinski:
>>
>> On Tue, Jun 14, 2016 at 11:50 AM, Ingemar Skarpås 
>> wrote:
>>
>>> LoadError:UdefVarError: @John_str not defined
>>
>>
>> This bit indicates that you've written something like this: John"...".
>> This is translated to a macro call to a macro named @John_str.
>>
>>


Re: [julia-users] Problems with MySQL sample code

2016-06-14 Thread Stefan Karpinski
Can you file an issue here: https://github.com/JuliaDB/MySQL.jl/issues

On Tue, Jun 14, 2016 at 3:53 PM, Ingemar Skarpås  wrote:

> Well - it is this sample code- direct from Github for MySQL.jl -only
> modification i adrress username et c in the con=mysql_connect(). And the
> same works for the MySQL test suite. And the code works up until row 14 in
> this case. I my code I have a few more comments I've added but teh
> executable code is the same!
>
> using MySQL
> con = mysql_connect("192.168.23.24", "username", "password", "db_name")
> command = """CREATE TABLE Employee
>  (
>  ID INT NOT NULL AUTO_INCREMENT,
>  Name VARCHAR(255),
>  Salary FLOAT,
>  JoinDate DATE,
>  PRIMARY KEY (ID)
>  );"""
> mysql_execute(con, command)
>
> # Insert some values
> mysql_execute(con, "INSERT INTO Employee (Name, Salary, JoinDate) values 
> ("John", 25000.00, '2015-12-12'), ("Sam", 35000.00, '2012-18-17), ("Tom", 
> 5.00, '2013-12-14');")
>
> # Get SELECT results
> command = "SELECT * FROM Employee;"
> dframe = mysql_execute(con, command)
>
> # Close connection
> mysql_disconnect(con)
>
>
>
>
> Den tisdag 14 juni 2016 kl. 19:01:49 UTC+2 skrev Stefan Karpinski:
>>
>> On Tue, Jun 14, 2016 at 11:50 AM, Ingemar Skarpås 
>> wrote:
>>
>>> LoadError:UdefVarError: @John_str not defined
>>
>>
>> This bit indicates that you've written something like this: John"...".
>> This is translated to a macro call to a macro named @John_str.
>>
>>


[julia-users] Re: How to install 0.4.5 on Ubuntu?

2016-06-14 Thread Nils Gudat
What (might have) helped in the end was to remove the nightlies PPA -  I 
had added both PPAs for release version and nightly, so maybe that was my 
mistake.


Re: [julia-users] Problems with MySQL sample code

2016-06-14 Thread Ingemar Skarpås
Well - it is this sample code- direct from Github for MySQL.jl -only 
modification i adrress username et c in the con=mysql_connect(). And the 
same works for the MySQL test suite. And the code works up until row 14 in 
this case. I my code I have a few more comments I've added but teh 
executable code is the same!

using MySQL
con = mysql_connect("192.168.23.24", "username", "password", "db_name")
command = """CREATE TABLE Employee
 (
 ID INT NOT NULL AUTO_INCREMENT,
 Name VARCHAR(255),
 Salary FLOAT,
 JoinDate DATE,
 PRIMARY KEY (ID)
 );"""
mysql_execute(con, command)

# Insert some values
mysql_execute(con, "INSERT INTO Employee (Name, Salary, JoinDate) values 
("John", 25000.00, '2015-12-12'), ("Sam", 35000.00, '2012-18-17), ("Tom", 
5.00, '2013-12-14');")

# Get SELECT results
command = "SELECT * FROM Employee;"
dframe = mysql_execute(con, command)

# Close connection
mysql_disconnect(con)




Den tisdag 14 juni 2016 kl. 19:01:49 UTC+2 skrev Stefan Karpinski:
>
> On Tue, Jun 14, 2016 at 11:50 AM, Ingemar Skarpås  > wrote:
>
>> LoadError:UdefVarError: @John_str not defined
>
>
> This bit indicates that you've written something like this: John"...". 
> This is translated to a macro call to a macro named @John_str.
>
>

Re: [julia-users] Re: PyPlot: LineCollection help needed

2016-06-14 Thread Tom Breloff
David: Thanks so much for saving me a ton of headache figuring this out for
Plots.  Just pushed to dev:

```
using Plots
y = cumsum(randn(500))
plot(y, line_z = y, w = 3)
```



​

On Sat, Jun 11, 2016 at 4:13 PM, Christoph Ortner <
christophortn...@gmail.com> wrote:

> thanks, David, this will be useful for me as well! C
>
>
> On Saturday, 11 June 2016 15:20:52 UTC+1, David P. Sanders wrote:
>>
>> After looking at some matplotlib examples, it seems that the data
>> structure needed by LineCollection in Python
>> is a list of lists, with the inner lists being lists of (x,y) pairs.
>>
>> After playing around for a while, the following works for me
>> for drawing a pair of lines in Julia:
>> xs = [1., 3., 5., 0.]
>> ys = [2., 4., .06, 0.]
>> lines = Any[collect(zip(xs, ys))]
>>
>> xs = [3., 4]
>> ys = [5., 6]
>> push!(lines, collect(zip(xs, ys)))
>> #lines = Vector{Float64}[[1.0, 2.0], [3.0 4.0], 5.0 .06]];Any[[0.0 0.0]]]
>> # Points
>> #c = Any[Any[1 0 0];Any[0 1 0];Any[0 0 1]] # Color
>> c = Vector{Int}[[1,0,0], [0,1,0], [0,0,1]]
>>
>> line_segments = matplotlib[:collections][:LineCollection](lines, colors=c)
>>
>> fig = figure("Line Collection Example")
>> ax = gca()
>> ax[:add_collection](line_segments)
>> axis("image")
>>
>>
>> El viernes, 10 de junio de 2016, 10:29:25 (UTC-4), NotSoRecentConvert
>> escribió:
>>>
>>> I'm trying to do a plot using LineCollection in PyPlot however am having
>>> a hard time converting an example (1
>>>  or
>>> 2 
>>> ).
>>>
>>> lines = Any[Any[[1.0 2.0]];Any[[3.0 4.0]];Any[[5.0 .06]];Any[[0.0 0.0]]] #
>>> Points
>>> c = Any[Any[1 0 0];Any[0 1 0];Any[0 0 1]] # Color
>>>
>>> line_segments = matplotlib[:collections][:LineCollection](lines,colors=c
>>> )
>>>
>>> fig = figure("Line Collection Example")
>>> ax = axes()
>>> ax[:add_collection](line_segments)
>>> axis("tight")
>>>
>>> It doesn't return an errors but I don't see any lines. Any idea what
>>> could be wrong?
>>>
>>


Re: [julia-users] Re: Packages Distances problem with Distances.Jaccard : very slow

2016-06-14 Thread Kristoffer Carlsson
Ok, I merged it. Enjoy.

On Tuesday, June 14, 2016 at 8:53:26 PM UTC+2, jean-pierre both wrote:
>
> Hi,
>
> The fix is really great, thank you for the analysis and the fix.
> Thanks you
>
> Le lundi 13 juin 2016 20:19:26 UTC+2, Kristoffer Carlsson a écrit :
>>
>> Please try https://github.com/JuliaStats/Distances.jl/pull/44
>>
>> On Monday, June 13, 2016 at 8:14:01 PM UTC+2, Mauro wrote:
>>>
>>> > function myjaccard2(a::Array{Float64,1}, b::Array{Float64,1}) 
>>> > num = 0. 
>>> > den = 0. 
>>> > for I in 1:length(a) 
>>> > @inbounds ai = a[I] 
>>> > @inbounds bi = b[I] 
>>> > num = num + min(ai,bi) 
>>> > den = den + max(ai,bi) 
>>> > end 
>>> > 1. - num/den 
>>> > end 
>>> > 
>>> > 
>>> > 
>>> > function testDistances2(v1::Array{Float64,1}, v2::Array{Float64,1}) 
>>> > for i in 1:5 
>>> > myjaccard2(v1,v2) 
>>> > end 
>>> > end 
>>>
>>> I recommend using the values returned for something, otherwise the 
>>> compiler sometimes eliminates the loop (but not here): 
>>>
>>> julia> function testDistances2(v1::Array{Float64,1}, 
>>> v2::Array{Float64,1}) 
>>>out = 0.0 
>>>for i in 1:5 
>>>out += myjaccard2(v1,v2) 
>>>end 
>>>out 
>>>end 
>>>
>>> > @time testDistances2(v1,v2) 
>>> > machine   3.217329 seconds (200.01 M allocations: 2.981 GB, 19.91% gc 
>>> time) 
>>>
>>> I cannot reproduce this, when I run it I get no allocations: 
>>>
>>> julia> v2 = rand(10^4); 
>>>
>>> # warm-up 
>>> julia> @time testDistances2(v1,v2) 
>>>   3.604478 seconds (8.15 k allocations: 401.797 KB, 0.42% gc time) 
>>> 24999.00112162811 
>>>
>>> julia> @time testDistances2(v1,v2) 
>>>   3.647563 seconds (5 allocations: 176 bytes) 
>>> 24999.00112162811 
>>>
>>> What version of Julia are you running. Me 0.4.5. 
>>>
>>> > function myjaccard5(a::Array{Float64,1}, b::Array{Float64,1}) 
>>> > num = 0. 
>>> > den = 0. 
>>> > for I in 1:length(a) 
>>> > @inbounds ai = a[I] 
>>> > @inbounds bi = b[I] 
>>> > abs_m = abs(ai-bi) 
>>> > abs_p = abs(ai+bi) 
>>> > num += abs_p - abs_m 
>>> > den += abs_p + abs_m 
>>> > end 
>>> > 1. - num/den 
>>> > end 
>>> > 
>>> > 
>>> > function testDistances5(a::Array{Float64,1}, b::Array{Float64,1}) 
>>> > for i in 1:5000 
>>> > myjaccard5(a,b) 
>>> > end 
>>> > end 
>>> > 
>>> > end 
>>> > 
>>> > 
>>> > julia> @time testDistances5(v1,v2) 
>>> >   0.166979 seconds (4 allocations: 160 bytes) 
>>> > 
>>> > 
>>> > 
>>> > We see that using abs is faster. 
>>> > 
>>> > I do not do a pull request beccause 
>>> > 
>>> > I would expect a good implementation to be 2 or 3 times slower than 
>>> > Euclidean, and I have not 
>>> > that yet. 
>>> > 
>>> > Le lundi 13 juin 2016 13:43:00 UTC+2, Kristoffer Carlsson a écrit : 
>>> >> 
>>> >> It seems weird to me that you guys want to call Jaccard distance with 
>>> >> float arrays. AFAIK Jaccard distance measures the distance between 
>>> two 
>>> >> distinct samples from a pair of sets so basically between two 
>>> Vector{Bool}, 
>>> >> see: 
>>> >> 
>>> http://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.jaccard.html
>>>  
>>> >> 
>>> >> "Computes the Jaccard-Needham dissimilarity between two boolean 1-D 
>>> >> arrays." 
>>> >> 
>>> >> Is there some more general formulation of it that extends to vectors 
>>> in a 
>>> >> continuous vector space? 
>>> >> 
>>> >> And, to note, Jaccard is type stable for inputs of Vector{Bool} in 
>>> >> Distances.jl. 
>>> >> 
>>> >> On Monday, June 13, 2016 at 3:53:14 AM UTC+2, jean-pierre both wrote: 
>>> >>> 
>>> >>> 
>>> >>> 
>>> >>> I encountered in my application with Distances.Jaccard compared with 
>>> >>> Distances.Euclidean 
>>> >>> It was very slow. 
>>> >>> 
>>> >>> For example with 2 vecteurs Float64 of size 11520 
>>> >>> 
>>> >>> I get the following 
>>> >>> julia> D=Euclidean() 
>>> >>> Distances.Euclidean() 
>>> >>> julia> @time for i in 1:500 
>>> >>>evaluate(D,v1,v2) 
>>> >>>end 
>>> >>>   0.002553 seconds (500 allocations: 7.813 KB) 
>>> >>> 
>>> >>> and with Jaccard 
>>> >>> 
>>> >>> julia> D=Jaccard() 
>>> >>> Distances.Jaccard() 
>>> >>> @time for i in 1:500 
>>> >>>   evaluate(D,v1,v2) 
>>> >>>   end 
>>> >>>   1.995046 seconds (40.32 M allocations: 703.156 MB, 9.68% gc time) 
>>> >>> 
>>> >>> With a simple loop for computing jaccard : 
>>> >>> 
>>> >>> 
>>> >>> function myjaccard2(a::Array{Float64,1}, b::Array{Float64,1}) 
>>> >>>num = 0 
>>> >>>den = 0 
>>> >>>for i in 1:length(a) 
>>> >>>num = num + min(a[i],b[i]) 
>>> >>>den = den + max(a[i],b[i]) 
>>> >>>end 
>>> >>>1. - num/den 
>>> >>>end 
>>> >>> myjaccard2 (generic function with 1 method) 
>>> >>> 
>>> >>> julia> @time for i in 1:500 
>>> >>>   myj

Re: [julia-users] Re: Can I somehow get Julia without standard library?

2016-06-14 Thread Stefan Karpinski
>
> Of course I can use high level wrappers around the existing library
> functions, but this will cause a significant negative impact on the
> performance, that is why I want to implement this functionality on top of
> the lowest level.


Why would having the standard library present make what you want to
implement slower? "High level wrappers" are not necessarily any slower.
There's nothing preventing you from making your own high-performance
primitives without ditching Julia's standard library. There are tons of
examples out there of user-defined types in Julia code that are just as
efficient as the built-in ones:

   - https://github.com/JeffBezanson/FixedPointNumbers.jl
   - https://github.com/JuliaGraphics/ColorTypes.jl
   - https://github.com/JuliaDiff/DualNumbers.jl
   - https://github.com/dpsanders/ValidatedNumerics.jl

For a simple, self-contained example, see examples/modint.jl
.

On Tue, Jun 14, 2016 at 2:40 PM, Dmitry  wrote:

> I want to change the behaviour and implementation of some language
> features. In other words, I need my own little standard library that most
> accurately meets my needs. Of course I can use high level wrappers around
> the existing library functions, but this will cause a significant negative
> impact on the performance, that is why I want to implement this
> functionality on top of the lowest level. Generally speaking, to do this I
> do not need to remove the standard library, but I think it might be the
> most convenient way to "feel" that lowest level. If you say that Julia is
> so flexible that even primitive types and operations are implemented in the
> standard library then I want to take advantage of this and implement my
> own primitives.
>
> вторник, 14 июня 2016 г., 17:01:44 UTC+3 пользователь Stefan Karpinski
> написал:
>>
>> Tamas is dead on – see the intro of
>> https://www.youtube.com/watch?v=dK3zRXhrFZY for an explanation. Being
>> able to define even the most basis types in Julia itself is one of the most
>> powerful features of the language.
>>
>> Let's back up a little here. What are you trying to accomplish?
>>
>


Re: [julia-users] Re: Packages Distances problem with Distances.Jaccard : very slow

2016-06-14 Thread jean-pierre both
Hi,

The fix is really great, thank you for the analysis and the fix.
Thanks you

Le lundi 13 juin 2016 20:19:26 UTC+2, Kristoffer Carlsson a écrit :
>
> Please try https://github.com/JuliaStats/Distances.jl/pull/44
>
> On Monday, June 13, 2016 at 8:14:01 PM UTC+2, Mauro wrote:
>>
>> > function myjaccard2(a::Array{Float64,1}, b::Array{Float64,1}) 
>> > num = 0. 
>> > den = 0. 
>> > for I in 1:length(a) 
>> > @inbounds ai = a[I] 
>> > @inbounds bi = b[I] 
>> > num = num + min(ai,bi) 
>> > den = den + max(ai,bi) 
>> > end 
>> > 1. - num/den 
>> > end 
>> > 
>> > 
>> > 
>> > function testDistances2(v1::Array{Float64,1}, v2::Array{Float64,1}) 
>> > for i in 1:5 
>> > myjaccard2(v1,v2) 
>> > end 
>> > end 
>>
>> I recommend using the values returned for something, otherwise the 
>> compiler sometimes eliminates the loop (but not here): 
>>
>> julia> function testDistances2(v1::Array{Float64,1}, 
>> v2::Array{Float64,1}) 
>>out = 0.0 
>>for i in 1:5 
>>out += myjaccard2(v1,v2) 
>>end 
>>out 
>>end 
>>
>> > @time testDistances2(v1,v2) 
>> > machine   3.217329 seconds (200.01 M allocations: 2.981 GB, 19.91% gc 
>> time) 
>>
>> I cannot reproduce this, when I run it I get no allocations: 
>>
>> julia> v2 = rand(10^4); 
>>
>> # warm-up 
>> julia> @time testDistances2(v1,v2) 
>>   3.604478 seconds (8.15 k allocations: 401.797 KB, 0.42% gc time) 
>> 24999.00112162811 
>>
>> julia> @time testDistances2(v1,v2) 
>>   3.647563 seconds (5 allocations: 176 bytes) 
>> 24999.00112162811 
>>
>> What version of Julia are you running. Me 0.4.5. 
>>
>> > function myjaccard5(a::Array{Float64,1}, b::Array{Float64,1}) 
>> > num = 0. 
>> > den = 0. 
>> > for I in 1:length(a) 
>> > @inbounds ai = a[I] 
>> > @inbounds bi = b[I] 
>> > abs_m = abs(ai-bi) 
>> > abs_p = abs(ai+bi) 
>> > num += abs_p - abs_m 
>> > den += abs_p + abs_m 
>> > end 
>> > 1. - num/den 
>> > end 
>> > 
>> > 
>> > function testDistances5(a::Array{Float64,1}, b::Array{Float64,1}) 
>> > for i in 1:5000 
>> > myjaccard5(a,b) 
>> > end 
>> > end 
>> > 
>> > end 
>> > 
>> > 
>> > julia> @time testDistances5(v1,v2) 
>> >   0.166979 seconds (4 allocations: 160 bytes) 
>> > 
>> > 
>> > 
>> > We see that using abs is faster. 
>> > 
>> > I do not do a pull request beccause 
>> > 
>> > I would expect a good implementation to be 2 or 3 times slower than 
>> > Euclidean, and I have not 
>> > that yet. 
>> > 
>> > Le lundi 13 juin 2016 13:43:00 UTC+2, Kristoffer Carlsson a écrit : 
>> >> 
>> >> It seems weird to me that you guys want to call Jaccard distance with 
>> >> float arrays. AFAIK Jaccard distance measures the distance between two 
>> >> distinct samples from a pair of sets so basically between two 
>> Vector{Bool}, 
>> >> see: 
>> >> 
>> http://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.jaccard.html
>>  
>> >> 
>> >> "Computes the Jaccard-Needham dissimilarity between two boolean 1-D 
>> >> arrays." 
>> >> 
>> >> Is there some more general formulation of it that extends to vectors 
>> in a 
>> >> continuous vector space? 
>> >> 
>> >> And, to note, Jaccard is type stable for inputs of Vector{Bool} in 
>> >> Distances.jl. 
>> >> 
>> >> On Monday, June 13, 2016 at 3:53:14 AM UTC+2, jean-pierre both wrote: 
>> >>> 
>> >>> 
>> >>> 
>> >>> I encountered in my application with Distances.Jaccard compared with 
>> >>> Distances.Euclidean 
>> >>> It was very slow. 
>> >>> 
>> >>> For example with 2 vecteurs Float64 of size 11520 
>> >>> 
>> >>> I get the following 
>> >>> julia> D=Euclidean() 
>> >>> Distances.Euclidean() 
>> >>> julia> @time for i in 1:500 
>> >>>evaluate(D,v1,v2) 
>> >>>end 
>> >>>   0.002553 seconds (500 allocations: 7.813 KB) 
>> >>> 
>> >>> and with Jaccard 
>> >>> 
>> >>> julia> D=Jaccard() 
>> >>> Distances.Jaccard() 
>> >>> @time for i in 1:500 
>> >>>   evaluate(D,v1,v2) 
>> >>>   end 
>> >>>   1.995046 seconds (40.32 M allocations: 703.156 MB, 9.68% gc time) 
>> >>> 
>> >>> With a simple loop for computing jaccard : 
>> >>> 
>> >>> 
>> >>> function myjaccard2(a::Array{Float64,1}, b::Array{Float64,1}) 
>> >>>num = 0 
>> >>>den = 0 
>> >>>for i in 1:length(a) 
>> >>>num = num + min(a[i],b[i]) 
>> >>>den = den + max(a[i],b[i]) 
>> >>>end 
>> >>>1. - num/den 
>> >>>end 
>> >>> myjaccard2 (generic function with 1 method) 
>> >>> 
>> >>> julia> @time for i in 1:500 
>> >>>   myjaccard2(v1,v2) 
>> >>>   end 
>> >>>   0.451582 seconds (23.04 M allocations: 351.592 MB, 20.04% gc time) 
>> >>> 
>> >>> I do not see the problem in jaccard distance implementation in the 
>> >>> Distances packages 
>> >>> 
>> >> 
>>
>

Re: [julia-users] Re: Can I somehow get Julia without standard library?

2016-06-14 Thread Dmitry
I want to change the behaviour and implementation of some language 
features. In other words, I need my own little standard library that most 
accurately meets my needs. Of course I can use high level wrappers around 
the existing library functions, but this will cause a significant negative 
impact on the performance, that is why I want to implement this 
functionality on top of the lowest level. Generally speaking, to do this I 
do not need to remove the standard library, but I think it might be the 
most convenient way to "feel" that lowest level. If you say that Julia is 
so flexible that even primitive types and operations are implemented in the 
standard library then I want to take advantage of this and implement my 
own primitives.

вторник, 14 июня 2016 г., 17:01:44 UTC+3 пользователь Stefan Karpinski 
написал:
>
> Tamas is dead on – see the intro of 
> https://www.youtube.com/watch?v=dK3zRXhrFZY for an explanation. Being 
> able to define even the most basis types in Julia itself is one of the most 
> powerful features of the language.
>
> Let's back up a little here. What are you trying to accomplish?
>


Re: [julia-users] Re: why the numerical result is different (RK45 julia and matlab)?

2016-06-14 Thread Daniel Carrera
Can you post your new code and your new results? Is the difference
consistent with the tolerance level?

Naively, I would expect the difference between the two implementations to
be around sqrt(N)*AbsTol -- this is what you'd expect if at each step each
implementation has an unbiased random error of size AbsTol.

Cheers,
Daniel.

On 14 June 2016 at 18:22,  wrote:

>
> Hi Daniel
> I did the test and the difference decreased. interesting, I had not
> noticed.
>
> Em domingo, 12 de junho de 2016 09:53:40 UTC-3, Daniel Carrera escreveu:
>>
>> I don't know what you are trying to say, but did you try running the two
>> programs with the same relative and absolute tolerances? Do the results
>> look more similar now?
>>
>> On 12 June 2016 at 02:01,  wrote:
>>
>>> Hi daniel
>>> in fact, there is a relationship with the tolerance between the methods.
>>>
>>> Em sábado, 11 de junho de 2016 11:51:53 UTC-3, Daniel Carrera escreveu:

 Probably because the Julia module has different default values for the
 absolute and relative tolerance.  For Julia, the defaults are reltol=1e-5
 and abstol=1e-8 but in Matlab the defaults are RelTol=1e-3 and AbsTol=1e-6.

 https://github.com/JuliaLang/ODE.jl
 http://se.mathworks.com/help/matlab/ref/odeset.html

 That would also explain why the Julia program took so much longer. Try
 again with the same tolerance and see if the results are more similar. Oh,
 and like Erik said, you probably meant to have parenthesis around "1/8". If
 the results still look difference, look for more options that might have
 different default values.

 Cheers,
 Daniel.



 On Saturday, 11 June 2016 04:29:47 UTC+2, jmarcell...@ufpi.edu.br
 wrote:
>
> this is the test for equation differential using runge-kutta45:
> f(x,y)= (-5*x - y/5)^1/8 + 10
>
>
> 
>
> why the numerical result is different? I used :
>
> function Rk_JL()
>  f(x,y)= (-5*x - y/5)^1/8 + 10
>  tspan = 0:0.001:n
>  y0 = [0.0, 1.0]
>  return ODE.ode45(f, y0,tspan);end
>
>
> and
>
>
> function [X1,Y1] = RK_M()
>  f = @(x,y) (-5*x - y/5)^1/8 + 10;
>  tspan = 0:0.001:n;
>  y0 = 1
>  [X1,Y1]= ode45(f,tspan,1);end
>
>
>>


Re: [julia-users] Problems with MySQL sample code

2016-06-14 Thread Jacob Quinn
My guess is that you have an SQL query that is something like:

query("select * from table where name = "John" and dept = 7")

The problem then is that the double quotation mark right before John is
actually *ending* the double quote that started your query string. What you
want is to escape the quotation mark around John, (or better yet, just use
a single quote), so something like:

query("select * from table where name = 'John' and dept = 7")

or

query("select * from table where name = \"John\" and dept = 7")

should work.

-Jacob

On Tue, Jun 14, 2016 at 9:50 AM, Ingemar Skarpås  wrote:

>
>
> Last week I started to evaluate Julia to see if it fits my purposes (I
> made some test a year and half ago also) , so I have tested a few things
> written some tests of my own, and modified some sample code. So bare with
> me if this is an easy one...
>
> I have Julia 0.4.5, with MySQL 0.2.2+ on W7U and MariaDB 10.0.17 I have
> create a database which is set to be the default and then tries to execute
> the sample code with the MySQL.jl from that Github. I used Atom 1.8.0.
> Everything is updated!
>
> The running the sample code, the table is correctly created, but when
> executing the line with the SELECT INSERT it gives an Error on the file
> name refering to the line number after that line. In my case an empty line.
> (So, I found out that Atom's error message window can't be copied from!).
> So manually typed...
>
> LoadError:UdefVarError: @John_str not defined
>  in include_string at loading.jl:282
> in include_String at C:\Users\Myname\.julia\v.04\CodeTools\src\eval.jl:32
>  in anonymous at C:\Users\Myname\ .julia\v0.4\Atom\src\eval.jl:84
>  in withpath at C:\Users\Myname\.julia\v0.4\Requires\src\requires.jl:37
>  in withpath at C:\Users\Mname\.julia\v0.4\Atom\src\eval.jl:53
>  [inlined code] from C:\Users\Myname\.julia\v0.4\Atom\src\eval.jl:83
>  in anonymour at task.jl:58
> while loading C:\Julia_Code\test_Mysql_localhost.jl, in expression
> starting on line 16
>
> The odd thing - running the test suite that is located from my local MySQL
> test directory with Pkg.test("MySQL") is ok! And, that test suite (3 files
> are run) also uses SELECT INTO, but in a much more complicated way!
>
> So, what is the problem? I have been staring myself blind so far
>


Re: [julia-users] Abstract version of rng=1:end ?

2016-06-14 Thread Tim Holy
See https://github.com/JuliaLang/julia/pull/15750. What holds that up is the 
fact that people sometimes want to do math on `end`, e.g.,

b = a[1:round(Int,sqrt(end))]

works just fine.

--Tim

On Monday, June 13, 2016 8:40:39 AM CDT Dan wrote:
> A reason such 'extended' ranges might be good, is the ability to dispatch
> on them for efficiency. For example, `deleteat!(vec,5:end)`  could be
> implemented faster than just any `deleteat!` of any range. This would be
> applicable to other such structures with edge effects. Indeed, we can learn
> from mathematics which often embraced infinity for ease of use and
> expression.
> Again, this complication might not be worth the benefits.
> 
> So how about a half-bounded types of the form:
> typeof(5:end) == ExtendedUnitRange{BU}(5) # the BU stands for
> Bounded-Unbounded
> 
> a UnboundedUnbounded Unit range could be like `:` meaning unbounded in both
> directions.
> 
> To summarize: there are algorithmic optimizations which are enabled by
> knowing the operated range spans to the end (or even just up close to the
> end by  It would be interesting to allow these optimization to be taken using
> dispatch for static optimization.
> 
> On Monday, June 13, 2016 at 11:05:47 AM UTC-4, Yichao Yu wrote:
> > On Mon, Jun 13, 2016 at 10:47 AM, Matthew Pearce  > 
> > > wrote:
> > > Hello
> > > 
> > > I find myself frequently wishing to define functions that accept a range
> > > argument to operate on like:
> > > 
> > > function foo{T}(M::Array{T,1}, rng::UnitRange)
> > > 
> > > return sum(M[rng].^2)
> > > 
> > > end
> > > 
> > > It would be nice to be able to pass in `rng = 1:end`, but this isn't
> > 
> > legal.
> > 
> > > So I need a signature like,
> > 
> > rng=1:endof(M)
> > 
> > > function foo{T}(M::Array{T,1})
> > > 
> > > foo(M, 1:length(M))
> > > 
> > > end
> > > 
> > > Is there a way to set `rng` to achieve my intended effect without having
> > 
> > to
> > 
> > > resort to declaring additional functions?
> > > 
> > > Cheers
> > > 
> > > Matthew




[julia-users] Re: A naive question regarding the definition of a type with arguments of varying types

2016-06-14 Thread Kuan Xu
Thanks very much!! That's exactly what I need.


On Monday, June 13, 2016 at 10:19:44 PM UTC+1, Kristoffer Carlsson wrote:
>
> Perhaps:
>
> type RealorComplex{T1 <: Number, T2<:Real}
> v::Vector{T1}
> w::Vector{Complex{T2}}
> function RealorComplex(v, w)
> @assert T1 <: AbstractFloat || T1 <: Complex
> new(v, w)
> end
> end
>
> RealorComplex{T1,T2}(v::Vector{T1}, w::Vector{Complex{T2}}) = 
> RealorComplex{T1, T2}(v, w)
>
>
>
> On Monday, June 13, 2016 at 9:31:06 PM UTC+2, Kuan Xu wrote:
>>
>>
>>
>> I'm trying to define a type which has two fields, the first of which can 
>> be either real or complex and the second is always complex. 
>>
>> type RealorComplex{T<:Number}
>> v::Vector{T}
>> w::Vector{Complex{T}}
>> end
>>
>> r = RealorComplex([1.0, 2.0], [1.0+1.0im, 2.0])
>> t = RealorComplex([1.0+1.0im, 2.0], [1.0+1.0im, 2.0])
>>
>> The construction of r is totally fine but not that of t, since mismatch 
>> of the type. What is the best way to fix my ctor so that it can take either 
>> type of first argument . 
>>
>> Hope I have made my question clear. Thanks.
>>
>

Re: [julia-users] Problems with MySQL sample code

2016-06-14 Thread Stefan Karpinski
On Tue, Jun 14, 2016 at 11:50 AM, Ingemar Skarpås 
wrote:

> LoadError:UdefVarError: @John_str not defined


This bit indicates that you've written something like this: John"...". This
is translated to a macro call to a macro named @John_str.


Re: [julia-users] Indexing ranges out of an array

2016-06-14 Thread Stefan Karpinski
There's nothing predefined that does this, but it's easy to roll your own:
preallocate and output array of the correct size (a pretty straightforward
computation) and then use a for loop to copy the elements over; wrap this
in a function and then use as desired.

On Tue, Jun 14, 2016 at 11:37 AM, Jesse Jaanila 
wrote:

> I would like to know whats a juliatic way of indexing or slicing evenly
> spaced ranges out of an array:
>
> If I want to take out every n:th element out of Julia array, I would do
> something like
>
> a = [1,2,3,4,5,6];
> everySecond = a[2:2:end];
>
> What I would like to achieve is a slice of specified size between evenly
> spaced step sizes. So after n length step, collect a slice of specified
> length.
> So if I have step size as 1 and then I want to take the next two elements
> I would expect the result to be:
>
> a = [1,2,3,4,5,6,7,8,9,10];
>
> magicIndexing(a)
> >[2,3,5,6,8,9]
>
> Is there a nice way of achieving something like this?
>


[julia-users] Problems with MySQL sample code

2016-06-14 Thread Ingemar Skarpås


Last week I started to evaluate Julia to see if it fits my purposes (I made 
some test a year and half ago also) , so I have tested a few things written 
some tests of my own, and modified some sample code. So bare with me if 
this is an easy one... 

I have Julia 0.4.5, with MySQL 0.2.2+ on W7U and MariaDB 10.0.17 I have 
create a database which is set to be the default and then tries to execute 
the sample code with the MySQL.jl from that Github. I used Atom 1.8.0. 
Everything is updated!

The running the sample code, the table is correctly created, but when 
executing the line with the SELECT INSERT it gives an Error on the file 
name refering to the line number after that line. In my case an empty line. 
(So, I found out that Atom's error message window can't be copied from!). 
So manually typed...

LoadError:UdefVarError: @John_str not defined
 in include_string at loading.jl:282
in include_String at C:\Users\Myname\.julia\v.04\CodeTools\src\eval.jl:32
 in anonymous at C:\Users\Myname\ .julia\v0.4\Atom\src\eval.jl:84
 in withpath at C:\Users\Myname\.julia\v0.4\Requires\src\requires.jl:37
 in withpath at C:\Users\Mname\.julia\v0.4\Atom\src\eval.jl:53
 [inlined code] from C:\Users\Myname\.julia\v0.4\Atom\src\eval.jl:83
 in anonymour at task.jl:58
while loading C:\Julia_Code\test_Mysql_localhost.jl, in expression starting 
on line 16

The odd thing - running the test suite that is located from my local MySQL 
test directory with Pkg.test("MySQL") is ok! And, that test suite (3 files 
are run) also uses SELECT INTO, but in a much more complicated way!

So, what is the problem? I have been staring myself blind so far


Re: [julia-users] Re: why the numerical result is different (RK45 julia and matlab)?

2016-06-14 Thread jmarcellopereira

Hi Daniel
I did the test and the difference decreased. interesting, I had not noticed.

Em domingo, 12 de junho de 2016 09:53:40 UTC-3, Daniel Carrera escreveu:
>
> I don't know what you are trying to say, but did you try running the two 
> programs with the same relative and absolute tolerances? Do the results 
> look more similar now?
>
> On 12 June 2016 at 02:01, > wrote:
>
>> Hi daniel
>> in fact, there is a relationship with the tolerance between the methods.
>>
>> Em sábado, 11 de junho de 2016 11:51:53 UTC-3, Daniel Carrera escreveu:
>>>
>>> Probably because the Julia module has different default values for the 
>>> absolute and relative tolerance.  For Julia, the defaults are reltol=1e-5 
>>> and abstol=1e-8 but in Matlab the defaults are RelTol=1e-3 and AbsTol=1e-6.
>>>
>>> https://github.com/JuliaLang/ODE.jl
>>> http://se.mathworks.com/help/matlab/ref/odeset.html
>>>
>>> That would also explain why the Julia program took so much longer. Try 
>>> again with the same tolerance and see if the results are more similar. Oh, 
>>> and like Erik said, you probably meant to have parenthesis around "1/8". If 
>>> the results still look difference, look for more options that might have 
>>> different default values.
>>>
>>> Cheers,
>>> Daniel.
>>>
>>>
>>>
>>> On Saturday, 11 June 2016 04:29:47 UTC+2, jmarcell...@ufpi.edu.br wrote:

 this is the test for equation differential using runge-kutta45: f(x,y)= 
 (-5*x - y/5)^1/8 + 10


 

 why the numerical result is different? I used :

 function Rk_JL()
  f(x,y)= (-5*x - y/5)^1/8 + 10
  tspan = 0:0.001:n
  y0 = [0.0, 1.0]
  return ODE.ode45(f, y0,tspan);end


 and


 function [X1,Y1] = RK_M()
  f = @(x,y) (-5*x - y/5)^1/8 + 10;
  tspan = 0:0.001:n;
  y0 = 1
  [X1,Y1]= ode45(f,tspan,1);end


>

[julia-users] Re: Problem with Homebrew after Pkg.update()

2016-06-14 Thread Tony Kelman
Go into your Pkg.dir("Homebrew") and run `git diff`. The fact that you've 
checked out master and then changed something is making the package "dirty" 
which is preventing it from getting updates. Find out what change you made, 
revert it if possible, then run Pkg.free("Homebrew") to get back from 
master (which is unstable and not recommended for day to day use if you 
aren't specifically testing that package) to a tagged release.

On Sunday, June 12, 2016 at 7:23:15 PM UTC-7, Fabrice Collard wrote:
>
> Sorry, was away. Running the Pkg.status() I get
>
> 21 required packages:
>
>  - Clp   0.2.1
>
>  - DSP   0.0.11
>
>  - DataFrames0.7.3
>
>  - Distributions 0.9.0
>
>  - FastGaussQuadrature   0.0.3
>
>  - Formatting0.1.5
>
>  - FredData  0.1.2
>
>  - GLM   0.5.2
>
>  - Gadfly0.4.2
>
>  - Homebrew  0.2.0+ master (dirty)
>
>  - IJulia1.1.10
>
>  - Interact  0.3.1
>
>  - Interpolations0.3.5
>
>  - Ipopt 0.2.2
>
>  - JuMP  0.13.2
>
>  - MAT   0.2.14
>
>  - NLsolve   0.7.1
>
>  - ODE   0.2.1
>
>  - Optim 0.4.5
>
>  - PyPlot2.1.1+ master
>
>  - TimeSeries0.8.1
>
>
> Thanks
>
> On Tuesday, June 7, 2016 at 12:19:24 AM UTC-4, Tony Kelman wrote:
>>
>> Please answer the original question. What does Pkg.status() say?
>
>

[julia-users] Indexing ranges out of an array

2016-06-14 Thread Jesse Jaanila
I would like to know whats a juliatic way of indexing or slicing evenly 
spaced ranges out of an array:

If I want to take out every n:th element out of Julia array, I would do 
something like

a = [1,2,3,4,5,6];
everySecond = a[2:2:end];

What I would like to achieve is a slice of specified size between evenly 
spaced step sizes. So after n length step, collect a slice of specified 
length. 
So if I have step size as 1 and then I want to take the next two elements I 
would expect the result to be:

a = [1,2,3,4,5,6,7,8,9,10];

magicIndexing(a)
>[2,3,5,6,8,9]

Is there a nice way of achieving something like this?


Re: [julia-users] Re: Can I somehow get Julia without standard library?

2016-06-14 Thread Scott Jones
I think I've shown that it isn't too difficult (I started my Julia-lite 
branch originally just a couple months after learning Julia), it's mostly 
some tedious work, and most people are concentrating on other (very 
important) stuff.
I pushed to make this because I was interested in having things work better 
without so much overhead on things like my Raspberry Pi 2 Model B, later my 
Raspberry Pi 3, and now my Jetson TX1.  Also, I wanted a faster loading 
Julia for scripts (as now I prefer to write my scripts in Julia, instead of 
having to use Python or bash).

On Tuesday, June 14, 2016 at 11:01:00 AM UTC-4, Chris Rackauckas wrote:
>
> I agree that more should be backed out to packages. Even as a math person 
> who would probably never Julia without linear algebra, I think that some of 
> the linear algebra should move out to a JuliaMath package, and then part of 
> the standard startup script should be to "using LinAlg". That way if 
> someone is doing a lite install and doesn't need it, they don't have to 
> have it. From what I know about the way that namespaces work in Julia, 
> there would be no difference in the end: *, \, etc. would all work how I'd 
> expect.
>
> So I think a few things like that (sparse matrices, parallelism?) should 
> move out to packages which, in a normal build, are automatically installed 
> and the setup script automatically imports them when Julia is started. 
>
> At least from my understanding of how Julia works, that doesn't seem too 
> difficult. But maybe someone could chime in on why it would be almost 
> impossible, or if it's on the horizon?
>
> On Tuesday, June 14, 2016 at 7:23:46 AM UTC-7, Scott Jones wrote:
>>
>> You should try out my "lite" branch of Julia, I got it back in sync with 
>> master yesterday, made sure it still passed the unit tests, etc.
>> https://github.com/ScottPJones/julia/tree/spj/lite
>> I don't think it's so black and white as Avik and Stefan have made it 
>> seem.
>> My lite branch takes less than half as much space, has smaller memory 
>> requirements (nice for using on my Raspberry Pi!), is much faster to build 
>> from source, and is still a very useful language.
>>
>> If there are parts that you need that I've cut out, all you have to do is 
>> override an environment variable BUILD_ in Make.user (where  
>> can be the following:
>> BIGINT, BIGFLT, DSP, DATES, STATS, THREADS, PROFILER, MMAP, PKG, FLOAT16, 
>> LINALG, SPARSE, COMPLEX, RATIONAL
>> The following I normally leave enabled, but can be turned off to make a 
>> Julia without a REPL, that's good for running scripts: PARALLEL, DOCS, 
>> HELP, REPL, TEST
>> Enabling BUILD_FULL will enable everything by default (but then you can 
>> still explicitly disable them).
>>
>> What I haven't done, which I hope will be worked on for Julia v0.6, is to 
>> have these parts of the current standard library either moved out to 
>> packages, so they could be reloaded with using,
>> or to be loaded more on a "as-needed" basis,
>> from modules that are already compiled along with the base language, but 
>> left in separate .ji files. along with the sys library.
>>
>>
>>
>> On Tuesday, June 14, 2016 at 5:34:36 AM UTC-4, Dmitry wrote:
>>>
>>> That's what I was afraid of. It comes that Julia is very strongly tied 
>>> to its library. I was hoping that it would be like with most other 
>>> languages, for example C++. I mean C++ know about basic types and how to 
>>> work with them (and much more) even without the standard library.
>>>
>>> понедельник, 6 июня 2016 г., 21:17:16 UTC+4 пользователь Stefan 
>>> Karpinski написал:

 Really useless – it doesn't know about integers or how add them, for 
 example. If you want to trim down the standard library, you can try 
 editing 
 out parts of base/sysimg.jl and rebuilding, but that's kind of a tricky 
 process.

 On Mon, Jun 6, 2016 at 12:43 PM, Avik Sengupta  
 wrote:

> Julia is pretty useless without its standard library. 
>
> On Monday, 6 June 2016 14:42:02 UTC+1, Dmitry wrote:
>>
>> I tried to remove ".jl" library files from Julia installation 
>> directory, but it did not help. Then I tried to remove "libjulia.dll" 
>> but 
>> it does not want to run without this file.
>>
>


Re: [julia-users] Re: Can I somehow get Julia without standard library?

2016-06-14 Thread Chris Rackauckas
I agree that more should be backed out to packages. Even as a math person 
who would probably never Julia without linear algebra, I think that some of 
the linear algebra should move out to a JuliaMath package, and then part of 
the standard startup script should be to "using LinAlg". That way if 
someone is doing a lite install and doesn't need it, they don't have to 
have it. From what I know about the way that namespaces work in Julia, 
there would be no difference in the end: *, \, etc. would all work how I'd 
expect.

So I think a few things like that (sparse matrices, parallelism?) should 
move out to packages which, in a normal build, are automatically installed 
and the setup script automatically imports them when Julia is started. 

At least from my understanding of how Julia works, that doesn't seem too 
difficult. But maybe someone could chime in on why it would be almost 
impossible, or if it's on the horizon?

On Tuesday, June 14, 2016 at 7:23:46 AM UTC-7, Scott Jones wrote:
>
> You should try out my "lite" branch of Julia, I got it back in sync with 
> master yesterday, made sure it still passed the unit tests, etc.
> https://github.com/ScottPJones/julia/tree/spj/lite
> I don't think it's so black and white as Avik and Stefan have made it seem.
> My lite branch takes less than half as much space, has smaller memory 
> requirements (nice for using on my Raspberry Pi!), is much faster to build 
> from source, and is still a very useful language.
>
> If there are parts that you need that I've cut out, all you have to do is 
> override an environment variable BUILD_ in Make.user (where  
> can be the following:
> BIGINT, BIGFLT, DSP, DATES, STATS, THREADS, PROFILER, MMAP, PKG, FLOAT16, 
> LINALG, SPARSE, COMPLEX, RATIONAL
> The following I normally leave enabled, but can be turned off to make a 
> Julia without a REPL, that's good for running scripts: PARALLEL, DOCS, 
> HELP, REPL, TEST
> Enabling BUILD_FULL will enable everything by default (but then you can 
> still explicitly disable them).
>
> What I haven't done, which I hope will be worked on for Julia v0.6, is to 
> have these parts of the current standard library either moved out to 
> packages, so they could be reloaded with using,
> or to be loaded more on a "as-needed" basis,
> from modules that are already compiled along with the base language, but 
> left in separate .ji files. along with the sys library.
>
>
>
> On Tuesday, June 14, 2016 at 5:34:36 AM UTC-4, Dmitry wrote:
>>
>> That's what I was afraid of. It comes that Julia is very strongly tied to 
>> its library. I was hoping that it would be like with most other languages, 
>> for example C++. I mean C++ know about basic types and how to work with 
>> them (and much more) even without the standard library.
>>
>> понедельник, 6 июня 2016 г., 21:17:16 UTC+4 пользователь Stefan Karpinski 
>> написал:
>>>
>>> Really useless – it doesn't know about integers or how add them, for 
>>> example. If you want to trim down the standard library, you can try editing 
>>> out parts of base/sysimg.jl and rebuilding, but that's kind of a tricky 
>>> process.
>>>
>>> On Mon, Jun 6, 2016 at 12:43 PM, Avik Sengupta  
>>> wrote:
>>>
 Julia is pretty useless without its standard library. 

 On Monday, 6 June 2016 14:42:02 UTC+1, Dmitry wrote:
>
> I tried to remove ".jl" library files from Julia installation 
> directory, but it did not help. Then I tried to remove "libjulia.dll" but 
> it does not want to run without this file.
>

>>>

[julia-users] Re: Standard wrapper for global variable optimization hack?

2016-06-14 Thread Arch Robison
Thanks Kristoffer for the suggestion of Ref.  It indeed is the  kind of 
wrapper I was looking for.

Thanks Eric for catching my typo.  Yes, it should be `const w = 
wrapper(0.0)`, with the w instead of x.


Re: [julia-users] Re: Can I somehow get Julia without standard library?

2016-06-14 Thread Scott Jones
You should try out my "lite" branch of Julia, I got it back in sync with 
master yesterday, made sure it still passed the unit tests, etc.
https://github.com/ScottPJones/julia/tree/spj/lite
I don't think it's so black and white as Avik and Stefan have made it seem.
My lite branch takes less than half as much space, has smaller memory 
requirements (nice for using on my Raspberry Pi!), is much faster to build 
from source, and is still a very useful language.

If there are parts that you need that I've cut out, all you have to do is 
override an environment variable BUILD_ in Make.user (where  
can be the following:
BIGINT, BIGFLT, DSP, DATES, STATS, THREADS, PROFILER, MMAP, PKG, FLOAT16, 
LINALG, SPARSE, COMPLEX, RATIONAL
The following I normally leave enabled, but can be turned off to make a 
Julia without a REPL, that's good for running scripts: PARALLEL, DOCS, 
HELP, REPL, TEST
Enabling BUILD_FULL will enable everything by default (but then you can 
still explicitly disable them).

What I haven't done, which I hope will be worked on for Julia v0.6, is to 
have these parts of the current standard library either moved out to 
packages, so they could be reloaded with using,
or to be loaded more on a "as-needed" basis,
from modules that are already compiled along with the base language, but 
left in separate .ji files. along with the sys library.



On Tuesday, June 14, 2016 at 5:34:36 AM UTC-4, Dmitry wrote:
>
> That's what I was afraid of. It comes that Julia is very strongly tied to 
> its library. I was hoping that it would be like with most other languages, 
> for example C++. I mean C++ know about basic types and how to work with 
> them (and much more) even without the standard library.
>
> понедельник, 6 июня 2016 г., 21:17:16 UTC+4 пользователь Stefan Karpinski 
> написал:
>>
>> Really useless – it doesn't know about integers or how add them, for 
>> example. If you want to trim down the standard library, you can try editing 
>> out parts of base/sysimg.jl and rebuilding, but that's kind of a tricky 
>> process.
>>
>> On Mon, Jun 6, 2016 at 12:43 PM, Avik Sengupta  
>> wrote:
>>
>>> Julia is pretty useless without its standard library. 
>>>
>>> On Monday, 6 June 2016 14:42:02 UTC+1, Dmitry wrote:

 I tried to remove ".jl" library files from Julia installation 
 directory, but it did not help. Then I tried to remove "libjulia.dll" but 
 it does not want to run without this file.

>>>
>>

Re: [julia-users] Re: Can I somehow get Julia without standard library?

2016-06-14 Thread Stefan Karpinski
Tamas is dead on – see the intro of
https://www.youtube.com/watch?v=dK3zRXhrFZY for an explanation. Being able
to define even the most basis types in Julia itself is one of the most
powerful features of the language.

Let's back up a little here. What are you trying to accomplish?

On Tue, Jun 14, 2016 at 7:40 AM, Dmitry  wrote:

> So. I stepped deeper into the Julia standard library and found some
> interesting things. I mean intrinsic functions. If I understand correctly
> this is the glue between the language core and the library. Is there any
> documentation about intrinsics?
>
> понедельник, 6 июня 2016 г., 17:42:02 UTC+4 пользователь Dmitry написал:
>>
>> I tried to remove ".jl" library files from Julia installation directory,
>> but it did not help. Then I tried to remove "libjulia.dll" but it does not
>> want to run without this file.
>>
>


[julia-users] Re: how can I create an incidence matrix

2016-06-14 Thread Robert Schwarz
I think that this would give you the adjacency matrix.

In LightGraphs.jl , there is 
a method incidence_matrix that might be useful.


On Tuesday, June 14, 2016 at 8:46:08 AM UTC+2, Ford O. wrote:
>
> Are you sure you know what is incidence matrix? wiki 
> 
>
> You don't need any dictionaries to implement it. Just use simple Array().
>
> matrix = fill(false, row_size, col_size)
> from_node = scan_input()
> to_node   = scan_input()
> matrix[from_node, to_node] = true
>
>

[julia-users] Re: Can I somehow get Julia without standard library?

2016-06-14 Thread Dmitry
So. I stepped deeper into the Julia standard library and found some 
interesting things. I mean intrinsic functions. If I understand correctly 
this is the glue between the language core and the library. Is there any 
documentation about intrinsics?

понедельник, 6 июня 2016 г., 17:42:02 UTC+4 пользователь Dmitry написал:
>
> I tried to remove ".jl" library files from Julia installation directory, 
> but it did not help. Then I tried to remove "libjulia.dll" but it does not 
> want to run without this file.
>


Re: [julia-users] Re: Can I somehow get Julia without standard library?

2016-06-14 Thread Tamas Papp
Look at it this way: Julia is so powerful that many language features
can be implemented natively, instead of using primitives.

On Tue, Jun 14 2016, Dmitry wrote:

> That's what I was afraid of. It comes that Julia is very strongly tied to 
> its library. I was hoping that it would be like with most other languages, 
> for example C++. I mean C++ know about basic types and how to work with 
> them (and much more) even without the standard library.
>
> понедельник, 6 июня 2016 г., 21:17:16 UTC+4 пользователь Stefan Karpinski 
> написал:
>>
>> Really useless – it doesn't know about integers or how add them, for 
>> example. If you want to trim down the standard library, you can try editing 
>> out parts of base/sysimg.jl and rebuilding, but that's kind of a tricky 
>> process.
>>
>> On Mon, Jun 6, 2016 at 12:43 PM, Avik Sengupta > > wrote:
>>
>>> Julia is pretty useless without its standard library. 
>>>
>>> On Monday, 6 June 2016 14:42:02 UTC+1, Dmitry wrote:

 I tried to remove ".jl" library files from Julia installation directory, 
 but it did not help. Then I tried to remove "libjulia.dll" but it does not 
 want to run without this file.

>>>
>>



[julia-users] MethodError closest candidate is same as "no matching method" method

2016-06-14 Thread Toivo Henningsson
Could it be that you happened to reload Nemo after using/importing it? This 
kind of thing can happen when there are two live instances of the same module 
and your code happens to combine types/functions from both.


Re: [julia-users] Re: Can I somehow get Julia without standard library?

2016-06-14 Thread Dmitry
That's what I was afraid of. It comes that Julia is very strongly tied to 
its library. I was hoping that it would be like with most other languages, 
for example C++. I mean C++ know about basic types and how to work with 
them (and much more) even without the standard library.

понедельник, 6 июня 2016 г., 21:17:16 UTC+4 пользователь Stefan Karpinski 
написал:
>
> Really useless – it doesn't know about integers or how add them, for 
> example. If you want to trim down the standard library, you can try editing 
> out parts of base/sysimg.jl and rebuilding, but that's kind of a tricky 
> process.
>
> On Mon, Jun 6, 2016 at 12:43 PM, Avik Sengupta  > wrote:
>
>> Julia is pretty useless without its standard library. 
>>
>> On Monday, 6 June 2016 14:42:02 UTC+1, Dmitry wrote:
>>>
>>> I tried to remove ".jl" library files from Julia installation directory, 
>>> but it did not help. Then I tried to remove "libjulia.dll" but it does not 
>>> want to run without this file.
>>>
>>
>

Re: [julia-users] Standard wrapper for global variable optimization hack?

2016-06-14 Thread Kristoffer Carlsson
I still think Ref is the way to go.

const a = Ref{Float64}(0.0)

inc_ref() = a[] += 1

@code_llvm inc_ref()

define double @julia_inc_ref_50012() #0 {
top:
  %0 = load double, double* inttoptr (i64 140310118277680 to double*), 
align 16
  %1 = fadd double %0, 1.00e+00
  store double %1, double* inttoptr (i64 140310118277680 to double*), align 
16
  ret double %1
}


type wrapper{T}
x::T
end

const w = wrapper(0.0)

function inc_global()
w.x += 1
end

@code_llvm inc_global()

define double @julia_inc_global_50045() #0 {
top:
  %0 = load double, double* inttoptr (i64 139878620260272 to double*), 
align 16
  %1 = fadd double %0, 1.00e+00
  store double %1, double* inttoptr (i64 139878620260272 to double*), align 
16
  ret double %1
}

Hope I managed to paste everything correctly this time...

On Tuesday, June 14, 2016 at 6:51:32 AM UTC+2, Eric Forgy wrote:
>
> Creating a global instance of a special type seems reasonable to me. I 
> also use global Dict's for this kind of thing.
>
> Instead of inc_global, I might define 
>
> Base.(:+)(w::wrapper,s) = w.x + s 
>
> so you can just do `w += 1` :)
>
> If you find a better way, I would love to see it.
>
> PS: Minor point, but looks like you have a typo. Should be `const w = 
> wrapper(0.0)` I think. No biggie.
>
> On Tuesday, June 14, 2016 at 8:41:40 AM UTC+8, Arch Robison wrote:
>>
>> Indeed the one-element vector case was what inspired my wrapper.  I 
>> created the wrapper to avoid the run-time bounds check on the vector, 
>> though I suppose I could sprinkle @inbounds to eliminate it.
>>
>> On Mon, Jun 13, 2016 at 6:40 PM, Eric Forgy  wrote:
>>
>>> Not sure if this is the best way (curious about 'Ref'), but you could 
>>> also make x a 1-element vector:
>>>
>>> const x = [0]
>>>
>>> x[1] += 1
>>>
>>
>>

Re: [julia-users] Standard wrapper for global variable optimization hack?

2016-06-14 Thread Kristoffer Carlsson
I feel my suggestion with Ref went a bit unnoticed..

const a = Ref(0.0)

inc_ref() = a[] += 1

@code_llvm inc_ref()

define i64 @julia_inc_ref_50057() #0 {
top:
  %0 = load i64, i64* inttoptr (i64 140258091307984 to i64*), align 16
  %1 = add i64 %0, 1
  store i64 %1, i64* inttoptr (i64 140258091307984 to i64*), align 16
  ret i64 %1
}

type wrapper{T}
x::T
end

const w = wrapper(0.0)

function inc_global()
w.x += 1
end

@code_llvm inc_global()

define double @julia_inc_global_50131() #0 {
top:
  %0 = load double, double* inttoptr (i64 140258000874464 to double*), 
align 32
  %1 = fadd double %0, 1.00e+00
  store double %1, double* inttoptr (i64 140258000874464 to double*), align 
32
  ret double %1
}


Same code is generated so Ref is pretty much the official way of doing this 
type of wrapping.

On Tuesday, June 14, 2016 at 6:51:32 AM UTC+2, Eric Forgy wrote:
>
> Creating a global instance of a special type seems reasonable to me. I 
> also use global Dict's for this kind of thing.
>
> Instead of inc_global, I might define 
>
> Base.(:+)(w::wrapper,s) = w.x + s 
>
> so you can just do `w += 1` :)
>
> If you find a better way, I would love to see it.
>
> PS: Minor point, but looks like you have a typo. Should be `const w = 
> wrapper(0.0)` I think. No biggie.
>
> On Tuesday, June 14, 2016 at 8:41:40 AM UTC+8, Arch Robison wrote:
>>
>> Indeed the one-element vector case was what inspired my wrapper.  I 
>> created the wrapper to avoid the run-time bounds check on the vector, 
>> though I suppose I could sprinkle @inbounds to eliminate it.
>>
>> On Mon, Jun 13, 2016 at 6:40 PM, Eric Forgy  wrote:
>>
>>> Not sure if this is the best way (curious about 'Ref'), but you could 
>>> also make x a 1-element vector:
>>>
>>> const x = [0]
>>>
>>> x[1] += 1
>>>
>>
>>

[julia-users] Re: Standard wrapper for global variable optimization hack?

2016-06-14 Thread Kristoffer Carlsson
I feel my suggestion with Ref was under appreciated.

const a = Ref{Int}(0)

inc_ref() = a[] += 1

julia> @code_llvm inc_ref()

define double @julia_inc_ref_50012() #0 {
top:
  %0 = load double, double* inttoptr (i64 140198715724432 to double*), 
align 16
  %1 = fadd double %0, 1.00e+00
  store double %1, double* inttoptr (i64 140198715724432 to double*), align 
16
  ret double %1
}

type wrapper{T}
x::T
end

const w = wrapper(0.0)

function inc_global()
w.x += 1
end

@code_llvm inc_global()

julia> @code_llvm inc_global()

define double @julia_inc_global_50131() #0 {
top:
  %0 = load double, double* inttoptr (i64 140258000874464 to double*), 
align 32
  %1 = fadd double %0, 1.00e+00
  store double %1, double* inttoptr (i64 140258000874464 to double*), align 
32
  ret double %1
}

So Ref generates the exact same code as the wrapper so if anything, Ref is 
the official way of doing this.

On Monday, June 13, 2016 at 11:37:21 PM UTC+2, Arch Robison wrote:
>
> I'm revising the notes for my JuliaCon workshop, and wondering if there is 
> a standard way/convention for the following hack to reduce the overhead of 
> accessing a global variable.  The hack is to replace a global variable, if 
> known to always be bound to objects of the same type, with a const variable 
> that wraps a reference to the the object.  For example, instead of writing:
> x = 0.0
>
> function inc_global()
>global x
>x += 1
> end
>
> we would write:
>
> type wrapper{T}
> x::T
> end
>
> const x = wrapper(0.0)
>
> function inc_global()
> w.x += 1
> end
>
> Is there a standard library type that serves the purpose of `wrapper`, or 
> a standard type that can be abused to do so?
>


Re: [julia-users] Changing the year in two digit year using DateTime

2016-06-14 Thread Tamas Papp
Try something like

function dateYY(d)
y = Dates.year(d)
if 70 <= y <= 99
d+Dates.Year(1900)
elseif 0 <= y <= 20
d+Dates.Year(2000)
else
error(@sprintf("don't know what to do with year %d", y))
end
end

eg

dateYY(DateTime("96/15/03", "yy/dd/mm"))
dateYY(DateTime("00/15/03", "yy/dd/mm"))
dateYY(DateTime("19/15/03", "yy/dd/mm"))
dateYY(DateTime("70/15/03", "yy/dd/mm"))

Cutoffs would depend on your dataset.

Best,

Tamas

On Tue, Jun 14 2016, akrun wrote:

> Hi,
>
> If I have a vector of dates
>
>v1 = ["96/15/03", "15/15/03"]
>
> Using DateTime, it gives
>
> DateTime(v1, "yy/dd/mm")
> #2-element Array{DateTime,1}:
> #0096-03-15T00:00:00
> #0015-03-15T00:00:00
>
> How do I get
>
>  1996-03-15T00:00:00 and 2015-03-15T00:00:00
>
> Thanks


[julia-users] Re: Changing the year in two digit year using DateTime

2016-06-14 Thread Eric Forgy
How's this?

julia>  v1 = ["96/15/03", "15/15/03"]
2-element Array{ASCIIString,1}:
 "96/15/03"
 "15/15/03"

julia> dt = DateTime(v1,"yy/dd/mm")
2-element Array{DateTime,1}:
 0096-03-15T00:00:00
 0015-03-15T00:00:00

julia> [Dates.year(d) > 16 ? d+Dates.Year(1900) : d+Dates.Year(2000) for d 
in dt]
2-element Array{Any,1}:
 1996-03-15T00:00:00
 2015-03-15T00:00:00


On Tuesday, June 14, 2016 at 3:00:01 PM UTC+8, akrun wrote:
>
> Hi,
>
> If I have a vector of dates
>
>v1 = ["96/15/03", "15/15/03"]
>
> Using DateTime, it gives
>
> DateTime(v1, "yy/dd/mm")
> #2-element Array{DateTime,1}:
> #0096-03-15T00:00:00
> #0015-03-15T00:00:00
>
> How do I get
>
>  1996-03-15T00:00:00 and 2015-03-15T00:00:00
>
> Thanks
>


[julia-users] Changing the year in two digit year using DateTime

2016-06-14 Thread akrun
Hi,

If I have a vector of dates

   v1 = ["96/15/03", "15/15/03"]

Using DateTime, it gives

DateTime(v1, "yy/dd/mm")
#2-element Array{DateTime,1}:
#0096-03-15T00:00:00
#0015-03-15T00:00:00

How do I get

 1996-03-15T00:00:00 and 2015-03-15T00:00:00

Thanks