2021-12-28

AttributeError: can't set attribute when trying to increment X value of a circle in sympy[2] I want 3Pattern

I want 3Pattern ①②➂

https://docs.sympy.org/latest/modules/geometry/points.html#sympy.geometry.point.Point2D.x

AttributeError: can't set attribute when trying to increment X value of a circle in sympy

from sympy import Point, Circle
def myPointSubs(PT,x,y):
    return PT.translate(x=-PT.x+x,y=-PT.y+y)
test_center=Point (1,2)
test_circle=Circle(myPointSubs(test_center,2,test_center.y), 1)
# test_circle=Circle(myPointSubs(test_center,2,), 1) #① I want Circle(Point2D(2,2), 1)
# test_circle=Circle(myPointSubs(test_center,,1), 1) #② I want Circle(Point2D(1,1), 1)
# test_circle=Circle(myPointSubs(test_center,, ), 1) #➂ I want Circle(Point2D(1,2), 1)
print("#",test_circle)
# Circle(Point2D(2, 2), 1)

test_circle=Circle(myPointSubs(test_center,2,), 1)

TypeError: myPointSubs() missing 1 required positional argument: 'y'

(2021-12-28)

from sympy import Point
def change(pt,x=None,y=None):
    return pt.func(pt.x if x is None else x, pt.y if y is None else y)
print("#",change(Point(1, 2), y=3))
print("#",change(Point(1, 2), x=3))
print("#",change(Point(1, 2), 3))
print("#",change(Point(1, 2), 2, 1))
print("")
print("#1",change(Point(1, 2)   ))
# print("#2",change(Point(1, 2),, ))         #SyntaxError: invalid syntax
# print("#3",change(Point(1, 2),,4))         #SyntaxError: invalid syntax
print("#4",change(Point(1, 2), x=3,y=4))
print("#5",change(Point(1, 2), y=4,x=3))
print("#6",change(Point(1, 2),3,))

# Point2D(1, 3)
# Point2D(3, 2)
# Point2D(3, 2)
# Point2D(2, 1)

#1 Point2D(1, 2)
#     print("#2",change(Point(1, 2),, ))         #SyntaxError: invalid syntax
#                                   ^
# SyntaxError: invalid syntax
#     print("#3",change(Point(1, 2),,4))         #SyntaxError: invalid syntax
#                                   ^
# SyntaxError: invalid syntax
#4 Point2D(3, 4)
#5 Point2D(3, 4)
#6 Point2D(3, 2)

google > python none default argument

from sympy import *
def change(pt,x=None,y=None):
    return pt.func(pt.x if x is None else x, pt.y if y is None else y)
test_center =Point (1,2)
test_circle =Circle(change(test_center,2,test_center.y), 1)
test_circle1=Circle(change(test_center,x=2),1) #① I want Circle(Point2D(2,2), 1)
test_circle2=Circle(change(test_center,y=1),1) #② I want Circle(Point2D(1,1), 1)
test_circle3=Circle(change(test_center    ),1) #➂ I want Circle(Point2D(1,2), 1)
print("# ",test_circle )
print("#1",test_circle1)
print("#2",test_circle2)
print("#3",test_circle3)

#  Circle(Point2D(2, 2), 1)
#1 Circle(Point2D(2, 2), 1)
#2 Circle(Point2D(1, 1), 1)
#3 Circle(Point2D(1, 2), 1)


from Recent Questions - Stack Overflow https://ift.tt/3HeFeFU
https://ift.tt/eA8V8J

No comments:

Post a Comment