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

2016-11-21 Thread Isaiah Norton
If breakpoints aren't working, I would suggest to your push object(s) of
interest into a global Vector{Any} and then debug with `@enter`.

On Mon, Nov 21, 2016 at 11:00 AM,  wrote:

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


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

2016-11-21 Thread Isaiah Norton
>
> Any other means without resorting to breakpoints??


Use `@enter function_to_debug( ... )` with the value of A that you are
interested in.

On Mon, Nov 21, 2016 at 6:30 AM,  wrote:

> Bump up for the following question:
>
> Suppose I have the following code where the variable A is defined multiple
> times and after each definition it is used by the same function
> function_to_debug. How can I step in function_to_debug with the first
> definition/instantiation of A?
> A = ...
> function_to_debug(A)
> ...
> ...
> A = ...
> function_to_debug(A)
>
> Seems that the only choice is to use breakpoint. Any other means without
> resorting to breakpoints??
>


Re: [julia-users] Re: Hide and disable REPL

2016-11-03 Thread Isaiah Norton
Can you explain the setup further -- Where is the REPL running? How are you
interacting with it? If I take "I want to temporarily switch the REPL off,
i.e. it should visually disappear" literally then it seems like a strange
thing to do, so I may be missing something

If you *do* want to hide the terminal window (if any) the REPL is (may be)
running in, that's going to be very hard to do generally and across
platforms (on Windows under Console you can use GetActiveWindow or
GetActiveConsole, but on real pty platforms the process doesn't necessarily
know anything about the terminal it is connected to beyond termcap and i/o).

On Thu, Nov 3, 2016 at 7:41 PM,  wrote:

> Bump, it would be great if someone could point me to some approach for
> this. We are getting an integrated terminal ready in VS Code, and this is
> the one piece missing right now.
>
> Thanks,
> David
>
>
> On Thursday, June 23, 2016 at 5:00:22 PM UTC-7, David Anthoff wrote:
>>
>> Hi,
>>
>>
>>
>> is there a way to switch off the REPL and then on again, from a task?
>>
>>
>>
>> Specifically, I want to start a julia instance and pass a script in with
>> the –L parameter that will open a socket, listen for connections and the
>> process messages from that socket. This server listening code is all
>> wrapped in @async macro calls. So when I start things this way, julia shows
>> the REPL and at the same time listens for incoming messages. I can use the
>> REPL etc. This is exactly what I want.
>>
>>
>>
>> But when I receive a message, I want to temporarily switch the REPL off,
>> i.e. it should visually disappear while I process that message, and then I
>> want to switch it back on once I’m done processing that message.
>>
>>
>>
>> Can that be done somehow?
>>
>>
>>
>> Thanks,
>>
>> David
>>
>>
>>
>> --
>>
>> David Anthoff
>>
>> University of California, Berkeley
>>
>>
>>
>> http://www.david-anthoff.com
>>
>>
>>
>


Re: [julia-users] Re: Sys.CPU_CORES

2016-11-02 Thread Isaiah Norton
Ref: https://github.com/JuliaLang/julia/issues/13901

On Wed, Nov 2, 2016 at 10:33 PM, Isaiah Norton <isaiah.nor...@gmail.com>
wrote:

> it returns the same concept in all OS?
>
>
> As far as I can tell, yes.
>
>
>> Is it physical number of cores?
>
>
> Number of logical processors.
>
> On Wed, Nov 2, 2016 at 9:42 PM, Júlio Hoffimann <julio.hoffim...@gmail.com
> > wrote:
>
>> My question is, it returns the same concept in all OS? Is it physical
>> number of cores?
>>
>> -Júlio
>>
>
>


Re: [julia-users] Re: Sys.CPU_CORES

2016-11-02 Thread Isaiah Norton
>
> it returns the same concept in all OS?


As far as I can tell, yes.


> Is it physical number of cores?


Number of logical processors.

On Wed, Nov 2, 2016 at 9:42 PM, Júlio Hoffimann 
wrote:

> My question is, it returns the same concept in all OS? Is it physical
> number of cores?
>
> -Júlio
>


Re: [julia-users] Cannot PyPlot / Matplotlib broken (warnings about font cache?)

2016-11-02 Thread Isaiah Norton
>
> Ok. So first of all, PyPlot is grabbing the system-wide installation of
> Python. I don't know how to tell PyPlot to look at the one that was
> installed with the Conda package.


https://github.com/JuliaPy/PyCall.jl#specifying-the-python-version

To force Julia to use its own Python distribution, via Conda, rather than
whatever is installed on your system, simply set ENV["PYTHON"] to the empty
string "" as described above.


Second, the errors are saying something about fonts, but I can't figure out
> what they are saying. I am also confused by the "permission denied" error:


Hard to say. Try checking the permissions of the files listed by
`fc-list`... Maybe something was installed with `sudo` that should not have
been.


On Wed, Nov 2, 2016 at 10:12 AM, Daniel Carrera  wrote:

> Hi everyone,
>
>
> I am getting some cryptic errors when I try to load PyPlot. It seems to be
> a problem on the Python end, but I'm not sure. I tried to use the "Conda"
> package so that Julia would have its own (hopefully not-broken) copy of
> Python, but that didn't help as PyPlot is still looking at the system-wide
> install of Python. Here are the messages in full (and some comments after
> ward). I decided to start from a completely clean install of Julia 0.5 (no
> packages) to make sure that there was no problem there:
>
> ---
> $ mv ~/.julia/v0.5 ~/.julia/old-v0.5
> $ julia
>_
>_   _ _(_)_ |  A fresh approach to technical computing
>   (_) | (_) (_)|  Documentation: http://docs.julialang.org
>_ _   _| |_  __ _   |  Type "?help" for help.
>   | | | | | | |/ _` |  |
>   | | |_| | | | (_| |  |  Version 0.5.0 (2016-09-19 18:14 UTC)
>  _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
> |__/   |  x86_64-pc-linux-gnu
>
> julia> Pkg.add("Conda")
> INFO: Initializing package repository /home/daniel/.julia/v0.5
> INFO: Cloning METADATA from https://github.com/JuliaLang/METADATA.jl
> INFO: Installing BinDeps v0.4.5
> INFO: Installing Compat v0.9.3
> INFO: Installing Conda v0.3.2
> INFO: Installing JSON v0.8.0
> INFO: Installing SHA v0.2.1
> INFO: Installing URIParser v0.1.6
> INFO: Package database updated
>
> julia> Pkg.add("PyPlot")
> INFO: Installing ColorTypes v0.2.12
> INFO: Installing Colors v0.6.9
> INFO: Installing FixedPointNumbers v0.2.1
> INFO: Installing LaTeXStrings v0.2.0
> INFO: Installing MacroTools v0.3.2
> INFO: Installing PyCall v1.7.2
> INFO: Installing PyPlot v2.2.4
> INFO: Installing Reexport v0.0.3
> INFO: Building PyCall
> INFO: PyCall is using python (Python 2.7.12) at /usr/bin/python, libpython
> = libpython2.7
> INFO: Package database updated
>
> julia> using PyPlot
> INFO: Recompiling stale cache file /home/daniel/.julia/lib/v0.5/PyPlot.ji
> for module PyPlot.
> /usr/lib/python2.7/dist-packages/matplotlib/font_manager.py:273:
> UserWarning: Matplotlib is building the font cache using fc-list. This may
> take a moment.
>   warnings.warn('Matplotlib is building the font cache using fc-list. This
> may take a moment.')
> /usr/lib/python2.7/dist-packages/matplotlib/__init__.py:1352:
> UserWarning:  This call to matplotlib.use() has no effect
> because the backend has already been chosen;
> matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
> or matplotlib.backends is imported for the first time.
>
>   warnings.warn(_use_error_msg)
> /usr/lib/python2.7/dist-packages/matplotlib/font_manager.py:273:
> UserWarning: Matplotlib is building the font cache using fc-list. This may
> take a moment.
>   warnings.warn('Matplotlib is building the font cache using fc-list. This
> may take a moment.')
> /usr/lib/python2.7/dist-packages/matplotlib/font_manager.py:273:
> UserWarning: Matplotlib is building the font cache using fc-list. This may
> take a moment.
>   warnings.warn('Matplotlib is building the font cache using fc-list. This
> may take a moment.')
> /usr/lib/python2.7/dist-packages/matplotlib/font_manager.py:273:
> UserWarning: Matplotlib is building the font cache using fc-list. This may
> take a moment.
>   warnings.warn('Matplotlib is building the font cache using fc-list. This
> may take a moment.')
> /usr/lib/python2.7/dist-packages/matplotlib/font_manager.py:273:
> UserWarning: Matplotlib is building the font cache using fc-list. This may
> take a moment.
>   warnings.warn('Matplotlib is building the font cache using fc-list. This
> may take a moment.')
> WARNING: No working GUI backend found for matplotlib.
> /usr/lib/python2.7/dist-packages/matplotlib/font_manager.py:273:
> UserWarning: Matplotlib is building the font cache using fc-list. This may
> take a moment.
>   warnings.warn('Matplotlib is building the font cache using fc-list. This
> may take a moment.')
> ERROR: InitError: PyError (:PyImport_ImportModule)  'exceptions.IOError'>
> IOError(13, 'Permission denied')
>   File "/usr/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 29,
> in 
> import 

Re: [julia-users] building julia 0.5.0 on FreeBSD 11

2016-10-30 Thread Isaiah Norton
Just guessing here from some quick poking around: try adding `#include
` to that file (`OPENBLAS_SRC/driver/others/blas_server.c`).

On Sat, Oct 29, 2016 at 4:50 PM, Kostas Oikonomou <
kostas.oikonomo...@gmail.com> wrote:

> Hi, I'm following the instructions in the README, trying to build 0.5.0
> from source on an amd64 machine.
>
> However, I'm stuck at errors  in the OpenBlas build:
>
>
> blas_server.c:569:16: error: variable has incomplete type 'struct rlimit'
> struct rlimit rlim;
>   ^
> blas_server.c:569:9: note: forward declaration of 'struct rlimit'
> struct rlimit rlim;
>^
> blas_server.c:578:17: warning: implicit declaration of function 'raise' is
> invalid in C99
>   [-Wimplicit-function-declaration]
> if(0 != raise(SIGINT)) {
> ^
> blas_server.c:578:23: error: use of undeclared identifier 'SIGINT'
> if(0 != raise(SIGINT)) {
>   ^
> 1 warning and 2 errors generated.
> gmake[3]: *** [Makefile:101: blas_server.o] Error 1
>
>
> I also tried using FreeBSD's OpenBlas port, but that apparently creates a
> conflict between gcc 4.8.4 and the recommended gcc6.
>
> Here is my Make.user file:
>
> # libunwind needs a small patch to its tests to compile.
> FC=gfortran6
> # gfortran can't link binaries:
> FFLAGS=-Wl,-rpath,/usr/local/lib/gcc6
> # System libraries installed by pkg are not on the compiler path by
> default:
> LDFLAGS=/usr/local/lib
> CPPFLAGS=/usr/local/include
> # Problems with OpenBLAS
> OPENBLAS_TARGET_ARCH=BARCELONA
> OPENBLAS_DYNAMIC_ARCH=0
> # Installation
> prefix=/opt/julia
>
> Thanks for any help.
>
> Kostas
>


Re: [julia-users] Quote-friendly way to express keyword Expr?

2016-10-30 Thread Isaiah Norton
Not really clear what you are trying to do. These are inserted by the
parser whenever keyword arguments are used in (function) call syntax. So:

julia> quote f(x= 10) end |> dump
Expr
  head: Symbol block
  args: Array{Any}((2,))
1: Expr
  head: Symbol line
  args: Array{Any}((2,))
1: Int64 1
2: Symbol REPL[6]
  typ: Any
2: Expr
  head: Symbol call
  args: Array{Any}((2,))
1: Symbol f
2: Expr
  head: Symbol kw
  args: Array{Any}((2,))
1: Symbol x
2: Int64 10
  typ: Any
  typ: Any
  typ: Any



On Sun, Oct 30, 2016 at 12:47 AM, Penn Taylor  wrote:

> Is there a quote-friendly way to write the following keyword Expr, or must
> I directly manipulate raw Expr's to get this?
>
> Expr(:kw, :foo, 2)
>
>
> By "quote-friendly", I mean a form such as
>
> :(stuff)
>
> # or
>
> quote
>  stuff
> end
>


Re: [julia-users] Gallium: how to remove a breakpoint?

2016-10-29 Thread Isaiah Norton
`Gallium.remove(Gallium.breakpoints[1])`

On Sat, Oct 29, 2016 at 9:09 AM, Florian Oswald 
wrote:

> hi all,
>
> i have got a rather simple question but can't figure it out:
>
> https://github.com/Keno/Gallium.jl/issues/166
>
> thanks
>


Re: [julia-users] Re: so many plotting packages

2016-10-28 Thread Isaiah Norton
>
> the julia community would benefit by collecting all these packages in one
> place.
>

There are only 3 or 4 of those packages that should be recommended for
general use. If someone wants to help users decide what package to use,
write up a comparison page with examples. It could be linked from the
existing blurbs on the download page.

i'd suggest moving the rest to juliagraphics.  make sense?


Trying to herd together a group of people who have already rejected the
aesthetic or engineering choices of existing, competing projects seems
totally futile. Winston and Gadfly existed before many of the newer
packages, but people chose to start/use/contribute to newer things anyway.
Putting packages in an org doesn't make people want to start cooperating.
Some of those listed are unmaintained or hobby experiments, and as your
link demonstrates, sometimes people just want to do their own thing -- and
that's fine!

On Fri, Oct 28, 2016 at 9:47 PM, Ben Arthur  wrote:

> i wasn't looking for recommendations.  am happily using gadfly.  started
> out with pyplot three years ago.
>
> rather, i just think the julia community would benefit by collecting all
> these packages in one place.  since tbreloff appears to want to keep an iron
> grip
> 
> on juliaplots, i'd suggest moving the rest to juliagraphics.  make sense?
>>
>>


Re: [julia-users] Parameteric Function of Types

2016-10-28 Thread Isaiah Norton
On Fri, Oct 28, 2016 at 12:07 PM, Derek Gaston  wrote:

> I can't quite seem to get the right syntax for creating methods that are
> keyed off of subtypes (as a parameter).
>
> Say I have:
>
> abstract foo
> abstract bar <: foo
>
> I want to create a function that is like so:
>
> function doStuff(::Type{foo})
> end
>
> in such a way that I can call it with "Type{bar}".  i.e.:
>  doStuff(Type{bar})
>
> I understand that:
>
> # Returns true:
> issubtype(bar, foo)
>
> # Returns false:
> issubtype(Type{bar}, Type{foo})
>
> And I understand why.
>
> So... I tried to define:
>
> function doStuff{T}(::Type{T<:foo})
> end
>
> But it tells me that: "WARNING: static parameter T does not occur in
> signature" (it looks like it does to me! :-)... so that's not the right
> answer.
>

function doStuff{T <: foo}(::Type{T})
end


>
> Obviously I'm just thinking about the problem incorrectly... so can
> someone shed some light on what's up here?
>
> Before you ask: I really do need to operate on the _types_ and not on
> instances of the objects themselves (which would obviously be
> straightforward to do).
>
>
>
>
> Also: a (related) follow-on question.  What is the correct/preferred way
> to do the following:
>
> function createSomething{T}()
>   return T()
> end
>
>
If you want to implement the "factory pattern", that can be simulated, but
I'm not sure it's necessary (or useful) in Julia.

See also:
  http://stackoverflow.com/a/35524338/508431
  http://docs.julialang.org/en/latest/manual/constructors/#out
er-constructor-methods




(obviously, this is a toy example, my real application of this is not
> trivial)
>
> Is it to do:
>
> function createSomething{T}(::Type{T})
>   return T()
> end
>
> ?
>
>
>
>
> Thanks for any help!
>
> Derek
>


Re: [julia-users] Re: MersenneTwister, srand

2016-10-28 Thread Isaiah Norton
>
> So what is the difference between srand and merseentwister?


Per doc link, srand uses MT by default.

and also how do I get my random numbers


rand() for floats less than 1 by default, or specify a set to choose from:

help?> rand
search: rand randn rand! randn! randexp randperm randjump randexp!
randcycle randsubseq randstring randsubseq! RandomDevice srand sprand
sprandn sprandbool bitrand transcode

  rand([rng=GLOBAL_RNG], [S], [dims...])

  Pick a random element or array of random elements from the set of values
specified by S; S can be

•an indexable collection (for example 1:n or ['x','y','z']), or

•a type: the set of values to pick from is then equivalent to
typemin(S):typemax(S) for integers (this is not applicable to BigInt), and
to [0, 1) for floating point numbers;

what do the different fields mean?


The fields aren't intended to be accessed, but you can see each element
name with:

julia> fieldnames(MersenneTwister)
4-element Array{Symbol,1}:
 :seed
 :state
 :vals
 :idx


How do I acutally set the seed
>

srand


> srand(0) and rand() would actually be a mersennetwister I'd expect zeros
> everywhere...
>

Why?


On Fri, Oct 28, 2016 at 2:11 PM, digxx  wrote:

> Sorry but that doesn't answer my question. That's where I have the calling
> from but it does not explain the output and what it means...
>


Re: [julia-users] Re: MersenneTwister, srand

2016-10-28 Thread Isaiah Norton
http://docs.julialang.org/en/latest/stdlib/numbers/?highlight=global_rng#random-numbers

On Fri, Oct 28, 2016 at 1:23 PM, digxx  wrote:

> With number in my head I meant, that I expected to see random number
> arrays of size 624 since as far as I know they are created
> simultaneously,right?
>


Re: [julia-users] automatically moving from cmake 3.6.1 to cmakex.y.z

2016-10-27 Thread Isaiah Norton
>
> Or even better: let's remove a lot of complexity and move the whole Julia
> build system to CMake.


The main advantage I see to CMake is support for Visual Studio. I would not
consider it a reduction of complexity -- CMake is very much like regexes:
now you have two problems. Or perhaps three...

set(number_problems 3 FORCE CACHE PARENT_SCOPE)

I think I saw an issue about this some time


https://github.com/JuliaLang/julia/pull/11754


On Thu, Oct 27, 2016 at 9:56 AM, Bart Janssens <b...@bartjanssens.org>
wrote:

>
> On Thu, Oct 27, 2016 at 3:24 PM Isaiah Norton <isaiah.nor...@gmail.com>
> wrote:
>
>>
>> I'm not sure if there's any good way to introspect this and trigger a
>> reconfigure from Julia's build system without adding a lot of complexity.
>>
>
> Or even better: let's remove a lot of complexity and move the whole Julia
> build system to CMake. I think I saw an issue about this some time, so I
> guess it's non-trivial, but I'd be willing to help.
>


Re: [julia-users] automatically moving from cmake 3.6.1 to cmakex.y.z

2016-10-27 Thread Isaiah Norton
>
> Thanks!  is there a way of doing it automatically and recursively until it
> finds the appropiate CMakeLists.txt file so I do not have to trawl for it? in
> addition, as it seems pretty simple I am surprised this does not happen
> ‘automagically’.


The generated Makefiles have absolute, symlink-resolved paths because CMake
doesn't want the version to change underneath (I guess?). But the cmake
binary itself is called back by make to detect whether a reconfiguration is
necessary. Hence this error.

I'm not sure if there's any good way to introspect this and trigger a
reconfigure from Julia's build system without adding a lot of complexity.
If you want to figure out which projects to reconfigure: `find
/path/to/julia -name *CMakeCache*`.

On Thu, Oct 27, 2016 at 3:46 AM, Federico Calboli 
wrote:

>
> > On 27 Oct 2016, at 10:34, Bart Janssens  wrote:
> >
> > Normally this is solved by running "cmake ." in the build directory or
> directories of the library or libraries compiled using cmake.
>
> Thanks!  is there a way of doing it automatically and recursively until it
> finds the appropiate CMakeLists.txt file so I do not have to trawl for it?
> in addition, as it seems pretty simple I am surprised this does not happen
> ‘automagically’.
>
> BW
>
> F
>
> >
> > Cheers,
> >
> > Bart
> >
> > On Thu, Oct 27, 2016 at 9:28 AM Federico Calboli 
> wrote:
> > Hi, toady on a whim I tried
> >
> > make cleanall && make testall
> >
> > but it did not work because when julia was built cmake was at 3.6.1 and
> now it is a 3.6.2
> >
> > make[2]: /usr/local/Cellar/cmake/3.6.1/bin/cmake: No such file or
> directory
> > make[2]: *** [cmake_check_build_system] Error 1
> > make[1]: *** [/usr/local/julia/usr/lib/libmbedcrypto.dylib] Error 2
> > make: *** [julia-deps] Error 2
> >
> > Now I have:
> >
> > ../Cellar/cmake/3.6.2/bin/cmake
> >
> > This problem seems extremely silly, given that it forces me *not* to
> upgrade my cmake (and maybe other software), when the make routine could do
> the equivalent of `which cmake' and use the result.
> >
> > Leaving this aside, is there a way of rebuilding julia with the correct
> cmake without basically removing the whole thing and rebuilding from 0?
> >
> > BW
> >
> > F
>
>
>
>


Re: [julia-users] Re: CoinOptServices

2016-10-26 Thread Isaiah Norton
Other suggestion: try temporarily (re)moving that file (`%/liblapack.dll`).

I wonder if Julia itself is opening the dll for some reason, before WinRPM
tries to replace it. (check again with Process Explorer while Julia is
still running?)

On Wed, Oct 26, 2016 at 12:22 PM, Frank Kampas  wrote:

>
> Handle or Dll substring "liblapack" returned 0 matching items
>


Re: [julia-users] cscope like tool

2016-10-26 Thread Isaiah Norton
I don't think so, but Lint.jl might be of interest: https://github.com/
tonyhffong/Lint.jl

On Wed, Oct 26, 2016 at 8:56 AM, Ajay Mendez  wrote:

> Looking for a tool to grok large projects, a la cscope.
> methods(method_name) is good but insufficient. For those unfamiliar with
> cscope, it allows the following queries:
>
> Find this C symbol:
> Find this global definition:
> Find functions called by this function:
> Find functions calling this function:
> Find this text string:
> Change this text string:
> Find this egrep pattern:
> Find this file:
> Find files #including this file:
> Find assignments to this symbol:
>
>


Re: [julia-users] Re: CoinOptServices

2016-10-26 Thread Isaiah Norton
>
> Process Explorer does not indicate that lapack is being run when the
> problem occurs.


Does
  Find -> Find a Handle or DLL -> "liblapack"

Return any results? The goal is to look for any open handle to
"liblapack.dll", which would lead to the "Can not delete" error indicated
in the posted error log. (I would not expect "liblapack" to ever be listed
in the main Process list)

If the search does not return any results, then the "Can not delete" error
may have a different cause.

On Wed, Oct 26, 2016 at 11:39 AM, Frank Kampas  wrote:

> Process Explorer does not indicate that lapack is being run when the
> problem occurs.
> I do have mingw installed elsewhere on my computer.
>


Re: [julia-users] Re: CoinOptServices

2016-10-26 Thread Isaiah Norton
>
> Something is preventing the lapack dll from being overwritten on your
> system.


Try Process Explorer (
https://technet.microsoft.com/en-us/sysinternals/processexplorer.aspx)

  "Find" menu -> "Find a Handle or DLL"

  search for "liblapack" and look at what process owns the handle.

On Wed, Oct 26, 2016 at 9:55 AM, Tony Kelman  wrote:

> Look at the actual logs. It installs fine, just has a handful of known
> test failures that are due to bugs in the upstream library. Something is
> preventing the lapack dll from being overwritten on your system. That's not
> a problem that's been seen anywhere else as far as I'm aware.


Re: [julia-users] computation on types in type definition

2016-10-26 Thread Isaiah Norton
>
> However, if I want to compute types directly in the definition (see third
> implementation), I end up with a TypeVar object I don't know how to deal
> with (even though I read the "More about types" section in the manual,
> sorry). Is this even possible?


Not yet: https://github.com/JuliaLang/julia/issues/18466

On Wed, Oct 26, 2016 at 9:07 AM, Tamas Papp  wrote:

> I have a type which contains two slots, and it is important that the
> types of them satisfy certain constraints. I can enforce that in the
> constructor: see first and second implementations below. However, if I
> want to compute types directly in the definition (see third
> implementation), I end up with a TypeVar object I don't know how to deal
> with (even though I read the "More about types" section in the manual,
> sorry). Is this even possible?
>
> [Note: I also asked on Gitter, but did not get a solution, or an
> explanation.]
>
> # first implementation: dd1 maps values to types
> # uses constructor to constrain, works
>
> dd1(::Int) = Float64 # for the sake of example
>
> immutable Foo1{T,S}
> a::T
> b::Set{S}
> function Foo1{T,S}(a::T, b::Set{S})
> @assert S ≡ dd1(a)
> new(a, b)
> end
> end
>
> Foo1{T,S}(a::T, b::Set{S}) = Foo1{T,S}(a,b)
>
> Foo1(1, Set([9.0])) # OK
> foo1(1, Set(9)) # error
>
> # second implementation: dd2 maps types to types
> # uses constructor to constrain, works
>
> dd2(::Type{Int}) = Float64
>
> immutable Foo2{T,S}
> a::T
> b::Set{S}
> function Foo2{T,S}(a::T, b::Set{S})
> @assert S ≡ dd2(T)
> new(a, b)
> end
> end
>
> Foo2{T,S}(a::T, b::Set{S}) = Foo2{T,S}(a,b)
>
> Foo2(1, Set([9.0])) # OK
> Foo2(1, Set(9)) # error
>
> # third implementation, types to types
>
> immutable Foo3{T,S}
> a::T
> b::Set{dd2(T)}
> end
> ## ERROR: MethodError: no method matching dd2(::TypeVar)
>


Re: [julia-users] Arrays with custom indices examples?

2016-10-24 Thread Isaiah Norton
>
> mg = zeros(Int,(0:4,0:4))


This isn't related to indexing -- it doesn't work with `1:4` either. Use:

  zeros(Int, 4, 4)

(See also the help entry: `?zeros`)

That said, be aware of the warnings in the referenced document: this
feature is still considered experimental, so if you hit other issues please
ping back here again, and folks may suggest to file a bug report.

On Mon, Oct 24, 2016 at 7:13 AM, Angel de Vicente <
angel.vicente.garr...@gmail.com> wrote:

> Hi,
>
> I'm trying to figure out how to use arrays with custom indices, and I've
> read http://docs.julialang.org/en/release-0.5/devdocs/offset-arrays/,
> but I don't seem to see how I could actually access array positions
> using arbitrary indices.
>
> A basic example of what I'd like to do would be something like:
> ,
> | m = rand(1:10,(3,3))
> | mg = zeros(Int,(0:4,0:4))
> | mg[1:3,1:3]=m
> `
>
> so that mg would be a copy of m but with a buffer zone around it, and
> when I need to access any value in mg, I can use the same indexing as
> for m (the buffer zone would represent ghost cells for PDEs).
>
> But I don't seem to get very far, as the creation of mg already is
> giving me troubles:
> ,
> | julia> mg = zeros(Int,(0:4,0:4))
> | ERROR: MethodError: Cannot `convert` an object of type
> Tuple{UnitRange{Int64},UnitRange{Int64}} to an object of type
> | Array{Int64,N}
> | This may have arisen from a call to the constructor Array{Int64,N}(...),
> | since type constructors fall back to convert methods.
> |  in Array{Int64,N}(::Tuple{UnitRange{Int64},UnitRange{Int64}}) at
> ./sysimg.jl:53
> |  in zeros(::Type{T}, ::Tuple{UnitRange{Int64},UnitRange{Int64}},
> ::Vararg{Tuple{UnitRange{Int64},UnitRange{Int64}},N}
> | ) at ./array.jl:169
> `
>
> I had a tough night, so perhaps the answer is clear from
> http://docs.julialang.org/en/release-0.5/devdocs/offset-arrays/, but I
> can't see whether what I'm trying to do is doable and if so, how. Any
> help appreciated.
>
> Thanks,
> --
> Ángel de Vicente
> http://www.iac.es/galeria/angelv/
>


Re: [julia-users] Named for loops?

2016-10-24 Thread Isaiah Norton
On Monday, October 24, 2016, Angel de Vicente <
angel.vicente.garr...@gmail.com> wrote:

> Hi,
>
> I don't see it in the documentation, but I'm wondering if there is a way
> to have named nested loops, so that one can specify those names to break
> and continue, in order to have more control.
>
> In the following examples, continue always skips the remaining loop for
> j, while break terminates the j loop in the first example and terminates
> the single outer loop in the second (I guess it can be a bit confusing
> at first, but I can understand the design).
>
> ,
> | println("nested")
> | for i in 1:3
> | for j in 1:6
> | if 2 < j < 4 continue end
> | if j > 5 break end
> | @printf("i: %i j: %i \n",i,j)
> | end
> | end
> |
> | println("single outer loop")
> | for i in 1:3, j in 1:6
> | if 2 < j < 4 continue end
> | if j > 5 break end
> | @printf("i: %i j: %i \n",i,j)
> | end
> `
>
> But I'm used to Fortran, where one can do things like this (CYCLE ==
> continue ; EXIT == break), and you specify the loop that the instruction
> applies to.
>
> ,
> |   INA: DO a = 1,1000
> | INB: DO b=a+1,1000
> | IF (a+b .GT. 1000) CYCLE INA
> | INC: DO c=b+1,1000
> |IF (a+b+c .GT. 1000) CYCLE INB
> |IF (a+b+c .EQ. 1000 .AND. a**2 + b**2 .EQ. c**2) THEN
> |   PRINT*, a*b*c
> |   EXIT INA
> |END IF
> | END DO INC
> |  END DO INB
> |   END DO INA
> `
>
>
> Is it possible now (or in the near future) to have named nested loops in
> Julia?


No, and I'm not aware of any plan to support this. But you can create
custom control flow with '@goto', so it could be probably be done with a
macro.


>
> Thanks,
> --
> Ángel de Vicente
> http://www.iac.es/galeria/angelv/
>


Re: [julia-users] Re: Eval without JIT

2016-10-20 Thread Isaiah Norton
There is a startup option that controls this: `--compile=off` (internally
corresponds to `jl_options.compile_enabled`). I don't think there is a
function to modify the value at runtime. However, some types of statements
are not currently supported by the interpreter, so this is not really
feasible yet (see the heuristics in
src/toplevel.c:`jl_eval_with_compiler_p`  [1]).

Full interpretability (with the exception of `ccall`) is an active goal
[2], in order to support static compilation. When that is complete, it may
make sense to add a `jl_enable_compiler(bool)` runtime function.

[1]
https://github.com/JuliaLang/julia/blob/0faf8ce200103839577171d28a4d1545fa827336/src/toplevel.c#L358-L403
[2] https://github.com/JuliaLang/julia/pull/18754

On Thu, Oct 20, 2016 at 8:44 AM, Christian Rorvik <
christian.ror...@gmail.com> wrote:

> I see, so there's a heuristic, but no way to hint it or tell it what to do
> directly?
>
> On Thursday, October 20, 2016 at 1:22:51 PM UTC+1, Steven G. Johnson wrote:
>>
>> eval() already uses an interpreter without JIT for sufficiently simple
>> expressions.
>>
>


Re: [julia-users] Embedding Julia in C++ - Determining returned array types

2016-10-19 Thread Isaiah Norton
e.g. http://half.sourceforge.net/

But if you aren't sure you need to support this, then just throw an error
(Float16 is relatively new and AFAICT only useful in specialized
applications because of the precision limit, which is why support is rare)

If you are sure you (a) need it but (b) only need to up- and down-convert,
see the routines in `base/float.jl`. They should be straightforward to port
to C++.

On Wed, Oct 19, 2016 at 1:00 PM, Yichao Yu  wrote:

>
>
> On Wed, Oct 19, 2016 at 12:54 PM, Kyle Kotowick  wrote:
>
>> Aha, that fixed it!
>>
>> I'm running into one issue though. What do I do with the data when it's a
>> "Float16" type? C++ has no way to represent a 16-bit float, so I'm having
>> difficulty converting it to a regular 32-bit float.
>>
>
> Find a compiler / library that supports it? ;-p
>
> I'm only half joking. You can always just keep a pointer to the value or
> store it in a int16_t as long as you don't need to do any operation on it.
> If you want to operate on them in C++ natively you would have to find a
> C/C++ compiler/library (or write the necessary operations yourself) that
> supports __fp16.
>
>
>>
>> jl_value_t *ret = jl_eval_string(code_string);
>> jl_array_t *ret_array = (jl_array_t*)ret;
>>
>> if (jl_array_eltype(ret) == jl_float16_type) {
>>
>>  /* now I need to convert the 'ret_array' to a C++ array of floats, but
>> how do I do that when they're given in Float16? */
>>
>> }
>>
>>
>> On Tuesday, 18 October 2016 20:57:10 UTC-4, Isaiah wrote:
>>>
>>> The issue here is that `jl_array_eltype` is already returning a type.
>>>
>>> `jl_typeis(v, t)` becomes `jl_typeof(v) == t`, so your checks become:
>>>
>>> jl_typeof(array_type) == jl_int64_type
>>>
>>> But
>>>
>>> jl_typeof(array_type) -> DataType
>>>
>>> Instead, either do the equality check directly:
>>>
>>>   array_type == jl_int64_type
>>>
>>> Or use the exported API only (jlapi.c):
>>>
>>>   strcmp(jl_typename_str(array_type), jl_typename_str(jl_int64_type))
>>>
>>> On Tue, Oct 18, 2016 at 7:52 PM, Kyle Kotowick 
>>> wrote:
>>>
 I apologize for the formatting, that should be:

 jl_value_t *ret = jl_eval_string(code_string);
 void* array_type = jl_array_eltype(ret);
 jl_array_t *ret_array = (jl_array_t*)ret;

 if (jl_typeis(array_type, jl_int64_type)) {
   long *data = (long*) jl_array_data(ret_array);
 }
 else if (jl_typeis(array_type, jl_float64_type)) {
   double *data = (double*) jl_array_data(ret_array);
 }


 And the issue is that even if it is an Int64 or Float64, neither of
 those IF statements will return true.



 On Sunday, 16 October 2016 21:36:03 UTC-4, Kyle Kotowick wrote:
>
> Awesome, thanks. Could you show how to use it in a minimal code
> example? Here's what I'm currently trying, but it does not appear to be
> working:
>
> jl_value_t *ret = jl_eval_string(code_string);
> void* array_type = jl_array_eltype(ret);
> jl_array_t *ret_array = (jl_array_t*)ret;
>
>
>
> if (jl_typeis(array_type, jl_int64_type)) {
>  long *data = (long*) jl_array_data(ret_array);
> }
> else if (jl_typeis(array_type, jl_float64_type)) { double *data = (
> double*) jl_array_data(ret_array);
> }
>
>
> On Friday, 14 October 2016 20:45:18 UTC-4, Isaiah wrote:
>>
>> On Fri, Oct 14, 2016 at 2:28 PM, Kyle Kotowick 
>> wrote:
>>>
>>>
>>> After determining that an array was returned, how would you
>>> determine what the inner type of the array is (i.e. the type of the 
>>> objects
>>> it contains)?
>>>
>>
>> `jl_array_eltype`
>>
>>
>>>
>>> And furthermore, if it returns an array of type "Any", would there
>>> be any way to tell what the type is of any arbitrary element in that 
>>> array?
>>>
>>
>> `jl_typeof`, after retrieving the element (which will be boxed)
>>
>>
>>>
>>> Thanks!
>>>
>>
>>
>>>
>


Re: [julia-users] Embedding Julia in C++ - Determining returned array types

2016-10-18 Thread Isaiah Norton
The issue here is that `jl_array_eltype` is already returning a type.

`jl_typeis(v, t)` becomes `jl_typeof(v) == t`, so your checks become:

jl_typeof(array_type) == jl_int64_type

But

jl_typeof(array_type) -> DataType

Instead, either do the equality check directly:

  array_type == jl_int64_type

Or use the exported API only (jlapi.c):

  strcmp(jl_typename_str(array_type), jl_typename_str(jl_int64_type))

On Tue, Oct 18, 2016 at 7:52 PM, Kyle Kotowick  wrote:

> I apologize for the formatting, that should be:
>
> jl_value_t *ret = jl_eval_string(code_string);
> void* array_type = jl_array_eltype(ret);
> jl_array_t *ret_array = (jl_array_t*)ret;
>
> if (jl_typeis(array_type, jl_int64_type)) {
>   long *data = (long*) jl_array_data(ret_array);
> }
> else if (jl_typeis(array_type, jl_float64_type)) {
>   double *data = (double*) jl_array_data(ret_array);
> }
>
>
> And the issue is that even if it is an Int64 or Float64, neither of those
> IF statements will return true.
>
>
>
> On Sunday, 16 October 2016 21:36:03 UTC-4, Kyle Kotowick wrote:
>>
>> Awesome, thanks. Could you show how to use it in a minimal code example?
>> Here's what I'm currently trying, but it does not appear to be working:
>>
>> jl_value_t *ret = jl_eval_string(code_string);
>> void* array_type = jl_array_eltype(ret);
>> jl_array_t *ret_array = (jl_array_t*)ret;
>>
>>
>>
>> if (jl_typeis(array_type, jl_int64_type)) {
>>  long *data = (long*) jl_array_data(ret_array);
>> }
>> else if (jl_typeis(array_type, jl_float64_type)) { double *data = (double
>> *) jl_array_data(ret_array);
>> }
>>
>>
>> On Friday, 14 October 2016 20:45:18 UTC-4, Isaiah wrote:
>>>
>>> On Fri, Oct 14, 2016 at 2:28 PM, Kyle Kotowick 
>>> wrote:


 After determining that an array was returned, how would you determine
 what the inner type of the array is (i.e. the type of the objects it
 contains)?

>>>
>>> `jl_array_eltype`
>>>
>>>

 And furthermore, if it returns an array of type "Any", would there be
 any way to tell what the type is of any arbitrary element in that array?

>>>
>>> `jl_typeof`, after retrieving the element (which will be boxed)
>>>
>>>

 Thanks!

>>>
>>>


Re: [julia-users] Does julia -L work with plots?

2016-10-14 Thread Isaiah Norton
Call `show()` at the end of the script. See explanation here:

https://github.com/JuliaPy/PyPlot.jl#non-interactive-plotting

On Fri, Oct 14, 2016 at 1:17 PM, Stefan Rigger  wrote:

>
>
> Hello everyone,
>
> I'm using julia to numerically solve partial differential equations and
> use PyPlot to plot the solutions. I'd like to be able to calculate a
> solution and plot entering something like
> julia -L file.jl
>
> in Terminal but unfortunately, this doesn't seem to work (there is no
> window opening where one can view the solution). I've attached a small .jl
> file if you want to test it yourself. Is there any way one can get this to
> work? Thank you for your time,
>
> Best Regards,
> Stefan Rigger
>


Re: [julia-users] Embedding Julia in C++ - Determining returned array types

2016-10-14 Thread Isaiah Norton
On Fri, Oct 14, 2016 at 2:28 PM, Kyle Kotowick  wrote:
>
>
> After determining that an array was returned, how would you determine what
> the inner type of the array is (i.e. the type of the objects it contains)?
>

`jl_array_eltype`


>
> And furthermore, if it returns an array of type "Any", would there be any
> way to tell what the type is of any arbitrary element in that array?
>

`jl_typeof`, after retrieving the element (which will be boxed)


>
> Thanks!
>


Re: [julia-users] Simple test functions generates different codegen

2016-10-04 Thread Isaiah Norton
These expressions are lowered differently because `test2` gets a temporary
due to the conditional reassignment of `u`, whereas `test1` is just a
straight line switch and jump (look at `code_lowered` and `code_typed`).

For the same C code, the lowered IR from Clang looks similar, but it
appears to constant fold and reduce down to identical assembly at `-O1` and
above. The fact that Julia doesn't is probably due to difference in LLVM
optimization passes or order.

As far as style, personally I think the first one is cleaner.

On Fri, Sep 30, 2016 at 1:48 PM, mmh  wrote:

> I would have that thought that these two function would produce the same
> code, but they do not.
>
> Could someone care to explain the difference and which is preferred and why
>
>
> http://pastebin.com/GJ8YPfV3
>
> function test1(x)
> y = 2.0
> u = 2.320
> x < 0 && (u = 32.0)
> x > 1 && (u = 1.0)
> return u + y
> end
>
>
> function test2(x)
> y = 2.0
> u = 2.320
> u = x < 0 ? 32.0 : u
> u = x > 1 ? 1.0 : u
> return u + y
> end
>
>
> @code_llvm test1(2.2)
>
> @code_llvm test2(2.2)
>
>


Re: [julia-users] jl_cstr_to_string() variant for wchar_t*

2016-10-03 Thread Isaiah Norton
The 'LegacyStrings' package has functions to convert utf16 (and utf32)
strings.

On Mon, Oct 3, 2016 at 4:03 AM, Ján Adamčák  wrote:

> Hi,
>
> Is there any version of
>
> jl_cstr_to_str()
>
> for use with wchar_t*?
>
> I try create a small wrapper processing windows wchar_t strings to Julia
> strings.
>
> Thanks.
>


Re: [julia-users] ANN: RawArray.jl

2016-09-26 Thread Isaiah Norton
Thanks for the response.

1. I don't think NRRD is as substantially used as you might think. I've
> worked in imaging science for years on the data processing/file format end,
> and I've never seen anyone use it, and I've never even heard of it.  (Pity,
> because it looks nice enough. :-\)


I think I can make a solid argument that the install-base of software
supporting NRRD is on the order of 30-50k -- probably larger than anything
but NIfTI (which is substantial, to me, as far as obscure, non-DICOM
medical imaging formats go...)

But that's neither here nor there. I'm not going to change your mind, but
perhaps someone else will see this thread and think twice before creating
`RawArraysWithSlightlyMoreMetadata.jl`.


> JuliaIO/Images.jl relies on having ImageMagick installed, whereas
> RawArray.jl is a pure Julia solution without any dependencies.
>

Indeed, that was a major pain point, especially for Windows users. However,
Images.jl has been modularized, and no longer requires ImageMagick. NRRD.jl
does have more dependencies (~10) than might be expected, in order to
support Images inter-op, but from what I can tell they are all pure-Julia
except for Rmath (the binary portions of which are distributed as part of
base Julia).

I'll take my other, minor, comments off-list since this curmudgeonly pet
peeve probably isn't of much general interest!


On Monday, September 26, 2016 at 8:59:15 AM UTC-5, David Smith wrote:
>>
>> Hi, Isaiah. This is a valid question.
>>
>> 0. As a preface, I'd like to say I'm not trying to replace anything. I
>> wrote RawArray to solve a problem we have in magnetic resonance imaging
>> (quickly saving and loading large complex float arrays), and then I decided
>> to share it so if other people like it and find it useful, then cool beans.
>>
>> Now for the mild stumping...
>>
>> 1. I don't think NRRD is as substantially used as you might think. I've
>> worked in imaging science for years on the data processing/file format end,
>> and I've never seen anyone use it, and I've never even heard of it.  (Pity,
>> because it looks nice enough. :-\)
>>
>> 2. RawArray is simpler to handle and trivial to understand. I believe all
>> you need from an I/O library is I/O.* I don't want my file I/O library
>> performing transformations on my data.
>>
>> I also don't need it to read image formats. Part of the reason behind
>> RawArray is to avoid standard image formats because they are not optimized
>> for large complex-float arrays. I just want to save multi-GB data arrays to
>> disk quickly and read them back quickly on a different machine, five years
>> later.
>>
>> I have other implementations (https://github.com/davidssmith/ra), and
>> all are super short and platform agnostic.
>>
>> 3. RawArray is surely faster. All it does is read. It doesn't perform any
>> transformations or encoding, so it can't possibly be slower than NRRD.
>> There is a C library at (https://github.com/davidssmith/ra) if you think
>> a pure Julia implementation isn't fast enough.
>>
>> Cheers,
>> Dave
>>
>> [*] That said, I'm not completely ruling out having transformations
>> available in RawArray between the RAM and disk. For example, when I first
>> wrote it, I had included Blosc compression as an option, signaled by a flag
>> in the header. But in general most transformations are best made in RAM
>> after reading or on disk with already existing, battle-proven tools, such
>> as gzip, uunencode, tar, etc.
>>
>>
>> On Sunday, September 25, 2016 at 9:59:45 PM UTC-5, Isaiah wrote:
>>>
>>> Is there a reason to use this file format over NRRD [1]? To borrow a
>>> wise phrasing: I wonder if the world needs another lightweight raw data
>>> format ;)
>>>
>>> For what it's worth, NRRD is already supported by JuliaIO/Images.jl, and
>>> I believe addresses the use-cases identified in your readme, but with a
>>> number of technical and non-technical advantages (not least: a number of
>>> independent implementations, and a substantial user base, at least as far
>>> as these things go).
>>>
>>> I say this -- very selfishly I admit -- as someone who has been on the
>>> receiving end of far too many files in home-brewed formats.
>>>
>>> [1] http://teem.sourceforge.net/nrrd/descformat.html
>>>
>>> On Sunday, September 25, 2016, David Smith  wrote:
>>>
 Hi, all:

 I finally pushed this out, and it might satisfy some of your needs for
 a simple way to store N-d arrays to disk. Hope you enjoy it.

 RawArray (.ra) is a simple file format for storing n-dimensional
 arrays. RawArray was designed to be portable, fast, storage efficient, and
 future proof. Basically it writes the binary array data directly to disk
 with a short header that is used to recreate type and dimension
 information.

 RawArray is faster than HDF5 and supports complex numbers out of the
 box, which HDF5 does not. RawArray supports all basic `Int`, `UInt`,
 `Float`, and `Complex{}` types, 

Re: [julia-users] ANN: RawArray.jl

2016-09-25 Thread Isaiah Norton
Is there a reason to use this file format over NRRD [1]? To borrow a wise
phrasing: I wonder if the world needs another lightweight raw data format ;)

For what it's worth, NRRD is already supported by JuliaIO/Images.jl, and I
believe addresses the use-cases identified in your readme, but with a
number of technical and non-technical advantages (not least: a number of
independent implementations, and a substantial user base, at least as far
as these things go).

I say this -- very selfishly I admit -- as someone who has been on the
receiving end of far too many files in home-brewed formats.

[1] http://teem.sourceforge.net/nrrd/descformat.html

On Sunday, September 25, 2016, David Smith  wrote:

> Hi, all:
>
> I finally pushed this out, and it might satisfy some of your needs for a
> simple way to store N-d arrays to disk. Hope you enjoy it.
>
> RawArray (.ra) is a simple file format for storing n-dimensional arrays.
> RawArray was designed to be portable, fast, storage efficient, and future
> proof. Basically it writes the binary array data directly to disk with a
> short header that is used to recreate type and dimension information.
>
> RawArray is faster than HDF5 and supports complex numbers out of the box,
> which HDF5 does not. RawArray supports all basic `Int`, `UInt`, `Float`,
> and `Complex{}` types, and more can be easily added in the future, such as
> Rational or Big*. It can also handle derived types, but the serialization
> of them is currently left up to the user.
>
> A system of version numbers and flags are implemented to future-proof the
> data files as well, in case the implementation needs to change for some
> reason.
>
> You can grab it with `Pkg.add("RawArray")`. A minimum of Julia 0.4 is
> required.
>
> Repository: https://github.com/davidssmith/RawArray.jl
>
> Cheers,
> Dave
>


Re: [julia-users] Re: Dict get destroys global variable?

2016-09-22 Thread Isaiah Norton
Use `global a = ...`
Please see:
http://docs.julialang.org/en/latest/manual/variables-and-scoping/#hard-local-scope

global variables are only inherited for reading but not for writing




On Fri, Sep 23, 2016 at 12:00 AM, K leo  wrote:

> Sorry, this is not related to Dict at all.  If I replace the "a=get..."
> statement with simply "a=2", the global variable is no longer accessible.
> What is wrong?
>
>
> On Friday, September 23, 2016 at 11:52:24 AM UTC+8, K leo wrote:
>>
>> Calling "get" anywhere in a function makes a global variable undefined.
>> Can anyone please help explaining the following?
>>
>> 1) without calling "get", the global variable is fine:
>>
>> a=0
>>>
>>> Dicta = Dict{Int,Int}()
>>>
>>> function testGlobal()
>>>
>>> println(a)
>>>
>>> merge!(Dicta, Dict(1=>1))
>>>
>>> # a=get(Dicta, 1, 0)
>>>
>>> println(a)
>>>
>>> nothing
>>>
>>> end
>>>
>>>
>>> julia> testGlobal()
>> 0
>> 0
>>
>> 2) calling "get" (same code as above except uncommenting the "get"
>> statement) and the global variable becomes undefined:
>>
>> a=0
>>>
>>> Dicta = Dict{Int,Int}()
>>>
>>> function testGlobal()
>>>
>>> println(a)
>>>
>>> merge!(Dicta, Dict(1=>1))
>>>
>>> a=get(Dicta, 1, 0)
>>>
>>> println(a)
>>>
>>> nothing
>>>
>>> end
>>>
>>>
>>> julia> testGlobal()
>> ERROR: UndefVarError: a not defined
>>  in testGlobal() at /xxx/testType.jl:4
>>
>> 3) not calling the first println, the code works, but the global a is not
>> set:
>>
>> a=0
>>>
>>> Dicta = Dict{Int,Int}()
>>>
>>> function testGlobal()
>>>
>>> # println(a)
>>>
>>> merge!(Dicta, Dict(1=>1))
>>>
>>> a=get(Dicta, 1, 0)
>>>
>>> println(a)
>>>
>>> nothing
>>>
>>> end
>>>
>>>
>>>
>> julia> testGlobal()
>> 1
>>
>>
>>


Re: [julia-users] Implementing compilers or interpreters in Julia?

2016-09-22 Thread Isaiah Norton
Any answer if going to be fairly opinion-based. That said, here are some
opinions :)

some advantages:
- interactive development
- performance
- Cxx.jl, if you want to target LLVM
- multiple dispatch

some disadvantages:
- lack of ML-style pattern-matching -- though multiple dispatch on node
type covers much of how this is used (and
https://github.com/kmsquire/Match.jl might help too)
- for an interpreter, lack of static compilation (your language would need
to carry along Julia and LLVM machinery)

Some examples of compiler-related-things written in Julia:

- Intel's ParallelAccerator compiler:
https://github.com/IntelLabs/ParallelAccelerator.jl
- Julia's type inference:
https://github.com/JuliaLang/julia/blob/master/base/inference.jl
- Julia parser: https://github.com/JuliaLang/JuliaParser.jl

- "green-fairy", an abstract interpreter:
https://github.com/carnaval/green-fairy
   (MS thesis project, see PDF report. still WIP)
- parsers for object-file formats (DWARF, COFF, MachO, ...):
https://github.com/Keno?tab=repositories=source
- https://github.com/JuliaGPU/CUDAnative.jl
- https://github.com/swadey/LispSyntax.jl
- https://github.com/andrewcooke/ParserCombinator.jl
- https://github.com/abeschneider/PEGParser.jl
- BF interpreter: https://github.com/johnmyleswhite/Brainfuck.jl



On Wed, Sep 21, 2016 at 8:29 PM, Sebastian the Eight <
imperator.ozymand...@gmail.com> wrote:

> I'm curious how adept Julia is for writing compilers/interpreters? It's
> fairly easy to find example toy compilers for most other languages (C,
> OCaml, Ruby etc), but Julia seems to be lacking any examples except for its
> own. I was wondering if there are advantages or disadvantages for using
> Julia in this way, other than being a relatively new language


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

2016-09-14 Thread Isaiah Norton
See https://github.com/JuliaLang/julia/issues/18466#issuecomment-246713799

On Wed, Sep 14, 2016 at 6:13 PM, Dan  wrote:

> Maybe the following is the form you are looking for:
>
> julia> decomplexify{T}(::Type{Complex{T}}) = T
> decomplexify (generic function with 1 method)
>
>
> julia> type bar{S,T}
>sum::S
>sumsqr::T
>function bar(s,ss)
>if typeof(ss) != decomplexify(typeof(s))
>error("Yaiks")
>end
>new(s,ss)
>end
>end
>
>
> julia> bar{Complex{Float64},Float64}(1.5+2.0im,1.0)
> bar{Complex{Float64},Float64}(1.5 + 2.0im,1.0)
>
>
> julia> bar{S,T}(x::S,y::T) = bar{S,T}(x,y)
> bar{S,T}
>
>
> julia> bar(1.5+2.0im,1.0)
> bar{Complex{Float64},Float64}(1.5 + 2.0im,1.0)
>
>
> The outer constructor is necessary to get the last line working. The inner
> constructor basically maintains the constraint between S and T of: T ==
> Complex{S}.
>
> On Wednesday, September 14, 2016 at 3:38:53 PM UTC-4, Neal Becker wrote:
>>
>> Evan Fields wrote:
>>
>> > How about something like the following?
>> >
>> > type CT{T}
>> > ctsum::Complex{T}
>> > ctsumsq::T
>> > end
>> >
>>
>> I'm aware that it's easier to make the type parameter the scalar type,
>> allowing writing as you show, but as a learning exercise I'd like to know
>> how Julia would go the other way.
>>
>> In c++ this would be done with template metaprogramming, but as Julia
>> claims
>> to have types as 1st class objects, I thought there should be some
>> elegant
>> way to do this.
>>
>> That is, given T is Complex{U}, I need the type U so I can write
>> ctsumsq::U
>>
>>


Re: [julia-users] How to use jl_call1 with a struct argument?

2016-09-09 Thread Isaiah Norton
(Disregard my suggestion about `Ptr{TestType}`, `jl_call1` only takes boxed
arguments so that won't work)

The problem is that the passed argument type does not match any available
method (because it isn't actually passed a julia type at all) so `jl_call1`
silently gives up. The `jl_call*` methods are in TRY/CATCH blocks to
prevent spilling errors across the API, and they do not print error
messages.

The following example works, it's not really efficient but it does
demonstrate type construction from C:

#include 
#include 
using namespace std;

struct TestType {
double a;
double b;
};
int main(int argc, char *argv[])
{
TestType A, *ret;
A.a=2.;
A.b=3.;
jl_init("/Users/inorton/git/jl71/usr/lib/");
jl_load("TestArg.jl");
jl_value_t * mod = (jl_value_t*)jl_eval_string("TestArg");

   // construct a TestType instance

jl_value_t* jl_A =
jl_new_struct((jl_datatype_t*)jl_get_function((jl_module_t*)mod,
"TestType"),
 jl_box_float64(A.a),
jl_box_float64(A.b));

jl_function_t * func = jl_get_function((jl_module_t*)mod,"TestFunc");
jl_call1(func, jl_A);

jl_atexit_hook(0);
return 0;
}


Using the embedding API requires a substantial depth of understanding of ,
including stack vs heap and argument passing, as well as dynamic language
concepts such as boxing, and rooting. The embedding section of the manual
is designed to provide an overview, but ultimately you are going to have to
read and grok the Julia source to get every little detail.

On Fri, Sep 9, 2016 at 9:23 AM, K leo  wrote:

> Isaiah,
>
> Thanks for the reply.
>
> I tried your advice A, i.e. "change to an immutable on julia side, and
> change function signature to  'Ptr{TestType}'", and the code behaves the
> same as before, i.e. it compiles OK and runs OK but does not show the
> output of the println in the function.
>
> I guess at the moment what puzzles me is not whether the data get passed
> correctly (because I am not trying to access the data yet), but why the one
> single statement in the Julia function is not executed.  That function
> appears to be taken correctly because if I change the function name in
> Julia then there is a core dump.  Any thoughts?
>
> I have not yet tried your advice B as I am not too clear about it.
>
>
> On Friday, September 9, 2016 at 8:52:30 PM UTC+8, Isaiah wrote:
>>
>> In c, 'struct TestType' is plain old data, not a Julia type (jl_value_t).
>> Either change to an immutable on julia side, and change function signature
>> to  'Ptr{TestType}'; or allocate a 'jl_value_t*' with the correct type tag, 
>> and
>> set the fields.
>>
>> On Friday, September 9, 2016, K leo  wrote:
>>
>>> I tried the following, it compiles OK and runs OK, but it appears the
>>> julia function is not called (because there is no output from the println
>>> statement).  What is wrong?
>>>
>>> #include 
 #include 
 using namespace std;
 struct TestType {
 double a;
 double b;
 };
 int main(int argc, char *argv[])
 {
 TestType A, *ret;
 A.a=2.;
 A.b=3.;
 jl_init(NULL);
 jl_load("TestArg.jl");
 jl_value_t * mod = (jl_value_t*)jl_eval_string("TestArg");
 jl_function_t * func = jl_get_function((jl_module_t*)
 mod,"TestFunc");
 jl_call1(func, (jl_value_t *));
 jl_atexit_hook(0);
 return 0;
 }
 # TestArg.jl
 module TestArg
 type TestType
 a::Float64
 b::Float64
 end
 function TestFunc(data::TestType)
 println("in TestArg.TestFunc ")
 end
 end
>>>
>>>
>>>


Re: [julia-users] How to use jl_call1 with a struct argument?

2016-09-09 Thread Isaiah Norton
In c, 'struct TestType' is plain old data, not a Julia type (jl_value_t).
Either change to an immutable on julia side, and change function signature
to  'Ptr{TestType}'; or allocate a 'jl_value_t*' with the correct type tag, and
set the fields.

On Friday, September 9, 2016, K leo  wrote:

> I tried the following, it compiles OK and runs OK, but it appears the
> julia function is not called (because there is no output from the println
> statement).  What is wrong?
>
> #include 
>> #include 
>> using namespace std;
>> struct TestType {
>> double a;
>> double b;
>> };
>> int main(int argc, char *argv[])
>> {
>> TestType A, *ret;
>> A.a=2.;
>> A.b=3.;
>> jl_init(NULL);
>> jl_load("TestArg.jl");
>> jl_value_t * mod = (jl_value_t*)jl_eval_string("TestArg");
>> jl_function_t * func = jl_get_function((jl_module_t*)mod,"TestFunc");
>> jl_call1(func, (jl_value_t *));
>> jl_atexit_hook(0);
>> return 0;
>> }
>> # TestArg.jl
>> module TestArg
>> type TestType
>> a::Float64
>> b::Float64
>> end
>> function TestFunc(data::TestType)
>> println("in TestArg.TestFunc ")
>> end
>> end
>
>
>


Re: [julia-users] calling julia functions in C++

2016-09-08 Thread Isaiah Norton
As far as I can tell, everything in this thread is covered in the embedding
section [http://docs.julialang.org/en/latest/manual/embedding/] except for
the note about `jl_load` usage. Care to make a pull-request? ;)

On Thu, Sep 8, 2016 at 12:09 AM, K leo  wrote:

> Thank you.  This just saved my day.  Can someone please put this intro in
> the documentation?
>
> On Tuesday, June 30, 2015 at 11:58:18 PM UTC+8, Isaiah wrote:
>>
>> try
>>
>> jl_value_t * mod = (jl_value_t*)jl_eval_string("mymodule");
>> jl_function_t * func = jl_get_function((jl_module_t*)mod,"myfunction");
>>
>> (jl_new_module creates a new module -- that's not what you want, because
>> the module containing your function is created when you eval "yourfile.jl")
>>
>> On Tue, Jun 30, 2015 at 11:47 AM, Kostas Tavlaridis-Gyparakis <
>> kostas.t...@gmail.com> wrote:
>>
>>> Ok, so first of all thanks a lot for all the help so far.
>>> So, now I try to follow the instructions and I write the following three
>>> lines of code inside C++:
>>>
>>>  jl_load("mymodule.jl");
>>> jl_value_t * mod = jl_eval_string("mymodule");
>>> jl_function_t * func = jl_get_function(jl_new_module(
>>> mod),"myfunction");
>>>
>>> (the jl file and the module itself have the same name in this case
>>> mymodule)
>>> But I do receive the following 2 errors when Eclipse compiles:
>>>
>>> 1) error: invalid conversion from ‘void*’ to ‘jl_value_t* {aka
>>> _jl_value_t*}’ [-fpermissive] (this is referring to  jl_value_t * mod =
>>> jl_eval_string("mymodule");)
>>>
>>> 2) error: cannot convert ‘jl_value_t* {aka _jl_value_t*}’ to ‘jl_sym_t*
>>> {aka _jl_sym_t*}’ for argument ‘1’ to ‘jl_module_t*
>>> jl_new_module(jl_sym_t*)’ (this referring to jl_function_t * func =
>>> jl_get_function(jl_new_module(mod),"myfunction");)
>>>
>>>
>>> >No problem, no stupid questions. However, I would suggest that you
>>> might want to spend some time getting really familiar with Julia by itself,
>>> before trying to use the embedding API. It might save a lot of time in the
>>> long run.
>>>
>>> You are totally right on this, I am just trying first to check if it is
>>> doable to do some combinations between C++ in Eclipse and Julia (such as
>>> using functions written in
>>> Julia inside a C++ routine etc), because I am planning to connect a
>>> large-scale C++ with Julia and before starting to studying Julia in full
>>> detail and start writing proper
>>> code was thinking to do some small tests in connectivity between the
>>> two. But it turns out that I don't know some very basic things to finish
>>> this task.
>>>
>>>
>>> On Tuesday, June 30, 2015 at 5:32:53 PM UTC+2, Isaiah wrote:

 Sorry but I am not sure what you mean and how to "*evaluate your .jl
> file defining the module first*"?


 Ok, say you have a file:

 ```
 module mymod
 function foo() ... end
 end
 ```

 At the Julia prompt you would do:

 julia> include("myfile.jl")

 And then you have the module `mymod` available in the global namespace.
 In C you can do the equivalent with:

 `jl_load("myfile.jl")`

 I am really new to Julia so maybe the question sounds really stupid,
> sorry for that


 No problem, no stupid questions. However, I would suggest that you
 might want to spend some time getting really familiar with Julia by itself,
 before trying to use the embedding API. It might save a lot of time in the
 long run.

 On Tue, Jun 30, 2015 at 10:54 AM, Kostas Tavlaridis-Gyparakis <
 kostas.t...@gmail.com> wrote:

> Sorry but I am not sure what you mean and how to "*evaluate your .jl
> file defining the module first*"?
> (I am really new to Julia so maybe the question sounds really stupid,
> sorry for that)
>
>
>
>
>
> On Tuesday, June 30, 2015 at 4:28:54 PM UTC+2, Isaiah wrote:
>>
>> `jl_new_module` creates a new module. You must evaluate your .jl file
>> defining the module first, then to get a reference to the module do:
>>
>> `jl_value_t* mod = jl_eval_string("MyModName");
>>
>> Then you can pass "mod" as the argument to `jl_get_function`.
>>
>> On Tue, Jun 30, 2015 at 10:16 AM, Kostas Tavlaridis-Gyparakis <
>> kostas.t...@gmail.com> wrote:
>>
>>> Hello,
>>> I am trying to write some function in Julia which I will be able to
>>> call inside my C++ projects in Eclipse.
>>> In the documentation there is this
>>> 
>>> example on how to call a function of julia from an existing module.
>>> So, what I have done was to create my own module where inside I
>>> included my function and then my
>>> understanding is that I should be using "jl_new_module(jl_sym_t
>>> *name);" instead of jl_base_module.
>>> But I am not sure (in case my assumption that 

Re: [julia-users] Re: successfully built julia using windows subsystem for linux but getting '`: not enough memory (ENOMEM) when trying to use Compat

2016-08-24 Thread Isaiah Norton
Please see
https://groups.google.com/d/msg/julia-users/K3AKvD6EYT8/vGcchWRlAgAJ

On Wed, Aug 24, 2016 at 5:26 PM, mmh  wrote:

>
> versioninfo()
> Julia Version 0.6.0-dev.390
> Commit 3ab4d76 (2016-08-24 18:18 UTC)
> Platform Info:
>   System: Linux (x86_64-linux-gnu)
>   CPU: unknown
>   WORD_SIZE: 64
>   BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
>   LAPACK: libopenblas64_
>   LIBM: libopenlibm
>   LLVM: libLLVM-3.7.1 (ORCJIT, haswell)
>
>


Re: [julia-users] Re: Windows subsystem for Linux

2016-08-03 Thread Isaiah Norton
Tony has been trying this too and has reported upstream. See
https://github.com/Microsoft/BashOnWindows/issues/118#issuecomment-208249048

On Wed, Aug 3, 2016 at 12:29 PM, 'Bill Hart' via julia-users <
julia-users@googlegroups.com> wrote:

> In fact, both the old and new versions of libuv seem to fail their test
> suites on WSL. I imagine they tie into the system calls pretty tightly and
> Microsoft may not have implemented them all fully or correctly as of the
> moment. Perhaps things will improve with the next release of WSL.
>
> Bill.
>
> On Wednesday, 3 August 2016 18:23:53 UTC+2, Bill Hart wrote:
>>
>> Julia seems to use an old version of libuv. People have noticed that
>> libuv has problems on WSL. I don't know whether these have been fixed or
>> not. I couldn't find any specific tickets for it. But perhaps the latest
>> libuv works on WSL and maybe that points to a possible solution.
>>
>> Bill.
>>
>


Re: [julia-users] Does a wrapper for gmtime exist

2016-07-27 Thread Isaiah Norton
IIUC, the Julia DateTime object represents UT (milli)seconds, and has
converters to/from human-readable dates and local time.

http://docs.julialang.org/en/release-0.4/manual/dates/

On Wed, Jul 27, 2016 at 9:32 AM, Andrew Gibb  wrote:

> Hi,
>
> I'm writing a module for dealing with video timing. The C++ code I'm using
> as a basis uses gmtime to convert seconds into y:m:d.etc. Does anyone know
> if this functionality is exposed in Julia anywhere?
>
> I realise I could handle this myself with ccall, I just wanted to check to
> see if I could avoid duplicating effort.
>
> Thanks
>
> Andy
>


Re: [julia-users] Using Julia with Epsilon (EMACS)

2016-07-26 Thread Isaiah Norton
>
> The same command in the command prompt works fine.
> Has anyone seen this, or something like it, before?
>

https://github.com/JuliaLang/julia/issues/14776 looks similar. Worth
another thumbs-up at least ...

On Tue, Jul 26, 2016 at 12:31 PM, Gary Mallard 
wrote:

> I am trying to get Julia up and running under my normal editor.  The
> editor (epsilon) is an EMACS for Windows (and other platforms) and normally
> any program that runs as a console application runs under epsilon and
> epsilon captures all output text.  However when I try Julia I get the
> following:
>
> C:\Users\WGM\AppData\Local\Julia-0.4.6\bin>julia-debug.exe
> ERROR: MethodError: `convert` has no method matching
> convert(::Type{Base.TTY}, ::Base.PipeEndpoint)
> This may have arisen from a call to the constructor Base.TTY(...),
> since type constructors fall back to convert methods.
> Closest candidates are:
>   Base.TTY(::Any)
>   call{T}(::Type{T}, ::Any)
>   convert{T}(::Type{T}, !Matched::T)
>   ...
>  in call at Terminals.jl:116
>  in _start at client.jl:388
>
> The same command in the command prompt works fine.
> Has anyone seen this, or something like it, before?
>
> Thanks,
> Gary
>
>


Re: [julia-users] Re: isdefined with local variables

2016-07-20 Thread Isaiah Norton
>
> ​I want the behavior seen in t with the macro. t2 with `isdefined` has the
> "wrong" and counterintuitive behavior.​


Please see the documentation for `isdefined`, which mentions that
`isdefined` only works at module scope:

http://docs.julialang.org/en/release-0.4/stdlib/base/#Base.isdefined

As far as why `isdefined` and `eval` don't do what you want (work in local
scope): this is an explicit design decision. See explanation here:

