sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
37e6b16a390a522846799184aed45fcfbe48323a36ea405b425b9351855830ad
Python
918
33
# -*- coding: utf-8 -*- import numpy as np from .red_blue import RedBlueMove __all__ = ["StretchMove"] class StretchMove(RedBlueMove): """ A `Goodman & Weare (2010) <https://msp.org/camcos/2010/5-1/p04.xhtml>`_ "stretch move" with parallelization as described in `Foreman-Mackey et al. (2013) <h...
fff3e5390809a8d28b2662a0c60797ea0ad98e111a79f1a8c2eb2ee17cce98eb
Python
918
25
def scale_apical(cell, scale = None): ''' This is the function used to scale the apical dendrite in the following optimizations: 20190117_fitting_CDK_morphologies_Kv3_1_slope_variable_dend_scale.ipynb 20190125_fitting_CDK_morphologies_Kv3_1_slope_variable_dend_scale_step.ipynb ...
7e2dd849b4735dfb4bd117c46585e34939fdb87adac4caf6e4936ada950f1f39
Python
919
33
import sys, argparse import pyqtgraph as pg from kilosort.gui import DarkPalette, KiloSortGUI from PyQt5 import QtWidgets # TODO: figure out how to fix margin/padding around tooltip text. # property-margin, margin-right not working as expected. _QSS = """ QToolTip { color: #aeadac; backgrou...
b7ba1901b947c20389f87768ab55a182c7669874b43375a5f025cb9a82449981
Python
919
19
import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))) from app.models import Condition def get_oasis_dx(visit_cdr, visit_dx1): condition = None if visit_cdr == 0: condition ...
beffb503a24dbd2c27e2168cfa19205cc4556884dbf7d512d817241a5933ba04
Python
920
38
# IMPORTS from os.path import join, split, splitext from VINNA.config import get_cfg_defaults def get_config(args): """ Given the arguemnts, load and initialize the configs. """ # Setup cfg. cfg = get_cfg_defaults() # Load config from cfg. if args.cfg_file is not None: cfg.merge_f...
d0c28c231a485474d1e69d9859f1db49feeeda88862be5215e0da3f0c851ab73
Python
921
20
import numpy import bionetwork import pandas #Load network networkList, nodeNames, modeOfAction = bionetwork.loadNetwork('viabilityModel/ligandScreen-Model.tsv') annotation = pandas.read_csv('viabilityModel/ligandScreen-Annotation.tsv', sep='\t') uniprot2gene = dict(zip(annotation['code'], annotation['name'])) nodeNam...
77d345b3281c286b69fa9c3e6693af231321a6c46a775b8f05596a7a31e43665
Python
922
27
import numpy as np from pandas._libs.tslibs.dtypes import abbrev_to_npy_unit from pandas._libs.tslibs.vectorized import is_date_array_normalized # a datetime64 ndarray which *is* normalized day_arr = np.arange(10, dtype="i8").view("M8[D]") class TestIsDateArrayNormalized: def test_is_date_array_normalized_day(s...
378e55bc97e4d2302f2b1d5c4d655ffc7bda80fc41adc8f4e7a2de9b6894c801
Python
923
29
import pyqtgraph as pg class ShapeOutColorBarItem(pg.ColorBarItem): def __init__(self, yoffset, height, label, colorMap, *args, **kwargs): """pg.ColorBarItem modified for Shape-Out - Added option to define height - translate the colorbar so that it is aligned with the plot - show ...
b16da62cfb8b115e4e552365cb12583913e1d66982e2504ac72cecde25b3b818
Python
923
38
""" Extracted from alphapept.io https://github.com/MannLabs/alphapept/blob/master/alphapept/io.py under the Apache License 2.0 https://github.com/MannLabs/alphapept/blob/master/LICENSE """ __all__ = ["index_ragged_list"] import functools from typing import List, Sequence, TypeVar import numpy as np import numpy.typ...
6f0dd79e3532078385c35068cd1ed23666bf6c3454584b16a0c41817deebe785
Python
925
19
from datetime import datetime import sys sys.path.append("..") from app import db class Condition(db.Model): __tablename__ = 'condition' id = db.Column(db.Integer, primary_key=True) designation = db.Column(db.String(255)) subject = db.relationship('Subject', backref='condition', lazy='dynamic', cascad...
0a2c777699ccaac81f0d1326bdcf745e271ee3cf92d9061de6c6e2a926bb6fc4
Python
927
24
########################## ### Utilities Function ### ########################## # one-hot encoding (only allowable set) def one_of_k_encoding(x, allowable_set): # Maps inputs only in the allowable set if x not in allowable_set: raise Exception("input {0} not in allowable set {1}:".format(x, allowable...
f89bacd3d960c72a04baf5d97ef6d904d213ebfcc6549b044f4b3a222d2fd6e3
Python
927
20
import sys, argparse, pandas as pd argparser = argparse.ArgumentParser(''' Adds lag metrics to user-specified columns in space-delimited data table. ''') argparser.add_argument('-c', '--columns', dest='c', nargs='+', action='store', help='Columns for which to add metrics.') argparser.add_argument('-n', '--numlag', dest...
97fe4a7d7c575f2fdcbe7a422e8fb57cf0f67109fd1e0ddd9d230b3612afd03f
Python
928
31
import logging # A simple implementation of gradient descent with # heuristic changing of descent step (eps) def descend(opt, verb = True, maxIter=1000, TestGradient = False, epsInit=10.): eps = epsInit gradCoeff = 1.0 epsDoubleIterations = 10 obj = opt.objectiveFun() logging.info("***** iteratio...
eb3ecf22412dc00d4bee19fa7a89923655a834cd1b76332dc39084a890a198a7
Python
929
27
import setuptools with open("README.md", "r") as f: long_description = f.read() setuptools.setup( name="progres", version="1.1.0", author="Joe G Greener", author_email="jgreener@mrc-lmb.cam.ac.uk", description="Fast protein structure searching using structure graph embeddings", long_descri...
163cd4c94f24cd099da23bf6fc257f2125cebda3c7617c641d553bbf4962c6eb
Python
930
30
__all__ = ["get_logger"] import logging import os import sys from typing import Optional def get_logger( name: Optional[str] = None, console: bool = True, file: Optional[str] = None ): logger = logging.getLogger(name=name) logger.setLevel(logging.INFO) formater = logging.Formatter( "%(asctime...
132be4a54d7a7b17266aafc6bf1026283c6522275e5cb84ebd114264189cee70
Python
931
23
# Copyright 2019 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany # # 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://w...
cf9356df39bf785050ef3cf9db373d041b041fbd747354ff1dde2f2bf2dabbff
Python
933
26
import imageTimeSeries, imageTimeSeriesConfig import optparse import os import shutil import logging from base import loggingUtils output_directory_base = imageTimeSeriesConfig.compute_output_dir # set options from command line parser = optparse.OptionParser() parser.add_option("-o", "--output_dir", dest="output_dir")...
25a6fdf0aeb742aff28a1e003d985dadc806de5338aa86d48f1d1d0bce3e3014
Python
934
36
import sys import os import re import collections import tree import morph def validate( t, W, L ): ## apply morph rules... if len( t.ch )==1 and len( t.ch[0].ch )==0: s = morph.getLemma( t.c, t.ch[0].c ) cat,base = s.split( ':' ) W[ re.sub( '^(.)[^:]*', '\\1', re.sub('-[lx].*','',t.c) ) + ':' + t.ch...
ca27129aee6fb6cd85239525738e838e7da52d22dfa27214934e3144fa11716a
Python
935
36
"""Set COLRv1 fontRevision from CBDT. Used for bugfix, should fix to set properly on build instead. """ from fontTools import ttLib from pathlib import Path import sys NAME_ID_VERSION = 5 def name(font, name_id): return ",".join(n.toUnicode() for n in font["name"].names if n.isUnicode() and n.nameID == name_i...
10771e2b75f0f1479d1bb7880e082da853a95bd64a1cbde9221c215fd66f6e06
Python
938
21
#!/usr/bin/env python import pandas as pd from sys import argv EIci = pd.read_table(argv[1]) IR = pd.read_table(argv[2]) EIci_out = argv[3] EIci = EIci.rename(columns={'#chr': 'chr', 'gene_name': 'gene_id'}).query( 'tx_score >= 1') EIci['intron_start'] = EIci['intron_start'].str.split(',') EIci['intr...
576532f421d6a8f791200adfd1f8b1f094180c22fc995d6b2ea14d78018930df
Python
938
28
import numpy as np import random import os import matplotlib.pyplot as plt from matplotlib import cm from mpl_toolkits.axes_grid1 import make_axes_locatable import time # import sklearn.linear_model # from sklearn.model_selection import train_test_split # from sklearn.linear_model import Perceptron, LogisticRegression ...
f93653d653f4e6a7f47cda6124c1313440ea28238f59bdaea949b157921fc1a7
Python
938
33
""" We also test Series.notna in this file. """ import numpy as np import pandas as pd import pandas._testing as tm class TestIsna: def test_isna_period_dtype(self): # GH#13737 ser = pd.Series([pd.Period("2011-01", freq="M"), pd.Period("NaT", freq="M")]) expected = pd.Series([False, Tru...
18e344d4bd0a629c909d18c3d6cc743cf7dbaaa90df91511244c2a33e48da0ae
Python
939
21
"""Classes for calculating k-space trajectories.""" from mrpro.data.traj_calculators.KTrajectoryCalculator import KTrajectoryCalculator from mrpro.data.traj_calculators.KTrajectoryRpe import KTrajectoryRpe from mrpro.data.traj_calculators.KTrajectorySunflowerGoldenRpe import KTrajectorySunflowerGoldenRpe from mrpro.da...
667cad9e81eb13354e0607aca4daedf918ed99ba722b107000dd8649b9379b5c
Python
939
37
import numpy as np import pytest import pandas as pd @pytest.fixture(params=[None, False]) def sort(request): """ Valid values for the 'sort' parameter used in the Index setops methods (intersection, union, etc.) Caution: Don't confuse this one with the "sort" fixture used for concat...
9aec90670bf65df0dcfaa7ad1e4654f54efa59ed6b394d4e17f234077b695a61
Python
939
41
import pandas as pd df = pd.read_csv('~/data/ET_geco/EnglishMaterialInterestAreas.csv', keep_default_na=False) df2 = df.WORD_ID.str.split('-', expand=True) df2.columns = ['part', 'trialid', 'trialpos'] df2['sentid'] = df.SENTENCE_ID df4 = df2.drop_duplicates(['trialid', 'sentid']) trialid = df4.trialid.astype(int).v...
94b9afbc8ee8b5cf42dca21c8ec34e0260ce405758799fc6bbdc89cb9a0f89e6
Python
940
38
import sys, re spill = re.compile('(.+)S[0-9]+$') cli = sys.argv[1].strip().split('_') preds = [] restrdomain = '' for i in xrange(len(cli)): s = cli[i] if s in ['-a', '-A', '-x']: P = cli[i+1].split('+') for p in P: if p not in preds: preds.append(p) elif s ==...
9b63ef58e935b4e39e217f2a8f88419bef7f6e75ddd9868ae6769c3024d5e510
Python
940
25
"""Test nimare.annotate.lda (LDA).""" import numpy as np import pandas as pd from nimare import annotate def test_lda(testdata_laird): """A smoke test for LDA.""" N_TOPICS = 5 model = annotate.lda.LDAModel( n_topics=N_TOPICS, max_iter=100, text_column="abstract", ) new_dset...
388ab753244d644864aefc25903a567c537a5e022176f0ffbd4d3be7c6c97361
Python
941
23
# Copyright 2025 Xanadu Quantum Technologies Inc. # 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 applicable law or agre...
7fabcac07bec4743af1be571558cbee5eda92c73cdd19264e4be24284cb24291
Python
941
26
import pandas as pd, numpy as np, os, shutil from dask import dataframe as dd, array as da def set_files(param): if not param['recovery']: main_path = os.getcwd() path = os.path.join(main_path, param['matrices_folder']) if os.path.exists(path): shutil.rmtree(path) os.mkdir(path) ...
bb3da189565e0c4a06385ed29285c277211f76c4afd25f7aab233ee7d1c0d506
Python
941
26
"""Test nimare.annotate.lda (LDA).""" import numpy as np import pandas as pd from nimare import annotate def test_lda(testdata_laird): """A smoke test for LDA.""" N_TOPICS = 5 model = annotate.lda.LDAModel( n_topics=N_TOPICS, max_iter=100, text_column="abstract", ) new_dse...
d5393bb880163aa12ffcc29424bec00f4af7bf234e1dcd7e25148ef638ff3e0f
Python
941
43
import sys,os from setuptools import setup, find_packages with open('README.md') as readme_file: readme = readme_file.read() def read(name): with open(os.path.join(this, name)) as f: return f.read() this = os.path.dirname(os.path.realpath(__file__)) __description__ ='None' __version__ = '0.1.0' ...
5e669a80741c4ded57706bb5f926da876b0151953c6b6702461b55dff936b12e
Python
942
33
"""session 26: trial notes (free-form annotation) Revision ID: d4e5f6a7b8c9 Revises: c3d4e5f6a7b8 Create Date: 2026-05-09 10:00:00.000000+00:00 Adds a free-form ``notes`` column on ``trials`` so users can annotate candidates straight from the trial-detail page. Optional, nullable — existing rows just stay empty until...
90f2b056ebd69a5cc6799e1bcc3025085f67a6f84c1fe0a282b8e84a5fceb820
Python
942
40
# -*- coding: utf-8 -*- """ NeatMS library ~~~~~~~~~~~~~~ NeatMS is a peak filtering library for Mass Spectrometry data. The code is open-source and available at Full documentation is available at :licence: MIT, see LICENCE for more details. """ import pymzml import numpy as np import pandas as pd import pathli...
e28c80ec2826f14e2d0961dc0bf56256f1ac04538d428181344c8fc9402a2203
Python
943
27
# Tests for internal components of the atropos commands from pytest import raises from atropos.commands.trim.multicore import OrderPreservingWriterResultHandler from atropos.commands.trim.writers import Writers import tempfile import os def test_order_preserving_writer(): path = tempfile.mkstemp()[1] try: ...
b27b45c3a566219625e09ca21346b21960c05e1a8b800a804427c80104f7aa36
Python
945
36
class IVecEnv: def step(self, actions): raise NotImplementedError def reset(self): raise NotImplementedError def has_action_masks(self): return False def get_number_of_agents(self): return 1 def get_env_info(self): pass def seed(self, seed): p...
041dfb0aee3005a2ce36df342854c005518b57c4b4a83a4635f1a0f03aae9550
Python
946
29
#!/usr/bin/env python3 from SALib.sample import saltelli from SALib.analyze import sobol import numpy as np import sys, getopt import utils data_folder = '../data/' nsamples = 8000 outputfile = "param_values.csv" opts, args = getopt.getopt(sys.argv[1:], "h:n:o:", ["nsamples=", "ofile="]) for opt, arg in opts: if ...
335cfa2c58c9f1d358c27466f121d923f985debbb3d00d41921eda69c3a6d58a
Python
946
22
from Environment_ui import * def seg3d_to_2d(data_path, save_path, index=0): os.makedirs(save_path, exist_ok=True) for i in range(1, len(os.listdir(data_path)) + 1): image = sitk.ReadImage(os.path.join(data_path, 'Z{:05d}_filter.tif'.format(i))) image_array = sitk.GetArrayFromImage(image) ...
40255884972d05c91fa56182c057e39bc7270fc9efbe1b7b66115579fb83cf6b
Python
946
47
# # File for testing the Batch Normalization layer # import numpy as np import tensorflow as tf import protein_holography.network.L_batch_norm as lbn s = [100,3,100] bnl = lbn.LBatchNorm() #print(bnl.__dict__) bnl.build(s) print('\nMoving mean') print(bnl.moving_mean) print('\nMoving Variance') print(bnl.moving_v...
0aa05cbac9e0dd7f4710661efbc645b1caa6543282a562c6e10f878224804d00
Python
947
26
import numpy as np import pytest import pandas as pd import pandas._testing as tm class TestSearchSorted: def test_searchsorted_different_argument_classes(self, listlike_box): idx = pd.TimedeltaIndex(["1 day", "2 days", "3 days"]) result = idx.searchsorted(listlike_box(idx)) expected = np...
3532c12fb861c05bebc68d266bd9f6fa478ac61caa05e0be56e969c4ebc1d17f
Python
947
35
STATS_PREFIX = 'run_info' STAR_SOLO_DIR = 'Solo.out' STAR_GENE_DIR = 'Gene' STAR_RAW_DIR = 'raw' STAR_FILTERED_DIR = 'filtered' STAR_VELOCYTO_DIR = 'Velocyto' STAR_BAM_FILENAME = 'Aligned.sortedByCoord.out.bam' STAR_BAI_FILENAME = 'Aligned.sortedByCoord.out.bai' STAR_BARCODES_FILENAME = 'barcodes.tsv' STAR_FEATURES_FI...
b4e5aa0e83903e6f9306a83e49d44bc6340b87930797909c2268af70d8079e74
Python
947
28
# coding: utf-8 from atropos.adapters import Adapter, ColorspaceAdapter, PREFIX, BACK from atropos.commands.trim.modifiers import AdapterCutter from atropos.io.seqio import ColorspaceSequence, Sequence def test_cs_5p(): read = ColorspaceSequence("name", "0123", "DEFG", "T") adapter = ColorspaceAdapter("CG", P...
04ed25b26c123944ce38fbd37f4d89d2ea2764d92600cce52292b816ea5ea7c9
Python
948
26
import sys import pandas offset = 230 X1 = pandas.read_csv( sys.argv[1], index_col=False ) X2 = pandas.read_csv( sys.argv[2], index_col=False ) W = pandas.read_csv( sys.argv[3], sep='\t', index_col=False ) X = X1.append(X2) ## Remove the 231st item, which was an empty token in the orig expt that resulted in the mis...
80a9ad3821c5f2313e65a0a4245e7fc78f576f230a51ef0a4cd6de0f2805010c
Python
950
26
# Copyright 2026 Xanadu Quantum Technologies Inc. # 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 applicable law or agre...
490adfd18d56dc1a42bb7a7d060ebc41a0b4735d09717cad8b62a0af1c4c8f32
Python
951
22
import os import numpy as np import pandas as pd pwd = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) df = pd.read_csv(pwd+"/dataset/taste_dataset/bitter_sweet/bs_test.csv", header=0, sep="\t") df['Smiles'].to_csv(pwd+"/contrast_predictors/virtual_taste_test.dat", index=False, header=False) def get_virtu...
4bff105418279de049c7184955c023a28c9d84809a88863c6d3e4d5df4d06e95
Python
951
25
import os # import cloudpickle import compatibility import pandas as pd from . import parent_classes import pandas_msgpack def check(obj): '''checks wherther obj can be saved with this dumper''' return isinstance(obj, (pd.DataFrame, pd.Series)) #basically everything can be saved with pickle class Loader(paren...
76799b28c0b077bb66cba53373f8a7abb54603ecfa7c599bb4200e4dcaa2628c
Python
951
19
"""Typed data pipeline for MRI/PET scan ingestion, labeling, and splitting. Ports the scientifically meaningful behavior of `Dataset_MRI.ipynb` / `Dataset_PET.ipynb` (see `docs/legacy-notebooks-inventory.md`) into current, typed Python. Modules: - `manifest`: the canonical typed scan manifest / data contract. - `labe...
aa68e89bc6fb0370ea27d1c68e773980f31c103cd68b22d5e0b0d4d66d7aa968
Python
951
33
#Run sweeps over number of fields import numpy as np from placerg.funcs import * from placerg.funcsrg import * from placerg.objects import * from placerg.runfunc import * N0 = 1024 # number of cells N = 256 # number of cells after removing silent ones percell= 1.0 # probability that each field is accepted phi=1.0 #...
1f31c3215423ab5aadd789f17e763dc288bd022ee3e6a6cb7ba8ef3c39461699
Python
952
20
#!/usr/bin/env python import os, sys from cupcake.io import GFF def get_gff_from_list(gff_filename, listfile, partial_ok=False): seqs = [line.strip() for line in open(listfile)] for r in GFF.collapseGFFReader(gff_filename): if r.seqid in seqs or r.seqid.split('|')[0] in seqs or (partial_ok and any(r.se...
8eaecd64e319bc5a8de8d20bc2a6f8891c47e9e3ddccccdecbcb540c107b1c1d
Python
952
35
import linecache from functools import cached_property from typing import Any, List import numpy as np import pandas as pd import torch from scipy.sparse import issparse from torch.utils.data import Dataset import anndata as an from typing import Union class DatasetForInference(Dataset): def __init__(self, adata:...
a6402ece31576180b1fdbcf3d9cd2a2ea4b6169336f0db1dfe81c1f8e8849430
Python
952
36
from __future__ import absolute_import __author__ = 'Todd Young' __email__ = 'youngmt1@ornl.gov' __version__ = '0.1.0' # Essential pieces from .architecture import Architecture from .modules.network import Network from .modules.conv.network import ConvNetwork from .modules.linear.network import LinearNetwork from .st...
a9e8d6d8d4a822b93cbd2df06d7e15df7b1c8c35b3b02608471b52b0417a5005
Python
952
36
#! /usr/bin/env python ############################################################################## ## DendroPy Phylogenetic Computing Library. ## ## Copyright 2010-2015 Jeet Sukumaran and Mark T. Holder. ## All rights reserved. ## ## See "LICENSE.rst" for terms and conditions of usage. ## ## If you use this wo...
26008f042a50b51bee62a15d23013a84c9d77e067ccd4c1e7c32e18c77c8b5ed
Python
953
41
# pyaging/predict/__init__.py from ._cache import ClockCache from ._pred import predict_age from ._pred_utils import ( add_pred_ages_and_clock_metadata_adata, check_feature_ranges, check_features_in_adata, cleanup_clock_memory, load_clock, predict_ages_with_model, set_torch_device, ) from ....
3ffd48131ce4be53244df91128760f6f49bfa211097a9a0c9052edd21a432236
Python
953
38
import pandas as pd class TestReductions: def test_min_max(self): arr = pd.PeriodIndex( [ "2000-01-03", "2000-01-03", "NaT", "2000-01-02", "2000-01-05", "2000-01-04", ], freq...
e39c7f6d3ba8f50ce76cb9aaf6287a67771bde5330f2187e3e6a4e48b88a8602
Python
953
40
import numpy as np import pytest import pandas as pd @pytest.mark.parametrize( "data, expected", [ (np.random.default_rng(2).integers(0, 10, size=1000), False), (np.arange(1000), True), ([], True), ([np.nan], True), (["foo", "bar", np.nan], True), (["foo", "foo...
49a4da946b07d7262f948e88041fadc2ad8b3eb1bc9e8ac52b872232edb08bd6
Python
955
42
# %% from subprocess import Popen from pathlib import Path # %% method_names = ["att", "lstm", "tf", "acs", "2_5d", "3d", "mp", "avg"] dataset_names = ["organ", "nodule", "fracture", "adrenal", "vessel", "synapse"] configs = { d_name: [f"{d_name}_{m_name}.yaml" for m_name in method_names] for d_name in datase...
feeb6d5e4efbc2115245a9bd33cab0dda2596d90d399ccbe739451babe8dda5e
Python
955
38
# -*- coding: utf-8 -*- # # Sphinx configuration # Cribbed from <https://github.com/ondrejsika/sphinx-autodoc-example> and # <http://breathe.readthedocs.io/en/latest/readthedocs.html> import sys import os import subprocess read_the_docs_build = os.environ.get('READTHEDOCS', None) == 'True' if read_the_docs_build: ...
7fbd7c792db24bdb88e6cb1ee6774c5833b82cfea0c7f2503daa0fa15e0fe25b
Python
956
42
import argparse import pandas as pd from pathlib import Path from sklearn.metrics import r2_score, mean_absolute_error def main(direc, output=None): direc = Path(direc) csv_file = direc/'test_results.csv' if not csv_file.exists(): raise ValueError(f'{csv_file} must be exists') df = pd.re...
83f18719613f5dea7f31a27532db2b5c294094bbd43cca94d39bfbf6e8e778d6
Python
957
38
import vegas import numpy as np from cfcn_cffi import ffi, lib def f(x): _x = ffi.cast('double*', x.ctypes.data) return lib.fcn(_x, x.shape[0]) @vegas.batchintegrand # 5 times faster for neval=1e6 def alt_batch_f(x): n, dim = x.shape _x = ffi.cast('double*', x.ctypes.data) ans = np.empty(n,...
dbea14e4570f9135104af2771b3a30f5889bb29f6eb12a733bcb6cc5de0b2f76
Python
957
19
import os from sbrnet_core.utils import full_read_tiff, write_tiff, linear_normalize # The sbrnet-core package does not have a script to generate the synthetic ground truths. # This script takes existing ground truths, beads and vasculature, and combines them. # TODO: migrate synthetic data generation to sbrnet-core f...
52cf734d1995293a6192ddfdfee22b6a93ce5c89c3c20f6021dcaeb5562a924e
Python
959
39
#!/usr/bin/python3 # mark_secondaries.py: Mark all but the first alignment with a given name as secondary """ Mark duplicate alignments for a given read name as secondary. Useful for GraphAligner output which does not mark its secondaries. Assumes that the first alignment is the primary alignment, ignoring score. vg...
7853d31769ac66aac15d2f92ad68d14d5616b6797157bed302edeabd6a848293
Python
959
25
# Copyright 2026 Xanadu Quantum Technologies Inc. # 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 applicable law or agre...
bc23473d5133cc0fb74767c14650a8ad97950b751f4e0acf16ddcbe2077b6ba2
Python
961
26
import zoneinfo import numpy as np import pytest from pandas._libs.tslibs.tzconversion import tz_localize_to_utc class TestTZLocalizeToUTC: def test_tz_localize_to_utc_ambiguous_infer(self): # val is a timestamp that is ambiguous when localized to US/Eastern val = 1_320_541_200_000_000_000 ...
bd4bb8bc7ef8df7407241532e3cc07504252e524ac2e3009dcf388f6c21bbd9c
Python
962
38
###################### ### Import Library ### ###################### import numpy as np import networkx as nx ########################## ### Utilities Function ### ########################## # nodes and edges to nx def g_to_nx(nodes, edges): G = nx.Graph() for n in nodes: G.add_node(n,idx=n) for...
f1cb2be733539f91be9b5f0b718c8ee5ed8c60cc14a82c874e34f1abf82aa8f3
Python
962
25
import pandas as pd import os import sys sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))) from app import create_app, db from app.models import Condition from config.globals import ENVIRONMENT from pathlib ...
8fd38ad14f2b43adb286d1aed074740e83a74f2032b18439586811e46b0ef276
Python
964
34
# Copyright 2025 Xanadu Quantum Technologies Inc. # 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 applicable law or agre...
fc2ab07e78a6198e978fc11f314e1112c165d20728951b4c0aa61ec82d500415
Python
964
35
#!/usr/bin/env python import os pwd=os.getcwd() def git_clone(repo_url, max_attempts=3): for attempt in range(1, max_attempts + 1): result = os.system(f'git clone {repo_url}') if result == 0: return else: print(f"Attempt {attempt} failed.") if attempt ==...
421b7ad437bad2fe0d99b56aa6dd8553bdd2d2f803cf9018f5c461a1c907bd45
Python
965
34
# libraries import pandas as pd import numpy as np import sys import samalg import scanpy as sc # output out_fn = "results_alignment_samap/" ## Preprocess ## # query species for spj in ["Xboc","Hmia","Spur","Isopu","Nvec"]: # read print("# loading %s" % (spj)) mat_j = sc.read_mtx("data/expression/%s_UMI_table....
4d0173e32448c8d4d0e54f7d90b86d130e2b103e2ead69fd866abf168e9346d9
Python
965
31
__all__ = ["PeptideReportParserBase"] import abc from typing import Iterable, Union import pandas as pd from ....util.config import Configurable from ..spec import PeptideMS2Spectrum from ....util.table import filter_dataframe class PeptideReportParserBase(abc.ABC, Configurable): def __init__(self, configs: U...
9ac1a5fc0c50dbc734ab47bfbb76b7d4c30b93342f9d8d9d84644393800afd21
Python
966
36
#!/usr/bin/env python __version__ = '1.0' from Bio import SeqIO import os, sys def main(): from argparse import ArgumentParser parser = ArgumentParser("Convert fasta to fastq") parser.add_argument("fasta_filename", help="input fasta (must end with .fasta or .fa)") args = parser.parse_args() inpu...
bf28e66afaab9d73b866f7f8f6c8ab5902fb6fcff2621488864b8a3ca587caee
Python
967
28
# Copyright 2018-2021 Xanadu Quantum Technologies Inc. # 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 applicable law or...
1a6516b5e9713ea1ba21c0744e122b2c69fa250984dd2c175faaff2435ae99a1
Python
968
24
import pandas as pd import pandas._testing as tm class TestToFrame: def test_to_frame_datetime_tz(self): # GH#25809 idx = pd.date_range(start="2019-01-01", end="2019-01-30", freq="D", tz="UTC") result = idx.to_frame() expected = pd.DataFrame(idx, index=idx) tm.assert_frame_...
53f5fed166eb1973c9ce7a3fbf7b94813b8ad1623c382e1baeda36618fb9b0f6
Python
969
36
import os import unittest from unittest import TestCase from evcouplings.utils import check_required, MissingParameterError class TestUtilsConfig(TestCase): def setUp(self): self.config = { "global": { "prefix": "test" }, "management": { ...
a344d0d094b568ab698ed51290bb7f518619dff0644329feca0732a29aa3442d
Python
969
21
# ------------------------------------------------------------------------------------------------------------------------------------- # Following code curated for GCPNet (https://github.com/BioinfoMachineLearning/GCPNet): # ----------------------------------------------------------------------------------------------...
eb51fe9bf00a0a3a17a13005169c10e41dbf08c9ecca09affafec6d90e5ad04d
Python
969
27
from sys import path as sys_path sys_path.append('..') from base import loggingUtils from base.imageMatchingMetamorphosis import Metamorphosis from base.imageMatchingBase import ImageMatchingParam import matplotlib matplotlib.use("QT5Agg") import matplotlib.pyplot as plt import pyfftw pyfftw.config.NUM_THREADS = -1 l...
a0658d8e5410c30a2f6086e87b07da3742c573f1e306ed223b8517e771492f8c
Python
970
41
# -*- encoding: utf-8 -*- # JN 2016-02-16 """ Plot a spectrum from the first 1000 records of data """ import sys import scipy.signal as sig import matplotlib.pyplot as mpl from combinato import NcsFile, DefaultFilter def plot_spectrum(fname): fid = NcsFile(fname) rawdata = fid.read(0, 1000) data = rawda...
5ba9bfe105eee84b98ffc774d8827a42e85dc8e53433c142b4b559730637f56a
Python
971
29
# Author: Anastasios Nikolas Angelopoulos, angelopoulos@berkeley.edu # https://github.com/aangelopoulos/im2im-uq/blob/main/core/models/losses/pinball.py # pinball loss class import torch # pinball loss class class PinballLoss: def __init__(self, quantile=0.10, reduction="mean"): self.quantile = quantile ...
a136a6e05c382d86a4621a1f6ca94e3f73cb4747ee62d8b99721c3c8ebcb465d
Python
972
28
#! /usr/bin/env python ############################################################################## ## DendroPy Phylogenetic Computing Library. ## ## Copyright 2010-2015 Jeet Sukumaran and Mark T. Holder. ## All rights reserved. ## ## See "LICENSE.rst" for terms and conditions of usage. ## ## If you use this wo...
5223845c9b5607f379d2869b5506eb4e5be2b8077a87749b151fbcb8436dec1c
Python
974
28
# Copyright 2026 Xanadu Quantum Technologies Inc. # 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 applicable law or agre...
20024f81f4949b6a12008e6047d951e7ae73c0446f04dc3945aeb06cb46b63a8
Python
975
21
# Copyright 2018-2023 Xanadu Quantum Technologies Inc. # 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 applicable law or...
a6a83b1decb3c6054a198374f19066f982a37397d5a6394f5ae82caa674de5f6
Python
976
35
# From: http://stackoverflow.com/questions/12090503/listing-available-com-ports-with-python import sys import serial import glob def list_ports(): ''' Lists serial ports. :raises EnvironmentError: On unsupported or unknown platforms :returns: A list of available serial ports ''' ...
dbbcff8f2853acfc4cb54790a016639a98d94273d9dd349a4c3722563cf4671d
Python
978
25
import single_cell_analyzer as sca def silence_synapses_by_somadist(cell, evokedNW, soma_dist_ranges = None): ''' This allows to silence synapses active at a certain soma distance. Parameters: soma_dist_ranges: dict, with synapse types as keys (e.g. L5tt_C2) and the range in which it s...
d881e9d5a12e0f77dee05703e19ac967ea012b484fb1123ceb7386d6ec5d4b3c
Python
979
40
# JN 2015-05-28 """ convenience script to show how many groups there are in each channel """ from __future__ import print_function, division, absolute_import import os from combinato import Combinato, h5files def main(sign, label): """ show group sizes in h5files """ files = h5files(os.getcwd()) ...
5c8322469f7a7ed76a749d9c88d8bcb567975fb406f9c8f868244dda464c75a1
Python
980
41
import pytest jinja2 = pytest.importorskip("jinja2") import pandas as pd from pandas.io.formats.style import Styler @pytest.fixture def df(): return pd.DataFrame( data=[[0, -0.609], [1, -1.228]], columns=["A", "B"], index=["x", "y"], ) @pytest.fixture def styler(df): return St...
86b2ab6b7234170a8240dd0885a853520819f6f055b441b02286c7ef7599dc53
Python
980
31
# Copyright 2024 Xanadu Quantum Technologies Inc. # 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 applicable law or agre...
1cfa1a55f2a5970ca8b8394e1e4cba495ba0fff5f9065585a134aaf453429373
Python
981
29
""" Test possibility of formulating polynomial fit as a least-square fit, accounting for NaNs """ import numpy as np # Mimics 500 subjects aged between 1 and 100 years old, for which 4 metrics are taken np.random.seed(238237) age = np.random.uniform(1, 100, (500, 1)) A = np.hstack((np.ones(age.shape), age, age**2, ag...
da08bb09cc6e5fb0f48398bdea7ffc7256f9491b4944e860756862120eea1b6b
Python
982
34
import setuptools from glob import glob with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup( name="imagenet_c", version="0.0.2", author="Dan Hendrycks", author_email="hendrycks@berkeley.edu", description="Access to ImageNet-C corruption functions", long_descrip...
1930b4fc62c223d177c008c146f5904cf91a02e947df5061e9740daa876de7b1
Python
983
22
import dgl import torch import torch.nn as nn import torch.nn.functional as F from dgllife.model.readout import WeightedSumAndMax from dgllife.model.gnn import WLN class WLNPredictor(nn.Module): def __init__(self, node_in_feats=74, edge_in_feats=12, node_out_feats=100, n_layers=2, project_in_feats=True, set_compa...
b32d3f8a8d438bfc4f5046275110293d1f6e75fefa0ebea452f7ed84c1e52612
Python
983
31
"""PyCaret 4.0 structured event-stream logger. Replaces the 3.x mlflow/comet/wandb/dagshub tracker adapters with a lean in-process event stream designed to be consumed by: - The forthcoming PyCaret React UI (over websocket or polling). - LLM agents that reason over engine traces. - Notebook users who want a human-rea...
1bf86d079192892a7fa27ad4a88825052753910c388de1a1742bc6b034e9de6c
Python
984
26
import os # import cloudpickle import compatibility import pandas as pd import numpy as np from . import parent_classes import pandas_msgpack def check(obj): '''checks wherther obj can be saved with this dumper''' return isinstance(obj, np) #basically everything can be saved with pickle class Loader(parent_c...
8335d26e162016529be9f1094c4d4a363b26f0e45a5731dc68edea90d95f5b31
Python
984
36
import numpy as np import torch from torch.utils.data import Dataset class ICUDataset(Dataset): def __init__(self, df, pat_ids, config, mode = "train", hours = 14*24): self.df = df self.pat_ids = pat_ids self.mode = mode self.hours = hours self.config = config ...
c96db31f40abdbb67c6b9a2f515aa5879e864b7c02820b8d4dd8316737a59acf
Python
984
36
import dclab import matplotlib.pylab as plt # dataset ds = dclab.new_dataset("fluorescence/fluorescence.rtdc") evts = {"reference": 397, "extremely porous": 8228, "porosity above 1.05": 347, "invalid event": 4740, } # plot fig = plt.figure(figsize=(7, 3)) for ii, key in enumerate(e...
20ded7eae187899e4d7ed048498a00d814809e84de6e0f72940654b1bc3dab5f
Python
985
24
# Copyright 2025 Xanadu Quantum Technologies Inc. # 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 applicable law or agre...
5d00c51242ef72b65b30d339b0565dec686df0e7088b096a490cfc1f46ab08c0
Python
985
37
import numpy as np def generate_label(X_test_geneid, positive_Gene): y_test = np.array([]) last_gID = '' for gID in X_test_geneid: if gID != last_gID: if gID in positive_Gene: y_test = np.hstack((y_test, np.ones(1))) else: y_test = np.hstack(...
8406c770ebabfccf7364bd03060839603b8f377ce44d5b13b5f537491cb0aa1d
Python
985
30
# Copyright 2018-2021 Xanadu Quantum Technologies Inc. # 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 applicable law or...
95e8d7e97d08c58e92cecbbc7036dd2309eecbf3d19e94fb1f4d217c02002535
Python
987
24
import pandas as pd import os import numpy as np pwd = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) # df = pd.read_csv(pwd+"/dataset/taste_dataset/bitter_sweet/bs_test.csv", header=0, sep="\t") # df['Smiles'].to_csv(pwd+"/contrast_predictors/bs_test_VirtuousSweetBitter.csv", header=None, index=False) ...
97415f12b5f762f1cd7dacd1227dee70164e3675073f2b2ac9f4bc5fadcbd63e
Python
987
32
"""Phase 4 datasource driver layer. Each backend (CSV upload, Postgres table, S3 file, …) implements the ``DatasourceDriver`` protocol. The factory resolves the right driver by ``DataSource.kind`` and the API/orchestrator never touches a backend SDK directly. Phase 4 ships two drivers end-to-end: - ``csv_upload`` — ...
a52a80fced8c96555356b94fe3a1ce3b6cf3d568047405daba3773a9796b5ee8
Python
987
36
"""Screenshots for quick guide dcor""" import sys from PyQt6 import QtCore, QtTest from PyQt6.QtWidgets import QApplication from shapeout2.gui.main import ShapeOut2 from shapeout2.gui import dcor app = QApplication(sys.argv) QtCore.QLocale.setDefault(QtCore.QLocale(QtCore.QLocale.Language.C)) mw = ShapeOut2() mw.se...
ddde1824cc63b7ad41cfcd0912f60bd05b00e1483f950cf5e6ccc6b7160aa765
Python
987
36
import dclab import matplotlib.pylab as plt # dataset ds = dclab.new_dataset("fluorescence/fluorescence.rtdc") evts = {"reference": 397, "small inertia ratio": 445, "debris": 4429, "large inertia ratio": 1893, } # plot fig = plt.figure(figsize=(7, 3)) for ii, key in enumerate(evts....
8de60158732efaca29ce1fc8f3b552971d0955d117a36b3156f5944e62433690
Python
990
24
# Copyright 2019 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany # # 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://w...
a818594b072937e886e261b5494351ac15cfcc6ed11f8d7e75d2bcc8ecdf8006
Python
990
33
import os import unittest from evcouplings.utils.update_database import symlink_force, download_ftp_file from unittest import TestCase import tempfile class TestUtilsUpdateDatabase(TestCase): def test_symlink_force_createSymlink(self): """ tests whether a symlink is correctly created """ ...