Re: [julia-users] Re: In regular expression "replace", how to use the "match" as parameters to a Function?

2015-11-12 Thread JobJob
I like that idea, but it's not really available AFAICT.

The function eachmatch(::Regex, ::String) gives you an iterator over the 
match objects.

In any case, I had a little play with this for fun :) - so here's one way 
to do it:
(n.b. the function arguments don't really need to be typed, I just do it to 
make the code clearer to read):

replacerange(s::AbstractString, replacement::AbstractString, 
range::UnitRange{Int64}) = 
  s[1:range.start-1]*replacement*s[range.stop+1:end]

replacematches(s::AbstractString, r::Regex, f::Function) = 
foldl((_s,m) -> begin
offsetd = length(_s) - length(s) #needed because previous replaces 
may change the length of _s
repl_range = (offsetd + m.offset):(offsetd + m.offset + 
length(m.match)-1)
replacerange(_s, f(m), repl_range)
end, s, eachmatch(r,s))

y = "time format 02:45pm, 14:20, 03:45am"
replacematches(y, r"([01]\d)(:[0-6]\d)(am|pm)"i, 
  x->lowercase(x.captures[3])=="am"?x.match[1:end-2]:string(parse(Int, 
x.captures[1])+12, x.captures[2]))

"time format 14:45, 14:20, 03:45"





Re: [julia-users] Colormaps composing images

2015-11-12 Thread Tobias Knopp
Thanks Tim, I tried to look into the code of Overlay but it wasn't to clear 
to me. In particular I am missing where the RGB(A) data is combined. Is it 
really as simple as adding the individual RGB values and preventing 
overflow by clamp?
Or is there some infrastructure for color mixing in Colors.jl

I further looked for functions for gray value mapping (Contrast/Brightness) 
in Colors.jl but could not find anything. This is of course not complicated 
to code but I don't want to miss an existing solution.

Tobi

Am Donnerstag, 12. November 2015 16:42:00 UTC+1 schrieb Tim Holy:
>
> Probably the easiest thing would be to just extend the code in Images and 
> submit a PR (the code is not very complicated). 
>
> However, you can do very fancy things with MapInfo objects. This is 
> untested, 
> but it should be close: 
>
> immutable TwoColormap <: MapInfo 
> colormap1 
> colormap2 
> end 
>
> function map!(dest, mapi::TwoColormap, 
> src::Tuple{AbstractArray,AbstractArray}) 
> img1, img2 = src 
> for I in eachindex(dest) 
> dest[I] = clamp(RGBmapi.colormap1[img1[I]] + 
> mapi.colormap2[img2[I]]) 
> end 
> dest 
> end 
>
> --Tim 
>
> On Thursday, November 12, 2015 07:23:07 AM Tobias Knopp wrote: 
> > Hi, 
> > 
> > I am using the OverlayImage type from the Images.jl package to overlay 
> two 
> > different grayscale images (tomographic data). 
> > If I understand it correctly OverlayImage is restricted to colormaps 
> that 
> > go from black to a certain RGB value. Has anybody an idea how this could 
> be 
> > extended to Colormaps provided by Colors.jl? 
> > 
> > So my need is: 
> > Input: two 3D datasets (FloatingPoint) + two Colormaps + WindowWidth 
> > WindowLevel for each 
> > Output: Combined 3D dataset as RGBA values. 
> > 
> > Thanks 
> > 
> > Tobias 
>
>

Re: [julia-users] Re: In regular expression "replace", how to use the "match" as parameters to a Function?

2015-11-12 Thread Yunde Zhong
Thanks for your help. It works very well. It also provides a very good 
example for me to learn the "foldl" function. 

Inspired by your reply and the implementation of "replace" function defined 
in "...\share\julia\base\strings\util.jl", I defined a similar version for 
my research, which is copied below for your reference.

function replacematches(f::Function, s::AbstractString, r::Regex)
  out = IOBuffer();
  pos = foldl((_pos,m) -> begin
  write(out, SubString(s, _pos, m.offset-1)) ; 
  ns::String = f(m);
  write(out, ns);
  _pos = m.offset + length(m.match);
end, 1, eachmatch(r,s))
  write(out, SubString(s, pos));
  takebuf_string(out);
end

y = "time format 02:45pm, 14:20, 03:45am. The End."

replacematches(y, r"([01]\d)(:[0-6]\d)(am|pm)"i) do x 
  lowercase(x.captures[3])=="am"?x.match[1:end-2]:string(parse(Int, 
x.captures[1])+12, x.captures[2])
end


Thanks 

Yunde 


On Thursday, November 12, 2015 at 2:04:58 PM UTC-6, JobJob wrote:
>
> I like that idea, but it's not really available AFAICT.
>
> The function eachmatch(::Regex, ::String) gives you an iterator over the 
> match objects.
>
> In any case, I had a little play with this for fun :) - so here's one way 
> to do it:
> (n.b. the function arguments don't really need to be typed, I just do it 
> to make the code clearer to read):
>
> replacerange(s::AbstractString, replacement::AbstractString, 
> range::UnitRange{Int64}) = 
>   s[1:range.start-1]*replacement*s[range.stop+1:end]
>
> replacematches(s::AbstractString, r::Regex, f::Function) = 
> foldl((_s,m) -> begin
> offsetd = length(_s) - length(s) #needed because previous replaces 
> may change the length of _s
> repl_range = (offsetd + m.offset):(offsetd + m.offset + 
> length(m.match)-1)
> replacerange(_s, f(m), repl_range)
> end, s, eachmatch(r,s))
>
> y = "time format 02:45pm, 14:20, 03:45am"
> replacematches(y, r"([01]\d)(:[0-6]\d)(am|pm)"i, 
>   x->lowercase(x.captures[3])=="am"?x.match[1:end-2]:string(parse(Int, 
> x.captures[1])+12, x.captures[2]))
>
> "time format 14:45, 14:20, 03:45"
>
>
>
>

Re: [julia-users] Why does Tk.jl have pre-compile code and set it to "false"?

2015-11-12 Thread milktrader
Yeah, the message isn't too big, so here it is ...
julia> using Tk
INFO: Precompiling module Tk...
fatal: error thrown and no exception handler available.
ErrorException("Task cannot be serialized")
rec_backtrace at /Users/Administrator/.pantry/julia-0.4.0/src/task.c:644
jl_error at 
/Users/Administrator/.pantry/julia-0.4.0/julia/usr/lib/libjulia.dylib 
(unknown line)
jl_serialize_fptr at /Users/Administrator/.pantry/julia-0.4.0/src/dump.c:439
jl_serialize_value_ at 
/Users/Administrator/.pantry/julia-0.4.0/src/dump.c:738
jl_serialize_value_ at 
/Users/Administrator/.pantry/julia-0.4.0/src/dump.c:900
jl_serialize_value_ at 
/Users/Administrator/.pantry/julia-0.4.0/src/dump.c:900
jl_serialize_module at 
/Users/Administrator/.pantry/julia-0.4.0/src/dump.c:566
jl_serialize_value_ at 
/Users/Administrator/.pantry/julia-0.4.0/src/dump.c:738
jl_finalize_serializer at 
/Users/Administrator/.pantry/julia-0.4.0/src/dump.c:1673
julia_save at /Users/Administrator/.pantry/julia-0.4.0/src/init.c:629
main at /Users/Administrator/.pantry/julia-0.4.0/julia/usr/bin/julia 
(unknown line)
ERROR: Failed to precompile Tk to /Users/Administrator/.julia/lib/v0.4/Tk.ji
 in error at ./error.jl:21
 in compilecache at loading.jl:383
 in require at ./loading.jl:250



On Thursday, November 12, 2015 at 2:02:10 PM UTC-5, Tim Holy wrote:
>
> Try it and see what happens :-). 
>
> Better that Winston switch to Gtk. I have a PR open for that. 
>
> --Tim 
>
> On Thursday, November 12, 2015 10:48:42 AM milktrader wrote: 
> > This is the first line in the module definition: 
> > 
> > VERSION >= v"0.4.0-dev+6521" && __precompile__(false) 
> > 
> > Just curious what the issue here is as this prevents Winston from 
> > pre-compiling and results in long load times for Winston. 
>
>

