Re: Stubbing with instrument and generators

2017-06-30 Thread Michael Glaesemann
we replace its spec. > > (stest/instrument `do-y > {:stub #{`do-y} >:spec {`do-y (s/fspec > :args (s/cat :y-er (s/with-gen ::y >(fn [] y-gen)))

Re: Stubbing with instrument and generators

2017-06-30 Thread Alex Miller
.alpha{:path [:y-er], :form :spec-ex.core/y, :failure > :no-gen} > > ;; However, we *can* stub `do-y` if we replace its spec. > > (stest/instrument `do-y > {:stub #{`do-y} >:spec {`do-y (s/fspec > :args (s/cat :y-er (s/

Stubbing with instrument and generators

2017-06-30 Thread Michael Glaesemann
::y (fn [] y-gen}}) ;; => [spec-ex.core/do-y] There is a ticket open[ (CLJ-2095[1]) regarding using overrides s/gen with custom generators. Is this a case where this applies? I can imagine that it could be. Not overriding something tha

Re: Custom generators for custom predicate functions

2016-12-08 Thread Dave Dixon
appears there is no way to do the same for a custom predicate >> function. I see that the generators for predicate functions testing for >> core primitives are hard-coded in the private >> clojure.spec.gen\gen-builtins. Curious why this isn't extensible, since it >&

Re: Custom generators for custom predicate functions

2016-12-08 Thread Alex Miller
rsday, December 8, 2016 at 10:56:29 AM UTC-6, Dave Dixon wrote: > > Though one can obviously attach a custom generator to a keyword-named > spec, it appears there is no way to do the same for a custom predicate > function. I see that the generators for predicate functions testing for

Custom generators for custom predicate functions

2016-12-08 Thread Dave Dixon
Though one can obviously attach a custom generator to a keyword-named spec, it appears there is no way to do the same for a custom predicate function. I see that the generators for predicate functions testing for core primitives are hard-coded in the private clojure.spec.gen\gen-builtins

Re: Spec & test.check generators for complex data structures

2016-11-01 Thread Alex Miller
screencast-customizing-generators using gen/fmap and gen/bind which is probably the best way to build something like this. As an example, if you need to test on a graph of nodes, your model might consist of first creating random nodes, then generating random edges between the nodes (rather tha

Re: Spec & test.check generators for complex data structures

2016-11-01 Thread Maarten Truyens
Thanks - the start of that thread was indeed interesting, but it quickly changed course towards a discussion on whether Spec should check function outputs. Rich hinted at exactly the kind of in-depth discussion I wanted to find — but much too briefly... -- You received this message because yo

Re: Spec & test.check generators for complex data structures

2016-11-01 Thread Josh Tilles
s of type F. > > It is trivial to have Spec generate completely random nodes to test > functions that can ignore the business rules. However, other functions do > depend on the business rules, and for those it is necessary to somewhat > "guide" the generators towards random

Spec & test.check generators for complex data structures

2016-11-01 Thread Maarten Truyens
al to have Spec generate completely random nodes to test functions that can ignore the business rules. However, other functions do depend on the business rules, and for those it is necessary to somewhat "guide" the generators towards random-but-compliant output. And here I'm s

Re: clojure.spec.test/instrument causes clojure.spec/exercise-fn to use generators which fail the args spec!?

2016-10-20 Thread J.-F. Rompre
Ah, I missed thatthank you very much! -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubs

Re: clojure.spec.test/instrument causes clojure.spec/exercise-fn to use generators which fail the args spec!?

2016-10-19 Thread Beau Fabry
at 3:17:19 PM UTC+11, J.-F. Rompre wrote: > > I am trying to learn clojure.spec and tried my hand at a spec for a > fizzbuzz function. > For some strange reason, generators created for it fail the same spec > during clojure.spec/exercise-fn ! > > Stranger, this happens onl

clojure.spec.test/instrument causes clojure.spec/exercise-fn to use generators which fail the args spec!?

2016-10-19 Thread J.-F. Rompre
I am trying to learn clojure.spec and tried my hand at a spec for a fizzbuzz function. For some strange reason, generators created for it fail the same spec during clojure.spec/exercise-fn ! Stranger, this happens only if the same function is first instrumented using clojure.spec.stest

Q: Is there a reason why some clojure.test.check generators are excluded from clojure.spec.gen lazy primitives?

2016-06-04 Thread Joseph Wayne Norton
Is there a reason why some clojure.test.check generators are excluded from clojure.spec.gen lazy primitives? https://github.com/clojure/clojure/blob/1f25347a7b219488d5d9f8d17b04f2cc7828b30e/src/clj/clojure/spec/gen.clj#L114 The nat generator as one example is missing. Best regards, Joe N

clojure.spec guide updated with generators

2016-05-27 Thread Alex Miller
I've added a new section to the clojure.spec guide for generators. Certainly doesn't cover everything yet but hope it helps! http://clojure.org/guides/spec#_generators -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post

[ANN] schema-generators 0.1.0 (now with ClojureScript!)

2016-03-24 Thread Jason Wolfe
We've released schema-generators 0.1.0, which includes ClojureScript support via cljc: https://github.com/plumatic/schema-generators This library allows you to generate test data from most plumatic/schemas out of the box, as well as automatically "complete" partial datums -- whi

Re: [ANN] boot-new 0.4.0 -- Templates AND Generators for Boot!

2016-02-29 Thread Bryan Maass
> > But the plan is to merge it into the core Boot project at some point (once > we get a bit more feedback on boot-new itself and its templates and > generators) to knock off any rough edges. > > Sean Corfield -- (904) 302-SEAN > An Architect's View -- http://

Re: [ANN] boot-new 0.4.0 -- Templates AND Generators for Boot!

2016-02-28 Thread Sean Corfield
boot-new itself and its templates and generators) to knock off any rough edges. Sean Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ "If you're not annoying somebody, you're not really alive." -- Margaret Atwood -- You received this message because

Re: [ANN] boot-new 0.4.0 -- Templates AND Generators for Boot!

2016-02-27 Thread Frank Liu
nk On Saturday, February 13, 2016 at 2:21:18 PM UTC-8, Sean Corfield wrote: > > What / Where? > Boot new — a task to produce new projects from Boot and/or Leiningen > templates! > boot-new 0.4.0 — https://github.com/seancorfield/boot-new > > Updates? > Now supports generators to a

[ANN] boot-new 0.4.0 -- Templates AND Generators for Boot!

2016-02-13 Thread Sean Corfield
What / Where? Boot new — a task to produce new projects from Boot and/or Leiningen templates! boot-new 0.4.0 — https://github.com/seancorfield/boot-new Updates? Now supports generators to add / modify code in the current project! Add a new namespace with: boot new –g ns=foo.bar.quux Add a new

Re: Controlling growth rates of generators with test.check

2015-07-29 Thread Mayank Jain
Thanks. That looks useful. On Jul 30, 2015 6:14 AM, "Mikera" wrote: > See: > > https://github.com/clojure/test.check/commit/d4883873df73717629272d0ab71619d7e58c9c9e > > On Wednesday, 29 July 2015 23:31:14 UTC+8, Mayank Jain wrote: >> >> Nice. Any updates on this? >> Is this a good idea? >> >> On

Re: Controlling growth rates of generators with test.check

2015-07-29 Thread Mikera
See: https://github.com/clojure/test.check/commit/d4883873df73717629272d0ab71619d7e58c9c9e On Wednesday, 29 July 2015 23:31:14 UTC+8, Mayank Jain wrote: > > Nice. Any updates on this? > Is this a good idea? > > On Friday, May 15, 2015 at 12:13:06 PM UTC+5:30, Mikera wrote: >> >> Hi all, >> >> I am

Re: Controlling growth rates of generators with test.check

2015-07-29 Thread Mayank Jain
Nice. Any updates on this? Is this a good idea? On Friday, May 15, 2015 at 12:13:06 PM UTC+5:30, Mikera wrote: > > Hi all, > > I am doing some generative testing with test.check and need a way to > control the growth rate of data structures (the regular linear growth > quickly makes the computat

Controlling growth rates of generators with test.check

2015-05-14 Thread Mikera
Hi all, I am doing some generative testing with test.check and need a way to control the growth rate of data structures (the regular linear growth quickly makes the computations too large for meaningful testing usage). I came up with the following solution to do this: (defn gen-resize "Crea

Re: Howto write test.check custom generators

2014-08-19 Thread Reid Draper
:first-name gen/string-alpha-numeric > :last-name gen/string-alpha-numeric > :email gen/string-alpha-numeric))) > > (def has-agroup > (prop/for-all [v (gen/sample gend-user)] > (->

Re: Howto write test.check custom generators

2014-08-10 Thread Timothy Washington
(-> v nil? not))) Tim Washington Interruptsoftware.com <http://interruptsoftware.com> On Sun, Aug 10, 2014 at 3:02 PM, Sam Ritchie wrote: > You can to use gen/fmap to build up generators. Here's an example: > > -- You received this message because you are subscribed

Re: Howto write test.check custom generators

2014-08-10 Thread Sam Ritchie
You can to use gen/fmap to build up generators. Here's an example: ;; generates a millisecond using gen/choose, then maps that to a time instance using my u/ms-to-time function. (def result-gen (->> (gen/choose 0 u/max-time) (gen/fmap u/ms-to-time))) ;; Generates EITHER

Howto write test.check custom generators

2014-08-10 Thread Timothy Washington
Hi there, I'm trying to get my head wrapped around test.check <https://github.com/clojure/test.check/>. My current stumbling block is custom generators. Of course I've combed through the docs <https://github.com/clojure/test.check/blob/master/doc/intro.md#record-generators

Re: Advice on managing random number generators across threads

2014-06-07 Thread Mars0i
On Saturday, June 7, 2014 7:09:53 PM UTC-5, Alexander Hudek wrote: > > Keep in mind that there could be accuracy reasons why you might want to > use multiple random number generators (aka multiple streams). See the > section "Single Versus Multiple Streams" here: >

Re: Advice on managing random number generators across threads

2014-06-07 Thread Alexander Hudek
Keep in mind that there could be accuracy reasons why you might want to use multiple random number generators (aka multiple streams). See the section "Single Versus Multiple Streams" here: http://www.cse.msu.edu/~cse808/CSIM_Notes03/cse808/html_c/16random.htm Also, the built in j

Re: Advice on managing random number generators across threads

2014-06-06 Thread Mars0i
On Friday, June 6, 2014 10:33:04 PM UTC-5, Mars0i wrote: > > On Friday, June 6, 2014 2:26:25 PM UTC-5, Linus Ericsson wrote: >> >> Here I assume that the incoming calls to agents aren't guaranteed to >> strictly ordered among different agents, even though the agents reside in >> one of two thre

Re: Advice on managing random number generators across threads

2014-06-06 Thread Mars0i
Wow. Linus, thanks for the very detailed answer. It sounds as your view is that there's no problem with the logic of my proposed solution, but it seems wasteful to create 100 RNGs, when I don't actually need to have so many of them. Your solutions provide ways to get the same result without m

Re: Advice on managing random number generators across threads

2014-06-06 Thread Mars0i
Thanks Lee. It looks like this could be useful. On Friday, June 6, 2014 4:19:11 PM UTC-5, Lee wrote: > > > I don't know if this will be helpful in your application, or even if it's > the best approach for our own work (or if java 1.7 provides a simpler > approach?), but FWIW one of my projects

Re: [ANN] clj-generators - generator magic inspired by Python

2014-06-06 Thread Gary Johnson
Gotcha. By all means then, hack away. ;-) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubs

Re: [ANN] clj-generators - generator magic inspired by Python

2014-06-06 Thread Alex Engelberg
Gary, I fully acknowledge that there are many ways to create lazy sequences that are much more elegant and efficient. However, as I mentioned, I'm very fascinated by generators in Python, and I mostly wanted to toy around with how to implement it in Clojure. Also, as I mentioned, for begi

Re: Advice on managing random number generators across threads

2014-06-06 Thread Lee Spector
I don't know if this will be helpful in your application, or even if it's the best approach for our own work (or if java 1.7 provides a simpler approach?), but FWIW one of my projects deals with the thread-local RNG issue via: https://clojars.org/clj-random -Lee On Jun 6, 2014, at 12:28 PM,

Re: Advice on managing random number generators across threads

2014-06-06 Thread Linus Ericsson
(I think your stepwise problem is better to be solved without agents, see below.) I realized that the *rng* actually is conflated, it keeps both the state for the random number generator AND the algorithm used for the random number generation. This is usually not a problem, since the state-size an

Re: Advice on managing random number generators across threads

2014-06-06 Thread Mars0i
On Friday, June 6, 2014 2:05:16 PM UTC-5, Gunnar Völkel wrote: > > In Java 7 you would use ThreadLocalRandom you said in another thread. > Well, in Java 6 you already have ThreadLocal [1] and thus you are able to > build a thread local Random yourself to keep Java 6 as minimum requirement. > > [1

Re: Advice on managing random number generators across threads

2014-06-06 Thread Gunnar Völkel
In Java 7 you would use ThreadLocalRandom you said in another thread. Well, in Java 6 you already have ThreadLocal [1] and thus you are able to build a thread local Random yourself to keep Java 6 as minimum requirement. [1] http://docs.oracle.com/javase/6/docs/api/index.html?java/lang/ThreadLoc

Re: Advice on managing random number generators across threads

2014-06-06 Thread Mars0i
One more point: I would save the system-time-determined seed of the initial RNG to a file (i.e. the RNG used to generate seeds for each Person's RNG). I believe this will allow me to re-run a simulation with identical results, by seeding the initial RNG with the seed saved from the previous si

Advice on managing random number generators across threads

2014-06-06 Thread Mars0i
I'm writing an agent-based simulation framework, in which agents are Clojure records called Persons. There are 40-100 persons at present, but conceivably the number could go up to 1000. In each timestep, Persons' states are functionally updated by mapping update functions across the collectio

Re: [ANN] clj-generators - generator magic inspired by Python

2014-06-04 Thread Timothy Baldridge
://github.com/halgari/async-bench/blob/master/src/async_bench/core.clj#L64 WARNING: this uses unpublished APIs from core.async, use at your own risk. Timothy On Wed, Jun 4, 2014 at 9:43 AM, Gary Johnson wrote: > What new features does this syntax provide over the existing infinite > sequence gene

Re: [ANN] clj-generators - generator magic inspired by Python

2014-06-04 Thread Gary Johnson
What new features does this syntax provide over the existing infinite sequence generators? - lazy-seq - iterate - repeat - repeatedly - range I realize you provided a simple example for clarity, but perhaps you could illustrate something more complex that couldn't be done with the

[ANN] clj-generators - generator magic inspired by Python

2014-06-03 Thread Alex Engelberg
https://github.com/aengelberg/clj-generators My all-time favorite feature of Python is "generators." It allows you to write lazy sequences imperatively. def infinite_range(): x = 1 while True: yield x x += 1 for i in infinite_range(): if (i > 5):

Re: generators...?

2014-03-27 Thread Tim
I'm fairly new to Clojure and this was a fun little exercise to try. (def color-map (reduce #(assoc % (count %) %2) {} [:red :yellow :blue :green :purple])) color-map => {4 :purple, 3 :green, 2 :blue, 1 :yellow, 0 :red} (defn random-repeating-map ([coll-map] (random-repeating-map coll-map col

Re: generators...?

2014-03-26 Thread Gary Trakhman
true, he did say 'or something that would be as useful', but lazy-seqs are more useful :-). On Wed, Mar 26, 2014 at 4:08 PM, Ben Wolfson wrote: > "cycle" isn't really the same thing, though, at least if the OP really > does require (for some reason) something that can be called repeatedly and >

Re: generators...?

2014-03-26 Thread Ben Wolfson
"cycle" isn't really the same thing, though, at least if the OP really does require (for some reason) something that can be called repeatedly and get a different answer each time. On Wed, Mar 26, 2014 at 1:05 PM, Gary Trakhman wrote: > cycle - http://clojuredocs.org/clojure_core/clojure.core/cyc

Re: generators...?

2014-03-26 Thread Ben Wolfson
If you really want something that can be called repeatedly and returns something different each time (rather than just iterating through an infinite sequence, which seems like it would be the more functional-ish approach): user> (defn cycle-gen [input] (let [iter (atom (cycle input))]

Re: generators...?

2014-03-26 Thread Gary Trakhman
cycle - http://clojuredocs.org/clojure_core/clojure.core/cycle And generally, this class of functionality is called lazy-seqs. On Wed, Mar 26, 2014 at 3:59 PM, Christopher Howard wrote: > Hi. I'm still fairly new to Clojure. I was wondering: What's the > easiest way to make a generator (or some

generators...?

2014-03-26 Thread Christopher Howard
Hi. I'm still fairly new to Clojure. I was wondering: What's the easiest way to make a generator (or something that would be as useful). In one application, I need something that will return a different color each time I call it - following a predefined list of colors, and starting over again at th

avoiding generators

2013-10-14 Thread Brian Craft
I need to pull sequence ids from a db, which is a lot like using a generator. I found this thread about generators: https://groups.google.com/forum/?fromgroups=#!searchin/clojure/generator/clojure/IL_ONPb52-0/S_2p2-vjVCYJ which suggests using seqs, like so: (defn sines [] (cycle (map