[julia-users] Re: Julia 0.5 Highlights

2016-10-12 Thread Evan Fields
Thanks for writing this up; it's helpful to see certain things highlighted 
and explained in more detail than news.md gives!


Re: [julia-users] Do threads in a threaded loop have their own scope?

2016-10-11 Thread Evan Fields
I'm unsure if "bit shared" is a technical term I should know, or if "bit 
shared" is a smartphone typo for "not shared" which would describe my 
understanding of normal loops, where it seems each iteration doesn't have 
access to loop-only variables defined in a previous iteration. :)

I guess the better question is if I want to run my f(mt::MyType) 
simulations in parallel, what's the best way to do so?


[julia-users] Do threads in a threaded loop have their own scope?

2016-10-11 Thread Evan Fields
Let's say I have a type MyType and function f(mt::MyType) which is slow and 
stochastic. I have an object y::MyType, and I'd like to compute f(y) many 
times.

If I write a loop like 
fvals = Vector{Float64}(100)
Threads.@threads for i in 1:length(fvals)
  ycopy = deepcopy(y)
  fvals[i] = f(ycopy)
end

The various loop iterations are not interfering with each other, right? 
Each has its own copy of y?


[julia-users] Re: PkgDev.tag issues

2016-09-24 Thread Evan Fields
I've had this problem as well so I'm eager to learn a solution. It was a 
while ago, but when this happened to me, git status in the metadata repo 
would show uncommitted changes. I think I had to reset metadata to a clean 
state, manually delete some tags in the package repository, and run the 
package commands again.


Re: [julia-users] ls()?

2016-09-14 Thread Evan Fields
Which can get gnarly on Windows, depending how you launched Julia. E.g. 
just launching from the Julia executable:


shell> ls
ERROR: could not spawn `ls`: no such file or directory (ENOENT)
 in _jl_spawn(::String, ::Array{String,1}, ::Ptr{Void}, ::Base.Process, 
::RawFD, ::RawFD, ::RawFD) at .\process.jl:321
 in #414 at .\process.jl:478 [inlined]
 in setup_stdio(::Base.##414#415{Cmd,Ptr{Void},Base.Process}, 
::Tuple{RawFD,RawFD,RawFD}) at .\process.jl:466
 in #spawn#413(::Nullable{Base.ProcessChain}, ::Function, ::Cmd, 
::Tuple{RawFD,RawFD,RawFD}, ::Bool, ::Bool) at .\process.jl:477
 in run(::Cmd) at .\process.jl:591
 in repl_cmd(::Cmd, ::Base.Terminals.TTYTerminal) at .\client.jl:91

julia>

(It works fine if launched from Git bash)


[julia-users] Re: dependent types in julia?

2016-09-14 Thread Evan Fields
I'm not sure then, but hopefully someone here can help you out! Naively 
perhaps it feels like this makes the type inference impossible. Your 
function decomplexify always produces the same output for the same input, 
but what if you had a function that returned a different output (always of 
type DataType) based on a random number generated inside the function? Then 
using that function to annotate field types would be super hairy, right?


[julia-users] Re: dependent types in julia?

2016-09-14 Thread Evan Fields
How about something like the following?

type CT{T}
ctsum::Complex{T}
ctsumsq::T
end

x = 1 + 2im

ctx = CT(x, convert(decomplexify(typeof(x)), x * conj(x))

You could also make a convenience function so you don't have to do the 
converts yourself for the second argument.
Have you seen the standard docs on parametric 
types? 
http://docs.julialang.org/en/release-0.5/manual/types/#man-parametric-types


[julia-users] Rescuing abandoned package

2016-09-02 Thread Evan Fields
I use the package GreatCircle  for 
great circle distance calculations. On 0.4.x it generates depwarns, and 
it's incompatible with 0.5. I've opened a pull request with the tiny 
changes needed to use the package on 0.5, but there's been no response and 
from the author's Github profile it looks like he/she is no longer 
generally active. Is there a way to rescue the package in this situation? 
(Besides perhaps forking and renaming, which leads to cluttered package 
names...)


Re: [julia-users] Re: Return type of eye()

2016-08-29 Thread Evan Fields


On Monday, August 29, 2016 at 9:39:19 AM UTC-4, Júlio Hoffimann wrote:
>
> I'd like to understand the existence of eye() in Julia, it is still not 
> clear to me. Is it because one wants type stability when updating a matrix 
> iteratively? Is this possibly a limitation from the design of the language?
>
> -Júlio
>

I've used it for things like 
m = m + lambda*eye(m)

 


[julia-users] Re: DataFrame Manipulation (like dplyr) Help

2016-08-26 Thread Evan Fields
I'm not sure if you'll find this any cleaner, but maybe something like

function summary2(df, queries...)
  d = Dict()
  for query in queries
name = query[1]
f = query[2]
col = query[3]
d[name] = f(df[col])
  end
  return d
end

Which could be used e.g.

julia> summary2(dat, ("mu_x", mean, :x), ("std_y", std, :y))
Dict{Any,Any} with 2 entries:
  "std_y" => 0.338854
  "mu_x"  => 0.438158

julia>

Admittedly this is less flexible, but perhaps more transparent. 


[julia-users] Re: AutoGrad port for Julia

2016-08-26 Thread Evan Fields
This looks really interesting. Can you give the high level comparison of 
how this compares to the various JuliaDiff tools and when to use one over 
the other?


Re: [julia-users] Proposed solution for writing Enums

2016-08-23 Thread Evan Fields
@enum doesn't do what you want for enums?


[julia-users] Julia 0.5.0-rc2 allocates 6x as much as and runs 4x slower than Julia 0.4.6

2016-08-18 Thread Evan Fields
Unfortunately I haven't been able to find a minimal reproducing example, so 
first the relevant snippet then the whole function. I have some code which 
contains the following inner loop:

for after in 1:(length(path) - 1) # can't insert after end of path
counter += 1
c = inscost(k, after)
if c < bestCost
bestCost = c
bestInsertion = (k, after)
end
end

where inscost is a one-line closure:

function inscost(k, after)
return distmat[path[after], k] + 
   distmat[k, path[after + 1]] -
   distmat[path[after], path[after + 1]]
end

Running on Julia 0.5.0-rc2 is about 4x slower than running on Julia 0.4.6, 
and it seems to be because 0.5.0 is doing way more allocations. In 
particular, using the @timev macro shows that Julia 0.5.0 does 6 pool 
allocs* per inner loop, whereas Julia 0.4.6 does only 1 pool alloc per 
inner loop. This is true whether I prefix function inscost with @inline, 
@noinline, or no decoration. On a typical function call, Julia 0.5.0 
allocates 18.6 MB, and Julia 0.4.6 allocates 3.0 MB.

If I move the body of inscost into the inner loop, Julia 0.5.0 is now 
lightning fast and allocates only 584 KB for the same function call:

for after in 1:(length(path) - 1) # can't insert after end of path
counter += 1
c = distmat[path[after], k] + 
distmat[k, path[after + 1]] -
distmat[path[after], path[after + 1]]
if c < bestCost
bestCost = c
bestInsertion = (k, after)
end
end

Any thought what's going on, how to avoid this performance penalty in 
general (manually inlining here is easy, but could be painful or hard to 
diagnose elsewhere), and whether this is worth a Github issue?

For context, here's the full function. It's a simple/naive implementation 
of the cheapest insertion heuristic for the traveling salesman problem.

function cheapest_insertion{T<:Real}(distmat::Matrix{T}, 
initpath::Vector{Int})
check_square(distmat, "Distance matrix passed to cheapest_insertion must be 
square.")
n = size(distmat, 1)
path = copy(initpath)
# collect cities to visited
visitus = setdiff(collect(1:n), initpath)
# helper for insertion cost
# tour cost change for inserting node k after the node at index after in 
the path
function inscost(k, after)
return distmat[path[after], k] + 
 distmat[k, path[after + 1]] -
 distmat[path[after], path[after + 1]]
end
while !isempty(visitus)
bestCost = Inf
bestInsertion = (-1, -1)
for k in visitus
for after in 1:(length(path) - 1) # can't insert after end of path
c = inscost(k, after)
if c < bestCost
bestCost = c
bestInsertion = (k, after)
end
end
end
# bestInsertion now holds (k, after)
# insert into path, remove from to-do list
k, after = bestInsertion
insert!(path, after + 1, k)
visitus = setdiff(visitus, k)
end
return (path, pathcost(distmat, path))
end

* confession time: I don't know what "pool allocs" is measuring or whether 
to focus on that vs. bytes allocated...


[julia-users] Re: ANN: Julia 0.5.0-rc2 now available

2016-08-13 Thread Evan Fields
Thanks Tony. Two questions, one related to Uwe's question:

1) I noticed earlier that 0.5.0-rc0 starts up much faster than 0.4.6 but is 
a little slower on initial function calls. Does it load or precompile less 
of the standard library on startup? 
2) Is there / will there be a list of important changes 0.4.x -> 0.5.0 
besides the github commit log, which is useful but hard to parse if your 
general question is "how should I change my mental model of Julia programs?"


[julia-users] Re: Working with DataFrame columns types that are Nullable

2016-07-22 Thread Evan Fields
As far as I know, DataFrames are only backed by DataArrays. (I believe 
there's current work being done to upgrade the speed and type stability of 
DataFrames, in part by using Nullables.)

It might be helpful to write a little convenience function like

f(n) = isnull(n) ? NA : get(n)

I will say I've found DataArrays to be super finicky when inferring types. 
YMMV.


[julia-users] Pkg operations hanging on Windows with Julia 0.4.6

2016-06-21 Thread Evan Fields
I upgraded from 0.4.5 to 0.4.6 today and did a little work with no issue. 
Then I ran Pkg.update() and apparently updated the cache of a few packages. 
When Pkg.update got to Conda, everything seemed to hang. After letting that 
run about 40 minutes I killed the Julia process, restarted, and tried 
Pkg.update again. The first package it tried to update was DataStreams, and 
that also hung for a while. I killed that process, started a new one, and 
Pkg.resolve() ran for a half hour without giving any output. I thought 
maybe there was a problem with Conda and I should remove and reinstall it, 
and Pkg.rm("Conda") did work, but everything else just hangs indefinitely.

I tested on my other computer (also running Windows but still on Julia 
0.4.5) and it updated all its needed packages successfully.

Thoughts? Bug worth trying to chase down or just uninstall Julia, nuke the 
.julia folder, and reinstall?

Thanks,
Evan


[julia-users] Re: JuliaCon schedule announced

2016-06-20 Thread Evan Fields
Can non-registered local Julia fans show up for the hackathon?


[julia-users] Re: function! vs. function

2016-06-12 Thread Evan Fields
Apologies if this is obvious, but: appending ! to a function name doesn't 
do anything special. It is convention to "append ! to names of functions 
that modify their arguments" (from the manual, section style guide). But 
this is just a naming convention and doesn't affect how the function is 
actually computed.


[julia-users] Re: ANN: PkgSearch - a REPL utility for package discovery

2016-06-04 Thread Evan Fields
Hi, this looks great. Two comments from playing around a little bit.

1) PkgSearch.lookup fails if any of the arguments contain a space. In 
general maybe add to the documentation some notes about whitespace, case 
sensitivity, etc.?
2) The search seems to get confused between package names and the 
corresponding github respository name, which often differ by a .jl at the 
end. For example, JuMP is one of the most used Julia packages, you can find 
it on pkg.julialang.org, etc. But PkgSearch.details("JuMP") will give an 
error. PkgSearch.details("JuMP.jl") gives the readme and associated info 
from the correct git repo except labels the package unofficial.

Let me know if you want me to open issues on github, etc. Great work 
overall!


[julia-users] Re: Getting sequence of time and subset it

2016-06-01 Thread Evan Fields
Of course there's a way :)

You can use the isna function to check if a value is NA or not. There's 
also the dropna function which takes a DataArray as input and returns a 
regular Vector with the NA elements removed.

You could try something like the following:

firstbreakcol = 4
lastbreakcol = 5
for i in 1:nrow(sdt2), t in 
sdt2[:StartTime][i]:Dates.Minute(30):sdt2[:EndTime][i]
shouldprint = true
for j in firstbreakcol:lastbreakcol
if !isna(sdt2[i,j]) && sdt2[i,j] == t
# t is in a break column
shouldprint = false
break
end
end
if shouldprint
println(t)
end
end

