sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
329cfae870a5b9d637e9b5245aa6cd1b69662c0c27237acb502c105bed4bc314
Python
1,071
42
"""Add not-null constraints to group_role_association Revision ID: 25b092f7938b Revises: 9ef6431f3a4e Create Date: 2024-09-09 16:17:26.652865 """ from alembic import op from galaxy.model.migrations.data_fixes.association_table_fixer import GroupRoleAssociationNullFix from galaxy.model.migrations.util import ( a...
4bb7b47e769362b74698630fd3becf36c0067e69cdc258738fd52f117f7accdc
Python
1,071
46
import csv import re import h5py import urllib3 import urllib import gzip from io import StringIO import requests import numpy as np import time from utils_rbns import create_datapoints rbns_data = 'metadata_rbns.csv' protein_idx = 0 protein_list = list() protein_dict = {} with open(rbns_data, 'r') as f: f.read...
4d9cf35b5d7c73f3bcdb6f9b90cef1173360a3c0e39f2b672aff66011ca8d72a
Python
1,071
36
from sys import argv from msp import MSP msp = MSP() msp.file = __file__ msp.seed = int(argv[1]) msp.architecture["num_motifs"] = 82 msp.architecture["sparse_spec"] = dict(type="SpatiallySparseAcrossChannels") msp.architecture["motif_model_spec"]["motif_width"] = 17 msp.architecture["motif_model_spec"]["motif_feature...
6d7c40fa06634c8acd9e68b75c9bb076e29a88bf8d43cca786281b9642e34e58
Python
1,071
36
from sys import argv from msp import MSP msp = MSP() msp.file = __file__ msp.seed = int(argv[1]) msp.architecture["num_motifs"] = 82 msp.architecture["sparse_spec"] = dict(type="SpatiallySparseAcrossChannels") msp.architecture["motif_model_spec"]["motif_width"] = 17 msp.architecture["motif_model_spec"]["motif_feature...
94701e07b0dca626574e26e2e1ad35ead77a74d651dd4f98489f9ebb7e0b410c
Python
1,071
36
from sys import argv from msp import MSP msp = MSP() msp.file = __file__ msp.seed = int(argv[1]) msp.architecture["num_motifs"] = 82 msp.architecture["sparse_spec"] = dict(type="SpatiallySparseAcrossChannels") msp.architecture["motif_model_spec"]["motif_width"] = 13 msp.architecture["motif_model_spec"]["motif_feature...
d5562e616cb3a361bf47219d2ebb0da23261757a70058e52fd55c770ca2d90aa
Python
1,071
33
import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' from drug_interactions.datasets.dataset_builder import DatasetTypes from drug_interactions.models.AFMP import AFMP, AFMPConfig from drug_interactions.models.CharSmiles import CharSmiles, CharSmilesConfig from drug_interactions.models.DeepSmiles import DeepSmiles, Deep...
db25a448324a6579bb2c4f27a60728a917e187f8af9958b47b4fbffc549ffbf3
Python
1,071
36
from sys import argv from msp import MSP msp = MSP() msp.file = __file__ msp.seed = int(argv[1]) msp.architecture["num_motifs"] = 82 msp.architecture["sparse_spec"] = dict(type="SpatiallySparseAcrossChannels") msp.architecture["motif_model_spec"]["motif_width"] = 13 msp.architecture["motif_model_spec"]["motif_feature...
f0cb4004308782b224208b23fe345d6357f6e24ad23ae6b1ecdd0eb3bf2dde0f
Python
1,071
36
from sys import argv from msp import MSP msp = MSP() msp.file = __file__ msp.seed = int(argv[1]) msp.architecture["num_motifs"] = 82 msp.architecture["sparse_spec"] = dict(type="SpatiallySparseAcrossChannels") msp.architecture["motif_model_spec"]["motif_width"] = 13 msp.architecture["motif_model_spec"]["motif_feature...
0ff9605f69ad0bcc5fb8b9687c3b74e1100feaee0a2d6dfd8f7476cff0cf5e46
Python
1,072
34
import sqlite3 from .db import DB class DistrictTestingTable(DB): def __init__(self): super().__init__() self.table_name = 'UK_testing' self.table_desc = 'Uttarakhand district wise testing snapshot' self.cols = self.getcolumns() def getcolumns(self): cols = { ...
64198993940d098c5acfd05a819e6489e5f4943e710efda867a09b355de3d9b3
Python
1,072
42
"""Add not-null constraints to user_group_association Revision ID: 13fe10b8e35b Revises: 56ddf316dbd0 Create Date: 2024-09-09 21:26:26.032842 """ from alembic import op from galaxy.model.migrations.data_fixes.association_table_fixer import UserGroupAssociationNullFix from galaxy.model.migrations.util import ( a...
06b3bef8d7d30b5f661be27940d01a745768d6c6b921852d2d765c3ca707a53d
Python
1,073
49
from typing import Tuple import numpy as np import torch import torch.nn as nn dev = torch.device('cuda:0') class MultipleOptimizer: def __init__(self, *op): self.optimizers = op def zero_grad(self): for op in self.optimizers: op.zero_grad() def step(self): for op in ...
659cc65cf33d1f8639ade623900d227d49682f8c09dab4e4cfc5974cc960ef43
Python
1,073
19
""" Copyright (c) 2022 EPFL-BBP, All rights reserved. THIS SOFTWARE IS PROVIDED BY THE BLUE BRAIN PROJECT ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE BLUE BRAIN PROJE...
af84b2c8a4b39aa8dc4135a03c7e12f00cb368b34ec981c8b179895593f2267c
Python
1,073
38
import torch import numpy as np def stack(items, axis=0): # wrapps np.stack and torch.stack if isinstance(items[0], np.ndarray): # numpy interpolation return np.stack(items, axis=axis) elif torch.is_tensor(items[0]): # torch interpolation return torch.stack(items, dim=axis)...
ebb6fddb4aa90960a274fbe748100209c2226e62bdda54282985704384f84b47
Python
1,073
36
from sys import argv from msp import MSP msp = MSP() msp.file = __file__ msp.seed = int(argv[1]) msp.architecture["num_motifs"] = 82 msp.architecture["sparse_spec"] = dict(type="SpatiallySparseAcrossChannels") msp.architecture["motif_model_spec"]["motif_width"] = 11 msp.architecture["motif_model_spec"]["motif_feature...
1ac5253972742f56a314e07a2e9bbe1c370b351eb970f3c496366b1a3204c84f
Python
1,074
38
import numpy as np from .annotation import Annotation class ExclusiveExons(Annotation): """ Represents a pair of exons, where exactly one of the two must be included in a transcript. """ @classmethod def patterns(self): return ["ADAD"] def compatible_with_overlapping_junction...
237c9d3a87003b88248d4344d5e368b5b0ac864e86a535ac74c1897e516f8ce9
Python
1,074
24
# coding=utf-8 # Copyright 2023 The Google Research Authors. # # 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.org/licenses/LICENSE-2.0 # # Unless required by applicab...
2a802d82586236459ef57bf72a6def921d62a7c062bb4ed7d555dacebe05bc7c
Python
1,074
50
#!/usr/bin/env python import sys, os, re def main(): usage = "\n\n\tusage: {} STAR.Log.final.out [STAR.Log.final.out ...]\n\n".format(sys.argv[0]) if len(sys.argv) < 2: exit(usage) tokens = ['sample_name'] processed_first = False files = sys.argv[1:] for log_filename in files...
9b409836203545af2c4f0a091790a71d3a02fb0747d6aea14879ac7f9e6aecb9
Python
1,074
33
import numpy as np def select_independent_mutations( saliency_map, mech, codon_table, rna, motifs_score, *, rng, temperature, negativity_bias ): muts, map_back = saliency_map.sample_nonconflicting_mutations( rna, codon_table, motif_width=mech.motif_width(), rng=rng ...
b8c2fe01c1daf777cf899f111c060b954ebc451c7ddfd289925d5a53c7ab4c59
Python
1,075
32
from typing import List, Tuple, Union from PIL import Image from lightly.transforms.rotation import ( RandomRotate, RandomRotateDegrees, random_rotation_transform, ) def test_RandomRotate_on_pil_image() -> None: random_rotate = RandomRotate() sample = Image.new("RGB", (100, 100)) random_rota...
4009878357e4b4237b58e5bf626eb4bd1e3445e9b05509e4795a278f40fa8d15
Python
1,076
26
from ethoscope.stimulators.sleep_depriver_stimulators import MiddleCrossingStimulator from ethoscope.hardware.interfaces.optomotor import OptoMotor class OptoMidlineCrossStimulator (MiddleCrossingStimulator): _description = {"overview": "A stimulator to shine light when animals cross the midline", ...
5ff2cbb1931c2a15133690fe10ce70b6f64dda522006867aa9d4b9f12058f79b
Python
1,076
32
""" This module define a L1 loss with min max norm """ # pylint: disable=W0223 import torch import logging from utils.utils import select_output_lm class L1LossMinSumNorm(torch.nn.modules.loss._Loss): # pylint: disable=protected-access """ This class define a specific loss : L1 loss with a min max normalisat...
9769185c9b959c56394abb9a4f2c650c6ef766a20300a550334ebe51b1c49206
Python
1,077
32
""" This module define a L1 loss with min max norm """ # pylint: disable=W0223 import torch import logging from utils.utils import select_output_lm class L2LossMinSumNorm(torch.nn.modules.loss._Loss): # pylint: disable=protected-access """ This class define a specific loss : L1 loss with a min max normalisat...
e7f58a99924b06421c70a715bec3243dd32f1dae19d65eead98f3c7299b3c332
Python
1,077
39
""" net """ import torch from torch import nn import torch.nn.functional as F class AttentiveNet(nn.Module): def __init__(self, input_size, hidden_size) -> None: super().__init__() # self.liner1 = nn.Linear(input_size, hidden_size) self.cov2 = nn.Conv1d(hidden_size, hidden_size, kernel...
e4eb394543301c830907917d05fd6900b670fab127f6ebe08377f2e5e8cb7b60
Python
1,078
30
"""Phase 5(e): backward op module attribution unchanged by refactor.""" from __future__ import annotations import torch import torchlens as tl def test_backward_pass_module_attribution() -> None: """Backward capture keeps forward-op module attribution available.""" torch.manual_seed(0) model = torch.n...
f32ba6aaefb1d95797d692ece1c036ed02a051bcfde292d4d2836fa9232db1c0
Python
1,078
42
from sys import argv from msp import MSP, rbnsp_split_90 msp = MSP() msp.file = __file__ msp.seed = int(argv[1]) msp.architecture["num_motifs"] = 172 msp.architecture["channels"] = 200 psam_model = dict( type="PSAMMotifModel", motif_spec=dict(type="rbns"), exclude_names=("3P", "5P") + tuple(rbnsp_split_90...
38e9c7d508a33f24ee933e66cf725a6e8cd3b41f6a3e8bbeca7616d8ef4d9376
Python
1,079
32
" Many losses code is from https://github.com/JunMa11/SegLoss/tree/master/losses_pytorch" from losses.dice import * from losses.distillation import * __all__ = ['all_losses', 'get_loss'] all_losses = { 'CrossEntropyLoss': torch.nn.CrossEntropyLoss, 'MSE': torch.nn.MSELoss, 'BCE': torch.nn.BCELoss, 'Ex...
61a3d10cd7997049be7b56e32327afea656c1c748665eadd154e2cf2681224f9
Python
1,079
26
""" 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. """ from nfp.frameworks import tf def masked_mean_squared_error(y_true, y_pred): mas...
8df5156a4f796ade8f642dfb1e9615c37b727590ee3d6a85c0b1b5d9cf008aca
Python
1,079
33
import larvaworld from larvaworld.lib import reg, param from larvaworld.lib.util import AttrDict from larvaworld.lib.param.custom import restore_param_class, _deserialize_param_value # A=reg.LarvaworldParam.set_vparam(param.Number(default=1.0, bounds=(0.0, 10.0), doc="Custom v parameter"))() # print(A.param.objects()[...
a2f96032c8dfa5bf5989601d13011745cb219d117905f67a8066f4bb1b897359
Python
1,079
40
def main(): import os import pkg_resources import sys from PyQt6 import QtCore, QtGui, QtWidgets from impose.gui.main import Impose from impose._version import version as __version__ for arg in sys.argv: if arg == '--version': print(__version__) sys.exit(0)...
7ae8dad4a1560be10aa3443c0896214e8322659a59e37b30a0927272a7894524
Python
1,080
31
import argparse import os import torch import numpy as np from transformers import * from src.data.Batcher import Batcher from src.adapet import adapet from src.utils.Config import Config from src.eval.eval_model import dev_eval if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument...
eaaa5bdd73c4cd7be6fe76f78b507f1b18e3a19630b41eff93086bc3683039ae
Python
1,080
33
"""AST guardrail tests for grad-preserving fastlog paths.""" from __future__ import annotations import ast from pathlib import Path def _python_files() -> list[Path]: """Return files whose predicate-mode branches must avoid no_grad.""" return [ *Path("torchlens/fastlog").glob("*.py"), Path(...
25fdaffa8494879445e214da9025ed3ce7a980f4ac5f9906ab7b1ba7ba729a97
Python
1,081
38
#!/usr/bin/env python import argparse import os import shlex import subprocess parser = argparse.ArgumentParser() parser.add_argument("-i", "--input", help="Input file name") parser.add_argument("-o1", "--output1", help="tabular output file") parser.add_argument("-s", "--parameters", help="arguments") args = parser.p...
c73cf734ecdfc0705f2d1a44f47b0cf8280db9dab14f489d1c78c879fa9bfc98
Python
1,081
35
""" A few ABFs were recorded with incorrect scaling factors. This script can fix them. """ import os import sys import glob import time import numpy as np import matplotlib.pyplot as plt PATH_HERE = os.path.abspath(os.path.dirname(__file__)) PATH_DATA = os.path.abspath(PATH_HERE+"../../../data/abfs/") PATH_SRC = os.p...
ffad9f07878cd8d05d9d1132af6a9ab55065866adea83528c242d756c7867345
Python
1,081
49
#!/usr/bin/env python # coding: utf-8 # In[4]: import numpy as np import argparse import tempfile import sys from pathlib import Path # In[6]: def sample_from_bed(bed_filepaths, n): total = 0 for bed in bed_filepaths: with open(bed) as f: for _ in f: total += 1 ...
130a22323f0e4665e4f7da2cfd2d9af3359a1d853676387166abc5c33b7491f3
Python
1,083
44
#!/usr/bin/env python """ Convert from GFF file to interval index file. usage: python gff_to_interval_index_converter.py [input] [output] """ import fileinput import sys from bx.interval_index_file import Indexes from bx.intervals.io import GenomicInterval from galaxy.datatypes.util.gff_util import ( conve...
2d50df5585e7e1cb650a896dc6e1d5dd184e0333f67a49a5ae5b26ccd7927e43
Python
1,083
40
import sys import os import re import glob import io import time import base64 import random import tempfile import subprocess import nibabel import json import nrrd import numpy import cv2 import urllib.parse import xml.etree.ElementTree as ET import nibabel as nib import numpy as np import pickle a...
ad2ae0586a1f1fc1acb3522b3b0b67448d2894fdc7f0dbd48cf193b6f74abe60
Python
1,083
29
""" Ensure discontinuous sweeps (sweeps whose sweep length is less than their inter- sweep interval) are loaded properly and work with comments. I confirmed there is a problem on 2018_11_16_sh_0006.abf: print(abf) says total length of 0.10 min when it should be 5 minutes. Inter-sweep interval seems to be defined by ...
7f1f222b5a653f0c72d1a404c74ae4a2a49cba3217c897a27f899b665a3f12f3
Python
1,084
37
# Generated by Django 3.0.3 on 2020-02-27 10:47 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('biomedisa_app', '0051_upload_queue'), ] operations = [ migrations.RemoveField( model_name='upload', name='scale_size...
c114e7d2afa0b782a3603c6251c3f9acd2f906a44173b9d4f915d28505c8ab7f
Python
1,084
35
import os import shutil import torch import yaml def save_checkpoint(state, is_best, filename='checkpoint.pth.tar'): torch.save(state, filename) if is_best: shutil.copyfile(filename, 'model_best.pth.tar') def save_config_file(model_checkpoints_folder, args): if not os.path.exists(model_checkpoi...
d7648b96084c36875dfdbbbb590a248a51136de78c3eaa372949d27e757f61b6
Python
1,084
22
from __future__ import annotations from .bootstrap_count_curve import generate_bootstrap_count_curves # noqa: F401, E501 from .count_curve import count_point # noqa: F401 from .count_curve import generate_count_curve # noqa: F401 documentation = None """ This submodule provides functionality for generating count...
14e40fc14edcf3551d2aaf120906a9c0cd293b061c8e4c4f3b80a49a18cc5af9
Python
1,085
38
from urllib.parse import ( quote_plus, urlencode, urljoin, ) from galaxy.util import commands def count_special_lines(word, filename, invert=False): """ searching for special 'words' using the grep tool grep is used to speed up the searching and counting The number of hits is returned. ...
1709d6ac3b6ddbf564c8d91d6d4530cdbfd192ac0562967925032178cc3f0f9d
Python
1,085
39
import pytest from celery import states class test_state_precedence: @pytest.mark.parametrize('r,l', [ (states.SUCCESS, states.PENDING), (states.FAILURE, states.RECEIVED), (states.REVOKED, states.STARTED), (states.SUCCESS, 'CRASHED'), (states.FAILURE, 'CRASHED'), ]) ...
49c016ff9e08b5b4396fb48392157163e88bec9b41b0024f96c963c9bad77141
Python
1,085
37
import logging import time from codecarbon import track_emissions from codecarbon.external.logger import logger @track_emissions( measure_power_secs=5, api_call_interval=3, save_to_prometheus=True, ) def train_model(): """ This function will do nothing during (occurrence * delay) seconds. The...
72bb4f9f8ae76015ff4ae3d836ca6594f6c7a84def82a05e1292cc36749cd585
Python
1,085
31
import os from abc import ABC, abstractmethod from typing import Any, Sequence, Dict from bioconfpred.conf_ensemble import ConfEnsembleLibrary class Evaluator(ABC): """Base class for evaluators that assess rankers/model on conformer ranking/RMSD prediction :param evaluation_name: Name of the current evalu...
83f597f1ca67091c8f15b1923d0474a64bb00a4688733340c6ba12ad640a43ff
Python
1,085
35
import numpy as np import pytest import gym from gym.wrappers import TransformObservation @pytest.mark.parametrize("env_id", ["CartPole-v1", "Pendulum-v1"]) def test_transform_observation(env_id): def affine_transform(x): return 3 * x + 2 env = gym.make(env_id, disable_env_checker=True) wrapped_...
a247116dd624be15b6f2d9beaf7452be938206549966890d6d4503afa838e126
Python
1,085
35
"""AST guardrail tests for fastlog detach behavior.""" from __future__ import annotations import ast from pathlib import Path def _python_files() -> list[Path]: """Return files whose predicate-mode branches must avoid bare detach.""" return [ *Path("torchlens/fastlog").glob("*.py"), Path("t...
b596e08396c23a99f56c1e9fe36ecf0e7b66a5f972f42e4d342daf07d46314d3
Python
1,085
28
''' Copyright 2021 Twente Medical Systems international B.V., Oldenzaal The Netherlands 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.org/licenses/LICENSE-2.0 Unless requir...
df7c95e5075570e55ce3d8b9c56a83b393fb80bb23157b4c5c7ac557426aad33
Python
1,085
40
from sys import argv from msp import MSP msp = MSP() msp.file = __file__ msp.seed = int(argv[1]) msp.architecture["num_motifs"] = 82 msp.architecture["motif_model_spec"] = dict( type="PSAMMotifModel", motif_spec=dict(type="rbns"), exclude_names=("3P", "5P"), ) msp.architecture["sparse_spec"] = dict(type="S...
4f6c28242fd11797a3d7b6ec5f9cd523c4ea3e6d22eadf6e35404cf34c971e1c
Python
1,086
33
from Bio import SeqIO import sys def split(rna_file,protein_file,prefix): is_coding = lambda x: x.startswith('XM') or x.startswith('NM') pc_storage = [] nc_storage = [] for record in SeqIO.parse(rna_file,'fasta'): if is_coding(record.id): pc_storage.append(record) else:...
343bddba52fb2e21bead0907a77166b03ef546f6d1d457c93ce342f6eef7604b
Python
1,087
19
import os from os.path import dirname, join # PYTHONPATH=/home/chansingh/llm-tree/experiments python /home/chansingh/llm-tree/experiments/01_train_model.py --use_cache 0 --subsample_frac 0.1 --refinement_strategy None # PYTHONPATH=/home/chansingh/llm-tree/experiments python /home/chansingh/llm-tree/experiments/01_trai...
42d78fbc6e120dd361860db214b8f206cc97dcbf6af57c796ecaf43266c324a5
Python
1,087
41
"""Conversion functions.""" import numpy as np ################################################################################################### ################################################################################################### def dict_array_to_lst(in_dict): """Convert any numpy arrays presen...
76db2c724a92fd78df794c198a7da65f9010c0646f74b2e49213f1c291c2ed13
Python
1,087
32
import numpy as np import torch def gabor_kernel(frequency, sigma_x, sigma_y, theta=0, offset=0, ks=61): w = ks // 2 grid_val = torch.arange(-w, w+1, dtype=torch.float) x, y = torch.meshgrid(grid_val, grid_val) rotx = x * np.cos(theta) + y * np.sin(theta) roty = -x * np.sin(theta) + y * np.cos(...
afc6556667a03a6168de0012f2fb27daceda7949476a62c4fc731ea33b032c31
Python
1,087
35
""" MetaCyto analysis datatypes. """ import logging from galaxy.datatypes.sniff import FilePrefix from galaxy.datatypes.tabular import Tabular log = logging.getLogger(__name__) class mStats(Tabular): """Class describing the table of cluster statistics output from MetaCyto""" file_ext = "metacyto_stats.txt...
e6de9ced0e7d6fb180dd64d839be8b23f32c280e2ba3916e8e69ef86171e84f6
Python
1,087
54
""" test_ca.py Unit tests for ca imaging processing. """ import unittest import pathlib from fused_org_ephys import FusedOrgCa ################################ class TestMUASpikes(unittest.TestCase): def setUp(self): # Calcium class fpath = pathlib.PurePath('tests', 'test_data', 'gcamp', 't...
fe3ab3996db1c93ea0abc13066864d2bcf58c9be3fb98c3a62f094049a05421a
Python
1,087
34
"""Test functions for specparam.metrics.pointwise.""" from specparam.metrics.pointwise import * ################################################################################################### ################################################################################################### def test_compute_poin...
a68478b938a75bdf339c2d2461de0117f9902ccf909433331d30c97249d25e2d
Python
1,088
38
""" This module define an interface for the differents datasets """ import logging import torch class GenericDataset(torch.utils.data.Dataset): """ This class is an interface for the datasets """ def __init__( self, dataframe, limit_size_input_prot, config, col...
b80a57014df574fa253bb90474b16964226b855964ebb8873beaaa15a0861367
Python
1,088
36
import csv numb_to_letters = {'0': 'A', '1': 'B', '2': 'C', '3': 'D', '4': 'E', '5': 'F'} def csv_processor(file_name_input, file_name_output): access_mode_input='r' access_mode_output='w' f_input = open(file_name_input, access_mode_input) f_output = open(file_name_output, access_mode_output, newline='') ...
3af02b58f0864ae2a2f2a2e97f1f4d77909d72f34808e218c48641755895d69e
Python
1,089
30
import time from types import SimpleNamespace import pytest from celery import states, uuid from celery.result import AsyncResult, GroupResult @pytest.mark.celery(result_expires=1, result_chord_expires=60) def test_chord_expires(app): if not app.conf.result_backend.startswith('cache+memcached'): pytest....
cc7b9d31d0c74cee40092d4623a985dd0c87dd2f0a646ca7a986dbfff645b426
Python
1,089
44
"""Miscellaneous Helper Methods. """ import logging from functools import wraps logger = logging.getLogger(__name__) class deprecated(object): """Mark a method deprecated This method is used internally to mark methods as deprecated. Deprecated methods will print a warning when used but will otherwi...
f311726221c17d9c443e2c62222e720161c4ea2b3ca5c72fa34c5f01d3143f34
Python
1,089
47
from sys import argv from msp import MSP msp = MSP() msp.file = __file__ msp.seed = int(argv[1]) msp.architecture["num_motifs"] = 32 msp.architecture["sparse_spec"] = dict(type="SpatiallySparseAcrossChannels") msp.architecture["motif_model_spec"]["motif_width"] = 13 msp.architecture["motif_model_spec"]["motif_feature...
3300613c9a56d43b7719f255dd5f15ea4800cbfa574f48c6ad9241d700935be1
Python
1,090
37
from __future__ import absolute_import from pip._internal.cli.base_command import Command from pip._internal.cli.status_codes import SUCCESS from pip._internal.exceptions import CommandError class HelpCommand(Command): """Show help for commands""" name = 'help' usage = """ %prog <command>""" su...
52aaaf9a001d396d9696e6f9c4ef2665340b8b3d3b8335fb781288f9f0f78ad9
Python
1,090
41
import sys import os import importlib import anndata as ad import pandas as pd import numpy as np from pyprojroot import here proj_root = str(here()) sys.path.insert(0, os.path.join(proj_root, "package/python")) from utils import set_file_logger import cembav2env importlib.reload(cembav2env) rsc_dir = os.path.join(p...
fca1b9013c86d4d1ea1af33a81c8c029e5273b5f1175f4987e894281baa8f8d9
Python
1,090
31
# LICENSE # # _This file is Copyright 2018 by the Image Processing and Analysis Group (BioImage Suite Team). Dept. of Radiology & Biomedical Imaging, Yale School of Medicine._ # # BioImage Suite Web is licensed under the Apache License, Version 2.0 (the "License"); # # - you may not use this software except in complian...
3216a4e698b4efb3b488f9d73df1e28c54d9ed52eb36625d03408728ae3233a3
Python
1,091
36
import sys from typing import TYPE_CHECKING if TYPE_CHECKING: from ._error_x import ErrorX from ._error_y import ErrorY from ._error_z import ErrorZ from ._hoverlabel import Hoverlabel from ._legendgrouptitle import Legendgrouptitle from ._line import Line from ._marker import Marker fr...
67a4c5926a517863e20e89a68e82eb092e9fcdf5fcd731ae147c347a9acf89fc
Python
1,091
41
import re import numpy as np import pytest from gym.spaces import Text def test_sample_mask(): space = Text(min_length=1, max_length=5) # Test the sample length sample = space.sample(mask=(3, None)) assert sample in space assert len(sample) == 3 sample = space.sample(mask=None) assert ...
a33a6c8493270d118db4154854018dc5d139a7591ecb074cbe5b0bff445c3f78
Python
1,091
37
# -*- coding: utf-8 -*- # Copyright (c) 2016-2018 Braintech Sp. z o.o. [Ltd.] <http://www.braintech.pl> # All rights reserved. """Module provides classes for exceptions raised from DataProxy.""" class NoNextValue(Exception): """Raised when end of data file is met in self.get_next_value().""" class NoNextTag(Ex...
c7f40d14d415033c101514768ad447f91f02f1c31287d0a32c668c60c19c490e
Python
1,091
38
import sys import collections from collections import Counter def get_AG(site_file): c = collections.defaultdict(lambda :0) with open(site_file) as f: for line in f: line = line.strip().split('\t') if len(line) == 1: continue else: chrID = line[0] position = line[2] ref_base = line[3] ...
59b15a0771237140d3bf07821e24a96dfd2b64f64dce43b0a6b81eb7797c283c
Python
1,092
38
import logging import time from codecarbon import track_emissions from codecarbon.external.logger import logger @track_emissions( measure_power_secs=2, api_call_interval=2, api_key="", save_to_api=True, ) def train_model(): """ This function will do nothing during (occurrence * delay) seconds...
650ca926dfa670495727adb786c88934eb0261a9082ee40549a532bf2a20efbb
Python
1,092
40
"""Wrapper for flattening observations of an environment.""" import gym import gym.spaces as spaces class FlattenObservation(gym.ObservationWrapper): """Observation wrapper that flattens the observation. Example: >>> import gym >>> env = gym.make('CarRacing-v1') >>> env.observation_sp...
b1d1b1b32f8548b2870bed3de112d26759681e03bc7b94ac34109332075a7556
Python
1,092
42
from __future__ import annotations import sys from typing import TYPE_CHECKING from loguru import logger from loguru._colorizer import AnsiParser if TYPE_CHECKING: from loguru import Record def _custom_format(record: Record) -> str: """Put together a context-aware custom format string. Args: r...
4f529ca6ee85a88c487a488807ff30cb8e4672307b9017f348174a67a5984347
Python
1,093
42
from werkzeug.routing import BaseConverter from flask import request from flask import session from flask import url_for def test_custom_converters(app, client): class ListConverter(BaseConverter): def to_python(self, value): return value.split(",") def to_url(self, value): ...
c81a30f41bf262113726fd07bf248c1dd3ad776b85df98974118e7c7e64a6d32
Python
1,093
32
import sys import graph import graphutils import matplotlib.pyplot as plt import utils def Characteristics(filename1, label1, filename2, label2): data1, celldata1, timedata1 = utils.LoadAllData(filename1) data2, celldata2, timedata2 = utils.LoadAllData(filename2) legendsize = 12 fontsize = 18 maj...
8f1a100a9d66d0e0b04c67e58b77a4afb797963dc617c21ee54a22664ac1e7b8
Python
1,094
31
import sqlite3 from .db import DB class DistrictInfoTable(DB): def __init__(self): self.table_name = 'PB_mucormycosis_district_cases' self.table_desc = 'Mucormycosis district-wise details for total cases, deaths, under treatment etc. Table on the last page of bulletins from June 2021' sel...
a4212b2d5615f7a1c0a62b693a60a698c8ee26a77ac31aa6f606d904a76bf513
Python
1,094
38
## Reading images and spectra exported as txt from Ntegra system import numpy as np def parse_txt_line(line): splitted = line.strip().split(',') floats = [np.float(el) for el in splitted] x = floats[0] y = floats[1] nu = np.array(floats[2::2]) v = np.array(floats[3::2]) return x,y,nu,v ...
a5a946522466181b6433db4d831e1d777aa910cbf4edb4ec8007f5abee47a5d8
Python
1,094
22
#!/usr/bin/env python3 '''quick script for generating a real model and caffe time command''' import argparse,sys parser = argparse.ArgumentParser(description='Train neural net on .types data.') parser.add_argument('-m','--model',type=str,required=True,help="Model template. Must use TRAINFILE and TESTFILE") parser.add...
b4dd40e17acccfd9e7bc46c7de75d80557ee72742032705bd0f739adbd947622
Python
1,094
34
import numpy as np from permacache import permacache, stable_hash from ..direct_inference_experiment import directly_infer_output @permacache("hsmm/analysis/validate_hsmm_directly", key_function=dict(sm=stable_hash)) def compute_hsmm(hsmm_spec, sm, config, limit, transformation_spec): b_s, a_s, y_s = [], [], [...
faeb2d0585331e66e2bd8e5ac5d4b261001dcc93de5ebf4c69b66a17a90eae38
Python
1,094
30
import os import numpy as np from mirp.extract_features_and_images import extract_images CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) def test_dicom_segmentation_mask(): from mirp._images.ct_image import CTImage, GenericImage image, seg_mask = extract_images( image=os.path.join(CURRENT_...
183cd62810527ba0d61948e487668da8a3291923767e90298364d2111fb97afd
Python
1,095
31
""" Double-check to ensure sweepUnitsY are always the right units for multi-channel abfs that mix voltage-clamp and current-clamp. It passed right away, so I think whatever bug used to be here got fixed a while back """ import os import sys import glob import time import numpy as np PATH_HERE = os.path.abspath(os.pat...
361fabc799e4913c4728ddc2e2d5e9b406def3edc348c38c7c4c6a579fa29cea
Python
1,095
26
''' Copyright 2021 Twente Medical Systems international B.V., Oldenzaal The Netherlands 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.org/licenses/LICENSE-2.0 Unless requir...
8a9aca3728edcdd5a771d097e59c111580f3df04432b10d916e95302ba74fd18
Python
1,095
37
import os import sys import numpy as np import pandas as pd import snapatac2 as sa2 clevel = "L1" out_dir = f"sa2_dlt2_{clevel}_subsets" os.makedirs(out_dir, exist_ok = False) # load snap data into memory: # - it consumes about 200G and loading process takes about 10 minutes. # - tscc has slow IO, so use this to make ...
b9ea11a707e2d326bf9f7cd58ed7b05778f2cd89c78985149c9a5eff3b06d358
Python
1,095
41
from hobj.benchmarks.mut_oneshot_benchmark import MutatorOneshotBenchmark from hobj.benchmarks.mut_highvar_benchmark import MutatorHighVarBenchmark from hobj.data.behavior import load_highvar_behavior, load_oneshot_behavior from hobj.data.images import ( load_image, list_image_ids, get_image_path, loa...
d96a5dd1e808837b9014172b68e44b883a2825acc16c6da6e6a3cf874379cf5c
Python
1,096
41
""" Helper functions for views.py. """ import numpy def getVal(form, element): return getattr(form, element).data def getData(form): """Retrieves the data from the form and places into dictionary.""" params = {} form_elements = form.elements form_fields = form.element_fields for i, element ...
df20b1fe769898718d6152cb6415bb9057bcdb23cc27b8e7c789e88be4a13a91
Python
1,096
38
""" Get the evoked response """ import sys sys.path.append('..') import argparse from config import fname, events_id import mne from pathlib import Path # Be verbose mne.set_log_level('INFO') # Handle command line arguments parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('subject', type=int...
016afe287b6e7592cb135fc2a09af5d39a5ffe5101240671a68f813e056bcf01
Python
1,097
33
from typing import Tuple import torch from torch import Tensor from torch.distributions import Uniform class AmplitudeRescaleTransform: """Implementation of amplitude rescaling transformation. This transform will rescale the amplitude of the Fourier Spectrum (`freq_image`) of the image and return it. A...
50ddcc14fb69feed12fd8041fae64457bdc70c9188fbb1c324aac39826b1717e
Python
1,097
41
#!/usr/bin/env python """ Calculates the reverse complement of a sequence. Usage: reverse.py <sequence file> <output file> <sequence file format> <output file format> <alphabet: dna or rna> """ import sys from Bio import SeqIO from Bio.Alphabet import DNAAlphabet, RNAAlphabet from Bio.SeqRecord import Seq...
d73bbea7af3bd7f27300315bf7e09af958ccede73c5b65182aeaab2a51b0c6bb
Python
1,097
35
"""The MISSING kwarg-omission sentinel. Historical note: this module also carried the additive-deprecation helpers (``warn_deprecated_alias``, ``TorchLensDeprecationWarning``, ``REMOVED_IN``). The 2026-08-19 shim-removal lane deleted every deprecation shim outright per the interim-phase ruling, so only the load-bearin...
30ab573eb3fcf347f8399b3e6d6f5572395f3f7bac9892db0edee71e035900d8
Python
1,098
31
import unittest import numpy as np from bdpy.ml import ensemble class TestEnsemble(unittest.TestCase): def test_ensemble_get_majority(self): '''Tests of bdpy.ml.emsenble.get_majority''' data = np.array([[1, 3, 2, 1, 2], [2, 1, 0, 0, 2], [2, 1, 1,...
51f81bdf7bbc90a97b3bf39d8e4887e082844aa5e6af5184aad1277e2b2448c7
Python
1,098
40
""" Refactor the AP detection module to provide a clean interface. You can always refactor the core later. """ import os import sys PATH_HERE = os.path.abspath(os.path.dirname(__file__)) PATH_DATA = os.path.abspath(PATH_HERE+"../../../data/abfs/") PATH_SRC = os.path.abspath(PATH_HERE+"../../../src/") sys.path.insert(0...
b1e1e909b48e8d7cb1b3b660fbf0e53abe6fafaa838874ae1810396b293f018a
Python
1,098
35
from torch import nn class SSLEvaluator(nn.Module): def __init__(self, n_input, n_classes, n_hidden=512, p=0.1): super().__init__() self.n_input = n_input self.n_classes = n_classes self.n_hidden = n_hidden if n_hidden is None: # use linear classifier ...
d9705ea076ee190192092ae2db10bd2817b7d2468c3a32956efc3801dfbd7ce1
Python
1,098
21
""" Copyright (c) 2022 EPFL-BBP, All rights reserved. THIS SOFTWARE IS PROVIDED BY THE BLUE BRAIN PROJECT ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE BLUE BRAIN PROJE...
4ce42e8ba6bae634e63472b50429d51e59911f6f70deb1fd355c53af82fad07a
Python
1,099
49
#!/usr/bin/env python # coding: utf-8 # In[1]: import tpot import pandas as pd import numpy as np from tpot import TPOTRegressor from sklearn.model_selection import TimeSeriesSplit from sklearn.model_selection import train_test_split # In[2]: features = pd.read_csv('Combined.csv') features['Timestamp'] = pd.to_...
645e16e1a233a5c7a42c0befc83b10e73a81e379f762857a4b89cfc02c76b3f1
Python
1,099
32
import matplotlib.pyplot as plt import torch def visualize_test_inference(model_, data_loader, test_batch_size, num_classes, device): X, Y = next(iter(data_loader)) Y = torch.nn.functional.one_hot(Y.long(), num_classes).permute(0, 3, 1, 2) X, Y = X.to(device), Y.to(device) Y_pred = model_(X) Y_pre...
bb9c662b3e0439120460dda4cdbe75b2358a1757ab143050b2104289c2fa808f
Python
1,099
35
import io import gzip import tempfile import subprocess import tqdm.auto as tqdm import pandas as pd from BCBio import GFF # first row of https://www.gencodegenes.org/human/ ANNOTATION_FILE = "https://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/release_40/gencode.v40.annotation.gff3.gz" gz_path = tempfile.mkt...
c13b96ce3fd9d1e618ba54b3ff7467ea0a41007c28e748121204eb618bc156c0
Python
1,099
29
import torch from imodelsx import explain_dataset_iprompt, get_add_two_numbers_dataset if __name__ == '__main__': has_gpu = torch.cuda.device_count() > 0 device = 'cuda' if has_gpu else 'cpu' llm_float16 = True if has_gpu else False # get a simple dataset of adding two numbers input_strings, ou...
37bb633838a32130d3895bdcb70e0d8818a43c5474a1170dfd7f31ddd59dab49
Python
1,100
35
""" Get the grand averaged evoked response """ import sys sys.path.append('..') import mne from config import fname, subjects import argparse from pathlib import Path # Be verbose mne.set_log_level('INFO') # Handle command line arguments parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('event...
07c82d5f9b384aa1c0c6b6675133c59b1c632b87b46f07d9d2ec8c137b935044
Python
1,101
29
import numpy as np import pandas as pd import math import pdb # ------------------------------------------------------ # Correct non standard TypeIDs for soma def set_standard_somaID(swc_matrix, nonstandard_somaID=None, swcPlus_remove=None): updated_swc_matrix = swc_matrix if not(nonstandard_somaID is None...
4ab3a1e567edbfe1574650fe0e6cecf0dbee8e71ba0f0e2457c0ed80e1a21f12
Python
1,101
39
from numpy import array, matrix, ndarray, result_type np_float = result_type(float) try: import numba as nb except ModuleNotFoundError: guvectorize_compute = None else: _nb_float = nb.from_dtype(np_float) def guvectorize_compute(target: str, *, cache: bool = True): return nb.guvectorize([nb.v...
aeba8c5d810068f8f29c5de7aeb41fb71295f18b1860049b52f42b1532b6e641
Python
1,101
32
from typing import List from uuid import UUID from carbonserver.api.infra.repositories.repository_users import SqlAlchemyRepository from carbonserver.api.schemas import User, UserAutoCreate class UserService: def __init__(self, user_repository: SqlAlchemyRepository) -> None: self._repository: SqlAlchemyR...
033d7dbd3f3874776824c2b47d058c756284299ddd77270cd3ab64eb2e9166e5
Python
1,102
40
"""Phase 4 multi-pass tests.""" from __future__ import annotations import torch import torchlens as tl import torchlens.utils as utils def test_trace_streaming_on_iterable_inputs() -> None: """Capture iterable inputs into one stacked root log.""" model = torch.nn.Linear(2, 2) traces = utils.trace_stre...
84acc4c7009e34c3fa3ac1e3984f9379c7606bd73bb0f3a88a86afc72c8817c1
Python
1,102
24
from neurogym.wrappers.block import RandomGroundTruth, ScheduleAttr, ScheduleEnvs, TrialHistoryV2 from neurogym.wrappers.monitor import Monitor from neurogym.wrappers.noise import Noise from neurogym.wrappers.pass_action import PassAction from neurogym.wrappers.pass_reward import PassReward from neurogym.wrappers.react...