Re: [julia-users] Passing N-D Julia arrays to C functions

2016-11-04 Thread Tim Holy
r)[1:end] > Aptrs = Array{Ptr{eltype(ar)}}(sz) > for I in CartesianRange(sz) > Aptrs[I] = pointer(ar, sub2ind(size(ar), 1, I.I...)) > end > println(ccall(("test","test"),Float64,(Ptr{Ptr{Ptr{Ptr{Float64,), > Aptrs)) > > > something is wrong here... > > &

Re: [julia-users] Passing N-D Julia arrays to C functions

2016-11-04 Thread Tim Holy
ccall(sym, Void, (Ptr{Ptr{T}},), Aptrs) When you pass an array via `ccall`, it takes the pointer of the data, which is why this produces a Ptr{Ptr{T}} from an Array{Ptr{T}}. Best, --Tim On Fri, Nov 4, 2016 at 9:14 AM, Alexander Lyapin wrote: > but in C i have

Re: [julia-users] Passing N-D Julia arrays to C functions

2016-11-04 Thread Tim Holy
If you need the pointers to each lower-dimensional slice, you should be able to build it like so (warning: untested): ``` sz = size(A)[2:end] # if you need type-stability, use Base.tail(size(A)) instead Aptrs = Array{Ptr{eltype(A)}(sz) for I in CartesianRange(sz) Aptrs[I] = pointer(A,

Re: [julia-users] Re: Fast vector element-wise multiplication

2016-11-02 Thread Tim Holy
Hmm, that's surprising. Looks like we're using generic broadcasting machinery for that operation (check out what @which P.*P returns). Might be good to add .* to this line: https://github.com/JuliaLang/julia/blob/b7f1aa7554c71d3759702b9c2e14904ebdc94199/base/arraymath.jl#L69. Want to make a pull

Re: [julia-users] Reducing complexity of OffsetArrays

2016-11-01 Thread Tim Holy
(i.e., the loss of a simple model > of how things are laid out). Maybe my fears are unfounded. Others don't > seem concerned it would seem. > > I'll check out those packages that you mention. > > Thanks, > Bob > > On Sun, Oct 30, 2016 at 2:29 PM, Tim Holy <tim.h...@g

Re: [julia-users] Reducing complexity of OffsetArrays

2016-10-30 Thread Tim Holy
abstract tree. > > Does this help? > > Bob > > ps I don't have any concrete examples yet because OffsetArrays are so > scarce in the julia ecosystem. I'm just looking ahead to a world where it > will no longer be possible to assume AbstractArrays are OneTo. This seems >

Re: [julia-users] Reducing complexity of OffsetArrays

2016-10-29 Thread Tim Holy
I should add, abstract discussions are all well and good, but I fully recognize you may have something very specific in mind and my answer simply fails to understand your concern. If you can give one or more concrete examples of where the current system is either bug-prone or a pain in the

Re: [julia-users] Reducing complexity of OffsetArrays

2016-10-29 Thread Tim Holy
At least with the non-1 arrays I know of now, you can always get the OneTo array form with parent(A). However, that's not something I feel comfortable saying will be guaranteed forever. In terms of the "automatic conversion" part of your proposal, I'm a bit uncomfortable because in my view the

Re: [julia-users] Re: ImageView very slow

2016-10-25 Thread Tim Holy
Yes, it should be pretty responsive now---ImageView doesn't have to go through a Python layer, so I think it's a bit snappier. It's been a while since I've used Matlab, but at least when I first compared them ImageView was considerably better than Matlab for interactive display of movies, etc. But

Re: [julia-users] Re: Trait for exactness of numbers

2016-10-25 Thread Tim Holy
> Why not use dispatch instead? Because subtyping isn't powerful enough for all needs. For example: julia> using Unitful julia> const mm = u"mm" mm julia> isa(3.2mm, AbstractFloat) false You'd probably like to use the fancy logic of `FloatRange` if you're constructing a range

Re: [julia-users] Re: Trait for exactness of numbers

2016-10-24 Thread Tim Holy
+1. We need number traits for a variety of circumstances; I was also contemplating them as a step in generalizing the FloatRange/StepRange distinction, for example to Unitful numbers (numbers with physical units). You need type-stability for the created range object, so I think a trait is the only

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

2016-10-24 Thread Tim Holy
That document is aimed at developers to tell them how to make their package ready for arrays that have custom indices. As a user, the key line is: > Such array types are expected to be supplied through packages. I recommend the OffsetArrays package. Great to see someone interested in trying

Re: [julia-users] congratulations to Indian dost

2016-10-21 Thread Tim Holy
Don't look at me, I swear it was just a simple change in the return type of a function---they should have used a parametric type definition. Another $1billion down the drain... Best, --Tim On Wed, Oct 19, 2016 at 11:50 PM, Michele Zaffalon < michele.zaffa...@gmail.com> wrote: > Tim Ho

Re: [julia-users] Please help me to convert a BitArray to a Integer array in Julia

2016-10-17 Thread Tim Holy
julia> a = bitrand(3,5) 3×5 BitArray{2}: true false false true true false true true true false true true true true true julia> Int.(a) 3×5 Array{Int64,2}: 1 0 0 1 1 0 1 1 1 0 1 1 1 1 1 julia> convert(Array{Int}, a) 3×5 Array{Int64,2}: 1 0 0 1 1 0 1 1

Re: [julia-users] Re: ImageView very slow

2016-10-16 Thread Tim Holy
Hmm, I fixed this on the images-next branch but forgot to fix it on master. Will be fixed in https://github.com/timholy/Images.jl/pull/564. If you're just getting started with Julia & Images, you might want to consider using the upcoming version of Images. See

Re: [julia-users] Re: indirect array indexing

2016-10-01 Thread Tim Holy
For simple cases there's also the IndirectArrays package: https://github.com/JuliaArrays/IndirectArrays.jl Best, --Tim On Fri, Sep 30, 2016 at 10:51 PM, wrote: > OK! many thanks for your fast reply > --a > > > On Friday, September 30, 2016 at 3:53:43 PM UTC+2,

Re: [julia-users] Re: Any 0.5 performance tips?

2016-09-29 Thread Tim Holy
No real clue about what's happening, but my immediate thought was that if your algorithm is iterative and uses some kind of threshold to decide convergence, then it seems possible that a change in the accuracy of some computation might lead to it getting "stuck" occasionally due to roundoff error.

Re: [julia-users] Re: Why was a fundamental indexing inconsistency introduced in 0.5?

2016-09-26 Thread Tim Holy
Try explaining both indexing behaviors to a newcomer and you'll see the difference. Old behavior: `3:3` causes the dimension to be retained; `3` causes the dimension to be dropped if it's a 'trailing dimension' (all the later indices are also scalars) but retained if it's a 'leading dimension'

Re: [julia-users] fieldtype() for parameterised types

2016-09-19 Thread Tim Holy
You don't have to do this in the type definition, you can do it at introspection time: fieldtype(Foo{Float64,3},:a) returns Array{T,N} fieldtype(Foo{Float64,3},:b) returns Array{Float64,3} More generally: julia> T, N = TypeVar(:T, true), TypeVar(:N, true) (T,N) julia> fieldtype(Foo{T,N},

Re: [julia-users] Read a stuctured binary file with big endian unsigned integers (4 bytes) and big endian floats (4 bytes)

2016-09-18 Thread Tim Holy
See ntoh and hton. Perhaps even better, see StrPack.jl. --Tim On Sunday, September 18, 2016 1:13:43 AM CDT Femto Trader wrote: > Hello, > > I'd like to read this file > http://www.dukascopy.com/datafeed/EURUSD/2016/02/14/20h_ticks.bi5 > using Julia. > > It's a LZMA compressed file. > > I can

Re: [julia-users] What is the best way to element-wise right shift an array?

2016-09-18 Thread Tim Holy
On Sunday, September 18, 2016 2:55:46 AM CDT K leo wrote: > I have been using simply A=[0; A[1:end-1]], but found it to be somehow > quite expensive. I saw that there is unshift! but it has to be followed up > with deleteat! to make the array the same size, i.e. there need to be two > operations.

Re: [julia-users] Re: wrapping a julia package

2016-09-16 Thread Tim Holy
Yes, the idea of wrappers that reinterpret or convert makes sense. On Friday, September 16, 2016 9:29:33 AM CDT Páll Haraldsson wrote: > type Color > r::Uint8 > g::Uint8 > b::Uint8 > a::Uint8 RGBA{U8} is bitwise identical to this, so you can use reinterpret as needed. --Tim

Re: [julia-users] unexpected mapslice result on 0.5rc3

2016-09-15 Thread Tim Holy
https://github.com/JuliaLang/julia/issues/18524 On Wednesday, September 14, 2016 9:15:45 AM CDT Marius Millea wrote: > Is this the expected behavior? > > julia> mapslices(x->tuple(x), [1 2; 3 4], 1) > 1×2 Array{Tuple{Array{Int64,1}},2}: > ([2,4],) ([2,4],) > > julia> mapslices(x->tuple(x...),

Re: [julia-users] Hard-to-debug deep inlining

2016-09-13 Thread Tim Holy
Which version of julia? If you're not using 0.5, try it and you might be pleased. You can also launch `julia --inline=no`, which occasionally still remains useful. --Tim On Tuesday, September 13, 2016 8:55:58 AM CDT Tim Wheeler wrote: > Hi Julia Users, > > So I was looking at

Re: [julia-users] Re: equivalent of numpy newaxis?

2016-09-12 Thread Tim Holy
nt? (Note that for both of them, the result is 2-dimensional.) --Tim On Monday, September 12, 2016 6:47:04 PM CDT Neal Becker wrote: > I haven't studied it, but I guess that newaxis increases the dimensionality, > while specifying 0 for the stride. Can reshape do that? > > Tim Holy wrote:

Re: [julia-users] equivalent of numpy newaxis?

2016-09-12 Thread Tim Holy
I'm not certain I understand what `np.newaxis` does, but doesn't `reshape` do the same thing? (newaxis does look like a convenient way to specify shape, though.) Best, --Tim On Monday, September 12, 2016 3:28:56 PM CDT Neal Becker wrote: > Some time ago I asked this question >

Re: [julia-users] Want to contribute to Julia

2016-09-12 Thread Tim Holy
There are some great resources at http://julialang.org/learning/ Best, --Tim On Monday, September 12, 2016 7:56:46 AM CDT rishucod...@gmail.com wrote: > Thanks for the help. Can you suggest me what should I learn to work in > Julia?

Re: [julia-users] Julia in top 50 on the TIOBE index

2016-09-11 Thread Tim Holy
Had not seen that, thanks for sharing. For this month's survey at least, passing Clojure, within sight of Rust, and nearly 1/3 of the way to Fortran. Pretty impressive. Nice work, Julia community! Best, --Tim On Sunday, September 11, 2016 12:52:21 AM CDT Viral Shah wrote: > Perhaps many of

Re: [julia-users] How does garbage collection really work in Julia?

2016-09-10 Thread Tim Holy
Every time julia allocates memory, it adds the number of bytes to a running tally; once that tally gets big enough, it does a garbage-collection pass (and resets the tally). Consequently GC is triggered only when you allocate, but even the smallest allocation can trigger GC if it pushes the

Re: [julia-users] Re: ProfileView not compatible with julia-0.5?

2016-09-10 Thread Tim Holy
More likely you just need to run Pkg.update(). For example, you can test with a "dummy" package repository: $ mkdir /tmp/pkgs * _* * _ _ _(_)_ | A fresh approach to technical computing* * (_) | (_) (_)| Documentation: http://docs.julialang.org* * _ _ _|

Re: [julia-users] Re: Cell array of images like Matlab

2016-09-10 Thread Tim Holy
Try putting a semicolon at the end of that line. Thanks for the bug report! https://github.com/timholy/Images.jl/issues/554 --Tim On Friday, September 9, 2016 5:18:45 PM CDT Drew Mahedy wrote: > In Julia, if I try and concatenate two images together of type: > >

Re: [julia-users] Re: How I did get a spurious method for *{T}(Irrational{T},Irrational{T})?

2016-09-09 Thread Tim Holy
https://github.com/JuliaLang/julia/issues/18419 --Tim On Wednesday, September 7, 2016 12:59:05 AM CDT Lutfullah Tomak wrote: > A reduced case that also makes multiplication of the same Irrational an > error. > >_ >_ _ _(_)_ | A fresh approach to technical

Re: [julia-users] Re: Is it better to call Julia from C++ or call C++ from Julia?

2016-09-08 Thread Tim Holy
On Thursday, September 8, 2016 6:31:37 AM CDT Páll Haraldsson wrote: > Not sure I understand ("this case"), in another thread Tim Holy cautioned > that C++ would not be inlined into Julia functions, as Julia functions can > be. My caution was for the opposite direction: you

Re: [julia-users] There is very little overhead calling Julia from C++

2016-09-08 Thread Tim Holy
Keep in mind that statements like "very little overhead" depend entirely on what you're comparing against. Your TestFunc is quite expensive, so it's not surprising that how it's called adds little overhead. If you called a much cheaper function, you might come to a rather different conclusion.

Re: [julia-users] Re: Saving and Loading data (when JLD is not suitable)

2016-08-31 Thread Tim Holy
https://github.com/JuliaIO/JLD.jl/blob/master/doc/jld.md#custom-serialization On Wednesday, August 31, 2016 1:56:25 AM CDT Kristoffer Carlsson wrote: > I am sure you know but I just want to point out that it is possible to > overload the way JLD saves and loads types. You can write a custom save

Re: [julia-users] Re: Adding items into a tuple

2016-08-30 Thread Tim Holy
On Tuesday, August 30, 2016 3:57:36 PM CDT Yichao Yu wrote: > And even then, this completely looses the advantage of using tuple > (inferrable size and element types) so you shouldn't do this in general > unless you are going to do a lot of work with the tiny tuple afterwards. Right. If you want

Re: [julia-users] Running Julia in Ubuntu

2016-08-30 Thread Tim Holy
I'm rather surprised that building from source gave you version 0.4.7; I don't think that makes sense (it should have been master). Are you sure you know what you're running? (Try `.julia` from the directory in which you built julia, rather than just `julia`.) Best, --Tim On Monday, August

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

2016-08-29 Thread Tim Holy
I confess I'm not quite sure what the right answer is here. It would seem overkill to have both `I` and something that's the same thing, except sized. OTOH, I see the attraction. Maybe if it were part of a general mechanism, e.g., SizedArrayOperator{O,N} (for performing an operation `O` on

Re: [julia-users] @threads not providing as big speedup as expected

2016-08-29 Thread Tim Holy
eads > @timeit test(3000,40) > 1 loops, best of 3: 3.84 s per loop > > # without @threads > @timeit test(3000,40) > 1 loops, best of 3: 2.33 s per loop > > On Monday, August 29, 2016 at 6:50:15 PM UTC+2, Tim Holy wrote: > > Very quickly (train to catch!): try this >

Re: [julia-users] @threads not providing as big speedup as expected

2016-08-29 Thread Tim Holy
Very quickly (train to catch!): try this https://github.com/JuliaLang/julia/ issues/17395#issuecomment-241911387 and see if it helps. --Tim On Monday, August 29, 2016 9:22:09 AM CDT Marius Millea wrote: > I've parallelized some code with @threads, but instead of a factor NCPUs > speed

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

2016-08-29 Thread Tim Holy
On Monday, August 29, 2016 10:40:10 AM CDT Júlio Hoffimann wrote: > Why would one want dense identity matrix? Because you might want it to serve as an initialization for an iterative optimization routine (e.g., ICA) that updates the solution in place, and which assumes a dense matrix? We could

Re: [julia-users] Re: Hard time with Compat and 0.5

2016-08-29 Thread Tim Holy
To rephrase what Steven and Tony said, for some things you won't need a macro. For example, `unsafe_wrap` didn't exist on Julia 0.4, but Compat contains an implementation of `unsafe_wrap` for use on Julia 0.4. It's just a plain-old function call, so you don't need `@compat`---just use it in

Re: [julia-users] Wiener deconvolution

2016-08-29 Thread Tim Holy
Or perhaps make the package Deconvolution.jl, and have wiener be the first (and currently only) method? Best, --Tim On Sunday, August 28, 2016 12:44:44 PM CDT Mosè Giordano wrote: > Hi all, > > I wrote a very simple implementation of the Wiener deconvolution >

Re: [julia-users] Wiener deconvolution

2016-08-29 Thread Tim Holy
If you can't find another home, I'd be happy to have it in Images, but to me DSP seems like the (slightly) better choice. That said, I also don't think it's terrible to have small packages (they are easier to document and faster for newcomers to come to grips with), so it could also stay a

Re: [julia-users] Unstructured Spline2D (progress / performance)

2016-08-29 Thread Tim Holy
For unstructured grids, it depends a lot on what you want. I'm a fan of piecewise linear polyhedral interpolation, but there are many other choices: https://en.wikipedia.org/wiki/Multivariate_interpolation#Irregular_grid_. 28scattered_data.29. One of the (many) Voronoi/Delaunay packages should

Re: [julia-users] does quote...end really create a QuoteNode?

2016-08-28 Thread Tim Holy
julia> qn = :(:n) :(:n) julia> ex = :("My docstring about n, which has value $($qn))") :("My docstring about n, which has value $(:n))") julia> dump(ex) Expr head: Symbol string args: Array{Any}((3,)) 1: String "My docstring about n, which has value " 2: QuoteNode value:

Re: [julia-users] Blob detection and size measurement in Julia?

2016-08-27 Thread Tim Holy
Good catch. Looks like the edge-handling in `findlocalmaxima` needed to be a bit more refined---it was discarding results from the first and last sigma- values supplied by the user. I may have fixed this in https://github.com/timholy/Images.jl/commit/ 7336f35c824b15de9e4d0def8e739bdeb6ed3b3d,

Re: [julia-users] Images package: Create and show image

2016-08-26 Thread Tim Holy
You must be using Julia 0.5, where `view` means something different than you're expecting (it creates a SubArray). Maybe try `display(img)`. Best, --Tim On Friday, August 26, 2016 1:31:46 PM CDT Bill Maier wrote: > I have the following code in an IJulia notebook(). The image is saved >

Re: [julia-users] Recursive/Circular parametric types

2016-08-25 Thread Tim Holy
enyEdge}() >confidence!(x, -1.0) >return x >end > end > > And define getters and setters in such a way that type assertions make > things certain for the compiler? > I saw that Jeff proposed a similar solution in julia issue #269 to handle > circular type de

Re: [julia-users] High memory consumption with loops

2016-08-24 Thread Tim Holy
What have you tried so far? See http://docs.julialang.org/en/latest/manual/ performance-tips/#tools, esp. @code_warntype. --Tim On Wednesday, August 24, 2016 1:55:23 PM CDT Venil Noronha wrote: > The following code seems to consume a lot of memory. Could anyone spot what > I'm doing wrong here?

Re: [julia-users] Recursive/Circular parametric types

2016-08-24 Thread Tim Holy
I don't think that's type-stable. Since each node of each tree will also be a different type, I also think you'll end up hating life due to compile times. There's some (peripherally) relevant discussion at http://docs.julialang.org/

Re: [julia-users] Re: ANN: Documenter.jl 0.3

2016-08-22 Thread Tim Holy
I haven't inspected anything in detail, but I agree with Kristoffer that my first impression is that I really like the new look. Nice work, folks. Best, --Tim On Monday, August 22, 2016 1:30:39 PM CDT Kristoffer Carlsson wrote: > Just from looking at the generated docs for the Documenter

Re: [julia-users] Re: higher rank sparse matrices

2016-08-21 Thread Tim Holy
Perhaps https://github.com/JuliaComputing/NDSparseData.jl? --Tim On Sunday, August 21, 2016 8:14:48 AM CDT Kristof Cools wrote: > Just wondering whether there have emerged any packages for this in the > meantime. I need a rank 3 sparse matrix to implement a retarded potential > integral equation

Re: [julia-users] suspect memory allocation in generated function

2016-08-21 Thread Tim Holy
Not an answer to your question (I don't have time to check now), but in case it helps perhaps FFTViews may be a useful model. (The code is shorter than the README :-).) https://github.com/timholy/FFTViews.jl I think getting its tests to pass requires what will become julia-0.5+rc3 (currently

Re: [julia-users] Re: ANN: Optim v0.6

2016-08-14 Thread Tim Holy
For what it's worth, long ago I was caught by that once, too. To fix it, I think all one would have to do is make the doc badges 2x larger (if possible). --Tim On Sunday, August 14, 2016 1:22:26 AM CDT Kristoffer Carlsson wrote: > What did you expect them to be? They are right under a big

Re: [julia-users] Re: "eval cannot be used in a generated function"

2016-08-10 Thread Tim Holy
AFAICT, it remains possible to do dynamic type generation if you (1) print the code that would define the type to a file, and (2) `include` the file. function create_type_dynamically{T}(::Type{T}) type_name = string("MyType", T) isdefined(Main, Symbol(type_name)) && return nothing

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

2016-08-09 Thread Tim Holy
I'd recommend starting by picking a very small project. For example, fix a bug or implement a small improvement in a package that you already find useful or interesting. That way you'll get some guidance while making a positive contribution; once you know more about julia, it will be easier to

Re: [julia-users] precompiling all packages

2016-08-09 Thread Tim Holy
There are several previous threads on this, hopefully one of those will help. Best, --Tim On Monday, August 8, 2016 8:13:42 PM CDT Chang Kwon wrote: > Is there a way to precompile all packages at once? Each time that I run > Pkg.update(), I would also like to precompile all packages so that when

Re: [julia-users] How do I write `import Base.!` in julia 0.5?

2016-08-09 Thread Tim Holy
import Base: ! also works (and you can include more operators). --Tim On Monday, August 8, 2016 9:59:25 PM CDT Fengyang Wang wrote: > On Monday, August 8, 2016 at 10:26:46 AM UTC-4, Kevin Squire wrote: > > Try > > > > import Base.(!) > > > > Cheers, > > > > Kevin > > Why do import

Re: [julia-users] Re: CALL TO ACTION for package devs

2016-08-05 Thread Tim Holy
Aside from checking out the package's master, a glance at the list of open PRs and recent commits usually tells you a lot. Best, --Tim On Thursday, August 4, 2016 7:23:11 PM CDT Chris Rackauckas wrote: > Not always. Some repos have a dev branch or a v0.5 compatibility branch, > etc. I think

Re: [julia-users] Re: Tuples of Functions

2016-08-02 Thread Tim Holy
On Wednesday, August 3, 2016 6:34:51 AM CDT Yichao Yu wrote: > I guess I could register it after some clean up later, given that we had > FastAnonymous package (which was in a very similar situation, if not > slightly more undefined than this one, sorry @timholy ;-p ) Hey, no sweat. I agree that

Re: [julia-users] I'd like to see something like the Rust platform proposal in the Julia ecosystem

2016-08-01 Thread Tim Holy
module MyMetaPackage using Reexport @reexport using PackageA @reexport using PackageB ... end Best. --Tim On Monday, August 1, 2016 1:48:47 AM CDT Steven Sagaert wrote: > is more than just a webpage with a list of packages... for starters the > concept of metapackage. > > On Monday, August

Re: [julia-users] Re: Writing code compatible with custom-indexed arrays

2016-07-26 Thread Tim Holy
t that a bit un-Julianic? Or > are you worried that people will then start using (e.g.) 1:len(A) instead > of 1:length(A), resulting in an even bigger mess? > > On Tuesday, July 26, 2016 at 1:47:57 PM UTC+2, Tim Holy wrote: > > On Tuesday, July 26, 2016 2:31:10 AM CDT Oliver Schulz

Re: [julia-users] Re: Writing code compatible with custom-indexed arrays

2016-07-26 Thread Tim Holy
OK, new package here: https://github.com/timholy/EndpointRanges.jl It might make life easier even for folks who aren't using custom-indexed arrays. Give it a whirl and see what breaks! Best, --Tim On Tuesday, July 26, 2016 2:31:10 AM CDT Oliver Schulz wrote: > Hi Tim, > > I should have known

Re: [julia-users] Re: Writing code compatible with custom-indexed arrays

2016-07-26 Thread Tim Holy
On Tuesday, July 26, 2016 2:31:10 AM CDT Oliver Schulz wrote: > I should have known you already have a (very elegant) solution in your > pocket. :-) I really like your proposed first:last syntax! As discussed in that issue, the problem is that it may not be workable (it's also very unlikely to

Re: [julia-users] Writing code compatible with custom-indexed arrays

2016-07-26 Thread Tim Holy
Hi Oliver, On Tuesday, July 26, 2016 12:21:27 AM CDT Oliver Schulz wrote: > Will there by something like > > A[start+1:end-1] That would be lovely. See discussion in https://github.com/JuliaLang/julia/ pull/15750. > length(linearindices(A)) > > instead of length() in generic code. This

Re: [julia-users] Re: A Very Simple Benchmark for Brutal-force Loops in Several Languages: revised, Julia is fast!

2016-07-25 Thread Tim Holy
Given the apparent interest in the topic and the decisions that people seem to be making, it seems worth pointing out that folks are still using apples-to- oranges comparisons on this benchmark. There are at least two important differences: - in the other languages, `linspace` allocates a

Re: [julia-users] Re: Tuple type to tuple of types

2016-07-24 Thread Tim Holy
As long as you don't mind preserving exactly what's between the {}, (t.parameters...) is an easy way to get this. --Tim On Sunday, July 24, 2016 5:21:56 AM CDT Kristoffer Carlsson wrote: > Maybe; > > type MyType end > > function f(t::DataType) > I = () > for t in t.types > if isa(t,

Re: [julia-users] findpeaks

2016-07-20 Thread Tim Holy
On Wednesday, July 20, 2016 4:01:00 PM CDT Gabriel Gellner wrote: > Is there a standard (Base or common package) that implements something akin > to matlab's `findpeaks`. It is easy enough to make something like this, but > I imagined that this would be something that already exists but that I

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

2016-07-19 Thread Tim Holy
They can mean "real" boxing and consequent performance problems, but sometimes these get auto-removed during compilation. I see this all the time when writing array code, for example this function which takes an input tuple and adds 1 to each element: julia> @inline inc1(a) = _inc1(a...) inc1

Re: [julia-users] Re: Few questions about methods and sub()

2016-07-16 Thread Tim Holy
Perhaps just f = (U,V) -> flipdim(conv(flipdim(U, 1), V), 1) if su < sv return f([u; zeros(eltype(u), sv - su)], v) elseif sv < su return f(u, [v; zeros(eltype(v), su - sv)]) else return f(u, v) end ? Worth pointing out that this is not specific to SubArrays; any AbstractArray

Re: [julia-users] Trying to understand parametric types as function arguments

2016-07-16 Thread Tim Holy
I never could tell my shapes apart. Nearly failed kindergarten because all my lines had 3 corners. --Tim On Saturday, July 16, 2016 4:20:04 AM CDT Patrick Kofod Mogensen wrote: > On Thursday, July 14, 2016 at 10:14:38 PM UTC+2, Tim Holy wrote: > > *Until we get "diagonal dispa

Re: [julia-users] Inherit from AbstractMatrix

2016-07-15 Thread Tim Holy
Hi Madeleine, Is there any chance you have two versions of julia installed, and are running the wrong one? (Confession: I make that mistake surprisingly frequently!) The reason I ask is that on current master: julia> methodswith(Array, kron) 0-element Array{Method,1} In master (which is what

Re: [julia-users] Trying to understand parametric types as function arguments

2016-07-14 Thread Tim Holy
Until we get "diagonal dispatch," I think the only way to do this is to expand the number of arguments in the function: myfunc(vec::Vector) = _myfunc(eltype(vec), vec) # internal function _myfunc{D<:Dict{ASCIIString}}(::Type{D}, vec) = 1 _myfunc{D}(::Type{D}, vec) = 2 julia>

Re: [julia-users] How to determine the type of a complex data structure

2016-07-12 Thread Tim Holy
What might be missing is to note the important difference between abstract and concrete types. Otherwise it might indeed be interpreted as advice to use curly-brackets in your type definitions. Best, --Tim On Tuesday, July 12, 2016 12:36:28 PM CDT Yichao Yu wrote: > On Tue, Jul 12, 2016 at

Re: [julia-users] A Very Simple Benchmark for Brutal-force Loops in Several Languages: Julia far from approaching C++ speed - any suggestions?

2016-07-11 Thread Tim Holy
The documentation page seems to be down at the moment, but when it's back up see the "performance tips" page. In particular, - never benchmark anything in global scope, always wrap it in a function - always run once before you benchmark it (to force JIT compilation) --Tim On Sunday, July 10,

Re: [julia-users] Few questions about methods and sub()

2016-07-09 Thread Tim Holy
much of a coding noob to figure out what to do > (even with your precious hint). > > On Saturday, 9 July 2016 14:15:29 UTC+1, Tim Holy wrote: > > Looks like xcorr has a type-instability. You can see this from > > > > x = rand(10 * 192000); u = rand(10 * 192000, 3); >

Re: [julia-users] Few questions about methods and sub()

2016-07-09 Thread Tim Holy
Looks like xcorr has a type-instability. You can see this from x = rand(10 * 192000); u = rand(10 * 192000, 3); su = sub(u, :, 1); @code_warntype xcorr(x, su) Would you mind filing an issue? https://github.com/JuliaLang/julia/issues/new Alternatively, if you feel up to fixing it, the hint is

Re: [julia-users] Ambiguity error when dispatching on Union types

2016-07-09 Thread Tim Holy
Ambiguities are often a bit tricky. Two tips I've adopted: - Have as few methods as possible, and declare types on their arguments only when absolutely necessary. These measures greatly reduce your exposure to the risk of ambiguities. To achieve this, it sometimes takes a fair bit of thought

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

2016-07-08 Thread Tim Holy
On Friday, July 8, 2016 6:43:36 PM CDT Daniel Carrera wrote: > For that matter, will there be upper case functions for every > concrete type? ... I'm just curious. I wouldn't actually use that feature. Yes, it's just the constructor. In most cases you don't have to define them manually, they are

Re: [julia-users] how to tell if a jld file contains a dataset?

2016-07-08 Thread Tim Holy
`has` or `exists` --Tim On Friday, July 8, 2016 8:01:40 AM CDT Davide Lasagna wrote: > I have read the available documentation but I cannot seem to get it. > > How do I test whether an existing .jld file, opened as > > jldopen(filename, "r") do handle > # test whether handle contains the

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

2016-07-08 Thread Tim Holy
The string unification is already in julia-0.5. There are functions called String(), Int(), and Float64(). In some cases there are lowercase variants, and these often "do more" (e.g., `float` will parse a string and return an AbstractFloat). The uppercase versions are the minimalist

Re: [julia-users] Re: Converting from ColorTypes to Tuple

2016-07-07 Thread Tim Holy
On Thursday, July 7, 2016 4:41:10 PM CDT Islam Badreldin wrote: > Maybe > this means PyPlot.jl needs to add better support for ColorTypes? That sounds like a very reasonable solution. I don't really know PyPlot at all, so I don't have any advice to offer, but given how well you seem to

Re: [julia-users] Re: Converting from ColorTypes to Tuple

2016-07-05 Thread Tim Holy
Well, you've just written that convenience function yourself :-). It's not more complicated than that. The reason there isn't an exported function is because the general case is not quite as simple as it may seem. For example, BGR and RGB both mean "RGB colors," but with different internal

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

2016-07-05 Thread Tim Holy
both. This way I can easily the profiling via > > julia> Profile.print(format=:flat, sortedby=:count) > > Sorry for my dumb question. > > On Tuesday, July 5, 2016 at 12:49:37 PM UTC+1, Tim Holy wrote: > > I don't know what "profiling a module" means. You profil

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

2016-07-05 Thread Tim Holy
I don't know what "profiling a module" means. You profile running code, wherever that code happens to live---and that's all there is to say. To profile the code in a module, you just have to write code that exercises the functions in the module. The meaning of the numbers is described here:

Re: [julia-users] How to store tuples in different jld files

2016-07-03 Thread Tim Holy
Duplicated in http://stackoverflow.com/questions/38147946/julia-how-to-store-tuples-in-different-files --Tim On Friday, July 1, 2016 7:48:34 AM CDT Ahmed Mazari wrote: > Hello, > > l want to store each tuple X[p] in a different file > # X[1] in mini_batch1.jld X[2] in mini_batch2. > # but

Re: [julia-users] PriorityQueue for fast large network simulation

2016-07-01 Thread Tim Holy
ay, July 1, 2016 5:27:03 PM CDT Rainer J. Engelken wrote: > 2016-07-01 11:41 GMT+02:00 Tim Holy <tim.h...@gmail.com>: > > My guess is that you could do better by doing a "batch update" of the > > queue, > > so that you don't rebalance the heap each time. > >

Re: [julia-users] Re: A naive benchmark

2016-07-01 Thread Tim Holy
Read about cache here: http://julialang.org/blog/2013/09/fast-numeric and add @inbounds @simd in front of the inner loop. --Tim On Friday, July 1, 2016 8:10:33 AM CDT baillot maxime wrote: > Thank you but don't worry in general I do it like 3 or 4 times before > looking at the time :) > > I

Re: [julia-users] Re: how to hide deprecated warning ?

2016-06-30 Thread Tim Holy
To translate: [a] concatenation is deprecated; use collect(a) instead in depwarn at ./deprecated.jl:73 while loading In[2], in expression starting on line 9 The first line implies you have some object `a` and you're putting brackets around it, `[a]`. Julia is telling you to switch

[julia-users] Julia community stewards

2016-06-29 Thread Tim Holy
Hi everyone, I'm writing to call your attention to a new page on the julialang website, explaining the mission of a newly-created group called "Julia Stewards": http://julialang.org/community/stewards/ This is a group that we hope will have very little to do, but which seems important

Re: [julia-users] Row/column iterators?

2016-06-27 Thread Tim Holy
In Base there's mapslices, which may already do what you want. Something like what you're proposing (but not yet with a nice "high level" API wrapper, since the low-level stuff is still in flux) is already here: https://github.com/timholy/ArrayIteration.jl That's aiming at a very general

Re: [julia-users] Efficient iteration for tensor dot product - alternatives to splatting

2016-06-26 Thread Tim Holy
I'd try TensorOperations.jl or AxisAlgorithms.jl Best, --Tim On Sunday, June 26, 2016 4:24:17 AM CDT Alex Williams wrote: > I'm trying to code an efficient implementation of the n-mode tensor > product. Basically, this amounts to taking a dot product between a vector > (b) and the mode-n fibers

Re: [julia-users] Re: Segfaults in SharedArrays

2016-06-26 Thread Tim Holy
On Sunday, June 26, 2016 3:27:57 AM CDT Nils Gudat wrote: > Oh well that would explain why it had no effect then - is there some > version that contains this fix then? Would building the current 0.4.7+ > master from source do? (Sorry, I've stuck strictly to stable versions so > far so am not well

Re: [julia-users] Re: Drop element from tuple

2016-06-26 Thread Tim Holy
On Saturday, June 25, 2016 6:45:05 AM CDT jw3126 wrote: > @Tim: Thanks for the insights! On my machine slowness starts to kick in at > size 9 already. Depends on which version of julia you're running (I'm running a recent julia-0.5-dev). > I tried to read the llvm code, but did not really >

Re: [julia-users] Re: Drop element from tuple

2016-06-25 Thread Tim Holy
It might scale just fine, because LLVM might discover the pattern of your "giant switch statement" and essentially compute a jump location. Even if not, if you're calling this repeatedly with a tuple of consistent length, the branches become predictable and then they kind of don't count. So in

Re: [julia-users] Re: Deepcopy of BigInt and BigFloat (#16999)

2016-06-20 Thread Tim Holy
On Sunday, June 19, 2016 at 10:20:11 PM UTC-5, Tim Holy wrote: > > Presumably if someone sat down and implemented similar operations in > pure-julia using, say, > tuples, it would blow away what we have now. Proof-of-principle in this gist: https://gist.github

Re: [julia-users] Re: Deepcopy of BigInt and BigFloat (#16999)

2016-06-19 Thread Tim Holy
On Sunday, June 19, 2016 5:51:35 PM CDT Chris Rackauckas wrote: > But as a user, I do find it troubling that the only reliable high-precision > number type is clearly not aiming for performance. More like "it's hard to make it high performance" because the interaction with the C library means

Re: [julia-users] Saving and Accessing Composite Types in HDF5

2016-06-17 Thread Tim Holy
Hmm, that needs fixing. Thanks for mentioning it. --Tim On Fri, Jun 17, 2016 at 4:04 PM, Kaela Martin wrote: > JLD worked! Thanks! > > As a side note, I typed in the wrong command and got lots of errors. > > save("temp.jld","t",t) > load("temp.jld","t",t) # t is > >

Re: [julia-users] Saving and Accessing Composite Types in HDF5

2016-06-17 Thread Tim Holy
Can you use JLD.jl? It also writes hdf5 files, but adds annotation to allow julia to know what it's dealing with. Best, --Tim On Friday, June 17, 2016 10:51:07 AM CDT Kaela Martin wrote: > Let's say I have a composite type of: > > type TEST > numbers > times > measurement > end >

  1   2   3   4   5   6   7   8   9   10   >