benchmarks: pin dependencies of rw-heatmaps
Signed-off-by: Cenk Alti <cenkalti@gmail.com>dependabot/go_modules/github.com/prometheus/procfs-0.11.0
parent
8c715f8a40
commit
2efecd1978
|
@ -79,106 +79,6 @@ def load_data_files(*args):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
# This is copied directly from matplotlib source code. Some early versions of matplotlib
|
|
||||||
# do not have CenteredNorm class
|
|
||||||
class CenteredNorm(colors.Normalize):
|
|
||||||
|
|
||||||
def __init__(self, vcenter=0, halfrange=None, clip=False):
|
|
||||||
"""
|
|
||||||
Normalize symmetrical data around a center (0 by default).
|
|
||||||
|
|
||||||
Unlike `TwoSlopeNorm`, `CenteredNorm` applies an equal rate of change
|
|
||||||
around the center.
|
|
||||||
|
|
||||||
Useful when mapping symmetrical data around a conceptual center
|
|
||||||
e.g., data that range from -2 to 4, with 0 as the midpoint, and
|
|
||||||
with equal rates of change around that midpoint.
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
vcenter : float, default: 0
|
|
||||||
The data value that defines ``0.5`` in the normalization.
|
|
||||||
halfrange : float, optional
|
|
||||||
The range of data values that defines a range of ``0.5`` in the
|
|
||||||
normalization, so that *vcenter* - *halfrange* is ``0.0`` and
|
|
||||||
*vcenter* + *halfrange* is ``1.0`` in the normalization.
|
|
||||||
Defaults to the largest absolute difference to *vcenter* for
|
|
||||||
the values in the dataset.
|
|
||||||
|
|
||||||
Examples
|
|
||||||
--------
|
|
||||||
This maps data values -2 to 0.25, 0 to 0.5, and 4 to 1.0
|
|
||||||
(assuming equal rates of change above and below 0.0):
|
|
||||||
|
|
||||||
>>> import matplotlib.colors as mcolors
|
|
||||||
>>> norm = mcolors.CenteredNorm(halfrange=4.0)
|
|
||||||
>>> data = [-2., 0., 4.]
|
|
||||||
>>> norm(data)
|
|
||||||
array([0.25, 0.5 , 1. ])
|
|
||||||
"""
|
|
||||||
self._vcenter = vcenter
|
|
||||||
self.vmin = None
|
|
||||||
self.vmax = None
|
|
||||||
# calling the halfrange setter to set vmin and vmax
|
|
||||||
self.halfrange = halfrange
|
|
||||||
self.clip = clip
|
|
||||||
|
|
||||||
def _set_vmin_vmax(self):
|
|
||||||
"""
|
|
||||||
Set *vmin* and *vmax* based on *vcenter* and *halfrange*.
|
|
||||||
"""
|
|
||||||
self.vmax = self._vcenter + self._halfrange
|
|
||||||
self.vmin = self._vcenter - self._halfrange
|
|
||||||
|
|
||||||
def autoscale(self, A):
|
|
||||||
"""
|
|
||||||
Set *halfrange* to ``max(abs(A-vcenter))``, then set *vmin* and *vmax*.
|
|
||||||
"""
|
|
||||||
A = np.asanyarray(A)
|
|
||||||
self._halfrange = max(self._vcenter-A.min(),
|
|
||||||
A.max()-self._vcenter)
|
|
||||||
self._set_vmin_vmax()
|
|
||||||
|
|
||||||
def autoscale_None(self, A):
|
|
||||||
"""Set *vmin* and *vmax*."""
|
|
||||||
A = np.asanyarray(A)
|
|
||||||
if self._halfrange is None and A.size:
|
|
||||||
self.autoscale(A)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def vcenter(self):
|
|
||||||
return self._vcenter
|
|
||||||
|
|
||||||
@vcenter.setter
|
|
||||||
def vcenter(self, vcenter):
|
|
||||||
self._vcenter = vcenter
|
|
||||||
if self.vmax is not None:
|
|
||||||
# recompute halfrange assuming vmin and vmax represent
|
|
||||||
# min and max of data
|
|
||||||
self._halfrange = max(self._vcenter-self.vmin,
|
|
||||||
self.vmax-self._vcenter)
|
|
||||||
self._set_vmin_vmax()
|
|
||||||
|
|
||||||
@property
|
|
||||||
def halfrange(self):
|
|
||||||
return self._halfrange
|
|
||||||
|
|
||||||
@halfrange.setter
|
|
||||||
def halfrange(self, halfrange):
|
|
||||||
if halfrange is None:
|
|
||||||
self._halfrange = None
|
|
||||||
self.vmin = None
|
|
||||||
self.vmax = None
|
|
||||||
else:
|
|
||||||
self._halfrange = abs(halfrange)
|
|
||||||
|
|
||||||
def __call__(self, value, clip=None):
|
|
||||||
if self._halfrange is not None:
|
|
||||||
# enforce symmetry, reset vmin and vmax
|
|
||||||
self._set_vmin_vmax()
|
|
||||||
return super().__call__(value, clip=clip)
|
|
||||||
|
|
||||||
|
|
||||||
# plot type is the type of the data to plot. Either 'read' or 'write'
|
# plot type is the type of the data to plot. Either 'read' or 'write'
|
||||||
def plot_data(title, plot_type, cmap_name_default, *args):
|
def plot_data(title, plot_type, cmap_name_default, *args):
|
||||||
if len(args) == 1:
|
if len(args) == 1:
|
||||||
|
@ -220,7 +120,7 @@ def plot_data(title, plot_type, cmap_name_default, *args):
|
||||||
if col == 2:
|
if col == 2:
|
||||||
cmap_name = 'bwr'
|
cmap_name = 'bwr'
|
||||||
if params.zero:
|
if params.zero:
|
||||||
norm = CenteredNorm()
|
norm = colors.CenteredNorm()
|
||||||
else:
|
else:
|
||||||
cmap_name = cmap_name_default
|
cmap_name = cmap_name_default
|
||||||
plt.tripcolor(df['conn_size'], df['value_size'], df[plot_type],
|
plt.tripcolor(df['conn_size'], df['value_size'], df[plot_type],
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
matplotlib==3.7.1
|
||||||
|
numpy==1.24.3
|
||||||
|
pandas==2.0.1
|
Loading…
Reference in New Issue