_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q250200
text_extract
train
def text_extract(path, password=None): """Extract text from a PDF file""" pdf = Info(path, password).pdf
python
{ "resource": "" }
q250201
open_window
train
def open_window(path): """Open path in finder or explorer window""" if 'pathlib' in modules: try: call(["open", "-R", str(Path(str(path)))]) except FileNotFoundError:
python
{ "resource": "" }
q250202
secure
train
def secure(pdf, user_pw, owner_pw, restrict_permission=True, pdftk=get_pdftk_path(), output=None): """ Encrypt a PDF file and restrict permissions to print only. Utilizes pdftk command line tool. :param pdf: Path to PDF file :param user_pw: Password to open and view :param owner_pw: Password t...
python
{ "resource": "" }
q250203
WatermarkAdd.add
train
def add(self, document, watermark): """Add watermark to PDF by merging original PDF and watermark file.""" # 5a. Create output PDF file name output_filename = self.output_filename def pypdf3(): """Much slower than PyPDF3 method.""" # 5b. Get our files ready ...
python
{ "resource": "" }
q250204
img_opacity
train
def img_opacity(image, opacity): """ Reduce the opacity of a PNG image. Inspiration: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/362879 :param image: PNG image file :param opacity: float representing opacity percentage :return: Path to modified PNG """ # Validate parameters...
python
{ "resource": "" }
q250205
IMG2PDF._image_loop
train
def _image_loop(self): """Retrieve an iterable of images either with, or without a progress bar.""" if self.progress_bar and 'tqdm' in self.progress_bar.lower(): return tqdm(self.imgs,
python
{ "resource": "" }
q250206
IMG2PDF._convert
train
def _convert(self, image, output=None): """Private method for converting a single PNG image to a PDF.""" with Image.open(image) as im: width, height = im.size co = CanvasObjects()
python
{ "resource": "" }
q250207
IMG2PDF.convert
train
def convert(self, image, output=None): """ Convert an image to a PDF. :param image: Image file path :param output: Output name,
python
{ "resource": "" }
q250208
add
train
def add(image_path, file_name=None): """Add an image to the GUI img library.""" if file_name is not None: dst_path = os.path.join(IMG_DIR, str(Path(file_name).stem + Path(image_path).suffix)) else:
python
{ "resource": "" }
q250209
remove
train
def remove(image): """Remove an image to the GUI img library.""" path = os.path.join(IMG_DIR, image)
python
{ "resource": "" }
q250210
pluginkit_beforerequest
train
def pluginkit_beforerequest(): """blueprint access auth""" authMethod = current_app.config.get("PLUGINKIT_AUTHMETHOD") authResult = dict(msg=None, code=1, method=authMethod) def authTipmsg(authResult, code=403): """make response message""" return "%s Authentication failed [%s]: %s [%s]"...
python
{ "resource": "" }
q250211
PluginManager.__scanPlugins
train
def __scanPlugins(self): """Scanning local plugin directories and third-party plugin packages. :returns: No return, but self.__plugins will be updated :raises: PluginError: raises an exception, maybe CSSLoadError, VersionError, based PluginError """ self.logger.info("Initializa...
python
{ "resource": "" }
q250212
PluginManager.__getPluginInfo
train
def __getPluginInfo(self, plugin, package_abspath, package_name): """ Organize plugin information. :returns: dict: plugin info """ if not isValidSemver(plugin.__version__): raise VersionError("The plugin version does not conform to the standard named %s" % package_name) ...
python
{ "resource": "" }
q250213
PluginManager.get_plugin_info
train
def get_plugin_info(self, plugin_name): """Get plugin information""" if plugin_name: for i in self.get_all_plugins:
python
{ "resource": "" }
q250214
PluginManager.get_all_tep
train
def get_all_tep(self): """Template extension point :returns: dict: {tep: dict(HTMLFile=[], HTMLString=[]), tep...} """ teps = {} for p in self.get_enabled_plugins: for e, v in p["plugin_tep"].items(): tep = teps.get(e, dict()) tepHF = ...
python
{ "resource": "" }
q250215
PluginManager.get_all_hep
train
def get_all_hep(self): """Hook extension point. * before_request_hook, Before request (intercept requests are allowed) * before_request_top_hook, Before top request (Put it first) * after_request_hook, After request (no exception before return) * teardown_request_hook, After ...
python
{ "resource": "" }
q250216
PluginManager.push_dcp
train
def push_dcp(self, event, callback, position="right"): """Connect a dcp, push a function. :param event: str,unicode: A unique identifier name for dcp. :param callback: callable: Corresponding to the event to perform a function. :param position: The position of the insertion function, ...
python
{ "resource": "" }
q250217
PluginManager.push_func
train
def push_func(self, cuin, callback): """Push a function for dfp. :param cuin: str,unicode: Callback Unique Identifier Name. :param callback: callable: Corresponding to the cuin to perform a function. :raises: DFPError,NotCallableError: raises an exception .. versionadded:: 2....
python
{ "resource": "" }
q250218
PublishCommand.finalize_options
train
def finalize_options(self): """Post-process options.""" if self.test: print("V%s will
python
{ "resource": "" }
q250219
JWTUtil.signatureJWT
train
def signatureJWT(self, message): """ Python generate HMAC-SHA-256 from string """
python
{ "resource": "" }
q250220
PluginInstaller.__isValidTGZ
train
def __isValidTGZ(self, suffix): """To determine whether the suffix `.tar.gz` or `.tgz` format""" if suffix and isinstance(suffix, string_types):
python
{ "resource": "" }
q250221
PluginInstaller.__isValidZIP
train
def __isValidZIP(self, suffix): """Determine if the suffix is `.zip` format""" if suffix and isinstance(suffix, string_types):
python
{ "resource": "" }
q250222
PluginInstaller.__isValidFilename
train
def __isValidFilename(self, filename): """Determine whether filename is valid""" if filename and isinstance(filename, string_types):
python
{ "resource": "" }
q250223
PluginInstaller.__getFilename
train
def __getFilename(self, data, scene=1): """To get the data from different scenarios in the filename, scene value see `remote_download` in 1, 2, 3, 4""" try: filename = None if scene == 1: plugin_filename = [i for i in parse_qs(urlsplit(data).query).get("plugi...
python
{ "resource": "" }
q250224
PluginInstaller.__getFilenameSuffix
train
def __getFilenameSuffix(self, filename): """Gets the filename suffix""" if filename and isinstance(filename, string_types):
python
{ "resource": "" }
q250225
PluginInstaller.__unpack_tgz
train
def __unpack_tgz(self, filename): """Unpack the `tar.gz`, `tgz` compressed file format""" if isinstance(filename, string_types) and self.__isValidTGZ(filename) and tarfile.is_tarfile(filename): with tarfile.open(filename, mode='r:gz') as t: for name
python
{ "resource": "" }
q250226
PluginInstaller.__unpack_zip
train
def __unpack_zip(self, filename): """Unpack the `zip` compressed file format""" if isinstance(filename, string_types) and self.__isValidZIP(filename) and zipfile.is_zipfile(filename): with zipfile.ZipFile(filename) as z: for name in
python
{ "resource": "" }
q250227
PluginInstaller._local_upload
train
def _local_upload(self, filepath, remove=False): """Local plugin package processing""" if os.path.isfile(filepath): filename = os.path.basename(os.path.abspath(filepath)) if filename and self.__isValidFilename(filename): suffix = self.__getFilenameSuffix(file...
python
{ "resource": "" }
q250228
sortedSemver
train
def sortedSemver(versions, sort="asc"): """Semantically sort the list of version Numbers""" if versions and isinstance(versions, (list, tuple)): if PY2: return sorted(versions, cmp=semver.compare, reverse=True if sort.upper() == "DESC" else False) else: from functools imp...
python
{ "resource": "" }
q250229
LocalStorage.set
train
def set(self, key, value): """Set persistent data with shelve. :param key: string: Index key :param value: All supported data types in python :raises: :returns: """
python
{ "resource": "" }
q250230
RedisStorage.set
train
def set(self, key, value): """set key data""" if self._db:
python
{ "resource": "" }
q250231
flatten_list
train
def flatten_list(items, seqtypes=(list, tuple), in_place=True): """Flatten an irregular sequence. Works generally but may be slower than it could be if you can make assumptions about your list. `Source`__ __ https://stackoverflow.com/a/10824086 Parameters ---------- items : iterable ...
python
{ "resource": "" }
q250232
intersperse
train
def intersperse(lis, value): """Put value between each existing item in list. Parameters ---------- lis : list List to intersperse. value : object Value to insert. Returns ------- list
python
{ "resource": "" }
q250233
get_index
train
def get_index(lis, argument): """Find the index of an item, given either the item or index as an argument. Particularly useful as a wrapper for arguments like channel or axis. Parameters ---------- lis : list List to parse. argument : int or object
python
{ "resource": "" }
q250234
_title
train
def _title(fig, title, subtitle="", *, margin=1, fontsize=20, subfontsize=18): """Add a title to a figure. Parameters ---------- fig : matplotlib Figure Figure. title : string Title. subtitle : string Subtitle. margin : number (optional) Distance from top of ...
python
{ "resource": "" }
q250235
add_sideplot
train
def add_sideplot( ax, along, pad=0., *, grid=True, zero_line=True, arrs_to_bin=None, normalize_bin=True, ymin=0, ymax=1.1, height=0.75, c="C0" ): """Add a sideplot to an axis. Sideplots share their corresponding axis. Parameters ---------- ax : matplotlib...
python
{ "resource": "" }
q250236
corner_text
train
def corner_text( text, distance=0.075, *, ax=None, corner="UL", factor=200, bbox=True, fontsize=18, background_alpha=1, edgecolor=None ): """Place some text in the corner of the figure. Parameters ---------- text : str The text to use. distance : numb...
python
{ "resource": "" }
q250237
create_figure
train
def create_figure( *, width="single", nrows=1, cols=[1], margin=1., hspace=0.25, wspace=0.25, cbar_width=0.25, aspects=[], default_aspect=1 ): """Re-parameterization of matplotlib figure creation tools, exposing convenient variables. Figures are defined primarily by thei...
python
{ "resource": "" }
q250238
diagonal_line
train
def diagonal_line(xi=None, yi=None, *, ax=None, c=None, ls=None, lw=None, zorder=3): """Plot a diagonal line. Parameters ---------- xi : 1D array-like (optional) The x axis points. If None, taken from axis limits. Default is None. yi : 1D array-like The y axis points. If None, taken...
python
{ "resource": "" }
q250239
get_scaled_bounds
train
def get_scaled_bounds(ax, position, *, distance=0.1, factor=200): """Get scaled bounds. Parameters ---------- ax : Axes object Axes object. position : {'UL', 'LL', 'UR', 'LR'} Position. distance : number (optional) Distance. Default is 0.1. factor : number (optional)...
python
{ "resource": "" }
q250240
pcolor_helper
train
def pcolor_helper(xi, yi, zi=None): """Prepare a set of arrays for plotting using `pcolor`. The return values are suitable for feeding directly into ``matplotlib.pcolor`` such that the pixels are properly centered. Parameters ---------- xi : 1D or 2D array-like Array of X-coordinates. ...
python
{ "resource": "" }
q250241
plot_colorbar
train
def plot_colorbar( cax=None, cmap="default", ticks=None, clim=None, vlim=None, label=None, tick_fontsize=14, label_fontsize=18, decimals=None, orientation="vertical", ticklocation="auto", extend="neither", extendfrac=None, extendrect=False, ): """Easily add a ...
python
{ "resource": "" }
q250242
plot_margins
train
def plot_margins(*, fig=None, inches=1., centers=True, edges=True): """Add lines onto a figure indicating the margins, centers, and edges. Useful for ensuring your figure design scripts work as intended, and for laying out figures. Parameters ---------- fig : matplotlib.figure.Figure object (o...
python
{ "resource": "" }
q250243
plot_gridlines
train
def plot_gridlines(ax=None, c="grey", lw=1, diagonal=False, zorder=2, makegrid=True): """Plot dotted gridlines onto an axis. Parameters ---------- ax : matplotlib AxesSubplot object (optional) Axis to add gridlines to. If None, uses current axis. Default is None. c : matplotlib color argume...
python
{ "resource": "" }
q250244
savefig
train
def savefig(path, fig=None, close=True, *, dpi=300): """Save a figure. Parameters ---------- path : str Path to save figure at. fig : matplotlib.figure.Figure object (optional) The figure to plot onto. If None, gets current figure. Default is None. close : bool (optional) ...
python
{ "resource": "" }
q250245
set_ax_labels
train
def set_ax_labels(ax=None, xlabel=None, ylabel=None, xticks=None, yticks=None, label_fontsize=18): """Set all axis labels properties easily. Parameters ---------- ax : matplotlib AxesSubplot object (optional) Axis to set. If None, uses current axis. Default is None. xlabel : None or string ...
python
{ "resource": "" }
q250246
set_ax_spines
train
def set_ax_spines(ax=None, *, c="k", lw=3, zorder=10): """Easily set the properties of all four axis spines. Parameters ---------- ax : matplotlib AxesSubplot object (optional) Axis to set. If None, uses current axis. Default is None. c : any matplotlib color argument (optional) Spi...
python
{ "resource": "" }
q250247
set_fig_labels
train
def set_fig_labels( fig=None, xlabel=None, ylabel=None, xticks=None, yticks=None, title=None, row=-1, col=0, label_fontsize=18, title_fontsize=20, ): """Set all axis labels of a figure simultaniously. Only plots ticks and labels for edge axes. Parameters -------...
python
{ "resource": "" }
q250248
subplots_adjust
train
def subplots_adjust(fig=None, inches=1): """Enforce margin to be equal around figure, starting at subplots. .. note:: You probably should be using wt.artists.create_figure instead. See Also -------- wt.artists.plot_margins Visualize margins, for debugging / layout. wt.artists.c...
python
{ "resource": "" }
q250249
stitch_to_animation
train
def stitch_to_animation(images, outpath=None, *, duration=0.5, palettesize=256, verbose=True): """Stitch a series of images into an animation. Currently supports animated gifs, other formats coming as needed. Parameters ---------- images : list of strings Filepaths to the images to stitch ...
python
{ "resource": "" }
q250250
Group.item_names
train
def item_names(self): """Item names.""" if "item_names" not in self.attrs.keys():
python
{ "resource": "" }
q250251
Group.natural_name
train
def natural_name(self): """Natural name.""" try: assert self._natural_name is not None except (AssertionError, AttributeError):
python
{ "resource": "" }
q250252
Group.natural_name
train
def natural_name(self, value): """Set natural name.""" if value is None: value = "" if hasattr(self, "_natural_name") and self.name != "/": keys = [k for k in self._instances.keys() if k.startswith(self.fullpath)] dskeys = [k for k in Dataset._instances.keys()...
python
{ "resource": "" }
q250253
Group.close
train
def close(self): """Close the file that contains the Group. All groups which are in the file will be closed and removed from the _instances dictionaries. Tempfiles, if they exist, will be removed """ from .collection import Collection from .data._data import Chan...
python
{ "resource": "" }
q250254
Group.copy
train
def copy(self, parent=None, name=None, verbose=True): """Create a copy under parent. All children are copied as well. Parameters ---------- parent : WrightTools Collection (optional) Parent to copy within. If None, copy is created in root of new tempfile...
python
{ "resource": "" }
q250255
Group.save
train
def save(self, filepath=None, overwrite=False, verbose=True): """Save as root of a new file. Parameters ---------- filepath : Path-like object (optional) Filepath to write. If None, file is created using natural_name. overwrite : boolean (optional) Toggle...
python
{ "resource": "" }
q250256
from_JASCO
train
def from_JASCO(filepath, name=None, parent=None, verbose=True) -> Data: """Create a data object from JASCO UV-Vis spectrometers. Parameters ---------- filepath : path-like Path to .txt file. Can be either a local or remote file (http/ftp). Can be compressed with gz/bz2, decompre...
python
{ "resource": "" }
q250257
make_cubehelix
train
def make_cubehelix(name="WrightTools", gamma=0.5, s=0.25, r=-1, h=1.3, reverse=False, darkest=0.7): """Define cubehelix type colorbars. Look `here`__ for more information. __ http://arxiv.org/abs/1108.5083 Parameters ---------- name : string (optional) Name of new cmap. Default is Wr...
python
{ "resource": "" }
q250258
make_colormap
train
def make_colormap(seq, name="CustomMap", plot=False): """Generate a LinearSegmentedColormap. Parameters ---------- seq : list of tuples A sequence of floats and RGB-tuples. The floats should be increasing and in the interval (0,1). name : string (optional) A name for the col...
python
{ "resource": "" }
q250259
plot_colormap_components
train
def plot_colormap_components(cmap): """Plot the components of a given colormap.""" from ._helpers import set_ax_labels # recursive import protection plt.figure(figsize=[8, 4]) gs = grd.GridSpec(3, 1, height_ratios=[1, 10, 1], hspace=0.05) # colorbar ax = plt.subplot(gs[0]) gradient = np.li...
python
{ "resource": "" }
q250260
grayify_cmap
train
def grayify_cmap(cmap): """Return a grayscale version of the colormap. `Source`__ __ https://jakevdp.github.io/blog/2014/10/16/how-bad-is-your-colormap/ """ cmap = plt.cm.get_cmap(cmap) colors = cmap(np.arange(cmap.N))
python
{ "resource": "" }
q250261
get_color_cycle
train
def get_color_cycle(n, cmap="rainbow", rotations=3): """Get a list of RGBA colors following a colormap. Useful for plotting lots of elements, keeping the color of each unique. Parameters ---------- n : integer The number of colors to return. cmap : string (optional) The colorma...
python
{ "resource": "" }
q250262
label_sectors
train
def label_sectors( *, labels=["I", "II", "IV", "VI", "V", "III"], ax=None, lw=2, lc="k", cs=None, c_zlevel=2, c_alpha=0.5, fontsize=40 ): """Label the six time-orderings in a three-pulse experiment. Parameters ---------- labels : list of strings Labels to pla...
python
{ "resource": "" }
q250263
fluence
train
def fluence( power_mW, color, beam_radius, reprate_Hz, pulse_width, color_units="wn", beam_radius_units="mm", pulse_width_units="fs_t", area_type="even", ) -> tuple: """Calculate the fluence of a beam. Parameters ---------- power_mW : number Time integrated p...
python
{ "resource": "" }
q250264
mono_resolution
train
def mono_resolution( grooves_per_mm, slit_width, focal_length, output_color, output_units="wn" ) -> float: """Calculate the resolution of a monochromator. Parameters ---------- grooves_per_mm : number Grooves per millimeter. slit_width : number Slit width in microns. focal_l...
python
{ "resource": "" }
q250265
nm_width
train
def nm_width(center, width, units="wn") -> float: """Given a center and width, in energy units, get back a width in nm. Parameters ---------- center : number Center (in energy units). width : number Width (in energy units). units : string (optional) Input units. Default ...
python
{ "resource": "" }
q250266
Subplot.add_arrow
train
def add_arrow( self, index, between, kind, label="", head_length=0.1, head_aspect=2, font_size=14, color="k", ): """Add an arrow to the WMEL diagram. Parameters ---------- index : integer The interac...
python
{ "resource": "" }
q250267
Artist.label_rows
train
def label_rows(self, labels, font_size=15, text_buffer=1.5): """Label rows. Parameters ---------- labels : list of strings Labels. font_size : number (optional) Font size. Default is 15. text_buffer : number Buffer around text. Default...
python
{ "resource": "" }
q250268
Artist.clear_diagram
train
def clear_diagram(self, diagram): """Clear diagram. Parameters ----------
python
{ "resource": "" }
q250269
Artist.add_arrow
train
def add_arrow( self, diagram, number, between, kind, label="", head_length=0.075, font_size=7, color="k" ): """Add arrow. Parameters ---------- diagram : [column, row] Diagram position. number : integer Arrow position. between : [start...
python
{ "resource": "" }
q250270
Artist.plot
train
def plot(self, save_path=None, close=False, bbox_inches="tight", pad_inches=1): """Plot figure. Parameters ---------- save_path : string (optional) Save path. Default is None. close : boolean (optional) Toggle automatic figure closure after plotting. ...
python
{ "resource": "" }
q250271
Collection.create_collection
train
def create_collection(self, name="collection", position=None, **kwargs): """Create a new child colleciton. Parameters ---------- name : string Unique identifier. position : integer (optional) Location to insert. Default is None (append). kwargs ...
python
{ "resource": "" }
q250272
Collection.create_data
train
def create_data(self, name="data", position=None, **kwargs): """Create a new child data. Parameters ---------- name : string Unique identifier. position : integer (optional) Location to insert. Default is None (append). kwargs Addition...
python
{ "resource": "" }
q250273
Collection.flush
train
def flush(self): """Ensure contents are written to file.""" for name in self.item_names: item
python
{ "resource": "" }
q250274
closest_pair
train
def closest_pair(arr, give="indicies"): """Find the pair of indices corresponding to the closest elements in an array. If multiple pairs are equally close, both pairs of indicies are returned. Optionally returns the closest distance itself. I am sure that this could be written as a cheaper operation. ...
python
{ "resource": "" }
q250275
diff
train
def diff(xi, yi, order=1) -> np.ndarray: """Take the numerical derivative of a 1D array. Output is mapped onto the original coordinates using linear interpolation. Expects monotonic xi values. Parameters ---------- xi : 1D array-like Coordinates. yi : 1D array-like Values....
python
{ "resource": "" }
q250276
fft
train
def fft(xi, yi, axis=0) -> tuple: """Take the 1D FFT of an N-dimensional array and return "sensible" properly shifted arrays. Parameters ---------- xi : numpy.ndarray 1D array over which the points to be FFT'ed are defined yi : numpy.ndarray ND array with values to FFT axis : in...
python
{ "resource": "" }
q250277
joint_shape
train
def joint_shape(*args) -> tuple: """Given a set of arrays, return the joint shape. Parameters ---------- args : array-likes Returns ------- tuple of int Joint shape. """ if len(args) == 0: return ()
python
{ "resource": "" }
q250278
orthogonal
train
def orthogonal(*args) -> bool: """Determine if a set of arrays are orthogonal. Parameters ---------- args : array-likes or array shapes Returns ------- bool Array orthogonality condition. """ for i, arg in enumerate(args):
python
{ "resource": "" }
q250279
remove_nans_1D
train
def remove_nans_1D(*args) -> tuple: """Remove nans in a set of 1D arrays. Removes indicies in all arrays if any array is nan at that index. All input arrays must have the same size. Parameters ---------- args : 1D arrays Returns ------- tuple
python
{ "resource": "" }
q250280
share_nans
train
def share_nans(*arrs) -> tuple: """Take a list of nD arrays and return a new list of nD arrays. The new list is in the same order as the old list. If one indexed element in an old array is nan then every element for that index
python
{ "resource": "" }
q250281
smooth_1D
train
def smooth_1D(arr, n=10, smooth_type="flat") -> np.ndarray: """Smooth 1D data using a window function. Edge effects will be present. Parameters ---------- arr : array_like Input array, 1D. n : int (optional) Window length. smooth_type : {'flat', 'hanning', 'hamming', '...
python
{ "resource": "" }
q250282
svd
train
def svd(a, i=None) -> tuple: """Singular Value Decomposition. Factors the matrix `a` as ``u * np.diag(s) * v``, where `u` and `v` are unitary and `s` is a 1D array of `a`'s singular values. Parameters ---------- a : array_like Input array.
python
{ "resource": "" }
q250283
unique
train
def unique(arr, tolerance=1e-6) -> np.ndarray: """Return unique elements in 1D array, within tolerance. Parameters ---------- arr : array_like Input array. This will be flattened if it is not already 1D. tolerance : number (optional) The tolerance for uniqueness. Returns --...
python
{ "resource": "" }
q250284
valid_index
train
def valid_index(index, shape) -> tuple: """Get a valid index for a broadcastable shape. Parameters ---------- index : tuple Given index. shape : tuple of int Shape. Returns ------- tuple Valid index. """ # append slices to index index = list(index) ...
python
{ "resource": "" }
q250285
mask_reduce
train
def mask_reduce(mask): """Reduce a boolean mask, removing all false slices in any dimension. Parameters ---------- mask : ndarray with bool dtype The mask which is to be reduced Returns ------- A boolean mask with no all False slices. """ mask = mask.copy() for i in...
python
{ "resource": "" }
q250286
enforce_mask_shape
train
def enforce_mask_shape(mask, shape): """Reduce a boolean mask to fit a given shape. Parameters ---------- mask : ndarray with bool dtype The mask which is to be reduced shape : tuple of int Shape which broadcasts to the mask shape. Returns -------
python
{ "resource": "" }
q250287
DatasetContainer._from_directory
train
def _from_directory(self, dirname, prefix=""): """Add dataset from files in a directory. Parameters ---------- dirname : string Directory name. prefix : string Prefix. """
python
{ "resource": "" }
q250288
string2identifier
train
def string2identifier(s): """Turn a string into a valid python identifier. Currently only allows ASCII letters and underscore. Illegal characters are replaced with underscore. This is slightly more opinionated than python 3 itself, and may be refactored in future (see PEP 3131). Parameters ---...
python
{ "resource": "" }
q250289
converter
train
def converter(val, current_unit, destination_unit): """Convert from one unit to another. Parameters ---------- val : number Number to convert. current_unit : string Current unit. destination_unit : string Destination unit. Returns ------- number Conv...
python
{ "resource": "" }
q250290
get_symbol
train
def get_symbol(units) -> str: """Get default symbol type. Parameters ---------- units_str : string Units. Returns ------- string LaTeX formatted symbol. """ if kind(units) == "energy": d = {} d["nm"] = r"\lambda" d["wn"] = r"\bar\nu" ...
python
{ "resource": "" }
q250291
kind
train
def kind(units): """Find the kind of given units. Parameters ---------- units : string The units of interest
python
{ "resource": "" }
q250292
latex_defs_to_katex_macros
train
def latex_defs_to_katex_macros(defs): r'''Converts LaTeX \def statements to KaTeX macros. This is a helper function that can be used in conf.py to translate your already specified LaTeX definitions. https://github.com/Khan/KaTeX#rendering-options, e.g. `\def \e #1{\mathrm{e}^{#1}}` => `"\\e:" "\\m...
python
{ "resource": "" }
q250293
katex_rendering_delimiters
train
def katex_rendering_delimiters(app): """Delimiters for rendering KaTeX math. If no delimiters are specified in katex_options, add the katex_inline and katex_display delimiters. See also https://khan.github.io/KaTeX/docs/autorender.html """ # Return if we have user defined rendering delimiters ...
python
{ "resource": "" }
q250294
Axis.label
train
def label(self) -> str: """A latex formatted label representing axis expression.""" label = self.expression.replace("_", "\\;") if self.units_kind: symbol = wt_units.get_symbol(self.units) for v in self.variables: vl = "%s_{%s}" % (symbol, v.label)
python
{ "resource": "" }
q250295
Axis.natural_name
train
def natural_name(self) -> str: """Valid python identifier representation of the expession.""" name = self.expression.strip() for op in operators:
python
{ "resource": "" }
q250296
Axis.masked
train
def masked(self) -> np.ndarray: """Axis expression evaluated, and masked with NaN shared from data channels.""" arr = self[:] arr.shape = self.shape arr = wt_kit.share_nans(arr, *self.parent.channels)[0]
python
{ "resource": "" }
q250297
Axis.convert
train
def convert(self, destination_units, *, convert_variables=False): """Convert axis to destination_units. Parameters ---------- destination_units : string Destination units. convert_variables : boolean (optional) Toggle conversion of stored arrays. Default ...
python
{ "resource": "" }
q250298
INI.add_section
train
def add_section(self, section): """Add section. Parameters ---------- section : string
python
{ "resource": "" }
q250299
INI.dictionary
train
def dictionary(self) -> dict: """Get a python dictionary of contents."""
python
{ "resource": "" }