From eb0ae661c27bd8fdcd655931f23c64bbdbd38bd7 Mon Sep 17 00:00:00 2001 From: dpohl <pohl@physik.uni-bonn.de> Date: Mon, 23 Nov 2020 16:05:11 +0100 Subject: [PATCH] MAINT: fix deprecation warning --- bdaq53/analysis/plotting.py | 20 +++++++++++--------- bdaq53/system/bdaq53.py | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/bdaq53/analysis/plotting.py b/bdaq53/analysis/plotting.py index 96504593c..b6b283d91 100644 --- a/bdaq53/analysis/plotting.py +++ b/bdaq53/analysis/plotting.py @@ -20,15 +20,17 @@ and run the script. ''' -import numpy as np +import copy import math import shutil import os -import matplotlib import random import datetime + import iminuit import tables as tb +import matplotlib +import numpy as np import matplotlib.pyplot as plt from collections import OrderedDict @@ -1602,7 +1604,7 @@ class Plotting(object): ax.set_adjustable('box') extent = self.plot_box_bounds bounds = np.linspace(start=z_min, stop=z_max + (1 if extend_upper_bound else 0), num=255, endpoint=True) - cmap = cm.get_cmap('plasma') + cmap = copy.copy(cm.get_cmap('plasma')) cmap.set_bad('w') cmap.set_over('r') # Make noisy pixels red cmap.set_under('g') @@ -1673,7 +1675,7 @@ class Plotting(object): z_max = 2 * np.ma.median(hist2d) bounds = np.linspace(start=z_min, stop=z_max, num=255, endpoint=True) if cmap is None: - cmap = cm.get_cmap('coolwarm') + cmap = copy.copy(cm.get_cmap('coolwarm')) cmap.set_bad('w', 1.0) norm = colors.BoundaryNorm(bounds, cmap.N) im = ax.imshow(hist2d, interpolation='none', aspect="auto", cmap=cmap, norm=norm, extent=extent) @@ -1688,7 +1690,7 @@ class Plotting(object): fig.colorbar(im, boundaries=bounds, cmap=cmap, norm=norm, ticks=np.linspace(start=0, stop=z_max, num=9, endpoint=True), cax=cax) def _plot_three_way(self, hist, title, x_axis_title=None, z_min=None, z_max=None, bins=101, suffix='threeway'): # the famous 3 way plot (enhanced) - cmap = cm.get_cmap('plasma') + cmap = copy.copy(cm.get_cmap('plasma')) # TODO: set color for bad pixels # set nan to special value # masked_array = np.ma.array (a, mask=np.isnan(a)) @@ -1814,7 +1816,7 @@ class Plotting(object): bounds = np.logspace(start=np.log10(z_min), stop=np.log10(z_max), num=255, endpoint=True) else: bounds = np.linspace(start=z_min, stop=z_max, num=int((z_max - z_min) + 1), endpoint=True) - cmap = cm.get_cmap('plasma') + cmap = copy.copy(cm.get_cmap('plasma')) cmap.set_bad('w') norm = colors.BoundaryNorm(bounds, cmap.N) @@ -1964,7 +1966,7 @@ class Plotting(object): self._add_text(fig) fig.patch.set_facecolor('white') - cmap = cm.get_cmap('cool') + cmap = copy.copy(cm.get_cmap('cool')) if np.allclose(hist, 0.0) or hist.max() <= 1: z_max = 1.0 else: @@ -2192,7 +2194,7 @@ class Plotting(object): ax = fig.add_subplot(111) self._add_text(fig) - cmap = cm.get_cmap('viridis', (range_tdac)) + cmap = copy.copy(cm.get_cmap('viridis', (range_tdac))) # create dicts for tdac data data_thres_tdac = {} hist_tdac = {} @@ -2438,7 +2440,7 @@ class Plotting(object): ax.set_title(title) bounds = np.linspace(start=np.min(core), stop=np.max(core), num=255, endpoint=True) - cmap = cm.get_cmap('plasma') + cmap = copy.copy(cm.get_cmap('plasma')) cmap.set_bad('w', 1.0) norm = colors.BoundaryNorm(bounds, cmap.N) diff --git a/bdaq53/system/bdaq53.py b/bdaq53/system/bdaq53.py index 282501906..6a609d473 100644 --- a/bdaq53/system/bdaq53.py +++ b/bdaq53/system/bdaq53.py @@ -147,7 +147,7 @@ class BDAQ53(Dut): chip_cfgs = [] for mod_cfg in module_cfgs.values(): for k, v in mod_cfg.items(): - if isinstance(v, collections.Mapping) and 'chip_sn' in v: # Detect chips defined in testbench by the definition of a chip serial number + if isinstance(v, collections.abc.Mapping) and 'chip_sn' in v: # Detect chips defined in testbench by the definition of a chip serial number chip_cfgs.append(v) return chip_cfgs -- GitLab