-
Notifications
You must be signed in to change notification settings - Fork 0
/
point.py
129 lines (105 loc) · 3.82 KB
/
point.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/env python
"""point.py class required for the point.
:author: Jose Carlos Recuero
:version: 0.1
:since: 10/21/2014
"""
__docformat__ = 'restructuredtext en'
###############################################################################
## _ _
## (_)_ __ ___ _ __ ___ _ __| |_ ___
## | | '_ ` _ \| '_ \ / _ \| '__| __/ __|
## | | | | | | | |_) | (_) | | | |_\__ \
## |_|_| |_| |_| .__/ \___/|_| \__|___/
## |_|
###############################################################################
#
# import std python modules
#
#
# import point python modules
#
###############################################################################
##
## ___ ___ _ __ ___| |_ __ _ _ __ | |_ ___
## / __/ _ \| '_ \/ __| __/ _` | '_ \| __/ __|
## | (_| (_) | | | \__ \ || (_| | | | | |_\__ \
## \___\___/|_| |_|___/\__\__,_|_| |_|\__|___/
##
###############################################################################
#
###############################################################################
## _ _ _
## ___ _ _| |__ _ __ ___ _ _| |_(_)_ __ ___ ___
## / __| | | | '_ \| '__/ _ \| | | | __| | '_ \ / _ \/ __|
## \__ \ |_| | |_) | | | (_) | |_| | |_| | | | | __/\__ \
## |___/\__,_|_.__/|_| \___/ \__,_|\__|_|_| |_|\___||___/
##
###############################################################################
#
###############################################################################
## _ _ __ _ _ _ _
## ___| | __ _ ___ ___ __| | ___ / _(_)_ __ (_) |_(_) ___ _ __ ___
## / __| |/ _` / __/ __| / _` |/ _ \ |_| | '_ \| | __| |/ _ \| '_ \/ __|
## | (__| | (_| \__ \__ \ | (_| | __/ _| | | | | | |_| | (_) | | | \__ \
## \___|_|\__,_|___/___/ \__,_|\___|_| |_|_| |_|_|\__|_|\___/|_| |_|___/
##
###############################################################################
#
#
#------------------------------------------------------------------------------
class Point(object):
"""
"""
#--------------------------------------------------------------------------
def __init__(self, theX=0, theY=0):
""" Initialize Point instance
:type theX: int
:param theX: point x value
:type theY: int
:param theY: point y value
"""
self.x = theX
self.y = theY
#--------------------------------------------------------------------------
def set(self, theX=None, theY=None, theDict=None):
""" Set values for the point.
:type theX: int
:param theX: point x value
:type theY: int
:param theY: point y value
:type theDict: dict
:param theDict: dictionary with point values
"""
if theDict:
self.x = theDict['x']
self.y = theDict['y']
else:
self.x = theX if theX is not None else self.x
self.y = theY if theY is not None else self.y
#--------------------------------------------------------------------------
def getAsDict(self):
""" Get point value as dictionary.
:rtype: dict
:return: dictionary with point values
"""
return {'x': self.x, 'y': self.y}
#--------------------------------------------------------------------------
def getAsTuple(self):
""" Get point value as a tuple.
:rtype: tuple
:return: tuple with point values
"""
return (self.x, self.y)
###############################################################################
## _
## _ __ ___ __ _(_)_ __
## | '_ ` _ \ / _` | | '_ \
## | | | | | | (_| | | | | |
## |_| |_| |_|\__,_|_|_| |_|
##
###############################################################################
#
if __name__ == '__main__':
import doctest
doctest.testmod()