It's a little verbose, true. I'm sure there's something cleaner with 
dropna, filter, etc.


[julia-users] Re: Getting sequence of time and subset it

2016-05-30 Thread Evan Fields
I'm not 100% sure I understand your question, but let me give it a shot. 

First thing is to note why you're getting that MethodError. It's from the 
line

println(si in sdt1[i, [:BreakTime1, :BreakTime2]])

Define sdt1 as you do (I just copied into a Julia REPL) and set i = 1 to 
for the first iteration of the for loop.

Then:

julia> sdt1[i, [:BreakTime1, :BreakTime2]]
1×2 DataFrames.DataFrame
│ Row │ BreakTime1  │ BreakTime2  │
├─┼─┼─┤
│ 1   │ 2016-04-13T10:00:00 │ 2016-04-13T12:00:00 │

julia> si = 
Dates.format([sdt1[i,:StartTime]:Dates.Minute(30):sdt1[i,:EndTime]], 
"HH:MM")
WARNING: [a] concatenation is deprecated; use collect(a) instead
 in depwarn at deprecated.jl:73
 in oldstyle_vcat_warning at abstractarray.jl:29
 in vect at abstractarray.jl:32
while loading no file, in expression starting on line 0
11-element Array{Any,1}:
 "07:15"
 "07:45"
 "08:15"
 "08:45"
 "09:15"
 "09:45"
 "10:15"
 "10:45"
 "11:15"
 "11:45"
 "12:15"

julia> si in sdt1[i, [:BreakTime1, :BreakTime2]]
ERROR: MethodError: `start` has no method matching 
start(::DataFrames.DataFrame)
 in mapreduce_sc_impl at reduce.jl:194
 in in at reduce.jl:377

So si is of type Vector{Any} but happens to hold strings. sdt1[i, 
[:BreakTime1, :BreakTime2]] is a DataFrame. What does it mean to ask if a 
vector is in a DataFrame? That's what's happening in your println; the `in` 
is just an infix operator of function in.

3-element Array{Int64,1}:
 1
 2
 3

julia> 1 in x
true

julia> in(1,x)
true

julia> in(5,x)
false

I assume you get the MethodError of no method start because in(a,b) 
iterates over b, checking each element of b for equality to a. But 
DataFrames are not iterable in this way. (This part just a guess; look it 
up in the manual before telling your friends.)

Anyway, to get output as from your R snippet, you could use a loop like the 
following:

julia> for i in 1:nrow(sdt1), t in 
sdt1[:StartTime][i]:Dates.Minute(30):sdt1[:EndTime][i]
   if !(t in [sdt1[:BreakTime1][i], sdt1[:BreakTime2][i]])
   println("$i $(Dates.format(t, "HH:MM"))")
   end
   end
1 07:00
1 07:30
1 08:00
1 08:30
1 09:00
1 09:30
1 10:30
1 11:00
1 11:30
2 07:15
2 07:45
2 08:15
2 08:45
2 09:15
2 09:45
2 10:45
2 11:15
2 11:45

I hope this helps!


Re: [julia-users] Re: Pkg.publish() : ERROR: There are no METADATA changes to publish

2016-05-20 Thread Evan Fields

>
> Yes, thanks for your help. I did Pkg.add("TravelingSalesmanHeuristics") 
> and checked out master in that directory. Pkg.tag and Pkg.publish both 
> seemed to work fine.


Surely this was all an unforced error on my part but hopefully someone in 
the future will find this thread useful. Cheers! 


[julia-users] Re: Pkg.publish() : ERROR: There are no METADATA changes to publish

2016-05-20 Thread Evan Fields
On further inspection I think this is because I managed to name the package 
repository TravelingSalesmanHeuristics.jl (rather than just 
TravelingSalesmanHeuristics). Indeed I just ran 
Pkg.add("TravelingSalesmanHeuristics") and now have in my .julia/v0.4 both 
TravelingSalesmanHeuristics and TravelingSalesmanHeuristics.jl

When I published v0.0.1 Pkg.publish failed (different error, can't 
remember) and I had to create the pull request manually; presumably I now 
have to do that going forward?


[julia-users] Pkg.publish() : ERROR: There are no METADATA changes to publish

2016-05-20 Thread Evan Fields
Presumably I'm doing something dumb, but I'm at a loss. I'm trying to tag 
version 0.0.2 of TravelingSalesmanHeuristics in METADATA. With my local 
machine up to date with the remote github repository, I run Pkg.update() and 
Pkg.tag("TravelingSalesmanHeuristics.j", v"0.0.2") and get no errors. 

Then I run Pkg.publish() and get the following output:

julia> Pkg.publish()
ERROR: There are no METADATA changes to publish
 in publish at pkg/entry.jl:348
 in anonymous at pkg/dir.jl:31
 in cd at file.jl:32
 in cd at pkg/dir.jl:31
 in publish at pkg.jl:61


Indeed, when I to git log -n 10 in the local copy of METADATA I see no 
commits about tagging TravelingSalesmanHeuristics. So it seems the 
Pkg.publish error is not wrong.

What am I doing wrong? Thanks!


[julia-users] Re: ANN: AffineSpaces.jl (work in progress)

2016-05-16 Thread Evan Fields
Very cool stuff; I could see this being really useful in heuristic vehicle 
routing work I do.

By the way, in the readme should the 2d example which creates the line y = 
1 first create the x-axis (y=0) and then offset? It looks like you're using 
the second component vector [0,1].


[julia-users] Is there a performance penalty for defining functions inside functions?

2016-03-29 Thread Evan Fields
To keep namespaces clear and to help with code readability, I might like to 
do this:

function mainFunc()
function helper()
do stuff
return something
end

call helper() and do stuff
return something
end

That way the helper function is only visible to the function that needs it 
and when reading the code it's obvious that the helper "belongs to" the 
main function. Is there any performance penalty for doing this? Or is this 
bad practice for some reason I don't know?


[julia-users] Re: To solve optimization problem in julia is it necessary to add any module.

2016-03-25 Thread Evan Fields
It depends on what kind of problem you'd like to solve and how you'd like 
to solve it. 

- JuMP is a modeling interface that lies between you and a dedicated 
solver. JuMP lets you easily specify your problem, sends that problem to 
the solver, and retrieves output for you. JuMP itself is not a solver.

- Packages such as Optim.jl implement some optimization algorithms in pure 
Julia and thus do not require external solvers nor packages to interact 
with them.

See juliaopt.org for an overview of the optimization packages and how they 
fit together.

Which solver is best depends on many factors: primarily what kind of 
problem you want to solve, but also whether you need features like 
callbacks, what licenses you have access to, etc. The main page of 
juliaopt.org has a chart which can help you pick a a solver (probably to be 
used with JuMP) or a pure Julia optimization package.


[julia-users] Re: Announcing JuDE: autocomplete and jump to definition support for Atom

2016-03-21 Thread Evan Fields
Looks great - I'm excited to try this out. Does the autocomplete work in 
the console as well? I recently tried Atom flavored Juno and was super 
impressed but found the lack of console completions a major pain point. 
Will this play nicely with Juno's packages?

On Sunday, March 20, 2016 at 2:58:15 PM UTC-4, James Dang wrote:
>
> Hi All, Julia has been great for me, and I wanted to give back a little. 
> LightTable and Atom are great editors, but I was really starting to miss 
> good intellisense-like autocomplete and basic navigation features like 
> jump-to-definition, especially on larger codebases. It's really quite a 
> slog to remember exactly where in which file a function was defined, or 
> what its exact arguments are. And maybe with better tooling, more people 
> will be drawn to the community. So I put a bit of work into a new package 
> for Atom that gives you that!
>
> https://atom.io/packages/jude
>
>
> 
>
>
> This is a bit different from what you get out of julia-client and 
> autocomplete-julia because it does a full syntax parsing and scope 
> resolution of your codebase without executing it in a Julia process. It 
> reparses very quickly on the fly without needing to save. And the matching 
> is precise, not fuzzy, giving you exactly what names are available in the 
> scope you are in currently. It's quite new and unpolished, but please try 
> it out and let me know what you think!
>
> Cheers,
> James
>
>

[julia-users] Re: Announcing JuDE: autocomplete and jump to definition support for Atom

2016-03-21 Thread Evan Fields
Looks great - I'm excited to try this out. Does the autocomplete work in 
the console as well? I recently tried Atom flavored Juno and was super 
impressed but found the lack of console completions a major pain point. 
Will this play nicely with Juno's packages?


[julia-users] Re: ANN: JuMP 0.12 released

2016-03-08 Thread Evan Fields
Great to hear. Two minor questions which aren't clear (to me) from the 
documentation:
- Once a user defined function has been defined and registered, can it be 
incorporated into NL expressions via @defNLExpr?
- The documentation references both ForwardDiff.jl and 
ReverseDiffSparse.jl. Which is used where? What are the tradeoffs users 
should be aware of?

Semi-unrelated: two days ago I was using JuMP 0.12 and NLopt to solve what 
should have been a very simple (2 variable) nonlinear problem. When I fed 
the optimal solution as the starting values for the variables, the 
solve(model) command (or NLopt) hung indefinitely. Perturbing my starting 
point by .0001 fixed that - solve returned a solution 
instantaneously-by-human-perception. Am I doing something dumb?


[julia-users] usage of eachindex with Array type?

2016-02-11 Thread Evan
Hi, I am trying to understand how to use eachindex with an array.  For 
example, I can do:

julia> A = zeros(Int, (3,2))
3x2 Array{Int64,2}:
 0  0
 0  0
 0  0

followed by:
julia> for iter in eachindex(A)
  @show iter.I[1], iter.I[2]
  @show A[iter]
  end
ERROR: type Int64 has no field I
 [inlined code] from show.jl:127
 in anonymous at no file:0



However, using:
julia> A = sprand(2, 3, 0.5)
2x3 sparse matrix with 2 Float64 entries:
[1, 1]  =  0.599423
[2, 2]  =  0.340233

julia> for iter in eachindex(A)
  @show iter.I[1], iter.I[2]
  @show A[iter]
  end
(iter.I[1],iter.I[2]) = (1,1)
A[iter] = 0.5994230074532017
(iter.I[1],iter.I[2]) = (2,1)
A[iter] = 0.0
(iter.I[1],iter.I[2]) = (1,2)
A[iter] = 0.0
(iter.I[1],iter.I[2]) = (2,2)
A[iter] = 0.3402329840051479
(iter.I[1],iter.I[2]) = (1,3)
A[iter] = 0.0
(iter.I[1],iter.I[2]) = (2,3)
A[iter] = 0.0

works just fine.  I'm sure it's something simple, but at this stage would 
appreciate some help.


Re: [julia-users] usage of eachindex with Array type?

2016-02-11 Thread Evan
Thank you Mauro, CartesianRange(size(A)) seems to be what I am looking for.

Evan


On Thursday, February 11, 2016 at 11:42:11 AM UTC+1, Mauro wrote:
>
> It works like so: 
> julia> for i in eachindex(A) 
>   @show A[i] 
>end 
>
> ... 
>
> I.e. the `i` is to be used as sole index into the array.  What `i` is 
> exactly depends on the type of the array.  It's either just a Int or a 
> `CartesianIndex` has a field `I`.  But you should not access `I` 
> directly, that is private to `CartesianIndex`. 
>
> Have a look at 
> help?> eachindex 
>
> and if you want to know what else one can do with CartesianIndex: 
> http://www.juliabloggers.com/multidimensional-algorithms-and-iteration/ 
>
> On Thu, 2016-02-11 at 10:56, Evan <evan...@gmail.com > 
> wrote: 
> > Hi, I am trying to understand how to use eachindex with an array. For 
> example, 
> > I can do: 
> > 
> > julia> A = zeros(Int, (3,2)) 
> > 3x2 Array{Int64,2}: 
> > 0 0 
> > 0 0 
> > 0 0 
> > 
> > followed by: 
> > julia> for iter in eachindex(A) 
> >  @show iter.I[1], iter.I[2] 
> >  @show A[iter] 
> >end 
> > ERROR: type Int64 has no field I 
> > [inlined code] from show.jl:127 
> > in anonymous at no file:0 
> > 
> > 
> > 
> > However, using: 
> > julia> A = sprand(2, 3, 0.5) 
> > 2x3 sparse matrix with 2 Float64 entries: 
> > [1, 1] = 0.599423 
> > [2, 2] = 0.340233 
> > 
> > julia> for iter in eachindex(A) 
> >  @show iter.I[1], iter.I[2] 
> >  @show A[iter] 
> >end 
> > (iter.I[1],iter.I[2]) = (1,1) 
> > A[iter] = 0.5994230074532017 
> > (iter.I[1],iter.I[2]) = (2,1) 
> > A[iter] = 0.0 
> > (iter.I[1],iter.I[2]) = (1,2) 
> > A[iter] = 0.0 
> > (iter.I[1],iter.I[2]) = (2,2) 
> > A[iter] = 0.3402329840051479 
> > (iter.I[1],iter.I[2]) = (1,3) 
> > A[iter] = 0.0 
> > (iter.I[1],iter.I[2]) = (2,3) 
> > A[iter] = 0.0 
> > 
> > works just fine. I'm sure it's something simple, but at this stage would 
> > appreciate some help. 
>


