Justin and Cedric: thank you for your suggestions. I removed all uses of 
`with-precision`; instead, I used various BigDecimal methods directly, such 
as .divide, .round, and .setScale by passing in a MathContext. Best I can 
tell (so far), this solved my problem.

On Monday, January 6, 2014 9:19:50 PM UTC-5, Cedric Greevey wrote:
>
> It's possibly an interaction between memoization and dynamic vars; more 
> specifically, a result might be being memoized with one with-precision 
> context active, and then recalled with a different one active, with 
> arguments that compare equal despite the different precisions (say, because 
> those arguments that are BigDecimals are exactly representable at the lower 
> of the two precisions). If the result is *not* the same at the higher 
> precision, that could cause an expected-equal check to fail in your test.
>
> I'd also wonder at possibly having a test work if it used a memoized 
> result generated earlier with a finite precision in effect, and fail with 
> ArithmeticException without the memoization if the test doesn't set a 
> precision limit itself and the result's not exactly representable at any 
> finite precision (e.g. 1/7); but this would likely result in a test that 
> worked in the suite and failed in isolation, instead of the reverse. 
> However, if high memory use is causing a memoized value computed at limited 
> precision to be "forgotten" and then recalculated with no precision limit, 
> that might trigger failures in the suite of tests that worked in isolation.
>
> In any event, subtle interaction of with-precision's underlying dynamic 
> var *math-context* with memoization is an obvious suspect worth 
> investigating, even if it might ultimately be acquitted by the jury. :)
>
>
>
> On Mon, Jan 6, 2014 at 1:21 PM, Justin Kramer <jkkr...@gmail.com<javascript:>
> > wrote:
>
>> Shot in the dark: check that arguments passed to your memoized functions 
>> use consistent typing. A BigDecimal such as 1M does not necessarily equal 1 
>> (a Long):
>>
>> > (= 1 1M)
>> false
>> > (== 1 1M)
>> true
>>
>> Your memoized functions could be recomputing values unnecessarily if 
>> you're giving them different types of numbers.
>>
>> Justin
>>
>>
>> On Monday, January 6, 2014 12:57:49 PM UTC-5, David James wrote:
>>>
>>> I've got a Clojure test suite that fails when run as whole but passes 
>>> when run piecemeal. This just started happening. I've tested the code 
>>> thoroughly. The bug pops up in a part of the code that I did not change. 
>>> So, at present, it feels like a heisenbug!
>>>
>>> These may be some relevant pieces:
>>> * I'm using memoization; the failures happen in memoized functions.
>>> * I'm doing a lot of various precision BigDecimal math.
>>>
>>> Some tentative guesses:
>>> * Somehow one test is affecting another test
>>>
>>> Questions (there are speculative):
>>> * What are some possible ways that memoization might fail (e.g. return 
>>> an incorrect value)?
>>> * Is it possible that higher memory usage could cause memoization 
>>> results to get lost?
>>>
>>> Unfortunately, it is a sizable code base, and I don't have a small, 
>>> reproducible example. Any suggestions?
>>>
>>> -David
>>>
>>  -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com<javascript:>
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to