summaryrefslogtreecommitdiff
path: root/chroma/histogram/graph.py
diff options
context:
space:
mode:
Diffstat (limited to 'chroma/histogram/graph.py')
-rw-r--r--chroma/histogram/graph.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/chroma/histogram/graph.py b/chroma/histogram/graph.py
new file mode 100644
index 0000000..5e27dee
--- /dev/null
+++ b/chroma/histogram/graph.py
@@ -0,0 +1,29 @@
+import numpy as np
+
+class Graph(object):
+ """
+ Graph object.
+
+ Args:
+ - x: array, *optional*
+ - y: array, *optional*
+ - xerr: array, *optional*
+ - yerr: array, *optional*
+ """
+ def __init__(self, x=[], y=[], xerr=None, yerr=None):
+ self.x = np.asarray(x)
+ self.y = np.asarray(y)
+ if xerr is None:
+ self.xerr = np.zeros(self.x.size)
+ else:
+ self.xerr = np.array(xerr)
+ if yerr is None:
+ self.yerr = np.zeros(self.x.size)
+ else:
+ self.yerr = np.array(yerr)
+
+ if self.y.size != self.x.size or self.xerr.size != self.x.size \
+ or self.yerr.size != self.x.size:
+ raise ValueError('array size mismatch')
+
+ self.size = self.x.size