sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
80362e28d45ebc7c227bb34367840b9d8c5ebedeac6711d60a2ea8c881256228
Python
1,069
43
import pytest import pandas as pd from pandas.core.arrays.floating import ( Float32Dtype, Float64Dtype, ) @pytest.fixture(params=[Float32Dtype, Float64Dtype]) def dtype(request): """Parametrized fixture returning a float 'dtype'""" return request.param() @pytest.fixture def data(dtype): """Fixt...
a079dde0498568aec94509dc10c207247727282230596c4b5991474036eb0385
Python
1,070
31
"""Tests of split index calculation.""" import pytest import torch from einops import repeat from mrpro.utils import RandomGenerator, split_idx @pytest.mark.parametrize( ('ni_per_block', 'ni_overlap', 'cyclic', 'unique_values_in_last_block'), [ (5, 0, False, torch.tensor([3])), (6, 2, False, ...
1294c425436784f6eb6252c2183209425d33b29168626e19b579c57c769bde3b
Python
1,071
27
import logging import numpy as np import nibabel as nib def save_estimations_as_nifti(estimations, model, powder_average_path, mask_path, out_path): aff, hdr = nib.load(powder_average_path).affine, nib.load(powder_average_path).header powder_average = nib.load(powder_average_path).get_fdata() if powder_a...
46c77199df82bd13dc2e94ce68755af3d8bd9b8d464487b21928e79ec2eaaf00
Python
1,071
28
import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import os excitatory = ['L6cc', 'L2', 'VPM', 'L4py', 'L4ss', 'L4sp', 'L5st', 'L6ct', 'L34', 'L6ccinv', 'L5tt'] inhibitory = ['SymLocal1', 'SymLocal2', 'SymLocal3', 'SymLocal4', 'SymLocal5', 'SymLocal6', 'L45Sym', 'L1', 'L45Peak', 'L56Trans', 'L...
8d1890d33b4a401856f261d967470aac72ba959992fe11ff0b3c8b43c66d9759
Python
1,071
30
import pytest import pandas.util._test_decorators as td import pandas as pd @pytest.mark.parametrize( "values, dtype, expected_dtype", ( ([1], "int64", int), ([1], "Int64", int), ([1.0], "float64", float), ([1.0], "Float64", float), (["abc"], "object", str), (...
f911c8728a987d9e9fe9726e2a5171b61227a090ca0c983b1c9483a72f799ac9
Python
1,072
45
import pytest import pandas as pd from pandas.tests.extension.list.array import ( ListArray, ListDtype, make_data, ) @pytest.fixture def dtype(): return ListDtype() @pytest.fixture def data(): """Length-10 ListArray for semantics test.""" data = make_data(10) while len(data[0]) == len(...
080f9327116fec2da43aa3de5099f32f4d6519ddbc5601564d8f9c7b68da34bb
Python
1,073
35
default_param = { "Autofluo channel": '488nm', "Staining channel": '561nm', 'voxel_size': '4', 'Brain_weight': '3500', 'Brain_height': '2500', "Thickness": '75', "Network_input_z": '64', "Network_input_x_y": '256', 'Train_total_num': '40', 'Cut_index_x': '470', 'Cut_index_y':...
5ca393cdeabc169653a73af9e966f01b84b16dc055ee5cfea03dbc92fb4de79f
Python
1,073
41
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Feb 20 12:04:14 2023 @author: tomas """ import glob from cine import Cine import tube2 from meniscus3 import locate_objects, find_real_measurements, get_stem from matplotlib import pyplot filenames = glob.glob("data2/unsuitableVideos/*.cine") def pro...
ae946ce615dedc022950a5acc74d66ff97b29c41fe218f0b6fd03cf385a69053
Python
1,073
38
import argparse import matplotlib.pyplot as plt from osgeo import gdal parser = argparse.ArgumentParser(description='Rescale a geotiff') parser.add_argument('-i', dest='input', required=True, help='Input geotiff') parser.add_argument('-o', dest='output', required=True, help='Output geotiff') parser.add_argument( '...
acf36265c1a661a24e0fa7787d99ba932dbe7b170b2490f9595ca4ed792d2490
Python
1,074
44
import numpy as np import pandas as pd import time import datetime def es_mu(esws: list, verbose: bool=False) -> pd.DataFrame: """Compute ESmu Computes mean of ESWs, i.e. ES_mu, for each gene / cell-type. Parameters ---------- esws : list List of ESw dataframes to compute mean from. ...
96ea42cc71c00310d2a746dff6051a04ee28927be766cfd4ca9125c49265fcd5
Python
1,075
32
# Copyright 2018-2020 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...
059b7763b8e079c12c2c20b6af033869277874c086073a2f8c0cffb3a00c06be
Python
1,076
38
"""TaskType — the enum of ML tasks PyCaret supports. Using a real Enum instead of a string makes it easy for an LLM agent or a React UI to enumerate what's available without guessing. """ from __future__ import annotations from enum import StrEnum class TaskType(StrEnum): """The machine-learning task a PyCaret...
07004b1c93d19126df615e2fc8207221a3070a14efc38414f9b170c65c4555ef
Python
1,076
28
from isaacgymenvs.pbt.launcher.run_description import ParamGrid, RunDescription, Experiment from isaacgymenvs.pbt.experiments.allegro_kuka_pbt_base import kuka_env, kuka_base_cli from isaacgymenvs.pbt.experiments.run_utils import version _pbt_num_policies = 8 _name = f'{kuka_env}_throw_{version}_pbt_{_pbt_num_policie...
bc7c017c0804b0efe7ab13f46b10a159f3c44ee97316037d18cdaa66911949e8
Python
1,076
38
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Feb 27 14:13:57 2023 @author: tomas """ import meniscus_rate as mr import glob from sklearn.ensemble import IsolationForest from matplotlib import pyplot def no_skinny(data): return data[data[:,7] - data[:,5] > mr.MIN_WIDTH] def remove_outliers(d...
dcaceddcbfe9ab5f6281218bdd890b04cd09a1298bbbca75988d9ab8524bb982
Python
1,077
25
from Environment import * from Parameter 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}_seg.tif'.format(i))) image_array = sitk.GetArrayFro...
4058139912420d0bf7f13dcb34a8c6315b651b00e1ded4220906f4393c200f4f
Python
1,078
37
from multiprocessing import Array, Process, Event import time import random def test_ring_buffer_array(eno1_buffer, event): while (True): time.sleep(4) # Generate a list of 10 random integers between 1 and 100 (inclusive) random_integers = [random.randint(1, 1000) for _ in range(10)] ...
1f1940bed47875b591322e78358df75fc38a4b9d71b2b078092026003d3d1e97
Python
1,081
35
import numpy as np allocentric_color = '#{:02x}{:02x}{:02x}{:02x}'.format(109, 47, 255, 248) # a.k.a task-anchored egocentric_color = '#{:02x}{:02x}{:02x}{:02x}'.format(0, 220, 184, 255) # a.k.a task-independent null_color = '#{:02x}{:02x}{:02x}{:02x}'.format(128, 128, 128, 255) # a.k.a aperiodic alt_egocentric_color ...
0b6fd54b938d0eff4882179601d8dd446c55edf89524c49085757b1851582ebf
Python
1,082
36
"""Fixtures for scripts/hyper-sweep tests. `scripts/hyper-sweep` uses a hyphen in its directory name, so it is not a valid Python package and its modules cannot be reached with a normal `import` statement. Load them from their file path instead. """ import importlib.util import sys from pathlib import Path from types...
b4f1bab1b9668f30ade1545ee692c4f0bd71dfec05ba11b7cdce8b67c32edb9b
Python
1,083
30
from isaacgymenvs.pbt.launcher.run_description import ParamGrid, RunDescription, Experiment from isaacgymenvs.pbt.experiments.run_utils import version, seeds, default_num_frames kuka_env = 'allegro_kuka_two_arms_regrasp' _frames = default_num_frames _name = f'{kuka_env}_{version}' _params = ParamGrid([ ('seed',...
92b5b772db5e67400f667c18dd46465e9a3bf828a817f0ea1b080c2f92d5fc34
Python
1,085
28
# # a script to go from berkeley's .grammar file format to our CKY parser's format import re import sys #startsyms = 1 for line in sys.stdin: arr = line.split(' ') if len(arr) == 4: arr[0] = arr[0].replace("&","-") arr[2] = arr[2].replace("&","-") #una...
29bee3f4c4aff4ede053ccec603bc76ad6076e40af70a97371022fdb527929fd
Python
1,086
36
import pandas as pd import pandas._testing as tm class TestDataFrameCount: def test_count(self): # corner case frame = pd.DataFrame() ct1 = frame.count(1) assert isinstance(ct1, pd.Series) ct2 = frame.count(0) assert isinstance(ct2, pd.Series) # GH#423 ...
05f9e9c293735a101dc00d32a8b3a4c3e83a0f4f84c52e346fbc8722b38c6a60
Python
1,087
36
import sys import pandas as pd import argparse argparser = argparse.ArgumentParser(''' Tiles stimuli by subject into experiment data. ''') argparser.add_argument('stimuli', help='Path to data table containing stimuli') argparser.add_argument('responses', help='Path to data table containing by-subject responses...
2c2cd788d77e8f6bf0946e2951411496a5aaa6685728ece3e02629d99ebeec84
Python
1,087
29
import sys import os sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'resource-gcg', 'scripts')) import model import argparse argparser = argparse.ArgumentParser(description=''' Counts and divides model-formatted files. ''') argparser.add_argument('-n', '--no-normalization', dest='nonorm', action=...
7f509de4203532b48bdd23604ea4948d11f73a80d1c515ce165225ec4a913758
Python
1,088
37
from docutils import nodes from docutils.statemachine import ViewList from docutils.parsers.rst import Directive from sphinx.util.nodes import nested_parse_with_titles import os class RTDPDF(Directive): def run(self): if "READTHEDOCS" in os.environ: project = os.environ["READTHEDOCS_PROJECT"]...
aa19b73bd71b1ce24131038bf8b625d7ea3374c6db9dc039c3610bd32aa03724
Python
1,088
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...
7979235edf2ff5a7afd41a38c404e854ae2b63131f6fc225ca8127a372a79fb4
Python
1,089
51
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Feb 27 20:21:38 2023 @author: tomas """ from cine import Cine import glob import align import numpy as np import random from skimage.filters import sobel, threshold_li from skimage.io import imshow from matplotlib import pyplot def difference(left, r...
a5da682662d53986167c14b19f9b5b48be84f5e6219e72ed792c0fd24606dfed
Python
1,089
19
def test_detect_ref(): import pheweb.load.detect_ref, os default_builds = pheweb.load.detect_ref.get_default_builds() filepath = os.path.join(os.path.dirname(__file__), 'input_files/', 'assoc-files', 'has-fields-ac-af-maf.txt') # has only chr10 variant_iterator = pheweb.load.detect_ref.make_variant_ite...
0fc819cf4aa7eb1d7a7eb658b7a4f24381283fdd61e6bc0ebe8761e96770ab3a
Python
1,090
29
# 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...
a0337a98c369df1d05d550e485a4482b4feb76aedab0d6bf0126d8832792d922
Python
1,090
32
import pandas as pd import pandas._testing as tm class TestToDictOfBlocks: def test_no_copy_blocks(self, float_frame): # GH#9607 df = pd.DataFrame(float_frame, copy=True) column = df.columns[0] _last_df = None # use the copy=False, change a column blocks = df._to_d...
320b4538e0d6b8dd68c51ce21503463b358c3a5e98a67bbeb517ebe53238a8be
Python
1,092
39
import multiprocessing import threading import os import time import concurrent.futures # 多线程反编译函数 # @Jully_xiaoman def multi_decompile(apk_list): threads = [] for filename in apk_list: inputpath = os.path.join(path, filename) outputpath = os.path.join(outpath, filename) threads...
b6d198ab8314a0743cffa76a20736260db2d85d5d9606f06a8e23210d3979775
Python
1,093
40
import logging import os # Directly modified from the OT-flow Github Depository def get_logger(logpath, filepath, package_files=[], displaying=True, saving=True, debug=False, mode="a"): logger = logging.getLogger() if debug: level = logging.DEBUG else: level = logging.INFO logger.setLe...
d5859e7c2efe3de84bed280154fb3d8f13def12856309018af8431cc1b57be25
Python
1,093
35
from pgen.utils import parse_fasta import argparse import sys if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("-i", default=None) parser.add_argument("-o", default=None) parser.add_argument("--clean_strategy", type=str, default=None, choices={"delete", "upper", "unali...
d239603f5795c494980be23a1d7ee73bd66931b5257e282bd7206035e758e719
Python
1,094
40
import sys import pandas as pd import argparse argparser = argparse.ArgumentParser(''' Add Natural Stories document ID's to item-level tokenization ''') argparser.add_argument('src', help='Path to source tokenization table <NSDIR>/naturalstories_RTS/all_stories.tok') args = argparser.parse_args() docnames = [None, 'B...
4b83846db348c4aedccda29d2ddab957d2cb2162c38b496a7200bed664c5068e
Python
1,095
44
import numpy as np import pandas as pd import time import datetime def es_sd(esws: list, verbose: bool=False) -> pd.DataFrame: """Compute ESsd Computes standard deviation of ESWs, i.e. ES_sd, for each gene / cell-type. Parameters ---------- esws : list List of ESw dataframes to comput...
5f6f827f59bce15c273ac75ad4519b567cbfa23124609187271952d1c574e3da
Python
1,096
48
""" transforms.py is for shape-preserving functions. """ from __future__ import annotations from typing import TYPE_CHECKING import numpy as np if TYPE_CHECKING: from pandas._typing import Scalar def shift(values: np.ndarray, periods: int, fill_value: Scalar) -> np.ndarray: new_values = values if per...
e2561d6ca6c3d7117f944743c9582c40dea198f8a7d6e90f55d7999fc24e7a4e
Python
1,097
31
import pandas import numpy cellLineList = pandas.read_csv('cellLine.tsv', sep='\t', low_memory=False, index_col=0) cellLineList = cellLineList.columns cellLineData = pandas.read_csv('data CCLE/CCLE_RNAseq_genes_rpkm_20180929.gct ', sep='\t', low_memory=False, index_col=1, skiprows=2) cellLineName = cellLineData.col...
01ae73d54946127e5773cb1bbb965c4d9b4d8556df0f572481da0fac7a8cf3b9
Python
1,098
38
import torch from torch import nn # Typing from torch import Tensor from typing import List, Optional, Tuple class MLP(nn.Module): """Multi-layer perceptron. """ def __init__(self, dims: List[int], act=None) -> None: """ Args: dims (list of int): Input, hidden, and output dime...
c97bca8cfd3d524b50cb1307c2aa57e31d34b87f03c262b75ee4871729214e8f
Python
1,098
41
import torch import torch.nn as nn from darts.api import Model from darts.genotypes import PRIMITIVES from darts.modules.operations.conv import OPS class MixedLayer(Model): """ A mixture of 8 unit types We use weights to aggregate these outputs while training. and softmax to select the strongest edges w...
32a658b3dd6faa8b8aa07564d528cffbe2299c1306eaecd56ec029c774d21ee0
Python
1,099
33
import functools from PyQt6.QtWidgets import QApplication from PyQt6.QtGui import QCursor from PyQt6.QtCore import Qt, QEventLoop class ShowWaitCursor(object): def __enter__(self): QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor)) # This overloaded function call makes sure that a...
b118e7ade2d00b0af992e98d481059b364f051d598cf9dff34a788fcf9fc6c5f
Python
1,099
27
# 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...
e5c61e05edde57a1bee7ebc8315fb3b9e5b671660e8541faec5b6ce612b22f89
Python
1,099
34
#! /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...
18bf3266621f4a8dfe24643cb9a2faf840b25f88af1a0bf0847be975af8dbc80
Python
1,101
32
import pandas as pd import sys names = ['subject','word','sentid','sentpos','fdurFP','fdurGP','wdelta','wlen', 'resid', 'prevwasfix', 'startofsentence', 'endofsentence'] cumwdelta = 1 def calccumwdelta(row): global cumwdelta tmp = cumwdelta if row['RTfirstfix'] == 0: cumwdelta += 1 else: ...
8b9bdad2ad9677b492744cda9d6160b23e91be8f240230a107387859851280b8
Python
1,102
42
__all__ = ["zip_content"] import os from typing import Literal, Optional, Tuple try: from zipfile_deflate64 import ZipFile except ModuleNotFoundError: from zipfile import ZipFile def resolve_zip_content_path(path: str) -> Tuple[str, Optional[str]]: if os.path.exists(path): return path, None ...
72518d37cbb377c1dcbaa36c42ad1fbd21f95bbefa84450ef512b634f13135bc
Python
1,103
46
import torch from tnn.loss import t_softmax import matplotlib.pyplot as plt import imageio tmp = imageio.v3.imread('elephant.jpeg') img = torch.tensor(tmp).float() / 255.0 M = 1.0 * torch.tensor([[-1, 1, 1], [0, 1, 1], [0, 0, 1]]) M_inv = 1.0 * torch.tensor([[-1, 1, 0], [0, 1, -1], [0, 0, 1]]) f = [lambda x: torc...
b1ac462f4dd6bf17c7619b7d93a37953df054cbb81c1e9020e74fac61d933c5c
Python
1,103
29
from circlemap.utils import start_realign,insert_size_dist import multiprocessing as mp from circlemap.realigner import realignment import os from tqdm import * input = "/home/iprada/faststorage/projects/6_aged_yeast/working_directory/aligned/BM3/sort_circle_qname_BM3.bam" qbam = "/home/iprada/faststorage/projects/6_a...
2d24665d972c68ebe36ed05fb19df5fcf3f3f2e68f3925edd1d0a5d233a5135e
Python
1,104
30
import setuptools from glob import glob # Will load the README.md file into a long_description of the package with open("README.md", "r", encoding="utf-8") as fh: long_description = fh.read() # Load the requirements file with open('requirements.txt') as f: required = f.read().splitlines() if __name__ == "__mai...
3320e217a8a0e42500207ba4aeed01a3b956a2ef87d198b8e01067e73732b6e5
Python
1,104
29
"""Basic plugin This plugin defines two simple features by calculating them in the `compute_some_new_features` function and setting the plugin metadata in the `info` dictionary. It is used for testing in dclab. """ def compute_some_new_features(rtdc_ds): """The function that does the heavy-lifting""" circ_pe...
46ba69dd9bc3d5fd877050335d6985167a83a9f218bd8de4d3b534b282c3bedf
Python
1,104
40
import sys sys.path.append('') import numpy as np class s2t(object): def __init__(self, filename): self.t2v = {} self.dim = None for line in open(filename): line = line.strip().split('\t') t = line[0] v = np.array([float(x) for x in lin...
558eeb243b3f5cd3e3a812121080d2d180ef7dcdaa02a87e1e8d3c9b9dd5f061
Python
1,105
40
from datetime import timedelta import pandas as pd class TestAsOf: def test_asof_partial(self): index = pd.date_range("2010-01-01", periods=2, freq="ME") expected = pd.Timestamp("2010-02-28") result = index.asof("2010-02") assert result == expected assert not isinstance(re...
a058af856b3e0f4401518fa58eda12a3f9705355953751202bee2a1e10456d62
Python
1,106
40
import pytest import pandas as pd import pandas._testing as tm @pytest.fixture def range_index(): return pd.RangeIndex(3, name="range_index") @pytest.fixture def interval_index(): return pd.IntervalIndex.from_tuples( [(0.0, 1.0), (1.0, 2.0), (1.5, 2.5)], name="interval_index" ) def test_join_...
2790bd4f897bc1f14b73447c679397861321dffc198af2c265d5f27e03a5d0c1
Python
1,107
48
"""Installation script for the 'isaacgymenvs' python package.""" from __future__ import absolute_import from __future__ import print_function from __future__ import division from setuptools import setup, find_packages import os root_dir = os.path.dirname(os.path.realpath(__file__)) # Minimum dependencies required...
89479e19a5a2f21cf95b29a41f61fac5d2f5d091fb9f8d388acb7b82e64ec228
Python
1,107
36
from .DropDownMenu import DropDownMenu class SelectROI(DropDownMenu): """ Class for selecting Region of Interest (ROI) from a dropdown menu. """ def __init__(self, default_msg): """ Initialize the SelectROI class. Args: default_msg (str): The default message to di...
b3acf86421f0c3f4fb3c92a543d70ce2d2f99022c7fbec84ab1521b94ff4b08c
Python
1,107
39
import numpy as np, matplotlib.pyplot as plt, sys import pumpprobe as pp folder = sys.argv[1] fconn = pp.Fconn.from_file(folder) # Times on which to look for the peak time tmax = 60 time = np.linspace(0,tmax,1000) # Iterate over stimulations and responding neurons peak_times = [] integrals = [] for ie in np.arange(...
c239e5481701dfe3900827b48c205b2cb492f98d3124cbec93c00eee030e2a6a
Python
1,108
33
import pytest import torch from lightning_pose.models.heads.regression import LinearRegressionHead class TestLinearRegressionHead: @pytest.fixture def basic_head(self): """Create a basic LinearRegressionHead instance for testing.""" return LinearRegressionHead( in_channels=512, ...
c9e2447e231f18cf738ac3706126282a974f9aba55445edd2bf35b6b12be55c8
Python
1,108
31
from sys import path as sys_path sys_path.append('..') sys_path.append('../base') from base.loggingUtils import setup_default_logging from base.kernelFunctions import Kernel from base import surfaceMatching from base import surfaces as surfaces from base import secondOrderMatching as match setup_default_logging('../O...
8be738faceae07bee4ca337ad55d5138b76da0b5926b0bf22243e5a41d471578
Python
1,109
40
# Model save path SAVE_PATH = "../../models/" # Check point for encrypter ENC_LARGE_CHK = SAVE_PATH + "encrypter_large_chk" DEC_LARGE_CHK = SAVE_PATH + "decrypter_large_chk" # Actual models go here ! ENC_LARGE_MODEL = SAVE_PATH + "encrypter_large.h5" ENC_LARGE_JSON = SAVE_PATH + "encrypter_large.json" DEC_LARGE_MODE...
70d8218e8ecac2b36fe00b5def6f4b41aceb39df1cb373f80ce93b6bcd070939
Python
1,110
41
import io import pytest import pandas as pd class BasePrintingTests: """Tests checking the formatting of your EA when printed.""" @pytest.mark.parametrize("size", ["big", "small"]) def test_array_repr(self, data, size): if size == "small": data = data[:5] else: d...
3fd69c5b70b5cb7da6b67e9975a6aa26996c1da9993560b919e1f49a1a0f5a52
Python
1,112
41
import torch import torch.nn as nn from darts.api import Model from darts.genotypes import LINEAR_PRIMITIVES from darts.modules.operations.linear import OPS class MixedLayer(Model): """ A mixture of 8 unit types We use weights to aggregate these outputs while training. and softmax to select the stronges...
a4eaa96c9c9f9b0e84fa916d882dc81c4097aa5b038c23fdcc7d3688a4a34574
Python
1,112
21
"""Diagnostics for treatment/control chromosome-name compatibility.""" def check_chromosome_names(treatment_names, control_names, error_stream): """Require at least one shared name, reporting both sets on failure.""" treatment_names = set(treatment_names) control_names = set(control_names) if treatmen...
dfdbc098c5bba3b02a7e79624c63cb768468458c43f8535cb29c60527c276e79
Python
1,114
35
''' Created on Feb 16, 2019 @author: abast This package is contains functions, that modify the cell after it is initalized. Such a function can for example be used to scale the apical dendrite. These kind of modifying functions have caused a lot of trouble in the past, as it has not been specified in t...
e840af78bfeea79f24fef793be6118a3ca3bd3f3f1cd48b97618483550ca4a08
Python
1,114
28
from aigarmic.train import train_binary, train_softmax from tests.conftest import TRAIN_ANNOTATIONS_PATH from aigarmic._nn_design import model_design_spectrum_2024_binary_first_step import pytest @pytest.mark.assets_required def test_train_binary(binary_model_trained): # not checking performance here, just that a...
60c67d5abebb2ff76ea8af0bae940678322107933c83c448b131fbece3e4f17f
Python
1,115
26
# this file will be interpreted as python3 urlprefix = '/test' # Minor allele frequency (MAF) filters: # Note: # "Association" means an association between a variant and a phenotype. # Every association has a p-value. It may also have other attributes. # MAF-filters will apply to allele frequency (AF) and ...
7edbfbefe60961472964b5d7b4115d7778bfc34d086d74f55d3feceacf023854
Python
1,115
40
from Surfaces import surfaces from vtk import * import argparse def main(): parser = argparse.ArgumentParser(description='replaces points from a vtk file by those read from a byu or vtk file') parser.add_argument('vtkFile', metavar='vtkFile', type = str, help='original vtk file') parser.add_argument('point...
8d3d56456a99df1fc8b0755d7806b11a3b4214a884fd701a7787e65cade16095
Python
1,116
29
import os import yaml import pathlib import warnings code_dir = str(pathlib.Path(__file__).parent.resolve()) yaml_path = os.path.join(code_dir, 'glm_config.yaml') with open(yaml_path, 'r') as f: cfg = yaml.load(f, Loader=yaml.FullLoader) cfg['yaml_path'] = yaml_path cfg['code_dir'] = code_dir # Check LEMON cfg[...
d62d9c999f521d7a5b9d44eb609f48df5fb72d7cd5fabaf854bb1f1fdf9745f1
Python
1,116
25
''' library for analysis of simulation data (voltage traces, spike shapes, currents etc...) and anatomical data (synapse distances etc...) ''' from .membrane_potential_analysis import SpikeInit from .membrane_potential_analysis import vm_mean from .membrane_potential_analysis import vm_std from .membrane_potential_an...
4a788f4c97267ceed4987883ab8db269c16ff979f45e63104240761f4dfb7725
Python
1,117
40
import numpy as np from values import * from defs import * def Pendrin(cell,memb_id,xPendrin,area): ph=np.zeros(NC) for j in range(NC): ph[j] = -np.log(abs(cell.conc[11][j])/1.0e3)/np.log(10.0) Pbiiclepd = Pbieclepd*Pcliclepd Pohiclepd = Poheclepd*Pcliclepd ohe = 1.0e-11/cell.conc[11,0] ohi = 1.0e-11/cell.c...
17f354b78a96aecb4fca228d44c3fe2719dbdd3885131c5dad855ac9fe2efe19
Python
1,118
32
# 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...
ce2bcd22c7c89f50b92f324571b7f19b791f2379d400cdfa49d93d10b1c4ae64
Python
1,118
35
from pathlib import Path from setuptools import find_packages, setup try: from cellex import __author__, __email__ except ImportError: __author__ = __email__ = "" setup( name="cellex", version="1.2.2", author=__author__, author_email=__email__, description="Compute single-cell cell-type ex...
73410f0f43b943cf1d72df2f06d3a8a6ce54b2e5f07fb2bad8907c67750c3e89
Python
1,119
35
import os import cv2 import numpy as np import nibabel as nib def write_nifti(path,volume): ''' writeNifti(path,volume) Takes a Numpy volume, converts it to the Nifti1 file format, and saves it to file under the specified path. ''' #path = path.replace("/", "\\") if(path.find('.nii')...
d161c661bd90ecf46c813d26d8ef134415f07128d0e65ae67c166fb674965004
Python
1,119
27
import torch from torch.linalg import cross def bond_angles(bond_vec, edge_index_bnd_ang): bond_vec /= torch.linalg.norm(bond_vec, dim=-1, keepdim=True) i = edge_index_bnd_ang[0] j = edge_index_bnd_ang[1] cos_ang = (bond_vec[i] * bond_vec[j]).sum(dim=-1, keepdim=True).clamp(min=-1., max=1.) sin_an...
66b8fccc30918369d078ea8d1fb35349a50a89665b73248736d9b1c261717a93
Python
1,120
35
# 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...
79f29790667d73fec6c07c76ebd34c3d78fe8b655e48db09ae60c45a09fcf62c
Python
1,120
43
''' @Author: your name @Date: 2020-01-06 17:08:52 @LastEditTime : 2020-01-07 13:25:31 @LastEditors : Please set LastEditors @Description: In User Settings Edit @FilePath: /KGCN_Keras-master/utils/io.py ''' # -*- coding: utf-8 -*- import os import json import pickle def pickle_load(filename: str): try: w...
aa3bffaa64af78699e96af11df9a0526850e9977a523cb660fcc671dcde99ae0
Python
1,120
30
import torch from torch_geometric.utils import scatter # Typing from torch import Tensor from typing import List, Optional, Tuple def graph_softmax(src: Tensor, index: Tensor, dim_size: int) -> Tensor: src_max = scatter(src, index=index, dim=0, dim_size=dim_size, reduce='max') out = src - src_max[index] ...
336ea12c2d35cdaa41a5ae3e4073b8385f0447f0c96e794563abf33a0c713e1f
Python
1,122
33
from skimage.filters import threshold_multiotsu from skimage.morphology import dilation, ball import torch from typing import List from ...image import Stack, Image def otsu_thresholding(stacks: List[Stack], nbins: int = 256) -> List[Stack]: for stack in stacks: thresholds = threshold_multiotsu( ...
d003528400ada73c50fc282e6cd7a588942f3c8af592f5618a2731f9708374e1
Python
1,122
36
import os.path import shutil import tarfile import zlib import zipfile from time import gmtime, strftime refuseddirs = ['CVS','images'] refuseddirsextra = ['CVS','small'] source = 'V:\\\\cvs\\porting24\\qwtplot3d\\doc\\' sourceim = 'V:\\\\cvs\\porting24\\qwtplot3d\\doc\\images\\' zipname = 'V:\\\\cvs\\upl...
38ba91e0ad2fbb5377f82807157fa5da350165a3fb91986cb3c342ba010b0630
Python
1,123
40
"""Example model training script.""" import hydra from omegaconf import DictConfig from lightning_pose.train import train @hydra.main(config_path="configs", config_name="config_mirror-mouse-example") def train_model(cfg: DictConfig): """Main fitting function, accessed from command line. To train a model on...
82c3af3d631e1afff8699b244ac3e58f2e9f97f6f03433397c8cfc989d4e9c85
Python
1,123
55
""" Tests for offset behavior with indices. """ import pytest import pandas as pd from pandas.tseries.offsets import ( BMonthBegin, BMonthEnd, BQuarterBegin, BQuarterEnd, BYearBegin, BYearEnd, MonthBegin, MonthEnd, QuarterBegin, QuarterEnd, YearBegin, YearEnd, ) @pyt...
8e5dd02ce570d4060dc637d4606abb5bd8cb16da234d658f07b988d00a90068e
Python
1,123
22
import time #This function is the countup timer, the count is set to 0 before the script # waits for a second, otherwise the beep will sound several times before the second # changes. def timer(second, completion_event, test_duration): # First we initialize a variable that will contain the moment the timer began ...
ede63e0e424b538d9d7d666e2c27c6e29136ec7fcc7a651af258d3b44103393e
Python
1,124
45
# JN 2015-01-11 from __future__ import print_function, division, absolute_import import logging import numpy as np import pywt # scipy doesn't have the flexibility yet from .. import options logger = logging.getLogger(__name__) WAVELET = pywt.Wavelet(options['Wavelet']) OUT_DTYPE = np.float32 LEVEL = 4 def wavelet_...
2d06e92a0c11bdc24808443ade9eb1a8527e26b85b6fa3994781890516b5f261
Python
1,126
44
import numpy as np import matplotlib.pyplot as plt import pandas as pd from mat4py import loadmat import scipy as sp from matplotlib import cm from helper_make_data import make_data from matplotlib.ticker import FormatStrFormatter import sys import os def make(whichdelay, whichITI, delay, ITIs): #, hit # define a ...
76768bb1ec400be7e91e789da243aedb6b8b5be19a5762bcfb900e5863eb62b7
Python
1,126
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...
1f49fecdd9714157b1d0b4cb1b3d9d9d267e4a965337afc216cfefa3a6b1dcc9
Python
1,127
33
# ------------------------------------------------------------------------------------------------------------------------------------- # Following code curated for GCPNet (https://github.com/BioinfoMachineLearning/GCPNet): # ----------------------------------------------------------------------------------------------...
6f7ee0a6c758e35a91d7fca991ac1b3f126521d1f63513f2e888ab8d12528837
Python
1,128
35
# Copyright 2023 Image Analysis Lab, German Center for Neurodegenerative Diseases (DZNE), Bonn # # 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...
754ad8c3d3d32961d2305a3b30843ef12fd16b37e1c7158d6c6e6c02395338eb
Python
1,130
45
from datetime import datetime import numpy as np import pandas as pd import pandas._testing as tm def test_series_set_value(using_infer_string): # GH#1561, GH#51363 as of 3.0 we do not do inference in Index.insert dates = [datetime(2001, 1, 1), datetime(2001, 1, 2)] if using_infer_string: index...
dafe53121ff0d37c8083d61740e18f8ab7f58ad35b63570278847d2a95c61b27
Python
1,130
51
# pyaging/logger/__init__.py from ._logger import ( Logger, LoggerManager, format_logging_message, main_critical, main_debug, main_exception, main_finish_progress, main_info, main_info_insert_adata, main_info_insert_adata_layer, main_info_insert_adata_obs, main_info_inse...
6e28e677bc03a460892611525941043be2afdb26d0b25196ac39e7f6ffa3363a
Python
1,132
29
from subprocess import check_output # Hyper-parameters table = "cnn_tuning" # _post_spec_fix" target = "dspln_PSYCHIATRY_12" channels = [500] # dropouts = [0.2, 0.5, 0.8] # dropouts = [0.4, 0.5, 0.6, 0.7, 0.8, 0.9] # , 0.9] [0.55, 0.65] dropouts = [0.85, 0.875, 0.9] # dropouts = [0.5, 0.6, 0.65, 0.7, 0.8, 0.85, 0.9,...
5dc35194516465bdbd676a89e2a2744e12f3cc4ecac91ba51cf9b26b06492654
Python
1,133
44
# Copyright 2024-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...
9ccd1da212afbe24ea048cc250a1d2de9b12dbdd3cf06fcf3b43c69867ba9726
Python
1,133
46
""" Tests for np.foo applied to Series, not necessarily ufuncs. """ import numpy as np import pytest import pandas.util._test_decorators as td import pandas as pd import pandas._testing as tm class TestPtp: def test_ptp(self): # GH#21614 N = 1000 arr = np.random.default_rng(2).standard_...
31d284c3e2f0c20af2341a4d300163944c4a0d74893337f1de42c71276f6b4a3
Python
1,134
36
import sys import os import argparse if __name__ == '__main__': argparser = argparse.ArgumentParser(''' Print usage for CDR executables. ''') argparser.add_argument('names', default=[], nargs='*', help='Names of executables to show.') args = argparser.parse_args() bin_dir = os.path.dirname(os.p...
2dcc187c5991705b1a1f243056617732762f60d2426c05cda8fcc391c6b3dd9d
Python
1,137
34
# NB: This is for the Timestamp.timestamp *method* specifically, not # the Timestamp class in general. from datetime import UTC import pytest from pandas._libs.tslibs import Timestamp from pandas.compat import WASM import pandas.util._test_decorators as td import pandas._testing as tm class TestTimestampMethod: ...
99cb92204fb93fbaa821410704885a61d4cd4ac3d847196539af8e72f77d81d9
Python
1,137
23
import torch # Prints model summary def model_summary(model): model_params_list = list(model.named_parameters()) print("--------------------------------------------------------------------------") line_new = "{:>30} {:>20} {:>20}".format( "Layer.Parameter", "Param Tensor Shape", "Param #" ...
e10520c0fb6626c7b8f71e2c0e52fe168285e8b4b1f27091a67d00964b1a4ee0
Python
1,137
32
"""Phase 8 notebook runtime package. A ``NotebookManager`` spawns isolated JupyterLab containers per session. Two drivers ship: - ``LocalManager`` — for dev. Doesn't actually spawn a container; just marks the session ``running`` with a fake port + token so the rest of the system can be exercised end-to-end withou...
763a640c65908dfd44ecdd3f139937b4957bd867adab14863ae4e10c7ed3c930
Python
1,140
41
import tensorflow as tf @tf.custom_gradient def gradient_reversal(x,alpha): def grad(dy): return -dy * alpha, None #return -dy * alpha return x, grad def loss_domain(label,domain): domain = tf.clip_by_value(domain,0.001,0.999) p2 = 1. - domain loss = -label * tf.math.log(domain) -...
fa6ee872825ee117801613584ab8908ec6914b400de4da88dd26eeff8305eb5f
Python
1,140
33
#!/usr/bin/python3 ### positional comparison script useful for tagging alignments with their true position # length.bp unaligned.bp known.nodes known.bp novel.nodes novel.bp import sys threshold = int(sys.argv[1]) for line in sys.stdin: fields = line.split(' ') # every input has a t...
00afdf0a81c027abff89a4d17f610395a37c619d5f95d9c7ef25b6cc37659183
Python
1,141
40
#python querydataframe.py --input FILE [--i colheader ...] # each --i argument specifies a column header whose column will be output to stdout # outputs columns in order specified by input file import sys targetcols = [] OPTS = {} for aix in range(1,len(sys.argv)): if len(sys.argv[aix]) < 2 or sys.argv[aix][:2] != ...
46c3710d2ce496d7e98295736571c7a92be268ca80815e96d0d5c0e9322a5312
Python
1,144
39
# 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...
d880fc28f80fe4c4b69508e36f7ac1bcfc871f33ae49678916e8be474de9df1b
Python
1,144
48
########################## #### Weidong Cai, 2021 import os import sys import numpy as np import pandas as pd import scipy.stats as spss import sklearn import seaborn as sns import matplotlib.pyplot as plt from sklearn import preprocessing from sklearn.cross_decomposition import CCA ### read BSDS state OR data state_...
5308732d0096b6dc8504aeea0f18ba543f4c2c8968886ca0f2651d3b2901bee4
Python
1,145
33
from base.surfaces import * def compute(): fv0 = Surface(filename='/Users/younes/Data/sculptris/shape1.obj') fv0.updateVertices(10*fv0.vertices) center = fv0.vertices.sum(axis=0)/fv0.vertices.shape[0] a = np.sign(fv0.vertices[:,0] - center[0] - 5) + 1 a = a[:,np.newaxis] print(fv0.normGr...
8de66ae48833244b9ebc4f9d2d34bbfb25d822c83b1e062cb32d568855af037c
Python
1,145
38
"""Fixtures that load the scripts/inference-timing/*.py modules by file path. scripts/inference-timing is not a valid Python package name (it has a hyphen), so its modules can't be imported with a normal `import` statement. Mirrors the pattern used in tests/scripts/hyper_sweep/conftest.py for scripts/hyper-sweep. """ ...
ce8ec9d90a99b758f19d244d13086b49c47109dd7305e2b7bf504ed648539c8f
Python
1,145
47
"""Test the initialization and training of regression models.""" import copy import pytest pytestmark = pytest.mark.gpu def test_supervised_regression( cfg, base_data_module, video_dataloader, trainer, run_model_test, ): """Test the initialization and training of a supervised regression mod...