content
stringlengths
35
762k
sha1
stringlengths
40
40
id
int64
0
3.66M
from typing import Dict def dataset_is_open_data(dataset: Dict) -> bool: """Check if dataset is tagged as open data.""" is_open_data = dataset.get("isOpenData") if is_open_data: return is_open_data["value"] == "true" return False
fc1591d4a045ba904658bb93577a364145492465
3,659,600
def _remove_suffix_apple(path): """ Strip off .so or .dylib. >>> _remove_suffix_apple("libpython.so") 'libpython' >>> _remove_suffix_apple("libpython.dylib") 'libpython' >>> _remove_suffix_apple("libpython3.7") 'libpython3.7' """ if path.endswith(".dylib"): return path[:...
c5526b0f3420625c2efeba225187f72c7a51fb4b
3,659,601
def sparsenet201(**kwargs): """ SparseNet-201 model from 'Sparsely Aggregated Convolutional Networks,' https://arxiv.org/abs/1801.05895. Parameters: ---------- pretrained : bool, default False Whether to load the pretrained weights for model. root : str, default '~/.torch/models' ...
83de415e043876ae90dd3f79c3ca26dd82d8c5df
3,659,602
def alt_text_to_curly_bracket(text): """ Converts the text that appears in the alt attribute of image tags from gatherer to a curly-bracket mana notation. ex: 'Green'->{G}, 'Blue or Red'->{U/R} 'Variable Colorless' -> {XC} 'Colorless' -> {C} 'N colorless' -> {N}, where N is some ...
c604b236a8d0baeff244e0e246176a406674c9e2
3,659,603
def massage_primary(repo_primary, src_cache, cdt): """ Massages the result of dictify() into a less cumbersome form. In particular: 1. There are many lists that can only be of length one that don't need to be lists at all. 2. The '_text' entries need to go away. 3. The real information st...
fd57ff925b46eb5adddee2c180fbc01b3c60ec7c
3,659,604
def ansi_color_name_to_escape_code(name, style="default", cmap=None): """Converts a color name to the inner part of an ANSI escape code""" cmap = _ensure_color_map(style=style, cmap=cmap) if name in cmap: return cmap[name] m = RE_XONSH_COLOR.match(name) if m is None: raise ValueError...
70b8fe19fc34d14c678c9e54890a4da7e0e37c24
3,659,605
import shlex import getopt from datetime import datetime def twitter(bot, message): """#twitter [-p 天数] -p : 几天以前 """ try: cmd, *args = shlex.split(message.text) except ValueError: return False if not cmd[0] in config['trigger']: return False if not cmd[1:] == 'tw...
ba02cebb5a680f26f2eb17c32b62ead9ac3995a3
3,659,606
from typing import List import os def checkdir(*args: List[str]) -> bool: """ Guard for checking directories Returns: bool -- True if all arguments directories """ for a in args: if a and not os.path.isdir(a): return False if a and a[0] != '/': retu...
f1fc1c99e9bb6d4fd12129f1287923fc2f3325eb
3,659,607
import logging def get_zones(request): """Returns preprocessed thermal data for a given request or None.""" logging.info("received zone request:", request.building) zones, err = _get_zones(request.building) if err is not None: return None, err grpc_zones = [] for zones in zones: ...
b04dca4da5b68faea64744c9c7093a977eb120c1
3,659,608
def proper_classification(sp): """ Uses splat.classifyByStandard to classify spectra using spex standards """ #sp.slitpixelwidth=1 #sp.slitwidth=1 #sp.toInstrument('WFC3-G141') wsp= wisps.Spectrum(wave=sp.wave.value, flux=sp.flux.value, ...
31529d96fbc4fec69a5996fb33829be4caf51529
3,659,609
from typing import Tuple import torch def sum_last_4_layers(sequence_outputs: Tuple[torch.Tensor]) -> torch.Tensor: """Sums the last 4 hidden representations of a sequence output of BERT. Args: ----- sequence_output: Tuple of tensors of shape (batch, seq_length, hidden_size). For BERT base, th...
14bba441a116712d1431b1ee6dda33dc5ec4142c
3,659,610
def TotalCust(): """(read-only) Total Number of customers served from this line section.""" return lib.Lines_Get_TotalCust()
58984b853cdd9587c7db5ff6c30b7af20a64985a
3,659,611
import re def extra_normalize(text_orig: str): """ This function allows a simple normalization to the original text to make possible the aligning process. The replacement_patterns were obtained during experimentation with real text it is possible to add more or to get some errors without new rule...
d06ee939c8035cd7b83ed7f1577b383bfcaf203d
3,659,612
def list2str(lst: list) -> str: """ 将 list 内的元素转化为字符串,使得打印时能够按行输出并在前面加上序号(从1开始) e.g. In: lst = [a,b,c] str = list2str(lst) print(str) Out: 1. a 2. b 3. c """ i = 1 res_list = [] for x in lst: res_list.append(str(i)+'. '+str(x)) i += 1 res...
3da11748d650e234c082255b8d7dff5e56e65732
3,659,613
def _prompt_save(): # pragma: no cover """Show a prompt asking the user whether he wants to save or not. Output is 'save', 'cancel', or 'close' """ b = prompt( "Do you want to save your changes before quitting?", buttons=['save', 'cancel', 'close'], title='Save') return show_box(b...
859cbbe94ef35bf434b1c4f6cac9ec61a6311fb8
3,659,614
def plot_dataset_samples_1d( dataset, n_samples=10, title="Dataset", figsize=DFLT_FIGSIZE, ax=None, plot_config_kwargs={}, seed=123, ): """Plot `n_samples` samples of the a datset.""" np.random.seed(seed) with plot_config(plot_config_kwargs): if ax is None: f...
41b34e276a0236d46e13d7b0f24797e739384661
3,659,615
def list_versions(namespace, name, provider): """List version for mnodule. Args: namespace (str): namespace for the version name (str): Name of the module provider (str): Provider for the module Returns: response: JSON formatted respnse """ try: return make_...
dca0c24f391cce69a10fe7e61165647c9ce1cf66
3,659,616
import requests def script_cbor(self, script_hash: str, **kwargs): """ CBOR representation of a plutus script https://docs.blockfrost.io/#tag/Cardano-Scripts/paths/~1scripts~1{script_hash}~1cbor/get :param script_hash: Hash of the script. :type script_hash: str :param return_type: Optional. ...
fdb71d1e95d67da4a18552f4e42a28e27c7ab95a
3,659,617
def ithOfNPointsOnCircleY(i,n,r): """ return x coordinate of ith value of n points on circle of radius r points are numbered from 0 through n-1, spread counterclockwise around circle point 0 is at angle 0, as of on a unit circle, i.e. at point (0,r) """ # Hints: similar to ithOfNPointsOnCircle...
d4e697145423146b085f8423315c795745498afd
3,659,618
def get_tags(ec2id, ec2type, region): """ get tags return tags (json) """ mytags = [] ec2 = connect('ec2', region) if ec2type == 'volume': response = ec2.describe_volumes(VolumeIds=[ec2id]) if 'Tags' in response['Volumes'][0]: mytags = response['Volumes'][0]['Tags...
c150d83b6563f79140febb65a4ea7e50bc733286
3,659,619
def parse(data, raw=False, quiet=False): """ Main text parsing function Parameters: data: (string) text data to parse raw: (boolean) unprocessed output if True quiet: (boolean) suppress warning messages if True Returns: Dictionary. Raw or process...
dd7da8a23a0691dc2df75391c77fa1448362330a
3,659,620
import os def download_pretrained_model(model: str, target_path: str = None) -> str: """Downloads pretrained model to given target path, if target path is None, it will use model cache path. If model already exists in the given target path than it will do notting. Args: model (str): pretraine...
b9fcbec011136929e8240944f5f8c595f941d29e
3,659,621
def callNasaApi(date='empty'): """calls NASA APIS Args: date (str, optional): date for nasa APOD API. Defaults to 'empty'. Returns: Dict: custom API response """ print('calling nasa APOD API...') url = nasaInfo['nasa_apod_api_uri'] if date != 'empty': params = getA...
5eaa7fe9434c608df47828c8ce19d4e5e5cfe799
3,659,622
def train_reduced_model(x_values: np.ndarray, y_values: np.ndarray, n_components: int, seed: int, max_iter: int = 10000) -> sklearn.base.BaseEstimator: """ Train a reduced-quality model by putting a Gaussian random projection in front of the multinomial logistic regression stage of t...
ab2871875c751b5d7abb56991a55607e79c17e6e
3,659,623
def pv(array): """Return the PV value of the valid elements of an array. Parameters ---------- array : `numpy.ndarray` array of values Returns ------- `float` PV of the array """ non_nan = np.isfinite(array) return array[non_nan].max() - array[non_nan].min()
987ae80fa68cd1dee3e179975b283bb7f48dd2aa
3,659,624
def format_bad_frames(bad_frames): """Create an array of bad frame indices from string loaded from yml file.""" if bad_frames == "": bads = [] else: try: bads = [x.split("-") for x in bad_frames.split(",")] bads = [[int(x) for x in y] for y in bads] bads ...
433bcba8cc8bf7985a8103d595759d04099dce6a
3,659,625