https://github.com/JuliaLang/julia/issues/2386#issuecomment-13966397

On Wed, Jul 20, 2016 at 9:10 AM, Christopher Rinderspacher <
crind...@gmail.com> wrote:

> Here's a session demonstrating what I see:
>
> julia> macro isDefined(x)
>   return :(defined = true; try eval($x); catch e; defined =
> !isa(e,UndefVarError); end; defined)
>end
>
> julia> function t()
>   if !@isDefined(x)
>println("x is not defined")
>   end
>   x = 1
>   if !@isDefined(x)
>   println("x should be defined.")
>   end
>end
> t (generic function with 1 method)
>
> julia> t()
> x is not defined
>
> julia> function t2()
>   if !isdefined(:x)
>  println("x is not defined")
>   end
>   x = 1
>   if !isdefined(:x)
>  println("x is defined, but `isdefined` doesn't recognize it.")
>   end
>end
> t2 (generic function with 1 method)
>
> julia> t2()
> x is not defined
> x is defined, but `isdefined` doesn't recognize it.
>
> julia>
>
> ​I want the behavior seen in t with the macro. t2 with `isdefined` has the
> "wrong" and counterintuitive behavior.​
> Since the macro is a product of trial and error (no pun intended), I can
> only rationalize its behavior.
>
>
>
> On Wed, Jul 20, 2016 at 8:37 AM, Yichao Yu <yyc1...@gmail.com> wrote:
>
>> On Wed, Jul 20, 2016 at 8:32 AM, Christopher Rinderspacher
>> <crind...@gmail.com> wrote:
>> > My solution right now is a macro
>> >
>> > macro isDefined(x)
>> >return :(defined = true; try eval($x); catch e; defined =
>> > isa(e,UndefVarError); end; defined)
>>
>> It's unclear what you are trying to do here. The eval is likely a
>> no-op or not doing what you want. `$x` should probably be escaped.
>>
>> > end
>> >
>> > I find this to be very clunky, but it works for my limited test cases.
>> >
>> >> All compile-time undefined bindings become a runtime lookup from the
>> >> enclosing (i.e. module) scope. The undefined error means that this
>> lookup
>> >> failed.
>> >
>> > If that is so, what is the function I can call to determine whether my
>> > variable is in scope? `isdefined` is definitely _not_ that function.
>> How do
>> > I need to call that function from Julia? Your explanation is not a
>> solution
>> > to my problem.
>> >
>> >
>> >
>> > On Wed, Jul 20, 2016 at 12:01 AM, Yichao Yu <yyc1...@gmail.com> wrote:
>> >>
>> >> On Tue, Jul 19, 2016 at 11:54 PM, Isaiah Norton <
>> isaiah.nor...@gmail.com>
>> >> wrote:
>> >> > Creating variables dynamically at local scope is not possible (if you
>> >> > are
>> >> > calling `eval` inside a function: it does not work like that!)
>> >> >
>> >> >> Since the runtime can determine that the local variable is
>> undefined as
>> >> >> evidenced by an appropriate error
>> >> >
>> >> >
>> >> > All compile-time undefined bindings become a runtime lookup from the
>> >> > enclosing (i.e. module) scope. The undefined error means that this
>> >> > lookup
>> >> > failed.
>> >>
>> >> We do have local only variables that can be undefined.
>> >>
>> >> >
>> >> >
>> >> > On Tue, Jul 19, 2016 at 10:43 PM, Christopher Rinderspacher
>> >> > <crind...@gmail.com> wrote:
>> >> >>
>> >> >> I, too, would like to be able to check whether local variables are
>> >> >> defined. In my case, I am parsing a file that doesn't allow
>> >> >> redefinition of
>> >> >> a field. The natural way to do this is to check whether I've
>> previously
>> >> >> assigned a variable with the content.
>> >> >>
>> >> >> Th

Re: [julia-users] Re: isdefined with local variables

2016-07-19 Thread Isaiah Norton
Creating variables dynamically at local scope is not possible (if you are
calling `eval` inside a function: it does not work like that!)

Since the runtime can determine that the local variable is undefined as
> evidenced by an appropriate error


All compile-time undefined bindings become a runtime lookup from the
enclosing (i.e. module) scope. The undefined error means that this lookup
failed.


On Tue, Jul 19, 2016 at 10:43 PM, Christopher Rinderspacher <
crind...@gmail.com> wrote:

> I, too, would like to be able to check whether local variables are
> defined. In my case, I am parsing a file that doesn't allow redefinition of
> a field. The natural way to do this is to check whether I've previously
> assigned a variable with the content.
>
> The fact that isdefined only looks at the module scope is really
> irrelevant to my use case. Since the runtime can determine that the local
> variable is undefined as evidenced by an appropriate error, I wish I could
> do the same within my function without some clunky try ... catch mehcanism.
>
>
> On Monday, May 11, 2015 at 7:31:06 PM UTC-4, Juha Heiskala wrote:
>>
>>  Hello,
>>
>> Am I missing something or doesn't isdefined detect local variables of a
>> function?
>>
>>
>> julia> foo()= begin bar=1; isdefined(current_module(), :bar); end
>> foo (generic function with 1 method)
>>
>> julia> foo()
>> false
>>
>> Best Regards,
>>
>> Juha
>>
>> julia version 0.3.5
>>
>> julia> versioninfo()
>> Julia Version 0.3.5
>> Commit a05f87b* (2015-01-08 22:33 UTC)
>> Platform Info:
>>   System: Linux (x86_64-linux-gnu)
>>   CPU: Intel(R) Core(TM) i7-3667U CPU @ 2.00GHz
>>   WORD_SIZE: 64
>>   BLAS: libopenblas (NO_LAPACK NO_LAPACKE DYNAMIC_ARCH NO_AFFINITY)
>>   LAPACK: liblapack.so.3
>>   LIBM: libopenlibm
>>   LLVM: libLLVM-3.3
>>
>


Re: [julia-users] What does Base.box mean in code_warntype?

2016-07-19 Thread Isaiah Norton
On Fri, Jul 15, 2016 at 5:02 PM, David Anthoff  wrote:

>
> What do these mean?
>

http://stackoverflow.com/questions/13055/what-is-boxing-and-unboxing-and-what-are-the-trade-offs


> And should I be worried, i.e. is this an indication that something slow
> might be going on?
>

Boxing requires allocation and can block optimizations, so it can be a
problem to have box/unbox at points where you might hope to be working with
contiguous primitive values (such as within a loop). But there's really no
hard-and-fast rule.


> --
>
> David Anthoff
>
> University of California, Berkeley
>
>
>
> http://www.david-anthoff.com
>
>
>


Re: [julia-users] Call C functions from file.cpp in a shared library from Julia

