sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
36d078557a171bcfd2e69dbdef3bc1a02573f0a965de24b07b25abc918daf86c
Python
701
22
import os from setuptools import setup from torch.utils.cpp_extension import CppExtension, CUDAExtension, BuildExtension #ENV = os.environ["CONDA_PREFIX"] # Absolute path of active conda env root #LIBRARY_DIRS = [os.path.join(ENV, "lib")] # .[so,dylib] #INCLUDE_DIRS = [os.path.join(ENV, "include")] #LIBRARIES = ["ma...
68c21841395d961df86f9a10800a0cee1beff25220a9891f7907d1b7584479df
Python
701
35
from __future__ import annotations import pytest from textstat.backend import utils @pytest.mark.parametrize( "grade, expected", [ (1, "st"), (2, "nd"), (3, "rd"), (4, "th"), (5, "th"), (6, "th"), (7, "th"), (8, "th"), (9, "th"), ...
c7e8f470f2e08d7873714f3cc7da7d279c102998daa477ab414ba8aa10853785
Python
701
19
from yass.explore import RecordingExplorer def test_returns_empty_if_cannot_get_complete_wf(path_to_standardized_data): e = RecordingExplorer(path_to_standardized_data, spike_size=15, dtype='float32', n_channels=10, data_order='channels', loader='array') as...
dfe5771088d4d7ea4cebd7b79d9ed8c6d012c5cf6e41212c06d0bcac6b0216a7
Python
701
26
# License: GNU Affero General Public License v3 or later # A copy of GNU AGPL v3 should have been included in this software package in LICENSE.txt. """ A more accessible and defined set of data structures for interacting with a sequence and its annotations. Can convert to and from Biopython, but that use is i...
3584fe9804f53bb03f4d26e971187e5fca0e370aab320755fea2c4083e4416eb
Python
702
22
from importlib import resources from enum import Enum class DefaultDataFile(Enum): atac_ref_motifs = "ATAC.ref.motifs.txt" dnase_ref_motifs = "DNASE.ref.motifs.txt" motif_to_pwm_atac = "motif_to_pwm.ATAC.tsv" motif_to_pwm_dnase = "motif_to_pwm.DNASE.tsv" motif_to_pwm_tf = "motif_to_pwm.TF.tsv" ...
c382cb012015a799fa55da316cee606b4ede0482d9f89eb94bc11219958a0dda
Python
702
31
import pytest import cedalion.sigproc.physio as physio import cedalion.data from cedalion import units import numpy as np np.random.seed(42) @pytest.fixture def rec(): rec = cedalion.data.get_snirf_test_data()[0] return rec def test_global_component_subtract(rec): ts = rec["amp"] ts_weights = ts.s...
b2f79defa9779ecb444a36489ec606ccfaf247870f21a7f74074c9b930d85cd3
Python
704
34
# file generated by setuptools-scm # don't change, don't track in version control __all__ = [ "__version__", "__version_tuple__", "version", "version_tuple", "__commit_id__", "commit_id", ] TYPE_CHECKING = False if TYPE_CHECKING: from typing import Tuple from typing import Union V...
a28badd0599da1d67a8499329b16307798c3ec9d0f7a255462415d75cf89a3e1
Python
708
26
"""Contains modules for dereplicate workflow""" from .input_data_loading import load_input_folder, parse_gbk_files, gbk_factory, load_input_data, make_gbk_name from .gbk_component_parsing import get_parser_functions from .sourmash_utilities import ( make_sourmash_input, run_sourmash_branchwater, parse_sour...
fad919ba9209aff8cba9e5fbc5b46113cf823971d12341a846900a72156d7b9e
Python
709
22
import os import sys if 'setuptools' in sys.modules: from setuptools.command.bdist_rpm import bdist_rpm as old_bdist_rpm else: from distutils.command.bdist_rpm import bdist_rpm as old_bdist_rpm class bdist_rpm(old_bdist_rpm): def _make_spec_file(self): spec_file = old_bdist_rpm._make_spec_file(sel...
84f56e16f19f2e2ed726c51c7cd7dae57b29af08ba1d8b3f405da77c0eac368f
Python
710
20
import pandas as pd import os # Create consistency directory if it doesn't exist os.makedirs('CT2_log/euclidean/final_candidate/consistency', exist_ok=True) # Read the files current_candidates_df = pd.read_csv('CT2_log/euclidean/final_candidate/candidate_genes.csv') h9_df = pd.read_csv('consistency/H9_candidate_genes...
c2db7ed8c2479561915cfbe39613151e177a71d81cbf5162fbddd24a343354fb
Python
710
24
from .layer import Layer from .composercluster import ComposerCluster class ComposerLayer(Layer): ''' This layer defines the information of composer name. One neuron corresponds to a composer ''' def __init__(self, neutype='LIF'): self.neutype = neutype self.groups = {} def s...
0000a14fdc9a2f6d9ad4755c0e08c08cc4bd053b8871aeffee93811ea5a50356
Python
711
21
from typing import Optional import tempfile import shutil import contextlib @contextlib.contextmanager def tmpdir_manager(base_dir: Optional[str] = None): """Context manager that deletes a temporary directory on exit.""" tmpdir = tempfile.mkdtemp(dir=base_dir) try: yield tmpdir finally: ...
fd0d7e75265829bad78d64ea5a78018ac9e75cdaba6a07457dac634e8a759837
Python
711
20
import torch from torch import Tensor from torchmetrics.functional.regression.mae import _mean_absolute_error_update from torchmetrics.regression import MeanAbsoluteError class MaskedMeanAbsoluteError(MeanAbsoluteError): """Overloaded MAE for usage with block diagonal matrix. Mask calculated from target tenso...
2a72440391f871783b48bacc8f05ad89d0f6e154af39dbbbd9dd7bbe8b6263d1
Python
713
21
from distutils.unixccompiler import UnixCCompiler class PathScaleCCompiler(UnixCCompiler): """ PathScale compiler compatible with an gcc built Python. """ compiler_type = 'pathcc' cc_exe = 'pathcc' cxx_exe = 'pathCC' def __init__ (self, verbose=0, dry_run=0, force=0): UnixCCompil...
3e9753526ddc8d6594328c4ff652376028ef46ee777a336a4b3ae493fc8a531d
Python
713
22
from setuptools import setup, find_packages setup( name='modamix', version='0.0.2', description='A Unified Framework for Correcting Batch Effects and Integrating Multi-Omics Data', author='miniymay', author_email='joungmin@vt.edu', url='https://github.com/cbi-bioinfo/MoDAmix', install_requi...
452dee15b65b0e2c56c78b5cc8380ae36bce3acb2efc78ef670bd23ba831bddb
Python
713
21
# -*- coding: utf-8 -*- # # __init__.py # # Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.o...
7f78c2f7bf50bb4da226180065736834728f6f8b0a98fa7b03753741be500eb3
Python
714
25
# >>> # https://gist.github.com/Cilyan/9424144 import base64 import struct def fnv64(data): hash_ = 0xcbf29ce484222325 for b in data: hash_ *= 0x100000001b3 hash_ &= 0xffffffffffffffff hash_ ^= b return hash_ def hash_dn(dn: str, salt: str): # Turn dn into bytes with a salt, d...
a196f3f72a1a60d12f138ff069fc1f901b11c2de90d8376baf6f689be098022b
Python
714
31
import numpy as np import pandas as pd from tabulate import tabulate from rdkit import Chem def load_data(file_path): df = pd.read_csv( file_path, sep=None, engine="python" ) smiles = df.iloc[:, 1].values targets = df.iloc[:, 2:].values return smiles, ...
cfa5c8072401665627feeabafdd1754755c2f5ce323b7f55009a5eedfba4cf74
Python
715
28
#!/usr/bin/env python3 import stsc.parser as parser from stsc.run import run from stsc.look import look from stsc.progress import progress from stsc.test import test def main(): prs = parser.make_parser() args = prs.parse_args() if args.command == 'run': run(prs,args) elif args.command == 'lo...
78e994bb8ab48a11936d8a4295ea029d8b6fc21d530421194108cb78969430d0
Python
717
20
import pytest from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike @pytest.mark.parametrize("datum1", [1, 2.0, "3", (4, 5), [6, 7], None]) @pytest.mark.parametrize("datum2", [8, 9.0, "10", (11, 12), [13, 14], None]) def test_cast_1d_array(datum1, datum2): data = [datum1, datum2] result...
10a3e2963adf285f874c69b426e910c2fe9f8afd77c1eee8c40a40dba06837ad
Python
718
28
from __future__ import annotations from ..utils._typed_cache import typed_cache from ._list_difficult_words import list_difficult_words @typed_cache def set_difficult_words(text: str, syllable_threshold: int, lang: str) -> set[str]: """Get a set (no duplicates) of the difficult words in the text. Parameter...
b065d2e48a71d48a3174a07b54f287f9789a070f1a8f556795626a9a4c53e449
Python
718
17
# License: GNU Affero General Public License v3 or later # A copy of GNU AGPL v3 should have been included in this software package in LICENSE.txt. """ Helpers for type hints. """ class ConfigType: # pylint: disable=too-few-public-methods """ Exists only to allow mypy to use the stub by this name in custom_typi...
e945a6236275e6add3a116be219715efc48746d6970140a603c27f394285f04a
Python
722
31
# run as: python make_video.py import os import matplotlib.pyplot as plt import numpy as np fiber = 0 model = 0 ve_path = os.path.join('..', 've_files', f'model{model}_fiber{fiber}.dat') print(f've_path: {ve_path}') ve = -1 * np.loadtxt(ve_path, skiprows=1) coords_path = os.path.join('..', 'coords_files', f'{fiber...
dc8a69c9df21737d3c531609ed84a522f25e81be9e8f272c04c8b7dddfe7954c
Python
725
27
from setuptools import setup, Extension import numpy setup( ext_modules=[ Extension( 'crystal_tracer.algorithm.detection', ['crystal_tracer/algorithm/detection.pyx'], language='c++', include_dirs=[numpy.get_include()], ), Extension( ...
6f7af0d49fd5dccc14f8b65ff2e21244abdf5f315a0631470026e0c8ba3bf396
Python
727
29
""" Compatibility module. This module contains duplicated code from Python itself or 3rd party extensions, which may be included for the following reasons: * compatibility * we may only need a small subset of the copied library/module This module is deprecated since 1.26.0 and will be removed in future versions....
b8f6fe4f04f2a5972bbaf1ecadff40cff029e4feea826fabd80f0672995c7571
Python
727
18
import pandas as pd # Read the deletion distance file distances_df = pd.read_csv('CT2_log/euclidean/high_variation_genes/deletion_distance.csv') # Sort by difference in descending order and get top 200 top_200 = distances_df.sort_values('Difference', ascending=False).head(200) # Save to a new file top_200.to_csv('CT...
36967e0a616fb6b6d2f485633acf147726c70cd99d9a5497359d376986b2232f
Python
731
33
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jul 1 13:49:20 2021 @author: wanxiang.shen@u.nus.edu """ import os import pandas as pd file_path = os.path.dirname(__file__) class load_all: @property def data(self): return pd.read_csv(os.path.join(file_path, 'result_data', 'all_d...
8b73a2d426fc7fcf07d76f7bd5bac7cde1c2d68439a9f765ffe598ba2417632a
Python
732
27
from typing import Optional from app.config.camera import CameraConfig class CameraConfigValidator: @classmethod def _validate(cls, camera_config: CameraConfig) -> Optional[str]: if camera_config is None: return "Config is null" if camera_config.fps is None: return "F...
0a2bb2b221c0dfd57951f702057148c7cdc8ac3a6ec1f37d45c4d482fdbc7ed4
Python
733
33
""" requests.hooks ~~~~~~~~~~~~~~ This module provides the capabilities for the Requests hooks system. Available hooks: ``response``: The response generated from a Request. """ HOOKS = ["response"] def default_hooks(): return {event: [] for event in HOOKS} # TODO: response is the only one def dispatch_...
d26b56d8e099638e57f15c18ee3ef69cff2376f458f6c0b960670489d56cc2c9
Python
733
23
from __future__ import annotations import pytest from textstat.backend import metrics from .. import resources @pytest.mark.parametrize( "text, lang, expected", [ (resources.EMPTY_STR, "en_US", 0.0), (resources.EASY_TEXT, "en_US", 7.348), (resources.SHORT_TEXT, "en_US", 8.842), ...
f13b23bb54705cd6cfc90723bfc191305bde150a9895b35d4998765f5395f955
Python
733
27
import sys if 'setuptools' in sys.modules: from setuptools.command.sdist import sdist as old_sdist else: from distutils.command.sdist import sdist as old_sdist from numpy.distutils.misc_util import get_data_files class sdist(old_sdist): def add_defaults (self): old_sdist.add_defaults(self) ...
f8681da17db0a17acbdfebe7063aba10a893c933054365330cea59ef63abc108
Python
733
38
from __future__ import annotations from ._words_per_sentence import words_per_sentence from ._chars_per_word import chars_per_word from ..utils._typed_cache import typed_cache @typed_cache def automated_readability_index(text: str) -> float: r"""Calculate the Automated Readability Index (ARI). Parameters ...
cc48243eedae89d2ccc473ffd6032deffeac5c7030b3ce5b8b88968e08c0c8be
Python
734
25
import pennylane as qml import tensorflow as tf nwires, nlayers, nbatch = 6, 3, 16 dev = qml.device("default.qubit.tf", wires=nwires) @tf.function @qml.qnode(dev, interface="tf") def yp(inputs, params): for i in range(nwires - 1): qml.RX(inputs[i], wires=i) for j in range(nlayers): for i in r...
3380b234b890a10e6886800c1f91c44bd461da5a6bc80335b682fe6f54c95e3d
Python
736
31
from pandas.core.indexers.utils import ( check_array_indexer, check_key_length, check_setitem_lengths, disallow_ndim_indexing, is_empty_indexer, is_list_like_indexer, is_scalar_indexer, is_valid_positional_slice, length_of_indexer, maybe_convert_indices, unpack_1tuple, un...
b2ff8f81a6a6bbeb8395cfa9848f783988c0a54c6803ee34596d34b23fbc58aa
Python
736
25
import tensorcircuit as tc tc.set_backend("tensorflow") nwires, nlayers = 6, 3 def vqe_forward(param): c = tc.Circuit(nwires) for i in range(nwires): c.H(i) for j in range(nlayers): for i in range(nwires - 1): c.exp1(i, i + 1, theta=param[2 * j, i], unitary=tc.gates._zz_matrix...
e0bdbe9d691d018875d63962fa0144bb3e17abe8c876b4cae4a2e22825da04c8
Python
736
30
import argparse import logging import os from nmf_analysis import data from nmf_analysis import settings as s logger = logging.getLogger(__name__) logging.getLogger().setLevel(logging.INFO) def generate() -> None: """ Load the dataset store in HDF database. """ parser = argparse.ArgumentParser() ...
eb5011bf0b4992c7aac039e749809493e5df079dc1b66859d46ec3e84411da23
Python
737
32
from __future__ import annotations from .constants import LANG_CONFIGS from ._get_lang_root import get_lang_root def get_lang_cfg(lang: str, key: str) -> float: """Get the config value specified by `key` for the given language `lang`. Parameters ---------- lang : str The language of the text...
f53539310ac9eb1ad02b8300ec4c90f91e85d557a263c2076b5f6a33a25bcb92
Python
737
34
''' Created on 2016.7.7 @author: liangqian ''' from Modal.note import Note from Modal.cluster import Cluster from conf.conf import configs from Modal.pitch import Pitch class APAC(): ''' anterior primary auditory cortex,encoding the musical notes ''' def __init__(self): ''' Constructo...
81dfa70572def8373956873f2ac826abd98e53a4bf239659aa55dc6a980acdf1
Python
738
30
from datetime import timedelta from pandas import ( Index, Timestamp, date_range, isna, ) class TestAsOf: def test_asof_partial(self): index = date_range("2010-01-01", periods=2, freq="ME") expected = Timestamp("2010-02-28") result = index.asof("2010-02") assert re...
ecbc2a8bd2caa7193800be418281d6532be27a2aa0f6f083002f3fe93a8ad2c0
Python
739
19
# License: GNU Affero General Public License v3 or later # A copy of GNU AGPL v3 should have been included in this software package in LICENSE.txt. """ Representations of features within secmet """ from .antismash_domain import AntismashDomain from .antismash_feature import AntismashFeature from .candidate_cluster im...
feda2cf68177e7f66cf279e2a310aaf351d91fb0f2f2b44b562138d7c537c665
Python
739
25
import sys sys.path.append('.') from plotting.utils import load_results, mesh_name, sim_name, set_plotting_defaults, efcolor, pvscolor, ecscolor import matplotlib.pyplot as plt if __name__ == '__main__': sim_name = sys.argv[1] mesh_name = sys.argv[2] results = load_results(mesh_name, sim_name) times = resu...
d3c77ea09407002c91f88e684dea06d699a57a2090f2f3bb9d54ceee02f4eb74
Python
741
23
# License: GNU Affero General Public License v3 or later # A copy of GNU AGPL v3 should have been included in this software package in LICENSE.txt. """ A collection of functions for running prodigal. """ from .base import execute, get_config def run_prodigal_version() -> str: """ Get the version of the prodigal...
94ae5f5efe1c448bbaf6872f3877ca2f96e378ad230dd5b7a6cbebaecb230e80
Python
742
25
import numpy as np from pandas import ( Categorical, Series, ) import pandas._testing as tm class TestCategoricalComparisons: def test_categorical_nan_equality(self): cat = Series(Categorical(["a", "b", "c", np.nan])) expected = Series([True, True, True, False]) result = cat == ca...
aaeb29d88511360da6fd50c3988bdaa74ecadc189871e4ba5d840e40bf33b0a1
Python
743
26
# Create 'crime.pickle' import pickle import lightgbm as lgb from sklearn.model_selection import train_test_split import shap random_state = 1203344 # Load data and train model X, y = shap.datasets.communitiesandcrime() X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=random_s...
db6622c6969b2008d4cb0062ebdb5ae54eb182a07336d4676b6fd6960132d6b0
Python
743
25
""" General DL functions """ import torch import warnings def get_device(device_str): """ This function gets the desired device """ if device_str == 'cpu': device = torch.device(device_str) elif device_str.startswith('cuda'): if torch.cuda.is_available(): device = torc...
da8f0178cc63018df1ba5d6d91fd3f3e2c35883bab18f1d58923738b2d5b3f04
Python
744
23
import mido import time from midi_functions import create_chord_from_number, send_chord_on, clear_all_notes, send_chord_off TR = 1.5 # in seconds chord = [60 - 12, 60, 60 + 7] # MIDI output midi_music_out = mido.open_output('IAC Driver Music Port') CHANGE_CHORD = True #base_note_prog = [1, 0, 1, 2, 3, 4, 5, 6, 7, 8...
553773fd53ad6284c2d57309a7397a6c3e6f44edf39e4657b14e7524cbfd73cd
Python
745
27
# -*- coding: utf-8 -*- import numpy as np import os import pandas as pd import sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) def read_data(file_path): df = pd.read_csv(file_path, index_col='time', parse_dates=['time'], date_format="%Y-%m-%d %H:%M:%S").dropna().astype(float) return df def...
7aa56b15607d7c0b472bb5c5dfbd34e23ae4785243e30206dccdca0406cef14f
Python
748
28
""" Created on Jan 6, 2026 @author: mning """ import statsmodels.api as sm from sklearn.base import BaseEstimator from sklearn.base import RegressorMixin class SMWrapper(BaseEstimator, RegressorMixin): """A universal sklearn-style wrapper for statsmodels regressors""" def __init__(self, model_class, fit_int...
2c3d8133810f027a3bb1608f0b25d52b4312ad7ea6b1546095cce0cc544dc9d2
Python
750
40
import numpy as np show_hz = 15 num_seconds = 120 num_repeats = 4 num_junk_seconds = 10 num_blank_seconds = 10 img_template = "im%07d.png" blank_img = img_template % 0 stimlist = [] blank = [blank_img] * (num_blank_seconds * show_hz) stimlist = stimlist + blank junk_offset = num_seconds * show_hz + 1 junk = [...
57b94c530c3b0aa809d93854067d4f89ab59b506a73b2b7b399a6ed86648fb7e
Python
750
17
from __future__ import annotations from blinker import Namespace # This namespace is only for signals provided by Flask itself. _signals = Namespace() template_rendered = _signals.signal("template-rendered") before_render_template = _signals.signal("before-render-template") request_started = _signals.signal("request...
3802763df28ea431ef2ebc331ac776dcccdc9a4be3cc7ddc2d8c7e19dd811d3f
Python
751
22
import torch from .rk_common import _ButcherTableau, RKAdaptiveStepsizeODESolver _BOGACKI_SHAMPINE_TABLEAU = _ButcherTableau( alpha=torch.tensor([1 / 2, 3 / 4, 1.], dtype=torch.float64), beta=[ torch.tensor([1 / 2], dtype=torch.float64), torch.tensor([0., 3 / 4], dtype=torch.float64), ...
c061e1ad4d923ee3da27bbbabc3dbaf7eb8f74fc65d2040eb6fc1a7f2fdf4a0e
Python
751
20
import pytest from click.testing import CliRunner from cardio_audio_sleep.commands.sys_info import run @pytest.mark.parametrize("developer", [False, True]) def test_sys_info(developer: bool): """Test the system information entry-point.""" runner = CliRunner() result = runner.invoke(run, ["--developer"] i...
a9b3457ee161ee012ec6666816f29f4ed8316d12498993b307787b6525cc682d
Python
753
26
# Tests for the '.AminoAcidMWChange' defs import pandas import numpy import pytest import sbmlcore def test_amino_acid_MW_change_value(): a = {'mutation': ['A1D', 'E2K']} df = pandas.DataFrame(a) a = sbmlcore.AminoAcidMWChange() df = a._add_feature(df) assert 'd_MW' in df.columns assert df....
cf380546ec3f9163e32a91b0ecb0b4654303d8243611b7ab50862cf22ce37420
Python
753
25
from dataclasses import dataclass from pip._vendor.packaging.version import Version from pip._vendor.packaging.version import parse as parse_version from pip._internal.models.link import Link @dataclass(frozen=True) class InstallationCandidate: """Represents a potential "candidate" for installation.""" __s...
404c852e79a6c4a922dc4082a8c0c72ebb2b6d7e1a1925723c97f831bc397197
Python
754
29
''' Created on 2016.6.8 @author: liangqian ''' import time import sys import stomp class MyListener(object): def on_error(self, headers, message): print('received an error : %s' % message) def on_message(self, headers, message): print('%s' % message) conn = stomp.Connection([('159.226.19.16',6...
9332b42a79f1b865bfa050543badd56fa9f81f610b84a52f321f5f65fccb730d
Python
754
23
# License: GNU Affero General Public License v3 or later # A copy of GNU AGPL v3 should have been included in this software package in LICENSE.txt. """ A collection of functions for running java. """ from .base import execute, get_config def run_java_version() -> str: """ Get the version of the java binary """ ...
d1b716c9065401ad700d9648fa43ca97695419d0001f312b35f63b0ba50c04e1
Python
754
26
from pathlib import Path import nrrd import matplotlib.pyplot as plt from tqdm.contrib.concurrent import process_map def main(i): img, _ = nrrd.read(str(i)) img = img.max(axis=0) height, width = img.shape[:2] dpi = 300 figsize = (width / dpi, height / dpi) fig, ax = plt.subplots(facecolor='bla...
914f97aed2edb99820fea1c9a0df2e3f5cb742e2dee91220cf7c41ecdc55d0f2
Python
755
33
from io import StringIO from cardio_audio_sleep.utils.config import sys_info def test_sys_info(): """Test info-showing utility.""" out = StringIO() sys_info(fid=out) value = out.getvalue() out.close() assert "Platform:" in value assert "Executable:" in value assert "CPU:" in value ...
ecc9bb4fdabbbdf34ec893f08619526aecc703b1d759f11f4fc5ac3de5372084
Python
755
25
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # setup.py # # Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # ...
29c3f5192df4f8ddb6b97394d6688ab5a7b1240b4be448c8dabf90b74ac399c5
Python
757
27
"""Utilities for phyid.""" import numpy as np PhiID_atoms_abbr = [ "rtr", "rtx", "rty", "rts", "xtr", "xtx", "xty", "xts", "ytr", "ytx", "yty", "yts", "str", "stx", "sty", "sts", ] PhiID_atoms_full = [ ("Red", "Red"), ("Red", "Un1"), ("Red", "Un2"), ("Red", "Syn"), ("Un1", "Red"), ("Un1", "Un1...
75027b54542e2619bb57f93cdfb6484cba75b6de2a141e10b06f38fddaf320b1
Python
757
26
# Tests for the '.AminoAcidPiChange' defs import pandas import numpy import pytest import sbmlcore def test_amino_acid_Pi_change_value(): a = {'mutation': ['A1D', 'E2K']} df = pandas.DataFrame(a) a = sbmlcore.AminoAcidPiChange() df = a._add_feature(df) assert 'd_Pi' in df.columns assert df....
436dc2cbfe10d2f510b3c2b1c1880d3305dc2612caefee3640f3d3a20bbf8d6c
Python
758
20
import pandas as pd import os # Create consistency directory if it doesn't exist os.makedirs('CT2_log/euclidean/final_candidate/consistency', exist_ok=True) # Read the files current_candidates_df = pd.read_csv('CT2_log/euclidean/final_candidate/candidate_genes.csv') small_deletion_df = pd.read_csv('consistency/small_...
e915f65fe995d47ba12599d57d098398b5612145ac7884f83f9c1fdeb74babd6
Python
758
28
from numpy.distutils.fcompiler import FCompiler from numpy.distutils import customized_fcompiler compilers = ['NoneFCompiler'] class NoneFCompiler(FCompiler): compiler_type = 'none' description = 'Fake Fortran compiler' executables = {'compiler_f77': None, 'compiler_f90': None, ...
03175f43c40739f293f816c3994d762221ab3b57048084574ef13350e676a946
Python
759
30
"""module containing integration tests for the family calling workflows""" # from python from unittest import TestCase # from dependencies # from other modules import big_scape.data as bs_data # from this module class TestComparison(TestCase): """Test class for hmm search/scan workflow""" def clean_db(se...
bebcd9e13b285221677ced3b0d3a424867abc54be8b7b5a02619423f22c6f0d7
Python
759
27
from __future__ import annotations import pytest from textstat.backend import counts from .. import resources @pytest.mark.parametrize( "text,ignore_spaces,expected", [ ("", True, 0), ("", False, 0), ("a", True, 1), ("a ", True, 1), ("a ", False, 2), ("a b", Tr...
db8e0be148c23db28730fab1168670dea002df5aa2696f44a4fb85da192002a4
Python
759
39
import argparse import logging from nmf_analysis.nmf import train_model logger = logging.getLogger(__name__) logging.getLogger().setLevel(logging.INFO) def train() -> None: """ Train a NMF model. """ parser = argparse.ArgumentParser() parser.add_argument( "--behavior", default="T...
310c1c1660b91b7d6266b789ea71ed2e7123e0923e10b32faa4e9c2c542c76b9
Python
760
29
""" Created on Jun 5, 2024 @author: mning """ import logging import os from src.utils import logFilter def setup_custom_logger(name: str, loglevel: int = logging.INFO) -> logging.Logger: log_Dir = ( r"C:\Users\mning\Documents\CNBS_Projects\SAGES I and II" r"\Data\Baseline_rsEEG_preprocessing\csv...
6f6ab8ffee0b2269b5e7c80a2ffda31e807ceaaaa3e0cfa38ba7082e6a0b44b5
Python
760
15
import pandas, sys threshold_file = sys.argv[1] regions_file = sys.argv[2] thresholds = pandas.read_csv(threshold_file, sep="\t", compression="gzip", header=0) regions = pandas.read_csv(regions_file, sep="\t", compression="gzip", header=None, names=["Chrom", "Start", "End", "Region", "AverageCov"], index_col=...
3f7f5826f226efcc85117b9bb3fc6e2e4895ab7ba112fe333553bac927d7205c
Python
763
19
""" Keras loss functions will choke on NaN inputs, which we'll often have for unspecified inputs. These are just a couple simple loss functions that mask NaN values in both the test and predicted tensors when computing the cost. """ import keras.backend as K import tensorflow as tf def masked_mean_squared_error(y_tru...
821dde182e4312f34828502dbb3cd73df89b8f5a91c4cbbf94d89e7e9496e4c9
Python
763
31
"""Smoke test TensorCircuit after installing only its required dependencies.""" import importlib.util import numpy as np import tensorcircuit as tc OPTIONAL_MODULES = ("tensorflow", "jax", "torch", "cupy", "qiskit", "cirq", "stim") def main() -> None: installed_optional_modules = [ name for name in OP...
e84942e9d065ff58a617852565515eafa5ad6f0ca960bd04862b9cd18c0990fa
Python
763
23
import numpy as np def tile_images(img_nhwc): """ Tile N images into one big PxQ image (P,Q) are chosen to be as close as possible, and if N is square, then P=Q. input: img_nhwc, list or array of images, ndim=4 once turned into array n = batch index, h = height, w = width, c = channel ...
46f49d37b08bf533b7c6fd9e0635a35a22e1b1143b5f8b17e5d7171fd5b1c1f5
Python
764
25
import numpy as np import torch from torch_geometric.data import Batch, Data def np_scatter_add(updates, indices, shape): target = np.zeros(shape, dtype=updates.dtype) np.add.at(target, indices, updates) return target def atoms_list_to_PYG(ase_atoms_list, device): """Function to convert ase.Atoms ob...
4e2c6c9bba46763593d702f349969ca5cb02565915b5181409059c76565aaef4
Python
764
24
import scvelo as scv from scvelo.tools import SecondOrderSteadyStateModel, SteadyStateModel # TODO: Add test to check equivalence with original implementation def test_first_order_model_run(): adata = scv.datasets.simulation(random_seed=0, n_vars=10) scv.pp.filter_and_normalize(adata) scv.pp.moments(adata...
92bdca2a73295822b2ac1166939cfc9805a6259b20cdf5eea61c31053b0553a9
Python
766
20
import pandas as pd import os # Create consistency directory if it doesn't exist os.makedirs('CT2_log/euclidean/final_candidate/consistency', exist_ok=True) # Read the files current_candidates_df = pd.read_csv('CT2_log/euclidean/final_candidate/candidate_genes.csv') original_dataset_df = pd.read_csv('consistency/orig...
cbf2a4b8bcf5b8cee9bf9dea7eaec640ebae7782e85c4ddaa4ad70b4045d5723
Python
766
37
import numpy as np AR = np.arange(10) AR.setflags(write=False) with np.printoptions(): np.set_printoptions( precision=1, threshold=2, edgeitems=3, linewidth=4, suppress=False, nanstr="Bob", infstr="Bill", formatter={}, sign="+", float...
e485791a73361570732d6cf073af13d10b908ebfbb3ff55f1abca2fb15011422
Python
768
30
import numpy as np def get_pads(target_dim, d): if target_dim <= d: return 0, 0 p = (target_dim - d) // 2 if (p * 2 + d) % 2 != 0: return p, p + 1 return p, p def target_pad(img, target_dims, mode="zero"): pads = tuple(get_pads(t, d) for t, d in zip(target_dims, img.shape)) ...
e9c1610c5a57ed32797cb9fc3cf0ba766fb8d98d5aea350aa4121413b2d2024f
Python
770
25
from __future__ import annotations import pytest from textstat.backend import metrics from .. import resources @pytest.mark.parametrize( "text, ms_per_char, expected", [ (resources.EMPTY_STR, 0.0, 0.0), (resources.EMPTY_STR, 1.0, 0.0), (resources.EMPTY_STR, 5.3, 0.0), (resour...
d4dc27f9e3d80445d663837da457476aa719a0a856ba29ca74527e12366d1656
Python
772
26
import numpy as np import pytest from pandas import ( PeriodIndex, period_range, ) import pandas._testing as tm class TestRepeat: @pytest.mark.parametrize("use_numpy", [True, False]) @pytest.mark.parametrize( "index", [ period_range("2000-01-01", periods=3, freq="D"), ...
6fca452a634452837994050260177c108c2300a98bee4872b79fc238adceea41
Python
775
29
""" Depracated, using ``vectorized_value_and_grad`` instead for batched optimization """ import tensorcircuit as tc from tensorcircuit.applications.dqas import ( parallel_qaoa_train, single_generator, set_op_pool, ) from tensorcircuit.applications.layers import * # pylint: disable=wildcard-import from ten...
f2b6fbaecb2abc8a12cedcc27c56f9a58e28207fc68c34ad2ab5e40ba6e75199
Python
776
28
import pytest from pandas import ( Categorical, CategoricalDtype, Index, IntervalIndex, ) import pandas._testing as tm class TestAstype: @pytest.mark.parametrize("ordered", [True, False]) def test_astype_categorical_retains_ordered(self, ordered): index = IntervalIndex.from_breaks(ran...
fb98d18de32171b53599b768d1964e33dc87354004b3f5d062a81a762418b09b
Python
776
30
#!/usr/bin/env python3 import os import re def set_output(name: str, val: str) -> None: print(f"Setting output {name}={val}") if os.getenv("GITHUB_OUTPUT"): with open(str(os.getenv("GITHUB_OUTPUT")), "a") as env: print(f"{name}={val}", file=env) else: print(f"::set-output name...
7468a8b3ed64f900467b0ed817338d653cd55b1cfe69801aaa571c976fe1e41a
Python
777
27
"""A module with platform-specific extended precision `numpy.number` subclasses. The subclasses are defined here (instead of ``__init__.pyi``) such that they can be imported conditionally via the numpy's mypy plugin. """ import numpy as np from . import ( _80Bit, _96Bit, _128Bit, _256Bit, ) uint128 =...
196329b3e2b384a4b579267d13fe1807303e02800f803b861428a74802a4a195
Python
779
26
"""Cere-MEG-Bellum (CMB).""" import os as _os from ._version import __version__ from .functions import get_cerebellum_data, get_plot_data_from_stc from .segmentation import segment_cerebellum from .source_space import create_cerebellar_surface, setup_full_source_space # Deprecated, will just instruct users to use th...
7bb179327aaa231ad3088053c904e230ef9ff225e9656b03af1a9a3d615cc224
Python
779
24
import torch import torch.nn as nn """ Learnable swish activation """ class Swish(nn.Module): def __init__(self, num_features, initial_alpha=1.0, initial_beta=1.702): super(Swish, self).__init__() self.num_features = num_features self.initial_alpha = initial_alpha self.initial_bet...
87e0233b8a380e0beb4f3b59677cc46ce9386657c222dd4ef77068b6d665afa6
Python
779
30
import numpy as np import logging import yass from yass import preprocess from yass import detect from yass import cluster from yass import templates np.random.seed(0) # configure logging module to get useful information logging.basicConfig(level=logging.INFO) # set yass configuration parameters yass.set_config('co...
8ec2d62c77f33b6a51ba83edf4b69d4df2adde8d3ddef438a040c30e5392724f
Python
779
20
import sys import numpy as np import pandas as pd import polars as pl import pyranges as pr pseudo_fragment = pl.read_csv(snakemake.input.pseudo_fragment_file, separator='\t', comment_prefix='#', n_threads=8) pseudo_fragment.columns = ['chrom', 'chromStart', 'chromEnd', 'name', 'score'] # Filter for only the main 23...
a743e8c088755cbff5791f2ca6cd55d71c7775d6f0dadf41a55b8fd35bb7126f
Python
779
32
""" The calculation of molecular connectivity indices based on its topological structure(Chi). You can get molecular connectivity descriptors. """ from mordred import Calculator, descriptors import numpy as np _calc = Calculator(descriptors.Chi) _ConnectivityNames = [str(i) for i in _calc.descriptors] def GetCon...
d5392ddf94ad64f1991c69cff741029387fe4bacca04e3e4f12acb96a62fb13e
Python
779
27
from __future__ import annotations import pytest from textstat.backend import metrics from .. import resources @pytest.mark.parametrize( "text, lang, expected", [ (resources.EMPTY_STR, "en_US", 0.0), (resources.EASY_TEXT, "en_US", 4.004), (resources.SHORT_TEXT, "en_US", 10.0), ...
d437a76d287d9c44e3a82bc34b384b17bfe128a1aa5ab6ade150e7c1de4bb102
Python
781
25
from Bio.Data import PDBData from pathlib import Path import unittest from rna3db.parser import ModificationHandler class TestModifications(unittest.TestCase): modification_handler = ModificationHandler( Path(__file__).parent / "test_data" / "modifications_cache.json" ) def test_biopython_covera...
530ae8de579330f43c9bc74c05be1cf80d1c3010cd32adef3a76e8fa5e55ef8b
Python
782
37
"""Tests for fooof.plts.fm.""" from py.test import raises from fooof import FOOOFGroup from fooof.plts.fg import * from fooof.tests.utils import plot_test ################################################################################################### ##############################################################...
489e2beda7a9ec74ab4a03e1c74dac9a62dd38c651c14b96dea2d2e3abcf45b7
Python
784
36
""" Command Line Interface (CLI). Easy to use + accessible remotely Sources: - Nice instructional video: https://www.youtube.com/watch?v=FWacanslfFM - https://dojofive.com/blog/3-steps-to-make-a-professional-cli-tool-using-pythons-click/ """ import os import click from FLightcase.server import server from FLightcase...
4739082fc217eb75f57e0c2bf28e3fc6e2af74eb4f1dda1d3dbb12ef9bbd0513
Python
785
31
from dateutil.tz import tzlocal import pytest from pandas.compat import IS64 from pandas import date_range @pytest.mark.parametrize( "freq,expected", [ ("YE", "day"), ("QE", "day"), ("ME", "day"), ("D", "day"), ("h", "hour"), ("min", "minute"), ("s", "...
e1b39cac9260927aa1900fcfbbf6a3f74ad4549a5b5f6e542f9efd862b2a62d5
Python
785
26
from rna3db.utils import write_json from rna3db.parser import parse_fasta from collections import defaultdict from pathlib import Path import argparse if __name__ == "__main__": parser = argparse.ArgumentParser( description="Converts a FASTA to an RNA3DB-style JSON." ) parser.add_argument("input_...
67192a5e6a0516380d0dc9e2371e533bb6bd1d6085e4c27511cd9aa331eddb12
Python
786
26
# Tests for .AminoAcidVolumeChange import pandas import numpy import pytest import sbmlcore def test_amino_acid_volume_change_value(): a = {'mutation': ['A1D', 'E2K']} df = pandas.DataFrame.from_dict(a) a = sbmlcore.AminoAcidVolumeChange() df = a._add_feature(df) assert 'd_volume' in df.columns ...
6d8e73e41709e23ec6af73877c05407b01910996a99c46b792e4a238326fbd69
Python
787
37
from PySide6.QtCore import QObject, Signal from app.dataflow.qqueue import IQueue class QListMeta(type(QObject), type(IQueue)): pass class QList(QObject, IQueue, metaclass=QListMeta): """ A thread-safe list with signals for changes """ list_changed = Signal() list_cleared = Signal() d...
f10bbdfeea6df42d9a7b7bf7de8d02b0501bcef7b92618cca2c3d38fc221c783
Python
787
32
""" Produce image with grey mask author: Ana Luisa Pinho date: July 2019 """ import os import numpy as np import ibc_public.utils_data from nilearn import plotting import matplotlib # Get grey matter mask _package_directory = os.path.dirname( os.path.abspath(ibc_public.utils_data.__file__)) mask = os.path.join...
3c91c289b79c2655783cfb913d8c356069659822ce1f315bf2755be963fe0f4b
Python
788
22
import pytest from cardio_audio_sleep.utils._imports import import_optional_dependency def test_import_optional_dependency(): """Test the import of optional dependencies.""" # Test import of present package numpy = import_optional_dependency("numpy") assert isinstance(numpy.__version__, str) # T...
5b88acc0077b9b23a708b2a7b2299f23c96335010b516292da98252b5fcf4fb5
Python
790
28
from __future__ import annotations import nltk from ._typed_cache import typed_cache from ._get_lang_root import get_lang_root @typed_cache def get_cmudict(lang: str) -> dict[str, list[list[str]]] | None: """Get a cmudict object for the given language. Currently only English is supported. Parameters ----...
c012df0cd2b75686e1666033de5e041012fda19d9a2d6670bc556465a7286e4a
Python
790
25
""" Functions for threshold detection """ import os import logging import numpy as np from scipy.signal import argrelmin def voltage_threshold(recording, threshold, order=5): T, C = recording.shape spike_index = np.zeros((0, 2), 'int32') energy = np.zeros(0, 'float32') for c in range(C): sing...
1d852799c877feff3de394d7f6af484fd46b1bbcd280a221b60da27b15694f15
Python
792
32
''' ====CAML v0.1==== cschwal's assisted machine learning suite for RODEO ''' print(__doc__) import svm_sample import svm_optimize invalidinp = True def main(): print('Indicate which stage of SVM classification to perform:\n 1...splitting data set into training and fitting\n 2...optimizing hyperparameters\n 0....