On Sun, Oct 23, 2011 at 11:33 PM, Aaron Meurer <asmeu...@gmail.com> wrote: > On Sat, Oct 22, 2011 at 3:57 AM, Joachim Durchholz <j...@durchholz.org> wrote: >> Hi, >> >> I have started working on the issue in the subject line. >> ( See http://code.google.com/p/sympy/issues/detail?id=1740 ) >> >> Things I noticed, questions: >> >> I'm seeing parameters that select primes by index, and parameters that >> select primes by magnitude. I'm assuming they should all be protected, not >> just those two that are mentioned in the issue report. >> Correct? > > Yes, anything that is a public function should do some kind of type > check to prevent against this problem. > >> >> Those that select by index should be limited to integers. >> Those that select by defining a minimum and/or maximum range should be >> limited to floats. >> Correct? > > I think since the range is over the integers, you can also just cast > these to int(), and if that fails then it is incorrect. > >> >> The issue report suggests testing for non-"intness" via >> int(N) != N >> What's the best way to test for "floatness" in Python? > > This is not what the issue suggests. It says that you should just > cast it to int, and if it works, then it is correct, and if not, then > it will raise a TypeError, which is what it should do in that case.
More specifically, just add n = int(n) to the top of the function. Aaron Meurer > >> >> I'm also considering allowing symbols and formulae, provided that they can >> be evaluated. >> Is that useful, or are users simply supposed to force Sympy into evaluating >> by using their own call? > > If I understand what you're saying correctly, you could allow this by changing > > def prime(...): > (stuff) > > to > > class prime(Function): > @classmethod > def eval(cls, ...): > (stuff) > > Aaron Meurer > >> >> Regards, >> Jo >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sympy" group. >> To post to this group, send email to sympy@googlegroups.com. >> To unsubscribe from this group, send email to >> sympy+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/sympy?hl=en. >> >> > -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.