2016-07-13 Thread Isaiah Norton
If you use .cpp the compiler decides to compile it as C++ and so uses
name-mangling (https://en.wikipedia.org/wiki/Name_mangling#C.2B.2B). If you
want to compile as C++ but have ccall'able signatures, put an `extern "C" {
... }` around the C entrypoints.

FYI: you can debug this kind of question by using `nm` to see the list of
exports (on linux and mac, there are similar tools on windows).

On Wed, Jul 13, 2016 at 8:14 AM, Guillaume 
wrote:

> Hi !
>
> I'm trying to implement an interface between Julia and a program
> developping in C++. For that I would like to use ccall from Julia to call C
> functions which call C++ functions of my program in a shared library. When
> I create a shared library from a file.c it works but when I create a shared
> library with the same function in a file.cpp and call it from Julia I've
> got this error :
> *ERROR: ccall: could not find function hello in library libtest*
> * in anonymous at no file*
>
> I really don't understand why the simple fact to name my file "file.cpp"
> instead of "file.c" change something. In both case I generate a "file.o"
> with -fPIC option and put it in a shared library... Can someone explain me
> the reason please?
>
> Guillaume
>
>


Re: [julia-users] Why two (qualified) macro invocation forms?

2016-07-10 Thread Isaiah Norton
>
> I don't think any of these requires a specific form.
>

Ok.

Anyway, this was originally put in place to allow calling un-exported
macros:
https://github.com/JuliaLang/julia/issues/1107

Question raised here:
https://github.com/JuliaLang/julia/issues/1769#issuecomment-231596892


>
> > On Sun, Jul 10, 2016 at 12:46 AM, Isaiah Norton <isaiah.nor...@gmail.com
> >
> > wrote:
> >>
> >> I believe the second form may be vestigial at this point, and agree that
> >> it is inconsistent. The usage is non-existent in base (except for one
> test),
> >> but there is at least one issue for which the current work-around
> requires
> >> the second form: https://github.com/JuliaLang/julia/issues/14208
> >>
> >> On Fri, Jul 8, 2016 at 4:52 AM, Hans-Peter <gcha...@gmail.com> wrote:
> >>>
> >>> Acc. to the manual [1] either `Mod.@mac` or `@Mod.mac` can be used.
> What
> >>> is the reason for the second form? Is it necessary to make me (other
> >>> people?) think which form should be used preferably? Maybe there is a
> reason
> >>> (didn't find something in issues/maillist) but with my current
> knowledge I'd
> >>> propose to 'push' the first form and deprecate the second.
> >>>
> >>> Both forms are not used often (in Julia source and my v0.4 packages).
> The
> >>> first (Mod.@mac) form is more frequent.
> >>>
> >>> ~~~
> >>> find ~/.julia/v0.4/ -name "*.jl" | xargs ack " \w+\.@\w+"
> >>> find ~/.julia/v0.4/ -name "*.jl" | xargs ack " @\w+\."
> >>> ~~~
> >>>
> >>> Sometimes both forms are being used, e.g.:
> >>>
> >>> ... v0.4/DataArrays/src/DataArrays.jl
> >>> 78:Base.@deprecate removeNA dropna
> >>> ... v0.4/DataArrays/test/reducedim.jl
> >>> 12:Base.Test.@test DataArrays._any(bits, i, j) == v
> >>>
> >>> vs.
> >>>
> >>> ... v0.4/Calculus/src/Calculus.jl
> >>> 62:@Base.deprecate integrate(f,a,b) quadgk(f,a,b)[1]
> >>> ... v0.4/Distributions/test/truncate.jl
> >>> 70:@Base.Test.test_approx_eq_eps(logpdf(d, x), lp, sqrt(eps()))
> >>>
> >>>
> >>> [1]
> >>>
> http://docs.julialang.org/en/latest/manual/modules/#namespace-miscellanea
> >>
> >>
> >
>


Re: [julia-users] Why two (qualified) macro invocation forms?

2016-07-09 Thread Isaiah Norton
(also a work-around for a symbol hygiene issue:
https://github.com/JuliaLang/julia/issues/15085)

On Sun, Jul 10, 2016 at 12:46 AM, Isaiah Norton <isaiah.nor...@gmail.com>
wrote:

> I believe the second form may be vestigial at this point, and agree that
> it is inconsistent. The usage is non-existent in base (except for one
> test), but there is at least one issue for which the current work-around
> requires the second form: https://github.com/JuliaLang/julia/issues/14208
>
> On Fri, Jul 8, 2016 at 4:52 AM, Hans-Peter <gcha...@gmail.com> wrote:
>
>> Acc. to the manual [1] either `Mod.@mac` or `@Mod.mac` can be used. What
>> is the reason for the second form? Is it necessary to make me (other
>> people?) think which form should be used preferably? Maybe there is a
>> reason (didn't find something in issues/maillist) but with my current
>> knowledge I'd propose to 'push' the first form and deprecate the second.
>>
>> Both forms are not used often (in Julia source and my v0.4 packages). The
>> first (Mod.@mac) form is more frequent.
>>
>> ~~~
>> find ~/.julia/v0.4/ -name "*.jl" | xargs ack " \w+\.@\w+"
>> find ~/.julia/v0.4/ -name "*.jl" | xargs ack " @\w+\."
>> ~~~
>>
>> Sometimes both forms are being used, e.g.:
>>
>> ... v0.4/DataArrays/src/DataArrays.jl
>> 78:Base.@deprecate removeNA dropna
>> ... v0.4/DataArrays/test/reducedim.jl
>> 12:Base.Test.@test DataArrays._any(bits, i, j) == v
>>
>> vs.
>>
>> ... v0.4/Calculus/src/Calculus.jl
>> 62:@Base.deprecate integrate(f,a,b) quadgk(f,a,b)[1]
>> ... v0.4/Distributions/test/truncate.jl
>> 70:@Base.Test.test_approx_eq_eps(logpdf(d, x), lp, sqrt(eps()))
>>
>>
>> [1]
>> http://docs.julialang.org/en/latest/manual/modules/#namespace-miscellanea
>>
>
>


Re: [julia-users] Why two (qualified) macro invocation forms?

2016-07-09 Thread Isaiah Norton
I believe the second form may be vestigial at this point, and agree that it
is inconsistent. The usage is non-existent in base (except for one test),
but there is at least one issue for which the current work-around requires
the second form: https://github.com/JuliaLang/julia/issues/14208

On Fri, Jul 8, 2016 at 4:52 AM, Hans-Peter  wrote:

> Acc. to the manual [1] either `Mod.@mac` or `@Mod.mac` can be used. What
> is the reason for the second form? Is it necessary to make me (other
> people?) think which form should be used preferably? Maybe there is a
> reason (didn't find something in issues/maillist) but with my current
> knowledge I'd propose to 'push' the first form and deprecate the second.
>
> Both forms are not used often (in Julia source and my v0.4 packages). The
> first (Mod.@mac) form is more frequent.
>
> ~~~
> find ~/.julia/v0.4/ -name "*.jl" | xargs ack " \w+\.@\w+"
> find ~/.julia/v0.4/ -name "*.jl" | xargs ack " @\w+\."
> ~~~
>
> Sometimes both forms are being used, e.g.:
>
> ... v0.4/DataArrays/src/DataArrays.jl
> 78:Base.@deprecate removeNA dropna
> ... v0.4/DataArrays/test/reducedim.jl
> 12:Base.Test.@test DataArrays._any(bits, i, j) == v
>
> vs.
>
> ... v0.4/Calculus/src/Calculus.jl
> 62:@Base.deprecate integrate(f,a,b) quadgk(f,a,b)[1]
> ... v0.4/Distributions/test/truncate.jl
> 70:@Base.Test.test_approx_eq_eps(logpdf(d, x), lp, sqrt(eps()))
>
>
> [1]
> http://docs.julialang.org/en/latest/manual/modules/#namespace-miscellanea
>


Re: [julia-users] string interpolation for memory object name

2016-07-09 Thread Isaiah Norton
Technically you *can* do the following:


@eval $(Symbol("logit_", outcomes[i], "_unadjusted")) = [... fix the RHS
too]

But IMHO programming like this is kind of discouraged. (for one thing,
undisciplined use can lead to big speed traps). An alternative is to hold a
string-addressable handle to results in a dictionary or a DataFrame.




On Fri, Jul 8, 2016 at 3:26 PM, Min-Woong Sohn  wrote:

> I am trying to run logistic regressions on a bunch of dependent variables
> like so:
>
> using GLM
>
> outcomes = [:mort30d, :readmit, :reoper, :sar]
>
> for i in 1:length(outcomes)
> logit_$(outcomes[i])_unadjusted = glm($(outcomes[i]) ~ race, puf,
> Binomial(),LogitLink())
> dump(coef(logit_$(outcomes[i])_unadjusted))
> end
>
> Here I want to run the logistic regression four times, once for each
> outcome, and save the return values into four different memory objects:
>
> logit_mort30d_unadjusted
> logit_readmit_unadjusted
> etc
>
> The glm... part works fine with the interpolation, $(outcomes[i]), but I
> cannot create the memory objects in this way. Is there any way I can use
> some method of string interpolation to this end?
>
>
>
>


Re: [julia-users] Enter permanently on a REPL mode

2016-07-09 Thread Isaiah Norton
https://github.com/JuliaLang/julia/issues/14081

On Fri, Jul 8, 2016 at 10:07 AM, Iagoba Apellaniz <
iagoba.apella...@gmail.com> wrote:

> I would prefer to enter permanently on a REPL mode like `shell`. See
> RCall.jl packages behavior. Once you are on R you have to hit `backspace`
> to get back to `julia>` which of course should be the default RELP mode.
>
> *julia*>[;]
>
>
> *shell*> ls
>
> DesktopDocuments  Downloads
>
> JuliaProjects  Music  Pictures
>
> *shell*> cd JuliaProjects
>
> ...
>
> *shell*> [backspace]
>
>
> *julia*>
>
>
> I have seen also some of issues about REPL modes.
>
> I don't know about the implementation of this but... for accessing any
> available REPL
>
> *ju**lia*> [?]
>
>
>
> *help?*>
>
> [;] shell [0] julia [1] python [2] R [3]    <- This would be a kind
> of menu to chose from. That it disappears whenever some action is
> performed.
>
>
> Alternatively, still special characters instead of numbers could be
> displayed if that's the trendy option.
>
>
> *help?*>
> [;] shell [<-] julia [*] python [$] R [?] help  <- I invented the symbols
> used
>
>
>
> As more packages are installed more REPLs can be available tho show to the
> user when help mode is chosen.
>
>
>
>
>


Re: [julia-users] Could someone explain @static?

2016-07-09 Thread Isaiah Norton
This is mostly for precompilation and library use. When compiling a shared
library we can't rely on a runtime check if the compiler is not available
(and trying to compile both branches is inefficient and might be impossible
for the reason in the help section).

On Saturday, July 9, 2016, feza  wrote:

> The docs read
>
> @static()
>
> Partially evaluates an expression at parse time.
>
> For example, @static is_windows() ? foo : bar will evaluateis_windows() and
> insert either foo or bar into the expression. This is useful in cases
> where a construct would be invalid on other platforms, such as a ccall to
> a non-existent function.
>
> My understanding at a very top level is that julia code is first parsed,
> macro expanded, then compiled.
>
> Now why is it important for this to be handled at parse time? I don't
> really understand the following `This is useful in cases where a
> construct would be invalid on other platforms, such as a ccall to a
> non-existent function.`
>
> Why couldn't  a simple
>
> ` if is_windows(); foo; else; bar; end `
>
>  work and why do we need @static?
>


Re: [julia-users] ccall doesnt work in embed.c example

2016-07-09 Thread Isaiah Norton
The symbol exists but is not exported (t vs T). Try adding DLLEXPORT in
front of the function declaration. On 0.4 it appears to have had a
Windows-only export declaration.

On Saturday, July 9, 2016, Sourabh Chadha  wrote:

> I am new to Julia and have been trying to use ccall to call C functions in
> embedded mode but i am unable to even successfully run the example
> embedding.c that is in package. The example file define a
> function my_c_sqrt and then tries to call it using jl_eval_string("println(
> ccall( :my_c_sqrt, Float64, (Float64,), 2.0 ) )");. This doesnt work and if
> i trace the issue by printing errors i get ErrorException("ccall: could not
> find function my_c_sqrt").
>
> I have tried checking eveything. nm on the executble gives this.
> nm ../usr/bin/embedding | grep my
> 00601d80 t __frame_dummy_init_array_entry
> 00400f60 t frame_dummy
> 00400f90 t my_c_sqrt
>
> so the symbol is available.
>
> I am running Red Hat Enterprise Linux Workstation release 7.0 (Maipo) nd
> hve compiled julia Version 0.4.6 from scratch.
>
> any help would be really appreciated
>
>


Re: [julia-users] Pkg "threadsafe" or interprocess mutex package

2016-07-08 Thread Isaiah Norton
Libuv mostly abstracts away the differences, but named pipes are released
automatically when the last handle closes, whereas named sockets are
associated with an inode and must be checked/cleaned-up manually.

On Thu, Jul 7, 2016 at 10:24 PM, David Anthoff <anth...@berkeley.edu> wrote:

> Yes, seems to work.
>
>
>
> You need to use a different naming scheme on Windows, namely ``
> .\\pipe\\yourname``, but then one can just use the normal julia
> socket functions for it. In particular, if one process listens on such a
> named pipe, calling ``listen`` from another process with the same name will
> give an error.
>
>
>
> Actually, are there really different semantics? I haven’t come across any
> when I use such a named pipe on Windows for inter-process communication via
> the julia socket API…
>
>
>
> *From:* julia-users@googlegroups.com [mailto:julia-users@googlegroups.com]
> *On Behalf Of *Isaiah Norton
> *Sent:* Thursday, July 7, 2016 5:34 PM
>
> *To:* julia-users@googlegroups.com
> *Subject:* Re: [julia-users] Pkg "threadsafe" or interprocess mutex
> package
>
>
>
> Does that work on Windows? I briefly tried earlier and it didn't seem to
> work. IIUC Windows doesn't support Unix-style named sockets. (it does have
> named pipes, but the semantics are a bit different)
>
>
>
> On Thu, Jul 7, 2016 at 1:07 PM, David Anthoff <anth...@berkeley.edu>
> wrote:
>
> Ah, I had actually come up with the same solution that Amit suggested in
> #7176 and am using a named socket as a lock, that seems to work for now.
>
>
>
> I’m also running into another race condition with respect to precompile, I
> opened a new issue for that:
>
> https://github.com/JuliaLang/julia/issues/17320
>
>
>
> Cheers,
>
> David
>
>
>
> *From:* julia-users@googlegroups.com [mailto:julia-users@googlegroups.com]
> *On Behalf Of *Isaiah Norton
> *Sent:* Thursday, July 7, 2016 6:52 AM
> *To:* julia-users@googlegroups.com
> *Subject:* Re: [julia-users] Pkg "threadsafe" or interprocess mutex
> package
>
>
>
> See
>
> https://github.com/JuliaLang/julia/issues/5622 and
>
> https://github.com/JuliaLang/julia/issues/7176
>
>
>
> If you are on Windows, LockFileEx is reliable and you could ccall it
> yourself. Probably simpler to handle the problem at a higher level for now
> though (i.e. run one script that checks installation *before* launching
> your analysis jobs).
>
>
>
>
>
> On Wed, Jul 6, 2016 at 5:09 PM, David Anthoff <anth...@berkeley.edu>
> wrote:
>
> Hi,
>
>
>
> I have a script that is using some packages. The script is set up such
> that if the package it is trying to use is not installed, it will do a
> ``Pkg.add`` to add the package before ``using`` it.
>
>
>
> This script is triggered by a third process, and it might be triggered
> multiple times simultaneously, i.e. multiple instances of julia might run
> the same script at the same time. Therefore the second julia instance might
> issue the same ``Pkg.add`` command as the first instance, while the first
> instance is not done with the ``Pkg.add`` yet.
>
>
>
> I assume the package manager per se is not set up to handle that situation
> gracefully?
>
>
>
> If not, is there some package that allows me to have something like a
> mutex/lock between my julia processes, so that I can guard the code section
> that fiddles with packages and make sure only one julia instance at a time
> runs that code?
>
>
>
> Thanks,
>
> David
>
>
>
> --
>
> David Anthoff
>
> University of California, Berkeley
>
>
>
> http://www.david-anthoff.com
>
>
>
>
>
>
>


Re: [julia-users] Pkg "threadsafe" or interprocess mutex package

2016-07-07 Thread Isaiah Norton
Does that work on Windows? I briefly tried earlier and it didn't seem to
work. IIUC Windows doesn't support Unix-style named sockets. (it does have
named pipes, but the semantics are a bit different)

On Thu, Jul 7, 2016 at 1:07 PM, David Anthoff <anth...@berkeley.edu> wrote:

> Ah, I had actually come up with the same solution that Amit suggested in
> #7176 and am using a named socket as a lock, that seems to work for now.
>
>
>
> I’m also running into another race condition with respect to precompile, I
> opened a new issue for that:
>
> https://github.com/JuliaLang/julia/issues/17320
>
>
>
> Cheers,
>
> David
>
>
>
> *From:* julia-users@googlegroups.com [mailto:julia-users@googlegroups.com]
> *On Behalf Of *Isaiah Norton
> *Sent:* Thursday, July 7, 2016 6:52 AM
> *To:* julia-users@googlegroups.com
> *Subject:* Re: [julia-users] Pkg "threadsafe" or interprocess mutex
> package
>
>
>
> See
>
> https://github.com/JuliaLang/julia/issues/5622 and
>
> https://github.com/JuliaLang/julia/issues/7176
>
>
>
> If you are on Windows, LockFileEx is reliable and you could ccall it
> yourself. Probably simpler to handle the problem at a higher level for now
> though (i.e. run one script that checks installation *before* launching
> your analysis jobs).
>
>
>
>
>
> On Wed, Jul 6, 2016 at 5:09 PM, David Anthoff <anth...@berkeley.edu>
> wrote:
>
> Hi,
>
>
>
> I have a script that is using some packages. The script is set up such
> that if the package it is trying to use is not installed, it will do a
> ``Pkg.add`` to add the package before ``using`` it.
>
>
>
> This script is triggered by a third process, and it might be triggered
> multiple times simultaneously, i.e. multiple instances of julia might run
> the same script at the same time. Therefore the second julia instance might
> issue the same ``Pkg.add`` command as the first instance, while the first
> instance is not done with the ``Pkg.add`` yet.
>
>
>
> I assume the package manager per se is not set up to handle that situation
> gracefully?
>
>
>
> If not, is there some package that allows me to have something like a
> mutex/lock between my julia processes, so that I can guard the code section
> that fiddles with packages and make sure only one julia instance at a time
> runs that code?
>
>
>
> Thanks,
>
> David
>
>
>
> --
>
> David Anthoff
>
> University of California, Berkeley
>
>
>
> http://www.david-anthoff.com
>
>
>
>
>


Re: [julia-users] How to profile a module?

2016-07-07 Thread Isaiah Norton
http://docs.julialang.org/en/latest/manual/profile/#accumulation-and-clearing

If you want to save results from a single session, use `savedprof =
copy(Profile.fetch())` and print with `Profile.print(savedprof)`.

On Thu, Jul 7, 2016 at 11:07 AM,  wrote:

> Thanks. Can I do profiling on B.g() and A.f() simultaneously? For example,
>
> import A, B
> @profile p = B.g()
> @profile A.f(p)
>
>
> Then when I do `Profile.print()`, which `Profile` is it? The profile data
> for B.g() or A.f(p)? Is there a way to store the data separately into two
> different Profile variables?
>
>
> On Thursday, July 7, 2016 at 2:39:30 PM UTC+1, Isaiah wrote:
>>
>> Yes
>>
>> On Thu, Jul 7, 2016 at 9:31 AM,  wrote:
>>
>>> Do you mean that in the test file I do something like this?
>>>
>>> import A, B
>>> p = B.g()
>>> @profile A.f(p)
>>>
>>>
>>>
>>>
>>> On Thursday, July 7, 2016 at 1:22:24 PM UTC+1, Isaiah wrote:

 Profile the calls to B.g and A.f separately.

 On Thursday, July 7, 2016,  wrote:

> Bump up.
>

>>


Re: [julia-users] When Julia v1.0 will be released?

2016-07-07 Thread Isaiah Norton
>
> I knew that.
>

The goal is 2017, if development community considers it to be ready.

I don't mean to be too glib, but I fail to see how any answer is
particularly actionable; it is certainly not binding.


On Thursday, July 7, 2016 at 10:14:24 AM UTC-4, Isaiah wrote:
>>
>> When it is ready.
>>
>> On Thu, Jul 7, 2016 at 10:07 AM, Hisham Assi  wrote:
>>
>>> I really like Julia (I am using it for my publications & thesis), but I
>>> noticed that the versions are not really backward compatible. I am still ok
>>> with that, but  many other people are waiting for the mature, stable
>>> version  (1.0) to start using Julia. So, when Julia v1.0 will be
>>> released?
>>>
>>
>>


Re: [julia-users] When Julia v1.0 will be released?

2016-07-07 Thread Isaiah Norton
When it is ready.

On Thu, Jul 7, 2016 at 10:07 AM, Hisham Assi  wrote:

> I really like Julia (I am using it for my publications & thesis), but I
> noticed that the versions are not really backward compatible. I am still ok
> with that, but  many other people are waiting for the mature, stable
> version  (1.0) to start using Julia. So, when Julia v1.0 will be released?
>


Re: [julia-users] Pkg "threadsafe" or interprocess mutex package

2016-07-07 Thread Isaiah Norton
See
https://github.com/JuliaLang/julia/issues/5622 and
https://github.com/JuliaLang/julia/issues/7176

If you are on Windows, LockFileEx is reliable and you could ccall it
yourself. Probably simpler to handle the problem at a higher level for now
though (i.e. run one script that checks installation *before* launching
your analysis jobs).


On Wed, Jul 6, 2016 at 5:09 PM, David Anthoff  wrote:

> Hi,
>
>
>
> I have a script that is using some packages. The script is set up such
> that if the package it is trying to use is not installed, it will do a
> ``Pkg.add`` to add the package before ``using`` it.
>
>
>
> This script is triggered by a third process, and it might be triggered
> multiple times simultaneously, i.e. multiple instances of julia might run
> the same script at the same time. Therefore the second julia instance might
> issue the same ``Pkg.add`` command as the first instance, while the first
> instance is not done with the ``Pkg.add`` yet.
>
>
>
> I assume the package manager per se is not set up to handle that situation
> gracefully?
>
>
>
> If not, is there some package that allows me to have something like a
> mutex/lock between my julia processes, so that I can guard the code section
> that fiddles with packages and make sure only one julia instance at a time
> runs that code?
>
>
>
> Thanks,
>
> David
>
>
>
> --
>
> David Anthoff
>
> University of California, Berkeley
>
>
>
> http://www.david-anthoff.com
>
>
>


Re: [julia-users] How to profile a module?

2016-07-07 Thread Isaiah Norton
Yes

On Thu, Jul 7, 2016 at 9:31 AM,  wrote:

> Do you mean that in the test file I do something like this?
>
> import A, B
> p = B.g()
> @profile A.f(p)
>
>
>
>
> On Thursday, July 7, 2016 at 1:22:24 PM UTC+1, Isaiah wrote:
>>
>> Profile the calls to B.g and A.f separately.
>>
>> On Thursday, July 7, 2016,  wrote:
>>
>>> Bump up.
>>>
>>


Re: [julia-users] list kw args

2016-07-07 Thread Isaiah Norton
>
> And finally, can this code run on current stable version?
>

No.

For future reference (i.e. when 0.5 is released), you can run:

Base.kwarg_decl(methods(f).ms[1].sig, typeof(methods(f).mt.kwsorter))


On Wed, Jul 6, 2016 at 5:38 PM, Leonardo <maxsa...@gmail.com> wrote:

> Thanks, I've found function:
> kwarg_decl(sig::ANY, kwtype::DataType)
> in develop version (not stable version 0.4.6)
>
> But I cannot understand (also following code flow) what is kwtype
> parameter and how kwarg_decl can be called.
>
> And finally, can this code run on current stable version?
>
> Many thanks again
>
> Leonardo
>
>
>
> Il 06/07/2016 15:32, Isaiah Norton ha scritto:
>
>> The implementation is not trivial to follow, but have a look at
>> `kwarg_decl` in `base/methodshow.jl`.
>>
>> This might be a reasonable thing to have as a helper function, if you
>> want to open a GitHub issue to discuss.
>>
>> (Be warned: you will pay a severe performance penalty if you try to use
>> reflection for some kind of runtime meta-dispatch)
>>
>> On Wed, Jul 6, 2016 at 1:41 AM, Leonardo <maxsa...@gmail.com
>> <mailto:maxsa...@gmail.com>> wrote:
>>
>> There is a way to list all keyword arguments defined by a function f?
>> (a sort of reflection?)
>>
>> e.g.;
>>
>> /having
>> /function f(i::Int; a::AbstractString=0, b::Float64=0.0)
>>   ...
>> end
>>
>> /how to return a, b from f?
>> /
>>
>> Many thanks in advance
>>
>> Leonardo
>>
>>
>>


Re: [julia-users] How to profile a module?

2016-07-07 Thread Isaiah Norton
Profile the calls to B.g and A.f separately.

On Thursday, July 7, 2016,  wrote:

> Bump up.
>


Re: [julia-users] More on Macros

2016-07-06 Thread Isaiah Norton
No worries; if you are missing S-expressions too much, you might enjoy
playing with https://github.com/swadey/LispSyntax.jl

On Wed, Jul 6, 2016 at 12:41 AM, Rangarajan Krishnamoorthy <
ranga@gmail.com> wrote:

> That was very helpful. Thanks for your patience.
>
> -Rangarajan
>
>
> On Wednesday, July 6, 2016 at 9:39:56 AM UTC+5:30, Isaiah wrote:
>>
>> Is there a clear language spec for macros, or is it still evolving? I
>>> understand that relying on implementation to learn a language feature can
>>> be risky.
>>>
>>
>> There is no formal spec that I am aware of. However, I don't remember any
>> substantive changes except for this one in 0.5-dev:
>>
>> https://github.com/JuliaLang/julia/pull/14563
>>
>>
>> (which is fairly minor: macro-methods can now dispatch on number of
>> arguments IIUC)
>>
>> There's one major proposal related to hygiene; no final decision on
>> whether/when it will be accepted:
>>
>> https://github.com/JuliaLang/julia/pull/6910 (rebased in #10940)
>>
>>
>> When I call retMacro(), I get an error saying "Macro definition not
>>> allowed in local scope". What I tried to do in my earlier example (pre
>>> post) is to hide the macro definition in a string and then parse and
>>> evaluate it to get the same effect as the above function. Obviously the
>>> behaviour is different.
>>>
>>
>> Your earlier example works because `eval` always operates at
>> module-global scope. Macro definitions, type declarations, and a handful of
>> other things, are only allowed at global scope.
>>
>>
>>> Does it mean every macro is its own type?
>>>
>>
>> Yes (and further, on 0.5-dev all functions are internally represented as
>> types)
>>
>>
>>> Should it not be a predefined type like "macro" (just as there is type
>>> for functions)? If macros are "pre-processed away", then there can't be an
>>> independent existence for them?
>>>
>>
>> Here's some more detail that will hopefully clarify. Macro invocations
>> are represented as :macrocall expressions:
>>
>> julia> parse("@foo(1, 2)") |> dump
>> Expr
>>   head: Symbol macrocall
>>   args: Array{Any}((3,))
>> 1: Symbol @foo
>> 2: Int64 1
>> 3: Int64 2
>>   typ: Any
>>
>>
>> The first step of lowering is to walk the AST to find all :macrocall
>> expressions, call the corresponding macro-function -- exactly the function
>> returned by `eval(Symbol("@foo"))` -- with the appropriate arguments, and
>> paste the result expression into the AST. (see
>> http://docs.julialang.org/en/latest/devdocs/julia/ for some more details)
>>
>> Finally, in 0.5-dev, if "returnMacro()" works as expected, then calling
>>> myMacro("1+1") should return 2 (and not the parsed structure), isn't it?
>>> The reason is does an additional evaluation?
>>>
>>
>> No, `myMacro` is just a handle to the macro-function, exactly the same as
>> `myMacro(x) = parse(x)`. There is no evaluation of the return expression
>> when directly calling a macro-function.
>>
>>
>> As I had mentioned in my first post, these questions are based on my
>>> experience with Lisp and I am trying to digest the differences, if any.
>>>
>>> -Rangarajan
>>>
>>> On Tuesday, July 5, 2016 at 9:35:52 PM UTC+5:30, Isaiah wrote:
>>>
 Anonymous functions are a bit incomplete / not-fully-integrated in 0.4,
 and I think this falls out as a consequence.

 You can simulate the result you want with:

 julia> function returnMacro()
  eval(parse("""
  macro myMacro(anexpr)
parse(anexpr)
  end
  """))
  eval(symbol("@myMacro"))
end

 julia> mymacro = returnMacro()
 (anonymous function)

 julia> mymacro("1+1")
 :(1 + 1)

 However, there have been significant improvements to anonymous
 functions in the nightly (0.5-dev), and the result is what you expect:

 julia> function returnMacro()
  eval(parse("""
  macro myMacro(anexpr)
parse(anexpr)
  end
  """))
end
 returnMacro (generic function with 1 method)

 julia> mymacro = returnMacro()
 @myMacro (macro with 1 method)

 julia> typeof(mymacro)
 #@myMacro

 julia> mymacro("1+1")
 :(1 + 1)

 That said, `mymacro` here is purely a function handle -- totally
 identical to writing `mymacro(expr) = parse(expr)`. There is no special
 behavior.

 (are you trying to do something specific?)

 On Tue, Jul 5, 2016 at 11:04 AM, Rangarajan Krishnamoorthy <
 rang...@gmail.com> wrote:

> Consider this function:
>
> function returnMacro()
>   eval(parse("""
>   macro myMacro(anexpr)
> parse(anexpr)
>   end
>   """))
> end
>
> I assign the function's result to a variable:
> mymacro = returnMacro()
>
> Then, typeof(mymacro) returns "Void". Is this correct? Because macros
> are parse time entities, wouldn't it be better for 

Re: [julia-users] list kw args

2016-07-06 Thread Isaiah Norton
The implementation is not trivial to follow, but have a look at
`kwarg_decl` in `base/methodshow.jl`.

This might be a reasonable thing to have as a helper function, if you want
to open a GitHub issue to discuss.

(Be warned: you will pay a severe performance penalty if you try to use
reflection for some kind of runtime meta-dispatch)

On Wed, Jul 6, 2016 at 1:41 AM, Leonardo  wrote:

> There is a way to list all keyword arguments defined by a function f?
> (a sort of reflection?)
>
> e.g.;
>
>
> *having*function f(i::Int; a::AbstractString=0, b::Float64=0.0)
>   ...
> end
>
>
> *how to return a, b from f?*
>
> Many thanks in advance
>
> Leonardo
>
>


Re: [julia-users] More on Macros

2016-07-05 Thread Isaiah Norton
>
> Is there a clear language spec for macros, or is it still evolving? I
> understand that relying on implementation to learn a language feature can
> be risky.
>

There is no formal spec that I am aware of. However, I don't remember any
substantive changes except for this one in 0.5-dev:

https://github.com/JuliaLang/julia/pull/14563


(which is fairly minor: macro-methods can now dispatch on number of
arguments IIUC)

There's one major proposal related to hygiene; no final decision on
whether/when it will be accepted:

https://github.com/JuliaLang/julia/pull/6910 (rebased in #10940)


When I call retMacro(), I get an error saying "Macro definition not allowed
> in local scope". What I tried to do in my earlier example (pre post) is to
> hide the macro definition in a string and then parse and evaluate it to get
> the same effect as the above function. Obviously the behaviour is
> different.
>

Your earlier example works because `eval` always operates at module-global
scope. Macro definitions, type declarations, and a handful of other things,
are only allowed at global scope.


> Does it mean every macro is its own type?
>

Yes (and further, on 0.5-dev all functions are internally represented as
types)


> Should it not be a predefined type like "macro" (just as there is type for
> functions)? If macros are "pre-processed away", then there can't be an
> independent existence for them?
>

Here's some more detail that will hopefully clarify. Macro invocations are
represented as :macrocall expressions:

julia> parse("@foo(1, 2)") |> dump
Expr
  head: Symbol macrocall
  args: Array{Any}((3,))
1: Symbol @foo
2: Int64 1
3: Int64 2
  typ: Any


The first step of lowering is to walk the AST to find all :macrocall
expressions, call the corresponding macro-function -- exactly the function
returned by `eval(Symbol("@foo"))` -- with the appropriate arguments, and
paste the result expression into the AST. (see
http://docs.julialang.org/en/latest/devdocs/julia/ for some more details)

Finally, in 0.5-dev, if "returnMacro()" works as expected, then calling
> myMacro("1+1") should return 2 (and not the parsed structure), isn't it?
> The reason is does an additional evaluation?
>

No, `myMacro` is just a handle to the macro-function, exactly the same as
`myMacro(x) = parse(x)`. There is no evaluation of the return expression
when directly calling a macro-function.


As I had mentioned in my first post, these questions are based on my
> experience with Lisp and I am trying to digest the differences, if any.
>
> -Rangarajan
>
> On Tuesday, July 5, 2016 at 9:35:52 PM UTC+5:30, Isaiah wrote:
>
>> Anonymous functions are a bit incomplete / not-fully-integrated in 0.4,
>> and I think this falls out as a consequence.
>>
>> You can simulate the result you want with:
>>
>> julia> function returnMacro()
>>  eval(parse("""
>>  macro myMacro(anexpr)
>>parse(anexpr)
>>  end
>>  """))
>>  eval(symbol("@myMacro"))
>>end
>>
>> julia> mymacro = returnMacro()
>> (anonymous function)
>>
>> julia> mymacro("1+1")
>> :(1 + 1)
>>
>> However, there have been significant improvements to anonymous functions
>> in the nightly (0.5-dev), and the result is what you expect:
>>
>> julia> function returnMacro()
>>  eval(parse("""
>>  macro myMacro(anexpr)
>>parse(anexpr)
>>  end
>>  """))
>>end
>> returnMacro (generic function with 1 method)
>>
>> julia> mymacro = returnMacro()
>> @myMacro (macro with 1 method)
>>
>> julia> typeof(mymacro)
>> #@myMacro
>>
>> julia> mymacro("1+1")
>> :(1 + 1)
>>
>> That said, `mymacro` here is purely a function handle -- totally
>> identical to writing `mymacro(expr) = parse(expr)`. There is no special
>> behavior.
>>
>> (are you trying to do something specific?)
>>
>> On Tue, Jul 5, 2016 at 11:04 AM, Rangarajan Krishnamoorthy <
>> rang...@gmail.com> wrote:
>>
>>> Consider this function:
>>>
>>> function returnMacro()
>>>   eval(parse("""
>>>   macro myMacro(anexpr)
>>> parse(anexpr)
>>>   end
>>>   """))
>>> end
>>>
>>> I assign the function's result to a variable:
>>> mymacro = returnMacro()
>>>
>>> Then, typeof(mymacro) returns "Void". Is this correct? Because macros
>>> are parse time entities, wouldn't it be better for "eval" to raise some
>>> sort of exception?
>>>
>>> -Rangarajan
>>>
>>
>>


Re: [julia-users] More on Macros

2016-07-05 Thread Isaiah Norton
Anonymous functions are a bit incomplete / not-fully-integrated in 0.4, and
I think this falls out as a consequence.

You can simulate the result you want with:

julia> function returnMacro()
 eval(parse("""
 macro myMacro(anexpr)
   parse(anexpr)
 end
 """))
 eval(symbol("@myMacro"))
   end

julia> mymacro = returnMacro()
(anonymous function)

julia> mymacro("1+1")
:(1 + 1)

However, there have been significant improvements to anonymous functions in
the nightly (0.5-dev), and the result is what you expect:

julia> function returnMacro()
 eval(parse("""
 macro myMacro(anexpr)
   parse(anexpr)
 end
 """))
   end
returnMacro (generic function with 1 method)

julia> mymacro = returnMacro()
@myMacro (macro with 1 method)

julia> typeof(mymacro)
#@myMacro

julia> mymacro("1+1")
:(1 + 1)

That said, `mymacro` here is purely a function handle -- totally identical
to writing `mymacro(expr) = parse(expr)`. There is no special behavior.

(are you trying to do something specific?)

On Tue, Jul 5, 2016 at 11:04 AM, Rangarajan Krishnamoorthy <
ranga@gmail.com> wrote:

> Consider this function:
>
> function returnMacro()
>   eval(parse("""
>   macro myMacro(anexpr)
> parse(anexpr)
>   end
>   """))
> end
>
> I assign the function's result to a variable:
> mymacro = returnMacro()
>
> Then, typeof(mymacro) returns "Void". Is this correct? Because macros are
> parse time entities, wouldn't it be better for "eval" to raise some sort of
> exception?
>
> -Rangarajan
>


Re: [julia-users] Question on Macros

2016-07-05 Thread Isaiah Norton
>
> I am new to Julia, but have a background in Lisp and other languages. I
> found it interesting that Julia supports Macros similar to Lisp. A few
> questions:
>

Welcome. You may be interested in this recent talk:
https://www.youtube.com/watch?v=dK3zRXhrFZY


> 1) Julia uses "@" operator as a prefix to a macro call. Why is this needed
> at all? Why not call it like a normal function without the prefix?
>

Design decision to let people know that something different is happening.


> 2) Consider this macro:
> macro myEval(anexpr)
> parse(anexpr)
> end
> After defining this macro, the expression:
> typeof(myEval)
> triggers an "undefVarError". Why? The symbol "myEval" is a macro
> definition. There must be some type for it?
> (If this is a "Function", then type is returned correctly.)
>

 Use:

julia> typeof(eval(Symbol("@myEval")))
#@myEval


3) Julia allows me to define both a function and a macro to have the same
> name. Isn't this likely to lead to subtle mistakes?
>

You can't call them by the same name, see above. In practice this hasn't
been a problem (I think most people avoid name duplication as a matter of
style, unless there is a good justification to do otherwise).


>
> Regards,
> Rangarajan
>


Re: [julia-users] testing intrument Automation

2016-07-02 Thread Isaiah Norton
I haven't seen any libraries for GPIB or Visa. The NIDAQ library might be
of interest (https://github.com/JaneliaSciComp/NIDAQ.jl).

Depending on your latency requirements, you could potentially use PyVISA
via PyCall.jl (https://github.com/stevengj/PyCall.jl).

On Fri, Jul 1, 2016 at 10:08 AM, Yared Melese  wrote:

> Can Julia be used as instrument test Automation? Send commands via GPIB to
> different instruments
>
> If so is there Visa library for it?
>
> Thanks
> Yared
>


Re: [julia-users] Re: Fixing JavaCall for 0.5: generating methods which call ccall

2016-06-30 Thread Isaiah Norton
https://github.com/JuliaLang/julia/issues/17219

On Thu, Jun 30, 2016 at 6:28 PM, Isaiah Norton <isaiah.nor...@gmail.com>
wrote:

> This is a lowering bug. I have a repro and a patch that fixes it (Pkg.test
> JavaCall succeeds), but may have unforeseen side-effects. Will file an
> issue or a PR soon once I do a bit more testing.
>
> (there's also a work-around: use a different variable name for the ccall
> ptr argument)
>
> On Wed, Jun 29, 2016 at 6:43 PM, Avik Sengupta <avik.sengu...@gmail.com>
> wrote:
>
>> I'd like to bump this and see if anyone has any ideas. I do not see what
>> could change.
>>
>> To provide some background, if it would help,
>>
>> The code referenced by Eric runs at load time, to generate a set of
>> methods (called _jcall) for different types of inputs. For each such input
>> type, a method definition is created within a quote block, and then that
>> quote block is eval-ed to actually define the method.
>>
>> The reason separate functions are defined, rather than doing this by
>> dynamic dispatch, is that a key part of the method is a ccall. The argument
>> types to the ccall needs to be determined at compile time, and hence in
>> this case we define a separate method for each input type, rather than use
>> dynamic dispatch. This code works correctly in 0.4 (and 0.3), but fails
>> with an UndefRefError in 0.5.
>>
>> Any ideas?
>>
>> Thanks!
>> -
>> Avik
>>
>>
>> On Friday, 24 June 2016 19:50:01 UTC+1, Eric Davies wrote:
>>>
>>> I have an intuition that this should be possible because the ccall
>>> depends on the input types, but I can't figure out how to make it work.
>>> I've tried a few things and they all seem to result in an UndefVarError or
>>> UndefRefError.
>>>
>>> I want to turn this:
>>> for (x, y, z) in [ (:jboolean, :(jnifunc.CallBooleanMethodA), :(jnifunc.
>>> CallStaticBooleanMethodA)),
>>>   (:jchar, :(jnifunc.CallCharMethodA), :(jnifunc.
>>> CallStaticCharMethodA)),
>>>   (:jbyte, :(jnifunc.CallByteMethodA), :(jnifunc.
>>> CallStaticByteMethodA)),
>>>   (:jshort, :(jnifunc.CallShortMethodA), :(jnifunc.
>>> CallStaticShortMethodA)),
>>>   (:jint, :(jnifunc.CallIntMethodA), :(jnifunc.
>>> CallStaticIntMethodA)),
>>>   (:jlong, :(jnifunc.CallLongMethodA), :(jnifunc.
>>> CallStaticLongMethodA)),
>>>   (:jfloat, :(jnifunc.CallFloatMethodA), :(jnifunc.
>>> CallStaticFloatMethodA)),
>>>   (:jdouble, :(jnifunc.CallDoubleMethodA), :(jnifunc.
>>> CallStaticDoubleMethodA)),
>>>   (:Void, :(jnifunc.CallVoidMethodA), :(jnifunc.
>>> CallStaticVoidMethodA)) ]
>>> m = quote
>>> function _jcall(obj,  jmethodId::Ptr{Void}, callmethod::Ptr{Void
>>> }, rettype::Type{$(x)}, argtypes::Tuple, args... )
>>> if callmethod == C_NULL #!
>>> callmethod = ifelse( typeof(obj)<:JavaObject, $y , $z )
>>> end
>>> @assert callmethod != C_NULL
>>> @assert jmethodId != C_NULL
>>> if(isnull(obj)); error("Attempt to call method on Java NULL"
>>> ); end
>>> savedArgs, convertedArgs = convert_args(argtypes, args...)
>>> result = ccall(callmethod, $x , (Ptr{JNIEnv}, Ptr{Void}, Ptr
>>> {Void}, Ptr{Void}), penv, obj.ptr, jmethodId, convertedArgs)
>>> if result==C_NULL; geterror(); end
>>> if result == nothing; return; end
>>> return convert_result(rettype, result)
>>> end
>>> end
>>> eval(m)
>>> end
>>>
>>> Into something that works on 0.5. Code located here:
>>> https://github.com/invenia/JavaCall.jl/blob/compat-0.5/src/core.jl#L196
>>>
>>> I've learned tricks to deal with the 0.4 function eval pattern, but they
>>> don't seem to work with ccall, which is a special feature that requires
>>> some arguments to be static and known at compile time.
>>>
>>> Anyone have any tips?
>>>
>>> Thanks,
>>> Eric
>>>
>>
>


Re: [julia-users] Re: Fixing JavaCall for 0.5: generating methods which call ccall

2016-06-30 Thread Isaiah Norton
This is a lowering bug. I have a repro and a patch that fixes it (Pkg.test
JavaCall succeeds), but may have unforeseen side-effects. Will file an
issue or a PR soon once I do a bit more testing.

(there's also a work-around: use a different variable name for the ccall
ptr argument)

On Wed, Jun 29, 2016 at 6:43 PM, Avik Sengupta 
wrote:

> I'd like to bump this and see if anyone has any ideas. I do not see what
> could change.
>
> To provide some background, if it would help,
>
> The code referenced by Eric runs at load time, to generate a set of
> methods (called _jcall) for different types of inputs. For each such input
> type, a method definition is created within a quote block, and then that
> quote block is eval-ed to actually define the method.
>
> The reason separate functions are defined, rather than doing this by
> dynamic dispatch, is that a key part of the method is a ccall. The argument
> types to the ccall needs to be determined at compile time, and hence in
> this case we define a separate method for each input type, rather than use
> dynamic dispatch. This code works correctly in 0.4 (and 0.3), but fails
> with an UndefRefError in 0.5.
>
> Any ideas?
>
> Thanks!
> -
> Avik
>
>
> On Friday, 24 June 2016 19:50:01 UTC+1, Eric Davies wrote:
>>
>> I have an intuition that this should be possible because the ccall
>> depends on the input types, but I can't figure out how to make it work.
>> I've tried a few things and they all seem to result in an UndefVarError or
>> UndefRefError.
>>
>> I want to turn this:
>> for (x, y, z) in [ (:jboolean, :(jnifunc.CallBooleanMethodA), :(jnifunc.
>> CallStaticBooleanMethodA)),
>>   (:jchar, :(jnifunc.CallCharMethodA), :(jnifunc.
>> CallStaticCharMethodA)),
>>   (:jbyte, :(jnifunc.CallByteMethodA), :(jnifunc.
>> CallStaticByteMethodA)),
>>   (:jshort, :(jnifunc.CallShortMethodA), :(jnifunc.
>> CallStaticShortMethodA)),
>>   (:jint, :(jnifunc.CallIntMethodA), :(jnifunc.
>> CallStaticIntMethodA)),
>>   (:jlong, :(jnifunc.CallLongMethodA), :(jnifunc.
>> CallStaticLongMethodA)),
>>   (:jfloat, :(jnifunc.CallFloatMethodA), :(jnifunc.
>> CallStaticFloatMethodA)),
>>   (:jdouble, :(jnifunc.CallDoubleMethodA), :(jnifunc.
>> CallStaticDoubleMethodA)),
>>   (:Void, :(jnifunc.CallVoidMethodA), :(jnifunc.
>> CallStaticVoidMethodA)) ]
>> m = quote
>> function _jcall(obj,  jmethodId::Ptr{Void}, callmethod::Ptr{Void
>> }, rettype::Type{$(x)}, argtypes::Tuple, args... )
>> if callmethod == C_NULL #!
>> callmethod = ifelse( typeof(obj)<:JavaObject, $y , $z )
>> end
>> @assert callmethod != C_NULL
>> @assert jmethodId != C_NULL
>> if(isnull(obj)); error("Attempt to call method on Java NULL"
>> ); end
>> savedArgs, convertedArgs = convert_args(argtypes, args...)
>> result = ccall(callmethod, $x , (Ptr{JNIEnv}, Ptr{Void}, Ptr{
>> Void}, Ptr{Void}), penv, obj.ptr, jmethodId, convertedArgs)
>> if result==C_NULL; geterror(); end
>> if result == nothing; return; end
>> return convert_result(rettype, result)
>> end
>> end
>> eval(m)
>> end
>>
>> Into something that works on 0.5. Code located here:
>> https://github.com/invenia/JavaCall.jl/blob/compat-0.5/src/core.jl#L196
>>
>> I've learned tricks to deal with the 0.4 function eval pattern, but they
>> don't seem to work with ccall, which is a special feature that requires
>> some arguments to be static and known at compile time.
>>
>> Anyone have any tips?
>>
>> Thanks,
>> Eric
>>
>


Re: [julia-users] errors using packages in parallel

2016-06-03 Thread Isaiah Norton
Try `@everywhere using Dierckx`

On Thu, Jun 2, 2016 at 3:49 PM, Ethan Anderes 
wrote:

> I’m looking for help setting up a parallel job spread across different
> servers. I would like to use my laptop as the master node. I’m getting
> errors when using packages and I’m not sure what I’m doing wrong. Any
> help would be appreciated
>
>_
>_   _ _(_)_ |  A fresh approach to technical computing
>   (_) | (_) (_)|  Documentation: http://docs.julialang.org
>_ _   _| |_  __ _   |  Type "?help" for help.
>   | | | | | | |/ _` |  |
>   | | |_| | | | (_| |  |  Version 0.4.6-pre+36 (2016-05-19 19:11 UTC)
>  _/ |\__'_|_|_|\__'_|  |  Commit 1e3e941 (14 days old release-0.4)
> |__/   |  x86_64-apple-darwin15.5.0
>
> julia> machines = ["ande...@xxx.xxx.edu", "ande...@yyy.yyy.edu"]
> 2-element Array{ASCIIString,1}:
>  "ande...@xxx.xxx.edu"
>  "ande...@yyy.yyy.edu"
>
> julia> addprocs(
>machines,
>tunnel=true,
>dir="/home/anderes/",
>exename="/usr/local/bin/julia",
>topology=:master_slave,
>)
> 2-element Array{Int64,1}:
>  2
>  3
>
> julia> using  Dierckx
> WARNING: node state is inconsistent: node 2 failed to load cache from 
> /Users/ethananderes/.julia/lib/v0.4/Dierckx.ji
> WARNING: node state is inconsistent: node 3 failed to load cache from 
> /Users/ethananderes/.julia/lib/v0.4/Dierckx.ji
>
> julia> @everywhere spl = Dierckx.Spline1D([1., 2., 3.], [1., 2., 3.], k=2)
> ERROR: On worker 2:
> ERROR: On worker 2:
> UndefVarError: Dierckx not defined
>  in eval at ./sysimg.jl:14
>  in anonymous at multi.jl:1394
>  in anonymous at multi.jl:923
>  in run_work_thunk at multi.jl:661
>  [inlined code] from multi.jl:923
>  in anonymous at task.jl:63
>  in remotecall_fetch at multi.jl:747
>  in remotecall_fetch at multi.jl:750
>  in anonymous at multi.jl:1396
>
> ...and 1 other exceptions.
>
>  in sync_end at ./task.jl:413
>  in anonymous at multi.jl:1405
>
> Note: I’ve got Dierckx installed and working on the remote servers (not
> even sure if that is needed). Also, as you can see below, I can get the
> code to run fine if I have the workers on my local machine.
>
> julia> addprocs(2, topology=:master_slave)
> 2-element Array{Int64,1}:
>  2
>  3
>
> julia> using  Dierckx
>
> julia> @everywhere spl = Dierckx.Spline1D([1., 2., 3.], [1., 2., 3.], k=2)
>
> Thanks!
> ​
>


Re: [julia-users] Is the master algorithm on the roadmap?

2016-06-02 Thread Isaiah Norton
This is not a forum for wildly off-topic, speculative discussion.

Take this to Reddit, Hacker News, etc.


On Thu, Jun 2, 2016 at 10:01 PM, Kevin Liu  wrote:

> I am wondering how Julia fits in with the unified tribes
>
> mashable.com/2016/06/01/bill-gates-ai-code-conference/#8VmBFjIiYOqJ
>
> https://www.youtube.com/watch?v=B8J4uefCQMc
>


Re: [julia-users] Can we make Julia develop itself?

2016-06-02 Thread Isaiah Norton
I'm going to assume that there is a terminology barrier here...

My interpretation of the question is: can we directly translate programs
from other languages?

This is called source to source translation or compilation (
https://en.m.wikipedia.org/wiki/Source-to-source_compiler), and the answer
is "it's complicated".

Kevin, hopefully that terminology will give you a better start on looking
for answers -- stackoverflow probably has better treatments than I can give
regarding why this is difficult.

On Thursday, June 2, 2016, Kevin Liu  wrote:

> Is there an answer somewhere here?
>
> On Thursday, June 2, 2016 at 7:54:04 PM UTC-3, Kristoffer Carlsson wrote:
>>
>> Someone taught you wrong.
>
>


Re: [julia-users] Reading from a TCP socket with quasi-continuous data transfer

2016-06-01 Thread Isaiah Norton
On Wednesday, June 1, 2016, Joshua Jones <
highly.creative.pseudo...@gmail.com> wrote:

>
>>>1. I've read (here and elsewhere) that Julia does an implicit block
>>>while waiting for data. Is there a workaround?
>>>
>>> Do the blocking read asynchronously in a task. For network I/O (but not
>> file), `read` will only block at the task level. To end the read, `close`
>> the socket from another task.
>>
>
> Only a call to @async eof(conn) works as an asynchronous task; I'm not
> sure how that's going to help, except in the REPL. Any other attempt to
> read remotely is a segmentation fault that destroys the worker.
>
> *Example (test function)*
> @everywhere readSL(conn) = begin
>   while true
> eof(conn)
> tmp = read(conn.buffer, UInt8, 520)
>   end
> end
>
>
>
> Test call
> julia> remotecall(6, readSL, conn);
>
> julia>
> signal (11): Segmentation fault
> uv_read_start at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown
> line)
> start_reading at stream.jl:850
> wait_readnb at stream.jl:373
> eof at stream.jl:96
> readSL at none:4
> jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown
> line)
> jl_f_apply at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown
> line)
> anonymous at multi.jl:920
> run_work_thunk at multi.jl:661
> run_work_thunk at multi.jl:670
> jlcall_run_work_thunk_21322 at  (unknown line)
> jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown
> line)
> anonymous at task.jl:58
> unknown function (ip: 0x7f1d162898cc)
> unknown function (ip: (nil))
> Worker 6 terminated.
> ERROR (unhandled task failure): EOFError: read end of file
>  in read at stream.jl:929
>  in message_handler_loop at multi.jl:878
>  in process_tcp_streams at multi.jl:867
>  in anonymous at task.jl:63
>
> Am I doing something fundamentally wrong here?
>

Yes: using multiprocess parallelism instead of tasks. '@everywhere'
executes code on other processes that do not share the same address space
as the head process and cannot access the same socket. See the section on
Tasks in the manual.

(though it probably shouldn't segfault, please file a big about that)


Re: [julia-users] hankelh1(1,z) bug?

2016-05-26 Thread Isaiah Norton
This looks like an issue in the underlying AMOS library from netlib. Both
SciPy and SciLab give the same answer as Julia and also use AMOS. mpmath
and Wolfram Alpha give the correct answer. Possibly a documentation issue
about tolerances in the AMOS implementation, I'm not quite sure.

Issue: https://github.com/JuliaLang/openspecfun/issues/45

On Wed, May 25, 2016 at 2:51 PM, Edmundo Lavia <
sivasadartantasvueltasnosi...@gmail.com> wrote:

> It seems to me that the hankelh1 function ([image: H_\nu(z)]) has a bug
> for small argument values,
> for example:
>
> > hankelh1(1,2e-32)
> 1.9490859162596872e15 - 3.1830988618379058e31im
>
> while
>
> > besselj(1,2e-32) + im*bessely(1,2e-32)
> 1.0e-32 - 3.1830988618379067e31im
>
> Iam using Version 0.5.0-dev+3667 under Fedora Linux 23.
> Cheers,
> E.
>


Re: [julia-users] Reading from a TCP socket with quasi-continuous data transfer

2016-05-26 Thread Isaiah Norton
On Tue, May 24, 2016 at 4:43 PM, Joshua Jones <
highly.creative.pseudo...@gmail.com> wrote:

> Hi,
>
> First post to the group, but I've been coding in Julia for about a year
> now.
>

Welcome!

*Questions*:
>
>1. If I try to read from the TCP buffer, it blocks; CTRL-C seemingly
>can't interrupt. Why?
>
> Appears to be fixed on master, I believe by 
> *https://github.com/JuliaLang/julia/issues/16174
*

julia> s = connect(8880)
TCPSocket(open, 0 bytes waiting)

julia> t = try read(s) catch e println("error occurred"); throw(e) end
^Cerror occurred
ERROR: InterruptException:
 in eval(::Module, ::Any) at ./boot.jl:225
 in macro expansion at ./REPL.jl:92 [inlined]
 in (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:46

julia>



>
>1. I've read (here and elsewhere) that Julia does an implicit block
>while waiting for data. Is there a workaround?
>
> Do the blocking read asynchronously in a task. For network I/O (but not
file), `read` will only block at the task level. To end the read, `close`
the socket from another task.

>
>1. If I *don't* try a read, the connection shows no data waiting. This
>appears unique to Julia; I've tested simultaneous connections with
>identical data requests using C and Python clients; those buffer data while
>Julia shows 0 bytes waiting. Is something fundamentally different about how
>Julia deals with (or shows) buffered data? If so, what?
>
> Are you using `nb_available`? Unfortunately, this is probably one of the
most confusing and poorly-documented functions we have.

https://github.com/JuliaLang/julia/issues/8762
https://github.com/JuliaLang/julia/issues/14624

The tl;dr is that it returns the number of bytes available
(already-buffered) to read *without* making a potentially-blocking call.
Hopefully you can (mostly) avoid needing to use it, by building around
tasks.


Re: Soukromá zpráva ohledně: [julia-users] Re: getindex vs @getindex

2016-05-25 Thread Isaiah Norton
Because a QuoteNode is not the same thing as a symbol:

julia> :x == :(:x)
false
julia> dump(:(:x))
QuoteNode
  value: Symbol x


(please read the metaprogramming documentation to see what tools are
available to help with macro development...)

On Wed, May 25, 2016 at 10:10 AM, Ford Ox  wrote:

> Could somebody smarter than me tell me why this return *false*:
>
> macro  symbolequal(symbol)
>  mysymbol =  :(:x)
>  :($(symbol==mysymbol))
> end
>
> @show  @symbolequal  :x
>
>


Re: [julia-users] I feel that on the syntax level, Julia sacrificed too much elegancy trying to be compatible with textbook math notations

2016-05-24 Thread Isaiah Norton
This has been a point of (extremely) lengthy discussion. See the following
issues for recent improvements and plans, some of which will be in the next
release:

https://github.com/JuliaLang/julia/pull/15032
https://github.com/JuliaLang/julia/issues/16285

On Tue, May 24, 2016 at 5:23 PM, Siyi Deng  wrote:

>
> numpy arrays operate element-wise by default, and have broadcasting
> (binary singleton expansion) behaviors by default. in julia you have to do
> (.> , .<, .==) all the time.
>
>


Re: [julia-users] Handling large xml-files

2016-05-24 Thread Isaiah Norton
One example to start from is the parser in OpenStreetMap.jl, which uses
LibExpat's streaming functionality:
https://github.com/tedsteiner/OpenStreetMap.jl/blob/master/src/parseMap.jl

On Tue, May 24, 2016 at 11:18 AM, Johann Spies 
wrote:

>
>
>
> *In Python I can use etree.iterparse from lxml.  Is there something
> similar available in Julia? I have looked at the LibExpat package, but the
> reference **Streaming XML parsing does not give me enough information (at
> least for my level of understanding) on how to use it.*
>
>
> I am working with xml files that may contain up to 1.5 million records and
> takes up more than 8Gb when zipped.
>
>
> Regards
>
> Johann
>


Re: [julia-users] julia equivalent of python [] (aka list)

2016-05-24 Thread Isaiah Norton
`Any[]` constructs a list instance. The proper type signature is
`::Array{Any,1}` (or if you don't absolutely need it, you can leave the
member signature out of the type declaration)

On Tue, May 24, 2016 at 1:16 PM, Andreas Lobinger 
wrote:

> I tend to agree with you, however...
>
> julia> d = Any[]
> 0-element Array{Any,1}
>
> julia> type d1
>name::AbstractString
>content::Any[]
>end
> ERROR: TypeError: d1: in type definition, expected Type{T}, got Array{Any,
> 1}
>
>
>
>
>
> On Tuesday, May 24, 2016 at 7:11:50 PM UTC+2, Stefan Karpinski wrote:
>>
>> Since Julia 0.4 [] is what you're looking for.
>>
>> On Tue, May 24, 2016 at 1:06 PM, Andreas Lobinger 
>> wrote:
>>
>>> Hello colleagues,
>>>
>>> it really feels strange to ask this, but what is the julia equivalent of
>>> python's list?
>>>
>>> So.
>>>
>>>
>>>1. can by initialised empty
>>>2. subject of append and extend
>>>3. accepting Any entry
>>>4. foolproof usage in type definition... (my real problem seems to
>>>be here)
>>>
>>>
>>> Wishing a happy day,
>>>
>>> Andreas
>>>
>>
>>


Re: [julia-users] Lack of an explicit return in Julia, heartache or happiness?

2016-05-24 Thread Isaiah Norton
This is common in more functionally-oriented languages, and facilitates a
similar style in Julia. I would probably ban it in an organization-level
linting standard, but I do use it myself ;)

On Tue, May 24, 2016 at 12:48 PM, David Parks 
wrote:

> The last line of a function is its implicit return value in Julia.
>
> Can someone tell me why this is a great idea?
>
> I'm realizing a serious downside to it in reading someone else's code.
> It's not immediately clear to me if a use of a particular function is using
> the last statement as a return value or not.
>
> The lack of an explicit return is making the code ambiguous to read, and
> therefore I'm searching for uses of it to understand the original intent.
>
> Even if the original coder is being perfectly hygienic in their style, I
> can't make an assumption as such. I've always though explicit over implicit
> reigned king in code maintainability. Can someone convince me otherwise?
>
>
>
>


Re: [julia-users] Julia implementation

2016-05-24 Thread Isaiah Norton
I would suggest to read src/README.md and the Devdocs (
http://docs.julialang.org/en/latest/devdocs/julia/) for an overview of the
organization of the codebase.


> What is not implemented in julia?
> What language is it implemented in? (I think that arrays come from c,
> right?)


- frontend (parsing and lowering): small Scheme variant called flisp, also
written by Jeff Bezanson
- runtime (primitives, allocation, GC): C
- code generation: C++
- various libraries are written in C, Fortran, etc. (PCRE, BLAS, GMP,
libgit2, ...)

Why is it implemented in that particular language?


- C: because is the lowest-common-denominator for system implementations.
- C++: because it is the most straight-forward way to interface with LLVM.
- Scheme: because Julia is a Trojan Horse to finally make the world use
Lisp. because it keeps the pesky peasants out. because it's a great
compiler language and allowed fast implementation and iteration. There is
some interest in moving the front end to pure Julia, and the parser has
been ported already (JuliaParser.jl) -- that's about ~1/3 of the job.
Porting the lowering and sorting out bootstrapping is a fair amount of
effort and would likely need to be done by people who could be making more
user-relevant improvements elsewhere. So far, doing so hasn't been a
priority.


On Tue, May 24, 2016 at 10:24 AM, Ford Ox  wrote:

> Docs state that most of the julia language is implemented in julia itself.
> What is not implemented in julia?
> What language is it implemented in? (I think that arrays come from c,
> right?)
> Why is it implemented in that particular language?
>
>


Re: [julia-users] methods list

2016-05-23 Thread Isaiah Norton
julia> methodswith(Foo)

On Mon, May 23, 2016 at 2:03 PM, Ford Ox  wrote:

> Is there any function that will print out all methods available for
> concrete type?
>
> type Foo end
> method1(f::Foo) = ...
> method2(x::Int, f::Foo) = ...
> methods(Foo)
>
> Foo has three methods:
>>
> method1(...)
>>
> method2(...)
>>
> methods(...)
>>
>
>
>


Re: [julia-users] Keyword chaining

2016-05-23 Thread Isaiah Norton
Also, the given example is already valid syntax... (simply missing a final
`end`)

On Mon, May 23, 2016 at 1:51 PM, Stefan Karpinski 
wrote:

> What is "keyword chaining"? Can you provide examples of languages that do
> something like this?
>
> On Mon, May 23, 2016 at 1:43 PM, Ford Ox  wrote:
>
>> Why is there no keyword chaining in julia?
>>
>> for x in 1:30, y in 1:30
>> if x == 5 && y == 5
>> dosomething()
>> else let obj = array[y, x]  # Chained keywords here
>> if obj == FOO
>> dosomethingelse()
>> end
>> end
>> end
>>
>>
>>
>


Re: [julia-users] Re: Async file IO?

2016-05-19 Thread Isaiah Norton
>
> Julia IO is mostly built on libuv, but file IO uses the internal ios
> library that is part of flisp.


(I guess file IO is kind of important so replace "mostly" with "partly"...)

To clarify: operations on the `IOStream` type use the "ios" library.
Operations on `LibuvStream` (and its subtypes) use Libuv.





On Thu, May 19, 2016 at 6:36 PM, Isaiah Norton <isaiah.nor...@gmail.com>
wrote:

> I don't think this happens for normal file IO.
>
>
> Right, good point. The stuff in the thread linked by Andrei applies to
> Libuv streams only.
>
> I think that Julia IO is built on libuv
>>
>
> Julia IO is mostly built on libuv, but file IO uses the internal ios
> library that is part of flisp.
>
> On Thu, May 19, 2016 at 5:43 PM, Yichao Yu <yyc1...@gmail.com> wrote:
>
>> On Thu, May 19, 2016 at 5:24 PM, Andrei Zh <faithlessfri...@gmail.com>
>> wrote:
>> > Based on answers to my own question, I believe it's safe to assume that
>> > `read()` on file will switch to another task during IO operation.
>>
>> I don't think this happens for normal file IO.
>>
>> >
>> >
>> >
>> > On Tuesday, May 17, 2016 at 2:03:21 AM UTC+3, g wrote:
>> >>
>> >> Hello All,
>> >>
>> >> I think that Julia IO is built on libuv, and that libuv offers
>> >> asynchronous IO to the filesystem. Is this exposed through the Julia
>> API? I
>> >> can't figure it out from the documentation. I did a simple test
>> >>
>> >> julia> tic(); t = @async read(open("filename"),UInt8,25);
>> yield();
>> >> toc()
>> >>
>> >> elapsed time: 9.094271773 seconds
>> >>
>> >> and it seems that reading blocks without yielding.
>> >>
>> >> Is there a way to do this where the reading task yields to other
>> processes
>> >> while it is getting the data from disk?
>> >>
>> >>
>> >>
>> >
>>
>
>


Re: [julia-users] Re: Async file IO?

2016-05-19 Thread Isaiah Norton
>
> I don't think this happens for normal file IO.


Right, good point. The stuff in the thread linked by Andrei applies to
Libuv streams only.

I think that Julia IO is built on libuv
>

Julia IO is mostly built on libuv, but file IO uses the internal ios
library that is part of flisp.

On Thu, May 19, 2016 at 5:43 PM, Yichao Yu  wrote:

> On Thu, May 19, 2016 at 5:24 PM, Andrei Zh 
> wrote:
> > Based on answers to my own question, I believe it's safe to assume that
> > `read()` on file will switch to another task during IO operation.
>
> I don't think this happens for normal file IO.
>
> >
> >
> >
> > On Tuesday, May 17, 2016 at 2:03:21 AM UTC+3, g wrote:
> >>
> >> Hello All,
> >>
> >> I think that Julia IO is built on libuv, and that libuv offers
> >> asynchronous IO to the filesystem. Is this exposed through the Julia
> API? I
> >> can't figure it out from the documentation. I did a simple test
> >>
> >> julia> tic(); t = @async read(open("filename"),UInt8,25);
> yield();
> >> toc()
> >>
> >> elapsed time: 9.094271773 seconds
> >>
> >> and it seems that reading blocks without yielding.
> >>
> >> Is there a way to do this where the reading task yields to other
> processes
> >> while it is getting the data from disk?
> >>
> >>
> >>
> >
>


Re: [julia-users] Ubuntu bug? Executing .jl files via shebang does nothing on Ubuntu 16.04 x64

2016-05-19 Thread Isaiah Norton
What is `versioninfo()` for both cases? If your versions are different,
this might be a bug that has been fixed...

On Thu, May 19, 2016 at 1:48 PM, Adrian Salceanu 
wrote:

> Hi,
>
> There seems to be a problem with executing .jl scripts on Ubuntu 16.04 x64
>
> Take this simple program in exec_text.jl
>
> #!/usr/bin/env julia --color=yes
> println("all good!")
>
>
> On Mac OS:
> $ ./exec_test.jl
> all good!
>
>
> On Ubuntu it just hangs
> $ ./exec_test.jl
>
> [=> never returns, does nothing]
>
> This works as expected:
> $ julia exec_test.jl
> all good!
>
> But this is not an acceptable solution as I need to execute my program in
> order to pass command line args to it. Otherwise julia would just gobble up
> the command line args intended for my script.
>
> Thanks,
> Adrian
>


Re: [julia-users] Re: static compilation

2016-05-19 Thread Isaiah Norton
It looks like there might be a parser ambiguity when the arguments are
given as a tuple (the whole thing is parsed as keyword argument to the
macro call).

Either of the following will work right now:

@Base.ccallable Int64 foo(x::Int64) = x+1
@Base.ccallable(Int64, function foo(x::Int64) x+1 end)

Please file a bug report with the signature you tried.

On Thu, May 19, 2016 at 10:51 AM, Ján Adamčák  wrote:

> Thanks @Jameson
>
> The problem with @ccallable is, I get following error(Version
> 0.5.0-dev+4124 (2016-05-16 22:35 UTC)):
>
> julia> @Base.ccallable (Int64, foo(x::Int64) = x+1)
> ERROR: expected method definition in @ccallable
>  in eval(::Module, ::Any) at .\boot.jl:226
>
> Thanks
>
> Dňa streda, 18. mája 2016 18:46:31 UTC+2 Jameson napísal(-a):
>>
>> You might need to be more specific than "doesn't work"; I tried it last
>> week and it worked for me. The usage is essentially the same (the macro in
>> v0.5 takes an extra argument of the return type, but the deprecation
>> warning should note this already).
>>
>> On Wed, May 18, 2016 at 7:59 AM Ján Adamčák  wrote:
>>
>>> Thanks @Jameson
>>>
>>> Do you have an idea, how the compilation will work on v0.5 release? I
>>> have tried with recent commits of master, but @ccallable doesn't work.
>>>
>>>
>>>
>>> Dňa sobota, 14. mája 2016 1:17:45 UTC+2 Jameson napísal(-a):

 > without jl_init()

 That is not implemented at this time, although patches are welcome.

 > it has something to do with ccallable

 Yes, it also is orthogonal to compile-all. It is possible that
 compile-all is non-functional on v0.4 on Windows, I know master has many
 enhancements, which may have included more stable Windows support. I
 suggest playing with these two options independently before jumping into
 combining them.

>>> On Fri, May 13, 2016 at 2:39 PM Ján Adamčák  wrote:

> Thanks @Jameson,
>
>
> I have successfully built .so with "--compile=all" flag on 0.5-dev on
> ubuntu 16.04, but my .so library is 110MB. The same compilation on
> Win10 crashes. I can call
>
> my function in c++ code using jl_init and jl_get_function.
>
>
> My primary goal is to compile a dll with my own exported function,
> which I can call without jl_init(). I think it has something to do with
> ccallable, which you have mentioned. I'm stacked at this point. Could you
> please explain in more details, or point me to Julia code, how to move
> forward?
>
>
> Thanks in advance.
>
> -jan
>
> Dňa piatok, 13. mája 2016 4:30:41 UTC+2 Jameson napísal(-a):
>>
>> We have been working on a number of simplifications on master, so
>> some of the best practices and extra steps aren't necessary anymore. But 
>> it
>> should still work on v0.4.
>>
>> There are a few different goals that can be accomplished by invoking
>> the Julia compiler directly, so it was a bit difficult to write that blog
>> post talking about them all generically. Since it touches on several of 
>> the
>> optimization options, I structured it in part to show how these layers 
>> can
>> build on each other. But I decided to leave out demonstrations of how
>> mixing various layers and options can be used to create other products.
>>
>> Since most of these steps are already configured in the Julia build
>> system, one of the easiest ways to augment it is to simply drop a
>> userimg.jl file into base/
>> This will then get incorporated into the usual build and become part
>> of the pre-defined system image.
>>
>> The `-e nothing` stage is there because you have to give it something
>> to evaluate (a file, stdin, or `-e`, etc.), or it will pop open the REPL
>> and wait for the user to enter commands. This is actually also a valid 
>> way
>> to create an executable and can be fun to play with as a development
>> exercise (I still do this on occasion to test out how it is handling odd
>> cases).
>>
>> To get a ccallable declaration to show up in the binary, the only
>> condition is that you must declare it ccallable in the same execution 
>> step
>> as the final output.
>>
>> -jameson
>>
>>
>> On Thu, May 12, 2016 at 10:23 AM Ján Adamčák 
>> wrote:
>>
>>> Thanks @Jameson,
>>>
>>> I am a bit confused about "you are not adding any code to the system
>>> image (`--eval nothing`)". According to your blog
>>> http://juliacomputing.com/blog/2016/02/09/static-julia.html , I
>>> think that this is a crucial point to obtain a small sized dll. Am I 
>>> right?
>>>
>>> What is then the right way to emit "ccallable" declarations in order
>>> to export julia function(s)? (foo in our example from the original post 
>>> in
>>> this 

Re: [julia-users] Using @spawnat to define var on particular process

2016-05-19 Thread Isaiah Norton
On Mon, May 16, 2016 at 7:48 PM, Alex Williams 
wrote:

The basic question is why this doesn't define `x` on worker #2:
>
> *@spawnat 2 x=1*
>
Because it is wrapped in a closure; so `x` is local to the closure when the
code is executed on the other process. To see the difference, try `@spawnat
2 global x = 1` then `@spawnat 2 names(Main)`

> Meanwhile this seems to work:
>
> *@spawnat 2 eval(:(x=1))*
>
`eval` operates in global scope by default (you can optionally specify a
module as the first argument).


> And this seems to work if you want to define `x` on all procs:
>
> *@everywhere x=1*
>
This calls `eval`, see above :)

I tried using macroexpand to see the difference. I don't have a good sense
> of what things like `*:copyast*` and `*:localize*` mean. If someone could
> help me parse this, I'd greatly appreciate it.
>

- `copyast` makes a copy of a given AST, handling GC roots, etc. (see
definition as `jl_copy_ast` in "src/ast.c").
- `Expr(:localize, expr)` encloses the expression in a let block containing
an entry for each variable referenced in the expression (see the definition
of `localize_vars` in "base/expr.jl").

Apologies if there is a good explanation of this elsewhere on the web. You
> can just point me there if so.
>

Chris Rackauckas has done some nice tutorials on parallelization recently,
which might touch on some of this (check juliabloggers.com).

If you have any improvement suggestions for the Base documentation, those
would be great (PRs welcome).



> -- Alex
>
>


Re: [julia-users] tensor flow question

2016-05-18 Thread Isaiah Norton
Several things seem to be happening here:

- TensorFlow.jl does not export `tanh` (but does export `tanh_`, note
underscore)
- There is ambiguity among several `sigmoid` method signatures, which may
cause the import to fail (try calling `TF.API.sigmoid` directly to see the
warning).
- Julia does not raise an import error because the name `tanh` already
exists in every module namespace by default, due to implicit imports.

I would suggest to file an issue (or pull-request) at the TensorFlow.jl
repository for the first two.


On Wed, May 18, 2016 at 4:38 AM, Jon Norberg 
wrote:

> I am following the examples in tensor flow.jl I get all the examples to
> work nicely. however, when I want to change an activation function to tan
> or sigmoid I get an error. I suspect I am doing something wrong rather than
> a problem with the package so I ask here...
>
> If I do this:
>
> using TensorFlow
> using TensorFlow.Train
> using TensorFlow.InputData
> import TensorFlow: DT_FLOAT32
> import TensorFlow.API: relu, tanh,
> sigmoid,softmax_cross_entropy_with_logits, AdamOptimizer, arg_max, equal,
> cast
> methods(relu)
>
> I get:
>
> 2 methods for generic function relu:
> relu(features::Union{TensorFlow.CoreTypes.AbstractTensor,Void}) at
> /Users/Raukhur/.julia/v0.4/TensorFlow/src/API/TfNn.jl:1006
> relu(features::Union{TensorFlow.CoreTypes.AbstractTensor,Void},
> name::Union{AbstractString,Void}) at
> /Users/Raukhur/.julia/v0.4/TensorFlow/src/API/TfNn.jl:1006
>
> but if I do this
>
> methods(tanh)
>
> I get 13 methods for tanh but none for tensor flow related types and for
>
> methods(sigmoid) I get
>
> LoadError: UndefVarError: sigmoid not defined
> while loading In[42], in expression starting on line 6
>
> So it seems relu gets imported but not tanh or sigmoid. also
>
> methods(TensorFlow.API.tanh) nor
> methods(TensorFlow.tanh) works
>
> Its probably something simple I have overlooked


Re: [julia-users] Plagiarism detection for Julia?

2016-05-18 Thread Isaiah Norton
>
> Otherwise, I might develop an extension for JPlag
> 
>

In case you are not aware, there is a pure-Julia version (as opposed to
scheme) of the parser, that is easier to use for tooling purposes:

https://github.com/JuliaLang/JuliaParser.jl

On Wed, May 18, 2016 at 9:05 AM, Thibaut Cuvelier 
wrote:

> Dear all,
>
> Using Julia for the assignments in an mathematical optimisation, I'd like
> to check for plagiarism in what the students hand in. The university has
> already invested in a software package for text (such as reports), but it
> does not work well with source code.
>
> Has anyone developed software to detect plagiarism in Julia code?
> Otherwise, I might develop an extension for JPlag
> (there doesn't seem to be open
> source plagiarism detection programs…); any Julia grammar would be welcome!
>
> Thanks for your help!
> Thibaut Cuvelier
>


Re: [julia-users] Re: select/poll on TCPSocket in Julia?

2016-05-18 Thread Isaiah Norton
>
> And just of curiosity, when current task calls `read()` and there's no
> data available, does Julia switch to another task or lets operating system
> to switch thread?


Switches to another task. The reading task on the Julia side calls libuv to
initiate reading, then waits on a condition variable. The actual blocking
call is made in libuv. Once data is available, there is a callback from
libuv to Julia and the read task is woken up.

On Tue, May 17, 2016 at 4:36 PM, Andrei Zh 
wrote:

> Hmm, I now think that I could misinterpret exception (EOFError, if I
> remember correctly) - it could be a server who closed connection by
> timeout, not Julia's `read()`. I will check it once again and post back if
> I see any suspicious behavior. Thanks for clarification.
>
> And just of curiosity, when current task calls `read()` and there's no
> data available, does Julia switch to another task or lets operating system
> to switch thread?
>
> On Tuesday, May 17, 2016 at 6:14:39 PM UTC+3, Jameson wrote:
>>
>> > But if nothing is written to the socket for a while, `read()` will fail
>> with timeout
>>
>> That sounds like a bug, although I'm not aware of any read code-path that
>> has a timeout. Can you post an example of when it fails? This should
>> absolutely be the correct way to handle IO.
>>
>>
>>
>> On Tue, May 17, 2016 at 3:09 AM Andrei Zh  wrote:
>>
>>> Jameson, thanks for your reply. Basically, the question is what exactly
>>> to do in a task that handles a socket. E.g. I can't do just:
>>>
>>> @async begin
>>> socket = connect(...)
>>> while true
>>> data = read(socket, Int64)
>>> process_data(data)
>>> end
>>> end
>>> this only works if there's something to read all the time. But if
>>> nothing is written to the socket for a while, `read()` will fail with
>>> timeout.
>>>
>>> This is why I'm looking for a way to make a call to `read()` only when
>>> there's actually something to read. So far I came to the following function
>>> that does exactly this, but may have (configurable) delay:
>>>
>>> """
>>> Parameters:
>>>  * sockets - list of sockets to select from
>>>  * readfn - function that takes socket and returns read result
>>>  * sleep_time - (optional) - interval between socket checks
>>>  * channel_size - (optional) size of a result channel, effectively,
>>> buffer size
>>> Returns:
>>>  * channel with objects that were read from sockets
>>> """
>>> function select(sockets::Vector{TCPSocket}, readfn::Function;
>>> sleep_time::Float64=0.1, channel_size::Int64=1024)
>>> result_channel = Channel(channel_size)
>>> for s in sockets
>>> @async begin
>>> Base.start_reading(s)
>>> while isopen(s)
>>> while nb_available(s) == 0 sleep(sleep_time) end
>>> result = readfn(s)
>>> put!(result_channel, result)
>>> end
>>> end
>>> end
>>> return result_channel
>>> end
>>>
>>> Better implementation that would remove possible delay is welcome.
>>>
>>>
>>> On Tuesday, May 17, 2016 at 8:18:16 AM UTC+3, Jameson wrote:

 Launch each socket into it's own task (@async) and let Julia's
 green-threading manage the poll/select for you internally.


 On Friday, May 13, 2016 at 8:08:01 PM UTC-4, Andrei Zh wrote:
>
> 1. I found out that TCPSocket contains several conditions and
> callbacks, but I couldn't find any docs or example of their usage.
> 2. I also found #6563  
> that
> discusses exactly the problem of listening to multiple conditions /
> channels.
>
> So if I manage to create a callback for incoming data, I will be able
> to borrow some ideas from (1) and come up with a `select` function that
> satisfies my needs. Does anybody have an example of using TCPSocket's
> callbacks/conditions?
>
> On Thursday, May 12, 2016 at 12:45:44 AM UTC+3, Andrei Zh wrote:
>>
>> Given several TCPSocket-s, how can I sequentially poll them and read
>> the first that becomes readable?
>>
>> I believe *nix's poll/select functions provide something similar for
>> files (and Julia has `poll_fd`), but what is the best way to approach 
>> this
>> task for sockets?
>>
>


Re: [julia-users] uv-unix.h not found on windows

2016-05-13 Thread Isaiah Norton
How did you install Julia?

The issue is that the compiler is incorrectly identifying as unix, so libuv
looks for headers which are not available. You could try compiling with
`gcc ... -mwin32`. But most likely you will need to get a supported
toolchain. See the windows build instructions:

https://github.com/JuliaLang/julia/blob/master/README.windows.md#msys2-provides-a-robust-msys-experience

On Fri, May 13, 2016 at 1:15 PM, Primitivo Roman <
primitivo.roman.mont...@gmail.com> wrote:

> I try to run code for embedding julia in C with msys2 system environment:
>
>
> #include 
>
> int main(int argc, char *argv[])
> {
> /* required: setup the julia context */
> jl_init(NULL);
>
> printf("Calling julia from C:\n");
> /* run julia commands */
> jl_eval_string("print(sqrt(2.0))");
>
> /* strongly recommended: notify julia that the
>  program is about to terminate. this allows
>  julia time to cleanup pending write requests
>  and run all finalizers
> */
> jl_atexit_hook(0);
> printf("\n");
> return 0;
> }
>
> try to compile with:
> $gcc -o test test.c -fPIC -I$JULIA_DIR/src/ -I$JULIA_DIR/src/support
> -L/usr/lib/libjulia.dll  -L/usr/lib/x86_64-linux-gnu/libstc++-6.dll -ljulia
> test.c:1:0: aviso: se descarta -fPIC para el objetivo (todo el código es
> independiente de posición)
>  #include 
>  ^
> In file included from /c/src/julia/src/support/ios.h:7:0,
>  from /c/src/julia/src/support/libsupport.h:14,
>  from /c/src/julia/src/julia.h:12,
>  from test.c:1:
> /usr/include/uv.h:65:22: error fatal: uv-unix.h: No such file or directory
> compilación terminada.
>
> only exists uv-win.h
> How I specifie my SO to Julia?
>
>


Re: [julia-users] old objects and new code

2016-05-13 Thread Isaiah Norton
>
> It seems to me that when I execute one of the module functions on x the
> original version of the function, not the revised version, gets called.

First, is my understanding of what's going on correct?


Yes, if you are holding an alias to the "old" module, it doesn't get
updated.

Second, any recommendations for dealing with this?  In this case
> regenerating x was not a big deal, but I can imagine situations that
> weren't so trivial.  If there were lots of objects involved, one could keep
> a script that creates them and rerun it.


You can use `workspace()` to clear everything, but that might not be
desirable...

For interactive projects where there is a lot of setup, I often write all
repeated code in a text file inside a module with a short name ("X"), and
then just repeatedly reload that text file and call a single function to
execute the changes. I believe Juno uses some fancier techniques to allow
interactive updating and executing, you might want dig in the code and see
if you can adopt similar techniques for ESS.

```
file X.jl:
  module X
  import Y

  ...
  function run()
...
  end
  end # module X

  X.run()

REPL:
julia> include("X.jl")
```



On Thu, May 12, 2016 at 3:39 PM, Boylan, Ross  wrote:

> A file has code surrounded by a module declaration.  It includes
> definitions of some types and some functions.
> In the REPL (ESS) I include the file and execute a function that returns
> me an object x of type MyModule.Foo.
> Then I change some of the code and include the module again.  The type Foo
> is unchanged.
>
> It seems to me that when I execute one of the module functions on x the
> original version of the function, not the revised version, gets called.
>
> If I recreate x then I get the current function definitions aka what I
> wanted.
>
> First, is my understanding of what's going on correct?
>
> Second, any recommendations for dealing with this?  In this case
> regenerating x was not a big deal, but I can imagine situations that
> weren't so trivial.  If there were lots of objects involved, one could keep
> a script that creates them and rerun it.
>
> Thanks
> Ross Boylan


Re: [julia-users] How to check whether a macro is defined

2016-05-13 Thread Isaiah Norton
julia> isdefined(symbol("@inline"))
true

On Fri, May 13, 2016 at 6:11 AM,  wrote:

> to suppress some annoying method overwritten warnings, I found a useful
> @nowarn macro.
> However, I need to check whether this macro is defined and include the
> definition if not.
>
> Question, how to check whether a macro is defined?
>
> If one thread can ask multiple questions, I'm also interested in
> how to suppress warnings? especially those relates to redefinition.
>
> Thanks!
>


Re: [julia-users] Process medium-sized files in JuliaBox (or alternative)

2016-05-13 Thread Isaiah Norton
You could try uploading files to your own AWS bucket and access them using
AWS.jl. (I don't know what the transfer speed / latency would be like).

SageMathCloud supports Julia (or did in the past; not sure about current
version), and they have a generous free account (3 GB). Their subscription
is very reasonable, to get better specs and reliability.

On Fri, May 13, 2016 at 6:50 AM, Nils Gudat  wrote:

> Slightly weird scenario: Have to do a small bit of analysis on a heavily
> locked down machine, meaning the only way for me to use any type of decent
> software is to use it online. First port of call was obviously JuliaBox,
> but unfortunately I need to process a couple of csv files on the order of
> ~100MB each, and JuliaBox tells me I can't upload anything above 20MB.
>
> Is there a way around this limitation in JuliaBox, or a similar
> browser-based solution that would allow me to do this?
>
> Many thanks,
> Nils
>


Re: [julia-users] cannot make codespeed

2016-05-11 Thread Isaiah Norton
I believe it's just a metadata field for the web display, probably `julia`
or sometimes `julia-debug`.

On Sun, May 8, 2016 at 3:41 AM, Didier Verna  wrote:

>
>   Hello,
>
> I cloned Julia yesterday and could make it, except that I cannot 'make
> codespeed' in test/perf. The error message is the following:
>
> [skipping a bunch of warnings]
> ERROR: LoadError: LoadError: You must provide the JULIA_FLAVOR environment
> variable identifying this julia build!
>  in error(::String) at ./error.jl:21
>  in include_from_node1(::String) at ./loading.jl:426 (repeats 2 times)
>  in process_options(::Base.JLOptions) at ./client.jl:263
>  in _start() at ./client.jl:319
> while loading /Users/didier/tmp/julia/test/perf/micro/../perfutil.jl, in
> expression starting on line 14
> while loading /Users/didier/tmp/julia/test/perf/micro/perf.jl, in
> expression starting on line 5
> make: *** [codespeed] Error 1
> zsh: exit 2 make codespeed
>
>
> What value is expected for JULIA_FLAVOR ?
>
>
> Also, note that the file README.md in test/perf mentions a website which
> does not exist (speed.julialang.org).
>
> Thanks.
>
> --
> ELS'16, May 9-10, Krakow, Poland: http://www.european-lisp-symposium.org
>
> Lisp, Jazz, Aïkido: http://www.didierverna.info
>


Re: [julia-users] loop-else

2016-05-11 Thread Isaiah Norton
That issue is marked as a 1.0 milestone, which should be interpreted as
"decision before 1.0" in this case. But clearly a low priority.

On Wed, May 11, 2016 at 5:26 AM, Ford Ox  wrote:

> Will loop-else python like syntax be implemented in future? I have read
> this  topic, but no
> statement has been made.
>


Re: [julia-users] Re: Is there a function/macro that shows the line number where it is called?

2016-05-10 Thread Isaiah Norton
Use `@__LINE__` and `@__FILE__`.

(note, however, `@__LINE__` does not work when used within another macro,
see https://github.com/JuliaLang/julia/issues/9577)

On Tue, May 10, 2016 at 6:25 AM, FANG Colin  wrote:

> Currently I am using
>
> macro markup(line_number)
> println("compile time OK: #$(line_number)")
> quote
> x = $(esc(line_number))
> println("run time OK: #$x")
> end
> end
>
> For example
>
> I want to debug a function "to_debug".
>
> function to_debug()
> @markup(1)
> end
>
> compile time OK: #1
>
>
> to_debug()
>
>
> run time OK: #1
>
>
>
>
>
>
>
>
> On Tuesday, May 10, 2016 at 11:16:20 AM UTC+1, FANG Colin wrote:
>>
>> I am debugging some code.
>>
>> I would like to insert some markup function/macro in my code, so that I
>> know my code at least works fine until certain line number 
>>
>


Re: [julia-users] @edit could not determine location of method definition

2016-04-27 Thread Isaiah Norton
What version of Julia? Possibly this issue:
https://github.com/JuliaLang/julia/issues/14346

If your code is publicly available, please add the example (and link to
code) as a comment there, plus output of `versioninfo()`.

On Wed, Apr 27, 2016 at 6:01 AM,  wrote:

> Most of time, when I call @which, I'm usually returned with a
> dispatch/method and its location information, like this:
>
> @which Domain(-1.1,5.2)
> call{T<:Number}(::Type{BasicDecomposition.Domain{T}}, a::T<:Number, b::T<:
> Number) at /home/calvin/Documents/git/DomainDecomposition.jl/src/wedge.jl:
> 61
>
> But sometimes, the location of the method is missing, though the correct
> method is given:
>
> julia> @which Decompose(f,I)
> Decompose(f::Function, interval::BasicDecomposition.DomainSet{N,T})
>
> Of course, if I call @edit for the same method, an error is thrown saying
> that the location is not determined.
>
> julia> @edit Decompose(f,I)
> ERROR: could not determine location of method definition
>  in functionloc at reflection.jl:324
>  in edit at interactiveutil.jl:63
>
> What could cause such a problem? What should I do if I really want to know
> the location of the method/dispatch?
>


Re: [julia-users] Cloning private package with 0.5

2016-04-23 Thread Isaiah Norton
>
> I would hope that this is a release blocker issue, given that private
> package repos have been supported forever.
>
So right now there seems no way to use them on 0.5 from Windows...


https:// should be supported, although I haven't tried it on Windows. See
[1,2] for configuration details and instructions to avoid password prompts.

Regarding ssh, see [3]:

building against libssh2 is explicitly disabled by our Makefile.


(this line [2])

Switching ssh on for windows would require Makefile rules to build and
package libssh2 along with libgit2 and the rest of the libraries. Note that
libssh2 can use native windows crypto functionality ("WinCNG" backend), so
it should not impose any further requirements.

[1]
https://help.github.com/articles/which-remote-url-should-i-use/#cloning-with-https-urls-recommended
[2]
http://stackoverflow.com/questions/13800289/configure-git-clients-like-github-for-windows-to-not-ask-for-authentication/18607931#18607931
[3] https://groups.google.com/d/msg/julia-users/GEwX49wwmdo/CihXC62yCAAJ
[4]
https://github.com/JuliaLang/julia/blob/c2042326cc5d68db01c0b2e0d12a15f48b03563a/deps/Makefile#L2094


On Fri, Apr 22, 2016 at 8:30 PM, David Anthoff  wrote:

> Yes, I would hope that this is a release blocker issue, given that private
> package repos have been supported forever. I also have a very large number
> of private repos.
>
> So right now there seems no way to use them on 0.5 from Windows...
>
> I also would prefer to use SSH keys for authentication. If it does have to
> be https, I guess it would be ok if things are integrated with the git
> credential storage infrastructure. What would really be sort of a disaster
> is if I was asked for a username and password every time I do an
> Pkg.update() or something like that...
>
> > -Original Message-
> > From: julia-users@googlegroups.com [mailto:julia-
> > us...@googlegroups.com] On Behalf Of Eric Forgy
> > Sent: Friday, April 22, 2016 4:58 PM
> > To: julia-users 
> > Subject: RE: [julia-users] Cloning private package with 0.5
> >
> > I have the same problem (on Windows) and really hoping this gets fixed
> > before 0.5 is released. I have a ton of private repos.
> >
> > I'd prefer a solution that lets me keep my remotes at
> > g...@github.com:EricForgy/MyPrivateRepo.jl. It would be more than a
> little
> > annoying if I have to change every one to https. Hopefully, Pkg can do
> some
> > magic and make the changes for me if needed.
>


  1   2   3   4   5   6   7   8   >