def stream_process(self, entity, data, meta={}): try: start_datetime = data.index[0] trip_id = create_id( self.loader.organization.id, entity.id, start_datetime ) self.tripdata.append((trip_id, data)) metadata = meta.copy() util.update_dict( metadata, { 'passenger': True if data['passenger'][0] else False, } ) geometry = create_linestring(data) data = ( trip_id, entity.id, start_datetime, data.index[0] - start_datetime, geometry, self.archive_uri, json.dumps(metadata), ) return data except (SystemExit, KeyboardInterrupt): raise except: logger.warning('Failed to load: {} due to:\n{}'.format( entity.id, traceback.format_exc() )) return None
def add_text(self, x, y, s, **kwargs): style = {'color': 'k', 'fontsize': 10} update_dict(style, kwargs, False) self._text.append([x, y, s]) self._text_style.append(style)
def __init__(self, figlabel, **kwargs): super(TwoPaneFigure, self).__init__(figlabel, **kwargs) style = copy.deepcopy(self._style) update_dict(style, kwargs) height_ratio = 1.6 gs1 = gridspec.GridSpec(2, 1, height_ratios=[height_ratio, 1]) ax0 = self._fig.add_subplot(gs1[0, 0]) ax1 = self._fig.add_subplot(gs1[1, 0], sharex=ax0) style0 = copy.deepcopy(style) style1 = copy.deepcopy(style) style0['xlabel'] = None style1['legend'] = False style1['title'] = None fp0 = FigureSubplot(ax0, **style0) fp1 = FigureSubplot(ax1, **style1) self._fig.subplots_adjust(hspace=0.1) plt.setp([ax0.get_xticklabels()], visible=False) self._subplots.append(fp0) self._subplots.append(fp1)
def __init__(self,figlabel,**kwargs): super(TwoPaneFigure,self).__init__(figlabel,**kwargs) style = copy.deepcopy(self._style) update_dict(style,kwargs) height_ratio=1.6 gs1 = gridspec.GridSpec(2, 1, height_ratios = [height_ratio,1]) ax0 = self._fig.add_subplot(gs1[0,0]) ax1 = self._fig.add_subplot(gs1[1,0],sharex=ax0) style0 = copy.deepcopy(style) style1 = copy.deepcopy(style) style0['xlabel'] = None style1['nolegend'] = True style1['title'] = None fp0 = FigureSubplot(ax0,**style0) fp1 = FigureSubplot(ax1,**style1) self._fig.subplots_adjust(hspace=0.1) plt.setp([ax0.get_xticklabels()],visible=False) self._subplots.append(fp0) self._subplots.append(fp1)
def update_default_config(self,default_dict,group=None): """Update configuration for the object adding keys for elements that are not present. If group is defined then this configuration will be nested in a dictionary with that key.""" if default_dict is None: return if not isinstance(default_dict,dict) and \ issubclass(default_dict,Configurable): default_dict = default_dict.default_config elif not isinstance(default_dict,dict): raise Exception('Wrong type for default dict.') if group: default_config = self._default_config.setdefault(group,{}) self._config.setdefault(group,{}) else: default_config = self._default_config update_dict(default_config,default_dict,True) for k in default_dict.keys(): # if not isinstance(self._default_config[k],Option): option = Option.create(k,default_dict[k],group=group) default_config[option.name] = option if option.group: self._config.setdefault(option.group,{}) self._config[option.group][option.name] = option.value else: self._config[option.name] = self._default_config[k].value
def add_text(self,x,y,s,**kwargs): style = { 'color' : 'k', 'fontsize' : 10 } update_dict(style,kwargs,False) self._text.append([x,y,s]) self._text_style.append(style)
def minimize(self,pset=None,**kwargs): if pset is None: pset = self._objfn.param(True) bounds = [] for p in pset: if p.fixed: bounds.append([p.value.flat[0],p.value.flat[0]]) else: bounds.append(p.lims) from scipy.optimize import fmin_l_bfgs_b as fmin_bfgs bfgs_kwargs = self.config #{'pgtol' : 1E-5, bounds=bounds, 'factr' : 1E7 } bfgs_kwargs['bounds'] = bounds update_dict(bfgs_kwargs,kwargs) res = fmin_bfgs(self._objfn,pset.array(),None, approx_grad=1,**bfgs_kwargs)#,factr=1./self._tol) pset.update(res[0]) self._fit_results = FitResults(pset,res[1]) # How to compute errors? return copy.deepcopy(self._fit_results)
def add_hline(self, x, **kwargs): style = {'color': None, 'linestyle': None, 'label': None} update_dict(style, kwargs, False) self._hline.append(x) self._hline_style.append(style)
def add_hline(self,x,**kwargs): style = { 'color' : None, 'linestyle' : None, 'label' : None } update_dict(style,kwargs,False) self._hline.append(x) self._hline_style.append(style)
def enroll(): if check_audio_file(app, request, 'audio_file'): user_id = str(uuid.uuid4()) user_name = request.form.get('username') password = request.form.get('password') update_dict(paths.PASSWORDS, user_id, password) audio_file = request.files['audio_file'] preprocessed_audio_file = preprocess(audio_file, 3, 2) voice_vector = model_loader.predict(preprocessed_audio_file, 'conv_encoder') np.save(paths.VECTORS + user_id, voice_vector) # Update user dict. update_dict(paths.USER_DICT, user_id, user_name) return Response(str(200), mimetype='text/plain')
def normalize(self, residual=False, **kwargs): style = copy.deepcopy(self._style) update_dict(style, kwargs) norm_index = 0 if not style['norm_index'] is None: norm_index = style['norm_index'] if isinstance(self._data[norm_index], Histogram): x = copy.deepcopy(self._data[norm_index].center()) y = copy.deepcopy(self._data[norm_index].counts) elif isinstance(self._data[norm_index], Series): x = copy.deepcopy(self._data[norm_index].x()) y = copy.deepcopy(self._data[norm_index].y()) if style['norm_interpolation'] == 'log': fn = UnivariateSpline(x, np.log10(y), k=1, s=0) else: fn = UnivariateSpline(x, y, k=1, s=0) # msk = y>0 for i, d in enumerate(self._data): if isinstance(d, Series): msk = (d.x() >= x[0] * 0.95) & (d.x() <= x[-1] * 1.05) if style['norm_interpolation'] == 'log': ynorm = 10**fn(d.x()) else: ynorm = fn(d.x()) self._data[i]._msk &= msk self._data[i] /= ynorm if style['norm_style'] == 'residual': self._data[i] -= 1.0 elif isinstance(d, Histogram): if style['norm_interpolation'] == 'log': ynorm = 10**fn(d.axis().center) else: ynorm = fn(d.axis().center) self._data[i] /= ynorm if style['norm_style'] == 'residual': self._data[i]._counts -= 1.0
def __init__(self, figlabel, nsubplot=0, **kwargs): self._style = copy.deepcopy(Figure.style) update_dict(self._style, FigureSubplot.style, True) update_dict(self._style, kwargs) figsize = self._style['figsize'] figsize[0] *= self._style['figscale'] figsize[1] *= self._style['figscale'] self._fig = plt.figure('Figure %i' % Figure.fignum, figsize=figsize) Figure.fignum += 1 self._figlabel = figlabel self._subplots = [] self.add_subplot(nsubplot)
def __init__(self,figlabel,nsubplot=0,**kwargs): self._style = copy.deepcopy(Figure.style) update_dict(self._style,FigureSubplot.style,True) update_dict(self._style,kwargs) figsize = self._style['figsize'] figsize[0] *= self._style['figscale'] figsize[1] *= self._style['figscale'] self._fig = plt.figure('Figure %i'%Figure.fignum,figsize=figsize) Figure.fignum += 1 self._figlabel = figlabel self._subplots = [] self.add_subplot(nsubplot)
def update_distances(current_user_id, current_vector, distance='euclidean'): current_user_dict = dict() file_names = [] for (_, _, names) in walk(paths.VECTORS): file_names.extend(names) break if file_names: for file_name in file_names: other_vector = np.load(paths.VECTORS + file_name) # Update current user dict. dist = count_distance(current_vector, other_vector, distance) current_user_dict[os.path.splitext(file_name)[0]] = dist # Update other dict too and save to file. update_dict(paths.DISTANCES + os.path.splitext(file_name)[0], current_user_id, dist) # Write current user dict to file. write_dict_to_file(paths.DISTANCES + current_user_id, current_user_dict) # Save current vector to file. np.save(paths.VECTORS + current_user_id, current_vector)
def add_subplot(self,n=1,**kwargs): if n == 0: return if isinstance(n,tuple): nx, ny = n elif n == 1: nx, ny = 1,1 elif n == 2: nx, ny = 2,1 elif n > 2 and n <= 4: nx, ny = 2,2 for i in range(nx*ny): style = copy.deepcopy(self._style) update_dict(style,kwargs) ax = self._fig.add_subplot(ny,nx,i+1) if self._style['figstyle'] == 'ratio': self._subplots.append(RatioSubplot(ax,**style)) else: self._subplots.append(FigureSubplot(ax,**style))
def add_subplot(self, n=1, **kwargs): if n == 0: return if isinstance(n, tuple): nx, ny = n elif n == 1: nx, ny = 1, 1 elif n == 2: nx, ny = 2, 1 elif n > 2 and n <= 4: nx, ny = 2, 2 for i in range(nx * ny): style = copy.deepcopy(self._style) update_dict(style, kwargs) ax = self._fig.add_subplot(ny, nx, i + 1) if self._style['figstyle'] == 'ratio': self._subplots.append(RatioSubplot(ax, **style)) else: self._subplots.append(FigureSubplot(ax, **style))
def normalize(self,residual=False,**kwargs): style = copy.deepcopy(self._style) update_dict(style,kwargs) norm_index = 0 if not style['norm_index'] is None: norm_index = style['norm_index'] if isinstance(self._data[norm_index],Histogram): x = copy.deepcopy(self._data[norm_index].axis(0).center) y = copy.deepcopy(self._data[norm_index].counts) elif isinstance(self._data[norm_index],Series): x = copy.deepcopy(self._data[norm_index].x()) y = copy.deepcopy(self._data[norm_index].y()) if style['norm_interpolation'] == 'log': fn = UnivariateSpline(x,np.log10(y),k=1,s=0) else: fn = UnivariateSpline(x,y,k=1,s=0) # msk = y>0 for i, d in enumerate(self._data): if isinstance(d,Series): msk = (d.x() >= x[0]*0.95) & (d.x() <= x[-1]*1.05) if style['norm_interpolation'] == 'log': ynorm = 10**fn(d.x()) else: ynorm = fn(d.x()) self._data[i]._msk &= msk self._data[i] /= ynorm if style['norm_style'] == 'residual': self._data[i] -= 1.0 elif isinstance(d,Histogram): if style['norm_interpolation'] == 'log': ynorm = 10**fn(d.axis().center) else: ynorm = fn(d.axis().center) self._data[i] /= ynorm if style['norm_style'] == 'residual': self._data[i]._counts -= 1.0
def freq_filter_term(word_freq, words_tags): ''' Filter candidate term according to its frequency and pos tagging ''' cache_prefix = "" for word_tag in words_tags: # check correctness of number of elements if len(word_tag) != 3: continue #word = word_tag[0].lower() word = word_tag[0] pos_tag = word_tag[1] chunk_tag = word_tag[2] # word stemming and stopword checker word = nlp_process(word) if word == None: if len(cache_prefix) > 0: word_freq = update_dict(word_freq, cache_prefix) cache_prefix = "" continue # filter according to pos tagging if pos_tag not in NOUN_POS: if len(cache_prefix) > 0: word_freq = update_dict(word_freq, cache_prefix) cache_prefix = "" continue # check noun phrase if chunk_tag == CHUNK_POS_ST: if len(cache_prefix) > 0: word_freq = update_dict(word_freq, cache_prefix) cache_prefix = word elif chunk_tag == CHUNK_POS_MD: if len(cache_prefix) > 0: cache_prefix += PHRASE_SEP + word else: cache_prefix = word else: if len(cache_prefix) > 0: word_freq = update_dict(word_freq, cache_prefix) cache_prefix = "" return word_freq
def __init__(self,figlabel,**kwargs): super(TwoPaneRatioFigure,self).__init__(figlabel,**kwargs) style = copy.deepcopy(self._style) update_dict(style,kwargs) height_ratio=1.6 gs1 = gridspec.GridSpec(2, 1, height_ratios = [height_ratio,1]) ax0 = self._fig.add_subplot(gs1[0,0]) ax1 = self._fig.add_subplot(gs1[1,0],sharex=ax0) style0 = copy.deepcopy(style) style1 = copy.deepcopy(style) style0['xlabel'] = None if style['norm_style'] == 'ratio': style1['ylabel'] = 'Ratio' elif style['norm_style'] == 'residual': style1['ylabel'] = 'Fractional Residual' style1['yscale'] = 'lin' style1['ylim'] = style['ylim_ratio'] style1['nolegend'] = True style1['title'] = '' # ratio_subp.set_style('show_args',style['show_ratio_args']) # ratio_subp.set_style('mask_args',style['mask_ratio_args']) fp0 = FigureSubplot(ax0,**style0) fp1 = RatioSubplot(ax1,fp0,**style1) self._fig.subplots_adjust(hspace=0.1) plt.setp([ax0.get_xticklabels()],visible=False) self._subplots.append(fp0) self._subplots.append(fp1)
def plot(self,**kwargs): style = copy.deepcopy(self._style) update_dict(style,kwargs) fig_name = '%s'%(self._figlabel) fig_name = os.path.join(style['fig_dir'],fig_name) for p in self._subplots: p.plot(**kwargs) if not style['fontsize'] is None: for p in self._subplots: set_font_size(p.ax(),style['fontsize']) self._fig.subplots_adjust(**style['subplot_margins']) if isinstance(style['format'],list): formats = style['format'] else: formats = [style['format']] for fmt in formats: self._fig.savefig(fig_name + '.%s'%fmt)
def __init__(self, figlabel, **kwargs): super(TwoPaneRatioFigure, self).__init__(figlabel, **kwargs) style = copy.deepcopy(self._style) update_dict(style, kwargs) height_ratio = 1.6 gs1 = gridspec.GridSpec(2, 1, height_ratios=[height_ratio, 1]) ax0 = self._fig.add_subplot(gs1[0, 0]) ax1 = self._fig.add_subplot(gs1[1, 0], sharex=ax0) style0 = copy.deepcopy(style) style1 = copy.deepcopy(style) style0['xlabel'] = None if style['norm_style'] == 'ratio': style1['ylabel'] = 'Ratio' elif style['norm_style'] == 'residual': style1['ylabel'] = 'Fractional Residual' style1['yscale'] = 'lin' style1['ylim'] = style['ylim_ratio'] style1['legend'] = False # ratio_subp.set_style('show_args',style['show_ratio_args']) # ratio_subp.set_style('mask_args',style['mask_ratio_args']) fp0 = FigureSubplot(ax0, **style0) fp1 = RatioSubplot(ax1, fp0, **style1) self._fig.subplots_adjust(hspace=0.1) plt.setp([ax0.get_xticklabels()], visible=False) self._subplots.append(fp0) self._subplots.append(fp1)
def __init__(self, ax, **kwargs): self._style = copy.deepcopy(FigureSubplot.style) update_dict(self._style, kwargs) self._ax = ax self._cb = None self._data = [] self._style_counter = { 'color': 0, 'marker': 0, 'markersize': 0, 'linestyle': 0, 'linewidth': 0, 'hist_style': 0, 'hist_xerr': 0 } self._hline = [] self._hline_style = [] self._text = [] self._text_style = []
def plot(self, **kwargs): style = copy.deepcopy(self._style) update_dict(style, kwargs) fig_name = '%s' % (self._figlabel) fig_name = os.path.join(style['fig_dir'], fig_name) for p in self._subplots: p.plot(**kwargs) if not style['fontsize'] is None: for p in self._subplots: set_font_size(p.ax(), style['fontsize']) self._fig.subplots_adjust(**style['subplot_margins']) if isinstance(style['format'], list): formats = style['format'] else: formats = [style['format']] for fmt in formats: self._fig.savefig(fig_name + '.%s' % fmt)
def __init__(self,ax,**kwargs): self._style = copy.deepcopy(FigureSubplot.style) update_dict(self._style,kwargs) self._ax = ax self._cb = None self._data = [] self._style_counter = { 'color' : 0, 'marker' : 0, 'markersize' : 0, 'linestyle' : 0, 'linewidth' : 0, 'hist_style' : 0, 'hist_xerr' : 0 } self._hline = [] self._hline_style = [] self._text = [] self._text_style = []
def configure(self,config=None,opts=None,group=None,**kwargs): """Update the configuration of this object with the contents of 'config'. When the same option is defined in multiple inputs the order of precedence is config -> opts -> kwargs.""" if not config is None: if group and not group in config: raise Exception('Exception') if group: update_dict(self._config,config[group]) else: update_dict(self._config,config) if not opts is None: self.parse_opts(opts) update_dict(self._config,kwargs) for k, v in self._config.iteritems(): if v is None or not isinstance(v,str): continue if os.path.isfile(v): self._config[k] = os.path.abspath(v)
def _modify_ldap_config(keys, val): conf = yaml.safe_load(open(ldap_config_file)) conf = update_dict(conf, keys, val) yaml.dump(conf, open(ldap_config_file, 'w')) return ldap_config_file
def main(print_default_configuration, print_configuration, packages, owner, channel, create, config_file): """ Export conan packages to the local cache. This script exports conan recipes to the local cache by default. Consumers can then use the packages, but must specify `--build missing` the first time they install. This script allows conan package recipes to be generated from a base recipe. For example, if you wanted to create a package for the last three major releases of LibA, the recipe files for each version would probably look identical expect for the version number and the commit that gets checked out (unless the build system changes). Rather than write three different recipes, you can just write a single recipe for the latest release. This script can then generate recipes for the other versions. To do this, every package that gets exported by this script starts with a base recipe. You can then specify settings to override (see Configuration Settings below) to create a new recipe instance. If no override settings are specified, then the recipe instance will just be the base recipe. base recipe -> [override settigns] -> recipe instance This is convenient because it allows you to maintain a collection of valid recipe files that can be tested and used with just conan, and then use this script to export variations on these recipes. Configuration: The exported packages can be configured using a YAML file and passing it as an argument to this script. Configuration Settings: \b global a namespace for global package settings (setting that will be applied to all packages) global.export a namespace for setting related to exporting packages. global.export.owner the default package owner global.export.channel the default package channel package_instances a namespace used for overriding package settings on a per-package basis. package_instances[i].conanfile path to the conan recipe to use. package_instances[i].name name used to refer to package in the script. this is not the name that will be used in the package recipe (see settings_overrides) package_instances[i].setting_overrides a dict of key/value pairs that will be added to the recipe instance to override settings in the base recipe. the key/value pairs are arbitrary. if the key is a setting in the base recipe, it will be overridden. if it is not, it will be added. package_instances[i].setting_overrides.name override the package name package_instances[i].setting_overrides.version override the package version package_instances[i].setting_overrides.checkout override the git reference that will be checked out to build the package. must be supported by the base recipe. export-tool a namespace used for setting for this script export-tool.scratch-folder the name of the directory used for writing data to disk (logs, temp files, etc) export-tool.packages_to_export a list of packages to export. by default, all packages will be exported. this will be overridden by the --packages option. Example Configuration File: \b export-packages: packages_to_export: all scratch-folder: _package-exports.d global: export: channel: devel owner: MyOrg package_instances: - conanfile: /path/to/LibA/conanfile.py name: LibA setting_overrides: version: "3.1" checkout: "v3.1" - conanfile: /path/to/LibA/conanfile.py name: LibA setting_overrides: version: "3.2" checkout: "v3.2" This will create and export a recipe instance for every conanfile.py found in the recipies directory, and two recipe instances for the LibA package. """ default_configuration_file = prog_path.parent / f"{prog_path.stem}-default-config.yaml" if default_configuration_file.exists(): default_configuration_text = default_configuration_file.read_text() else: default_configuration_text = "" print( util.WARN + f"WARNING: did not find default configuration file '{str(default_configuration_file)}'." + util.EOL) config = yaml.load(default_configuration_text, Loader=yaml.BaseLoader) if print_default_configuration: print("# Default Configuration") print(yaml.dump(config)) sys.exit(0) for file in config_file: util.update_dict( config, yaml.load(Path(file).read_text(), Loader=yaml.BaseLoader)) if not 'global' in config: config['global'] = dict() if not 'export' in config['global']: config['global']['export'] = dict() if owner: config['global']['export']['owner'] = owner if channel: config['global']['export']['channel'] = channel if packages: if packages in ['all', 'instances-only']: config[prog_path.stem]['packages_to_export'] = packages else: config[prog_path.stem]['packages_to_export'] = packages.split(",") packages_to_export = config[prog_path.stem].get('packages_to_export', 'all') if not 'package_instances' in config: config['package_instances'] = list() # sort of a hack. we want to let the user specify that only the instances explicitly listed # should be exported if packages_to_export != "instances-only": for file in Path("recipes").glob("*/conanfile.py"): config['package_instances'].append({ 'conanfile': str(file.absolute()), 'name': str(file.parent.stem) }) for file in Path("recipes").glob("*/conanfile-latest.py"): config['package_instances'].append({ 'conanfile': str(file.absolute()), 'name': str(file.parent.stem) }) else: packages_to_export = "all" # make sure all conanfiles are specified with absolute path for instance in config["package_instances"]: instance["conanfile"] = str(Path(instance["conanfile"]).absolute()) if print_configuration: print("# Complete Configuration") print(yaml.dump(config)) sys.exit(0) pc = util.PackageCollection() pc.load(config) scratch_folder_path = Path(pc.config[prog_path.stem]["scratch-folder"]) if scratch_folder_path.exists(): shutil.rmtree(str(scratch_folder_path)) scratch_folder_path.mkdir() packages_to_export = [ p.name for p in util.filter_packages(packages_to_export, pc.package_instances) ] if create: print("Creating packages") with (Path(pc.config[prog_path.stem]["scratch-folder"]) / "conan_export.out").open('w') as f: pc.create_packages(config=packages_to_export, stdout=f) print("Done") else: print("Exporting packages") with (Path(pc.config[prog_path.stem]["scratch-folder"]) / "conan_export.out").open('w') as f: pc.export_packages(config=packages_to_export, stdout=f) print("Done")
def plot(self,**kwargs): style = copy.deepcopy(self._style) update_dict(style,kwargs) ax = self._ax yscale = style['yscale'] if 'yscale' in kwargs: yscale = kwargs.pop('yscale') xscale = style['xscale'] if 'xscale' in kwargs: xscale = kwargs.pop('xscale') logz = style['logz'] if 'logz' in kwargs: logz = kwargs.pop('logz') if not style['title'] is None: ax.set_title(style['title']) labels = [] iargs = range(len(self._data)) if not style['show_args'] is None: iargs = style['show_args'] if not style['mask_args'] is None: iargs = [x for x in iargs if x not in style['mask_args']] for i in iargs: s = self._data[i] labels.append(s.label()) p = s.plot(ax=ax,logz=logz) if isinstance(p,QuadMesh): self._cb = plt.colorbar(p,ax=ax) if not style['zlabel'] is None: self._cb.set_label(style['zlabel']) for i, h in enumerate(self._hline): ax.axhline(self._hline[i],**self._hline_style[i]) for i, t in enumerate(self._text): ax.text(*t,transform=ax.transAxes, **self._text_style[i]) ax.grid(style['grid']) if len(labels) > 0 and not style['nolegend']: legkwargs = copy.deepcopy(style['legend']) legkwargs['prop'] = {'size' : legkwargs.pop('size',12)} ax.legend(numpoints=1,**legkwargs) if not style['ylabel'] is None: ax.set_ylabel(style['ylabel']) if not style['xlabel'] is None: ax.set_xlabel(style['xlabel']) if not style['xlim'] is None: ax.set_xlim(style['xlim']) if not style['ylim'] is None: ax.set_ylim(style['ylim']) # if ratio: ax.set_ylim(0.0,2.0) # if not ylim is None: ax.set_ylim(ylim) if yscale == 'log': ax.set_yscale('log') elif yscale == 'sqrt': ax.set_yscale('sqrt',exp=2.0) if xscale == 'log': ax.set_xscale('log') elif xscale == 'sqrt': ax.set_xscale('sqrt',exp=2.0) if style['fontsize'] is not None: set_font_size(ax,style['fontsize'])
def plot(self, **kwargs): style = copy.deepcopy(self._style) update_dict(style, kwargs) ax = self._ax yscale = style['yscale'] if 'yscale' in kwargs: yscale = kwargs.pop('yscale') xscale = style['xscale'] if 'xscale' in kwargs: xscale = kwargs.pop('xscale') logz = style['logz'] if 'logz' in kwargs: logz = kwargs.pop('logz') if not style['title'] is None: ax.set_title(style['title']) labels = [] iargs = range(len(self._data)) if not style['show_args'] is None: iargs = style['show_args'] if not style['mask_args'] is None: iargs = [x for x in iargs if x not in style['mask_args']] for i in iargs: s = self._data[i] labels.append(s.label()) p = s.plot(ax=ax, logz=logz) if isinstance(p, QuadMesh): self._cb = plt.colorbar(p, ax=ax) if not style['zlabel'] is None: self._cb.set_label(style['zlabel']) for i, h in enumerate(self._hline): ax.axhline(self._hline[i], **self._hline_style[i]) for i, t in enumerate(self._text): ax.text(*t, transform=ax.transAxes, **self._text_style[i]) ax.grid(True) if len(labels) > 0 and style['legend']: ax.legend(prop={'size': style['legend_fontsize']}, loc=style['legend_loc'], ncol=1, numpoints=1) if not style['ylabel'] is None: ax.set_ylabel(style['ylabel']) if not style['xlabel'] is None: ax.set_xlabel(style['xlabel']) if not style['xlim'] is None: ax.set_xlim(style['xlim']) if not style['ylim'] is None: ax.set_ylim(style['ylim']) # if ratio: ax.set_ylim(0.0,2.0) # if not ylim is None: ax.set_ylim(ylim) if yscale == 'log': ax.set_yscale('log') elif yscale == 'sqrt': ax.set_yscale('sqrt', exp=2.0) if xscale == 'log': ax.set_xscale('log') elif xscale == 'sqrt': ax.set_xscale('sqrt', exp=2.0)
def update_config(self,config): update_dict(self._config,config)