Re: [julia-users] Colormaps composing images

2015-11-12 Thread Tim Holy
On Thursday, November 12, 2015 12:15:46 PM Tobias Knopp wrote:
> Thanks Tim, I tried to look into the code of Overlay but it wasn't to clear
> to me. In particular I am missing where the RGB(A) data is combined.

Here: 
https://github.com/timholy/Images.jl/blob/cac28026250814f6ae6594dd26e927076177db60/src/overlays.jl#L60-L67

> Is it
> really as simple as adding the individual RGB values and preventing
> overflow by clamp?

Yes.

> Or is there some infrastructure for color mixing in Colors.jl

There is, but it's considerably slower. See the ColorVectorSpace.jl README for 
discussion.

> I further looked for functions for gray value mapping (Contrast/Brightness)
> in Colors.jl but could not find anything. This is of course not complicated
> to code but I don't want to miss an existing solution.

The whole "MapInfo" structure is a very flexible and powerful. Search for it on 
this page:
http://timholy.github.io/Images.jl/function_reference.html
>From my standpoint, the best feature is that it's "lazy": you specify the 
transformation you want, but don't execute it until you need it. For people 
like me who routinely browse 1TB images but probably look at <1% of the raw 
data in any given dataset (and who also don't have 1TB worth of RAM...), this 
is quite an advantage.

In my own work, I pretty routinely design custom MapInfo types/map functions 
for visualization purposes. For example, I can color individual blobs in each 
frame of a movie with something along the lines of

immutable ColorizeBlobs
blobpixels::Vector   # of length nblobs
blobcolors::Vector{RGB{U8}}  # color assigned to each blob
end

and passing that to ImageView using the "scalei" keyword argument (a legacy of 
the days when this was called ScaleInfo rather than MapInfo). It's a nice way 
of getting custom visualization while leaving all the stupid zoom & navigation 
functionality up to ImageView.

--Tim

> 
> Tobi
> 
> Am Donnerstag, 12. November 2015 16:42:00 UTC+1 schrieb Tim Holy:
> > Probably the easiest thing would be to just extend the code in Images and
> > submit a PR (the code is not very complicated).
> > 
> > However, you can do very fancy things with MapInfo objects. This is
> > untested,
> > but it should be close:
> > 
> > immutable TwoColormap <: MapInfo
> > 
> > colormap1
> > colormap2
> > 
> > end
> > 
> > function map!(dest, mapi::TwoColormap,
> > src::Tuple{AbstractArray,AbstractArray})
> > 
> > img1, img2 = src
> > for I in eachindex(dest)
> > 
> > dest[I] = clamp(RGBmapi.colormap1[img1[I]] +
> > 
> > mapi.colormap2[img2[I]])
> > 
> > end
> > dest
> > 
> > end
> > 
> > --Tim
> > 
> > On Thursday, November 12, 2015 07:23:07 AM Tobias Knopp wrote:
> > > Hi,
> > > 
> > > I am using the OverlayImage type from the Images.jl package to overlay
> > 
> > two
> > 
> > > different grayscale images (tomographic data).
> > > If I understand it correctly OverlayImage is restricted to colormaps
> > 
> > that
> > 
> > > go from black to a certain RGB value. Has anybody an idea how this could
> > 
> > be
> > 
> > > extended to Colormaps provided by Colors.jl?
> > > 
> > > So my need is:
> > > Input: two 3D datasets (FloatingPoint) + two Colormaps + WindowWidth
> > > WindowLevel for each
> > > Output: Combined 3D dataset as RGBA values.
> > > 
> > > Thanks
> > > 
> > > Tobias



Re: [julia-users] Moore foundation grant.

2015-11-12 Thread lewis
Fantastic.



[julia-users] Re: Adding backslashes to a string fails

2015-11-12 Thread Lionel du Peloux

Hi,

Same problem here, but a little bit different : I want to *write* a latex 
string to a .txt file, including backslashes (to make an automatic graph 
with latex labels from a .csv generated in Julia).

For instance, I want to write  "{$ \lambda $}" in a txt file. In julia I 
can escape the backslash like this "{\$ \\lambda \$}" and println("{\$ 
\\lambda \$}") gives me a nice "{$ \lambda $}" in the REPL.

However, I can't find a syntax to write a simple backslash in a text file : 
the same string used with Julia's *write* function gives me "{\$ \\lambda 
\$}" in the file.

Any advice ?

Thanks,
Lionel


Re: [julia-users] JuliaML

2015-11-12 Thread Viral Shah
Sent you the invite to JuliaML. Would be nice to start populating it with 
existing packages by moving them. 

-viral

