sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
f54a59a85976432fdb295002f3b43c88df9f0bf5caaa868f08c065db8dee33ac
Python
1,215
38
""" Reads one or more fasta files, counts the number of amino acids of each type in the file. """ import argparse import sys import numpy as np from esmologs import utils from esmologs import __version__ import warnings ALPHABET="ACDEFGHIKLMNPQRSTVWY" CHAR_TO_IDX = {ALPHABET[i]:i for i in range(len(ALPHABET))} ...
955e44a69ac61c089a0db531dadc909e955104660ffdaaa4b3e15af4fc3d1759
Python
1,218
41
# Configuration file for the Sphinx documentation builder. # # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master...
039c2b0824d9332daa21ba755534590669286ac0ed5fc07b7da6d6777f6a6c16
Python
1,220
38
import numpy as np import pytest from pandas.errors import DtypeWarning import pandas._testing as tm from pandas.core.arrays import ArrowExtensionArray from pandas.io.parsers.c_parser_wrapper import _concatenate_chunks def test_concatenate_chunks_pyarrow(): # GH#51876 pa = pytest.importorskip("pyarrow") ...
424d7b57c0133703a1f55fcbb98fba288a4b95648663448e2c03e78fcac89906
Python
1,220
39
""" Example for how to load data and display results on one subject's cortical surface. """ import matplotlib.pyplot as plt import numpy as np import utils import os from scipy.stats import zscore # Get path to data files fdir = os.path.abspath('../') modality = "listening" subject = "01" # Load training data for...
bdd9ceb559d9c03f2c9bb3788d7112545508fe2d9324702119ec92354fd9d36b
Python
1,220
45
# libraries import sys import numpy as np import pandas as pd import samap import scanpy as sc import samalg from samap.mapping import SAMAP from samap.utils import save_samap, load_samap # output out_fn = "results_alignment_samap/" # list of pairwise species comparisons com_list = [ ["Xboc","Spur"], ["Xboc","Hmia"],...
0a11b3f64f5899b679cd6bca521a6aa9fa2a1fef62e997c8b1246ac22400795c
Python
1,221
48
# JN 2015-01-09 """ create a new folder for sorting """ from __future__ import print_function, division, absolute_import import logging logger = logging.getLogger(__name__) import os import numpy as np import tables def _set_attrs(h5file, attrs): """ helper """ for key, val in attrs.items(): ...
8688b9f82c179344e0929e6b19fcee45c7914cb605a5a0f760a66b2f1a9c5227
Python
1,221
34
import sys import re def getFn( c, w ): c = re.sub('(-l.|-[mnstuw]t?[0-9]+r?|-yQ)','',c) s = c + ':' + w.lower() expr = re.sub( '-x.*:', ':', s ) for xrule in re.split( '-x', c )[1:] : ## If morphological macro... # (none yet) ## If 2-variable compositional lex rule, apply... m = re.search( '(....
cb42002bcc6f1c498975641f6842e98fb1e0d77bacbd2cdd911104f17c9eab64
Python
1,222
35
# 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...
b795966f30ee63797a5e6e0b40d8fa2ba4db582584962e5a3d5b94ee98ef9bc5
Python
1,226
32
import pytest import pandas as pd import pandas._testing as tm class TestDropLevel: def test_droplevel(self, frame_or_series): # GH#20342 cols = pd.MultiIndex.from_tuples( [("c", "e"), ("d", "f")], names=["level_1", "level_2"] ) mi = pd.MultiIndex.from_tuples([(1, 2), ...
ede17f4de9e77a842bbad80d1da6cc5c91f4ba0761446234ec0968e2928f9e02
Python
1,228
39
""" .. module:: cmd_volume :platform: Linux, Windows :synopsis: Command class for updating volume data via CmdManager .. moduleauthor:: Fredrik Nysjo """ import gfx_utils import numpy as np class UpdateVolumeCmd: def __init__(self, volume_, subimage_, offset_, texture_=0): self.volume = volume_ ...
923c374285d730beecfe61b74f127bd35639143d6b7c6c931c925394aa957709
Python
1,231
42
import warnings import pytest from pandas.util._exceptions import rewrite_warning import pandas._testing as tm @pytest.mark.parametrize( "target_category, target_message, hit", [ (FutureWarning, "Target message", True), (FutureWarning, "Target", True), (FutureWarning, "get mess", Tr...
0636a749932b233ee1111295c144ae37e968689be52241eafe5f7796318ac031
Python
1,232
20
# 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...
2694734e1c42c6c1ad5aeaadd5e0a3f2d40d4678e36886b13f03e153da675204
Python
1,232
31
# ------------------------------------------------------------------------------------------------------------------------------------- # Following code curated for GCPNet (https://github.com/BioinfoMachineLearning/GCPNet): # ----------------------------------------------------------------------------------------------...
ae5cf56072c5fba0a42932a607f771426a614499d30bca7159772773cabfb5ef
Python
1,232
40
import logging from datetime import datetime import pandas as pd from Bio import SeqIO logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) def load_sequence_and_metadata(kind="csv"): """ Returns the sequences as a list of SeqRecords, and metadata as a pandas DataFrame. """ startti...
efeffc94d0a9462e6761bebc577a2f1f85dbd6de301380a38b942e7f78bd9aef
Python
1,232
54
"""Create a string to parametrise condor jobs and print to terminal.""" from itertools import product import os from pathlib import Path cwd = os.getcwd() log_dir = Path(cwd) / 'logs' log_dir.mkdir(exist_ok=True) env = 'julearn' exec_string = \ "1_predict_gf.py $(sign_threshold) $(corr_sign) $(cv)" PREAMBLE = ...
557d0e56128796d3e5488ad97ac79ea2fe55715d0296d8a49e533a6f2347036c
Python
1,235
43
# -*- coding: utf-8 -*- import numpy as np from .red_blue import RedBlueMove try: from scipy.stats import gaussian_kde except ImportError: gaussian_kde = None __all__ = ["KDEMove"] class KDEMove(RedBlueMove): """A proposal using a KDE of the complementary ensemble This is a simplified version of...
a3983cb43d79df62a813a8667450788d43efd62dbd0fcfb03279e7262cea82a2
Python
1,235
41
""" naive.py Created June 1, 2021 Naïve method for extracting digital signal from lead image using "center of mass". """ from typing import Iterator, Optional, Tuple import numpy as np from ... import common def findFirstLastNonZeroPixels(oneDimImage: np.ndarray) ->Tuple[Optional[int], Optional[int]]: def reve...
c8eb435b3018f6dd06e6ae330a26c24d71bcb033938421ccfba4fd5992ed2dea
Python
1,237
40
# TODO get rid of this script and generalize # resource-fmri/scripts/tile_stimuli.py to allow for different id_cols import sys import pandas as pd import argparse argparser = argparse.ArgumentParser(''' Tiles stimuli by subject and fROI into experiment data. ''') argparser.add_argument('stimuli', help='Path to...
67d10d39bbb64a007f126b41a30fe1d412b67e6060c8163e6b064b13f1aea4c3
Python
1,238
36
#!/usr/bin/env python import sys from setuptools import setup if sys.version_info < (3, 5): raise NotImplementedError("Sorry, you need at least Python 3.5 to use tfserve.") def readme(): with open("README.md") as f: return f.read() with open("requirements.txt") as f: required = f.read().splitlin...
9e59027d1547201fd198593f3392609a09550d9b5f342174bbdcc7aac44319e4
Python
1,238
42
from datetime import datetime import pandas as pd import pandas._testing as tm class TestInferObjects: def test_infer_objects(self): # GH#11221 df = pd.DataFrame( { "a": ["a", 1, 2, 3], "b": ["b", 2.0, 3.0, 4.1], "c": [ ...
f63356328e955561c179b375f5dfcc3360eaafa93d4e2bc7722d446f0db5f6d0
Python
1,238
26
from GATF import prepare_dataloaders, get_model, train_epoch, test_epoch import json import torch if __name__ == '__main__': train_dataloader, test_dataloader = prepare_dataloaders(train_batch = 1024) # can be reduced to make the model fit smaller CPUs, performance might change. with open("params/optimal_confi...
9b794be0e765e443f8a9bdc301767b52949212571724b8087e0a94387acb1f96
Python
1,239
36
# Copyright 2018-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...
7cba16d61bb435c0613104ca7de26d4c20cc05210cce715c77b9be04d65d7778
Python
1,240
33
"""Goeminne et al. plasma-protein OrganAge models. Original author code and coefficients: https://github.com/ludgergoeminne/organAging DOI: 10.1016/j.cmet.2024.10.005 The released coefficients are subject to the authors' Academic / Non-Commercial License. Each converted artifact carries that license and its pinned pr...
818d95074257a186011d0692aa6a14537929ff82733ff4d6a2b636a5f36d7d6d
Python
1,243
34
# 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...
9806f0d7542e24a6b35b131084df3809b5aa0529f13ae4565bcdba8bcc277c60
Python
1,243
24
#!/usr/bin/env python import os, sys from Bio import SeqIO def get_seqs_from_list(fafq, listfile, partial_ok=False, exclude=False): f = sys.stdout type = 'fastq' if fafq.upper().endswith('.FQ') or fafq.upper().endswith('.FASTQ') else 'fasta' seqs = set([line.strip() for line in open(listfile)]) for r i...
4678f2099ec3433e0c7cb26f68b877175594f88f57b5bf96b0b0ea461fa90a8d
Python
1,245
52
"""nesvor entrypoints""" import sys import string import logging from .parsers import main_parser def main() -> None: parser, subparsers = main_parser() # print help if no args are provided if len(sys.argv) == 1: parser.print_help(sys.stdout) return if len(sys.argv) == 2: if ...
9228fa048beb244a005f628fb476a0e31cf6e6c645bf3a2a662460373fe95328
Python
1,245
42
import pandas as pd # Parameters --------------- annotations_file = './annotations_new_3s.csv' # Annotation file produced after running 'convert_avi_to_gif.py' # Output CSV filenames for the training, validation and testing datasets # that will be generated in this script annotations_train = './annotations_train_3s....
cced40ef5504526a5ec205e65c67c6bb5b2ca4f5f65305373594314dc29fd658
Python
1,245
45
"""NotebookManager factory.""" from __future__ import annotations import threading from typing import TYPE_CHECKING from pycaret_server.config import get_settings if TYPE_CHECKING: from pycaret_server.notebooks.base import NotebookManager _lock = threading.Lock() _singleton: "NotebookManager | None" = None ...
1b24e1217ee4a2a02aef7489c1098b0289b626ab28fcd01e7f0095f61744374a
Python
1,246
25
# Detection of brain boundaries from Environment import * def remove_edge(image_path, label_array, critical_value=112, interval=15): image = sitk.ReadImage(image_path) image_array = sitk.GetArrayFromImage(image) image_array[image_array > critical_value] = 255 image_array[image_array <= critical_value] = 0 binary_...
e631130e42ca2d4806ec5d0a8eaf3686d1b9356bc2b983597f97f85f1b04eccd
Python
1,246
39
"""Test the run_app CLI command argument parsing.""" import argparse from lightning_pose.cli.commands.run_app import get_parser class TestGetParser: """Test the get_parser function.""" def test_returns_argument_parser(self): """Returns an ArgumentParser instance.""" assert isinstance(get_pa...
8ec763224054dbb80f273cc6ef72fad93d88d91194a6a81279aa6200c38343be
Python
1,247
38
import sys ''' Convert itemmeasures to delim.lineitems, where each line is an space-delimited sentence, one per line, and article delimiter (!ARTICLE) are inserted between articles. Don't insert initial article delim, as it is inserted when converting later to linetoks. ''' ARTICLEDELIM = "!ARTICLE" docid = "" sentid ...
cdd0f7719c3933097a33928201b64991edeea90721058f6287a8a772a50680bc
Python
1,247
40
import sys, os #from itertools import izip sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'resource-gcg', 'scripts')) import tree # File containing stripped linetrees trees = open(sys.argv[1], 'r') # File containing all words in Dundee corpus words = open(sys.argv[2], 'r') #curSent = word...
176c546944843957e2e51faefb7a371eaa04e1f4693b956e2d5d84e4c0d89da4
Python
1,251
41
"""Plot heatmap visualization of worm pose in time.""" import numpy as np import matplotlib.pyplot as plt def heatmap(time, angles, clip=None, timestep=10, fig=None, ax=None): """Plot heatmap of pose data.""" xtimes = np.arange(min(time), max(time), timestep) xticks = [] for i in xtimes: ind...
3642e015f55b4fef7caa996280a65ed822bc82419754e55b80b635adfedb0424
Python
1,252
30
from Environment import * from Parameter import * # VISoR reconstruction of the generated BrainImage path with 561 channels and 488 channels to # synthesize 3D images with (z, x, y) size (64,3500,2500) def brain2dto3d(data_path, save_path, total_num, z_num, channel_index): temp = [] j = 0 name_index =...
c39a37ff92f0bc15bfd1797718abc93ef7b7edfd04b7ffa6de7a07eab2220def
Python
1,252
33
"""Phase 2 object-storage abstraction. Goal: stop hard-coding local-fs paths into the DB. Every artifact (Run pickle, dataset snapshot, notebook output, registered-model bytes) lands on an ``ObjectStore`` driver — same interface whether the bytes live on disk, in S3, in MinIO, or in GCS/Azure Blob. DB rows store **UR...
8c9fb16e8c68cb44e2ec07a22b0967e7c58486c5b349ead86fb589647a6e8b38
Python
1,253
39
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and relat...
49c90ffa398fadf06a2dbce4607aa68bd440c19fc8e6cdbe34086c869c3818f3
Python
1,254
36
import pytest from src.pipeline import PipelineBuilder, PipelineRepresentation from src.transform import SelectCols from src.test_config import pipe_config from sklearn.preprocessing import StandardScaler import tempfile import yaml def test_pipeline_representation(): name = 'pipeline1' description = 'Example ...
007f010d3638c92634c4bbbefb141ba546cf575122999e1bcc7057948b8abe09
Python
1,255
32
# 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...
a889037d6591257eaedb2f0eaf80908fd2a5f078d5e932ffd7e0bdcec6252fbc
Python
1,255
42
from __future__ import print_function import pysam import sys inbam = sys.argv[1] outbam = sys.argv[2] readsin = pysam.AlignmentFile(inbam, "rb") readsout = pysam.AlignmentFile(outbam, "wb", template=readsin) last_reference = None observed_reads = set() for read in readsin: reference_id = read.reference_id ...
3740f1a352b5e6c5208d166c9d66e943666a28ef76449d06a33397a3dfd859ac
Python
1,256
40
import numpy as np from numpy.random import default_rng def get_population(min, max, N, seed=None): """get population between min and max with N samples args: min: minimum value max: maximum value N: number of samples seed: seed for random number generator returns: ...
9aa5e466eefab76affe453b7295bd0952260bad9fbb037622eb5834bdf330e1f
Python
1,258
30
class SimArgs: def __init__(self, n_in: int, n_delays: int, seed: int, r_mu: float, r_std: float, tau_mem: float, noise_std: float, nb_epochs: int): # archi self.n_in = n_in # number of input channels self.n_out = 20 self.n_delays = n_delays # numb...
4b4fbe6a8e68cc46aae3ccd8014b19c3e1ffdf31a766f268cfbdf77140dd9ae2
Python
1,259
38
from VtkinterProcess.Vtkinter import Vtkinter import threading class VtkinterThread(threading.Thread): def __init__(self, config=None, stimulator=None, threadName='Vtkinter', app='paint'): threading.Thread.__init__(self) self.name = threadName self.config = config ...
9cbe2efea126690f3fbe6eceac8d0eceb866e217f1a553e5ba91a0d07bbd4a4f
Python
1,259
33
import torch class D2RLNet(torch.nn.Module): def __init__(self, input_size, units, activations, norm_func_name = None): torch.nn.Module.__init__(self) self.activations = torch.nn.ModuleList(activations) self.linears = torch.nn.ModuleList([]) self.norm_layer...
baa269b07049a69cec2080ea3ccbb106215d6ed1aa8c8e4fef18b3b7a4944b0b
Python
1,259
40
# -*- coding: utf-8 -*- """ Created on Wed Aug 26 20:08:08 2020 @author: KerschensteinerLab """ import pandas as pd import numpy as np from tkinter import filedialog, Tk import os from hunting_analysis_functions import * #import cricket_hunting_analysis_dataframe as ck #select h5 files and mp4 to analy...
cad27b20c694f8505b6db3b65ece75187a463edb1f2e5f35888654526eb929bd
Python
1,259
42
import reverb import tensorflow as tf class VariableContainer: def __init__( self, # --- db_server: str, # --- table: str, variables: dict, ): self._table = table self._variables = variables # Initializes the reverb client self.t...
e0c35c4ecfd480685cc3f9c3acbf9c1936362b15fbb52ebd9334aaf0f009f643
Python
1,259
48
import os import pysam # # NanomonSV's VCF format does not fit the truvari comparison, so we need refine its format # # STEP 1: bcftools sort # # STEP 2: SVINSLEN --> SVLEN # # STEP 3: reformat GT raw_vcf_path = "/mnt/d/workspace/svision-pro/paper_revision/real_nt_hcc1395/ont/nanomonsv.s2.vcf" output_vcf_path =...
12378dfa903f253f6704f5dadee2f28f1fbab7ba1eed82c0a46ff4283cf39c38
Python
1,260
41
import numpy as np import pytest import pandas as pd class TestCopy: @pytest.mark.parametrize("attr", ["index", "columns"]) def test_copy_index_name_checking(self, float_frame, attr): # don't want to be able to modify the index stored elsewhere after # making a copy ind = getattr(floa...
fc32f6db44b2aaf4667111bd63a3286d5c1bb73299345bd959b267d7c0c72e9c
Python
1,261
33
"""Tests for padding and cropping of data tensors.""" from typing import Literal import pytest import torch from mrpro.utils import RandomGenerator from mrpro.utils.pad_or_crop import pad_or_crop @pytest.mark.parametrize('mode', ['constant', 'reflect', 'replicate', 'circular']) def test_pad_or_crop_content(mode: Li...
407ecb29916563ec8c7e520164f6c148bfb72e20a92484dac56db264a7a8dbcb
Python
1,262
29
from .files import import_data, save_data from .wavenet import hidden_layer, normalize, generate_stepwise from .ooc_compute import ooc_training from .user_interface import set_config from dask import array as da import numpy as np def training(param, euler_dict, model, var, **IC_train): neurons = hidden_layer(par...
2e290d029dc9f7045a2908c4db2292cf6f58941644b2eab02a37e04a5b0d93bf
Python
1,263
40
# -*- coding: utf-8 -*- # Copyright (C) 2019 Andrea Vázquez Varela # 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 3 of the License, or # (at your option) any later version. #...
4c57d5d2c7f24876b67ced0f8990816b0a49eada8ad8971e3ab8c14987df06d9
Python
1,263
30
# Production of training data from Environment import * from Parameter import * def load_tif2array(file): image = sitk.ReadImage(file) image = sitk.Cast(image, sitk.sitkFloat32) image_array = sitk.GetArrayFromImage(image) image_array = np.transpose(image_array, [0, 2, 1]) return image_array d...
de1b3dcdb9f4efb2994d32b228d8b71248aa82d3271d570a798283463c20bb08
Python
1,263
41
import numpy as np import pytest import pandas as pd import pandas._testing as tm dtlike_dtypes = [ np.dtype("timedelta64[ns]"), np.dtype("datetime64[ns]"), pd.DatetimeTZDtype("ns", "Asia/Tokyo"), pd.PeriodDtype("ns"), ] @pytest.mark.parametrize("ldtype", dtlike_dtypes) @pytest.mark.parametrize("rdt...
327c9c65a942bd6b4f84dc3c75a5d9d4261e43b65b4d48727de1ac1c108c7c16
Python
1,264
39
from sys import path as sys_path sys_path.append('..') sys_path.append('../base') import os import matplotlib if 'DISPLAY' in os.environ: matplotlib.use('qt5Agg') else: matplotlib.use("Agg") os.environ['CUDA_VISIBLE_DEVICES'] = '1' from base.loggingUtils import setup_default_logging from base.kernelFunctions i...
9b44c32a39ad269ab79026724ff84b71221883981b408190bcef33026e42214e
Python
1,265
26
import models.args import os def get_args(): parser = models.args.get_args() # Model arguments parser.add_argument('--lr', type=float, default=0.00001) parser.add_argument('--weight-decay', type=float, default=0) parser.add_argument('--max-tokens', type=int, default=4096, he...
a052b2c7b200306e7ea719110074865e721f8b9374e94b98b74068a5d9a94bce
Python
1,265
40
# Copyright 2018-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...
ca4e7f537a704ff3a35ed29992f67737c85c27777d1ac548b945be4d57def202
Python
1,266
44
from numba import njit from numba.types import bool_ import numpy as np import torch @njit("(int64[:], int32[:], int32)") def remove_duplicates(spike_times, spike_clusters, dt=15): '''Removes same-cluster spikes that occur within `dt` samples.''' keep = np.zeros_like(spike_times, bool_) cluster_t0 = {} ...
fe2a9892bc355e8f05032446e1b2e45491a4a80c179a5d91f9c4e94e973372d0
Python
1,266
39
import tensorflow as tf class DuelingDQN(tf.keras.Model): def __init__(self, action_space): super(DuelingDQN, self).__init__() self.fc1 = tf.keras.layers.Dense( 512, activation="elu", kernel_initializer=tf.keras.initializers.Orthogonal(tf.sqrt(2.0)), ) ...
3425deac45f832890d8ec494ddedad5957a45ad0ae840cba18ba886ce38aeae0
Python
1,267
44
import pytest import pandas._testing as tm from pandas.core.arrays import DatetimeArray class TestAccumulator: def test_accumulators_freq(self): # GH#50297 arr = DatetimeArray._from_sequence( [ "2000-01-01", "2000-01-02", "2000-01-03", ...
16704276f252171d14e54778ae8d762a44c4162fab760d2220fc105e39ca0ba0
Python
1,268
43
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Function for making sensory motor ROI. Created on Fri Jan 18 14:24:35 2019. @author: mikkel """ import mne from surfer import Brain # Make sensory-motor ROI based on aparc.a2009s def make_sensorymotorROI(subj, subjects_dir, hemi='both'): atlas = 'aparc.a2009s' ...
2d483a71748cf024a5dd91f1187ddb33d3db90743bda94fb4d2f5b839e1fec16
Python
1,269
40
# 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...
4ba2d2f4d14db100a941784576cf0b2e1e4b4b9237cedf7eb8c4ffd3a4856ae7
Python
1,271
36
import pytest import pandas as pd import pandas._testing as tm class TestSwaplevel: def test_swaplevel(self, multiindex_dataframe_random_data): frame = multiindex_dataframe_random_data swapped = frame["A"].swaplevel() swapped2 = frame["A"].swaplevel(0) swapped3 = frame["A"].swapl...
808d3b5ddc9f295213626037d43549573e4ea033e745e5c87d30e2b6e2b7eb23
Python
1,272
44
"""Class for Density Compensation Operator.""" import torch from mrpro.data.DcfData import DcfData from mrpro.operators.EinsumOp import EinsumOp class DensityCompensationOp(EinsumOp): """Density Compensation Operator.""" def __init__(self, dcf: DcfData | torch.Tensor) -> None: """Initialize a Densi...
b181dc97996c8fbc2eb750a21592b892719f798b047dbd7956cd68c817296527
Python
1,273
44
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Aug 18 15:41:13 2021 @author: rishikesh """ import torch import numpy as np from torch import nn def off_diagonal(x): # return a flattened view of the off-diagonal elements of a square matrix n, m = x.shape assert n ...
6da778b07310096f77914b7cd570410709fc08e2923539167d01a01a87d9cde8
Python
1,274
39
import pandas as pd def test_is_monotonic_increasing(): # GH#17717 p0 = pd.Period("2017-09-01") p1 = pd.Period("2017-09-02") p2 = pd.Period("2017-09-03") idx_inc0 = pd.PeriodIndex([p0, p1, p2]) idx_inc1 = pd.PeriodIndex([p0, p1, p1]) idx_dec0 = pd.PeriodIndex([p2, p1, p0]) idx_dec1 = ...
eb1588cbb25870eeb948051bc1a16fa0c0d961b35782e7d76bfdcccfe30c3ebe
Python
1,274
45
from OperationSystem.AnalysisProcess.TestingProcess import TestingProcess from OperationSystem.AnalysisProcess.WaitAnalysisProcess import WaitAnalysisProcess import json class AnalysisController: def __init__(self): self.current_process = None self.algorithm = None self.actualWin = ...
940a28a79fa8e3df59b7b8876b6d1f1cff42621f0d7825cda0f3bce71c6ca5f7
Python
1,275
31
import sys, argparse import pandas as pd argparser = argparse.ArgumentParser(description='Generates geco.evmeasures data table.') argparser.add_argument('f1', type=str, nargs=1, help='Path to experiment data table') argparser.add_argument('f2', type=str, nargs=1, help='Path to itemmeasures data table') args, unknown =...
4f2e5b3389cbcf0c83bc5adad8f74d230bae61577f6ed3234010c761744fa827
Python
1,276
49
import argparse import h5py import nibabel as nib import numpy as np import os DIR = os.path.dirname(os.path.realpath(__file__)) print(DIR) # %% parser = argparse.ArgumentParser(description='convert .h5 to .nii') parser.add_argument('--input_data', default='meas_MID00402_FID02551_EPISeg2_67_1p0is...
53d7af7ad96b25847d22b9bc73f0c5847a879061d274f759a3b9e8ce653c0ae8
Python
1,276
45
import argparse # Evaluates the dice score of segmentations given directories with saved # segmentations in npy format. def get_args(): parser = argparse.ArgumentParser( description='Train UNet Model', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( '-c',...
8a734643b88a93e7672de1065993b6ffcabdafd55b5000f1d792b4b9163c8f6f
Python
1,277
65
""" Data I/O API """ from pandas.io.clipboards import read_clipboard from pandas.io.excel import ( ExcelFile, ExcelWriter, read_excel, ) from pandas.io.feather_format import read_feather from pandas.io.html import read_html from pandas.io.iceberg import read_iceberg from pandas.io.json import read_json fro...
97b0da873996fbf1fe0901d5c806d71e602184b06d8d7c37bdd8881602c9f3a5
Python
1,277
29
# from initialization.config import * # from initialization.initialization import * # # from data_processing.cell_identifier import * # from data_processing.cleaning_formatting_filtering import * # from data_processing.clustering import * # from data_processing.data_io import * # from data_processing.data_wrangling imp...
ee88502bc18213ae8bea9302df658a5ce4e57ad981673f8baeca85f6a5327adb
Python
1,277
49
"""Keep executable sources and user documentation on the current data host.""" import re import subprocess from pathlib import Path ROOT = Path(__file__).resolve().parents[1] SOURCE_PATHS = ( "src", "clocks", "docs", "tutorials", ".github", "Makefile", "pyproject.toml", "uv.lock", ...
b8659341177259783bebd8a0193c5fce8796f8a67b7b34775f9b226391a94d70
Python
1,278
29
# from initialization.config import * # from initialization.initialization import * # from data_processing.cell_identifier import * # from data_processing.cleaning_formatting_filtering import * # from data_processing.clustering import * # from data_processing.data_io import * # from data_processing.data_wrangling impo...
e202c230fdcd82e16dd338b796384675ba8d046bea2f76d8a99cf510b139f27a
Python
1,278
25
import tempfile from esmologs import fasta2foldseek import helpers def test_fasta2foldseek_1(shared_datadir): with tempfile.TemporaryDirectory() as output_dir: #output_dir = "tmp" fasta2foldseek.main(["--aa", str(shared_datadir / "af2_examples.pep.fasta"), "--tdi", str(shared_datadir / "af2_example...
a3e5aa9bec24206f1fcf5490922d51a838c0b5bbd70716a1431d5fba0e8c2efa
Python
1,279
47
from datetime import ( UTC, datetime, ) import dateutil.parser import dateutil.tz from dateutil.tz import tzlocal import numpy as np import pandas as pd import pandas._testing as tm from pandas.tests.indexes.datetimes.test_timezones import FixedOffset fixed_off = FixedOffset(-420, "-07:00") class TestToPyD...
5c779bb4bc949c3a12515b545bba394b0dc8b05035de70f1578610be10aa806e
Python
1,281
38
# 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...
196fc223c5d436d93397abe9a6a2dc8458440eb83cf3bf9353e48131611c70b7
Python
1,282
53
import torch.nn as nn class View(nn.Module): def __init__(self, shape_out): super(View, self).__init__() self.shape_out = shape_out def forward(self, x): return x.view(self.shape_out) class Permute(nn.Module): def __init__(self, dims=(1, 0, 2)): super(Permute, self).__in...
047e51da5337e733517ffccc377f12eaccb75078f320cfdff11e5a6b8ae6aa56
Python
1,283
49
#!/usr/bin/env python ''' Testcases for the loiter detection ''' import windseer.utils as utils import windseer import numpy as np import os import unittest windseer_path = os.path.dirname(windseer.__file__) testdata_folder = os.path.join(windseer_path, 'test', 'testdata') test_file_hdf5 = os.path.join(testdata_fold...
a72c03942c2c27eb67798924fcd483fb979c0c98ee3dfe52de54a3411c145e0c
Python
1,285
36
from isaacgymenvs.pbt.launcher.run_description import ParamGrid, RunDescription, Experiment from isaacgymenvs.pbt.experiments.run_utils import version _env = 'ant' _name = f'{_env}_{version}' _iterations = 10000 _pbt_num_policies = 3 _params = ParamGrid([ ('pbt.policy_idx', list(range(_pbt_num_policies))), ]) _...
12324dc5d3f2ff4976fbb08eb4435ad3a196c2daa434045408391598c090a07d
Python
1,286
36
from msmfcode.core.logging import log from msmfcode.core.config import * from msmfcode.execution.parallel import ParallelExecutor, ParallelEvaluationExecutor from msmfcode.models.cann import DMSMF, FMSMF, Grid, SSSF from msmfcode.evaluation.plot import plot_weight_distribution, plot_neuron_activity_fixed_attractors, \ ...
126e9b36941cd69cbf60db518145b6955ce4a62ba6510bd256d34eff12e737a3
Python
1,286
55
import numpy as np import pickle def get_griddata(griddata): with open(griddata, 'rb') as f: return pickle.load(f) def get_grid(grid): parameter = {} with open(grid) as f: for line in f: data = line.strip().split() parameter[data[0]] = np.array(data[1:], dtype='f...
4a52a799ce7c2f6ab9014bdc0594b6032988b9dd4e704435b46a6506bc15282b
Python
1,286
35
from pathlib import Path import pandas as pd import numpy as np class StatsFile(): def __init__(self, file: Path, type: str) -> None: self.file = file self.type = type self.stats = pd.read_csv(file, sep='\t') self.stats.rename(columns={'Measure:volume':'subject_id', 'lh.aparc.volume...
32287049be422e96934d796e903e6a52d21dc7976feb298de979092b2e9f3923
Python
1,289
44
# 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...
90ddb1f3e94cf4e9501670b9f9295fd6225b2ecf0b93cad75445c56320028853
Python
1,291
55
# -*- coding: utf-8 -*- """ Created on Wed Jun 21 19:39:01 2023 Convolutional Spiking Neural Networks for Intent Detection Based on Anticipatory Brain Potentials Using Electroencephalogram Authors: Nathan Lutes, V. S. S. Nadendla, K. Krishnamurthy """ # train different networks on paper 1 using k fold cross-validati...
4004ac91c4cb14f986793494ad7c6ecbb6ecc84be118e731b51dcd7fc8329e49
Python
1,293
47
"""Declarative base + reusable mixins. Every table gets UUID v4 `id` + `created_at` / `updated_at`. Most get `created_by` as an FK to `users.id` — that's added per-model rather than in a mixin because the FK is awkward to express before `User` is defined. """ from __future__ import annotations import uuid from datet...
6c59416be2af4c91b386a79c3fa54f831bb6af4b32fc6535f3e0926c208576df
Python
1,293
34
import sys, re resources = {} for path in sys.argv[1:]: with open (path, 'rb') as f: line = f.readline() while line: while line and not line.strip().startswith('define RESOURCE-DESCR'): line = f.readline() if line: descr = '' ...
8894809a1a4a3cf9e2e31c0be5222fac759725b5464bc155dc0520c655fec0aa
Python
1,295
50
import sys, os, argparse sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'resource-gcg', 'scripts')) import tree argparser = argparse.ArgumentParser(''' Prints a CoNLL style table of word and PoS tags from linetrees input. ''') argparser.add_argument('-i', '--noindex', dest='i', action='store_true'...
e31cdceb0d82eb0dc6bc275fbaa07e299a6d273fe32b217ee748fafe6bf71248
Python
1,295
28
""" Some notes on how to extract e-fields from simnibs/pynibs FEMs at a cortical target. This expects optimal coil placements computed with https://gitlab.gwdg.de/tms-localization/papers/tmsloc_proto """ import h5py import pynibs headmesh_msh = "path/to/simnibs/headmesh.msh" # original simnibs mesh headmesh_hdf5 = "p...
a91d275f86de1642167ee3fb85e2d675d56e6fb66799e6ceb63cb954d8c98d8f
Python
1,297
32
import sys, argparse import pandas as pd argparser = argparse.ArgumentParser(description='Generates provo.evmeasures data table.') argparser.add_argument('f1', type=str, nargs=1, help='Path to experiment data table') argparser.add_argument('f2', type=str, nargs=1, help='Path to itemmeasures data table') args, unknown ...
2a0390eafe86ce85d85ea447c9b24c23dc568636e20b705e086f874bc9c85cb2
Python
1,299
36
"""Test backbone factory.""" import pytest from lightning_pose.models.backbones.factory import ( _build_convnet_backbone, _build_transformer_backbone, build_backbone, ) class TestBuildBackbone: """Test the build_backbone function.""" def test_raises_for_unknown_backbone(self): """Raises...
2cb430ac3e1d96caf44fb6c5ef29294d166a86e89a53e58a17fb165833f88835
Python
1,299
24
"""Model/training/evaluation/explainability pipeline (Phase 2b). Ports the scientifically meaningful behavior of `Training.ipynb` and `Heatmaps.ipynb` (see `docs/legacy-notebooks-inventory.md`) into current, typed Python. **Imports TensorFlow unconditionally**; run `just install` (installs the `model` extra along with...
50be93f65d9739e9e71e05382f0763fa04a1d7da99a89939712f28aaaa2cc654
Python
1,299
43
# 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...
2274587ffd9af822e9acb29bfb9d681a5c382cda4c2f9b721a5679205d7539c0
Python
1,300
35
import numpy as np import pandas._testing as tm class TestAutoCorr: def test_autocorr(self, datetime_series): # Just run the function corr1 = datetime_series.autocorr() # Now run it with the lag parameter corr2 = datetime_series.autocorr(lag=1) # corr() with lag needs Se...
4a50be5e865d38f5c473d766e5d498f43b1f47d099556506b9491c198ca1b7ac
Python
1,300
43
import numpy as np, matplotlib.pyplot as plt, matplotlib.cm as cm import pumpprobe as pp, wormdatamodel as wormdm folder = "/projects/LEIFER/francesco/pumpprobe/AKSxneuropal/20210907/pumpprobe_20210907_141336/" fconn = pp.Fconn.from_file(folder) signal = wormdm.signal.Signal.from_file(folder, "green") ie = 15 time,t...
878ff2ed523bad0ff56330a482288b5014f1c02da9b511262cf7ad6e16591a13
Python
1,301
32
"""Dictionary batches keep the worker/agent dimensions with one worker too.""" import numpy as np import pytest from rl_games.common.tr_helpers import dicts_to_dict_with_arrays @pytest.mark.parametrize('workers', [1, 2, 4]) @pytest.mark.parametrize('add_batch_dim', [True, False]) def test_dictionary_collation_preser...
f107912fb2d0b1d6617ddd6fb6785ebd67d3ba7b467f22eea51e61d84aae177a
Python
1,301
46
import cine from matplotlib import pyplot import tube2 import keras import numpy as np from skimage import io model = keras.models.load_model("meniscus_utils/meniscus_track_4") FILENAME = "data2/unsuitableVideos/moth22_2022_02_04_Cine1.cine" PAUSE = 0.5 #fig, ax = pyplot.subplots() try: video = cine.Cine(FILENAME...
71fb31fe93bfcdc851ccd11bb1738646f4daeddf6877c4b9865f912d35a5b269
Python
1,302
33
# 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...
84fb0cc3a0171d8dcebc2ef988b40b7f2bce09ee5ae7697b5231094ec9c4e665
Python
1,302
39
# 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...
f546b797637527c468ab380ded9fe2a18c88c020812de20a8557ab6d0222fec9
Python
1,302
35
"""Load digitclutter. """ import os import pandas as pd import numpy as np import torch from torch.utils import data from PIL import Image from torchvision import transforms class Digitclutter(data.Dataset): def __init__(self, path, root='./_data', transform=None, image_size=None): if image_size is None:...
7396714ada5d3e5db76202a7485fd4d4239be02687548d279ae4ed7b50d4a42d
Python
1,303
66
#!/usr/bin/env python # -*- coding: UTF-8 -*- # Created by Roberto Preste import pytest import os from mtoolnote.tests.constants import ( HUMAN, HUMAN_ANN, HUMAN_ANN_CSV, HUMAN_ANN_HAPLOS, HUMAN_ANN_HAPLOS_CSV, GGALLUS, GGALLUS_ANN, GGALLUS_ANN_CSV ) @pytest.fixture def human_vcf(): """Open the human vcf...
1c93b8d2d57839cd06873375e0c99142d15e81e6bc66ca126dac2464dae2f0ff
Python
1,304
30
import pandas as pd import os import sys import pdb 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 Image from config.globals import ENVIRONMENT ...