This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-10
Channels
- # beginners (97)
- # boot (77)
- # cider (7)
- # cljs-dev (47)
- # cljsrn (3)
- # clojure (125)
- # clojure-austin (5)
- # clojure-dusseldorf (1)
- # clojure-italy (4)
- # clojure-russia (91)
- # clojure-spec (80)
- # clojure-uk (54)
- # clojurescript (92)
- # core-async (6)
- # cursive (17)
- # datomic (56)
- # hoplon (7)
- # immutant (3)
- # liberator (3)
- # luminus (4)
- # off-topic (26)
- # om (41)
- # om-next (11)
- # pedestal (3)
- # perun (3)
- # protorepl (25)
- # re-frame (32)
- # reagent (33)
- # ring (46)
- # rum (3)
- # spacemacs (5)
- # specter (82)
- # test-check (16)
- # untangled (8)
- # yada (26)
Someone a idea when I use atom and I have some spec tests in my code. The proto-repl refuses to boot up properly
@roelofw you could ask in the #protorepl channel and see if someone there can help.
@agile_geek thanks
This has probably been asked alot of times but is it true that the symmetrize-body-parts function of clojure for the brave and true is flawed? the loop creates an empty remaining-asym-parts let and then checks if it's empty..
@wilcov does it? Where are you getting the code from? I don't have a print version but this is from the on-line version:
(defn symmetrize-body-parts
"Expects a seq of maps that have a :name and :size"
[asym-body-parts]
(loop [remaining-asym-parts asym-body-parts
final-body-parts []]
(if (empty? remaining-asym-parts)
final-body-parts
(let [[part & remaining] remaining-asym-parts]
(recur remaining
(into final-body-parts
(set [part (matching-part part)])))))))
This code sets remaining-asym-parts
to the asym-body-parts
argument passed to the fn. Can't see anything wrong there?that's weird, i also got the code form the online version. The result i get is
[{:name "head", :size 3} {:name "left-eye", :size 1} {:name "left-ear", :size 1} {:name "mouth", :size 1} {:name "nose", :size 1} {:name "neck", :size 2} {:name "left-shoulder", :size 3} {:name "left-upper-arm", :size 3} {:name "chest", :size 10} {:name "back", :size 10} {:name "left-forearm", :size 3} {:name "abdomen", :size 6} {:name "left-kidney", :size 1} {:name "left-hand", :size 2} {:name "left-knee", :size 2} {:name "left-thigh", :size 4} {:name "left-lower-leg", :size 3} {:name "left-achilles", :size 1} {:name "left-foot", :size 2}]
So my original statement was false, it doesn't set it to an empty value (wrong logic on my part). But it also doesn't add the right-side body parts. which is what confused me originally
Not what I get. Are you sure you eval'ed all the fn's and def's and that your repl is in the correct state?
I get this:
[{:name "head", :size 3}
{:name "left-eye", :size 1}
{:name "right-eye", :size 1}
{:name "left-ear", :size 1}
{:name "right-ear", :size 1}
{:name "mouth", :size 1}
{:name "nose", :size 1}
{:name "neck", :size 2}
{:name "left-shoulder", :size 3}
{:name "right-shoulder", :size 3}
{:name "right-upper-arm", :size 3}
{:name "left-upper-arm", :size 3}
{:name "chest", :size 10}
{:name "back", :size 10}
{:name "left-forearm", :size 3}
{:name "right-forearm", :size 3}
{:name "abdomen", :size 6}
{:name "left-kidney", :size 1}
{:name "right-kidney", :size 1}
{:name "left-hand", :size 2}
{:name "right-hand", :size 2}
{:name "right-knee", :size 2}
{:name "left-knee", :size 2}
{:name "right-thigh", :size 4}
{:name "left-thigh", :size 4}
{:name "right-lower-leg", :size 3}
{:name "left-lower-leg", :size 3}
{:name "right-achilles", :size 1}
{:name "left-achilles", :size 1}
{:name "right-foot", :size 2}
{:name "left-foot", :size 2}]
@wilcov silly question but you are invoking symmeterize-body-parts
correctly? I.e. (symmetrize-body-parts asym-hobbit-body-parts)
and not symmetrize-body-parts asym-hobbit-body-parts
?
The second one is without the parens and will just return the eval'ed symbol asym-hobbit-body-parts
which will obviously just be the initial value.
@agile_geek yes i was using the parentizes version. I've loaded up a lein repl (i use spacemacs with the clojure layer normally) and after i manually define the functions and values i get the correct values. Thanks for your help, it seems there's either something wrong with my spacemacs or i'm simply not using it right
I use emacs rather than spacemacs but the only real difference is the keybindings and it works in eamcs. Make sure you eval the whole buffer with your code in it using CIDER (in emacs this is normally bound to C-c C-k
not sure in spacemacs)
@agile_geek i created a new file and copied the functions. The new file works so there was a error somewhere in the old file. I have no idea where, defining the functions never gave an error but oh well. Thanks đ i can continue my learning journey haha, was stuck for several hours
then the outcome is this :
{:name "Rembrandt Harmensz. van Rijn",
:title "Schutters van wijk II onder leiding van kapitein Frans Banninck Cocq, bekend als de âNachtwachtâ",
:id "SK-C-5"}
but when I try to do the same with :
(pmap (comp get-data-front-page get-art-object read-json-data) "SK-C-5")
I see this output :
Exception Something wrong with the front-pag e paintings2.api-get/get-data-front-page
so in your example it will convert the string into a seq of chars and use the function on each char separately
to make it work the same way, wrap the string in a vec: (pmap (comp get-data-front-page get-art-object read-json-data) [âSK-C-5"])
When I do this :
(defn test-funct
"all the test"
[]
(stest/summarize-results (stest/check 'paintings2.api-get/get-objectNumbers))
(stest/summarize-results (stest/check 'paintings2.api-get/get-art-object))
(stest/summarize-results (stest/check 'paintings2.api-get/get-data-detail-page))
(stest/summarize-results (stest/check 'paintings2.api-get/get-data-front-page))
(stest/summarize-results (stest/check `paintings2.api-get/get-image-url))
(stest/summarize-results (stest/check `paintings2.api-get/get-data-front-page-url))
(stest/summarize-results (stest/check `paintings2.api-get/get-data-detail-page)))
now someone in the proto-repl says I could replace my function with this :
(defn test-funct
"all the test"
[]
(stest/summarize-results (stest/check)))
now the front-page and detail page test are failing like this:
{:sym paintings2.api-get/get-data-front-page}
{:spec
(fspec
:args
(cat :args (coll-of :paintings2.api-get/objectNumber))
:ret
(coll-of (and :basic/artObject :image/object))
:fn
nil),
:sym paintings2.api-get/fetch-paintings-and-images-front-page,
:failure #error {
:cause "Something wrong with the front-pag e"
:via
[{:type java.util.concurrent.ExecutionException
:message "java.lang.Exception: Something wrong with the front-pag e"
:at [java.util.concurrent.FutureTask report "FutureTask.java" 122]}
{:type java.lang.Exception
:message "Something wrong with the front-pag e"
:at [paintings2.api_get$get_data_front_page invokeStatic "form-init1214856096370173557.clj" 147]}]
:trace
[[paintings2.api_get$get_data_front_page invokeStatic "form-init1214856096370173557.clj" 147]
[paintings2.api_get$get_data_front_page invoke "form-init1214856096370173557.clj" 137]
[clojure.core$comp$fn__6823 invoke "core.clj" 2542]
[clojure.core$comp$fn__6823 invoke "core.clj" 2542]
[clojure.core$pmap$fn__9385$fn__9386 invoke "core.clj" 6897]
[clojure.core$binding_conveyor_fn$fn__6772 invoke "core.clj" 2020]
[clojure.lang.AFn call "AFn.java" 18]
[java.util.concurrent.FutureTask run "FutureTask.java" 262]
[java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1145]
[java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 615]
[java.lang.Thread run "Thread.java" 745]]}}
do you use any mutable objects or something that may not be thread-safe in your functions?
Not that I know of , here is the code when the tests are failing : https://github.com/rwobben/paintings/blob/master/src/clj/paintings2/api_get.clj
okay, after glancing at the code I couldnât see anything obvious, so I canât really help with this one, sorry đ
@roelof I have roughly zero experience with clojure.spec.test, so I have no idea what would happen, but Iâd be tempted to add a line like _ (prn {:art-object art-object})
just before the line that says checked (s/conform ::artObject art-object)
in the get-data-front-page
fn
@manutter51 when I do that atom seems to not to be responding to anything
Not sure what you mean by ânot respondingâ? You mean returning nil?
Wow, thatâs a new one on me
wait âatomâ as in a Clojure (atom)
, or âatomâ as in the Atom editor?
Whew, my brain was exploding trying to figure out how a Clojure (atom)
could fail to respond.
So art-object
is probably too big to render in the repl
maybe try changing that (prn)
line to be _ (prn {:type (type art-object)})
â mostly curious to see if youâre getting some kind of weird data there
Same happens, I see the output od the (-(prn .... ))
and then the Atom ide seems not be to responding
The first thing you need to do is confirm that (stest/summarize-results (stest/check))
actually does what you expect.
I would try loading a regular repl from the terminal and running that and seeing if it matches your expectations
You could try lein repl
to get the old tried-and-true command line repl (or better yet, rlwrap lein repl
if you have rlwrap installed)
the problem with things like proto-repl is they are another layer of stuff, and can make things more complicated
This is the output I see (require `[paintings2.api-get :as m]) nil user=> (m/test-funct) CompilerException java.lang.RuntimeException: No such namespace: m, compiling:(C:\Users\rwobb\AppData\Local\Temp\form-init6650075369155190938.clj:1:1)
If itâs the command line repl, I donât think autocomplete works, does it?
@roelof are you using backtick or single quote there? It looks like ` instead of â in what you pasted
yes, at some point this is happening :
{:type clojure.lang.PersistentArrayMap}
{:type clojure.lang.PersistentArrayMap}
{:type clojure.lang.PersistentArrayMap}
{:type clojure.lang.PersistentArrayMap}
{{:type :typenil }nil
}
{:type nil}
{:type nil}
{:type nil}
{:type nil}
{:type nil}
{:type nil}
and on a test that is working fine I see this :
nil
nil
nil
nil
nil
nil
nil
{:sym paintings2.api-get/get-art-object}
{:sym paintings2.api-get/get-data-detail-page}
{:sym paintings2.api-get/get-data-front-page}
{:sym paintings2.api-get/get-image-url}
{:sym paintings2.api-get/get-data-detail-page}
{:total 1, :check-passed 1}