15.12.2011 13:07, Joachim Durchholz пишет:
> int_tested was supposed to do
>>>> if x!=int(x) raise error, else x = int(x)
> which happens in a couple of handful cases in the SymPy code.
> (In fact the whole int_tested idea sprouted from issue #1740, where this
> idiom was not applied but should have been.)
> 
> Chris proposed using a decorator, Aaron proposed to extend it to float,
> my proposal here is to use a decorator that can handle arbitrary types
> and even arbitrary "normalization functions".
> I also reworked the interface so that the decorator can use an arbitrary
> mixture of normalizers; e.g.
> 

As I found, the original discussion is here.

https://github.com/sympy/sympy/pull/713

Is not it?


Note that there is a REP 3107 for the type checking (It is stalled though):

http://markmail.org/message/onxlt4t5mjqkls6k?q=thread:pruvsejfjvarfodk

In particular there exist an old third side module (2006 last updated,
overgrown with the other functionality a little, though):

http://oakwinter.com/code/typecheck/tutorial/basics.html

At least the name-token 'accept' is more understandable for me if we
only check the types and raise an error (and do not transform/align the
types of th arguments)

-- 
Alexey U.


>>>> @normalize_args(int, float, abs)
>>>> def something_with_a_square_root(a, b, needs_to_be_a_square)
> 
> Attached is a heavily documented and commented implementation of that idea.
> There are a handful things I'd like to change before this goes
> productive, but I think it is now in a shape that people can experiment
> with it and comment on it.
> The things I'm already aware of are:
> 1) I'd like to use @wraps or update_wrapper to make it play nicer with
> the metadata system of Python.
> 2) Somehow, both camelCase and underlined_words slipped in.
> 3) There's a TODO left about reporting a stumbling block to the Python
> community that they might want to fix in their documentation.
> 
> Regards,
> Jo
> 
> P.S:: In hindsight, issue #1740 wasn't EasyToFix; decorators rock, but
> diving right into them fully general was a real challenge.
> 


-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to