Closed mikera closed 10 years ago
Temporary fix is to drop core.matrix dependency back to 0.10.0
I investigated this issue a little bit. The problem is the behaviour of NDArray with empty shape. PersistentVector returns just the number in this case while NDArray has these wrapper types which are problematic for me because expresso treats elements with [] as normal numbers. Also it relied up to now on the behaviour that new-array returns a zero filled vector with the given shape. As I look into the docstring now it says it will be initialized with the default value of the implementation and that is null for ndarray. I would like the behaviour of new-vector generalized here for arbitrary shape. Note that ndarray fills with 0.0 with new-vector. Maybe a fill method in core.matrix would be a good idea. I see there is already a fill! method. The other huge annoyance is that an NDArray doesn't behave like a vector: assoc doesn't work and more important count doesn't work. Switching count to ecount introduces a bug because count is only concerned with the top level. I think it is very important to support the normal clojure vector api on NDArray especially if it is the default implementation considering how fast you get ndarrays from core.matrix functions even if you never specified it.
@si14 copying you in on this because you probably have some good ideas :-)
Some points:
new-array
variant that fills with zeros is probably a good idea. Alternatively :ndarray-double
should do zero filling by defaultfill
sounds sensible for API completeness, although assign
should already do the job.NDArray
probably can implement IPersistentVector - I think it's a good idea in principle but we need to think about the zero dimension case (is that consistent with IPersistentVector??)(dimension-count m 0)
to get count
like behaviour on an arbitrary array. I've added a slice-count
function that does this for the next version@mschuene - NDArray with empty shape is the old zero-dimensional array issue again, right?
Something with a shape of [] could currently be either a scalar value or a 0-dimensional array. Actually I've been wondering if a scalar value should have a shape of nil
- would that help you?
Apart from that, it looks like core.logic is traversing the NDArray via seq, right? I'm surprised that this is returning a zero-dimensional array, it should pure return numbers when it gets down to the zero-dimensional level
@mikera - any news on this issue? Expresso runs fine with core.matrix 0.20.0
Came across a slightly odd bug, for some reason only seems to trigger on Travis CI builds.
It appears that core.logic is trying to turn an NDArray into a sequence, which fails when the NDArray is 0-dimensional (i.e. a scalar-sized NDArray). NDArray is
sequential?
so presumably core.logic is trying to unify with it?Not quite clear to me where the defect is, seem to be two possibilities: