Skip to content
Snippets Groups Projects
Commit ee7e4e2d authored by Sergio Orlandini's avatar Sergio Orlandini
Browse files

improve docs

parent 1f7bc8d2
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,8 @@ class Point :
Class to manage multi-dimensional grid points.
Manage value, index, coordinates of grid points.
Point class is used for statistics of dataset.
Parameters
----------
value : float
......@@ -54,6 +56,40 @@ class Point :
label : str
Label of Point object
Examples
--------
A point of value 1.0 at 42-th index:
>>> p = Point(1.0, 42)
>>> p.get_value()
1.0
>>> p.get_index()
42
A point with value 42.0 in a 2D-grid with position (32, 45), index is not specified:
>>> p = Point(42, position=(32, 45))
>>> p.get_value()
42
>>> p.get_position()
(32, 45)
>>> p.get_index()
A useful usage of Point class is in statistic of dataset to manage properties of statistical quantities:
>>> import numpy as np
>>> x = np.array([[1, 2, 3], [4, 5, 6]], np.int32)
>>> p = Point(np.min(x), np.argmin(x), np.unravel_index(np.argmin(x), x.shape), 'minimum point')
>>> p.get_value()
1
>>> p.get_index()
0
>>> p.get_position()
(0, 0)
>>> p.get_label()
'minimum point'
"""
def __init__ (self, value, index=None, position=None, label=None):
......@@ -91,7 +127,7 @@ class Point :
Examples
--------
>>> x = Point(1.0)
>>> print x()
>>> x()
1.0
"""
return self.value
......@@ -108,7 +144,7 @@ class Point :
>>> x = Point(1.0, 981)
>>> y = Point(2.0, 12)
>>> z = x + y
>>> print z.get_value()
>>> z.get_value()
3.0
"""
#return Point(self.value + other.value, self.index, self.position)
......@@ -236,11 +272,9 @@ class Point :
def main():
import doctest
print "Testing mode for Class Name =", Point.__name__
doctest.testmod()
if __name__ == "__main__":
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment