-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uninitialized object exists on backward branch 108 in clojurescript #341
Comments
I've just checked out the project as a checkout and so far all the test cases clj and cljs pass. |
Ok, updating the clojure version to Updating clojurescript from (deftest test-norm
(is (== (Math/sqrt 30.0) (li/norm (matrix [[1 2][3 4]]))))
(is (== (Math/sqrt 30.0) (li/norm (matrix [[1 2][3 4]]) 2)))
(is (== 10.0 (li/norm (matrix [[1 2][3 4]]) 1)))
;;fails test
;;(is (== (Math/cbrt 100.0) (li/norm (matrix [[1 2][3 4]]) 3)))
(is (== 4 (li/norm (matrix [[1 2][3 -4]]) #?(:clj Double/POSITIVE_INFINITY :cljs Infinity))))
(is (== (Math/sqrt 30.0) (li/norm (vector 1 2 3 4))))
(is (== (Math/sqrt 30.0) (li/norm (vector 1 2 3 4) 2)))
(is (== 10.0 (li/norm (vector 1 2 3 4) 1)))
;;fails test
;;(is (== (Math/cbrt 100.0) (li/norm (vector 1 2 3 4) 3)))
(is (== 4 (li/norm (vector 1 2 3 4) #?(:clj Double/POSITIVE_INFINITY :cljs Infinity))))) I believe the test case however may be in error: (deftest test-norm
(is (== (Math/sqrt 30.0) (li/norm (matrix [[1 2][3 4]]))))
(is (== (Math/sqrt 30.0) (li/norm (matrix [[1 2][3 4]]) 2)))
(is (== 10.0 (li/norm (matrix [[1 2][3 4]]) 1)))
;;fails test
;;(is (== (Math/cbrt 100.0) (li/norm (matrix [[1 2][3 4]]) 3)))
(is (== 4 (li/norm (matrix [[1 2][3 -4]]) #?(:clj Double/POSITIVE_INFINITY :cljs js/Infinity))))
(is (== (Math/sqrt 30.0) (li/norm (vector 1 2 3 4))))
(is (== (Math/sqrt 30.0) (li/norm (vector 1 2 3 4) 2)))
(is (== 10.0 (li/norm (vector 1 2 3 4) 1)))
;;fails test
;;(is (== (Math/cbrt 100.0) (li/norm (vector 1 2 3 4) 3)))
(is (== 4 (li/norm (vector 1 2 3 4) #?(:clj Double/POSITIVE_INFINITY :cljs js/Infinity))))) Has the test passing on both I'm not sure what to do regarding the fact that clojure |
Ok, so initially isolated it to However, funnily enough Which is prompting me to exhaustively see if a newer version works... |
Nope, just tried everything north of |
I've so far not been able to require |
Not able to require cljs.user=> (require '[clojure.core.matrix.dataset :as dataset])
Compile Warning /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc line:151 column:23
Use of undeclared Var clojure.core.matrix.utils/x
146 arr))
147 ([a b & more]
148 (let [arr (long-array (+ 2 (count more)))]
149 (aset arr 0 (long a))
150 (aset arr 1 (long b))
151 (doseq-indexed [x more i] (aset arr (+ 2 i) (long x)))
^---
152 arr)))
153
154 (defn object-array-of
155 "Creates a long array with the specified values."
156 ([] (object-array 0))
Compile Warning /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc line:151 column:30
Use of undeclared Var clojure.core.matrix.utils/i
146 arr))
147 ([a b & more]
148 (let [arr (long-array (+ 2 (count more)))]
149 (aset arr 0 (long a))
150 (aset arr 1 (long b))
151 (doseq-indexed [x more i] (aset arr (+ 2 i) (long x)))
^---
152 arr)))
153
154 (defn object-array-of
155 "Creates a long array with the specified values."
156 ([] (object-array 0))
Compile Warning /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc line:151 column:48
Use of undeclared Var clojure.core.matrix.utils/i
146 arr))
147 ([a b & more]
148 (let [arr (long-array (+ 2 (count more)))]
149 (aset arr 0 (long a))
150 (aset arr 1 (long b))
151 (doseq-indexed [x more i] (aset arr (+ 2 i) (long x)))
^---
152 arr)))
153
154 (defn object-array-of
155 "Creates a long array with the specified values."
156 ([] (object-array 0))
Compile Warning /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc line:151 column:57
Use of undeclared Var clojure.core.matrix.utils/x
146 arr))
147 ([a b & more]
148 (let [arr (long-array (+ 2 (count more)))]
149 (aset arr 0 (long a))
150 (aset arr 1 (long b))
151 (doseq-indexed [x more i] (aset arr (+ 2 i) (long x)))
^---
152 arr)))
153
154 (defn object-array-of
155 "Creates a long array with the specified values."
156 ([] (object-array 0))
Compile Warning /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc line:170 column:23
Use of undeclared Var clojure.core.matrix.utils/x
165 arr))
166 ([a b & more]
167 (let [arr (object-array (+ 2 (count more)))]
168 (aset arr 0 a)
169 (aset arr 1 b)
170 (doseq-indexed [x more i] (aset arr (+ 2 i) x))
^---
171 arr)))
172
173 (defn find-index
174 "Returns the index of a value in a vector, or nil if not present"
175 ([^IPersistentVector v value]
Compile Warning /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc line:170 column:30
Use of undeclared Var clojure.core.matrix.utils/i
165 arr))
166 ([a b & more]
167 (let [arr (object-array (+ 2 (count more)))]
168 (aset arr 0 a)
169 (aset arr 1 b)
170 (doseq-indexed [x more i] (aset arr (+ 2 i) x))
^---
171 arr)))
172
173 (defn find-index
174 "Returns the index of a value in a vector, or nil if not present"
175 ([^IPersistentVector v value]
Compile Warning /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc line:170 column:48
Use of undeclared Var clojure.core.matrix.utils/i
165 arr))
166 ([a b & more]
167 (let [arr (object-array (+ 2 (count more)))]
168 (aset arr 0 a)
169 (aset arr 1 b)
170 (doseq-indexed [x more i] (aset arr (+ 2 i) x))
^---
171 arr)))
172
173 (defn find-index
174 "Returns the index of a value in a vector, or nil if not present"
175 ([^IPersistentVector v value]
Compile Warning /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc line:170 column:51
Use of undeclared Var clojure.core.matrix.utils/x
165 arr))
166 ([a b & more]
167 (let [arr (object-array (+ 2 (count more)))]
168 (aset arr 0 a)
169 (aset arr 1 b)
170 (doseq-indexed [x more i] (aset arr (+ 2 i) x))
^---
171 arr)))
172
173 (defn find-index
174 "Returns the index of a value in a vector, or nil if not present"
175 ([^IPersistentVector v value]
Compile Warning /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/impl/common.cljc line:55 column:18
Use of undeclared Var clojure.core.matrix.impl.common/ClassCastException
50 Uses a default implementation if needed"
51 ([impl data]
52 (or (mp/construct-matrix impl data)
53 (try
54 (mp/construct-matrix mi/*matrix-implementation* data)
55 (catch ClassCastException t nil)) ;; fix for element type not handled
^---
56 (mp/construct-matrix [] data))))
57
58 (defn mapmatrix
59 "Maps a function over all components of a persistent vector matrix. Like mapv but for matrices.
60 Assumes correct dimensionality / shape.
Compile Warning /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/impl/defaults.cljc line:818 column:45
No such namespace: Long, could not locate Long.cljs, Long.cljc, or JavaScript source providing "Long"
813 ([pairs n]
814 (let [^objects dest (object-array n)]
815 (loop [i (long 0)
816 pairs (seq pairs)]
817 (when (< i n)
818 (aset dest (first (first pairs)) (Long/valueOf i))
^---
819 (recur (inc i)
820 (next pairs))))
821 (vec dest))))
822
823 (extend-protocol mp/PIndexRank
Compile Warning /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/impl/defaults.cljc line:818 column:45
Use of undeclared Var Long/valueOf
813 ([pairs n]
814 (let [^objects dest (object-array n)]
815 (loop [i (long 0)
816 pairs (seq pairs)]
817 (when (< i n)
818 (aset dest (first (first pairs)) (Long/valueOf i))
^---
819 (recur (inc i)
820 (next pairs))))
821 (vec dest))))
822
823 (extend-protocol mp/PIndexRank
Compile Warning /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/impl/defaults.cljc line:2000 column:72
Use of undeclared Var clojure.core.matrix.impl.defaults/class
1995 (reshape-view [m shape]
1996 (mp/broadcast m shape))
1997 #?(:clj Object :cljs object)
1998 (reshape-view [m shape]
1999 (if (mp/is-mutable? m)
2000 (TODO "reshape-view not supported on mutable array of type: " (class m))
^---
2001 (mp/reshape m shape))))
2002
2003 (extend-protocol mp/PCoercion
2004 nil
2005 (coerce-param [m param]
Compile Warning /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/impl/dataset.cljc line:330 column:1
Extending an existing JavaScript type - use a different symbol name instead of js/Object e.g object
325 (convert-to-nested-vectors [ds]
326 (let [cols ( #?(:clj .columns :cljs .-columns) ds)
327 ix (get-index0 ds)]
328 (mapv #(mp/get-1d % ix) cols))))
329
330 (extend-protocol mp/PColumnIndex
^---
331 #?(:clj Object :cljs js/Object)
332 (column-index [ds column-name]
333 (when-let [cnames (mp/column-names ds)]
334 (let [cnames ^IPersistentVector (vec cnames)]
335 (and cnames (utils/find-index cnames column-name))))))
Compile Warning /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/impl/dataset.cljc line:421 column:1
Extending an existing JavaScript type - use a different symbol name instead of js/Object e.g object
416 (dataset-from-columns
417 (concat (mp/column-names ds1) (mp/column-names ds2))
418 (concat (mp/get-columns ds1) (mp/get-columns ds2)))
419 (error "Duplicate column names: " isection)))))
420
421 (extend-protocol mp/PDatasetMaps
^---
422 DataSet
423 (row-maps [ds]
424 (let [col-names (mp/column-names ds)]
425 (mapv #(zipmap col-names %)
426 (mp/get-rows ds))))
Compile Warning /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix.cljc line:271 column:14
Use of undeclared Var clojure.core.matrix/Throwable
266 If the current implementation does not support mutable matrices, will return a mutable array
267 from another core.matrix implementation that supports either the same element type or a broader type."
268 ([data]
269 (try (or (mp/mutable-matrix data)
270 (mutable (implementation-check) data))
271 (catch Throwable t ;; catch error in array construction, attempt to use a default implementation
^---
272 (default/construct-mutable-matrix data))))
273 ([implementation data]
274 (let [imp (implementation-check implementation)
275 r (mp/construct-matrix imp data)]
276 (or (and r (mp/ensure-mutable r)) ;; ensure contructed array is mutable, else fall through with nil Going to test with the |
Finally got it to work with cljs.user=> (require '[clojure.core.matrix.dataset :as dataset])
nil
cljs.user=> (dataset/dataset [{:a 1 :b 2} {:a 4 :b 5}])
Eval timed out!
No stacktrace available. |
I've had some success after someone suggested swapping to openjdk 8, as in I can require it, but I can't seem to get it currently working in the cljs repl. I'll do some more testing and update here if I figure anything out... |
Cool thanks! I don't really understand the cljs implementation too well but happy to help merge any changes needed. |
FWIW, I'm facing the same error without involving ClojureScript at all. Minimal repro:
On Mac |
From the error message, I conjectured that the issue was linked the self-referential constructor invocation in The changes proposed in the above PR remove that via Var indirection. I've checked manually that this does indeed fix the issue -
|
Reviewing #81, I get the impression clojurescript should work without issue?
However I get this exception when requiring the library:
I wasn't expecting the java error to be the cause.
The text was updated successfully, but these errors were encountered: