Nathann Cohen wrote:
Helloooooooo everybody !!!

If you play with the designs.orthogonal_array(k,n) function, you will
see that it returns three kinds of things :

1) A matrix (potentially big)
2) A boolean (telling you whether the matrix CAN be built)
3) An integer (telling you how large the matrix can be)

Now, it would be COOL if this function could cache its boolean/integer
answers (for we ask the same questions very often), but caching the
matrices is a really (really) bad idea.

The return type is determined by an argument of orthogonal_array,
existence=True, and we only want to cache answers to that.

1) Is there a way to obtain this behaviour with @cached_function ?

Similar answer as to your other thread:

Wrap the function, calling a cached function (also just a wrapper) if existence=True, the bare function otherwise. Here the overhead is presumably negligible.

The drawback being that checking the existence can be as expensive as constructing the resulting matrix (modulo perhaps using less memory), and you might call both functions in sequence, but that's not different to how it is now. The problem is that orthogonal_array() is not a member function (nor does it return an object of a specific class), otherwise you could keep some data in the object to be used on subsequent calls.


-leif

--
() The ASCII Ribbon Campaign
/\   Help Cure HTML E-Mail

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to