On Mon, Nov 11, 2013 at 9:13 PM, Amit Saha <[email protected]> wrote:
> Hello,
>
> Consider the following:
>
> Python 3:
>
>>>> from sympy import Line, Point
>>>> line = Line(Point(1,0), slope = 1)
>>>> Point.is_collinear(line)
> True
>
> Python 2:
>
>>>> from sympy import Line
>>>> line = Line(Point(1,0), slope = 1)
>>>> Point.is_collinear(line)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: unbound method is_collinear() must be called with Point
> instance as first argument (got Line instance instead)
>
> In the second case (because of Python 2's concept of unbound methods),
> the user at least knows that something wrong has happened. In the
> first case, however, since Python 3 allows class methods to be called
> with any object instance, it is simply not a problem.
>
> I propose the following fix:
>
> diff --git a/sympy/geometry/point.py b/sympy/geometry/point.py
> index 4e941a1..7f359f5 100644
> --- a/sympy/geometry/point.py
> +++ b/sympy/geometry/point.py
> @@ -151,6 +151,7 @@ def length(self):
>          """
>          return S.Zero
>
> +    @classmethod
>      def is_collinear(*points):
>          """Is a sequence of points collinear?
>
> @@ -209,6 +210,10 @@ def is_collinear(*points):
>          # Coincident points are irrelevant and can confuse this algorithm.
>          # Use only unique points.
>          points = list(set(points))
> +
> +        if not any([isinstance(p, Point) for p in points]):

That should be all() instead.

-Amit.

-- 
http://echorand.me

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to