sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
5b36ad5df27da6102174f484b93df168057c5b00bb85f0bb95b94dcb4c6f65a3
Python
1,431
27
import numpy as np import pkg_resources from vampire.germline_cdr3_aa_tensor import aa_encoding_tensors def test_aa_encoding_tensors(): aa_order = 'ABC' v_gene_list = ['TCRBV01-01', 'TCRBV02-01'] j_gene_list = ['TCRBJ01-01', 'TCRBJ01-02', 'TCRBJ01-03'] germline_cdr3_csv = pkg_resources.resource_filen...
ba9e6970cdbda491ae8e2cab16c3e07787c3ae3afcf13ccf9f65540468ab39b3
Python
1,431
56
""" Modeling of the energetics/metabolism based on the Dynamic Energy Budget theory """ from __future__ import annotations from typing import Any __displayname__ = "Dynamic Energy Budget" __all__: list[str] = [ # expose primary public classes/functions explicitly if needed later ] _LOADED: bool = False def _...
e2eed7a7eac5818742d79de218dd47d3d460dfa9af98dfc84cfd579844513362
Python
1,431
35
import os import sys import numpy as np import pandas as pd # EUGENE from seqproing import random_seqs, reverse_complement, encodeDNA # Simple script tp generate commonly used file types for testing EUGENE models if __name__ == "__main__": args = sys.argv num_seqs, seq_len = int(args[1]), int(args[2]) out...
c624551f45df3bce82531951b0541502a4a591566404a5f1be5d545359cdd146
Python
1,432
39
#!/usr/bin/env python from distutils.core import setup import libmushu setup( name = 'Mushu', version = libmushu.__version__, description = 'Brain Computer Interfacing signal acquisition software.', long_description = 'A Python library for BCI signal acquisition. It can be used as a stand-alone appl...
e84c5e05cdb7e6d2f27de2716e205c3f63e10d1ffc69b5a87445d8111722631d
Python
1,432
49
from sys import argv from msp import MSP msp = MSP() msp.file = __file__ msp.seed = int(argv[1]) msp.architecture["splicepoint_model_spec"] = dict( type="BothLSSIModels", acceptor="model/splicepoint-model-acceptor-1", donor="model/splicepoint-model-donor-1", ) msp.architecture["motif_model_spec"]["motif_...
fa2f7a14a73e215519964cbdf2a625cb6132c71b7f659831a441fddadde2d028
Python
1,432
49
from sys import argv from msp import MSP msp = MSP() msp.file = __file__ msp.seed = int(argv[1]) msp.architecture["splicepoint_model_spec"] = dict( type="BothLSSIModels", acceptor="model/splicepoint-model-acceptor-1", donor="model/splicepoint-model-donor-1", ) msp.architecture["motif_model_spec"]["motif_...
04d16c2ae20046b38d090bde4caac37271be25edd6cf83cc5f2a12d97253b84b
Python
1,433
47
# Copyright (c) 2022 PaddlePaddle Authors. 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.org/licenses/LICENSE-2.0 # # Unless required by app...
1e30856cc3c295ce1b590a2ee5b9f02d48343e293ccbb5b973383e4376654306
Python
1,433
1
import numpy as np import pandas as pd import time import random # [1] data preprocessing # df = pd.read_csv('./data/GSE76312_Single_cell_HSCs_expression_RPKM_table_gene_filtering_log.csv', index_col=0) # dimension = (genes x cells) sample_inf = pd.read_csv('./data/GSE76312_Giustacchini-Thongjuea_et.al_Cell_Annotation...
c1c53311305af6392598fbc4c14a14fd764dadab6f20a99f6cfaefd2a8c54d04
Python
1,433
49
from sys import argv from msp import MSP msp = MSP() msp.file = __file__ msp.seed = int(argv[1]) msp.architecture["splicepoint_model_spec"] = dict( type="BothLSSIModels", acceptor="model/splicepoint-model-acceptor-1", donor="model/splicepoint-model-donor-1", ) msp.architecture["motif_model_spec"]["motif_...
1c346fd2273ddd866d2e773f19795d13fe1664687f558de36a289e663b282e3e
Python
1,434
43
import sys import socket marcos_computer_path = "/home/nhattm/ToMoDL/ToMoDL/" # marcos_computer_path_datasets = "/home/obanmarcos/Balseiro/DeepOPT/datasets/" marcos_computer_path_datasets = "/home/nhattm/ToMoDL/datasets/" marcos_computer_path_metrics = "/home/nhattm/ToMoDL/ToMoDL/metrics/" marcos_computer_path_models ...
c618eee0b5ee9cfe2c71c1973373469c97aac9b19e2910f7230305367cd8a2bb
Python
1,434
38
import sys import subprocess ref_con_fname = sys.argv[1] cells_list_fname = sys.argv[2] mode = sys.argv[3] def compute_density_ratio_for_cell(cell_name, sex): # NOTE: the results change a little bit when you use impute versus contacts if mode == "impute": con_fname = "../merged." + cell_name + ".ca."...
d34abe4cb254f6cd0779219eacae4e86e7e6bcd8225e4b2b6897998e89b59f0b
Python
1,434
47
import mord from mord.datasets.base import load_housing from sklearn import linear_model, metrics, preprocessing data = load_housing() features = data.data le = preprocessing.LabelEncoder() le.fit(data.target) data.target = le.transform(data.target) features.loc[features.Infl == 'Low', 'Infl'] = 1 features.loc[featu...
4df9a007b5a4ff2b7af8373305bceddc54a0645579111989073703fc35bc203c
Python
1,435
45
from PyQt5 import QtCore import logging logger = logging.getLogger(__name__) class TrialDialogController(QtCore.QObject): dialog_done_signal = QtCore.pyqtSignal(name="TrialDialogController.dialog_done_signal") def __init__(self, caller, locations, object_files=None, parent=None): super(TrialDialogC...
747da16a8e019552aee14f52ee3a46955cde39d7ab21dc00d4b9ed02956c09aa
Python
1,437
39
""" This module define a converter """ import torch from converter.generic_converter import GenericConverter from utils.utils import select_output_lm class ConverterL5MostLikelyMediumAndLong(GenericConverter): """ This class select L/5 most likely contact pred """ def convert_output_and_target(self, ...
b1ca1fa4444debdf5908687a7e9a6c189d36663f3e28caa52c62ccee58369875
Python
1,437
44
from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import numpy as np import tensorflow as tf import pandas as pd import argparse import os import sys import pwd import pdb import csv import re import math import time df...
d06ba1435ea2e56599fb60debc9b8f135f9225f5892d7d24ba71401f7238d7b1
Python
1,437
47
from .bulletin import Bulletin import datetime class Haryana(Bulletin): def __init__(self, basedir): statename = 'HR' super().__init__(basedir, statename) self.bulletin_url_2020 = 'http://www.nhmharyana.gov.in/WriteReadData/userfiles/file/CoronaVirus/Daily Bulletin of COVID 19 as on {:...
71ba910ba05828ee3b9927205f724f01ff38af32c2115f593e2a40effdeb63ef
Python
1,438
42
"""Run ``celery upgrade settings`` as a real command on a real settings file.""" import subprocess import sys import pytest SETTINGS = ( b'BROKER_URL = "memory://"\r\n' b'CELERY_ALWAYS_EAGER = True\r\n' b'# \xc3\xa9t\xc3\xa9\n' ) def upgrade_settings(*args): # Deprecation warnings raised by the upg...
e5da12830e83b2b9563515594879fb5add9acea7d93d574b6c2c8bfbf03ffe59
Python
1,438
33
import numpy as np import math import pdb ## ------------------------------------------------------ ##-- remove bifurication TypeIDs 5 and 6 from NeuronStudio SWCs def remove_bifuc_neuronstudio(swc_matrix): updated_swc_matrix = swc_matrix for i in range(0,len(updated_swc_matrix)): if updated_swc_mat...
2216ac49122362281cd1f89bb1b26abf6117098e17dd5a0002be794d46dfc33e
Python
1,439
50
import sys,re,os import subprocess from Bio import SeqIO from Bio.Seq import Seq from Bio.SeqRecord import SeqRecord import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import numpy as np from utils import getLongestORF,parse_config, setup_fonts from tqdm import tqdm def parse(testfile,filename):...
ac4585b78ad427acfed6d6e2a10668a1f5e4d21b835a8759d2125bb260490c8b
Python
1,439
43
import sys import logging class StreamToLogger(object): """ Fake file-like stream object that redirects writes to a logger instance. Ref: https://stackoverflow.com/questions/19425736/how-to-redirect-stdout-and-stderr-to-logger-in-python """ def __init__(self, logger, level): self.logger ...
755c76b71a05d74dd3b2abd03fad7f4e65863f9357ca109aaaa0c2b10190156d
Python
1,440
43
import pytest import numpy as np from causal_optoconnectics.tools import compute_trials def test_compute_trials_from_spike_times(): s = np.array([1, 2, 3, 4, 5]) a = np.array([ .1, .99, # before 1 (Z True) 1.01, 1.02, # after 1 (X True) 2, # before 2 (Z True) 2.13, # after 2 (X...
ce8971dcbebdd24531ea9e61ba29d65aff5b2f4e8884a8fb3110518fc8a656ae
Python
1,440
56
"""Dueling DQN.""" import argparse from pytorch_lightning import Trainer from pl_bolts.models.rl.common.networks import DuelingCNN from pl_bolts.models.rl.dqn_model import DQN class DuelingDQN(DQN): """PyTorch Lightning implementation of `Dueling DQN <https://arxiv.org/abs/1511.06581>`_ Paper authors: Ziyu...
c5868265a79624c061cf2dc98d267bde614c18e103dc472df49cff0ccec34055
Python
1,441
48
from __future__ import annotations import numpy as np from larvaworld.lib.model.envs.arena import Arena class _DummyAgent: def __init__(self, pos, radius: float): self.pos = np.array(pos, dtype=float) self.radius = radius class _DummyAgents(list): @property def pos(self): retur...
c882d9e2f074aa98916955091b996d44da364b5a7b0b99dc4796c1c161ff327b
Python
1,441
44
import sys from typing import TYPE_CHECKING if TYPE_CHECKING: from ._cumulative import Cumulative from ._error_x import ErrorX from ._error_y import ErrorY from ._hoverlabel import Hoverlabel from ._insidetextfont import Insidetextfont from ._legendgrouptitle import Legendgrouptitle from ._...
f137e1f71edfb66cbb2bf59333d223707679c92105d9116d9b37a39fb2831901
Python
1,441
58
import re path = f"binary_all_acc_tmp.txt" psam_idx_acc_dict = dict() with open(path, 'r') as f: i = 0 for line in f: if i % 3 == 0: idx = int(line[:-1]) if i % 3 == 2: content = float(line[:-1].split("; ")[0].split(": ")[1]) psam_idx_acc_dict[idx] = content...
106a6ed8854b868650cb1b2ca0ac770941296107a1bfaaddc8ebf00a810db189
Python
1,442
66
import h5py from map_protein_name import get_map_protein import random import numpy as np map_index = get_map_protein() data = h5py.File("tiny_binary_dataset/protein_47/rbns_train.h5", "r") # L = data["L"][: # print(max(L)) X = data["X"][:]# .astype(int) L = data["L"][:]# .astype(int) Y = data["Y"][:]# .astype(int) t...
32580b4ddc96ad49517b34cf8a2292bb91bc5f10c25f3e946406875ff42f7049
Python
1,442
70
import numpy as np from neuron import h, gui from neuron.units import ms # Send a message from `spiker` to `receiver` using a # `net_event` in a NET_RECEIVE block. # # Since the NET_RECEIVE block in the `spiker` needs to # be triggered we add a `stim`. def simulate(): nseg = 1 s1 = h.Section() s1.nseg ...
432ca2dba282b682a0d60439c45359f15d7b9cf7ecf8f9e3aa575472f2685957
Python
1,442
46
""" More thorough sweep value validator created in June 2020. Checks EVERY value of EVERY sweep of EVERY channel of EVERY ABF to ensure it matches what we expect and does not change. """ try: import sys import pytest import datetime import inspect import numpy as np import glob # this ensu...
85471d1c1ce90df694606a499bfc25478c66beed5e1edc72d7c63fcc89b3a7aa
Python
1,442
54
import h5py from permacache import permacache @permacache("modules/additional_inputs/gene_element_counts") def gene_element_counts(datafile_path, index, cl_max): """ Get the counts of each nucleotide in a gene. Parameters ---------- datafile_path : str Path to the datafile. index : i...
87d61081adadd695919c11f9a64342ca6e291fdf51ccc0217c3086f7ba781535
Python
1,442
44
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Example script demonstrating how to use import and pre-process the eyelink data. @author: Florent Meyniel """ import re import numpy as np import matplotlib.pyplot as plt from preprocess import pupil # initialize the class data = pupil() # import the recording in p...
381f30a70a8b6647a4a400798c33e9a722e48df18b374718f454b3340524e92a
Python
1,443
75
""" Diverging color scales are appropriate for continuous data that has a natural midpoint \ other otherwise informative special value, such as 0 altitude, or the boiling point of a liquid. The color scales in this module are \ mostly meant to be passed in as the `color_continuous_scale` argument to various \ functions...
4597c1e013a38f7913882bd83b2ea4c4376df8219ce191f9cfe9aeb33d6bacb3
Python
1,443
42
import unittest from argparse import Namespace from deepspeech_training.util.importers import validate_label_eng, get_validate_label from pathlib import Path def from_here(path): here = Path(__file__) return here.parent / path class TestValidateLabelEng(unittest.TestCase): def test_numbers(self): ...
4dd1631a20fe00d00d3e24a94967f1d07f6502e6f575bbee864a844dc8fab148
Python
1,443
52
""" This script creates the histones folder for deepregfinder """ import os import subprocess ################## Edit the following ################## histone_marks = ['H3K9ac', 'H3K27me3'] cell_line = "K562" ######################################################## os.mkdir("histones") os.chdir("histones") for hist...
1279f1a6f0675e9782537753cfa248f4ee37f70ba43f3a4f7c496095108af1dd
Python
1,444
39
import cv2, os, math, operator, sys, time import numpy as np from scipy.signal import find_peaks def imRescale2uint8(im): '''Rescale and convert to 8 bit ([min max] to [0 255])''' imOffset = im - np.min(im) imOut = 255 * (imOffset / np.max(imOffset)) return(imOut.astype('uint8')) def imLevels(im,low,h...
aa76ef0b8498e287509ec5f3a65c220b3543e9129c57e7f5b4069049d6bfcea3
Python
1,444
52
""" This example demonstrates how to use CodeCarbon with command line tools. ⚠️ IMPORTANT LIMITATION: CodeCarbon tracks emissions at the MACHINE level when monitoring external commands via subprocess. It measures total system power during the command execution, which includes the command itself AND all other system p...
b5355702d40d09316c9c5240d46423f4ee26799ecace736886501b9279d20865
Python
1,445
55
import argparse import pandas as pd import numpy as np import os, sys, shutil, importlib, glob from tqdm.notebook import tqdm import celloracle as co from celloracle import motif_analysis as ma from genomepy import Genome import scanpy as sc import pyarrow.parquet as pq import pyprojroot packdir = f"{pyprojroot.here()}...
f77cee28d084ee970c0f72b9b4ce4731e54243995f251ff486d169a2db6039e5
Python
1,445
52
"""Task Annotations. Annotations is a nice term for monkey-patching task classes in the configuration. This prepares and performs the annotations in the :setting:`task_annotations` setting. """ from celery.utils.functional import firstmethod, mlazy from celery.utils.imports import instantiate _first_match = firstmet...
118f013418ff47c1cacae1233d2442a312eab29f1a7f39220b93f270011332a5
Python
1,446
34
import mne import pandas as pd import numpy as np from surfer import Brain data_fpath = 'data/zmap_feature_importance_full.txt' subjects_dir = 'data/subjects' df = pd.read_csv(data_fpath, sep='\t', index_col=0, header=None, names=['feature', 'score']) df['score'] = df['score'].str.split(' ').str[0].astype(float) pri...
670b937339948a3cf1cc37520dcba80cefef339e0a2e4734085714010ed0d117
Python
1,446
47
__all__ = [ "gmean", "mean_ale", "mean_alm", "mean_euclid", "mean_harmonic", "mean_kullback_sym", "mean_logdet", "mean_logeuclid", "mean_power", "mean_riemann", "mean_wasserstein", "maskedmean_riemann", "nanmean_riemann", "median_euclid", "median_riemann", ] ...
ee738f6483dc6fc2fcdbd2c1b6a81bcb77451b5f29ef98507ee75ddb541e0b86
Python
1,446
26
"""Oracles wave-0 harness: registry, censuses, surface walk, static lints. This package is the wrongness-defense machinery commissioned by the oracles panel (plan of record: megaplan MEMO.md row P02; normative spec: the oracles MEMO.md section 10 items 1-5). Doctrine in force here: - Every defense is a predicate plus...
985d15208b22916caaa73758171b5a329986e82b35ed67ad2e64322bd4d635d3
Python
1,447
48
# Author: Christian Brodbeck <christianbrodbeck@nyu.edu> import logging from eelbrain import datasets, testnd from eelbrain.fmtxt import html from eelbrain.report._auto import result_report from eelbrain.testing import requires_framework_build @requires_framework_build def test_result_report(): "Test result_repo...
e0704cd3210961f4d12fd6c82ad525ff8080c778af4e7aa0c6f516dfed02806a
Python
1,447
40
import numpy import os import sys import voxcell from projection_voxels import BinarySplitVoxelArray, BinarySplitModel from projection_voxels.binary_split_model import RootRegion if __name__ == "__main__": this_root = os.path.split(__file__)[0] sub_path = "input/configuration" if not os.path.isdir(os.path...
1de6e72985bd807510bdb1035362d6cd86400c4e0adae82462fd3d6f917d883a
Python
1,448
61
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"] = dict( type="AdjustedMotifModel", model_to_adjust_spec=dict( ...
8ffec739aa3ec7e48b31e54b93c70e5b72d268a03755bcdfb70b42c4c6ee5db9
Python
1,448
43
from unittest.mock import Mock import pytest from celery.backends.consul import ConsulBackend pytest.importorskip('consul') class test_ConsulBackend: def setup_method(self): self.backend = ConsulBackend( app=self.app, url='consul://localhost:800') def test_supports_autoexpire(self): ...
66f5855c4f685d58923057e8bcfc974656ef4b1123b854de731655ea51787106
Python
1,449
32
from __future__ import generators import logging import glob, os, functools import gc import pandas as pd import numpy as np import sys import math from dateutil import parser sys.path.append('../TM2_segmentation') df_albumin = pd.read_csv('/media/sda/Anna/TM2_segmentation/itmt_v2.0/Albumin.csv') df_scan_date = pd.rea...
cc8d58ffa5a75ff0f8608dfa5151867342c9544b89af3f61016385f0bfdb9f01
Python
1,449
50
"""Add reason column on invocation table Revision ID: 3100452fa030 Revises: 518c8438a91b Create Date: 2023-01-13 16:13:09.578391 """ from sqlalchemy import ( Column, ForeignKey, Integer, String, ) from galaxy.model.custom_types import TrimmedString from galaxy.model.migrations.util import ( crea...
45ad4b0224d0f517670cd93d57e049db8862ea30a5e12bf6d90ce2095a55b91f
Python
1,450
34
import numpy as np import pandas as pd def create_edge_network_representation(adjMatrixBootstrap, weight_matrix, gene_names): """ CreateEdgeNetwork - Create Edge file. This is needed before hypothesis test q-value derived adjacency matrix can be consumed by R network analysis code. ...
03559dc9eb0fb9dc0770610a5df27cda384a3ac43295201b129835971ff72af2
Python
1,451
51
#!/usr/bin/env python """ Input: fasta, int Output: tabular Return titles with lengths of corresponding seq """ import sys def compute_fasta_length(fasta_file, out_file, keep_first_char, keep_first_word=False): infile = fasta_file keep_first_char = int(keep_first_char) fasta_title = "" seq_len = 0 ...
0ea23b447aef3b6ed60fbd1ff8d745fe81edda90e79959181c7214449b1295ff
Python
1,451
37
"""Test to_scalabel.py.""" import copy import os import unittest from scalabel.label.io import load from bdd100k.common.utils import load_bdd100k_config from bdd100k.label.to_scalabel import IGNORED, bdd100k_to_scalabel class TestBDD100KToScalabel(unittest.TestCase): """Test cases for bdd100k to scalabel conver...
15f6d0523015714163a4838fb6f881c7d67ce3f81d82b7760780f11bed8f8709
Python
1,451
45
# this may not work import numpy as np import matplotlib.pyplot as plt import pandas as pd from input_parameters import dataset_name, channel_count, thickness_channel, \ processed_metadata_filepath, processed_imagedata_filepath, saved_model_filepath from stratify import index_split df = pd.read_json(processed_met...
688e4aab82a6eba158dd2bc6b309d9d4ebaf8e1824e35b4f60af94da1c472195
Python
1,451
50
from conftest import requires_matplotlib import numpy as np import pytest from pyriemann.utils.viz import ( plot_embedding, plot_cospectra, plot_waveforms ) @requires_matplotlib def test_embedding(get_covmats): """Test .""" n_matrices, n_channels = 5, 3 covmats = get_covmats(n_matrices, n_cha...
758d862ce003984c53a3403011dd6dd5329841674c6beb0475616eb2370c098a
Python
1,451
39
from spacy.lang.en import English import numpy as np from sklearn.feature_extraction.text import CountVectorizer from imodelsx.util import generate_ngrams_list def test_ngram_list(): nlp = English() def spacy_tokenizer(doc): return [str(x) for x in nlp(doc)] for x in [ 'here is a sample m...
c6fe54424a9f41b69a4a1c8f6107ac694e1bdbafc86ee50dd7df7df1ff218f3d
Python
1,451
49
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...
350e465d06f033bcd56b1e42ca7b9c9cfb6eca5eef48846346cdc0c57beb1bb7
Python
1,452
58
#!/usr/bin/python import sys import os import re import numpy as np import ConfigParser import json def main(): ##### check argument ##### if len(sys.argv)<2: sys.exit("ERROR: not enough arguments\nUSAGE ./celltypePlotData.py <filedir>") ##### get command line arguments ##### filedir = sys.argv[1] ##### add '...
630f037c7f4d1074e7ef4062eef9d3afbbd15eeeb58c04ecf08e445bff6e03c9
Python
1,452
52
#!/usr/bin/env python """ Connects to the URL specified and outputs builds available at that DSN in tabular format. UCSC Main gateway is used as default. build description """ import sys import xml.etree.ElementTree as ElementTree from galaxy.util import requests def getbuilds(url): try: text = reque...
809e3d751098d39263292cc6b12e3b4c77443c9b54c2350709d33bde0215523b
Python
1,452
45
from typing import List, Tuple, Union from warnings import warn import torch from torch import Tensor from lightly.data.multi_view_collate import MultiViewCollate def test_empty_batch() -> None: multi_view_collate = MultiViewCollate() batch: List[Tuple[List[Tensor], int, str]] = [] views, labels, fnames...
8ddff8302d29d77b688ee712c123b3c070d16e28a69fa1f89e2810cd89b46db1
Python
1,452
41
# test_triggerprecision.py # Copyright (C) 2013 Bastian Venthur # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # T...
9ea87cbae50ac6ebff36f31ebf15c3e3405639345fbb3bff5076fe3683a59e10
Python
1,452
62
"""utility functions""" from functools import reduce import numpy as np def chunks_of(length, list_): """ Splits list into sublists, each of length n. If the length of the list is not divisible by n, the last sublist will have length len(list) % n. The result is provided as a generator. >>> li...
c33c1c87540364ea35a6b3a27fbf621c70cb5ee1f2debced9186d28d55b3913c
Python
1,452
51
import os import random from typing import List import matplotlib.image as mpimg import matplotlib.pyplot as plt import tensorflow as tf from matplotlib.axes import Axes from matplotlib.figure import Figure from analysis.visualization import Visualizer from utilities.plotting import transparent_cmap os.chdir("../../...
4a0ed059475f6e1a73e0395bf0e5d8a81a6a13c9afed225f9818ebf83f733779
Python
1,453
58
"""Util functions for FASTA format.""" __author__ = "Gianluca Corrado" __copyright__ = "Copyright 2016, Gianluca Corrado" __license__ = "MIT" __maintainer__ = "Gianluca Corrado" __email__ = "gianluca.corrado@unitn.it" __status__ = "Production" def import_fasta(fasta_file): """Import a fasta file as a dictionary....
87288d87a0711a9d49e49efcf74774de8985c695c25aaab250da933dd0e53ca1
Python
1,453
58
from tensorflow import keras from tensorflow.keras import layers from keras.utils.vis_utils import plot_model import tensorflow as tf import numpy as np import pandas as pd from load2data import extraData import random import os import random import torch data = pd.read_csv("D:\JWJ\PycharmWorkplace\Data\\n...
2778b7c035d917bb0909ec6ee2f9d61ccba030ff8ae635ff65a52c133ec5afca
Python
1,454
62
import os import tempfile import pytest from flaskr import create_app from flaskr.db import get_db from flaskr.db import init_db # read in SQL for populating test data with open(os.path.join(os.path.dirname(__file__), "data.sql"), "rb") as f: _data_sql = f.read().decode("utf8") @pytest.fixture def app(): "...
755509531fc2b191c6f39a4ab9abab5a3fe1c0ffef48f30864c0232a846f65b3
Python
1,454
55
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...
f64f04ea03eef8e1080f255abfc4ca489e6880b3788e2164019216bca1484f98
Python
1,454
55
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...
668b117c3695b48ea77e4b2d9eacaf09d737e6cdeb6e27e9f767cd080de57928
Python
1,455
49
import pytest # In case pytest-nunit is not installed, defines a dummy fixture try: import pytest_nunit except ModuleNotFoundError: @pytest.fixture def add_nunit_attachment(request): def noop(file, description): pass return noop # Command line options for pytest must be adde...
755b1fe684b35efd41546bfc4d002de03a5a31e8e24db7bc6b8e89657d06f2b7
Python
1,455
35
from __future__ import generators import logging import glob, os, functools import gc import pandas as pd import numpy as np import sys import math from dateutil import parser sys.path.append('../TM2_segmentation') path_to_labs = '/media/sda/Anna/TM2_segmentation/itmt_v2.0/labs_csv/WBC.csv' df_albumin = pd.read_csv(pa...
cccab142f2b2bcbca574baf8e82482a69058d2d5ee0a32cdbb153651a86fd4d6
Python
1,455
36
import argparse from models.mn.model import get_model from helpers.utils import NAME_TO_WIDTH from helpers.receptive_field import receptive_field_cnn def calc_receptive_field(args): # model if args.model_width: # manually specified settings width = args.model_width model_name = "mn{}"....
68cd3c895a389877472767d998add54f7b990fdd62c74e86d7cead8e5445c362
Python
1,456
47
"""Guard a release tag against the packaged version. Used by the release workflow: given the pushed tag (e.g. ``v0.7.0``), confirm its version matches ``setup.py`` and refuse to publish on a mismatch (which would otherwise upload the wrong version under the tag). Also reports whether the version is a PEP 440 pre-relea...
db9c1a0c09be6312fb15e85e851db6f329a4bffd18700067decbe7c2ac941c5e
Python
1,456
43
# fix problems with pythons terrible import system import os import sys file_dir = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(file_dir, '../bin/')) sys.path.append(os.path.join(file_dir, '..')) # useful imports from prob2020.python.gene_sequence import GeneSequence import prob2020.python....
0a2bc82338cb5871097fd11dd101524c23b135a5a9ba71434f30b68f3c37c84d
Python
1,457
48
"""Pool implementation abstract factory, and alias definitions.""" import os # Import from kombu directly as it's used # early in the import stage, where celery.utils loads # too much (e.g., for eventlet patching) from kombu.utils.imports import symbol_by_name __all__ = ('get_implementation', 'get_available_pool_name...
0af04a9eda4380a31583212e2eefd9daceb9f717760718ebd99d8c4f515ed1ab
Python
1,457
50
import sys import re if __name__ == '__main__': texfile = sys.argv[1] bibfile = sys.argv[2] if not texfile.endswith('.tex') or not bibfile.endswith('.bib'): print('Use: filterrefs.py document.tex bibliography.bib') exit() keys = [] pattern = r'\\citep?\{([^\}]+)\}' with open(t...
277ce7e9ed375858312c8d1115b181cf9c3f1c447776d4f22783007fc92b7c7c
Python
1,457
52
import numpy as np import pytest import gym from gym.wrappers import FrameStack try: import lz4 except ImportError: lz4 = None @pytest.mark.parametrize("env_id", ["CartPole-v1", "Pendulum-v1", "CarRacing-v2"]) @pytest.mark.parametrize("num_stack", [2, 3, 4]) @pytest.mark.parametrize( "lz4_compress", ...
4582cc16a49b1a3ef21b66217214a29a17d4d8886b60b2ed238d5a98ae778617
Python
1,457
42
import logomaker as lm import matplotlib.pyplot as plt from ._motifs import pfm_to_df, pfms_to_df_dict def plot_filter_logo( mtx, mtx_type="counts", vocab="DNA", title=None ): df = pfm_to_df(mtx, vocab=vocab) plot_df = lm.transform_matrix(df, from_type=mtx_type, to_type="information", pseudocou...
60b58bc5ea1ca2e0b6d3bb93c5ed1fe3cbd96ac85bb17b442d7e47e547342542
Python
1,457
46
from pathlib import Path from typing import Tuple, Union import nibabel as nib import numpy as np def load_norm_cest_data( cest_file: Union[Path, str], mask_file: Union[Path, str, None] = None ) -> Tuple[np.ndarray, np.ndarray]: """ Load and normalize CEST data from the given file paths. Args: ...
c76015a5c8daa7decd02d81f2b4ee42071b669e478be64eed92c4817ee55e607
Python
1,457
47
import json import matplotlib.pyplot as plt from matplotlib.figure import Figure from dexterity.design.common import QUALITATIVE_COLOR_PALETTE AGENT_ID = 1581809147 with open(f"../../monitor/static/experiments/{AGENT_ID}/progress.json", "r") as f: data = json.load(f) vloss = data["vloss"] ploss = data["ploss"]...
d314b555007b020c52223aa0ce79a276467b0aa512424ce40f1e60459acbee5d
Python
1,457
40
from __future__ import annotations import json from pytest_celery import RESULT_TIMEOUT, CeleryTestWorker from celery.canvas import StampingVisitor from t.integration.tasks import add, identity class test_stamping_visitor: def test_callback(self, dev_worker: CeleryTestWorker): on_signature_stamp = {"on...
4f82e5797ab3e9b07772978741bcd8cbe68aeb41668d91f1bfa9a4c116e09285
Python
1,458
53
# coding=utf-8 # Copyright 2022 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...
e903fc0ea966a52226a0ab09f092a24b22866ef8c37380b42969295e17183460
Python
1,458
41
"""Handles the PlotOut Class""" # License: GNU General Public License v3.0 import ipywidgets as widgets from ipywidgets import Widget from gui import plots_widget, AlphaLevelWidget, DropdownSelectionWidget from gui import constants class PlotOut(Widget): """Handles plotting functionality""" def __init__(self,...
7e590d57cad208eac0e8a4abe6d92bad83073341e236c8872a7dd80d093d44fe
Python
1,459
18
#==============================================================================# # Author: Dominik Müller # # Copyright: 2024 IT-Infrastructure for Translational Medical Research, # # University of Augsburg ...
fbb32676a5e61fe5d084050d05bc81298592e49d1ca04b0628189ec1c0a4e87d
Python
1,459
69
import pytest import numpy as np import jax.numpy as jnp from cvsx.unit_conversions import Converter, convert def test_conversion_pa_to_kpa(): pa = 1000 kpa = convert(pa, "Pa", "kPa") assert kpa == 1 def test_default_to_ml(): l = 1 ml = convert(l, to="ml") assert ml == 1000 def test_defau...
3dd2cf31b06ad3a51a7dff91fd5686db2274e803748a2bb709419067423a7925
Python
1,460
50
from sys import argv from msp import MSP msp = MSP() msp.file = __file__ msp.seed = int(argv[1]) msp.architecture["splicepoint_model_spec"] = dict( type="BothLSSIModels", acceptor="model/splicepoint-model-acceptor-1", donor="model/splicepoint-model-donor-1", ) msp.architecture["motif_model_spec"]["motif_...
7f02359aa56bef8b481a140b34c9542aed9bcbc4daa48c842e5144390303c5af
Python
1,460
38
import torch import torch.nn as nn import torch.nn.functional as F from math import sqrt from torch.autograd import Variable def make_model(args, parent=False): return DRRN(args) class DRRN(nn.Module): def __init__(self, args): super(DRRN, self).__init__() self.scale = args.scale[0] s...
b2e3306810c0a73fd4c6aa8b3c89905b58f64e14b0e7098b747357eb0d1ed848
Python
1,460
41
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QPushButton, QListWidget, QHBoxLayout from PyQt5.QtCore import pyqtSignal class ListSelectionDialog(QDialog): dialogClosed = pyqtSignal(str) # Custom signal def __init__(self, items, parent=None): super(ListSelectionDialog, self).__init__(parent) ...
20fe4d7866b4923860c415c2dd34bca54439c57fe22aec8306c02f197541f7d7
Python
1,461
48
import numpy as np import torch from torch import nn from torchvision.transforms import transforms np.random.seed(0) class GaussianBlur(object): """blur a single image on CPU""" def __init__(self, kernel_size): radias = kernel_size // 2 kernel_size = radias * 2 + 1 self.blur_h = nn.Co...
cb540d4f8ef4ccf1776919e6dc8f2c56e90cbf87c8781ec8e2d543f0a9d31fbc
Python
1,461
46
import os import logging import torch from transformers import ViTImageProcessor from transformers import ViTForImageClassification def load_models(confidence, device): #YOLO Model obj_model = torch.hub.load('ultralytics/yolov5', 'custom', path = "Weights/YOLO_weights...
9149598f3183de35ede376177d3b90a6c038a15aa37fec31907f6356f2cf49bd
Python
1,463
36
from imodelsx import submit_utils from os.path import dirname import os.path repo_dir = dirname(dirname(os.path.abspath(__file__))) # python /home/chansingh/llm-tree/experiments/01_train_model.py --use_cache 0 --subsample_frac 1 --model_name llm_tree --max_depth 3 --use_llm_refine 1 # python /home/chansingh/llm-tree/...
c647e01e24020d3469f2c79609d06f4051b038da0ce95627ea0f71a7714920eb
Python
1,463
43
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """tests for svd""" import unittest import numpy as np from sknetwork.data import star_wars from sknetwork.embedding import GSVD, SVD, PCA from sknetwork.linalg import LanczosSVD class TestSVD(unittest.TestCase): def test_options(self): biadjacency = star...
e4a8ad80531103b8365b3000f5c0d8d156bfb9b0c5cba19d03ae5484c5b2d924
Python
1,463
50
import unittest from numpy import array, matrix from numpy.testing import assert_array_equal from pandas import DataFrame from .context import helpers class BasicTestSuite(unittest.TestCase): """Tests for Helper Functions.""" def test_is_numeric(self): x = 1 y = 1.0 z = "1" se...
5e27dfb0f820e724a9b5d6146bdc90831f893bc25c769b2e41b18ecb5af27877
Python
1,464
38
import community as community_louvain import networkx as nx import numpy as np # Compute cluster centroids, which is the mean of all points in one cluster. def computeCentroids(data, labels): n_clusters = len(np.unique(labels)) return np.array([data[labels == i].mean(0) for i in range(n_clusters)]) class lo...
68570c088631a674f3a91163c4ad1755b759fa5f12af615a927fc68732d81968
Python
1,465
63
import numpy as np class Feature(object): def get_map(self, img, roi): map_float32 = self.get_map_float32(img, roi) return np.uint8(255 * map_float32) def get_map_float32(self, img, roi): raise NotImplementedError() @staticmethod def norm(img, a, b): res = img.copy()...
be869de013850434818b5615e9325cfe30de715bc63a3e356b0c9b9fe2341dfb
Python
1,466
44
from ethoscope.core.monitor import Monitor from ethoscope.trackers.adaptive_bg_tracker import AdaptiveBGModel from ethoscope.roi_builders.target_roi_builder import SleepMonitorWithTargetROIBuilder from ethoscope.hardware.input.cameras import MovieVirtualCamera from ethoscope.drawers.drawers import DefaultDrawer from et...
d70dd24c5cc67d2f57060b802ee31ee1c400b4ce4d008ed2d46b6c00ae1fdff2
Python
1,466
45
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license from __future__ import annotations from pathlib import Path import torch from ultralytics.utils.checks import check_requirements from .base import BaseBackend class TritonBackend(BaseBackend): """NVIDIA Triton Inference Server backend for re...
20a48d4e646a56d5095610142ac000d90c5586c1b0ec7bf4a79a4437acdadc32
Python
1,467
59
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["motif_model_spec"] = dict(...
a98937de4f86adfc3b38e408218548d7928c12c8821ae3fb032698cc7eb007dc
Python
1,467
40
''' Basic test installation is working ''' import collections import numpy as np import pytest from OscopeBootstrap import SyntheticDataset from OscopeBootstrap.oscope_tf import bootstrap_hypothesis_test DataParameters = collections.namedtuple('DataParameters', 'ngroups NG N G noiselevel') @pytest.fixture def data...
cccc2fe0b9869e64c9bad1336a89bc13ed6f4f962ba83f46930e6b52d13bf67c
Python
1,467
55
import numpy as np from .misc import ifnot def DFoSD(vec, normL=None, th=1e-6): "Subtract mean value along first axis and normalize to S.D." normL = ifnot(normL, len(vec)) m, x = np.mean, vec[:normL] sdx = np.std(x, 0) out = np.zeros(vec.shape, vec.dtype) if np.ndim(sdx) == 0: if np.ab...
d96177bd6e3b9af7f6907215b987ce6d8f91bcc596f65e54982d97465cb65526
Python
1,467
48
import argparse import time import gluoncv as gcv gcv.utils.check_version('0.4.0') from gluoncv.utils import try_import_cv2 cv2 = try_import_cv2() import mxnet as mx parser = argparse.ArgumentParser(description="Webcam object detection script", formatter_class=argparse.ArgumentDefault...
8b3fc06542d787f51d047b1edb262991114dee35fe845664be07bc1f9fae41fb
Python
1,468
44
"""Validate GPU binding buffers before entering CUDA, without requiring a GPU.""" import numpy as np import pytest @pytest.mark.parametrize("invalid", ["dtype", "shape", "readonly", "strided"]) def test_gpu_buffer_validation(invalid): module = pytest.importorskip("shap_cuda._cext_gpu") out = np.zeros((2, 2, ...
8b61b9d5502cd9e9e09b2e0638b65cac7d08c331b93fe586bf3e030bd1b570ed
Python
1,468
48
""" Package to interface with R, with a focus on interactive usage (REPL approach to code-writing), although the package will work in non-interactive settings. The package aims at being simple rather than exhaustively complete (rpy2.robjects, or rpy2.rinterface, can be used if needed), providing a comfortable experien...
995cb8a6591eeb79b19aebefd967d6963a4ea0d7dec3a8f03285a9f207d89588
Python
1,468
50
#!/usr/bin/env python3 """ Created on Fri May 31 12:07:44 2019 @author: Bian Li @email: bian.li@yale.edu """ from pymol import cmd from argparse import ArgumentParser def parse_cmd_args(): """Set up a command line argument parser Returns ------- A set of command line arguments. """ pars...
bd95c964e58505295755c78d7e60b8c22918acf682044f69841a87d20d43679b
Python
1,468
41
import setuptools import os print('OS=',os.name); if (os.name == 'nt'): print('In Windows'); with open("README.md", "r") as fh: long_description = fh.read() with open("biswebpython/requirements.txt", "r") as fh: install_requires = list(fh.read().splitlines()) else: print('In UNIX'); with open("REA...