sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
f3a268e0fb744f6bd2a2b4193f173ebf315ce907a0a7e62e30d4b2716920756e
Python
386
24
print('\n$1 Net_file (col1: ID; col2: ID)\n$2 Output_net_file \n') import sys fi=open(sys.argv[1]) fo=open(sys.argv[2],'w') SPLIT=':' OLD=set() for line in fi: seq=line.rstrip().split('\t') this_net=[seq[0],seq[1]] this_net.sort() this_tmp = SPLIT.join(this_net) if this_tmp not in OLD: ...
f7637ae8a2a4af271f08b5908dbbec39b1418dec3b655dcc39644ba8a3842128
Python
386
18
""" Regression fit over a strip plot ================================ _thumb: .53, .5 """ import seaborn as sns sns.set_theme() mpg = sns.load_dataset("mpg") sns.catplot( data=mpg, x="cylinders", y="acceleration", hue="weight", native_scale=True, zorder=1 ) sns.regplot( data=mpg, x="cylinders", y="acceler...
2df2d07456856d750efca69950d5cd440c8547cd1cb6333d410a055613e8d41d
Python
387
13
from .cosine import CosineDistance, LogitCosineDistance, NegativeScaledDotProduct from .euclidean import EuclideanDistance, EuclideanMean from .hyperbolic import HyperbolicDistance, HyperbolicMean __all__ = [ "CosineDistance", "EuclideanDistance", "EuclideanMean", "HyperbolicDistance", "HyperbolicM...
30a38d42915720aa93ae25cd61b651a1e9c3df6ff47ed41199807fefadbdb594
Python
387
13
import unittest from .common import skipif_no_net @skipif_no_net class TestWrite(unittest.TestCase): def test_load_huang(self): from neurondm import Config # FIXME placeholder for loading and roundtripping # neurons with other neurons as asserted equivalent # or disjoint classes ...
c74c926537beb07427fa1e769cc85a3277705f365cf2b1d9572afd5822e989e0
Python
387
17
""" Timeseries plot with error bands ================================ _thumb: .48, .45 """ import seaborn as sns sns.set_theme(style="darkgrid") # Load an example dataset with long-form data fmri = sns.load_dataset("fmri") # Plot the responses for different events and regions sns.lineplot(x="timepoint", y="signal",...
0f1938528d8d065e1269f91f3d3b06f5e2a70476de3f45ffb0410bc275d44c0e
Python
388
16
from __future__ import print_function import csv import sys file_name = sys.argv[1] fold_coverage = int(sys.argv[2]) with open(file_name, 'rd') as fd: fd_reader = csv.reader(fd) fd_columns = fd_reader.next() fd_value = fd_reader.next() fd_dict = dict(zip(fd_columns, fd_value)) mean_depth = fd_dic...
f39146982c30e74aa93434cf01b2af5e18b8028e339631de345efd03dcd67996
Python
389
9
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++...
f6a2a8d4b1eeead5e537a00eaa6d65e3f13bec72a2b6a33ebc079ab764549c3a
Python
389
12
"""Tabby time-series foundation model. The core package contains the pretrained backbone and preprocessing utilities. Prompt/post-training components live under :mod:`tabby.posttraining`, while benchmark entry points stay outside the importable package. """ from .models.PatchTSTFM import PatchTSTFM, PatchTSTFMConfig ...
9bd2b82ce8917101558158cd94a6b08bbd2906145216677b91939796b8fac598
Python
390
14
""" Linear regression with marginal distributions ============================================= _thumb: .65, .65 """ import seaborn as sns sns.set_theme(style="darkgrid") tips = sns.load_dataset("tips") g = sns.jointplot(x="total_bill", y="tip", data=tips, kind="reg", truncate=False, ...
b77f1cc72bb21d78525e1cacc9610e087f4a5880e33d0d3cd6851b8e4f2c8a3b
Python
390
18
""" Grouped boxplots ================ _thumb: .66, .45 """ import seaborn as sns sns.set_theme(style="ticks", palette="pastel") # Load the example tips dataset tips = sns.load_dataset("tips") # Draw a nested boxplot to show bills by day and time sns.boxplot(x="day", y="total_bill", hue="smoker", palette...
77a5f315eb36c760bd548b8b1ce964bb301c880a518922bc59442f26789b0738
Python
391
8
from futhark_ffi.build import build build_single_core = build("src/cajal/ugw/c/unbalanced_gw_c", "cajal/ugw/single_core") build_multicore = build( "src/cajal/ugw/multicore/unbalanced_gw_multicore", "cajal/ugw/multicore" ) build_opencl = build("src/cajal/ugw/opencl/unbalanced_gw_opencl", "cajal/ugw/opencl") build_c...
1c85b2773430ea0aa7dfff309dc8ca81ab005750eab06a2cc7d770387274e85d
Python
392
15
"""ResNet deep learning classifiers. This subpackage provides ResNet based classifiers implemented in TensorFlow and PyTorch backends. """ __all__ = [ "ResNetClassifier", "ResNetClassifierTorch", ] from sktime.classification.deep_learning.resnet._resnet_tf import ResNetClassifier from sktime.classification.d...
2b532c3b071798df4993b7ccbf503035a5d9d78f9628b81ffd224cb58be54f1d
Python
392
15
"""TapNet deep learning classifiers. This subpackage provides TapNet based classifiers implemented in TensorFlow and PyTorch backends. """ __all__ = [ "TapNetClassifier", "TapNetClassifierTorch", ] from sktime.classification.deep_learning.tapnet._tapnet_tf import TapNetClassifier from sktime.classification.d...
bd08c69e5a5593d0d9bf7414a3bc8b63e807d7f747eab03c2eb6536d1480ed98
Python
392
16
from abc import ABC, abstractmethod from typing import Dict, List class Proposer(ABC): """Base model for proposer""" @abstractmethod def build_model(self, config: Dict) -> None: pass @abstractmethod def propose(self, input_smiles: List[str], rxn_types: List[str], ...
f55a3ab6510d1ea6d2126a4f9b2f551bbf7178d4e27b9d62a3c150781c4cd81a
Python
392
15
"""MCDCNN deep learning classifiers. This subpackage provides MCDCNN based classifiers implemented in TensorFlow and PyTorch backends. """ __all__ = [ "MCDCNNClassifier", "MCDCNNClassifierTorch", ] from sktime.classification.deep_learning.mcdcnn._mcdcnn_tf import MCDCNNClassifier from sktime.classification.d...
25a5c5913fc4b13a4874015f1a26e8f68cadb620ff662327b92963cfece42f7b
Python
395
15
""" Facetting histograms by subsets of data ======================================= _thumb: .42, .57 """ import numpy as np import seaborn as sns import matplotlib.pyplot as plt sns.set(style="darkgrid") tips = sns.load_dataset("tips") g = sns.FacetGrid(tips, row="sex", col="time", margin_titles=True) bins = np.linsp...
3ce7f85e4a77364e893def5da12e94c3342b7d16d42e74482141bafb08e86201
Python
398
15
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations from onnx.reference.ops.aionnxml._op_run_aionnxml import OpRunAiOnnxMl def compute_binarizer(x, threshold=None): return ((x > threshold).astype(x.dtype),) class Binarizer(OpRunAiOnnxMl): def ...
9efb18228e8eb08d481a00ee07ce92f24f5c42850c32a7d817c8f4ef42a8722e
Python
398
13
"""Exception types raised by corset-tools.""" class CorsetToolsError(Exception): """Base class for all errors raised by corset-tools.""" class DuplicateTranscriptError(CorsetToolsError): """Raised when the same transcript name occurs in more than one input set.""" class InputFormatError(CorsetToolsError):...
a535097a6f65ae1f2118e69880b4348774284373e1c8846ce6fc6257a266ba8b
Python
398
11
from __future__ import print_function def getTimeDiffInSeconds(time1, time2): # print('time1 = ' + str(time1)) # print('time2 = ' + str(time2)) e1 = time1.split(':') e2 = time2.split(':') s1 = (((float(e1[0]) * 60) + float(e1[1])) * 60) + float(e1[2]) s2 = (((float(e2[0]) * 60) + float(e2[1])) ...
12b8cb592b536194b7ce7be5f84ae876d5859e93912920b05887854f7cfb0e13
Python
399
9
"""Module containing adapters other framework packages covering multiple tasks.""" # copyright: sktime developers, BSD-3-Clause License (see LICENSE file) __all__ = ["_PytorchDeepAdapter", "_PytsAdapter", "_TslearnAdapter"] from sktime.base.adapters._pytorch import _PytorchDeepAdapter from sktime.base.adapters._pyts...
56fcdea458a51b3fec4cee63ab8d3bc6cbeb6af72e47f9564f2c2aebc1cf13b9
Python
402
15
# Copyright 2019-2026 The AmpliGraph Authors. All Rights Reserved. # # This file is Licensed under the Apache License, Version 2.0. # A copy of the Licence is available in LICENCE, or at: # # http://www.apache.org/licenses/LICENSE-2.0 # """Support for loading and managing pretrained models.""" from .pretrained_util...
5a7b0c2befe56c6e3e5ea52b1e97419b1fa9fa8f1ed19c783fc1f14652335de6
Python
402
13
from pathlib import Path def posix_path(*args: str) -> str: return Path().joinpath(*args).as_posix() TOP_DIR = Path(__file__).parent.parent.parent.resolve() SOURCE_DIR = posix_path(TOP_DIR.as_posix(), "Historia") RESOURCES_DIR = posix_path(SOURCE_DIR, "resources") RESOURCES_HEADERS_DIR = posix_path(RESOURCES_D...
5dd2da71231319f4a6457b8ed9091b19bf8983f8bee07ddbcc1d6b72aa5ff140
Python
404
12
# copyright: sktime developers, BSD-3-Clause License (see LICENSE file) """Implements base classes for forecasting in sktime.""" __all__ = [ "ForecastingHorizon", "BaseForecaster", "BaseProbaForecaster", ] from sktime.forecasting.base._base import BaseForecaster from sktime.forecasting.base._base_proba im...
be552ddc4e2e6e0312fdda6e00efd583b383039e468058732f783484103e11c4
Python
405
23
import sys fi=open(sys.argv[1]) fo=open(sys.argv[2],'w') V={} for line in fi: seq=line.rstrip().split('\t') #print(seq) this_tag=seq[0]+'\t'+seq[1]+'\t'+seq[2] if this_tag not in V: V[this_tag]=[[float(seq[-1]),line]] else: V[this_tag].append([float(seq[-1]),line]) fi.close() for o...
d4011e190a19aa1152716aa1652845e7d79b4cb70fe04912565b25da2160d3cd
Python
405
7
#Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. #This program is free software; #you can redistribute it and/or modify #it under the terms of the MIT License. #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHA...
0f831de0db0b97c331caa5ed5439d4ab8eba71ae4d4e2cff14f34f1a88a09a5a
Python
407
10
# Copyright (c) OpenMMLab. All rights reserved. from .inference import inference_model, init_model, show_result_pyplot from .test import multi_gpu_test, single_gpu_test from .train import init_random_seed, set_random_seed, train_model __all__ = [ 'set_random_seed', 'train_model', 'init_model', 'inference_model', ...
7ded3bfa3aad5d66e16a2dcc301ad12238c1234df0d90507531feee286107302
Python
407
11
# pytest module discovery somehow adds the nested compiled module # and models module to sys.modules which breaks tests, so we run # this file as the first test after test collection # I'm sure there is a non-hacked sanctioned way to actually do this # but for now let's not worry about that import sys def test_fix_sy...
7f2823d06e235d3cbdab07424c696e67f7a905e9534e80bb11b20fe0bdd4627d
Python
409
16
import numpy as np def to_tensor(data): """Ensure that data is a numpy 4D array.""" assert isinstance(data, np.ndarray) if data.ndim == 2: data = data[np.newaxis,np.newaxis,...] elif data.ndim == 3: data = data[np.newaxis,...] elif data.ndim == 4: pass else: rai...
15027e1d6f5dba7cb694d7bdfac5e3fe4d2c13586296b93fc10905d41045696d
Python
412
16
# Copyright 2007 Zachary Pincus # This file is part of CellTool. # # CellTool is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License as # published by the Free Software Foundation. ''' celltool libraries for performing statistical analysis on shape...
95c72ea60e15ad77d249b6d9c885b9dcdf8dea4a18caa0a19ec4781ed6a95183
Python
413
17
"""LSTM-FCN deep learning classifiers. This subpackage provides LSTM-FCN based classifiers implemented in TensorFlow and PyTorch backends. """ __all__ = [ "LSTMFCNClassifier", "LSTMFCNClassifierTorch", ] from sktime.classification.deep_learning.lstmfcn._lstmfcn_tf import ( LSTMFCNClassifier, ) from sktim...
d647ad52322b9eda2e4bfd34bac063f09cb5728ccb0dcf55607c20874c3ca4ba
Python
413
15
import sys def rename_contigs(): for l in sys.stdin: if l.find('.fasta.gz')>0: continue if l.startswith('>'): if l != l.split('|')[0]: raise Exception("Input FASTA header contains invalid character '|'") l = l.strip().split('|')[0] if len(...
470d239ff07fa993cf87cc3b1219b652f71ca1fa421f0bf48ea27d6139f23bd0
Python
416
17
import unittest from types import SimpleNamespace from typing import cast from elftools.dwarf.datatype_cpp import describe_cpp_datatype from elftools.dwarf.die import DIE class TestDatatypeCpp(unittest.TestCase): def test_missing_type(self): die = cast(DIE, SimpleNamespace(attributes={})) self.a...
a0902d9a0048e6130d3f203aae7f27f4c9f2bd82b480c4f81793a54b9c257d12
Python
416
16
"""Compositions for clusterers.""" # copyright: sktime developers, BSD-3-Clause License (see LICENSE file) __author__ = ["fkiraly"] __all__ = [ "ClustererAsTransformer", "ClustererPipeline", "SklearnClustererPipeline", ] from sktime.clustering.compose._as_transform import ClustererAsTransformer from skti...
394b5a9a55cc365c0f22c8b46d641cd4a5efde0711e36333ec1c35a67d3e2dd3
Python
417
23
import sys fi=open(sys.argv[1]) fo=open(sys.argv[2],'w') V={} for line in fi: seq=line.rstrip().split('\t') #print(seq) this_tag=seq[0]+'\t'+seq[1]+'\t'+seq[2] if this_tag not in V: V[this_tag]=[[float(seq[-2]),line]] else: V[this_tag].append([float(seq[-2]),line]) fi.close() for o...
ff595c3c713a5524d4ba2abb38c6eea4c5a944a6d4e9c75e031c1b86cd03ec12
Python
417
12
"""MLP (Multi-Layer Perceptron) Classifier for Time Series Classification. This subpackage provides Multi-Layer Perceptron (MLP) based time series classifier in TensorFlow and PyTorch backends. """ __all__ = [ "MLPClassifier", "MLPClassifierTorch", ] from sktime.classification.deep_learning.mlp._mlp_tf import...
121923e369fdd71ca379ad5618ce073da99d032b539951349ace62d94e39a77b
Python
419
14
import scanpy as sc import numpy as np import pandas as pd import scrublet as scr import pickle adata = sc.read("../combined_all_organoids_v2.h5ad") scrub = scr.Scrublet(adata.raw.X) doublet_scores, predicted_doublets = scrub.scrub_doublets() combined = {"doublet_scores": doublet_scores, "predicted_doubl...
5557586462b4ea8688ab6815874b85d39dcfa71057a9a88c394a562cee402b9c
Python
419
11
import tensorflow as tf with tf.device('/device:GPU:0'): a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a') b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b') c = tf.matmul(a, b) tf.compat.v1.disable_eager_execution() with tf.compat.v1.Session(config=tf.compat.v1....
cdf7fa43ef1714cadebfdf2cd8ebd9f50618095886df712530fcf8ac4cb43d67
Python
419
16
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.ops._op import OpRunUnary class Flatten(OpRunUnary): def _run(self, x, axis=None): i = axis or self.axis shape = x.shape new_shape = ...
d10ea9c9b031d0601fd864a796308da1397688547f7d2ab770beb725a4cfe9c4
Python
420
19
import os import pathlib import logging _logger = logging.getLogger(__name__) def create_dir(dir_path): """ Create directory if it does not exist """ try: if not os.path.exists(dir_path): pathlib.Path(dir_path).mkdir(parents=True, exist_ok=True) return 0 except Except...
da4671cbe30298aa2f3c638a5c69cb998edb880e7088000091f0cb3a87ececec
Python
421
19
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.op_run import OpRun def _global_max_pool(x: np.ndarray) -> np.ndarray: axis = tuple(range(2, np.ndim(x))) return x.max(axis=axis, keepdims=True) class ...
5c09802924b288772c7b4ab74cf77d76b52e98bbe21d1f46c8f00b1cfce8fdd4
Python
422
18
""" Anscombe's quartet ================== _thumb: .4, .4 """ import seaborn as sns sns.set_theme(style="ticks") # Load the example dataset for Anscombe's quartet df = sns.load_dataset("anscombe") # Show the results of a linear regression within each dataset sns.lmplot( data=df, x="x", y="y", col="dataset", hue="...
bfd62d7cf8ab630043d5bc56f4619d0337b398e956a2d09e7e92f093261cf8f6
Python
422
17
""" Grouped barplots ================ _thumb: .45, .5 """ import seaborn as sns sns.set(style="whitegrid") # Load the example Titanic dataset titanic = sns.load_dataset("titanic") # Draw a nested barplot to show survival for class and sex g = sns.catplot(x="class", y="survived", hue="sex", data=titanic, ...
9abb476c7b062dfd0eafa8c24cfa7f8156ab3b704e9b3be253d036fc5605dd67
Python
423
8
"""Kernel based time series classifiers.""" __all__ = ["RocketClassifier", "Arsenal", "TimeSeriesSVC", "TimeSeriesSVCTslearn"] from sktime.classification.kernel_based._arsenal import Arsenal from sktime.classification.kernel_based._rocket_classifier import RocketClassifier from sktime.classification.kernel_based._svc...
9e79f9968a8147092e7cc4ff4c3f1161ae059ef73f23f1d27bc0994f1eea6d32
Python
423
14
import numpy as np from scipy.signal import butter, lfilter, freqz import matplotlib.pyplot as plt def butter_lowpass(cutoff, fs, order=5): nyq = 0.5 * fs normal_cutoff = cutoff / nyq b, a = butter(order, normal_cutoff, btype='low', analog=False) return b, a def butter_lowpass_filter(data, cutoff, fs,...
f700157e654ab7a9c49329dbc3f60fd41fbcb35c2e72e6e20fd46b6b1020cc0e
Python
423
15
# -*- coding: utf-8 -*- # # Copyright © 2018 Charles E. Vejnar # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at https://www.mozilla.org/MPL/2.0/. # import os __all__ = [f[:-3] for f in os.listdi...
4b1753e24c0200338df1cc4e0557d2a24de33aea48a2ab0b9ea5cfbfc526368c
Python
424
16
""" Anscombe's quartet ================== _thumb: .4, .4 """ import seaborn as sns sns.set(style="ticks") # Load the example dataset for Anscombe's quartet df = sns.load_dataset("anscombe") # Show the results of a linear regression within each dataset sns.lmplot(x="x", y="y", col="dataset", hue="dataset", data=df, ...
6f9f9dd32e9457c9c34852e9a665dd77946c45ad247815f714cb88b1ed2b174e
Python
425
15
#!/usr/bin/env python from distutils.core import setup setup(name='basilisk', version='0.1', description='A generative, probabilistic model of side chains in proteins.', author='Tim Harder and Jes Frellsen', author_email='mail@tim-harder.de', url='http://www.binf.ku.dk/', license='...
ff152fa24f7e0c25fb5e859c91eaff694176d207fd5813999f00cb31c2984a1b
Python
425
13
"""Early classification time series classifiers.""" __all__ = [ "BaseEarlyClassifier", "ProbabilityThresholdEarlyClassifier", "TEASER", ] from sktime.classification.early_classification._probability_threshold import ( ProbabilityThresholdEarlyClassifier, ) from sktime.classification.early_classificati...
f4213fb39bc58dbd6225b36c6d18899f854a2ac13cf0df4a0f1500159fd5cc5f
Python
426
11
import os from pathlib import Path from tempfile import gettempdir import pytest temp_path = Path(gettempdir(), f'.pyontutils-testing-base-{os.getpid()}') temp_path_ap = temp_path.as_posix() SKIP_NETWORK = ('SKIP_NETWORK' in os.environ or 'FEATURES' in os.environ and 'network-sandbox' in os.environ['F...
7b1f129be7ebfdd7c40d9aa862e086e55eaaa31c1a536dbba4e52c2c76195f35
Python
427
13
# !/usr/bin/env python3 -u # copyright: sktime developers, BSD-3-Clause License (see LICENSE file) """Import all time series forecasting functionality available in sktime.""" from sktime.registry import all_estimators est_tuples = all_estimators(estimator_types="forecaster", return_names=True) est_names, ests = zip(*...
90a07ab371f1b81c54337abc1dd33a800beacf15a2ae9aed68ad9fdbb092c5ca
Python
427
15
import logging import sys def get_logger(name): logger = logging.getLogger(name) logger.setLevel(logging.INFO) if not logger.handlers: handler = logging.StreamHandler(sys.stdout) formatter = logging.Formatter( '%(asctime)s %(levelname)s %(process)d: %(message)s') handle...
97e18fcb47e5d47f03f09e79eba6ab0bae67239379b89b5b14c61972bff2c75f
Python
427
15
# author: proloy Das <proloy@umd.edu> class LazyProperty: "http://blog.pythonisito.com/2008/08/lazy-descriptors.html" def __init__(self, func): self._func = func self.__name__ = func.__name__ self.__doc__ = func.__doc__ def __get__(self, obj, klass=None): if obj is None: ...
532b7afd99f0fe3d6345a173622cde05587235a771213f4a07b9640274ec1219
Python
428
5
# data folders (raw clinical notes and SemEHR-processed notes) MIMIC_3_DIR = './data' # the current folder under 'data' SemEHR_DIR = './data/mimic-semehr-smp-outputs/outputs' # for MIMIC-III discharge summaries SemEHR_DIR_rad = './data/mimic-rad-semehr-outputs/outputs' # for MIMIC-III radiology reports #SemEHR_DIR_tays...
6b0b0786cc8edb2f01e8ecb419703cd41cd0fb3b718b94c3b570752e39efa4c3
Python
428
12
"""Version information.""" import importlib.metadata try: # Get version from pyproject.toml via package metadata __version__ = importlib.metadata.version("palantir") except importlib.metadata.PackageNotFoundError: # Package is not installed, fall back to hardcoded version __version__ = "1.4.5" # Shoul...
48be10350828ce416d072314272f71313a92a657346aa699179e7e1d03009280
Python
429
12
import warnings def simple_stats(image, method='mean', axis=3): """Deprecated. Use ``bcblib.imaging.stats.reduce_axis`` instead.""" warnings.warn( "bcblib.tools.nii_stats.simple_stats is deprecated. " "Use bcblib.imaging.stats.reduce_axis instead.", DeprecationWarning, stacklevel=2, ...
540211554e81e24f5598f448964bfe4275dfc0a34a0a6e361ec5e55830c03822
Python
430
22
import json import logging logging.basicConfig(level=logging.INFO, format='') class Logger: """ Training process logger Note: Used by BaseTrainer to save training history. """ def __init__(self): self.entries = {} def add_entry(self, entry): self.entries[len(self.en...
99f9abcc9a09de3c993896729ade4e5a4294d9d417519a682c0e608db93dfb9c
Python
430
16
""" Annotated heatmaps ================== """ import matplotlib.pyplot as plt import seaborn as sns sns.set() # Load the example flights dataset and conver to long-form flights_long = sns.load_dataset("flights") flights = flights_long.pivot("month", "year", "passengers") # Draw a heatmap with the numeric values in e...
c64deb4b39fdd89c3a073b5b9a9eedd109c3a3bfbc0f37228ec77b8b164e0927
Python
430
19
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.op_run import OpRun class Shrink(OpRun): def _run(self, x, bias=None, lambd=None): return ( np.where( x < -lambd, ...
19b43afdcdd3ca92b14b05041aa95f230c05930c9a86e5a5ed80da26529f7ca7
Python
431
20
""" Grouped barplots ================ _thumb: .36, .5 """ import seaborn as sns sns.set_theme(style="whitegrid") penguins = sns.load_dataset("penguins") # Draw a nested barplot by species and sex g = sns.catplot( data=penguins, kind="bar", x="species", y="body_mass_g", hue="sex", errorbar="sd", palette="...
831f8e5c6ebde5782c623f430ab4ee122941207a514efc2438f96fca41abc9cf
Python
431
20
import numpy as np from dnnbrain.brain.algo import convolve_hrf def test_convolve_hrf(): # prepare X = np.random.randn(10, 2) onsets = np.arange(10) durations = np.ones(10) n_vol = 5 tr = 2 # do convolution X_hrfed = convolve_hrf(X, onsets, durations, n_vol, tr) # assert as...
04de939b60465aab20640c40d4708fac39adfffd60476f6a5870973a18b99aa3
Python
432
17
from src.cajal.sample_seg import cell_boundaries, compute_icdm_all import tifffile import os def test(): cell_boundaries( tifffile.imread("CAJAL/data/tiff_images_cleaned/epd210cmdil3_5.tif"), 30, 0, True, False, ) compute_icdm_all( "CAJAL/data/...
7a6a3838771dc19180c0ddbe0f65103dfde58c8be2819aa46ff8bbf6e1e4e7dd
Python
432
12
# ---------------------------------------------------------------------------- # Copyright (c) 2017-2026, QIIME 2 development team. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file LICENSE, distributed with this software. # ------------------------------------------------...
9dc03c4e85e7620bacc3751daf14a0ef2a1ff013ef07a250851dbadf5bda349b
Python
432
16
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.ops._op import OpRunUnaryNum class HardSigmoid(OpRunUnaryNum): def _run(self, x, alpha=None, beta=None): alpha = alpha or self.alpha beta = b...
8aeea4b92fa50d8c1806cf38db165e67342d8c13e3ad93b7dd6f126baa6319df
Python
433
23
import sys fi=open(sys.argv[1]) fo=open(sys.argv[2],'w') V={} for line in fi: seq=line.rstrip().split('\t') #print(seq) this_tag='\t'.join(seq[:9]) if this_tag not in V: V[this_tag]=[[float(seq[-1]),seq[-2]]] else: V[this_tag].append([float(seq[-1]),seq[-2]]) fi.close() for one in ...
1a2b85716df5ebd2494c918c061c37f8d0a3d4f5a7d0d295cb2746a8eb4d1326
Python
435
14
import seaborn.objects from seaborn._core.plot import Plot from seaborn._core.moves import Move from seaborn._core.scales import Scale from seaborn._marks.base import Mark from seaborn._stats.base import Stat def test_objects_namespace(): for name in dir(seaborn.objects): if not name.startswith("__"): ...
1819b5ff895b41710ecd026318edb8334278d0c390dbc118a171c765e9d19299
Python
436
12
# ---------------------------------------------------------------------------- # Copyright (c) 2017-2026, QIIME 2 development team. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file LICENSE, distributed with this software. # ------------------------------------------------...
26714e9b4d37ad0b106bf8588968af31dd895ff941328344937db042fe15883d
Python
437
14
from torch import nn rnn_layers = {"lstm": (nn.LSTM, 2), "gru": (nn.GRU, 1)} def create_recurrent_layer(layer_type, initial_size, hidden_size, nlayers, dropout=0, **kwargs): layer_type = layer_type.lower() assert layer_type in rnn_layers module, hidden_count = rnn_layers[layer_type] if nlayers == 1:...
f1da4e641474e6631a091deb09007c7b1f54a5844200d05cb5c71320cd376585
Python
437
18
""" Single start point for system metrics and process metrics script """ import logging import sys from ts.metrics import system_metrics from ts.metrics.process_memory_metric import check_process_mem_usage if __name__ == '__main__': logging.basicConfig(stream=sys.stdout, format="%(message)s", level=logging.INF...
675f823d4dec390eec579c3daa6c7d4cfd213100d74ff14a0da897310a7b4f7f
Python
438
23
""" Module to define Unit mappings """ class Units(object): """ Define a unit of elements """ def __init__(self): self.units = { 'ms': "Milliseconds", 's': 'Seconds', 'percent': 'Percent', 'count': 'Count', 'MB': 'Megabytes', ...
a6e0f84ddbf8950540989cfcc235656e6d28c73c19b4b0a6be9079d9bc516ff4
Python
438
18
from .palette import method_palette, subgraph_palette, dashes from .scatter import matched_stripplot from .theme import set_theme from .utils import ( bound_texts, draw_colors, get_text_points, get_text_width, get_texts_points, make_sequential_colormap, merge_axes, multicolor_text, n...
28d1ebb69fb7d7de8a216fdc909e8429f13566b9e1cd203ce6af809744cd017d
Python
439
18
# copyright: sktime developers, BSD-3-Clause License (see LICENSE file) """Anomaly scores for interval evaluation.""" from sktime.detection._anomaly_scores._from_cost import ( LocalAnomalyScore, Saving, to_local_anomaly_score, to_saving, ) from sktime.detection._anomaly_scores._l2_saving import L2Savin...
d2df69ff31b9850e3718bd822c50aa9d4745360d49b6bc59ec91484a81e1982d
Python
440
15
from flair.data import Dictionary from flair.training_utils import convert_labels_to_one_hot def test_convert_labels_to_one_hot(): label_dict = Dictionary(add_unk=False) label_dict.add_item("class-1") label_dict.add_item("class-2") label_dict.add_item("class-3") one_hot = convert_labels_to_one_ho...
106a88dec2d5a20b46f3d25e93a42dd9d2bf086892fcfbee53398c5fdbbbbd1a
Python
442
13
from ray.rllib.agents.ppo.ppo_policy import PPOTFPolicy, KLCoeffMixin, ValueNetworkMixin, LearningRateSchedule, EntropyCoeffSchedule from mprl.rl.common.weights_utils_policy_mixin import WeightsUtilsPolicyMixin PPOStrategoModelTFPolicy = PPOTFPolicy.with_updates( name="PPOStrategoModelTFPolicy", mixins=[ ...
ecc037e21cb7cc5bddcccb588d6f55f292d08bac4244db3568d1b9e42bc5bae2
Python
444
15
from torch import nn class FCNHead(nn.Sequential): def __init__(self, in_channels, channels): inter_channels = in_channels // 4 layers = [ nn.Conv2d(in_channels, inter_channels, 3, padding=1, bias=False), nn.BatchNorm2d(inter_channels), nn.ReLU(), nn...
0277780953a5db6b0d84a9de062cd1045df13eec90a3079c75735f9cd291eacc
Python
445
17
""" Scatterplot with varying point sizes and hues ============================================== _thumb: .45, .5 """ import seaborn as sns sns.set(style="white") # Load the example mpg dataset mpg = sns.load_dataset("mpg") # Plot miles per gallon against horsepower with other semantics sns.relplot(x="horsepower", y...
371163ed78f000bdf25c4f9f2fbd18b58290d65af36234131933ceca3fb4e3d0
Python
445
18
# SPDX-License-Identifier: LGPL-3.0-or-later from deepmd.dpmodel.fitting.unimol_pretrain import ( UniMolPretrainFitting as UniMolPretrainFittingDP, ) from deepmd.pt_expt.common import ( torch_module, ) from .base_fitting import ( BaseFitting, ) @BaseFitting.register("unimol_pretrain") @torch_module clas...
c590e9bea214c1c4f8e605d83b761ebfb58fa979dcf2e4428b7f0cf6bed3d2da
Python
445
23
import sys fi=open(sys.argv[1]) fo=open(sys.argv[2],'w') V={} for line in fi: seq=line.rstrip().split('\t') #print(seq) this_tag=seq[0]+'\t'+seq[1]+'\t'+seq[2] if this_tag not in V: V[this_tag]=[[float(seq[-1]),seq[-2]]] else: V[this_tag].append([float(seq[-1]),seq[-2]]) fi.close() ...
37619e5fc5961b6e3214dab6dd26d51cc13b9a63f78b00b0e60fc183148aeed6
Python
448
10
# !/usr/bin/env python3 -u # copyright: sktime developers, BSD-3-Clause License (see LICENSE file) """Implements wrappers for estimators from hmmlearn.""" __all__ = ["BaseHMMLearn", "GaussianHMM", "GMMHMM", "PoissonHMM"] from sktime.detection.hmm_learn.base import BaseHMMLearn from sktime.detection.hmm_learn.gaussian...
794d0b29f9696cb449b685a39608a179ce7f1d7e61d56c735361164851e9d48b
Python
448
19
from extended_ring_model import * from dict_key_definitions import rmkeys import numpy as np import matplotlib.pyplot as plt if __name__ == "__main__": w1 = 0.8 w2 = 0.2 rm = RingModel({rmkeys.n_r:8, rmkeys.verbose:True, rmkeys.d_w1:w1, rmkeys.d_w...
0ade5e9bb3c4f40760867fae782e6d151c53b9d8209f7468b027d5ad11a13090
Python
449
16
# # # Node properties: size # # Netplotbrain allows for specifying different figure properties by only specifyign the column name. # # Below we demonstrate how node_size can change based on different columns in the nodes dataframe. # # The key lines of code here are when: # # `node_size='centrality_measure1'` # # and...
17dad8980e49d8c55d9eb2a507aed1e0ebb379fe43687fd082227e2789ad8d35
Python
451
15
# import all gumpy submodules that should be loaded automatically import gumpy.classification import gumpy.data import gumpy.plot import gumpy.signal import gumpy.utils import gumpy.features import gumpy.split # fetch into gumpy-scope so that users don't have to specify the entire # namespace from gumpy.cla...
8af8f1e1781c09bf006c786b0dee52e984bb064845c25ac06271a484d4b4f50a
Python
451
17
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.op_run import OpRun class NonZero(OpRun): def _run(self, x): if x.ndim == 0: return (np.empty((0, np.count_nonzero(x)), dtype=np.int64),)...
908d8f2a2935dc77a911298c81a00e4bd40a3d20016565a0b87b785ae1f61f45
Python
451
17
""" Scatterplot with varying point sizes and hues ============================================== _thumb: .45, .5 """ import seaborn as sns sns.set_theme(style="white") # Load the example mpg dataset mpg = sns.load_dataset("mpg") # Plot miles per gallon against horsepower with other semantics sns.relplot(x="horsepow...
995615b590128bdc5bb669aa8c597c3a174aef1fed87dae037f9670aae1a60e5
Python
452
20
""" Conditional kernel density estimate =================================== _thumb: .4, .5 """ import seaborn as sns sns.set_theme(style="whitegrid") # Load the diamonds dataset diamonds = sns.load_dataset("diamonds") # Plot the distribution of clarity ratings, conditional on carat sns.displot( data=diamonds, ...
69adac7441c06918410c0d052445ede00d194abf795066cb37836f45a6233ee3
Python
453
18
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.op_run import OpRun def common_reference_implementation(data: np.ndarray, shape: np.ndarray) -> np.ndarray: ones = np.ones(shape, dtype=data.dtype) retur...
9da224c6a85544af6e1b59dbfcf69053bda7a5c8dc865e2f9b79c5a46ad4aba0
Python
457
13
# ---------------------------------------------------------------------------- # Copyright (c) 2017-2026, QIIME 2 development team. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file LICENSE, distributed with this software. # ------------------------------------------------...
720575eaf8ec9df1e3116209eeee860e22b023879251a198bb7df4fa007d9ac3
Python
458
19
""" Scatterplot with continuous hues and sizes ========================================== _thumb: .45, .45 """ import seaborn as sns sns.set() # Load the example iris dataset planets = sns.load_dataset("planets") cmap = sns.cubehelix_palette(rot=-.2, as_cmap=True) ax = sns.scatterplot(x="distance", y="orbital_peri...
c2d3f850a9b1c1338e3528596c1da3f914b03c853da2d242b874e02b5567ce47
Python
458
14
import sciunit class ProducesSpikeTrains(sciunit.Capability): """ Spike trains are to be represented as a list of neo.SpikeTrain objects. """ def produce_spiketrains(self, **kwargs): return [st for st_list in self.produce_grouped_spiketrains(**kwargs) for st in st_list]...
659126643820f572381225c529a8e153b80987cc34b4a2e1f9cd03a50c98f523
Python
459
22
import random import numpy as np import tensorflow as tf def is_cuda_available(): return tf.test.is_gpu_available(cuda_only=True) def set_seed(seed): """ Referred from: - https://stackoverflow.com/questions/38469632/tensorflow-non-repeatable-results """ # Reproducibility random.seed(seed...
8f66b23ec5a5d7db371fae099ea47d291c7b8d8b03431745084580cb778da3a9
Python
459
17
from __future__ import print_function import sys from itertools import cycle input_file = sys.argv[1] number_of_split = int(sys.argv[2]) records = open(input_file).read().strip().split('\n') output_name = input_file.replace('.bed', '').replace('.txt', '') output_number = cycle(range(1, number_of_split+1)) for reco...
b734ee5085f41c7f5805922bc256d273e842e9cad9a1daba24f985cc9e043c0b
Python
459
17
from vp_suite.base import VPModel class CopyLastFrame(VPModel): r""" A simple, non-trainable baseline model that simply returns the latest frame as the next predicted frame. """ NAME = "CopyLastFrame" REQUIRED_ARGS = [] TRAINABLE = False def __init__(self, device=None, **model_kwargs)...
727b20b96b73c408f190541fbc838689dc632bad51e7fe881ff877764067353e
Python
460
16
""" Grouped violinplots with split violins ====================================== _thumb: .44, .47 """ import seaborn as sns sns.set_theme(style="dark") # Load the example tips dataset tips = sns.load_dataset("tips") # Draw a nested violinplot and split the violins for easier comparison sns.violinplot(data=tips, x="...
c01317541c9515f58ee9485bf5b955b3c3ef4c46ccfade02e625ba456aedef78
Python
464
13
"""Compositions for classifiers.""" # copyright: sktime developers, BSD-3-Clause License (see LICENSE file) __all__ = [ "BaggingClassifier", "ComposableTimeSeriesForestClassifier", "WeightedEnsembleClassifier", ] from sktime.classification.ensemble._bagging import BaggingClassifier from sktime.classifica...
12b068fc9ff3dc3ef1dba8d55366afbc9786730c284f24a20dfd41f03002e7e9
Python
465
19
""" Lineplot from a wide-form dataset ================================= _thumb: .52, .5 """ import numpy as np import pandas as pd import seaborn as sns sns.set(style="whitegrid") rs = np.random.RandomState(365) values = rs.randn(365, 4).cumsum(axis=0) dates = pd.date_range("1 1 2016", periods=365, freq="D") data = ...
d1741ca170731af73575f9fa4ea4fe5cc46c3b6ae6b6abef96c5bfd8760a7d8f
Python
465
18
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.ops.op_softmax import Softmax class LogSoftmax(Softmax): def _run(self, X): if X.size == 0: return (X,) tmp = X - X.max(axis=self...
c03f77578d6d58dd416fa555524301bc5b1ff0b5b368c695fd0a05a0c92a5c2f
Python
466
19
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations from math import erf import numpy as np from onnx.reference.ops._op import OpRunUnaryNum class Erf(OpRunUnaryNum): def __init__(self, onnx_node, run_params): OpRunUnaryNum.__init__(self, ...
1386aace726cfe117e2c934c08a6c1c04ae2d6167374d83a62e964ff2daf599c
Python
467
17
""" Plotting a three-way ANOVA ========================== _thumb: .42, .5 """ import seaborn as sns sns.set(style="whitegrid") # Load the example exercise dataset df = sns.load_dataset("exercise") # Draw a pointplot to show pulse as a function of three categorical factors g = sns.catplot(x="time", y="pulse", hue="ki...
6cba9e432a6515ccc09c9c240ddb0b3a3413d559bc476b34a395e4f7fe4e5415
Python
468
13
from __future__ import print_function import numpy as np from featureExtractor import FeatureExtractor class FeatureExtractorRealFourier(FeatureExtractor): def __init__(self, params): self.params = params self.extractorType = 'realFourier' def getFeatures(self, eegSegment, timeStampSe...
cbcaa9410f282f2fc78109509096c039593980dcd137e9597f5cd850a8ab6efb
Python
469
20
"""Test functions for loose loaders.""" __author__ = ["fkiraly"] __all__ = [] import pytest from skbase.utils.dependencies import _check_soft_dependencies @pytest.mark.skipif( not _check_soft_dependencies("statsmodels", severity="none"), reason="skip test if required soft dependency not available", ) def ...
28a34b9e85f6598003dc5544ad54e630886af61deb9c2eddf1eec27f49be2b6a
Python
470
14
from __future__ import print_function import numpy as np from scipy import signal from featureExtractor import FeatureExtractor class FeatureExtractorComplexFourier(FeatureExtractor): def __init__(self, params): self.params = params self.extractorType = 'wavelet' def getFeatures(self, eegSegm...