Skip to content
Snippets Groups Projects
Commit c9509db3 authored by Savici, Andrei T.'s avatar Savici, Andrei T.
Browse files

Re #21385. Fix compatibility with older numpy/matplotlib

parent b3391f30
No related branches found
No related tags found
No related merge requests found
...@@ -183,7 +183,7 @@ def _getMatrix2DData(workspace, distribution,histogram2D=False): ...@@ -183,7 +183,7 @@ def _getMatrix2DData(workspace, distribution,histogram2D=False):
else: else:
if histogram2D: if histogram2D:
if _commonX(x): if _commonX(x):
x=numpy.broadcast_to(numpy.expand_dims(boundaries_from_points(x[0]),0),(z.shape[0]+1,z.shape[1]+1)) x=numpy.tile(boundaries_from_points(x[0]),z.shape[0]+1).reshape(z.shape[0]+1,-1)
else: else:
x = numpy.vstack((x,x[-1])) x = numpy.vstack((x,x[-1]))
x = numpy.array([boundaries_from_points(xi) for xi in x]) x = numpy.array([boundaries_from_points(xi) for xi in x])
...@@ -192,7 +192,7 @@ def _getMatrix2DData(workspace, distribution,histogram2D=False): ...@@ -192,7 +192,7 @@ def _getMatrix2DData(workspace, distribution,histogram2D=False):
else: else:
if len(y)==z.shape[0]+1: if len(y)==z.shape[0]+1:
y=points_from_boundaries(y) y=points_from_boundaries(y)
y = numpy.broadcast_to(numpy.expand_dims(y,1),x.shape) y = numpy.tile(y,x.shape[1]).reshape(x.shape[1],x.shape[0]).transpose()
return (x,y,z) return (x,y,z)
......
...@@ -33,7 +33,7 @@ class Plots__init__Test(unittest.TestCase): ...@@ -33,7 +33,7 @@ class Plots__init__Test(unittest.TestCase):
def test_fail(self): def test_fail(self):
fig, ax = plt.subplots() fig, ax = plt.subplots()
self.assertRaises(AttributeError,ax.plot,self.ws2d_histo,'rs',specNum=1) self.assertRaises(Exception,ax.plot,self.ws2d_histo,'rs',specNum=1)
self.assertRaises(ValueError,ax.pcolormesh,self.ws2d_histo) self.assertRaises(ValueError,ax.pcolormesh,self.ws2d_histo)
if __name__ == '__main__': if __name__ == '__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