Re: [julia-users] how to make my own 3d array type

2015-11-25 Thread Evan Mason
Great, thanks.  So, I now have:

immutable MyType2{T,N,A<:AbstractArray, I<:Int} <: AbstractArray{T,N}
var :: A
nstar :: I
end

MyType2{T,N}(var::AbstractArray{T,N}, nstar::Int) = MyType2{T,N,
typeof(var), typeof(nstar)}(var, nstar)

Base.linearindexing(::Type{MyType2}) = Base.LinearFast()
Base.size(S::MyType2) = (S.nstar,)

and I found base/linalg/eigen.jl helpful in figuring this out.


On Wed, Nov 25, 2015 at 12:53 PM, Tim Holy <tim.h...@gmail.com> wrote:

> Check out the "Types" section of the manual, esp. the part about "Composite
> Types."
>
> Also, see base/subarray.jl if you want an example of a complex but full-
> featured AbstractArray type.
>
> Best,
> --Tim
>
> On Wednesday, November 25, 2015 03:24:39 AM Evan wrote:
> > Thanks Tim,
> >
> > Following the link you suggested I made the following type which does
> what
> > I want:
> >
> > immutable MyType{T,N,A<:AbstractArray} <: AbstractArray{Float64,3}
> > conf_lims :: A
> > end
> > MyType{T,N}(conf_lims::AbstractArray{T,N}) =
> MyType{T,N,typeof(conf_lims)}(
> > conf_lims)
> > Base.size(S::MyType) = (S.count,)
> > Base.linearindexing(::Type{MyType}) = Base.LinearFast();
> >
> >
> > What I haven't figured out is how to add more than just the one variable;
> > for instance I'd like to have a "count" variable which would be an
> integer?
> >
> > On Monday, November 16, 2015 at 3:45:43 PM UTC+1, Tim Holy wrote:
> > > Totally different error (it's a missing size method). You also need to
> > > read
> > > this:
> > > http://docs.julialang.org/en/stable/manual/interfaces/#abstract-arrays
> > >
> > > --Tim
> > >
> > > On Monday, November 16, 2015 06:08:15 AM Evan wrote:
> > > > Thank you, Tim, I understand the motivation for the approach in the
> link
> > > > you sent.
> > > >
> > > > I'm still unable to create the type that I want. I actually want two
> > >
> > > arrays
> > >
> > > > in my type, one 2d and the other 3d.
> > > >
> > > > First though, I'm still stuck on just the 2d when I try to implement
> > >
> > > your
> > >
> > > > suggestion:
> > > > julia> type MyType{T,N,A<:AbstractArray} <: AbstractArray{T,N}
> > > >
> > > >var::A
> > > >
> > > >end
> > > >
> > > > julia> MyType{T,N}(var::AbstractArray{T,N}) =
> > >
> > > MyType{T,N,typeof(var)}(var)
> > >
> > > > MyType{T,N,A<:AbstractArray{T,N}}
> > > >
> > > > julia> aa = MyType(zeros(2,3))
> > > > Error showing value of type MyType{Float64,2,Array{Float64,2}}:
> > > > ERROR: MethodError: `size` has no method matching
> > >
> > > size(::MyType{Float64,2,
> > >
> > > > Array{Float64,2}})
> > > >
> > > > Closest candidates are:
> > > >   size{T,n}(::AbstractArray{T,n}, ::Any)
> > > >   size(::Any, ::Integer, ::Integer, ::Integer...)
> > > >
> > > >  in showarray at show.jl:1231
> > > >  in anonymous at replutil.jl:29
> > > >  in with_output_limit at ./show.jl:1271
> > > >  in writemime at replutil.jl:28
> > > >  in display at REPL.jl:114
> > > >  in display at REPL.jl:117
> > > >  [inlined code] from multimedia.jl:151
> > > >  in display at multimedia.jl:162
> > > >  in print_response at REPL.jl:134
> > > >  in print_response at REPL.jl:121
> > > >  in anonymous at REPL.jl:624
> > > >  in run_interface at ./LineEdit.jl:1610
> > > >  in run_frontend at ./REPL.jl:863
> > > >  in run_repl at ./REPL.jl:167
> > > >  in _start at ./client.jl:420
> > > >
> > > > julia>
> > > >
> > > > Performance is important, but it's not clear what I should use in
> place
> > >
> > > of
> > >
> > > > abstract types; I've tried replacing AbstractArray with just Array
> but
> > >
> > > that
> > >
> > > > does not appear to work.
> > > >
> > > > On Monday, November 16, 2015 at 1:03:05 PM UTC+1, Tim Holy wrote:
> > > > > This fixes two problems:
> > > > >
> > > > > type MyType{T,N,A<:AbstractArray} <: AbstractArray{T,N}
> > > > >
> > > > > var::A
> > > > >

Re: [julia-users] how to make my own 3d array type

2015-11-25 Thread Evan
Thanks Tim,

Following the link you suggested I made the following type which does what 
I want:

immutable MyType{T,N,A<:AbstractArray} <: AbstractArray{Float64,3}
conf_lims :: A
end
MyType{T,N}(conf_lims::AbstractArray{T,N}) = MyType{T,N,typeof(conf_lims)}(
conf_lims)
Base.size(S::MyType) = (S.count,)
Base.linearindexing(::Type{MyType}) = Base.LinearFast();


What I haven't figured out is how to add more than just the one variable; 
for instance I'd like to have a "count" variable which would be an integer?




On Monday, November 16, 2015 at 3:45:43 PM UTC+1, Tim Holy wrote:
>
> Totally different error (it's a missing size method). You also need to 
> read 
> this: 
> http://docs.julialang.org/en/stable/manual/interfaces/#abstract-arrays 
>
> --Tim 
>
> On Monday, November 16, 2015 06:08:15 AM Evan wrote: 
> > Thank you, Tim, I understand the motivation for the approach in the link 
> > you sent. 
> > 
> > I'm still unable to create the type that I want. I actually want two 
> arrays 
> > in my type, one 2d and the other 3d. 
> > 
> > First though, I'm still stuck on just the 2d when I try to implement 
> your 
> > suggestion: 
> > julia> type MyType{T,N,A<:AbstractArray} <: AbstractArray{T,N} 
> >var::A 
> >end 
> > 
> > julia> MyType{T,N}(var::AbstractArray{T,N}) = 
> MyType{T,N,typeof(var)}(var) 
> > MyType{T,N,A<:AbstractArray{T,N}} 
> > 
> > julia> aa = MyType(zeros(2,3)) 
> > Error showing value of type MyType{Float64,2,Array{Float64,2}}: 
> > ERROR: MethodError: `size` has no method matching 
> size(::MyType{Float64,2, 
> > Array{Float64,2}}) 
> > Closest candidates are: 
> >   size{T,n}(::AbstractArray{T,n}, ::Any) 
> >   size(::Any, ::Integer, ::Integer, ::Integer...) 
> >  in showarray at show.jl:1231 
> >  in anonymous at replutil.jl:29 
> >  in with_output_limit at ./show.jl:1271 
> >  in writemime at replutil.jl:28 
> >  in display at REPL.jl:114 
> >  in display at REPL.jl:117 
> >  [inlined code] from multimedia.jl:151 
> >  in display at multimedia.jl:162 
> >  in print_response at REPL.jl:134 
> >  in print_response at REPL.jl:121 
> >  in anonymous at REPL.jl:624 
> >  in run_interface at ./LineEdit.jl:1610 
> >  in run_frontend at ./REPL.jl:863 
> >  in run_repl at ./REPL.jl:167 
> >  in _start at ./client.jl:420 
> > 
> > julia> 
> > 
> > Performance is important, but it's not clear what I should use in place 
> of 
> > abstract types; I've tried replacing AbstractArray with just Array but 
> that 
> > does not appear to work. 
> > 
> > On Monday, November 16, 2015 at 1:03:05 PM UTC+1, Tim Holy wrote: 
> > > This fixes two problems: 
> > > 
> > > type MyType{T,N,A<:AbstractArray} <: AbstractArray{T,N} 
> > > 
> > > var::A 
> > > 
> > > end 
> > > 
> > > MyType{T,N}(var::AbstractArray{T,N}) = MyType{T,N,typeof(var)}(var) 
> > > 
> > > 
> > > 
> > > If performance matters, you should not use abstract types for fields. 
> See 
> > > 
> > > 
> http://docs.julialang.org/en/stable/manual/faq/#how-do-abstract-or-ambiguo 
> > > us-fields-in-types-interact-with-the-compiler and the section after 
> that. 
> > > 
> > > --Tim 
> > > 
> > > On Monday, November 16, 2015 03:54:15 AM Evan wrote: 
> > > > For a 2d array the following works: 
> > > > 
> > > > type mytype{T} 
> > > > 
> > > > var :: AbstractMatrix{T} 
> > > > 
> > > > end 
> > > > 
> > > > julia> t = mytype(zeros(4, 3)) 
> > > > 
> > > > mytype{Float64}(4x3 Array{Float64,2}: 
> > > >  0.0  0.0  0.0 
> > > >  0.0  0.0  0.0 
> > > >  0.0  0.0  0.0 
> > > >  0.0  0.0  0.0) 
> > > > 
> > > > But how do I extend this to a 3d array? 
> > > > 
> > > > julia> t = mytype(zeros(2, 4, 3)) 
> > > > ERROR: MethodError: `convert` has no method matching 
> > > 
> > > convert(::Type{mytype{T 
> > > 
> > > > }}, ::Array{Float64,3}) 
> > > > This may have arisen from a call to the constructor mytype{T}(...), 
> > > > since type constructors fall back to convert methods. 
> > > > 
> > > > Closest candidates are: 
> > > >   call{T}(::Type{T}, ::Any) 
> > > >   convert{T}(::Type{T}, ::T) 
> > > >   mytype{T}(::AbstractArray{T,2}) 
> > > >   
> > > >  in call at essentials.jl:56 
>
>

[julia-users] Re: how to specify degrees of freedom for OneSampleTTest?

2015-11-16 Thread Evan
My data are not statistically independent, that is why I want to use N*.

So what I've done is modify a function I found here:
http://stackoverflow.com/questions/20425473/calculate-confidence-interval-in-julia

to do what I want:

function t_test(x::Array{Float64,1};
nstar=0, conf_level=0.95)
alpha = (1. - conf_level)
if nstar == 0
nstar=length(x) - 1
end
tstar = quantile(TDist(nstar - 1), 1 - alpha / 2)
SE = std(x) / sqrt(nstar)
lo, hi = mean(x) + [-1, 1] * tstar * SE
end





On Tuesday, November 10, 2015 at 4:48:39 PM UTC+1, j verzani wrote:
>
> If you have the sample data, it is just the length of the data minus 1, so 
> does not need to be specified, as it is computed.
>
> On Tuesday, November 10, 2015 at 9:47:43 AM UTC-5, Evan wrote:
>>
>> I want to do the following with some time series data:
>>
>> Calculate 95% confidence interval for mean defined as 
>> +/-sigma(x)qt(0.025, N*-1) / sqrt(N*) where sigma(x) is the standard 
>> deviation at any point x and qt(0.025, N*-1) is the 2.5 percentage point of 
>> the Student-t distribution with N*-1 degrees of freedom.
>>
>> I have been trying to do this with HypothesisTests' ci() and 
>> OneSampleTTest() functions, but as far as I can see OneSampleTTest() does 
>> not allow me to choose the number of degrees of freedom.
>>
>> julia> t = OneSampleTTest(arr)
>> One sample t-test
>> -
>> Population details:
>> parameter of interest:   Mean
>> value under h_0: 0
>> point estimate:  0.3835
>> 95% confidence interval: (0.14217301685460967,0.6248269831453903)
>>
>> Test summary:
>> outcome with 95% confidence: reject h_0
>> two-sided p-value:   0.0057946078675091515 (very significant)
>>
>> Details:
>> number of observations:   10
>> t-statistic:  3.5948622927526235
>> degrees of freedom:   9
>> empirical standard error: 0.10668002520517972
>>
>>
>> julia> t.df
>> 9
>> julia> ci(t, 0.025, tail=:both)
>> (0.09706297518543938,0.6699370248145606)
>>
>>
>> Can anybody point me in the right direction?
>>
>>
>>
>>

Re: [julia-users] how to make my own 3d array type

2015-11-16 Thread Evan
Thank you, Tim, I understand the motivation for the approach in the link 
you sent.

I'm still unable to create the type that I want. I actually want two arrays 
in my type, one 2d and the other 3d.

First though, I'm still stuck on just the 2d when I try to implement your 
suggestion:
julia> type MyType{T,N,A<:AbstractArray} <: AbstractArray{T,N}
   var::A
   end

julia> MyType{T,N}(var::AbstractArray{T,N}) = MyType{T,N,typeof(var)}(var)
MyType{T,N,A<:AbstractArray{T,N}}

julia> aa = MyType(zeros(2,3))
Error showing value of type MyType{Float64,2,Array{Float64,2}}:
ERROR: MethodError: `size` has no method matching size(::MyType{Float64,2,
Array{Float64,2}})
Closest candidates are:
  size{T,n}(::AbstractArray{T,n}, ::Any)
  size(::Any, ::Integer, ::Integer, ::Integer...)
 in showarray at show.jl:1231
 in anonymous at replutil.jl:29
 in with_output_limit at ./show.jl:1271
 in writemime at replutil.jl:28
 in display at REPL.jl:114
 in display at REPL.jl:117
 [inlined code] from multimedia.jl:151
 in display at multimedia.jl:162
 in print_response at REPL.jl:134
 in print_response at REPL.jl:121
 in anonymous at REPL.jl:624
 in run_interface at ./LineEdit.jl:1610
 in run_frontend at ./REPL.jl:863
 in run_repl at ./REPL.jl:167
 in _start at ./client.jl:420

julia>

Performance is important, but it's not clear what I should use in place of 
abstract types; I've tried replacing AbstractArray with just Array but that 
does not appear to work.




On Monday, November 16, 2015 at 1:03:05 PM UTC+1, Tim Holy wrote:
>
> This fixes two problems: 
>
> type MyType{T,N,A<:AbstractArray} <: AbstractArray{T,N} 
> var::A 
> end 
>
> MyType{T,N}(var::AbstractArray{T,N}) = MyType{T,N,typeof(var)}(var) 
>
>
>
> If performance matters, you should not use abstract types for fields. See 
>
> http://docs.julialang.org/en/stable/manual/faq/#how-do-abstract-or-ambiguous-fields-in-types-interact-with-the-compiler
>  
> and the section after that. 
>
> --Tim 
>
>
> On Monday, November 16, 2015 03:54:15 AM Evan wrote: 
> > For a 2d array the following works: 
> > 
> > type mytype{T} 
> > var :: AbstractMatrix{T} 
> > end 
> > 
> > julia> t = mytype(zeros(4, 3)) 
> > mytype{Float64}(4x3 Array{Float64,2}: 
> >  0.0  0.0  0.0 
> >  0.0  0.0  0.0 
> >  0.0  0.0  0.0 
> >  0.0  0.0  0.0) 
> > 
> > 
> > 
> > But how do I extend this to a 3d array? 
> > 
> > julia> t = mytype(zeros(2, 4, 3)) 
> > ERROR: MethodError: `convert` has no method matching 
> convert(::Type{mytype{T 
> > }}, ::Array{Float64,3}) 
> > This may have arisen from a call to the constructor mytype{T}(...), 
> > since type constructors fall back to convert methods. 
> > Closest candidates are: 
> >   call{T}(::Type{T}, ::Any) 
> >   convert{T}(::Type{T}, ::T) 
> >   mytype{T}(::AbstractArray{T,2}) 
> >  in call at essentials.jl:56 
>
>

[julia-users] how to make my own 3d array type

2015-11-16 Thread Evan
For a 2d array the following works:

type mytype{T}
var :: AbstractMatrix{T}
end

julia> t = mytype(zeros(4, 3))
mytype{Float64}(4x3 Array{Float64,2}:
 0.0  0.0  0.0
 0.0  0.0  0.0
 0.0  0.0  0.0
 0.0  0.0  0.0)



But how do I extend this to a 3d array?

julia> t = mytype(zeros(2, 4, 3))
ERROR: MethodError: `convert` has no method matching convert(::Type{mytype{T
}}, ::Array{Float64,3})
This may have arisen from a call to the constructor mytype{T}(...),
since type constructors fall back to convert methods.
Closest candidates are:
  call{T}(::Type{T}, ::Any)
  convert{T}(::Type{T}, ::T)
  mytype{T}(::AbstractArray{T,2})
 in call at essentials.jl:56






[julia-users] how to specify degrees of freedom for OneSampleTTest?

2015-11-10 Thread Evan
I want to do the following with some time series data:

Calculate 95% confidence interval for mean defined as +/-sigma(x)qt(0.025, 
N*-1) / sqrt(N*) where sigma(x) is the standard deviation at any point x 
and qt(0.025, N*-1) is the 2.5 percentage point of the Student-t 
distribution with N*-1 degrees of freedom.

I have been trying to do this with HypothesisTests' ci() and 
OneSampleTTest() functions, but as far as I can see OneSampleTTest() does 
not allow me to choose the number of degrees of freedom.

julia> t = OneSampleTTest(arr)
One sample t-test
-
Population details:
parameter of interest:   Mean
value under h_0: 0
point estimate:  0.3835
95% confidence interval: (0.14217301685460967,0.6248269831453903)

Test summary:
outcome with 95% confidence: reject h_0
two-sided p-value:   0.0057946078675091515 (very significant)

Details:
number of observations:   10
t-statistic:  3.5948622927526235
degrees of freedom:   9
empirical standard error: 0.10668002520517972


julia> t.df
9
julia> ci(t, 0.025, tail=:both)
(0.09706297518543938,0.6699370248145606)


Can anybody point me in the right direction?





Re: [julia-users] Pkg.[update()/install()/build()] woes on Windows 10 64 bit

2015-09-29 Thread Evan Fields
So I deleted just ArrayViews from .julia, still got errors. Decided to 
delete the whole of .julia, did Pkg.add("Images"), and got this:

   _
   _   _ _(_)_ |  A fresh approach to technical computing
  (_) | (_) (_)|  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "help()" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.3.11 (2015-07-27 06:18 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/   |  x86_64-w64-mingw32

julia> Pkg.add("Images")
INFO: Cloning cache of BinDeps from 
git://github.com/JuliaLang/BinDeps.jl.git
INFO: Cloning cache of ColorTypes from 
git://github.com/JuliaGraphics/ColorTypes.jl.git
INFO: Cloning cache of ColorVectorSpace from 
git://github.com/JuliaGraphics/ColorVectorSpace.jl.git
INFO: Cloning cache of Colors from 
git://github.com/JuliaGraphics/Colors.jl.git
INFO: Cloning cache of Compat from git://github.com/JuliaLang/Compat.jl.git
INFO: Cloning cache of Dates from git://github.com/quinnj/Dates.jl.git
INFO: Cloning cache of Docile from 
git://github.com/MichaelHatherly/Docile.jl.git
INFO: Cloning cache of FixedPointNumbers from 
git://github.com/JeffBezanson/FixedPointNumbers.jl.git
INFO: Cloning cache of Graphics from 
git://github.com/JuliaLang/Graphics.jl.git
INFO: Cloning cache of HttpCommon from 
git://github.com/JuliaWeb/HttpCommon.jl.git
INFO: Cloning cache of Images from git://github.com/timholy/Images.jl.git
INFO: Cloning cache of Reexport from 
git://github.com/simonster/Reexport.jl.git
INFO: Cloning cache of SHA from git://github.com/staticfloat/SHA.jl.git
INFO: Cloning cache of SIUnits from git://github.com/Keno/SIUnits.jl.git
INFO: Cloning cache of TexExtensions from 
git://github.com/Keno/TexExtensions.jl.git
INFO: Cloning cache of URIParser from 
git://github.com/JuliaWeb/URIParser.jl.git
INFO: Cloning cache of Zlib from git://github.com/dcjones/Zlib.jl.git
INFO: Installing BinDeps v0.3.18
INFO: Installing ColorTypes v0.1.6
INFO: Installing ColorVectorSpace v0.0.4
INFO: Installing Colors v0.5.4
INFO: Installing Compat v0.7.3
INFO: Installing Dates v0.3.2
INFO: Installing Docile v0.5.19
INFO: Installing FixedPointNumbers v0.0.11
INFO: Installing Graphics v0.1.0
INFO: Installing HttpCommon v0.1.2
INFO: Installing Images v0.4.48
INFO: Installing Reexport v0.0.3
INFO: Installing SHA v0.1.2
INFO: Installing SIUnits v0.0.5
INFO: Installing TexExtensions v0.0.2
INFO: Installing URIParser v0.0.7
INFO: Installing Zlib v0.1.10
INFO: Building Images
At line:1 char:3
+ --help
+   ~
Missing expression after unary operator '--'.
At line:1 char:3
+ --help
+   
Unexpected token 'help' in expression or statement.
+ CategoryInfo  : ParserError: (:) [], 
ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingExpressionAfterOperator

INFO: Installing ImageMagick library
INFO: Attempting to Create directory 
C:\Users\ejfie\.julia\v0.3\Images\deps\downloads
INFO: Attempting to Create directory 
C:\Users\ejfie\.julia\v0.3\Images\deps\usr\lib\x64
INFO: Attempting to Create directory 
C:\Users\ejfie\.julia\v0.3\Images\deps\downloads
INFO: Directory C:\Users\ejfie\.julia\v0.3\Images\deps\downloads already 
created
INFO: Downloading file 
http://www.imagemagick.org/download/binaries/ImageMagick-6.9.2-3-Q16-x64-dll.exe
  % Total% Received % Xferd  Average Speed   TimeTime Time 
 Current
 Dload  Upload   Total   SpentLeft 
 Speed
100 20.0M  100 20.0M0 0  3141k  0  0:00:06  0:00:06 --:--:-- 
4439k
INFO: Done downloading file 
http://www.imagemagick.org/download/binaries/ImageMagick-6.9.2-3-Q16-x64-dll.exe
INFO: Attempting to Create directory 
C:\Users\ejfie\.julia\v0.3\Images\deps\downloads
INFO: Directory C:\Users\ejfie\.julia\v0.3\Images\deps\downloads already 
created
INFO: Downloading file 
https://bintray.com/artifact/download/julialang/generic/innounp.exe
  % Total% Received % Xferd  Average Speed   TimeTime Time 
 Current
 Dload  Upload   Total   SpentLeft 
 Speed
  0 00 00 0  0  0 --:--:-- --:--:-- --:--:--   
  0
  0 00 00 0  0  0 --:--:--  0:00:01 --:--:--   
  0
100  592k  100  592k0 0   251k  0  0:00:02  0:00:02 --:--:-- 
 847k
INFO: Done downloading file 
https://bintray.com/artifact/download/julialang/generic/innounp.exe
INFO: Changing Directory to C:\Users\ejfie\.julia\v0.3\Images\deps\downloads
; Version detected: 5506 (Unicode)
INFO: Package database updated

julia>

But things seem to be working, at least for now.

Interesting side note: I know things aren't supposed to work this way, but 
this physical machine seems to create Julia problems. In January I had 
similar problems with installing packages that even a fresh install of 
Julia didn't solve. Since then I've formatted my hard drive and installed a 
later version of Windows, but again even a fresh 

Re: [julia-users] Pkg.[update()/install()/build()] woes on Windows 10 64 bit

2015-09-27 Thread Evan Fields
ry for 
C:\Users\ejfie\.julia\v0.3\ArrayViews\.git/refs/tags/v0.6.3
error: unable to create directory for 
C:\Users\ejfie\.julia\v0.3\ArrayViews\.git/refs/tags/v0.6.4
ERROR: failed process: Process(`git 
'--work-tree=C:\Users\ejfie\.julia\v0.3\ArrayViews' 
'--git-dir=C:\Users\ejfie\.
julia\v0.3\ArrayViews\.git' fetch -q 
'C:\Users\ejfie\.julia\v0.3\.cache\ArrayViews' 
+refs/*:refs/remotes/cache/*`,
ProcessExited(1)) [1]
 in error at error.jl:22 (repeats 2 times)

julia>

On Saturday, September 26, 2015 at 6:23:43 PM UTC-4, Stefan Karpinski wrote:
>
> The cache is just bunch of bare clones of package repos. Since those are 
> immutable and update only, it's safe to share them between arbitrarily many 
> working copies. I don't think manual management is ever necessary unless 
> one of the bare repos gets screwed up some how.
>
> On Friday, September 25, 2015, David Anthoff <ant...@berkeley.edu 
> > wrote:
>
>> Stefan, any pointers about this design?
>>
>>  
>>
>> I sometimes delete the folder of a package and then reinstall it with 
>> Pkg.update() if something got screwed up. Do I have to manually manage what 
>> is going on in .cache in that case as well?
>>
>>  
>>
>> Thanks,
>>
>> David
>>
>>  
>>
>> *From:* julia-users@googlegroups.com [mailto:julia-users@googlegroups.com] 
>> *On Behalf Of *Tony Kelman
>> *Sent:* Friday, September 25, 2015 5:46 PM
>> *To:* julia-users <julia-users@googlegroups.com>
>> *Subject:* Re: [julia-users] Re: Pkg.[update()/install()/build()] woes 
>> on Windows 10 64 bit
>>
>>  
>>
>> What is it? A cache. Other than that, no idea what it accomplishes (aside 
>> from reading the code to find out) or why it works the way it does. It was 
>> added in 
>> https://github.com/JuliaLang/julia/commit/df7a08893e4402182ec64178ffdb3130aa228943
>>  
>> but there are no design docs on the package manager. Ask Stefan.
>>
>>  
>>
>> .cache moved to being shared between different versioned package 
>> directories on 0.4 because of 
>> https://github.com/JuliaLang/julia/pull/7361. It worked that way on unix 
>> in 0.3 as well. With better support for making directory junctions via the 
>> symlink function (which was still a pretty new feature when 0.3.0 was 
>> released), that PR made the behavior consistent on Windows as well.
>>
>>
>>
>> On Friday, September 25, 2015 at 5:10:50 PM UTC-7, David Anthoff wrote:
>>
>> What is the .cache directory actually? And why is it moved into the 
>> ~\.julia folder for 0.4?
>>
>>  
>>
>> *From:* julia...@googlegroups.com [mailto:julia...@googlegroups.com] *On 
>> Behalf Of *Tony Kelman
>> *Sent:* Friday, September 25, 2015 2:35 PM
>> *To:* julia-users <julia...@googlegroups.com>
>> *Subject:* [julia-users] Re: Pkg.[update()/install()/build()] woes on 
>> Windows 10 64 bit
>>
>>  
>>
>> Try deleting everything in C:\Users\ejfie\.julia\v0.3\.cache  - 
>> something might be corrupt there
>>
>>
>> On Friday, September 25, 2015 at 12:29:14 PM UTC-7, Evan Fields wrote:
>>
>> I've been encountering problems with packages. Here's what happened:
>>
>> · I installed Julia 0.3.11 via the 64 bit .exe on julialang.org
>>
>>- Changed the install path to C:\Julia-0.3.11 but otherwise all 
>>default options
>>
>> · On Windows 10 x64, not using Cygwin or related
>>
>>- Right after install I opened a Julia terminal window; I had the 
>>session below.
>>
>> The errors are shown in the session below. I've tried
>>
>> - Running as an administrator
>>
>> - Running git config --global url."https://".insteadOf git:// in shell 
>> mode
>>
>> - Running Pkg.init() (already initialized)
>>
>> - Trying to clone a repository in Julia/Git using the git-bash there (it 
>> worked over https)
>>
>>  
>>
>>_   _ _(_)_ |  A fresh approach to technical computing
>>
>>   (_) | (_) (_)|  Documentation: http://docs.julialang.org
>>
>>_ _   _| |_  __ _   |  Type "help()" for help.
>>
>>   | | | | | | |/ _` |  |
>>
>>   | | |_| | | | (_| |  |  Version 0.3.11 (2015-07-27 06:18 UTC)
>>
>>  _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
>>
>> |__/   |  x86_64-w64-mingw32
>>
>>  
>>
>> julia> Pkg.add("Images")
>>
>> INFO: Nothing to be done
>>
>> INFO: METADATA is out-o

[julia-users] Pkg.[update()/install()/build()] woes on Windows 10 64 bit

2015-09-25 Thread Evan Fields
I've been encountering problems with packages. Here's what happened:

   - I installed Julia 0.3.11 via the 64 bit .exe on julialang.org
   - Changed the install path to C:\Julia-0.3.11 but otherwise all default 
   options
   - On Windows 10 x64, not using Cygwin or related
   - Right after install I opened a Julia terminal window; I had the 
   session below.

The errors are shown in the session below. I've tried
- Running as an administrator
- Running git config --global url."https://".insteadOf git:// in shell mode
- Running Pkg.init() (already initialized)
- Trying to clone a repository in Julia/Git using the git-bash there (it 
worked over https)

   _   _ _(_)_ |  A fresh approach to technical computing
  (_) | (_) (_)|  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "help()" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.3.11 (2015-07-27 06:18 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/   |  x86_64-w64-mingw32

julia> Pkg.add("Images")
INFO: Nothing to be done
INFO: METADATA is out-of-date — you may not have the latest version of Images
INFO: Use `Pkg.update()` to get the latest versions of your packages

julia> Pkg.update()
INFO: Updating METADATA...
Checking out files: 100% (1627/1627), done.
INFO: Updating cache of Hexagons...
INFO: Updating cache of Gadfly...
INFO: Updating cache of ArrayViews...
INFO: Updating cache of Lazy...
INFO: Updating cache of ImmutableArrays...
INFO: Updating cache of Graphics...
INFO: Updating cache of StatsBase...
INFO: Updating cache of Requires...
INFO: Updating cache of MacroTools...
INFO: Updating cache of NaNMath...
INFO: Updating cache of FactCheck...
INFO: Updating cache of DataArrays...
INFO: Updating cache of Grid...
INFO: Updating cache of Loess...
INFO: Updating cache of Compat...
INFO: Updating cache of FixedPointNumbers...
INFO: Updating cache of WoodburyMatrices...
INFO: Updating cache of Compose...
INFO: Updating cache of JuliaParser...
INFO: Updating cache of Iterators...
INFO: Updating cache of JSON...
INFO: Updating cache of DataFrames...
INFO: Updating cache of GZip...
INFO: Updating cache of Reexport...
INFO: Updating cache of Showoff...
INFO: Updating cache of Distributions...
INFO: Updating cache of Optim...
INFO: Updating cache of Color...
INFO: Updating cache of SortingAlgorithms...
INFO: Updating cache of Docile...
INFO: Updating cache of Calculus...
INFO: Updating cache of PDMats...
INFO: Updating cache of DualNumbers...
INFO: Updating cache of DataStructures...
INFO: Updating cache of Jewel...
ERROR: couldn't update C:\Users\ejfie\.julia\v0.3\.cache\Hexagons using `git 
remote update`
 in wait at task.jl:284
 in wait at task.jl:194
 in wait at task.jl:48
 in sync_end at task.jl:311
 in update at pkg/entry.jl:319
 in anonymous at pkg/dir.jl:28
 in cd at file.jl:30
 in cd at pkg/dir.jl:28
 in update at pkg.jl:41

julia> using Images
ERROR: Images not properly installed. Please run Pkg.build("Images") then 
restart Julia.
 in error at error.jl:21 (repeats 2 times)
while loading C:\Users\ejfie\.julia\v0.3\Images\src\ioformats/libmagickwand.jl, 
in expression starting on line 31
while loading C:\Users\ejfie\.julia\v0.3\Images\src\Images.jl, in expression 
starting on line 38

julia> Pkg.build("Images")
INFO: Building Images
=[ ERROR: Images 
]=


type Nothing has no field match
while loading C:\Users\ejfie\.julia\v0.3\Images\deps\build.jl, in expression 
starting on line 37

===


=[ BUILD ERRORS 
]==


WARNING: Images had build errors.

 - packages with build errors remain installed in C:\Users\ejfie\.julia\v0.3
 - build the package(s) and all dependencies with `Pkg.build("Images")`
 - build a single package by running its `deps/build.jl` script

===


julia>


Hopefully I'm missing something simple here! Any suggestion?


[julia-users] setting span for Loess filter

2015-09-24 Thread Evan
I am using Loess.jl to do some filtering of a few hundred daily time 
series, with gaps, and length ~4000 days.

I want to remove variability with periods below 20 days. In matlab this is 
easy to define:

Z = SMOOTH(X,Y,0.3,'loess') uses the loess method where span is
30% of the data, i.e. span = ceil(0.3*length(Y)).

The loess.jl function accepts the *span* parameter, with recommended value 
between 0 and 1. I have tried using span=1/20 (i.e., my desired cutoff 
period), but this approach would contradict the fact that smaller (larger) 
values of span lead to less (more) smoothing.  My question is how to 
specify span precisely for various cutoff periods?

Thanks, Evan


[julia-users] Re: installation problem mageia 5

2015-09-13 Thread Evan
I found the solution here: 
https://github.com/JuliaLang/julia/issues/13089


On Thursday, September 10, 2015 at 10:40:23 PM UTC+2, Evan wrote:
>
> Hi, I am trying to install Julia on a Mageia 5 i7 system.  In Make.user I 
> put this:
>
> USE_SYSTEM_LLVM=1
> USE_SYSTEM_BLAS=1
> USE_SYSTEM_LAPACK=1
> USE_SYSTEM_FFTW=1
> USE_SYSTEM_MPFR=1
> USE_SYSTEM_ARPACK=1
> USE_SYSTEM_ZLIB=1
> USE_SYSTEM_RMATH=1
>
> and the tail of output from "make" is below:
> 
> In file included from codegen.cpp:766:0:
> debuginfo.cpp: In function ‘void jl_getDylibFunctionInfo(const char**, 
> size_t*, const char**, size_t, int*, int)’:
> debuginfo.cpp:359:16: warning: unused variable ‘msize’ [-Wunused-variable]
>  size_t msize = (size_t)(((uint64_t)-1)-fbase);
> ^
> CC src/interpreter.o
> CC src/alloc.o
> CC src/dlload.o
> CC src/sys.o
> CC src/init.o
> CC src/task.o
> CC src/array.o
> CC src/dump.o
> CC src/toplevel.o
> CC src/jl_uv.o
> CC src/jlapi.o
> CC src/profile.o
> CC src/llvm-simdloop.o
> CC src/gc.o
> LINK usr/lib/libjulia.so
> PERL base/pcre_h.jl
> PERL base/errno_h.jl
> PERL base/build_h.jl.phony
> PERL base/fenv_constants.jl
> PERL base/file_constants.jl
> PERL base/uv_constants.jl
> fatal: bad revision '^origin/release-0.3'
> fatal: Not a valid object name origin/release-0.3
> PERL base/version_git.jl.phony
> CC ui/repl.o
> LINK usr/bin/julia
> exports.jl
> base.jl
> reflection.jl
> build_h.jl
> error during bootstrap: LoadError(at "sysimg.jl" line 28: LoadError(at 
> "build_h.jl" line 2: ErrorException("syntax: invalid character "")))
> Makefile:127: recipe for target '/opt/julia/julia/usr/lib/julia/sys0.o' 
> failed
> make[1]: *** [/opt/julia/julia/usr/lib/julia/sys0.o] Error 1
> Makefile:37: recipe for target 'release' failed
> make: *** [release] Error 2
> [emason@marula julia (release-0.3)]$
>
> See also the full output: 
> https://gist.github.com/evanmason/89d73157f042680ee755
>
>
> When I inspect line 2 of base/build_h.jl, I see indeed that line 2 seems 
> to be corrupted:
>
> # This file is automatically generated in base/Makefile
> ^[[01;31m^[[Kc^[[m^[[K^[[01;31m^[[Ko^[[m^[[K^[[01;31m^[[Kn^[[m^[[K^[[01;31m^[[Ks^[[m^[[K^[[01;31m^[[Kt^[[m^[[K^[[01;31m^[[K
>  
> ^[[m^[[K^[[01;31m^[[KO^[[m^[[K^[[01;31m^[[KS^[[m^[[K^[[01;31m^[[K_^[[m^[[K^[[01;31m^[[KN^[[m^[[K^[[01;31m^[[KA^[[m^[[K^[[01;31m^[[KM^[[m^[[K^[[01;31m^[[KE^[[m^[[K^[[01;31m^[[K
>  
> ^[[m^[[K^[[01;31m^[[K=^[[m^[[K^[[01;31m^[[K 
> ^[[m^[[K^[[01;31m^[[K:^[[m^[[K^[[01;31m^[[KL^[[m^[[K^[[01;31m^[[Ki^[[m^[[K^[[01;31m^[[Kn^[[m^[[K^[[01;31m^[[Ku^[[m^[[K^[[01;31m^[[Kx^[[m^[[K
> const ARCH = :x86_64
> const MACHINE = "x86_64-mageia-linux-gnu"
> const libm_name = "libopenlibm"
> const libblas_name = "libblas"
> const liblapack_name = "liblapack"
> const USE_BLAS64 = true
> const libfftw_name = "libfftw3_threads"
> const libfftwf_name = "libfftw3f_threads"
> const libllvm_version = "3.5.2"
> const VERSION_STRING = "0.3.12-pre"
> const TAGGED_RELEASE_BANNER = ""
> const SYSCONFDIR = "../etc"
> const DATAROOTDIR = "../share"
>
> I'd be grateful for any help with this.
>
> Thanks, Evan
>


[julia-users] Re: installation problem mageia 5

2015-09-11 Thread Evan
I agree it's a strange error.
I have recloned several times from github, but I always get this exact same 
error.
And I checked for disk errors with smartctl and dmesg, but nothing 
suspicious.

Has anyone else had success on a Mageia system?




[julia-users] installation problem mageia 5

2015-09-10 Thread Evan
Hi, I am trying to install Julia on a Mageia 5 i7 system.  In Make.user I 
put this:

USE_SYSTEM_LLVM=1
USE_SYSTEM_BLAS=1
USE_SYSTEM_LAPACK=1
USE_SYSTEM_FFTW=1
USE_SYSTEM_MPFR=1
USE_SYSTEM_ARPACK=1
USE_SYSTEM_ZLIB=1
USE_SYSTEM_RMATH=1

and the tail of output from "make" is below:

In file included from codegen.cpp:766:0:
debuginfo.cpp: In function ‘void jl_getDylibFunctionInfo(const char**, 
size_t*, const char**, size_t, int*, int)’:
debuginfo.cpp:359:16: warning: unused variable ‘msize’ [-Wunused-variable]
 size_t msize = (size_t)(((uint64_t)-1)-fbase);
^
CC src/interpreter.o
CC src/alloc.o
CC src/dlload.o
CC src/sys.o
CC src/init.o
CC src/task.o
CC src/array.o
CC src/dump.o
CC src/toplevel.o
CC src/jl_uv.o
CC src/jlapi.o
CC src/profile.o
CC src/llvm-simdloop.o
CC src/gc.o
LINK usr/lib/libjulia.so
PERL base/pcre_h.jl
PERL base/errno_h.jl
PERL base/build_h.jl.phony
PERL base/fenv_constants.jl
PERL base/file_constants.jl
PERL base/uv_constants.jl
fatal: bad revision '^origin/release-0.3'
fatal: Not a valid object name origin/release-0.3
PERL base/version_git.jl.phony
CC ui/repl.o
LINK usr/bin/julia
exports.jl
base.jl
reflection.jl
build_h.jl
error during bootstrap: LoadError(at "sysimg.jl" line 28: LoadError(at 
"build_h.jl" line 2: ErrorException("syntax: invalid character "")))
Makefile:127: recipe for target '/opt/julia/julia/usr/lib/julia/sys0.o' 
failed
make[1]: *** [/opt/julia/julia/usr/lib/julia/sys0.o] Error 1
Makefile:37: recipe for target 'release' failed
make: *** [release] Error 2
[emason@marula julia (release-0.3)]$

See also the full output: 
https://gist.github.com/evanmason/89d73157f042680ee755


When I inspect line 2 of base/build_h.jl, I see indeed that line 2 seems to 
be corrupted:

# This file is automatically generated in base/Makefile
^[[01;31m^[[Kc^[[m^[[K^[[01;31m^[[Ko^[[m^[[K^[[01;31m^[[Kn^[[m^[[K^[[01;31m^[[Ks^[[m^[[K^[[01;31m^[[Kt^[[m^[[K^[[01;31m^[[K
 
^[[m^[[K^[[01;31m^[[KO^[[m^[[K^[[01;31m^[[KS^[[m^[[K^[[01;31m^[[K_^[[m^[[K^[[01;31m^[[KN^[[m^[[K^[[01;31m^[[KA^[[m^[[K^[[01;31m^[[KM^[[m^[[K^[[01;31m^[[KE^[[m^[[K^[[01;31m^[[K
 
^[[m^[[K^[[01;31m^[[K=^[[m^[[K^[[01;31m^[[K 
^[[m^[[K^[[01;31m^[[K:^[[m^[[K^[[01;31m^[[KL^[[m^[[K^[[01;31m^[[Ki^[[m^[[K^[[01;31m^[[Kn^[[m^[[K^[[01;31m^[[Ku^[[m^[[K^[[01;31m^[[Kx^[[m^[[K
const ARCH = :x86_64
const MACHINE = "x86_64-mageia-linux-gnu"
const libm_name = "libopenlibm"
const libblas_name = "libblas"
const liblapack_name = "liblapack"
const USE_BLAS64 = true
const libfftw_name = "libfftw3_threads"
const libfftwf_name = "libfftw3f_threads"
const libllvm_version = "3.5.2"
const VERSION_STRING = "0.3.12-pre"
const TAGGED_RELEASE_BANNER = ""
const SYSCONFDIR = "../etc"
const DATAROOTDIR = "../share"

I'd be grateful for any help with this.

Thanks, Evan


[julia-users] scope of the expression (made with Expr)

2015-05-06 Thread Evan Pu
Hi, just a quick question on the scope/environment of an expression.

I am using the Expr construct inside a function to create an expression, 
and I would then want to use this expression in various different places. 
Here's a short example

First we have a simple function funky that takes in a function ff, and 
applies it to two symbolic arguments :x and :y
julia function funky(ff::Function)
 Expr(:call, ff, :x, :y)
   end
funky (generic function with 1 method)


We define x and y to be 1 and 2 respectively
julia x,y = 1,2
(1,2)


No surprise here, when funky is passed with the function +, it adds x and 
y together
julia eval(funky(+))
3


However, now I want to use this expression with different bindings for x 
and y, I attempt the following
julia function funfun(x, y)
 eval(funky(+))
   end
funfun (generic function with 1 method)


Which doesn't seem to work. Here the result is sitll 3, presumably it is 
using the earlier bindings of x=1, y=2
julia funfun(4,5)
3

I would really liked the last result to be 9.


So far it seems the expression uses static scoping and it's looking up the 
binding for :x and :y in the frame generated by calling funky, and not 
finding it there, it looks up :x and :y in the 
global frame, which is 1 and 2.
Is there a way to bind the symbols in an expression to different things? is 
there like an environment dictionary where we can mess with, or is there 
some clean way of doing it?

Much much much appreciated!!!
--evan


[julia-users] how do I overwrite the toString equivalent in Julia?

2015-02-09 Thread Evan Pu
I have a type with a lot of fields, but when I want to print it I only want 
to output the name field of that type.
So when I print an array of objects of this type, I get a on the prinout an 
array of names instead of a huge clutter of prints.

how might I do that?
much thanks!!


[julia-users] pair-wise operation on an array?

2015-02-07 Thread Evan Pu
say I want to compute a pair-wise diff for all the elements in the array.
input:[1, 2, 4, 7, 8]
output:[1, 2, 3, 1]

is there some kind of beautiful way of doing it? i.e. w/o using a for 
loop nor using explicit indecies


Re: [julia-users] pair-wise operation on an array?

2015-02-07 Thread Evan Pu
i see, maybe my example is too special.
What i meant is I have an array of elements and I have a binary operator 
which I want to apply to every adjacent elements.

On Saturday, February 7, 2015 at 7:26:55 AM UTC-5, Tamas Papp wrote:

 diff([1, 2, 4, 7, 8]) 

 I don't think it gets more beautiful than this :D 

 Best, 

 Tamas 

 On Sat, Feb 07 2015, Evan Pu evanth...@gmail.com javascript: wrote: 

  say I want to compute a pair-wise diff for all the elements in the 
 array. 
  input:[1, 2, 4, 7, 8] 
  output:[1, 2, 3, 1] 
  
  is there some kind of beautiful way of doing it? i.e. w/o using a for 
  loop nor using explicit indecies 



[julia-users] incomplete println? (and debugging memory in general)

2015-02-04 Thread Evan Pu
I'm trying to find a memory bug where all of a sudden my program freezes 
and eats up all the memory.
I tried to do some printing, and tried to understand which line of code is 
responsible for causing the memory leak to happen.
The print statement looks like this:

println(computing cost for..., fact.f_name,  , dom)

where fact is an object with a name, f_name, which is a string, and 
dom is simply a list of tuple of numbers.
Usually, this line of code will output something like this in the console:

computing cost for...f_inte1 [(7.2109375,7.21875)]

Indicating that it is about to start computing the cost for the fact 
object. However, when this memory bug occurs, it only prints this:

computing cost for...^CERROR: interrupt

It does not give me the name of fact before the bug happens, nor does it 
attempt to print out the dom. It doesn't even give me a stack trace!


I am very clueless on what could be happening. So here is my 3 questions:
1) What could cause a print statement to not finish printing? the fact 
objects are all already allocated, and all with a valid f_name field.
2) If there is some memory error where I am forced to ^C before my computer 
freezes, how can I recover a call-stack?
the answer here I think... is I am using the @profile macro so something 
happened that prevented the call-stack from showing.

3) Is there some way of knowing which part of the program is consuming most 
of the memory at the time of the bug? I tried using 
--track-allocation=all, but I do not care about memories that are already 
re-claimed by the garbage collector, but I do care about memory yet to be 
claimed at the time of the error.

Sorry for the long post...
--evan


[julia-users] julia array type?

2015-01-19 Thread Evan Pu
I'm trying to construct an array while making an array of pairs of floats. 
The error below is extremely confusing and I have no idea why.


=
# create the array w/o type declarations works fine
julia x = [(0.0, 1.0), (0.0, 1.0)]
2-element Array{(Float64,Float64),1}:
 (0.0,1.0)
 (0.0,1.0)

# but declaring the type in the constructor breaks it?!
julia y = (Float64, Float64)[(0.0, 1.0), (0.0, 1.0)]
ERROR: `getindex` has no method matching 
getindex(::Type{(Float64,Float64)}, ::(Float64,Float64), 
::(Float64,Float64))

# but somehow manually adding with push! works?!
julia z = (Float64, Float64)[]
0-element Array{(Float64,Float64),1}

julia push!(z, (0.0, 1.0))
1-element Array{(Float64,Float64),1}:
 (0.0,1.0)

julia push!(z, (0.0, 1.0))
2-element Array{(Float64,Float64),1}:
 (0.0,1.0)
 (0.0,1.0)



[julia-users] Re: What's your favourite editor?

2015-01-19 Thread Evan Pu
light table juno plugin.
literally cannot use the language w/o it haha, although it is buggy at times

On Saturday, January 17, 2015 at 11:34:46 AM UTC-5, Terry Seaward wrote:

 Hi,

 Just curious to know what people use to write/edit their Julia code 
 (os/app)?



[julia-users] Re: Simple type constructor question

2015-01-15 Thread Evan Pu
very handy, just saw this reply now.
thanks a ton

On Thursday, November 6, 2014 at 5:16:31 PM UTC-5, Valentin Churavy wrote:

 You could using a abstract type instead of a Union

 abstract Element
 type Tree 
   body :: Element
 end

 type Branch : Element
   a :: Tree
   b :: Tree
 end

 type Leaf : Element
   a
 end

 so  this would create a tree
 julia Tree(Branch(
Tree(Leaf(:a)), 
Tree(Branch(
   Tree(Leaf(:b)),
   Tree(Leaf(:c))
))
   ))
 Tree(Branch(Tree(Leaf(:a)),Tree(Branch(Tree(Leaf(:b)),Tree(Leaf(:c))

 adding the following methods makes it a bit more readable

 Tree(a :: Any) = Tree(Leaf(a))
 Tree(a :: Tree,b::Tree) = Tree(Branch(a, b))

 julia Tree(
 Tree(:a), 
 Tree(
  Tree(:b),
  Tree(:c)
   )
 )
 Tree(Branch(Tree(Leaf(:a)),Tree(Branch(Tree(Leaf(:b)),Tree(Leaf(:c))


 So this stills looks a bit clunky and you should also be aware that this 
 allows for Tree(Tree(:a), Tree(1.0)) so some type constraints would be in 
 order.


 On Thursday, 6 November 2014 21:52:05 UTC+1, Evan Pu wrote:

 Quick question:

 In haskell one can do something like the following to define a type:

  data Tree a = Branch (Tree a) (Tree a) | Leaf a


 Is there something analogous in the Julia world?
 I'm sure I'm doing something wrong here...

 julia type Tree
body :: Union(Branch, Leaf)
end
 ERROR: Branch not defined

 julia type Branch
a :: Tree
b :: Tree
end
 ERROR: Tree not defined

 julia type Leaf
a
end

 thanks!



[julia-users] what do you do with strings in julia

2015-01-13 Thread Evan Pu
what is the convention? I kept getting
`convert` has no method matching convert(::Type{SubString(UTF8String)}}, 
::ASCIIString)
all the time, every time

I I don't really know _why_ this error comes up, or how or what. I just 
kept typing :: ASCIIString trying to force the types onto things and 
hopefully it goes away, so of course I'm doing something wrong.
thanks~


[julia-users] Re: what do you do with strings in julia

2015-01-13 Thread Evan Pu
Steven,
The error is actually an issue with LightTable's Juno plugin and actually 
has nothing to do with Julia.
I think what happened is in reporting the errors the plugin makes some 
mistake and ended up reporting another error(or itself had some misuse of 
strings) instead. 
The actual error was discovered while running it from the command shell is 
in fact:
ERROR: assertion failed
 in ∫ at SimplePoly.jl:286
 in ∫ at SimplePoly.jl:518
 in ∫ at SimplePoly.jl:786
 in ∫ at Factor.jl:153
which seems more reasonable, as the assertion is the one I wrote.

sorry for the troubles!



On Tuesday, January 13, 2015 at 3:16:44 PM UTC-5, Steven G. Johnson wrote:

 Though we could define such a conversion method with:

 convert{T:AbstractString}(::Type{SubString{T}}, s::AbstractString) = 
 let s′ = T(s); SubString(s′, 1, endof(s′)); end

 Evan, what is your application here?  What are you trying to do?



[julia-users] Re: what do you do with strings in julia

2015-01-13 Thread Evan Pu
I'll try. the call chain is rather large and I'll see if I can get it down 
to a few constructs.

On Tuesday, January 13, 2015 at 4:34:39 PM UTC-5, Steven G. Johnson wrote:



 On Tuesday, January 13, 2015 at 4:10:54 PM UTC-5, Evan Pu wrote:

 Steven,
 The error is actually an issue with LightTable's Juno plugin and actually 
 has nothing to do with Julia.


 Can you file an issue at:

 https://github.com/one-more-minute/Jewel.jl

 explaining how the error arose? 



[julia-users] initialize array of arrays?

2015-01-08 Thread Evan Pu
Imagine I want to initialize an array of array.
x = [[1,2],[3,4]]

but this gets flattened into [1,2,3,4]

Is there an easy way of constructing a nested array? I'm currently having 
to do
x = Array{Int64}[]
push!(x, [1,2])
push!(x, [3,4])
which doesn't seem very clean


[julia-users] Re: initialize array of arrays?

2015-01-08 Thread Evan Pu
works for me! thanks!!

On Thursday, January 8, 2015 1:07:35 PM UTC-5, Steven G. Johnson wrote:

 You can do Array{Int}[[1,2],[3,4]], or Vector{Int}[[1,2],[3,4]] if you 
 want to restrict the entries to be 1d arrays of Int.



Re: [julia-users] Re: package proposal

2014-12-26 Thread Evan Pu
is this thread still alive? a phc package would be good...

On Monday, June 23, 2014 5:26:34 AM UTC-7, Andrei Berceanu wrote:

 By the way I recently stumbled upon NLSolve.jl, and asked them if they 
 would be interested in PHCpack
 https://github.com/EconForge/NLsolve.jl/issues/12

 Still no reply on their part yet though.

 On Monday, June 23, 2014 1:06:03 PM UTC+2, Andrei Berceanu wrote:

 Free binary versions for Mac and Windows of the gnu-ada compiler are 
 available at http://libre.adacore.com/ and are very easy to install.
 As for HOMPACK, the main difference is that PHCpack is specifically 
 targeted for polynomial systems. HOMPACK provides continuation methods for 
 general nonlinear systems and has extra drivers for polynomial systems. 
 Another main difference is that PHCpack offers polyhedral homotopies, which 
 are absent from HOMPACK. So I guess it depends on what we want really, 
 personally I am interested in polynomial systems. Please let me know if you 
 succeed in installing the ada compiler for Mac from the above link.


 On Friday, June 20, 2014 11:36:01 PM UTC+2, Tony Kelman wrote:

 That sounds like the best plan for the PHCpack code. Have you looked at 
 or are you familiar with whether HOMPACK as Hans mentioned would be able to 
 provide similar functionality? I say that just because more of us are used 
 to building Fortran code than Ada. Ada should be reasonable to work with on 
 Linux, and maybe even in MinGW or Cygwin, but it doesn't look like it's set 
 up in Homebrew for Mac users. If you know of a standard way to install GNAT 
 and can get the library building on at least your platform of choice, go 
 for it.


 On Friday, June 20, 2014 2:14:18 PM UTC-7, Andrei Berceanu wrote:

 I have contacted the author (
 https://github.com/janverschelde/PHCpack/issues/3) and it seems 
 redistribution under a different license is not really an option.
 However, if what Milan says is correct, then we should be able to 
 include it 'as-is'.
 Now for the interface, I was thinking that, since there already exists 
 a comprehensive C API to the Ada code, we could call that from Julia, what 
 do you guys reckon?

 On Friday, June 6, 2014 2:18:33 PM UTC+2, Milan Bouchet-Valat wrote:

  Le vendredi 06 juin 2014 à 03:43 -0700, Hans W Borchers a écrit : 

 Please notice that PHCpack is distributed under GPL license, so your 
 first 

  step should be to contact the author and ask for his approval to 
 distribute  

  it under a lesser license such as MIT. 


 Though since it's a package rather than code to be included in Julia 
 Base, GPL is fine too.


 Regards 



[julia-users] how to test NaN in an array?

2014-12-15 Thread Evan Pu
1 in [1,2,3] # returns true

NaN in [NaN, 1.0, 2.0] # returns false

how do I test if a float64 NaN is present in an array? I'm doing some 
numerical computation and it can have some NaN error, I want to drop the 
arrays that has NaN.


Re: [julia-users] how to test NaN in an array?

2014-12-15 Thread Evan Pu
come to think of it that is the right semantics.
well designed language this is!

On Monday, December 15, 2014 3:35:22 PM UTC-5, John Myles White wrote:

 You need to check isnan() per element. NaN == NaN is false, so in() fails 
 on NaN right now. 

  -- John 

 On Dec 15, 2014, at 3:33 PM, Evan Pu evanth...@gmail.com javascript: 
 wrote: 

  1 in [1,2,3] # returns true 
  
  NaN in [NaN, 1.0, 2.0] # returns false 
  
  how do I test if a float64 NaN is present in an array? I'm doing some 
 numerical computation and it can have some NaN error, I want to drop the 
 arrays that has NaN. 



[julia-users] customized hash function (or equality function)?

2014-12-10 Thread Evan Pu
Hi, this should be a simple affair.

I have a polynomial object that keeps track of its coefficients, it is 
defined as follows:

immutable Poly1
  coef :: Array{Float64}
end

I would like to make a dictionary with keys that are Poly1 type, like 
follows:

# creation
r_dict1 = [Poly1([1.0, 2.0]) = 1]
# access
r_dict1[Poly1([1.0, 2.0])]

However currently it gives the arrow key not found
By looking at the hash we can see why, the has is not identical even for 
equal polynomials:
hash(Poly1([1.0, 2.0])) # gives an arbitrary hex string
hash(Poly1([1.0, 2.0])) # gives a different hex string

How would I implement my own hash so the same polynomials (by same I mean 
the coefficients are same, i.e. the coef::Array{Float64} part of the two 
polynomials are the same?

Much thanks!!
--evan


[julia-users] Re: customized hash function (or equality function)?

2014-12-10 Thread Evan Pu
wonderful! thanks!!

On Wednesday, December 10, 2014 8:24:17 PM UTC-5, Steven G. Johnson wrote:

 Base.hash(p::Poly1, h::Uint) = hash(p.coef, h)
 Base.(==)(p1::Poly1, p2::Poly2) = p1.coef == p2.coef

 (If you override hash you should always override == to be consistent, and 
 vice versa.)



[julia-users] Simple type constructor question

2014-11-06 Thread Evan Pu
Quick question:

In haskell one can do something like the following to define a type:

 data Tree a = Branch (Tree a) (Tree a) | Leaf a


Is there something analogous in the Julia world?
I'm sure I'm doing something wrong here...

julia type Tree
   body :: Union(Branch, Leaf)
   end
ERROR: Branch not defined

julia type Branch
   a :: Tree
   b :: Tree
   end
ERROR: Tree not defined

julia type Leaf
   a
   end

thanks!


Re: [julia-users] type confusions in list comprehensions (and how to work around it?)

2014-11-04 Thread Evan Pu
It does indeed happens inside the function, if you pass a function as an 
argument to it (rather than refering to f implicitly in the function body, 
you explicitly pass in f as an extra argument)
see below:

julia f(x) = x + 1
f (generic function with 1 method)

julia g(f, xs) = [f(x) for x in xs]
g (generic function with 1 method)

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

julia g(f,xs)
3-element Array{Any,1}:
 2
 3
 4


On Tuesday, November 4, 2014 2:22:24 AM UTC-5, Jutho wrote:

 This only happens in global scope, not inside a function? If you define
 f(list) = return [g(x) for x in list]

 then f(xs) will return an Array{Float64,1}. 

 Op dinsdag 4 november 2014 03:23:36 UTC+1 schreef K leo:

 I found that I often have to force this conversion, which is not too 
 difficult.  The question why comprehension has to build with type Any? 


 On 2014年11月04日 07:06, Miguel Bazdresch wrote: 
   How could I force the type of gxs1 to be of an array of Float64? 
  
  The simplest way is: 
  
  gxs1 = Float64[g(x) for x in xs] 
  
  -- mb 
  
  On Mon, Nov 3, 2014 at 6:01 PM, Evan Pu evanth...@gmail.com 
  mailto:evanth...@gmail.com wrote: 
  
  Consider the following interaction: 
  
  julia g(x) = 1 / (1 + x) 
  g (generic function with 1 method) 
  
  julia typeof(g(1.0)) 
  Float64 
  
  julia xs = [1.0, 2.0, 3.0, 4.0] 
  4-element Array{Float64,1}: 
   1.0 
   2.0 
   3.0 
   4.0 
  
  julia gxs1 = [g(x) for x in xs] 
  4-element Array{Any,1}: 
   0.5 
   0.33 
   0.25 
   0.2 
  
  Why isn't gxs1 type of Array{Float64,1}? 
  How could I force the type of gxs1 to be of an array of Float64? 
  
  julia gxs2 = [convert(Float64,g(x)) for x in xs] 
  4-element Array{Any,1}: 
   0.5 
   0.33 
   0.25 
   0.2 
  
  somehow this doesn't seem to work... 
  
  
  
  



[julia-users] Is there an implicit apply method for a type?

2014-11-04 Thread Evan Pu
Hello,
I want to create a polynomial type, parametrized by its coefficients, able 
to perform polynomial additions and such.
but I would also like to use it like a function call, since a polynomial 
should be just like a function
Something of the following would be nice:

p = Poly([1,2,3]) # creating a polynomial p(x) = 1 + 2x + 3x^2
q = Poly([1,2]) # creating a polynomial 1 + 2x
r = p + q # using dynamic dispatch, creating the polynomial 2 + 4x + 3x^2

r(1) # this should give 9, by evaluating polynomial r at x = 1

Is there something in Julia that would allow me to create what I have in 
mind?
thanks!!


[julia-users] base case for the reduce operator?

2014-11-04 Thread Evan Pu
Hi I'm writing a simple polynomial module which requires addition of 
polynomials.

I have defined the addition by overloading the function + with an 
additional method:
+(p1::Poly, p2::Poly) = ...# code for the addition

I would like to use + now in a reduce call, imagine I have a list of 
polynomials [p1, p2, p3],
calling reduce(+, [p1, p2, p3]) behaves as expected, giving me a polynomial 
that's the sum of the 3

however, I would also like to cover the edge cases where there's only a 
single polynomial or no polynomial.
I would like the following behaviours, :

# reducing with a single polynomial list gives just the polynomial back
reduce(+, [p1]) 
 p1

# reducing with an empty list gives back the 0 polynomial
reduce(+, [])
 ZeroPoly

How might I add such functionality?
For the empty list case, how might I annotate the type so Julia is aware 
that [] means an empty list of polynomials rather than an empty list of Any?


Re: [julia-users] Fully Typed Function As Argument Type

2014-11-03 Thread Evan Pu
Nooo TT I was looking for it too today.
Hope it gets added soon, fingers crossed!

On Thursday, August 14, 2014 10:31:17 AM UTC-4, John Myles White wrote:

 Not possible in the current versions of Julia. Maybe one day. There are 
 bunch of us who’d like to have this functionality, but it’s a non-trivial 
 addition of complexity to the compiler.

  — John

 On Aug 14, 2014, at 4:59 AM, Chris Kellendonk chriske...@gmail.com 
 javascript: wrote:

 I'm new to the language so I may have missed something. But is there a way 
 to make sure a function passed as an argument is of a specific type 
 including it's arguments? It doesn't look like from the design of the 
 language this could be supported but I'm curious.

 For example I would like to be able to do:

 function callme(handler::Function(Int32, Float64))
 handler(12, 0.2)
 end

 And the compiler would guarantee the correct type of function is called.

 Thanks,




[julia-users] type confusions in list comprehensions (and how to work around it?)

2014-11-03 Thread Evan Pu
Consider the following interaction:

julia g(x) = 1 / (1 + x)
g (generic function with 1 method)

julia typeof(g(1.0))
Float64

julia xs = [1.0, 2.0, 3.0, 4.0]
4-element Array{Float64,1}:
 1.0
 2.0
 3.0
 4.0

julia gxs1 = [g(x) for x in xs]
4-element Array{Any,1}:
 0.5 
 0.33
 0.25
 0.2 

Why isn't gxs1 type of Array{Float64,1}?
How could I force the type of gxs1 to be of an array of Float64?

julia gxs2 = [convert(Float64,g(x)) for x in xs]
4-element Array{Any,1}:
 0.5 
 0.33
 0.25
 0.2   

somehow this doesn't seem to work...





[julia-users] Free Julia Workshop in Chicago Nov. 15

2014-11-01 Thread Evan Miller
For those of you in the Chicago area, Leah Hanson will be giving a free
full-day Julia workshop on November 15. Full details here:

http://www.meetup.com/JuliaChicago/events/216950712/

Feel free to pass the link along to anyone you think might be interested.
The event will be held downtown and close to transit. If you'd like to
attend, please sign up through Meetup before November 12. Thanks!

Evan

-- 
Evan Miller
http://www.evanmiller.org/


[julia-users] how to find out how many argument a function has?

2014-10-16 Thread Evan Pu
I'm assuming the function only has a single method, although a more general 
answer would be nice too.
Imagine I have:
f(x,y,z) = x + y + z

I would like to have something like
num_args(f)
which should give back 3

is there something that could let me do this?
thanks a lot!!


[julia-users] how to i get number of arguments of a function?

2014-10-16 Thread Evan Pu
How do I get the number of arguments of a function?

for instance, f(x, y) = x + y

I want something like num_args(f), which will give me back 2. If the 
function has multiple methods then something more general would be nice, 
but so far I only care about functions with just a single method.

Is there something like this?
thanks alot!!


Re: [julia-users] how to i get number of arguments of a function?

2014-10-16 Thread Evan Pu
thanks!!

On Thursday, October 16, 2014 12:41:22 PM UTC-4, Tim Holy wrote:

 You might want to look into the various introspection functions, like 
 `methods`, `code_lowered`, etc. Leah Hanson had a nice blog post: 
 http://blog.leahhanson.us/julia-introspects.html 

 For your specific problem, once you have a specific method, then `m.sig` 
 returns 
 its signature, and you can just compute the length. A MethodTable 
 (returned by 
 `methods(sum)`, for example) is iterable, so you can iterate over the 
 table 
 until you find what you want. 

 Best, 
 --Tim 

 On Thursday, October 16, 2014 08:55:01 AM Evan Pu wrote: 
  How do I get the number of arguments of a function? 
  
  for instance, f(x, y) = x + y 
  
  I want something like num_args(f), which will give me back 2. If the 
  function has multiple methods then something more general would be nice, 
  but so far I only care about functions with just a single method. 
  
  Is there something like this? 
  thanks alot!! 



[julia-users] named function within a loop is overwritten?

2014-10-16 Thread Evan Pu
Consider this code:

function give_funs()
  funs = []
  for i in 1:5
function newfun()
  i
end
funs = [funs, newfun]
  end
  funs
end

The intention is to create 5 functions and store them in a list called 
funs.
All the functions take no argument, and when the ith function is called, it 
returns i.

However, when run...
funs1 = give_funs()
funs1[1]() # this should give 1, but instead it gives 5
funs1[2]() # this should give 2, but instead it gives 5 as well

This is problem goes away if I stop naming the function as newfun but 
instead use ananymous functions like so:
funs = [funs, () - i]
however in real code I would like to give it a name so to be more clear 
what the function is suppose to compute

It seems that these functions are bound by their function names, and since 
they're all named newfun, the compiler over-write the old ones defined 
earlier.

How should this be resolved?


Re: [julia-users] how to i get number of arguments of a function?

2014-10-16 Thread Evan Pu
yeah, the function I'm intending to inspect will be defined by me and they 
shouldn't be varargs

On Thursday, October 16, 2014 2:10:34 PM UTC-4, Toivo Henningsson wrote:

 Though you should probably look out for varargs methods too, the length of 
 e.g. (Int...) is one, but a method with that signature can take any number 
 of arguments. 



[julia-users] JuliaCon: Registration is open!

2014-05-06 Thread Evan Miller
On behalf of the JuliaCon committee[1], I'm pleased to announce that
registration is now open for JuliaCon, taking place June 26 and 27 at the
University of Chicago's Gleacher Center in Chicago, IL. JuliaCon will be a
two-day, single-track conference and an excuse for the Julia faithful to
get together and geek out. Tickets are $110.

Conference website: http://www.juliacon.org/

Registration page: http://juliacon.eventbrite.com/

We have some great speakers lined up already, and are looking for more. See
the Call For Participation on the website for details. Talk proposals are
due Monday, May 26.

The day after the conference, Hack@UChicago will host a free Julia Hack Day
at the University of Chicago's Hyde Park campus. You'll need to register
for this event separately (link on website).

Sponsorship opportunities are available, which will help us keep the ticket
prices nice and cheap. If your organization might be interested in being a
JuliaCon sponsor, please contact me directly.

Mark your calendar, and get pumped! This will be a great event. More
information will be posted on the website as the conference approaches.

See you in June!

Evan



1. Full committee:

Douglas Bates, Wisconsin-Madison
Jeff Bezanson, MIT
Jonah Bloch-Johnson, UChicago
Jiahao Chen, MIT
Alan Edelman, MIT
Garrett Smith, CloudBees
Jeff Hammond, Argonne
Tim Holy, WUSTL
Stefan Karpinski, MIT
Evan Miller, Wizard
Hunter Owens, UChicago
James Porter, UChicago
Arch Robison, Intel
Viral B Shah, MIT


Re: [julia-users] Re: JuliaCon: Registration is open!

2014-05-06 Thread Evan Miller
Yes, the plan is to post recordings of all the talks online after the
conference.


On Tue, May 6, 2014 at 8:11 PM, Paulo Castro p.oliveira.cas...@gmail.comwrote:

 Will the event organizators post videos on youtube for Julia users that
 couldn't attend?

 Em terça-feira, 6 de maio de 2014 16h51min03s UTC-3, Evan Miller escreveu:

 On behalf of the JuliaCon committee[1], I'm pleased to announce that
 registration is now open for JuliaCon, taking place June 26 and 27 at the
 University of Chicago's Gleacher Center in Chicago, IL. JuliaCon will be a
 two-day, single-track conference and an excuse for the Julia faithful to
 get together and geek out. Tickets are $110.

 Conference website: http://www.juliacon.org/

 Registration page: http://juliacon.eventbrite.com/

 We have some great speakers lined up already, and are looking for more.
 See the Call For Participation on the website for details. Talk proposals
 are due Monday, May 26.

 The day after the conference, Hack@UChicago will host a free Julia Hack
 Day at the University of Chicago's Hyde Park campus. You'll need to
 register for this event separately (link on website).

 Sponsorship opportunities are available, which will help us keep the
 ticket prices nice and cheap. If your organization might be interested in
 being a JuliaCon sponsor, please contact me directly.

 Mark your calendar, and get pumped! This will be a great event. More
 information will be posted on the website as the conference approaches.

 See you in June!

 Evan



 1. Full committee:

 Douglas Bates, Wisconsin-Madison
 Jeff Bezanson, MIT
 Jonah Bloch-Johnson, UChicago
 Jiahao Chen, MIT
 Alan Edelman, MIT
 Garrett Smith, CloudBees
 Jeff Hammond, Argonne
 Tim Holy, WUSTL
 Stefan Karpinski, MIT
 Evan Miller, Wizard
 Hunter Owens, UChicago
 James Porter, UChicago
 Arch Robison, Intel
 Viral B Shah, MIT




-- 
Evan Miller
http://www.evanmiller.org/


Re: [julia-users] Re: 1st JuliaConference: June 26th-28th, Chicago

2014-04-09 Thread Evan Miller
We haven't made a decision about a block of hotel rooms, but the venue will
be the University of Chicago's Gleacher Center downtown:

https://www.google.com/maps/place/University+of+Chicago:+Gleacher+Center/@41.889666,-87.66,16z/data=!4m2!3m1!1s0x880e26623550ffd7:0x2de5428703b98337


On Wed, Apr 9, 2014 at 4:00 PM, Tracy Wadleigh tracy.wadle...@gmail.comwrote:

 Would it be possible to provide a few more specifics at this point so that
 folks can start to consider travel and accommodations? For instance, has an
 address for the meeting location been decided upon? Will a block of hotel
 rooms be reserved? ...





-- 
Evan Miller
http://www.evanmiller.org/