On Thursday, November 12, 2015 at 5:00:34 AM UTC+5:30, Kenta Sato wrote:
>
> JuliaML! sounds cool!
> I can offer the JuliaML organization my random forest package (
> https://github.com/bicycle1885/RandomForests.jl).
> I will have enough time to update and maintain the package, but I'm not a 
> specialist in machine learning. So, if anyone has much better 
> implementation ideas, it may be better to create a new package from scratch.
>
> On Thursday, November 12, 2015 at 5:33:06 AM UTC+9, Stefan Karpinski wrote:
>>
>> There's not really a group, there's a GitHub organization. Organizations 
>> contain packages and have people who have various permissions with respect 
>> to those packages. If you contribute to packages that end up there, you'll 
>> have commit access to at least those packages. Anyone can watch any of the 
>> packages and see what goes on there since they're all public.
>>
>> On Wed, Nov 11, 2015 at 3:27 PM, Alireza Nejati  
>> wrote:
>>
>>> Hello,
>>>
>>> I'd like to join the JuliaML group. My github account name is anj1.
>>>
>>> Regards,
>>> Al Nejati
>>>
>>
>>

Re: [julia-users] Re: The growth of Julia userbase

2015-11-12 Thread Viral Shah


Attching the github traffic data. Doesn't have history though, but the 
numbers were bigger than what I expected when I first saw this.


Some other interesting numbers:

1. ~10,000 pageviews on the website daily

2. 1.7M "users" and 8.6M pageviews over the lifetime of julialang.org - as 
per google analytics

3. The mailing lists have ~4000 subscribers combined

4. Github page gets 74000 views every fortnight, ~10,000 uniques. ~3000 
clones every fortnight, with ~700 uniques.


Iain posted the packages data, and the github stars and watch data is 
visible to everyone. 


-viral





On Thursday, November 5, 2015 at 12:57:22 AM UTC+5:30, Patrick O'Leary 
wrote:
>
> It's not in the repo, it's a GitHub feature. But it may only be visible if 
> you have Collaborator or Owner status on the repository.
>
> On Wednesday, November 4, 2015 at 10:51:34 AM UTC-6, Ben Ward wrote:
>>
>> I don't think the /graphs folder is part of the julia repo any-more :(
>>
>> On Wed, Nov 4, 2015 at 4:48 PM, Tony Kelman  wrote:
>>
>>> There are some interesting numbers at 
>>> https://github.com/JuliaLang/julia/graphs/traffic
>>>
>>> Elliot Saba also did some scraping of the AWS download logs for binaries 
>>> and shared the aggregate numbers (broken down by platform) privately with a 
>>> few people, it may be worth sharing those publicly.
>>>
>>>
>>> On Wednesday, November 4, 2015 at 8:26:19 AM UTC-8, Ben Ward wrote:

 Hi all,

 I was wondering are there any metrics or stats available that show how 
 the user-base of Julia has grown over the last few years, and what it's 
 size is now?

 Many Thanks,
 Ben W.

>>>
>>

[julia-users] Re: Google releases TensorFlow as open source

2015-11-12 Thread Gunnar Farnebäck
Den torsdag 12 november 2015 kl. 06:36:28 UTC+1 skrev Alireza Nejati
>
> Anyway, the problem I'm facing right now is that even though TensorFlow's 
> python interface works fine, I can't get TensorFlow's C library to build! 
> Has anyone else had any luck with this? I've had to update java AND gcc 
> just to make some progress in building (they use c++11 features, don't 
> ask). Plus I had to install google's own bizarre and buggy build manager 
> (bazel). TensorFlow.jl would be kind of pointless if everyone faced the 
> same build issues...
>

I managed to build from source on an Ubuntu machine at work, following the 
instructions at 
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md.
 
The most difficult part was getting the Python package installation 
dependencies in working order, which was not covered by the instructions. 
(The low mark being "pip install --no-use-wheel --upgrade distribute", 
which a google search suggested to get past the final hurdle and actually 
did work. Please don't emulate this in Julia.)

Whether it actually built anything useful beyond what the Python package 
needed I have no idea though. There's a forest of bazel generated 
directories that I'm not particularly tempted to try to navigate unless 
there's something specific I should look into.



[julia-users] Re: Google releases TensorFlow as open source

2015-11-12 Thread Sisyphuss
Good to know that.


On Wednesday, November 11, 2015 at 12:18:07 PM UTC+1, Viral Shah wrote:
>
> I think TensorFlow.jl is a great idea. Also their distributed computation 
> framework is also the kind that we want to have in Julia.
>
> I have created JuliaML. Send me email if you want to be part of it, and I 
> will make you an owner. Perhaps we can even move some of the JuliaStats ML 
> projects to JuliaML.
>
> -viral
>
> On Wednesday, November 11, 2015 at 11:27:21 AM UTC+5:30, Valentin Churavy 
> wrote:
>>
>> It fits in the same niche that Mocha.jl and MXNet.jl are filling right 
>> now. MXNet is a ML library that shares many of the same design ideas of 
>> TensorFlow and has great Julia support https://github.com/dmlc/MXNet.jl
>>
>>
>> On Wednesday, 11 November 2015 01:04:00 UTC+9, Randy Zwitch wrote:
>>>
>>> For me, the bigger question is how does TensorFlow fit in/fill in gaps 
>>> in currently available Julia libraries? I'm not saying that someone who is 
>>> sufficiently interested shouldn't wrap the library, but it'd be great to 
>>> identify what major gaps remain in ML for Julia and figure out if 
>>> TensorFlow is the right way to proceed. 
>>>
>>> We're certainly nowhere near the R duplication problem yet, but 
>>> certainly we're already repeating ourselves in many areas.
>>>
>>> On Monday, November 9, 2015 at 4:02:36 PM UTC-5, Phil Tomson wrote:

 Google has released it's deep learning library called TensorFlow as 
 open source code:

 https://github.com/tensorflow/tensorflow

 They include Python bindings, Any ideas about how easy/difficult it 
 would be to create Julia bindings?

 Phil

>>>

[julia-users] In regular expression "replace", how to use the "match" as parameters to a Function?

2015-11-12 Thread Yunde Zhong
Hi, All, 

I am new to Julia from Matlab. I am learning regular expression today. 

Here is an example: 

First, I'd like to high-lighten the word "goat" and "boat" in the sentence 
"a goat in a boat". 

x = "oat";
reg = Regex("(\\w+(?>$x))");

y = "a goat in a boat";
z = replace(y, reg, s"*\g<1>*")   

The result is: 
"a *goat* in a *boat*"

Then, I'd like to covert these two words into uppercase, that is, to get a 
new string of "a GOAT in a BOAT". 

I expect that Julia might have something like this:  z = replace(y, reg, 
s"$(uppercase(\g<1>))"). but it does not work. 

So, Here is my questions:  How to have a Function call as replacement in 
the regular expression? 

Thanks, 

Yunde


Re: [julia-users] linspace-like range generators and keyword ordering

2015-11-12 Thread Spencer Russell
Can you give a little more context for what you’re trying to do? I’m not clear 
on the various behaviors you want from the different `timespace` variants.

I’m actually not sure whether the order can be relied on, but I think the 
proposed API might be confusing for users of your function because most people 
assume keyword argument order doesn’t matter. My guess is that with a little 
more info on what you’re trying to accomplish we could help find a more 
idiomatic solution.

-s

> On Nov 12, 2015, at 4:19 PM, MA Laforge  wrote:
> 
> Hi users,
> 
> I want to be able to generate ranges using a syntax similar to:
> t1=timespace(tstart = 2e-9, ts=1e-9, tfund=20e-9);
> t11=timespace(fs=1/1e-9, tfund=20e-9, tstart=3e-9);
> t2=timespace(tfund=20e-9, tstart=4e-9, ts=1e-9);
> 
> Why not just use different function names?
> Simply put, I would rather not have to use long, ugly names like (timespace1, 
> timespace2, timespace_tfund, timespace_ts, timespace_fs, ...)
> 
> What is unusual/difficult about this solution:
> linspace uses "number of points" - presumably because specifying both 
> timespan, and timestep might result in non-integer number of points (poorly 
> defined).
> So...  in this case, I want timespace to use the first argument (ignoring 
> tstart) to dictate which algorithm to select.  For example: with 
> timespace(ts=1, tfund=20.5), the sampling period, ts is assumed to be exact, 
> and the fundamental period (tfund) will be adjusted to get an integer number 
> of points.
> It would be preferable to use Juila's dispatch system to dispatch on the 
> keyword names (which it does not - at least not directly).
> Since all arguments here are keywords, Julia will only support a single 
> master function "timespace(; kwargs...)".
> Attempted Solution
> I have a solution, but it depends on keyword ordering... and I don't know if 
> this is a dangerous thing to do: I believe keyword ordering is *not* 
> guaranteed.
> 
> Anyways, here is the solution...
> #Dispatchable keyword type (make name short - expect heavy use)
> immutable KD{Symbol}; end #Not kraft dinner
> 
> #Convert kwargs to a list of dispatchable elements:
> function dispatchable(kwargs::Vector{Any})
> result = Any[] for (k,v) in kwargs
> push!(result, KD{k}())
> push!(result, v)
> end
> return result
> end
> 
> timespace() = throw("timespace requires arguments")
> timespace(;tstart=0, kwargs...) =
> timespace(dispatchable(kwargs)..., tstart=tstart)
> 
> function timespace(::KD{:ts}, ts, ::KD{:tfund}, tfund; tstart=0)
> println("FUNCTION1 (priority on ts): ts=$ts, tfund=$tfund, 
> tstart=$tstart")
> end
> 
> #Similar to previous, but expects fs = 1/ts
> function timespace(::KD{:fs}, fs, ::KD{:tfund}, tfund; tstart=0)
> println("FUNCTION1.1 (priority on fs): fs=$fs, tfund=$tfund, 
> tstart=$tstart")
> end
> 
> function timespace(::KD{:tfund}, tfund, ::KD{:ts}, ts; tstart=0)
> println("FUNCTION2 (priority on tfund): tfund=$tfund, ts=$ts, 
> tstart=$tstart")
> end
> 
> This solution works (for the time being).  The generic timespace(;kwargs...) 
> function catches all the keyword argument, and converts the to normal 
> arguments.  After that, Julia's dispatch system finds the appropriate 
> specialization.
> 
> Problem
> The problem is that I don't know how safe it is to rely on the order of the 
> keyword arguments, as done here.
> 
> Is there maybe an alternative solution to this problem that would still keep 
> the solution/naming succinct and easy to understand?
> 
> (NOTE: this might be better suited for julia-dev, because it has to do with 
> the intended use of the keyword arguments)
> 
> I hope someone out there has an answer, or a better solution to this problem.
> 
> Regards,
> 
> MA



[julia-users] Re: haskey for Set

2015-11-12 Thread Seth
in(el, S) or  el in S.

On Thursday, November 12, 2015 at 2:36:28 PM UTC-8, Freddy Chua wrote:
>
> haskey does not work for Set ? It only works for Dict. Should it be that 
> way? How do I test whether an element is in a Set?
>


[julia-users] Re: Boost.Python-like CppWrapper package

2015-11-12 Thread Steven G. Johnson
The CppWrapper (and Boost.Python) approach is basically to do the hard work 
of the interfacing on the C++ side, so that Julia only has to work with 
ordinary C types and function pointers.See also SWIG, which generates C 
shims and other glue for C++ code.   It's the traditional approach for 
calling C++ code from other languages, because C++'s design makes it very 
difficult to call directly.

As I understand it, Cxx.jl is different, and is pretty unique among dynamic 
languages.  It allows you to call *unmodified* C++ libraries directly using *no 
C/C++ glue*, with all the work being done on the Julia side, including 
instantiating C++ templates, classes, etcetera.  The key is Julia 0.4's 
staged functions, which allow code generation based on inferred types 
(necessary to know which C++ function to invoke) combined with Clang to 
decipher the C++ ABI.

The only drawback with Cxx.jl is that it requires a custom build of Julia 
to use a bleeding-edge version of LLVM, and hence it isn't for the 
faint-hearted at the moment.


[julia-users] linspace-like range generators and keyword ordering

2015-11-12 Thread MA Laforge
Hi users,

I want to be able to generate ranges using a syntax similar to:
t1=timespace(tstart = 2e-9, ts=1e-9, tfund=20e-9);
t11=timespace(fs=1/1e-9, tfund=20e-9, tstart=3e-9);
t2=timespace(tfund=20e-9, tstart=4e-9, ts=1e-9);


*Why not just use different function names?*Simply put, I would rather not 
have to use long, ugly names like (timespace1, timespace2, timespace_tfund, 
timespace_ts, timespace_fs, ...)

*What is unusual/difficult about this solution:*

   - linspace uses "number of points" - presumably because specifying both 
   timespan, and timestep might result in non-integer number of points (poorly 
   defined).
   - So...  in this case, I want *timespace* to use the first argument 
  (ignoring tstart) to dictate which algorithm to select.  For example: 
with 
  timespace(ts=1, tfund=20.5), the sampling period, ts is assumed to be 
  exact, and the fundamental period (tfund) will be adjusted to get an 
  integer number of points.
  - It would be preferable to use Juila's dispatch system to dispatch 
   on the keyword names (which it does not - at least not directly).
  - Since *all *arguments here are keywords, Julia will only support a 
  single master function "timespace(; kwargs...)".
   
*Attempted Solution*
I have a solution, but it depends on keyword ordering... and I don't know 
if this is a dangerous thing to do: I believe keyword ordering is *not* 
guaranteed.

Anyways, here is the solution...
#Dispatchable keyword type (make name short - expect heavy use)
immutable KD{Symbol}; end #Not kraft dinner

#Convert kwargs to a list of dispatchable elements:
function dispatchable(kwargs::Vector{Any})
result = Any[] for (k,v) in kwargs
push!(result, KD{k}())
push!(result, v)
end
return result
end

timespace() = throw("timespace requires arguments")
timespace(;tstart=0, kwargs...) =
timespace(dispatchable(kwargs)..., tstart=tstart)

function timespace(::KD{:ts}, ts, ::KD{:tfund}, tfund; tstart=0)
println("FUNCTION1 (priority on ts): ts=$ts, tfund=$tfund, 
tstart=$tstart")
end

#Similar to previous, but expects fs = 1/ts
function timespace(::KD{:fs}, fs, ::KD{:tfund}, tfund; tstart=0)
println("FUNCTION1.1 (priority on fs): fs=$fs, tfund=$tfund, 
tstart=$tstart")
end

function timespace(::KD{:tfund}, tfund, ::KD{:ts}, ts; tstart=0)
println("FUNCTION2 (priority on tfund): tfund=$tfund, ts=$ts, 
tstart=$tstart")
end

This solution works (for the time being).  The generic 
timespace(;kwargs...) function catches all the keyword argument, and 
converts the to normal arguments.  After that, Julia's dispatch system 
finds the appropriate specialization.

*Problem*
The problem is that I don't know how safe it is to rely on the order of the 
keyword arguments, as done here.

Is there maybe an alternative solution to this problem that would still 
keep the solution/naming succinct and easy to understand?

(NOTE: this might be better suited for julia-dev, because it has to do with 
the intended use of the keyword arguments)

I hope someone out there has an answer, or a better solution to this 
problem.

Regards,

MA


Re: [julia-users] Re: haskey for Set

2015-11-12 Thread Freddy Chua
that works, thank you.

Freddy Chua


On Thu, Nov 12, 2015 at 3:06 PM, Seth  wrote:

> in(el, S) or  el in S.
>
>
> On Thursday, November 12, 2015 at 2:36:28 PM UTC-8, Freddy Chua wrote:
>>
>> haskey does not work for Set ? It only works for Dict. Should it be that
>> way? How do I test whether an element is in a Set?
>>
>


[julia-users] printing full DataFrame preserving HTML representation

2015-11-12 Thread Robert Smith
How can I print the full DataFrame preserving its HTML representation? 
Currently:

using DataFrames
df = DataFrame(x=1:500, y=1:500)
500x2 DataFrames.DataFrame
| Row | x   | y   |
|-|-|-|
| 1   | 1   | 1   |
| 2   | 2   | 2   |
| 3   | 3   | 3   |
| 4   | 4   | 4   |
| 5   | 5   | 5   |
| 6   | 6   | 6   |
| 7   | 7   | 7   |
| 8   | 8   | 8   |
| 9   | 9   | 9   |
| 10  | 10  | 10  |
| 11  | 11  | 11  |
| 12  | 12  | 12  |
⋮
| 488 | 488 | 488 |
| 489 | 489 | 489 |
| 490 | 490 | 490 |
| 491 | 491 | 491 |
| 492 | 492 | 492 |
| 493 | 493 | 493 |
| 494 | 494 | 494 |
| 495 | 495 | 495 |
| 496 | 496 | 496 |
| 497 | 497 | 497 |
| 498 | 498 | 498 |
| 499 | 499 | 499 |
| 500 | 500 | 500 |

As you see, there is this kind of summary. showall(df) prints the whole 
dataframe but unfortunately uses the text/plain representation.

Even subsetting shares the same behavior of reducing the DataFrame. In 
other words, what is the equivalent of pandas.set_option('display.max_rows', 
500) in Julia?

Thanks


[julia-users] haskey for Set

2015-11-12 Thread Freddy Chua
haskey does not work for Set ? It only works for Dict. Should it be that 
way? How do I test whether an element is in a Set?


[julia-users] Boost.Python-like CppWrapper package

2015-11-12 Thread Bart Janssens
Hello,

I've recently started using Julia, thanks to the great intro at the Julia 
meetup in Gent two months ago. To really start using it for my work, I 
would need to access some C++ software, most notably Trilinos and our own 
CFD code. We currently use Boost.Python to interface with Python, so I 
thought it would be nice to have a Julia package that facilitates writing 
wrappers in a similar fashion.

You can see my first attempt here:
https://github.com/barche/CppWrapper

Any thoughts/comments are welcome. While we need this package anyway to 
interface with our own code, I'd like to know if there is any interest in 
maintaining it as a clean, separate Julia package?

Cheers,

Bart


Re: [julia-users] Disable ESS-mode in emacs

2015-11-12 Thread Ahmadou Dicko
If not already done why don't you ask on the ESS mailing 
list: https://stat.ethz.ch/mailman/listinfo/ess-help
I'm sure they can help you with this issue, it can also help to fill an 
issue on the Github repo: https://github.com/emacs-ess/ESS

Hope it helps.



On Thursday, November 12, 2015 at 11:37:30 AM UTC, Asbjørn Nilsen Riseth 
wrote:
>
> Thanks Ista,
>
> I've tried this, but it doesent work. Seems like ESS has "hijacked" 
> julia-mode.
>
> My issues with ESS is that it doesn't behave like the julia-mode I'm used 
> to from my own computer.
> - It does not replace latex expressions like \alpha with the unicode 
> character. 
> - There is also some weird tab-indentation behaviour that does not make 
> sense.
>
> Are these supposed to be the same? If so, I might have to dig around to 
> see what the problem is with my ESS configuration.
>
>
> On Monday, 2 November 2015 19:26:38 UTC, Ista Zahn wrote:
>>
>> Probably 
>>
>>  (add-to-list 'auto-mode-alist '("\\.jl\\'" . julia-mode)) 
>>
>> should do it, though I'm not sure what the advantage would be. 
>>
>> Best, 
>> Ista 
>>
>> On Mon, Nov 2, 2015 at 10:05 AM, Asbjørn Nilsen Riseth 
>>  wrote: 
>> > Hi emacs users, 
>> > 
>> > is there a way to disable ESS[Julia] in emacs? I'd like to use 
>> julia-mode 
>> > without invoking ESS. 
>> > 
>> > ESS is installed globally on my system, but I don't have root rights to 
>> > uninstall it. 
>> > 
>> > 
>> > 
>>
>

[julia-users] Images package not downloading

2015-11-12 Thread Humayun Ehtisham
Hi I am new to julia and juno, I don't know why It is giving an error, i 
was just following the tutorial.jl
Also I want to mention that i am working on Linux/Ubuntu.
any help will be appreciated.





Re: [julia-users] Disable ESS-mode in emacs

2015-11-12 Thread Asbjørn Nilsen Riseth
Thanks Ista,

I've tried this, but it doesent work. Seems like ESS has "hijacked" 
julia-mode.

My issues with ESS is that it doesn't behave like the julia-mode I'm used 
to from my own computer.
- It does not replace latex expressions like \alpha with the unicode 
character. 
- There is also some weird tab-indentation behaviour that does not make 
sense.

Are these supposed to be the same? If so, I might have to dig around to see 
what the problem is with my ESS configuration.


On Monday, 2 November 2015 19:26:38 UTC, Ista Zahn wrote:
>
> Probably 
>
>  (add-to-list 'auto-mode-alist '("\\.jl\\'" . julia-mode)) 
>
> should do it, though I'm not sure what the advantage would be. 
>
> Best, 
> Ista 
>
> On Mon, Nov 2, 2015 at 10:05 AM, Asbjørn Nilsen Riseth 
>  wrote: 
> > Hi emacs users, 
> > 
> > is there a way to disable ESS[Julia] in emacs? I'd like to use 
> julia-mode 
> > without invoking ESS. 
> > 
> > ESS is installed globally on my system, but I don't have root rights to 
> > uninstall it. 
> > 
> > 
> > 
>


[julia-users] macro to exclude code depending on VERSION

2015-11-12 Thread andrew cooke

when you're writing code that uses macros, supporting different versions of 
julia seems to be more complex than normal.  in particular, things like:

if VERSION > XX
# code with macros here
end

don't work as expected, because macro expansion occurs before runtime 
evaluation.  so the macros are expenaded whatever version.

given that, i have found this simple macro to be useful;

macro cond(test, block)
if eval(test)
block
end
end

@cond VERSION >= v"0.4" begin
 # code with macros here
end

anyway, my questions are: (1) is the above sensible and (2) does this 
already exist?

thanks,
andrew



Re: [julia-users] macro to exclude code depending on VERSION

2015-11-12 Thread andrew cooke

ah, great.  i won't make a new package then.  thanks.

On Thursday, 12 November 2015 09:30:21 UTC-3, Yichao Yu wrote:
>
> https://github.com/JuliaLang/julia/issues/7449 
> https://github.com/JuliaLang/Compat.jl/pull/131 
> https://github.com/JuliaLang/julia/issues/5892 
>
> On Thu, Nov 12, 2015 at 7:23 AM, andrew cooke  > wrote: 
> > 
> > when you're writing code that uses macros, supporting different versions 
> of 
> > julia seems to be more complex than normal.  in particular, things like: 
> > 
> > if VERSION > XX 
> > # code with macros here 
> > end 
> > 
> > don't work as expected, because macro expansion occurs before runtime 
> > evaluation.  so the macros are expenaded whatever version. 
> > 
> > given that, i have found this simple macro to be useful; 
> > 
> > macro cond(test, block) 
> > if eval(test) 
> > block 
> > end 
> > end 
> > 
> > @cond VERSION >= v"0.4" begin 
> >  # code with macros here 
> > end 
> > 
> > anyway, my questions are: (1) is the above sensible and (2) does this 
> > already exist? 
> > 
> > thanks, 
> > andrew 
> > 
>


Re: [julia-users] macro to exclude code depending on VERSION

2015-11-12 Thread Yichao Yu
https://github.com/JuliaLang/julia/issues/7449
https://github.com/JuliaLang/Compat.jl/pull/131
https://github.com/JuliaLang/julia/issues/5892

On Thu, Nov 12, 2015 at 7:23 AM, andrew cooke  wrote:
>
> when you're writing code that uses macros, supporting different versions of
> julia seems to be more complex than normal.  in particular, things like:
>
> if VERSION > XX
> # code with macros here
> end
>
> don't work as expected, because macro expansion occurs before runtime
> evaluation.  so the macros are expenaded whatever version.
>
> given that, i have found this simple macro to be useful;
>
> macro cond(test, block)
> if eval(test)
> block
> end
> end
>
> @cond VERSION >= v"0.4" begin
>  # code with macros here
> end
>
> anyway, my questions are: (1) is the above sensible and (2) does this
> already exist?
>
> thanks,
> andrew
>


[julia-users] Re: did something change already with arrays in 0.5?

2015-11-12 Thread Seth
Following up, the easiest way I've found to fix things so they're 
cross-version is to change my test from

foo = [1 2 3 4 5]
@test [1, :] == [1 2 3 4 5]

to 

foo = [1 2 3 4 5]
@test [1, :][:] == [1, 2, 3, 4, 5]   # note the trailing [:]


This works on both 0.4 and 0.5.


On Wednesday, November 11, 2015 at 9:31:28 PM UTC-8, Tony Kelman wrote:
>
> We could possibly start adding feature flags for this kind of change 
> that's only in semantics and not syntax. Maybe better to put that kind of 
> flag in Compat.jl by way of a dummy indexing test rather than in Base?
>
>
> On Wednesday, November 11, 2015 at 8:50:17 PM UTC-8, Seth wrote:
>>
>> Thanks, Tony. It's in tests, so I guess I can make it version-dependent. 
>> Is there a better way to do it? I had version conditionals throughout the 
>> code during the 0.3 - 0.4 cycle, and it was less than ideal. I'd like to 
>> avoid that again if at all possible.
>>
>>
>> On Wednesday, November 11, 2015 at 8:43:02 PM UTC-8, Tony Kelman wrote:
>>>
>>> Yes. https://github.com/JuliaLang/julia/pull/13612
>>> It's in NEWS.md.
>>>
>>> Make your code version-dependent if it can't handle the new behavior.
>>>
>>>
>>> On Wednesday, November 11, 2015 at 8:19:32 PM UTC-8, Seth wrote:

 LightGraphs started failing 0.5 tests, while -release is fine:

 https://travis-ci.org/JuliaGraphs/LightGraphs.jl/jobs/90631116

 apparently foo[3,:] now returns [x,y,z] instead of [x y z].

 1) could someone confirm this new behavior?
 2) what's the best way of handling this besides disabling tests on 0.5?



[julia-users] Re: did something change already with arrays in 0.5?

2015-11-12 Thread Sheehan Olver
Or I think you can do 

foo[1:1,:] == [1 2 3 4 5]

On Friday, November 13, 2015 at 1:39:35 PM UTC+11, Seth wrote:
>
> Following up, the easiest way I've found to fix things so they're 
> cross-version is to change my test from
>
> foo = [1 2 3 4 5]
> @test [1, :] == [1 2 3 4 5]
>
> to 
>
> foo = [1 2 3 4 5]
> @test [1, :][:] == [1, 2, 3, 4, 5]   # note the trailing [:]
>
>
> This works on both 0.4 and 0.5.
>
>
> On Wednesday, November 11, 2015 at 9:31:28 PM UTC-8, Tony Kelman wrote:
>>
>> We could possibly start adding feature flags for this kind of change 
>> that's only in semantics and not syntax. Maybe better to put that kind of 
>> flag in Compat.jl by way of a dummy indexing test rather than in Base?
>>
>>
>> On Wednesday, November 11, 2015 at 8:50:17 PM UTC-8, Seth wrote:
>>>
>>> Thanks, Tony. It's in tests, so I guess I can make it version-dependent. 
>>> Is there a better way to do it? I had version conditionals throughout the 
>>> code during the 0.3 - 0.4 cycle, and it was less than ideal. I'd like to 
>>> avoid that again if at all possible.
>>>
>>>
>>> On Wednesday, November 11, 2015 at 8:43:02 PM UTC-8, Tony Kelman wrote:

 Yes. https://github.com/JuliaLang/julia/pull/13612
 It's in NEWS.md.

 Make your code version-dependent if it can't handle the new behavior.


 On Wednesday, November 11, 2015 at 8:19:32 PM UTC-8, Seth wrote:
>
> LightGraphs started failing 0.5 tests, while -release is fine:
>
> https://travis-ci.org/JuliaGraphs/LightGraphs.jl/jobs/90631116
>
> apparently foo[3,:] now returns [x,y,z] instead of [x y z].
>
> 1) could someone confirm this new behavior?
> 2) what's the best way of handling this besides disabling tests on 0.5?
>
>

Re: [julia-users] macro to exclude code depending on VERSION

2015-11-12 Thread Seth
...and I just discovered Requires.jl. Fantastic stuff.

On Thursday, November 12, 2015 at 8:55:23 PM UTC-8, Seth wrote:
>
> This could be useful to me :)
>
> I have a couple of functions that require JuMP but I don't want to add 
> JuMP to my REQUIRE file. My usual tactic of checking isdefined(:JuMP) won't 
> work because JuMP uses macros that are evaluated prior to runtime. However, 
> I was unable to make the following code work:
>
> @cond (isdefined(:JuMP)) begin
> function something_that_requires_jump(a...)
> ...
> end # function
> end # macro
>
> Is there an accepted way to do conditional includes of packages that 
> contain macros?
>
> On Thursday, November 12, 2015 at 4:37:43 AM UTC-8, andrew cooke wrote:
>>
>>
>> ah, great.  i won't make a new package then.  thanks.
>>
>> On Thursday, 12 November 2015 09:30:21 UTC-3, Yichao Yu wrote:
>>>
>>> https://github.com/JuliaLang/julia/issues/7449 
>>> https://github.com/JuliaLang/Compat.jl/pull/131 
>>> https://github.com/JuliaLang/julia/issues/5892 
>>>
>>> On Thu, Nov 12, 2015 at 7:23 AM, andrew cooke  
>>> wrote: 
>>> > 
>>> > when you're writing code that uses macros, supporting different 
>>> versions of 
>>> > julia seems to be more complex than normal.  in particular, things 
>>> like: 
>>> > 
>>> > if VERSION > XX 
>>> > # code with macros here 
>>> > end 
>>> > 
>>> > don't work as expected, because macro expansion occurs before runtime 
>>> > evaluation.  so the macros are expenaded whatever version. 
>>> > 
>>> > given that, i have found this simple macro to be useful; 
>>> > 
>>> > macro cond(test, block) 
>>> > if eval(test) 
>>> > block 
>>> > end 
>>> > end 
>>> > 
>>> > @cond VERSION >= v"0.4" begin 
>>> >  # code with macros here 
>>> > end 
>>> > 
>>> > anyway, my questions are: (1) is the above sensible and (2) does this 
>>> > already exist? 
>>> > 
>>> > thanks, 
>>> > andrew 
>>> > 
>>>
>>

Re: [julia-users] JuliaML

2015-11-12 Thread Kenta Sato
Thank you, Viral! I've joined the group and will move my package this 
weekend.


On Thursday, November 12, 2015 at 6:28:01 PM UTC+9, Viral Shah wrote:
>
> Sent you the invite to JuliaML. Would be nice to start populating it with 
> existing packages by moving them. 
>
> -viral
>
> On Thursday, November 12, 2015 at 5:00:34 AM UTC+5:30, Kenta Sato wrote:
>>
>> JuliaML! sounds cool!
>> I can offer the JuliaML organization my random forest package (
>> https://github.com/bicycle1885/RandomForests.jl).
>> I will have enough time to update and maintain the package, but I'm not a 
>> specialist in machine learning. So, if anyone has much better 
>> implementation ideas, it may be better to create a new package from scratch.
>>
>> On Thursday, November 12, 2015 at 5:33:06 AM UTC+9, Stefan Karpinski 
>> wrote:
>>>
>>> There's not really a group, there's a GitHub organization. Organizations 
>>> contain packages and have people who have various permissions with respect 
>>> to those packages. If you contribute to packages that end up there, you'll 
>>> have commit access to at least those packages. Anyone can watch any of the 
>>> packages and see what goes on there since they're all public.
>>>
>>> On Wed, Nov 11, 2015 at 3:27 PM, Alireza Nejati  
>>> wrote:
>>>
 Hello,

 I'd like to join the JuliaML group. My github account name is anj1.

 Regards,
 Al Nejati

>>>
>>>

[julia-users] Re: Chi square test in Julia?

2015-11-12 Thread Joshua Duncan
Thanks Benjamin! Creating a matrix out of my two arrays works just fine. 
 I'll go that way for now.

Josh

On Tuesday, November 10, 2015 at 4:32:27 PM UTC-6, Benjamin Deonovic wrote:
>
> Looks like the state of Julia's "Factors" (PooledDataArrays) is still 
> quite a fast evolving monster. Because of this there hasn't been a proper 
> implementation of R's "table" function. For now, if you want to run 
> ChisqTest in Julia on two vectors do it on the matrix you would obtain in R 
> by running table(x,y). 
>


[julia-users] Re: In regular expression "replace", how to use the "match" as parameters to a Function?

2015-11-12 Thread JobJob
Does this do what you need?

julia> replace(y, reg, uppercase)

"a GOAT in a BOAT"




[julia-users] Re: In regular expression "replace", how to use the "match" as parameters to a Function?

2015-11-12 Thread JobJob
Forgot to say: welcome to Julia :)

btw you can see the different methods for a function with e.g.:
julia> methods(replace)

also to see available documentation for a function type ?, e.g.
?replace




[julia-users] Community detection in julia

2015-11-12 Thread Jihui Han
Community detection in networks in pure Julia. Welcome to use and report 
bugs or even to request a feature is extremely valuable in helping me 
prioritize what to work on.


Re: [julia-users] macro to exclude code depending on VERSION

2015-11-12 Thread Seth
This could be useful to me :)

I have a couple of functions that require JuMP but I don't want to add JuMP 
to my REQUIRE file. My usual tactic of checking isdefined(:JuMP) won't work 
because JuMP uses macros that are evaluated prior to runtime. However, I 
was unable to make the following code work:

@cond (isdefined(:JuMP)) begin
function something_that_requires_jump(a...)
...
end # function
end # macro

Is there an accepted way to do conditional includes of packages that 
contain macros?

On Thursday, November 12, 2015 at 4:37:43 AM UTC-8, andrew cooke wrote:
>
>
> ah, great.  i won't make a new package then.  thanks.
>
> On Thursday, 12 November 2015 09:30:21 UTC-3, Yichao Yu wrote:
>>
>> https://github.com/JuliaLang/julia/issues/7449 
>> https://github.com/JuliaLang/Compat.jl/pull/131 
>> https://github.com/JuliaLang/julia/issues/5892 
>>
>> On Thu, Nov 12, 2015 at 7:23 AM, andrew cooke  wrote: 
>> > 
>> > when you're writing code that uses macros, supporting different 
>> versions of 
>> > julia seems to be more complex than normal.  in particular, things 
>> like: 
>> > 
>> > if VERSION > XX 
>> > # code with macros here 
>> > end 
>> > 
>> > don't work as expected, because macro expansion occurs before runtime 
>> > evaluation.  so the macros are expenaded whatever version. 
>> > 
>> > given that, i have found this simple macro to be useful; 
>> > 
>> > macro cond(test, block) 
>> > if eval(test) 
>> > block 
>> > end 
>> > end 
>> > 
>> > @cond VERSION >= v"0.4" begin 
>> >  # code with macros here 
>> > end 
>> > 
>> > anyway, my questions are: (1) is the above sensible and (2) does this 
>> > already exist? 
>> > 
>> > thanks, 
>> > andrew 
>> > 
>>
>

Re: [julia-users] Re: haskey for Set

2015-11-12 Thread Seth
Also note the equivalent unicode methods:

∈(item,collection) -> Bool
∋(collection,item) -> Bool
∉(item,collection) -> Bool
∌(collection,item) -> Bool

All(?) of which can also be infixed.

On Thursday, November 12, 2015 at 4:42:21 PM UTC-8, Freddy Chua wrote:
>
> that works, thank you.
>
> Freddy Chua
>
>
> On Thu, Nov 12, 2015 at 3:06 PM, Seth  > wrote:
>
>> in(el, S) or  el in S.
>>
>>
>> On Thursday, November 12, 2015 at 2:36:28 PM UTC-8, Freddy Chua wrote:
>>>
>>> haskey does not work for Set ? It only works for Dict. Should it be that 
>>> way? How do I test whether an element is in a Set?
>>>
>>
>

[julia-users] Re: Community detection in julia

2015-11-12 Thread Jihui Han
Forget the link, https://github.com/afternone/CommunityDetection.jl

在 2015年11月13日星期五 UTC+8上午10:45:55,Jihui Han写道:
>
> Community detection in networks in pure Julia. Welcome to use and report 
> bugs or even to request a feature is extremely valuable in helping me 
> prioritize what to work on.
>


Re: [julia-users] Disable ESS-mode in emacs

2015-11-12 Thread Ista Zahn
ess-julia-mode is a derived mode built on top of julia-mode, so all
the julia-mode functionality should be available. The keybindings have
changed, but you could change them back with something like

(add-hook 'ess-julia-mode-hook
  (lambda () (local-set-key (kbd "")
 'julia-latexsub-or-indent)))

Alternatively if you have no use for ESS you can just ignore the site
wide settings so that it will never be loaded. See
https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html
for instructions.

Best,
Ista

On Thu, Nov 12, 2015 at 6:37 AM, Asbjørn Nilsen Riseth
 wrote:
> Thanks Ista,
>
> I've tried this, but it doesent work. Seems like ESS has "hijacked"
> julia-mode.
>
> My issues with ESS is that it doesn't behave like the julia-mode I'm used to
> from my own computer.
> - It does not replace latex expressions like \alpha with the unicode
> character.
> - There is also some weird tab-indentation behaviour that does not make
> sense.
>
> Are these supposed to be the same? If so, I might have to dig around to see
> what the problem is with my ESS configuration.
>
>
> On Monday, 2 November 2015 19:26:38 UTC, Ista Zahn wrote:
>>
>> Probably
>>
>>  (add-to-list 'auto-mode-alist '("\\.jl\\'" . julia-mode))
>>
>> should do it, though I'm not sure what the advantage would be.
>>
>> Best,
>> Ista
>>
>> On Mon, Nov 2, 2015 at 10:05 AM, Asbjørn Nilsen Riseth
>>  wrote:
>> > Hi emacs users,
>> >
>> > is there a way to disable ESS[Julia] in emacs? I'd like to use
>> > julia-mode
>> > without invoking ESS.
>> >
>> > ESS is installed globally on my system, but I don't have root rights to
>> > uninstall it.
>> >
>> >
>> >


[julia-users] Colormaps composing images

2015-11-12 Thread Tobias Knopp
Hi,

I am using the OverlayImage type from the Images.jl package to overlay two 
different grayscale images (tomographic data).
If I understand it correctly OverlayImage is restricted to colormaps that 
go from black to a certain RGB value. Has anybody an idea how this could be 
extended to Colormaps provided by Colors.jl?

So my need is:
Input: two 3D datasets (FloatingPoint) + two Colormaps + WindowWidth 
WindowLevel for each
Output: Combined 3D dataset as RGBA values.

Thanks

Tobias


Re: [julia-users] Colormaps composing images

2015-11-12 Thread Tim Holy
Probably the easiest thing would be to just extend the code in Images and 
submit a PR (the code is not very complicated).

However, you can do very fancy things with MapInfo objects. This is untested, 
but it should be close:

immutable TwoColormap <: MapInfo
colormap1
colormap2
end

function map!(dest, mapi::TwoColormap, 
src::Tuple{AbstractArray,AbstractArray})
img1, img2 = src
for I in eachindex(dest)
dest[I] = clamp(RGBmapi.colormap1[img1[I]] + mapi.colormap2[img2[I]])
end
dest
end

--Tim

On Thursday, November 12, 2015 07:23:07 AM Tobias Knopp wrote:
> Hi,
> 
> I am using the OverlayImage type from the Images.jl package to overlay two
> different grayscale images (tomographic data).
> If I understand it correctly OverlayImage is restricted to colormaps that
> go from black to a certain RGB value. Has anybody an idea how this could be
> extended to Colormaps provided by Colors.jl?
> 
> So my need is:
> Input: two 3D datasets (FloatingPoint) + two Colormaps + WindowWidth
> WindowLevel for each
> Output: Combined 3D dataset as RGBA values.
> 
> Thanks
> 
> Tobias



Re: [julia-users] Re: Adding backslashes to a string fails

2015-11-12 Thread Stefan Karpinski
Can you provide some example code – printing to the terminal or a file
should be the same.

On Thu, Nov 12, 2015 at 3:26 AM, Lionel du Peloux  wrote:

>
> Hi,
>
> Same problem here, but a little bit different : I want to *write* a latex
> string to a .txt file, including backslashes (to make an automatic graph
> with latex labels from a .csv generated in Julia).
>
> For instance, I want to write  "{$ \lambda $}" in a txt file. In julia I
> can escape the backslash like this "{\$ \\lambda \$}" and println("{\$
> \\lambda \$}") gives me a nice "{$ \lambda $}" in the REPL.
>
> However, I can't find a syntax to write a simple backslash in a text file
> : the same string used with Julia's *write* function gives me "{\$
> \\lambda \$}" in the file.
>
> Any advice ?
>
> Thanks,
> Lionel
>


Re: [julia-users] Re: _jl_value_t setting value in C

2015-11-12 Thread Yichao Yu
On Thu, Nov 12, 2015 at 11:50 AM, Chris Cheetham
 wrote:
> Hi Yichao Yu,
>
> Thank you for the excellent reply. I have updated to 4.0 and followed your
> advice below which has resolved all of my issues.
>
> Kind regards,
> Chris
>
> Next problem:
> How are Dictionaries represtented
>

Surprise, Dict is implemented in Julia and not in C [1]. You can
access it's members just like any types in julia but I think this is
regarded as an internal implementation detail that you shouldn't rely
on.

I'm not sure how people usually do it for embedding but my guess is
that you can access a Dict by constructing an API function in julia
and pass (the cfunction() of) it to c via ccall/cglobal. (This is how
pypy embedding works AFAIK).

Something like (totally not tested!!)

```
function c_dict_getindex(pdict::Ptr{Void}, pkey::Ptr{Void})
dict = unsafe_pointer_to_objref(pdict)::Dict
key = unsafe_pointer_to_objref(pkey)
val = dict[key]
pointer_from_objref(val)
end

ccall(:register_my_dict_access_api, Void, (Ptr{Void},),
cfunction(c_dict_getindex, Ptr{Void}, Tuple{Ptr{Void},Ptr{Void}}))
```

Or if you have more specific knowedge about the types
```
function c_dict_getindex_int(pdict::Ptr{Void}, key::Int) # the ::Int
is not necessary and is only for clarity
dict = unsafe_pointer_to_objref(pdict)::Dict
val = dict[key]
pointer_from_objref(val)
end

ccall(:register_my_dict_access_api_for_int_dict, Void, (Ptr{Void},),
cfunction(c_dict_getindex_int, Ptr{Void}, Tuple{Ptr{Void},Int}))
```

(Note that Int in julia is pointer size, use `Cint` julia type for `int` in C)

[1] 
https://github.com/JuliaLang/julia/blob/53931509770e1571cc8218325629146efa9b2514/base/dict.jl#L380

>
> On Friday, November 6, 2015 at 4:34:37 PM UTC, Chris Cheetham wrote:
>>
>> Hi there,
>>
>> I am currently playing with Julia calls from C. I have made some good
>> progress insofar as calling Julia functions, boxing/unboxing etc. What I am
>> particularly interested in however is being able to return a type which
>> consists of a number of Float64s and being able to get/set their values on
>> the C side.
>>
>> For example
>>
>> type Example
>> a::Float64
>> b::Float64
>> c::Float64
>> end
>>
>>
>> Unboxing returns a copy of a value, so no means to then set it and
>> jl_get_nth_field seems to also do the same.
>>
>>
>> I am able to get a reference to the value using pointer arithmetic by
>> getting jl_value_t + 1. I'm assuming the raw jl_value_t pointer is the type
>> pointer? and offsetting by 1 is the pointer to the value?
>>
>> Accessing elements in the type seems possible by further offsetting the
>> pointer  jl_value_t + 1 + elementIndex. My question is, is this a safe
>> assumption to make? Or is there a better way to be doing this that I haven't
>> spotted yet?
>>
>> Thanks,
>> Chris
>>
>>
>>
>


Re: [julia-users] Re: In regular expression "replace", how to use the "match" as parameters to a Function?

2015-11-12 Thread Yunde Zhong
Yes, it is what I was looking for. It allows me to pass in local
variables. Thanks,
JobJob.

One more questions. This replace function allows access to each match in a
SubString format. Is there any function to allow the access to each match
in the format of RegexMatch to exposure the "captures"?

For example: I'd like to convert time format to remove "am" and "pm". Below
is one solution (to parse time string twice):

y = "time format 02:45pm, 14:20, 03:45am"
f(x) = replace(x, r"^0\d:[0-6]\d(am|pm)"i,
x->lowercase(x[end-1])=='a'?x[1:end-2]:string(parse(Int,x[1:2])+12,
x[3:end-2]));
replace(y, r"([01]\d)(:[0-6]\d)(am|pm)"i, f)
# "time format 14:45, 14:20, 03:45"

If the replace function allows to access each match in RegxMatch format,
then the solution could be something like this:

replace(y, r"([01]\d)(:[0-6]\d)(am|pm)"i,
x->x.capture[3]=="am"?x[1:end-2]:string(parse(Int, x.captures[1])+12,
x.captures[2]))

and it only needs to parse the time string once.

Thanks, again. Julia is great.

Yunde




On Thu, Nov 12, 2015 at 8:24 AM JobJob  wrote:

> Forgot to say: welcome to Julia :)
>
> btw you can see the different methods for a function with e.g.:
> julia> methods(replace)
>
> also to see available documentation for a function type ?, e.g.
> ?replace
>
>
>


[julia-users] Masters/PhD programs to continue work on Julia

2015-11-12 Thread Rohit Thankachan
Hello!

I am planning on applying to masters and/or PhD programs that start in Fall 
2016. I am a JSoC 2015 student and have been doing work related to 3D 
visualizations from Julia - ThreeJS.jl 
 and Compose3D.jl 
. I am hoping to continue 
working on these projects along with newer projects in Julia as part of a 
master's or PhD program. Does anyone know of any programs that would allow 
me to do this? Pointers would be appreciated too. :)

Regards,
Rohit


[julia-users] Re: _jl_value_t setting value in C

2015-11-12 Thread Chris Cheetham
Hi Yichao Yu,

Thank you for the excellent reply. I have updated to 4.0 and followed your 
advice below which has resolved all of my issues.

Kind regards,
Chris

Next problem:
How are Dictionaries represtented 

On Friday, November 6, 2015 at 4:34:37 PM UTC, Chris Cheetham wrote:
>
> Hi there,
>
> I am currently playing with Julia calls from C. I have made some good 
> progress insofar as calling Julia functions, boxing/unboxing etc. What I am 
> particularly interested in however is being able to return a type which 
> consists of a number of Float64s and being able to get/set their values on 
> the C side.
>
> For example
>
> type Example
> a::Float64
> b::Float64
> c::Float64
> end
>
>
> Unboxing returns a copy of a value, so no means to then set it and 
> jl_get_nth_field seems to also do the same.
>
>
> I am able to get a reference to the value using pointer arithmetic by 
> getting jl_value_t + 1. I'm assuming the raw jl_value_t pointer is the type 
> pointer? and offsetting by 1 is the pointer to the value?
>
> Accessing elements in the type seems possible by further offsetting the 
> pointer  jl_value_t + 1 + elementIndex. My question is, is this a safe 
> assumption to make? Or is there a better way to be doing this that I 
> haven't spotted yet?
>
> Thanks,
> Chris
>
>
>
>

[julia-users] Why does Tk.jl have pre-compile code and set it to "false"?

2015-11-12 Thread milktrader
This is the first line in the module definition:

VERSION >= v"0.4.0-dev+6521" && __precompile__(false)

Just curious what the issue here is as this prevents Winston from 
pre-compiling and results in long load times for Winston.


Re: [julia-users] Why does Tk.jl have pre-compile code and set it to "false"?

2015-11-12 Thread Tim Holy
Try it and see what happens :-).

Better that Winston switch to Gtk. I have a PR open for that.

--Tim

On Thursday, November 12, 2015 10:48:42 AM milktrader wrote:
> This is the first line in the module definition:
> 
> VERSION >= v"0.4.0-dev+6521" && __precompile__(false)
> 
> Just curious what the issue here is as this prevents Winston from
> pre-compiling and results in long load times for Winston.



Re: [julia-users] Disable ESS-mode in emacs

2015-11-12 Thread Asbjørn Nilsen Riseth
Ah, adding --no-site-file is what I was looking for, thanks.

Not sure what the issue with ESS is on my computer; but in any case I'm not 
using it.

On Thursday, 12 November 2015 15:05:29 UTC, Ista Zahn wrote:
>
> ess-julia-mode is a derived mode built on top of julia-mode, so all 
> the julia-mode functionality should be available. The keybindings have 
> changed, but you could change them back with something like 
>
> (add-hook 'ess-julia-mode-hook 
>   (lambda () (local-set-key (kbd "") 
>  'julia-latexsub-or-indent))) 
>
> Alternatively if you have no use for ESS you can just ignore the site 
> wide settings so that it will never be loaded. See 
> https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html 
> for instructions. 
>
> Best, 
> Ista 
>
> On Thu, Nov 12, 2015 at 6:37 AM, Asbjørn Nilsen Riseth 
>  wrote: 
> > Thanks Ista, 
> > 
> > I've tried this, but it doesent work. Seems like ESS has "hijacked" 
> > julia-mode. 
> > 
> > My issues with ESS is that it doesn't behave like the julia-mode I'm 
> used to 
> > from my own computer. 
> > - It does not replace latex expressions like \alpha with the unicode 
> > character. 
> > - There is also some weird tab-indentation behaviour that does not make 
> > sense. 
> > 
> > Are these supposed to be the same? If so, I might have to dig around to 
> see 
> > what the problem is with my ESS configuration. 
> > 
> > 
> > On Monday, 2 November 2015 19:26:38 UTC, Ista Zahn wrote: 
> >> 
> >> Probably 
> >> 
> >>  (add-to-list 'auto-mode-alist '("\\.jl\\'" . julia-mode)) 
> >> 
> >> should do it, though I'm not sure what the advantage would be. 
> >> 
> >> Best, 
> >> Ista 
> >> 
> >> On Mon, Nov 2, 2015 at 10:05 AM, Asbjørn Nilsen Riseth 
> >>  wrote: 
> >> > Hi emacs users, 
> >> > 
> >> > is there a way to disable ESS[Julia] in emacs? I'd like to use 
> >> > julia-mode 
> >> > without invoking ESS. 
> >> > 
> >> > ESS is installed globally on my system, but I don't have root rights 
> to 
> >> > uninstall it. 
> >> > 
> >> > 
> >> > 
>