def hist(self, fignum=1, subplot=111, **pltkeywords): import matplotlib.pyplot as plt import spacepy.toolbox as tb bins = tb.binHisto(self.y) fig = plt.figure(fignum) ax = fig.add_subplot(111) pp = ax.hist(self.y, bins[1], **pltkeywords) ax.set_xlabel('Y') ax.set_ylabel('Counts') ax.set_title('Histogram') return pp
def hist(self,fignum=1, subplot=111, **pltkeywords): import matplotlib.pyplot as plt import spacepy.toolbox as tb bins = tb.binHisto(self.y) fig=plt.figure(fignum) ax = fig.add_subplot(111) pp = ax.hist(self.y, bins[1], **pltkeywords) ax.set_xlabel('Y') ax.set_ylabel('Counts') ax.set_title('Histogram') return pp
def test_binHisto(self): """binHisto should return know answer for known input""" input = list(range(0, 101)) real_ans = (21.47300748096567, 5.0) ans = tb.binHisto(input) self.assertEqual(ans, real_ans) numpy.testing.assert_almost_equal(tb.binHisto([100]*10), (3.3333333333333335, 3.0)) numpy.testing.assert_almost_equal(tb.binHisto([100]), (1.0, 1.0)) realstdout = sys.stdout output = StringIO.StringIO() sys.stdout = output numpy.testing.assert_almost_equal(tb.binHisto([100], verbose=True), (1.0, 1.0)) result = output.getvalue() output.close() self.assertEqual(result, "Used sqrt rule\n") sys.stdout = realstdout realstdout = sys.stdout output = StringIO.StringIO() sys.stdout = output numpy.testing.assert_almost_equal(tb.binHisto([90, 100]*10, verbose=True), (7.3680629972807736, 1.0)) result = output.getvalue() output.close() self.assertEqual(result, "Used F-D rule\n") sys.stdout = realstdout
] lines.extend(tmp) # get a list of all the codes: codes = set([ re.search(r'INFO\ \-\ Command\:\ (.*)\ took.*seconds', v).groups()[0] for v in lines ]) ans = {} for code in codes: ans[code] = [] # get all the times for those codes for v in lines: match = re.search( r'INFO\ \-\ Command\:\ {0}\ took(.*)\ seconds'.format(code), v) if match: ans[code].append(float(match.groups()[0])) print('Collected {0}'.format(code)) # make all the plots for k in ans: fig = plt.figure() ax = fig.add_subplot(111) ax.hist(ans[k], tb.binHisto(ans[k])[1]) ax.set_title(k) ax.set_ylabel('Occurrences') ax.set_xlabel('Execution Time [s]') fig.savefig(k + '.png') print('Plotted {0}'.format(k + '.png'))