[julia-users] Re: Errors while trying to use cxx and embed Julia together
So I built and installed Cxx and then attempted to use it with embedded Julia and was successful. The tricky part is pretty tricky especially for someone not familiar how the whole thing is laid out, I've put most of what I did in this gist https://gist.github.com/waTeim/ec622a0630f220e6b3c3 Step 1. Build and run make install Step 2. While still in the top level source directory, install Cxx as per the Cxx webpage Step 3. Take the installed directory structure and put it in an installed location. Step 4. There are additional include files that Cxx needs access to after it has built whenever c++ source needs to be compiled, they can be found in the following directories relative to the source tree root. usr/include/{clang,llvm,llvm-c} usr/lib/clang/ Cxx attempts to access the files in these directories when it gets imported, and although addIncludeDir is supposed to help here, I could not make it work like that, so i ended up copying all of this to the installed directory (see the gist). Step 5. In addition for embedding the relative paths are off, so a couple of symbolic links need to be added. Step 6 access Cxx from embedding framework and I have some show and tell here for that Consider the following file (index.js) this is taken from the Cxx example page, I simplified it to merely good ol' hello world var julia = require('node-julia'); julia.eval('using Cxx'); julia.eval('cxx #includeiostream '); julia.eval('cxx void mycppfunction() { std::cout hello world std::endl; } '); julia.eval('julia_function() = @cxx mycppfunction()'); julia.exec('julia_function'); and when run: bizarro% node index.js hello world So that's JITed-C++ within JITed-Julia within JITed-Javascript, which I think is a first. It's pretty slow because of all of the compiling going on, and there's a bunch of eval where there could be something else, but I think pre-compilation will fix that. Pretty exciting.
[julia-users] Re: Indexing Array with empty vector in v.0.4.
Thanks, Yichao Yu, Int[] does solve it for me. Hope you found how to make your irrelevant denormals not slow down your code. For what I do, I would also agree to flush them all to 0 if that speeds up my code significantly.
[julia-users] Re: PyCall and urllib2
Sometimes PyCall cannot infer that an object is callable, since so many in python are (beyond simple functions). In such situations, the workaround is to use the pycall function in julia directly. See the invocations below... *julia **urllib2.Request(http://google.com;)* *ERROR: type: apply: expected Function, got PyObject* *julia **urllib2.urlopen(http://google.com;)* *PyObject addinfourl at 4660350848 whose fp = socket._fileobject object at 0x1168f1ed0* *julia **req = pycall(urllib2.Request, PyAny, http://google.com;)* *PyObject urllib2.Request instance at 0x115c74d40* *julia **f=urllib2.urlopen(req)* *PyObject addinfourl at 4660402584 whose fp = socket._fileobject object at 0x1168f76d0* *julia **f[:read](100)* *!doctype htmlhtml itemscope=\\ itemtype=\http://schema.org/WebPage\; lang=\en-GB\headmeta cont* On Sunday, 19 July 2015 03:15:28 UTC+1, Dejan Miljkovic wrote: What would be the right way to execute urllib2 call in julia using PyCall @pyimport urllib2 as urllib2 request = urllib2.Request(url, json_payload, {'Content-Type': 'application/json'}) type: apply: expected Function, got PyObject while loading In[29], in expression starting on line 1 Thanks, Dejan
[julia-users] Re: Errors while trying to use cxx and embed Julia together
Hello, Once again I really appreciate all the effort you put and the help you provide. I assume that since you made things work properly now we do havea working solution. Yet again as I am not really good with programming in general sth things I still unfortunately need to ask on how to follow your directions. So, Step 1. Build and run make install Step 2. While still in the top level source directory, install Cxx as per the Cxx webpage Step 3. Take the installed directory structure and put it in an installed location. These three steps I have already done, I have compiled the source code and installed Cxx accordingly for the source code and I also have copied the installed directory (the one with the big number that is created after make install) in a seperate file from which I run julia. Step 4. There are additional include files that Cxx needs access to after it has built whenever c++ source needs to be compiled, they can be found in the following directories relative to the source tree root. usr/include/{clang,llvm,llvm-c} usr/lib/clang/ Cxx attempts to access the files in these directories when it gets imported, and although addIncludeDir is supposed to help here, I could not make it work like that, so i ended up copying all of this to the installed directory (see the gist). Here I am a bit confused what to do. I did cp the abve mentioned directories: cp -a /usr/lib/clang /home/kostav/Julian/julia-f428392003/lib cp -a /usr/include/{clang,llvm-3.6,llvm-c-3.6} /home/kostav/Julian/julia-f428392003/include But then in the gist I see you do cp a bunch of other files which I am not sure I do have them all anyway. Does this mean that instead of copying the above mentioned directories I included I need to copy the spe- cific files you point out in the first session of the git ( i.e. *BuildJuliaLLVMforCXX* https://gist.github.com/waTeim/ec622a0630f220e6b3c3#file-buildjuliallvmforcxx )? Step 5. In addition for embedding the relative paths are off, so a couple of symbolic links need to be added. Symbolic links to link which files though? Sorry if the questions I raise are already answered by the git, I just failed to understand it properly so that's why I come back with these questions now. )
Re: [julia-users] The unique function and iterables of custom composite types
you may be interested in https://github.com/andrewcooke/AutoHashEquals.jl, but it uses all entries. i will consider adding that feature, though (with the idea that if it's not used at all, all are used). more generally - and this may just be a problem with my programming style - i find that there's a problem with julia (or me) conflating two different things: * record types * immutable types immutable types in julia are intended, as far as i can see, for small, value-like things that are stored on the stack. while types are for larger, record like things. some of us (perhaps coming more from a functional programming background) like to program with records that are immutable, we have no way to do that in julia except by convention. hence the need for AutoHashEquals (imho) (there are two problems - first, most obviously, you then want record equality to depend on contents, but second, less obviously, when these immutable records are used in immutable types then you want the immutable type's hash to depend on the record's contents, and not on the pointer value. hence applying the macro to both types). andrew On Friday, 17 July 2015 12:52:52 UTC-3, Seth wrote: Perhaps a @unique macro in front of the type field could specify that this is to be used in equality/hashing?
[julia-users] Re: is the highlight color in docs selectable
i don't know anything about this, so forgive me if this is hopelessly naive. but wouldn't that only be a problem if there were also green bits? the docs don't seem to have much that is green, so there isn't much that will get confused with red. andrew On Friday, 17 July 2015 21:25:55 UTC-3, ele...@gmail.com wrote: Is also a poor choice for the ~10% of males with red/green colour deficiency. On Saturday, July 18, 2015 at 7:19:20 AM UTC+10, Jeffrey Sarnoff wrote: Reading docs peppered with red is bit headache inducing for me. Is there support for a less aggressive color?
[julia-users] Strange results in using symbolic calculation
I am using Julia in my work. Please explain why the following result is so strange and how to treat this situation: using SymPy x=Sym(x) f1(x)=x^2 f2(x)=diff(f1(x), x) subs(f2(x), x, 1)== 2 subs(f2(x), x, 1)3 == false Thank you. Thanh Nguyen
Re: [julia-users] Indexing Array with empty vector in v.0.4.
On Sun, Jul 19, 2015 at 11:02 AM, Stefan Karpinski stefan.karpin...@gmail.com wrote: Slicing with an empty array of element type Union() should be supportable, though, no? It's Any array on 0.4, which makes me hesitate whether we should support that. On Jul 18, 2015, at 7:41 AM, Yichao Yu yyc1...@gmail.com wrote: On Sat, Jul 18, 2015 at 6:00 AM, Felipe Jiménez felipe.jimene...@gmail.com wrote: Say A is an Array, like A = [1 2 3 4], and I index it with an empty vector. In Julia v.0.3, A[[]] is empty. I find this convenient when programming. In Julia v.0.4, A[[]] throws an error. Is this intended? It sometimes forces me to code if isempty()... else... The difference is that on 0.4, `[]` is a `Array{Any}`. Write `Int[]` should work. My version is 0.4.0-dev+5841 (2015-07-07 14:58 UTC), Commit f428392* (10 days old master), x86_64-w64-mingw32. Thank you.
Re: [julia-users] The unique function and iterables of custom composite types
On Sun, Jul 19, 2015 at 11:44 AM, andrew cooke and...@acooke.org wrote: 1 - i asked myself the same question after posting and went back and looked at the use case that motivated this. and it was for values that i need to mutate early in their lifetime, and which then remain invariant. i've been thinking about how i could have done it differently, and one approach i am considering is re-creating the objects during the start-up process. i think that would work. so that particular use case is perhaps not so convincing. If I understand correctly, this is what motivate this julep[1] (the more general case) [1] https://github.com/JuliaLang/julia/issues/11902 2 - however, isn't there still a case for things that should be semantically equal, even though they are composite? maybe i am misunderstanding how things work, but i could imagine some object that stored, say, name and age. if i used an immutable type then equality would depend on interning of strings, wouldn't it? another example would be immutable arrays. in short: immutable things that are accessed by a pointer, and whose contents you want to include in equality. andrew On Sunday, 19 July 2015 11:53:43 UTC-3, Stefan Karpinski wrote: I don't really get what's lacking. If you want an immutable record type why not just use an immutable type? On Jul 19, 2015, at 8:03 AM, andrew cooke and...@acooke.org wrote: you may be interested in https://github.com/andrewcooke/AutoHashEquals.jl, but it uses all entries. i will consider adding that feature, though (with the idea that if it's not used at all, all are used). more generally - and this may just be a problem with my programming style - i find that there's a problem with julia (or me) conflating two different things: * record types * immutable types immutable types in julia are intended, as far as i can see, for small, value-like things that are stored on the stack. while types are for larger, record like things. some of us (perhaps coming more from a functional programming background) like to program with records that are immutable, we have no way to do that in julia except by convention. hence the need for AutoHashEquals (imho) (there are two problems - first, most obviously, you then want record equality to depend on contents, but second, less obviously, when these immutable records are used in immutable types then you want the immutable type's hash to depend on the record's contents, and not on the pointer value. hence applying the macro to both types). andrew On Friday, 17 July 2015 12:52:52 UTC-3, Seth wrote: Perhaps a @unique macro in front of the type field could specify that this is to be used in equality/hashing?
[julia-users] Re: Extracting values from Array{ANY}
Here is results file : https://copy.com/i9GeXhK0qHdfwpkT I need to extract values for node 79 , which starts at row 10 So i want the algorithm to find the row file[10,1] and get the value file[10,2], and then next and so on. file=readdlm(results.txt) findfirst(file,79) access to undefined reference while loading In[13], in expression starting on line 1 in findnext at array.jl:1034 (repeats 2 times)
[julia-users] Overlapping data in DArrays
Is it possible to construct DArrays such that they overlap? For example, given an array with 10 elements, and 2 processors, elements 1..6 should belong to processor 1, and 5..10 to processor 2. Thanks.
[julia-users] Re: Splatting NTuple-s in method signatures (what's the difference between defining foo{N}(x::NTuple{N}...) and bar{N}(x::NTuple{N})?)
Also, what's wrong with `foo(args...) = length(args)` ? Seems like that ought to achieve your desired result. On Sunday, July 19, 2015 at 5:43:30 PM UTC-4, Tomas Lycken wrote: Hi everybody, I created the function foo{N}(bar::NTuple{N}...) = N under the impression that I'd be able to do julia foo(2, 3) 2 julia foo(1, 2, 3, 4, 5, 6, 7) 7 julia foo(bar, qux, 3, rand(10)) 4 but all the above yield no-method errors, since the `NTuple` isn't splatted in the signature. The following works, though: julia foo((2,3)) 2 so if I actually pass a tuple, it works. However, julia methods(foo) # 1 method for generic function foo: foo{N}(bar::NTuple...) at none:1 does show the splatting `...`. so I assume there's some difference between the definition of `foo` and a similar function bar{N}(foo::NTuple{N}) = N which doesn't splat. The behavior of `foo` above is what I would expect (and what I get) from `bar`. I realize I'm probably trying to do something semi-pathological here, but it'd be really nice if it was possible to make `foo` work the way I want it too (and without `@ngenerate`, if I get to choose...). I seem to recall some discussion that mentioned a way to do this, but I can't remember where (or even if it was mentioned as a solution or as a suggestion for future language features...). What is the actual difference between `foo` and `bar` above? How can I get the behavior I want from `foo`? Regards, // T
[julia-users] Re: Splatting NTuple-s in method signatures (what's the difference between defining foo{N}(x::NTuple{N}...) and bar{N}(x::NTuple{N})?)
To see the difference between `foo` and `bar`, try `foo((2,3), (4,5))` and `bar((2,3), (4,5))`. Then try `foo((2,3), (4,5,6))`. On Sunday, July 19, 2015 at 5:43:30 PM UTC-4, Tomas Lycken wrote: Hi everybody, I created the function foo{N}(bar::NTuple{N}...) = N under the impression that I'd be able to do julia foo(2, 3) 2 julia foo(1, 2, 3, 4, 5, 6, 7) 7 julia foo(bar, qux, 3, rand(10)) 4 but all the above yield no-method errors, since the `NTuple` isn't splatted in the signature. The following works, though: julia foo((2,3)) 2 so if I actually pass a tuple, it works. However, julia methods(foo) # 1 method for generic function foo: foo{N}(bar::NTuple...) at none:1 does show the splatting `...`. so I assume there's some difference between the definition of `foo` and a similar function bar{N}(foo::NTuple{N}) = N which doesn't splat. The behavior of `foo` above is what I would expect (and what I get) from `bar`. I realize I'm probably trying to do something semi-pathological here, but it'd be really nice if it was possible to make `foo` work the way I want it too (and without `@ngenerate`, if I get to choose...). I seem to recall some discussion that mentioned a way to do this, but I can't remember where (or even if it was mentioned as a solution or as a suggestion for future language features...). What is the actual difference between `foo` and `bar` above? How can I get the behavior I want from `foo`? Regards, // T
[julia-users] Re: PyCall and urllib2
This can be also done by using Requests julia package using Requests.post using JSON.parse function call_endpoint_with_payload(rest_host::String, rest_port::Int, endpoint::String, json_payload::String) url = string(rest_host, :, rest_port, /, endpoint) resp = post(url, data = json_payload) return parse(resp.data) On Sunday, July 19, 2015 at 9:26:41 AM UTC-7, Dejan Miljkovic wrote: Thanks!! Dejan On Sunday, July 19, 2015 at 4:42:00 AM UTC-7, Avik Sengupta wrote: Sometimes PyCall cannot infer that an object is callable, since so many in python are (beyond simple functions). In such situations, the workaround is to use the pycall function in julia directly. See the invocations below... *julia **urllib2.Request(http://google.com http://google.com)* *ERROR: type: apply: expected Function, got PyObject* *julia **urllib2.urlopen(http://google.com http://google.com)* *PyObject addinfourl at 4660350848 whose fp = socket._fileobject object at 0x1168f1ed0* *julia **req = pycall(urllib2.Request, PyAny, http://google.com http://google.com)* *PyObject urllib2.Request instance at 0x115c74d40* *julia **f=urllib2.urlopen(req)* *PyObject addinfourl at 4660402584 whose fp = socket._fileobject object at 0x1168f76d0* *julia **f[:read](100)* *!doctype htmlhtml itemscope=\\ itemtype=\http://schema.org/WebPage\ http://schema.org/WebPage%5C lang=\en-GB\headmeta cont* On Sunday, 19 July 2015 03:15:28 UTC+1, Dejan Miljkovic wrote: What would be the right way to execute urllib2 call in julia using PyCall @pyimport urllib2 as urllib2 request = urllib2.Request(url, json_payload, {'Content-Type': 'application/json'}) type: apply: expected Function, got PyObject while loading In[29], in expression starting on line 1 Thanks, Dejan
Re: [julia-users] delayed evaluation without a macro
Thanks, Tamas. I will look into this along the lines that you mention. When I tried previously to implement delayed evaluation using delaying and forcing procedures my sequence elements were still getting evaluated although I believe the delaying and forcing procedures were otherwise working in that delay postponed function evaluation by wrapping it in a procedure and a call to the forcing procedure could subsequently evaluate the delayed function. But I will have another look as I must have been mistaken. I just wasn't sure if there was something about how Julia evaluates that prevented a procedural approach to delayed evaluation (and hence the use of macros for lazy.jl etc.). So there are three reasons actually I was curious about this. First I am learning Julia and I was trying to get a sense of Julia's evaluation model sort of step by step. Second (and relatedly) I am trying to get a better sense of the need and the utility of macros and meta-programming--what do they make possible that is otherwise not possible? Also at the moment for the way that I am going to use Julia, clarity in the code is a top priority (over fanciness). So if I can write something that is easier to read (for a novice) then that is an approach that I prefer to one that is more sophisticated but also more obscure. One of the things I like about Julia is that generally it is quite easy to read. Third I am interested in working with delayed evaluation and was trying to get a better sense of that also. I'd like to understand how the macro implementation is better than the procedural implementation. You mention that there would be a lot of boilerplate code without macros . . . . It seemed to me that once you have delaying and forcing procedures there is not big difference in delayed evaluation compared to where it is implemented using macros. I am interested in better understanding your comment . . . . Thanks, Mark On Friday, July 17, 2015 at 9:49:48 AM UTC-4, Tamas Papp wrote: Of course. Eg delayed1 = function() print(evaluating!\n) 42 end force(f::Function) = f() force(delayed1) You just need the macros for the syntactic sugar, bookkeeping, etc. Any intermediate Scheme textbook provides a lot of examples on how to do these things with closures. I am curious why you want to do it without macros, though; you just get a lot of boilerplate code. BTW, there aren't a lot of macros in Lazy.jl either. Best, Tamas On Fri, Jul 17 2015, Mark S mas...@gmail.com javascript: wrote: Hello, I am interested in the delayed evaluation implementations like Lazy.jl (one-more-minute) and LazySequences.jl (dcjones). Both of these use Julia's macros facilities. Is it possible to implement delayed evaluation without using macros? Thanks for any leads or good references on this. Mark
[julia-users] Splatting NTuple-s in method signatures (what's the difference between defining foo{N}(x::NTuple{N}...) and bar{N}(x::NTuple{N})?)
Hi everybody, I created the function foo{N}(bar::NTuple{N}...) = N under the impression that I'd be able to do julia foo(2, 3) 2 julia foo(1, 2, 3, 4, 5, 6, 7) 7 julia foo(bar, qux, 3, rand(10)) 4 but all the above yield no-method errors, since the `NTuple` isn't splatted in the signature. The following works, though: julia foo((2,3)) 2 so if I actually pass a tuple, it works. However, julia methods(foo) # 1 method for generic function foo: foo{N}(bar::NTuple...) at none:1 does show the splatting `...`. so I assume there's some difference between the definition of `foo` and a similar function bar{N}(foo::NTuple{N}) = N which doesn't splat. The behavior of `foo` above is what I would expect (and what I get) from `bar`. I realize I'm probably trying to do something semi-pathological here, but it'd be really nice if it was possible to make `foo` work the way I want it too (and without `@ngenerate`, if I get to choose...). I seem to recall some discussion that mentioned a way to do this, but I can't remember where (or even if it was mentioned as a solution or as a suggestion for future language features...). What is the actual difference between `foo` and `bar` above? How can I get the behavior I want from `foo`? Regards, // T
Re: [julia-users] Re: PyCall and urllib2
On Sunday, 19 July 2015 15:55:38 UTC+1, Stefan Karpinski wrote: Would it make sense to define a fallback call method for PyObject values that tries to apply the PyObject as a python function? Dunno. Sounds logical, but someone with more knowledge of Python internals than me will have to say if there are any unintended consequences for that.
Re: [julia-users] Re: Splatting NTuple-s in method signatures (what's the difference between defining foo{N}(x::NTuple{N}...) and bar{N}(x::NTuple{N})?)
The following should work in principle but somehow the type inference does not agree with codegen... ```julia julia @inline bar{N}(::NTuple{N}) = N bar (generic function with 1 method) julia foo(args...) = bar(args) foo (generic function with 1 method) julia @code_warntype foo(1, 2, 3) Variables: args::Tuple{Int64,Int64,Int64} Body: begin # none, line 1: return 3 end::Int64 julia foo(1, 2, 3) 3 julia @code_llvm foo(1, 2, 3) define %jl_value_t* @julia_foo_21108(%jl_value_t*, %jl_value_t**, i32) { top: %3 = alloca [4 x %jl_value_t*], align 8 %.sub = getelementptr inbounds [4 x %jl_value_t*]* %3, i64 0, i64 0 %4 = getelementptr [4 x %jl_value_t*]* %3, i64 0, i64 2 %5 = getelementptr [4 x %jl_value_t*]* %3, i64 0, i64 3 %6 = bitcast [4 x %jl_value_t*]* %3 to i64* store i64 4, i64* %6, align 8 %7 = getelementptr [4 x %jl_value_t*]* %3, i64 0, i64 1 %8 = bitcast %jl_value_t** %7 to %jl_value_t*** %9 = load %jl_value_t*** @jl_pgcstack, align 8 store %jl_value_t** %9, %jl_value_t*** %8, align 8 store %jl_value_t** %.sub, %jl_value_t*** @jl_pgcstack, align 8 store %jl_value_t* null, %jl_value_t** %4, align 8 store %jl_value_t* null, %jl_value_t** %5, align 8 %10 = call %jl_value_t* @jl_f_tuple(%jl_value_t* null, %jl_value_t** %1, i32 %2) store %jl_value_t* %10, %jl_value_t** %4, align 8 store %jl_value_t* %10, %jl_value_t** %5, align 8 %11 = call %jl_value_t* @jl_apply_generic(%jl_value_t* inttoptr (i64 140728696104080 to %jl_value_t*), %jl_value_t** %5, i32 1) %12 = load %jl_value_t*** %8, align 8 store %jl_value_t** %12, %jl_value_t*** @jl_pgcstack, align 8 ret %jl_value_t* %11 } ``` On Sun, Jul 19, 2015 at 6:03 PM, David Gold david.gol...@gmail.com wrote: Also, what's wrong with `foo(args...) = length(args)` ? Seems like that ought to achieve your desired result. On Sunday, July 19, 2015 at 5:43:30 PM UTC-4, Tomas Lycken wrote: Hi everybody, I created the function foo{N}(bar::NTuple{N}...) = N under the impression that I'd be able to do julia foo(2, 3) 2 julia foo(1, 2, 3, 4, 5, 6, 7) 7 julia foo(bar, qux, 3, rand(10)) 4 but all the above yield no-method errors, since the `NTuple` isn't splatted in the signature. The following works, though: julia foo((2,3)) 2 so if I actually pass a tuple, it works. However, julia methods(foo) # 1 method for generic function foo: foo{N}(bar::NTuple...) at none:1 does show the splatting `...`. so I assume there's some difference between the definition of `foo` and a similar function bar{N}(foo::NTuple{N}) = N which doesn't splat. The behavior of `foo` above is what I would expect (and what I get) from `bar`. I realize I'm probably trying to do something semi-pathological here, but it'd be really nice if it was possible to make `foo` work the way I want it too (and without `@ngenerate`, if I get to choose...). I seem to recall some discussion that mentioned a way to do this, but I can't remember where (or even if it was mentioned as a solution or as a suggestion for future language features...). What is the actual difference between `foo` and `bar` above? How can I get the behavior I want from `foo`? Regards, // T
Re: [julia-users] Re: PyCall and urllib2
All PyObjects will be callable once 0.4 is out. I just haven't pulled the trigger on that change yet.
[julia-users] Output from compose before finishing block in IJulia
Call display(...) on the picture.
Re: [julia-users] Re: PyCall and urllib2
Would it make sense to define a fallback call method for PyObject values that tries to apply the PyObject as a python function? On Jul 19, 2015, at 7:42 AM, Avik Sengupta avik.sengu...@gmail.com wrote: Sometimes PyCall cannot infer that an object is callable, since so many in python are (beyond simple functions). In such situations, the workaround is to use the pycall function in julia directly. See the invocations below... julia urllib2.Request(http://google.com;) ERROR: type: apply: expected Function, got PyObject julia urllib2.urlopen(http://google.com;) PyObject addinfourl at 4660350848 whose fp = socket._fileobject object at 0x1168f1ed0 julia req = pycall(urllib2.Request, PyAny, http://google.com;) PyObject urllib2.Request instance at 0x115c74d40 julia f=urllib2.urlopen(req) PyObject addinfourl at 4660402584 whose fp = socket._fileobject object at 0x1168f76d0 julia f[:read](100) !doctype htmlhtml itemscope=\\ itemtype=\http://schema.org/WebPage\; lang=\en-GB\headmeta cont On Sunday, 19 July 2015 03:15:28 UTC+1, Dejan Miljkovic wrote: What would be the right way to execute urllib2 call in julia using PyCall @pyimport urllib2 as urllib2 request = urllib2.Request(url, json_payload, {'Content-Type': 'application/json'}) type: apply: expected Function, got PyObject while loading In[29], in expression starting on line 1 Thanks, Dejan
Re: [julia-users] The unique function and iterables of custom composite types
I don't really get what's lacking. If you want an immutable record type why not just use an immutable type? On Jul 19, 2015, at 8:03 AM, andrew cooke and...@acooke.org wrote: you may be interested in https://github.com/andrewcooke/AutoHashEquals.jl, but it uses all entries. i will consider adding that feature, though (with the idea that if it's not used at all, all are used). more generally - and this may just be a problem with my programming style - i find that there's a problem with julia (or me) conflating two different things: * record types * immutable types immutable types in julia are intended, as far as i can see, for small, value-like things that are stored on the stack. while types are for larger, record like things. some of us (perhaps coming more from a functional programming background) like to program with records that are immutable, we have no way to do that in julia except by convention. hence the need for AutoHashEquals (imho) (there are two problems - first, most obviously, you then want record equality to depend on contents, but second, less obviously, when these immutable records are used in immutable types then you want the immutable type's hash to depend on the record's contents, and not on the pointer value. hence applying the macro to both types). andrew On Friday, 17 July 2015 12:52:52 UTC-3, Seth wrote: Perhaps a @unique macro in front of the type field could specify that this is to be used in equality/hashing?
Re: [julia-users] Extracting values from Array{ANY}
I have a text file containing special characters, text and some numbers and I need to extract from it some values which appear every n-th row. Since the file has around 20k rows, I want the algorithm to find first and next rows. I've read text file to matrix with readdlm(), but the type of array is ANY, and findfirst() gives and error access to undefined reference. Could you give me some guidance, please? Regards Mike It would be helpful if you post a minimal example which can be copy-pasted into the REPL and shows the error you get.
[julia-users] Re: Juno/LightTable - Connected to Julia but cannot evaluate
Have you tried using `Ctrl-Enter` to evaluate instead of the right click menu? On Thursday, 16 July 2015 21:16:55 UTC+1, Eric Forgy wrote: julia versioninfo() Julia Version 0.3.10 Commit c8ceeef* (2015-06-24 13:54 UTC) Platform Info: System: Windows (x86_64-w64-mingw32) CPU: AMD Opteron(tm) Processor 4171 HE WORD_SIZE: 64 BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Barcelona) LAPACK: libopenblas LIBM: libopenlibm LLVM: libLLVM-3.3 - Hi, I was happily using Juno/LightTable on MacOS and now I am trying to install Juno/LightTable (version 0.7.2) on a Windows VM on Azure. Here are my user.behaviors: [ ;; The app tag is kind of like global scope. You assign behaviors that affect ;; all of Light Table to it. [:app :lt.objs.style/set-skin dark] [:app :lt.objs.plugins/load-js user_compiled.js] [:app :lt.objs.langs.julia/julia-path C:\\Program Files\\Julia-0.3.10\\bin\\julia.exe] ;; The editor tag is applied to all editors [:editor :lt.objs.editor/no-wrap] [:editor :lt.objs.style/set-theme june-night] ;; Here we can add behaviors to just clojure editors [:editor.clojure :lt.plugins.clojure/print-length 1000] ;; Behaviors specific to a user-defined object [:user.hello :lt.plugins.user/on-close-destroy] ;; To subtract a behavior, prefix the name with '-' e.g. ;; [:app :-lt.objs.intro/show-intro] ] When I launch LightTable, it says Spinning up Julia and then after a few seconds, it says Connected to Julia. However, when I try to highlight or select any code and right-click, the Evaluate option is greyed out so I'm not able to run any code. Any ideas? Thanks a lot!
Re: [julia-users] Re: Extracting values from Array{ANY}
Here is results file : https://copy.com/i9GeXhK0qHdfwpkT A 50k lines file is hardly minimal! Using a trick with IOBuffer you can make it copy-pasteable: st = 1 n o d a l p o i n t d a t a t o t a l n o d a l t e m p e r a t u r e s 79 23.759 105 23.759 buf = IOBuffer(st) file = readdlm(buf) findfirst(file,79) ERROR: access to undefined reference in findnext at array.jl:1034 in findfirst at array.jl:1040 As Nils suggested, you probably need to parse the file yourself using readall, split and strip and maybe others. Report back if that doesn't work. Last, please don't cross post. People looking at Julia on Stackoverflow are mostly the same as the people here. Happy Julia hacking! I need to extract values for node 79 , which starts at row 10 So i want the algorithm to find the row file[10,1] and get the value file[10,2], and then next and so on. file=readdlm(results.txt) findfirst(file,79) access to undefined reference while loading In[13], in expression starting on line 1 in findnext at array.jl:1034 (repeats 2 times)
[julia-users] Re: Errors while trying to use cxx and embed Julia together
Symbolic links to link which files though? Sorry if the questions I raise are already answered by the git, I just failed to understand it properly so that's why I come back with these questions now. I've added a listing of the entire directory structure https://gist.github.com/waTeim/ec622a0630f220e6b3c3#file-directorylayout Here are the symbolic links. I believe with some simple changes to Cxx, the need for these will disappear, but for now there's where it searches. /usr/local/julia/lib bizarro% ls -l total 16 drwxr-xr-x 4 jeffw staff 136 Jul 18 18:26 clang lrwxr-xr-x 1 root staff10 Jul 19 03:16 include - ../include drwxr-xr-x 49 jeffw staff 1666 Jul 18 20:11 julia lrwxr-xr-x 1 root staff 1 Jul 19 03:16 lib - .
Re: [julia-users] The unique function and iterables of custom composite types
sorry, i have no idea wy this appeared in a different (new) thread on google groups. On Sunday, 19 July 2015 13:21:41 UTC-3, andrew cooke wrote: oh that looks interesting, thanks. but still, in very abstract terms, there are two orthogonal things: stack v heap storage and immutable v mutable. julia mixes those two up. there's an argument (which i think valid) that julia reflects the most common approach, but it would be nice if it were built on a lower level that exposed these differences for people that want to do things differently. (this is more a comment i wish i had said earlier than one related to julep). andrew On Sunday, 19 July 2015 12:48:57 UTC-3, Yichao Yu wrote: On Sun, Jul 19, 2015 at 11:44 AM, andrew cooke and...@acooke.org wrote: 1 - i asked myself the same question after posting and went back and looked at the use case that motivated this. and it was for values that i need to mutate early in their lifetime, and which then remain invariant. i've been thinking about how i could have done it differently, and one approach i am considering is re-creating the objects during the start-up process. i think that would work. so that particular use case is perhaps not so convincing. If I understand correctly, this is what motivate this julep[1] (the more general case) [1] https://github.com/JuliaLang/julia/issues/11902 2 - however, isn't there still a case for things that should be semantically equal, even though they are composite? maybe i am misunderstanding how things work, but i could imagine some object that stored, say, name and age. if i used an immutable type then equality would depend on interning of strings, wouldn't it? another example would be immutable arrays. in short: immutable things that are accessed by a pointer, and whose contents you want to include in equality. andrew On Sunday, 19 July 2015 11:53:43 UTC-3, Stefan Karpinski wrote: I don't really get what's lacking. If you want an immutable record type why not just use an immutable type? On Jul 19, 2015, at 8:03 AM, andrew cooke and...@acooke.org wrote: you may be interested in https://github.com/andrewcooke/AutoHashEquals.jl, but it uses all entries. i will consider adding that feature, though (with the idea that if it's not used at all, all are used). more generally - and this may just be a problem with my programming style - i find that there's a problem with julia (or me) conflating two different things: * record types * immutable types immutable types in julia are intended, as far as i can see, for small, value-like things that are stored on the stack. while types are for larger, record like things. some of us (perhaps coming more from a functional programming background) like to program with records that are immutable, we have no way to do that in julia except by convention. hence the need for AutoHashEquals (imho) (there are two problems - first, most obviously, you then want record equality to depend on contents, but second, less obviously, when these immutable records are used in immutable types then you want the immutable type's hash to depend on the record's contents, and not on the pointer value. hence applying the macro to both types). andrew On Friday, 17 July 2015 12:52:52 UTC-3, Seth wrote: Perhaps a @unique macro in front of the type field could specify that this is to be used in equality/hashing?
Re: [julia-users] Indexing Array with empty vector in v.0.4.
I think we should probably support indexing with Array{Any}, just so long as all the contained elements are Ints. It's not performant or recommended, but it can still work just fine.
Re: [julia-users] Indexing Array with empty vector in v.0.4.
Slicing with an empty array of element type Union() should be supportable, though, no? On Jul 18, 2015, at 7:41 AM, Yichao Yu yyc1...@gmail.com wrote: On Sat, Jul 18, 2015 at 6:00 AM, Felipe Jiménez felipe.jimene...@gmail.com wrote: Say A is an Array, like A = [1 2 3 4], and I index it with an empty vector. In Julia v.0.3, A[[]] is empty. I find this convenient when programming. In Julia v.0.4, A[[]] throws an error. Is this intended? It sometimes forces me to code if isempty()... else... The difference is that on 0.4, `[]` is a `Array{Any}`. Write `Int[]` should work. My version is 0.4.0-dev+5841 (2015-07-07 14:58 UTC), Commit f428392* (10 days old master), x86_64-w64-mingw32. Thank you.
[julia-users] Re: PyCall and urllib2
Thanks!! Dejan On Sunday, July 19, 2015 at 4:42:00 AM UTC-7, Avik Sengupta wrote: Sometimes PyCall cannot infer that an object is callable, since so many in python are (beyond simple functions). In such situations, the workaround is to use the pycall function in julia directly. See the invocations below... *julia **urllib2.Request(http://google.com http://google.com)* *ERROR: type: apply: expected Function, got PyObject* *julia **urllib2.urlopen(http://google.com http://google.com)* *PyObject addinfourl at 4660350848 whose fp = socket._fileobject object at 0x1168f1ed0* *julia **req = pycall(urllib2.Request, PyAny, http://google.com http://google.com)* *PyObject urllib2.Request instance at 0x115c74d40* *julia **f=urllib2.urlopen(req)* *PyObject addinfourl at 4660402584 whose fp = socket._fileobject object at 0x1168f76d0* *julia **f[:read](100)* *!doctype htmlhtml itemscope=\\ itemtype=\http://schema.org/WebPage\ http://schema.org/WebPage%5C lang=\en-GB\headmeta cont* On Sunday, 19 July 2015 03:15:28 UTC+1, Dejan Miljkovic wrote: What would be the right way to execute urllib2 call in julia using PyCall @pyimport urllib2 as urllib2 request = urllib2.Request(url, json_payload, {'Content-Type': 'application/json'}) type: apply: expected Function, got PyObject while loading In[29], in expression starting on line 1 Thanks, Dejan
Re: [julia-users] The unique function and iterables of custom composite types
oh that looks interesting, thanks. but still, in very abstract terms, there are two orthogonal things: stack v heap storage and immutable v mutable. julia mixes those two up. there's an argument (which i think valid) that julia reflects the most common approach, but it would be nice if it were built on a lower level that exposed these differences for people that want to do things differently. (this is more a comment i wish i had said earlier than one related to julep). andrew On Sunday, 19 July 2015 12:48:57 UTC-3, Yichao Yu wrote: On Sun, Jul 19, 2015 at 11:44 AM, andrew cooke and...@acooke.org javascript: wrote: 1 - i asked myself the same question after posting and went back and looked at the use case that motivated this. and it was for values that i need to mutate early in their lifetime, and which then remain invariant. i've been thinking about how i could have done it differently, and one approach i am considering is re-creating the objects during the start-up process. i think that would work. so that particular use case is perhaps not so convincing. If I understand correctly, this is what motivate this julep[1] (the more general case) [1] https://github.com/JuliaLang/julia/issues/11902 2 - however, isn't there still a case for things that should be semantically equal, even though they are composite? maybe i am misunderstanding how things work, but i could imagine some object that stored, say, name and age. if i used an immutable type then equality would depend on interning of strings, wouldn't it? another example would be immutable arrays. in short: immutable things that are accessed by a pointer, and whose contents you want to include in equality. andrew On Sunday, 19 July 2015 11:53:43 UTC-3, Stefan Karpinski wrote: I don't really get what's lacking. If you want an immutable record type why not just use an immutable type? On Jul 19, 2015, at 8:03 AM, andrew cooke and...@acooke.org wrote: you may be interested in https://github.com/andrewcooke/AutoHashEquals.jl, but it uses all entries. i will consider adding that feature, though (with the idea that if it's not used at all, all are used). more generally - and this may just be a problem with my programming style - i find that there's a problem with julia (or me) conflating two different things: * record types * immutable types immutable types in julia are intended, as far as i can see, for small, value-like things that are stored on the stack. while types are for larger, record like things. some of us (perhaps coming more from a functional programming background) like to program with records that are immutable, we have no way to do that in julia except by convention. hence the need for AutoHashEquals (imho) (there are two problems - first, most obviously, you then want record equality to depend on contents, but second, less obviously, when these immutable records are used in immutable types then you want the immutable type's hash to depend on the record's contents, and not on the pointer value. hence applying the macro to both types). andrew On Friday, 17 July 2015 12:52:52 UTC-3, Seth wrote: Perhaps a @unique macro in front of the type field could specify that this is to be used in equality/hashing?
Re: [julia-users] The unique function and iterables of custom composite types
1 - i asked myself the same question after posting and went back and looked at the use case that motivated this. and it was for values that i need to mutate early in their lifetime, and which then remain invariant. i've been thinking about how i could have done it differently, and one approach i am considering is re-creating the objects during the start-up process. i think that would work. so that particular use case is perhaps not so convincing. 2 - however, isn't there still a case for things that should be semantically equal, even though they are composite? maybe i am misunderstanding how things work, but i could imagine some object that stored, say, name and age. if i used an immutable type then equality would depend on interning of strings, wouldn't it? another example would be immutable arrays. in short: immutable things that are accessed by a pointer, and whose contents you want to include in equality. andrew On Sunday, 19 July 2015 11:53:43 UTC-3, Stefan Karpinski wrote: I don't really get what's lacking. If you want an immutable record type why not just use an immutable type? On Jul 19, 2015, at 8:03 AM, andrew cooke and...@acooke.org javascript: wrote: you may be interested in https://github.com/andrewcooke/AutoHashEquals.jl, but it uses all entries. i will consider adding that feature, though (with the idea that if it's not used at all, all are used). more generally - and this may just be a problem with my programming style - i find that there's a problem with julia (or me) conflating two different things: * record types * immutable types immutable types in julia are intended, as far as i can see, for small, value-like things that are stored on the stack. while types are for larger, record like things. some of us (perhaps coming more from a functional programming background) like to program with records that are immutable, we have no way to do that in julia except by convention. hence the need for AutoHashEquals (imho) (there are two problems - first, most obviously, you then want record equality to depend on contents, but second, less obviously, when these immutable records are used in immutable types then you want the immutable type's hash to depend on the record's contents, and not on the pointer value. hence applying the macro to both types). andrew On Friday, 17 July 2015 12:52:52 UTC-3, Seth wrote: Perhaps a @unique macro in front of the type field could specify that this is to be used in equality/hashing?
Re: [julia-users] Extracting values from Array{ANY}
I think this is cross-posted from here: http://stackoverflow.com/questions/31498869/extract-values-from-arrayany-in-julia The text file is not in a standard format, so readdlm inserts a bunch of #undef elements into the resulting matrix. It's not really a problem with findfirst. On Sunday, July 19, 2015 at 6:52:42 PM UTC+1, Mauro wrote: I have a text file containing special characters, text and some numbers and I need to extract from it some values which appear every n-th row. Since the file has around 20k rows, I want the algorithm to find first and next rows. I've read text file to matrix with readdlm(), but the type of array is ANY, and findfirst() gives and error access to undefined reference. Could you give me some guidance, please? Regards Mike It would be helpful if you post a minimal example which can be copy-pasted into the REPL and shows the error you get.
Re: [julia-users] Re: Azure: Which VM?
Done (well, proposed) in https://github.com/JuliaLang/julia/pull/12215 On Wednesday, July 15, 2015 at 1:26:55 PM UTC-7, Tony Kelman wrote: I don't see why not. I added a template to the Example.jl package that could pretty easily be created automatically during Pkg.generate as well. On Wednesday, July 15, 2015 at 1:47:42 PM UTC-4, David Anthoff wrote: Maybe one thing that would help on the package ecosystem side is to add an appveyor.yml file in addition to a .travis.yml file to the template generated by Pkg.generate? *From:* julia...@googlegroups.com [mailto:julia...@googlegroups.com] *On Behalf Of *Tony Kelman *Sent:* Tuesday, July 14, 2015 6:49 PM *To:* julia...@googlegroups.com *Subject:* [julia-users] Re: Azure: Which VM? If you're comfortable using Linux and have a choice in the matter, I would recommend avoiding using Julia on Windows if you can, especially for production purposes. Jameson, Isaiah, myself and others have put in a lot of effort to try to make things work, but there remains a lot of work to do across the package ecosystem (which was the point behind my JuliaCon talk), and there are a number of persistent bugs and usability issues that remain unsolved for a variety of reasons. On Tuesday, July 14, 2015 at 2:07:16 AM UTC-7, Eric Forgy wrote: I am about to do some experiments running Julia from an Azure VM. The first decision to make is Which VM? Azure has a Quick Create option for creating VM's and the options are: · Windows Server - Ubuntu Server · OpenLogic - Oracle Linux · CoreOS - SUSE Linux Enterprise Server I presume Azure has a good reason to shortlist these VM's (and shortlist them in that order) so unless there is a good reason to deviate, I'll probably choose one of the above. If I look at the Julia downloads http://julialang.org/downloads/ page, I see the following selections: · Windows - Mac OS X · Ubuntu - Fedora/RHEL/CentOS/SL · Generic Linux I presume you guys have a good reason to shortlist these OSs (but not sure if the order is significant). I am agnostic about which OS to use, but I prefer to use one that has the best Julia support and will cause the least headaches, which presumably might be related to the OS most Julia developers are using. If I could, I would probably prefer to run Julia on a Windows VM, but I get the impression Windows has the fewest Julia developers working on it (see Stephen's comment here https://groups.google.com/forum/#!msg/julia-users/zgoqVYyPaIk/lfRmeROpI7YJ) so I predict there to be some pain points. Is that impression misguided? Any thoughts? If not Windows, comparing the above two lists, I'd be inclined to consider using Ubuntu. My use case is ultimately going to be distributed computing in the cloud (Azure) driven by a web app (ASP.NET MVC) with communication via REST and/or ZMQ. In a nutshell: 1. I have a slight preference for a Windows VM, but could be dissuaded if there is some pain to be expected. Is there? 2. If not Windows, it seems Ubuntu VM is the next likely candidate with apparently solid support in the Julia community. Is that true? 3. Any other recommendation better than the above two? Any thoughts would be appreciated. Thanks!
[julia-users] Strange results in using symbolic calculation
The left side is a symbolic value. You could wrap in N() to convert them compare.