sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
41abee9e4e3d000bc80f495c2ecb70628ee69045bbc22f15641f791fb93dd52f
Python
1,873
61
import re import numpy as np import pytest import pandas as pd class TestDataFrameDelItem: def test_delitem(self, float_frame): del float_frame["A"] assert "A" not in float_frame def test_delitem_multiindex(self): midx = pd.MultiIndex.from_product([["A", "B"], [1, 2]]) df = ...
41493a1393e6ce69e1574df9a3f00983cf00cf7a2d64f5bc96b5e773bb493f79
Python
1,877
47
import pandas as pd import altair as alt b_name = "OR" name = "all" font_size = 20 line_size = 5 glauc = pd.read_csv(f"output/pheno_match/glauc_sec/resnet_models/{b_name}_{name}_grouped.csv") age = pd.read_csv(f"output/pheno_match/age/resnet_models/{b_name}_{name}_grouped.csv") glauc["Phenotype"] = "Glaucoma" age["P...
8fb53d4a7440823e6446665f42c78bdf4557e8a42fbd897d63336fcfba3ca814
Python
1,877
56
"""Deterministic fake provider for tests. Emits a stable shape matching `LLMAdvice`. Any test that wants to drive a specific output can override the `canned_response` attribute before calling `complete()`. """ from __future__ import annotations from typing import Any class FakeLLMProvider: """In-memory stand-i...
1da047aa74395fa0f9195caa7a0b8f398ec77bc5cd88e1ba5298e947ff9c5721
Python
1,878
48
"""Migration to rename colon-separated time directories to hyphen-separated ones. Addresses https://github.com/paninski-lab/lightning-pose/issues/278, where output directories used HH:MM:SS format (e.g., ``outputs/2024-01-01/12:00:00``) which is invalid on Windows and causes issues with some tools. This migration rena...
72fcbfd5eb2651a06361609f76df8184a1dc46b43eda18eb78f88e42cdfed6c3
Python
1,878
56
# JN 2015-09-10 """ Imports that can than be used by the packages in this folder """ from __future__ import absolute_import, print_function from .options import options, artifact_criteria import os,sys sys.path.insert(0, os.getcwd()) try: from .options import raster_options except ImportError: pass n_local = ...
dfa15b934b7bfef7ce0fa6fd3174546290b03478ec27f18bc8b465047b6563f7
Python
1,878
45
import torch import torch.nn as nn import torch.nn.functional as F from dgl.nn.pytorch.conv import SAGEConv class GraphSAGE(nn.Module): def __init__(self,params): super(GraphSAGE, self).__init__() self.layers = nn.ModuleList() self.dropout = nn.Dropout(params.gcn_dropout) self.acti...
a77106cd54b023db4f5cd342b0d96cb3a0b387846f432e4f13b9b3e75c033af7
Python
1,879
49
import numpy as np import pytest import pandas as pd import pandas._testing as tm @pytest.mark.parametrize("method", ["union", "intersection"]) def test_setop_mismatched_category_order(method): # GH#55335 unordered CategoricalIndex with same categories in different # order should give correct results for uni...
fe99c43616322e1ffb2f920f0a4aa5714ef21912f016c844b8aaa98b36a09ed6
Python
1,879
39
import torch from rl_games.common.diagnostics import PpoDiagnostics def _batch(actions, mu, sigma, adv, **extra): n = len(adv) b = {'values': torch.zeros(n, 1), 'returns': torch.arange(n, dtype=torch.float32).unsqueeze(1), 'new_neglogp': torch.zeros(n), 'old_neglogp': torch.zeros(n), 'masks': None, ...
43cf2d570964b2e6d46be3dd6ec8c50f78c0ca7cdfd6543803e2016027cbd162
Python
1,880
76
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Oct 30 11:48:59 2023 @author: nrq2 """ #%matplotlib inline import scenicplus scenicplus.__version__ import pickle import scanpy # Load functions from scenicplus.scenicplus_class import SCENICPLUS, create_SCENICPLUS_object from scenicplus.preprocessing....
5f9d030eb7b063b44a59cfddacfd5e4d71abdcfce5070ac12ba56f3726760066
Python
1,880
59
import argparse from pathlib import Path import keras import keras.backend as K import numpy as np from tqdm.auto import tqdm from global_config import config from ribosomal_autoencoder.model import load_ribosomal_autoencoder def get_args(): parser = argparse.ArgumentParser() parser.add_argument("-d", "--...
9386f56b2f00b8289d56b71dcdd4c5133b23f4a80a4fa975fbe3808e1a9d7ed9
Python
1,881
62
"""Perform meta-analysis on images constructed from coordinates using the Peaks2Maps kernel.""" import logging import os import pathlib import numpy as np from nilearn.image import resample_to_img from nilearn.masking import apply_mask from nilearn.mass_univariate import permuted_ols from ..base import MetaResult fro...
3549e1eb6314601655a37cb07161f644c0d715cfd49148a013835d808c67c044
Python
1,882
52
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
16cd0dc88b7a063196050a5bc03072c42ea58046e45ba4c92aded0e971e94e25
Python
1,883
54
import argparse import os import shutil def get_args(): """ Get arguments from command line with argparse. """ parser = argparse.ArgumentParser( prog='Filter-SemiBin.py', description="""Identify any superbins (>100Mb) from semibin2 and move to a separate directory.""") parser.add_ar...
8e46f61bbefcabc8b2f5fdab0decfff58efbe7ee1c2a18efd3dbf3753a38ed56
Python
1,884
62
"""Sphinx extension that warns about lists indented relative to their context. An indented list is parsed as a list inside a block quote, which renders with extra indentation. Top-level lists should not be indented, and nested lists should align with the text of their parent item. """ import re from docutils import ...
d29e9b36e9976d918892498f5e1d2f91efeb5987754bebf15dd6537029bd7124
Python
1,885
58
import torch import torch.nn as nn from darts.api import Model from darts.modules.linear.mixed_layer import MixedLayer class Cell(Model): def __init__(self, num_nodes, multiplier, cpp, cp, c, reduction, reduction_prev): """ :param steps: 4, number of layers inside a cell :param multiplie...
478f130a8f7693722685916ac42e35efb589e02e1634453a3700bff8376fdd6e
Python
1,886
93
from textwrap import dedent import pytest import pandas as pd pytest.importorskip("jinja2") from pandas.io.formats.style import Styler @pytest.fixture def df(): return pd.DataFrame( {"A": [0, 1], "B": [-0.61, -1.22], "C": pd.Series(["ab", "cd"], dtype=object)} ) @pytest.fixture def styler(df): ...
b4904c6b3413ef5c49e6e7ded1ba5a93f868211d721050895009162ce2ce28d1
Python
1,886
64
import warnings from secrets import randbelow import config import numpy as np from tensorflow.keras.models import model_from_json from utils import create_input_array warnings.filterwarnings("ignore") __all__ = ["allocate_encrypt_packet"] # For every dataPacket allocate NNs and encrypt parallely. def allocate_enc...
53be70355b0accec1f06c41e3dfc84dab536bed7bdf715ab228172ede0dbeeb1
Python
1,888
57
import tempfile import os import itertools as it from nose2.tools import params import chromosight.cli.chromosight as ccc from docopt import docopt COOL = "data_test/example.cool" BED2D = "data_test/example.bed2" OUTDIR = tempfile.TemporaryDirectory() DUMPDIR = tempfile.TemporaryDirectory() # Select a bunch of argumen...
ca716af836e35fbc311ba806c7c72e95318cd6eaffd95365d886accc9267ec46
Python
1,896
62
"""Perform meta-analysis on images constructed from coordinates using the Peaks2Maps kernel.""" import logging import os import pathlib import numpy as np from nilearn.image import resample_to_img from nilearn.masking import apply_mask from nilearn.mass_univariate import permuted_ols from nimare.base import MetaResul...
2b84a4d501780c24b321d92c03e9022ad10304d409bfc515a3264ca78711c837
Python
1,897
59
"""Utility helpers used across training, inference, and evaluation. **Submodules**: - ``utils.io`` — path handling and file I/O utilities. - ``utils.device`` — GPU-presence checks: selecting a ``pl.Trainer`` accelerator, and guarding DALI-only semi-supervised training with a clear error. - ``utils.predictions`` — i...
a8fb819ca24f7e813f7dfd93561909665c7c71bf2cb37e36486d5e963931d7cf
Python
1,897
45
""" # Microbiome Analysis Powered By Recursive Quasi-species Networks: Description: Uncovering rules of organization, competition, succession and exploitation --- ## Installation: ``` pip install qbiome ``` or ``` pip3 install qbiome --user ``` ## Notes: Depends on the `quasinet`...
1f689be82ea75663cff58868104d9932003619b9c7013fec062fbfabf9f3ac96
Python
1,899
67
""" Illustrates how to calculate a distribution dI with vegas. """ from __future__ import print_function # makes this work for python2 and 3 import vegas import numpy as np import gvar as gv gv.ranseed((1, 2, 3)) # causes reproducible random numbers RMAX = (2 * 0.5**2) ** 0.5 # non-batch version def fcn(x): ...
022af4342923a9e9e9f051604575bc0ac3566be7e3508b528b62203bb28c72e7
Python
1,902
54
import gymnasium as gym import numpy as np from rl_games.common.wrappers import MaskVelocityWrapper class TestAsymmetricCritic(gym.Env): def __init__(self, wrapped_env_name, **kwargs): gym.Env.__init__(self) self.apply_mask = kwargs.pop('apply_mask', True) self.use_central_value = kwargs.p...
8e7305fe6ac9056519c49656150b7ed466f77b95c79b86daed012b1dcb445d88
Python
1,903
84
import gc from importlib import import_module import os import numpy as np import pandas as pd # Compatibility import for lib for imp in ["pandas._libs.lib", "pandas.lib"]: try: lib = import_module(imp) break except (ImportError, TypeError, ValueError): pass # Compatibility import fo...
be2114cb8de8601f1291bc708dbf42c97b6cd3cf60e3fb65bf578fdd19aa166e
Python
1,903
75
# coding: utf-8 """ Colorspace conversion routines. Inspired by agapython/util/Dibase.py from Corona lite, but reimplemented to avoid licensing issues. Encoding Table A C G T A 0 1 2 3 C 1 0 3 2 G 2 3 0 1 T 3 2 1 0 """ def _initialize_dicts(): """ Create the colorspace encoding and decoding dictionaries. ...
d96111abe1beda720e25cca03f221152739702f8421d005ba3ab623a53a0ff8c
Python
1,903
57
import os import json import concurrent.futures import time # 多进程 原始提取函数:18.002195835113525 # 多进程 改造提取函数:8.507536172866821 apkfilename = [] permission_frequency={} path = r'E:\pythonProject\Experiment\out_benign_samples' apk_list=os.listdir(path) for apk in apk_list: apk = os.path.join(path,apk) a...
1dc23bb7b0c4dcb20f626e807467432a4fc4d24e891fc810db9130b8557eeee1
Python
1,904
64
import tensorflow as tf from .wrappers import FrameStack, dmControlGetTasks, dmControlGymWrapper class Process: """ Base class for processes ================= Attributes: env_name (str): the name of environment render (bool): enable the rendering """ def __init__( se...
6d0170d14c33764f27697ebf8dacf0c8ea8da85890e3107e74a98d0426953fea
Python
1,905
69
# -*- coding: UTF-8 -*- r""" @Author : wlhuang @Date : 2023/5/9 14:10 @Institution : CUbiCS, ICT, CAS @Contact : wuliang.huang@outlook.com @Description : Convert participant dataset to Aier platform compatible format. """ import re import shutil from pathlib import Path yaml_content = r""" attributes: ...
47673772569cc99c0ff0168d8aa96777489ddbe07cac3dd78c93af6bb9969d2a
Python
1,906
54
import os # import cloudpickle import compatibility from . import parent_classes def check(obj): '''checks wherther obj can be saved with this dumper''' return obj is None #isinstance(obj, np) #basically everything can be saved with pickle ## this was used to store more data in the ManagedFolder ## it turned ...
f59e334ea9ca0169f5abd29936fb8edc317aa2ccc78d0ad082d38e8a6bab59cb
Python
1,907
70
import pytest from pandas.util._validators import validate_args @pytest.fixture def _fname(): return "func" def test_bad_min_fname_arg_count(_fname): msg = "'max_fname_arg_count' must be non-negative" with pytest.raises(ValueError, match=msg): validate_args(_fname, (None,), -1, "foo") def te...
7334c1a7853b234462fec5705c8aba2bdda59e540788a24cdbabbc610c8fcbd9
Python
1,908
74
import os import pathlib import random import sys import unittest import anndata as an import numpy as np import pandas as pd import pytorch_lightning as pl import sklearn as sk import torch from torch.utils.data import * random.seed(42) from os.path import abspath, dirname, join sys.path.append(join(dirname(abspath...
6fd9039acf2ed145d3ab60b2cb8cadf054b5e6293f04491ba29442b976a011ae
Python
1,910
55
from argparse import ArgumentParser from atropos.modifiers import AdapterCutter, InsertAdapterCutter from atropos.adapters import AdapterParser from atropos.seqio import open_reader adapter_parser = AdapterParser() A1 = adapter_parser.parse('AGATCGGAAGAGCACACGTCTGAACTCCAGTCACACAGTGATCTCGTATGCCGTCTTCTGCTTG') A2 = adapt...
864a175543db0129055a7f1b195216b227977c8ad6eac6def4bd0489311ed772
Python
1,911
59
import os import time import json import concurrent.futures # 对于so文件的提取 # 没有lib文件夹就打标为NULL # 多进程 每次处理20个 开16进程 2.0976274013519287 apkfilename = [] permission_frequency={} path = r'E:\pythonProject\Experiment\out_benign_samples' apk_list=os.listdir(path) for apk in apk_list: apk = os.path.join(path,apk...
9397a8dd23c2a8a717c4c2ce45ff7af40733df5e9df3a6a97fec21ffb2baec39
Python
1,911
56
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
c606cb1dea895695d2fc111ea437c2da5d19edeab1dea72bd12d67468a4c6982
Python
1,911
57
import pandas as pd import os from os import path from glob import glob from base.shapeAnalysisPipeline import Pipeline from base import loggingUtils def makeFileList(dataDir): files = glob(dataDir+ '/*.vtk') dct = {'id':[], 'path_left':[], 'path_right':[], 'path_left_lmk':[], 'path_right_lmk':[], 'visit_numbe...
0f9af973ccbe32b7b754afc951447d155d75b5881ed25781359d9da4ea3477d0
Python
1,912
55
import importlib.resources from PyQt6 import uic, QtCore, QtWidgets class DlgSlotReorder(QtWidgets.QDialog): pipeline_changed = QtCore.pyqtSignal(dict) def __init__(self, pipeline, *args, **kwargs): super(DlgSlotReorder, self).__init__(*args, **kwargs) ref = importlib.resources.files( ...
1bba623b470f85daa2120687e41653c19e64619ca754bbbb9bd27e51bee10123
Python
1,914
48
import os import logging import json import torch def initialize_experiment(params, file_name): """ Makes the experiment directory, sets standard paths and initializes the logger """ params.main_dir = os.path.join(os.path.relpath(os.path.dirname(os.path.abspath(__file__))), '..') global_exps_dir =...
a6dc3bf8cd13cc4ab6ba5e2870f52347a0b1060f8ad2464b1011652d1426d7a1
Python
1,916
62
# -*- coding: utf-8 -*- """ T1 segmentation """ import logging logger = logging.getLogger(__name__) import os import numpy as np from skimage import morphology import nrrd from app.processing.preprocess import hist_perc from app.processing.morphops import closing_and_fill, erosion_2D, labelsize def and_brain_hems(p...
5907cb12ad2a5c989dc0bd57b1e50bcf020ad189f0ab1b91d473a2d2b1189bed
Python
1,918
60
# 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...
bc3084a9f189e770f111f75cfc40ef644dbb3939126f389bea82995f4484b471
Python
1,918
58
"""Session 33 — Git auto-publish on Run complete + Phase 14 GPU queue Revision ID: e5f6a8b9c0d1 Revises: d4e5f6a8b9c0 Create Date: 2026-05-17 13:00:00.000000+00:00 Two small additive columns; no data migration needed. 1. ``git_repositories.auto_publish`` (bool, default False) — when set, the orchestrator's ``reco...
999d5eb9bd1edf5685052441ce0dd21d5001a66fd917cb993fdc1c8ac73a6db8
Python
1,920
76
# -*- coding: utf-8 -*- """ Created on Tue Mar 8 14:31:15 2022 @author: System 6 """ import pycromanager_tessie as pmt # Start platform: platform = pmt.microscope.platform.Platform(load_synchronizer=True) # Set LED ring #platform.neopixel.color(red=int(255/4)) #%% Calibrate DMD: platform.neopixel.shutter(True) pl...
30784fde79f4c11c8346b23b3d67e2fa49f0cdd5d7791259672be1e9e70113e3
Python
1,922
56
#!/usr/bin/env python import os, sys from collections import defaultdict, Counter from cupcake.io.GFF import write_collapseGFF_format from cupcake.io.BioReaders import GMAPSAMReader def main(): from argparse import ArgumentParser parser = ArgumentParser("Convert SAM to collapsed GFF format") parser.add_ar...
63e95669e43ff226493a430160213c4145e1a2023b697eaf7910250b71ef3dfa
Python
1,922
71
#! /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...
c2d4237c7f87a67cc444e41fc55e984367fca8c02c1847ba5ee5b02f5196f6f0
Python
1,922
106
""" Arithmetic operations for PandasObjects This is not a public API. """ from __future__ import annotations from pandas.core.ops.array_ops import ( arithmetic_op, comp_method_OBJECT_ARRAY, comparison_op, fill_binop, get_array_op, logical_op, maybe_prepare_scalar_for_op, maybe_warn_co...
5c0b45151b8c90371631449fd234f98272f7d4bb1aa939e8c8ad9f6dbfaf83a3
Python
1,923
40
import torch.nn as nn from torchvision.models import convnext_base, ConvNeXt_Base_Weights, convnext_tiny, ConvNeXt_Tiny_Weights def ConvNext_model(args, diff=False): """ Load ConvNext model. Parameters: - args (dict): Dictionary containing model arguments, where 'model' specifies the model type. ...
16f01c473030625baeb875019c11c532b2073f283d8ec51cc9437b12d9fbaf5f
Python
1,926
84
import argparse import copy import numpy as np from pathlib import Path import pickle from sklearn.linear_model import Lasso from sklearn.metrics import r2_score from sklearn.metrics import mean_absolute_error from model.data import Dataset parser = argparse.ArgumentParser(description='Predict property using Energy ...
5be27f719b8b5e204b742b2cd352551b1aad6d9ee9dd4d4eac795c7bc063a137
Python
1,928
54
#Run sweeps over time constants import numpy as np from placerg.funcs import * from placerg.funcsrg import * from placerg.objects import * from placerg.runfunc import * N0 = 1024*4 # number of cells percell= 1.0 # probability that each field is accepted phi=1.0 # multiply by this constant to adjust overall activity...
0d5b7281e01b9e66eed1703faa9d89165b8834e3f91fd699fdf308cc19dd02ef
Python
1,929
49
import pytest import pandas as pd import pandas._testing as tm def test_add_prefix_suffix(float_frame): with_prefix = float_frame.add_prefix("foo#") expected = pd.Index([f"foo#{c}" for c in float_frame.columns]) tm.assert_index_equal(with_prefix.columns, expected) with_suffix = float_frame.add_suffi...
17136b7d6416624e431b1d6690bb90114b8d50b875d3437915155222b877dd88
Python
1,930
42
# Copyright (c) 2018-2023, NVIDIA Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, this # list of condit...
2fae007399a0ea4c49e39c44d2ad85c6a8db5c4023bb1d18a11b410ba290bf93
Python
1,932
57
import numpy as np import pandas as pd import pandas._testing as tm def test_head_tail_generic(index, frame_or_series): # GH#5370 ndim = 2 if frame_or_series is pd.DataFrame else 1 shape = (len(index),) * ndim vals = np.random.default_rng(2).standard_normal(shape) obj = frame_or_series(vals, ind...
bf4a8c7c9b5f48969f729ac5a4e94444c831b36cb2ed998cd9c1f12606f750a9
Python
1,932
72
#%% #Imports import numpy as np import os import matplotlib.pyplot as plt from matplotlib.gridspec import GridSpec plt.style.use('seaborn-talk') import pandas as pd from sklearn.preprocessing import StandardScaler from sklearn.decomposition import PCA from scipy.stats import gaussian_kde from src.vizualization impor...
e4a3efa2a764f751f372ce83ee756642b1f695cdb0b98bd80f1fefa7ca64221a
Python
1,932
45
# 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...
396ddde08ee5bd81cc41d3daa82845f308ce25c16c8faf16b587113d5b712232
Python
1,933
62
# -*- coding: utf-8 -*- """ T1 segmentation """ import logging logger = logging.getLogger(__name__) import os import numpy as np from skimage import morphology import nrrd from app.processing.preprocess import hist_perc from app.processing.morphops import closing_and_fill, erosion_2D, labelsize def and_brain_hems(p...
956a6f5bfe2b0284091472f8b39049e2a6aa0ca44d3043368f3d7e9d1f0f7b53
Python
1,935
72
#!/usr/bin/env python from __future__ import print_function import windseer.data as data import windseer.nn as nn_custom import windseer.utils as utils import argparse import numpy as np import os import torch parser = argparse.ArgumentParser( description='Script to plot a prediction of the network' ) parse...
81ccfa72ecbe3920ebf41aec2bad3dc9f84bf1bd9e4ba263293db2d3caa8fac5
Python
1,936
80
from pathlib import Path from typing import List from os import environ from argparse import ArgumentParser from pprint import pprint from MutComputeX.inference import EnsembleCIFPredictor def cli(): parser = ArgumentParser() parser.add_argument( "--data", required=True, type=Path, ...
02e89394b54ccdd2f9413c5bce9a8a4e850d4199fb958e0b0ee7f22c4bf41017
Python
1,937
32
############################################################################## ## ## ## This file is part of ModelBlocks. Copyright 2009, ModelBlocks developers. ## ## ## #...
557d09ef62a6bdb10b6aa5569a94ba32932134583661a0c8cc8dfd7fcf7f86e0
Python
1,937
43
from botocore.client import Config import ibm_boto3 # import types import os import sys import pdb import pandas as pd import numpy as np import pickle 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 ...
93fe8b7e3cf3e3791286fb8630e7e154de54792984aee524d9c6d8c7c1cfb4ea
Python
1,937
72
import numpy as np import pandas as pd import pandas._testing as tm from pandas.tests.copy_view.util import get_array def test_clip_inplace_reference(): df = pd.DataFrame({"a": [1.5, 2, 3]}) df_copy = df.copy() arr_a = get_array(df, "a") view = df[:] df.clip(lower=2, inplace=True) assert not...
84d2ed919e4f1fee74820e703556ded7c1822c6e3674ec64829c365bc87866a3
Python
1,938
58
from datetime import datetime import pandas as pd import pandas._testing as tm from pandas.tseries.holiday import ( AbstractHolidayCalendar, USFederalHolidayCalendar, USMartinLutherKingJr, USMemorialDay, ) def test_no_mlk_before_1986(): # see gh-10278 class MLKCalendar(AbstractHolidayCalenda...
b1044c86c7b84167bbfd927c8e934414762993d203750a2236b68eab3f48daf5
Python
1,938
65
""" Three Gaussians spread along the diagonal of a six-dimensional hypercube. This coding style for the integrand is the simplest but also gives the slowest runtime. It is made 3x faster by using nproc=8 processors, but is still slower than faster.py and fastest.py (using nproc=1 processor). """ from __future__ imp...
930ad62cd68cbefb0dd221d338f2d0fa3c780c90241f333c4ce13b94b9f23c25
Python
1,939
59
import sys import tempfile import unittest import inspect from pathlib import Path REPO_ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(REPO_ROOT)) from treeshrink.alignment import MultiLocusDataset from treeshrink.sequence_lib import hash_taxon_seq from treeshrink._vendor import dendropy class P...
cf36774dfe9f610e6af6d4b530bddde3092fa8f2d1566c165471a847dc80941c
Python
1,940
69
""" Functions for handling sequence identifiers in alignments Authors: Anna G. Green """ import re from collections import defaultdict from evcouplings.align import read_fasta ID_EXTRACTION_REGEX = [ # example: >UniRef100_H6SNJ6/11-331 "^Uni\w+\_(\w+).*/", # example: >tr|Q1NYN0|...
25823fc6130d16df63e291961d642f5e5dea5eccb12f6c7e98a0b2828c3ed798
Python
1,941
72
# -*- coding: utf-8 -*- """ Created on Mon Sep 27 09:53:59 2021 @author: Noelia Martínez-Molina, adapted from code provided by Yonatan Sanz-Perl at CNS, UPF """ import numpy as np import matplotlib.pyplot as plt plt.style.use('ggplot') subjects=['VIS','SM','DAT','VAT','LIM','CNT','DMN'] HC_TBI3=[40,43,...
676b36a4931e12cb7aac191af38bc8aadb23ba78b6bd021a2d693ae569ae53dd
Python
1,942
58
import numpy as np import pytest import pandas as pd import pandas._testing as tm class TestTimedeltaIndex: def test_misc_coverage(self): rng = pd.timedelta_range("1 day", periods=5) result = rng.groupby(rng.days) assert isinstance(next(iter(result.values()))[0], pd.Timedelta) def te...
5cf4221a53d3ea4b04cf262e29fbba939bf1ce9e7941414b41e920235b30eddd
Python
1,943
76
""" Functions for generating input to Haddock webserver Authors: Anna G. Green """ def haddock_dist_restraint(resid_i, chain_i, resid_j, chain_j, dist, lower, upper, atom_i=None, atom_j=None, comment=None): """ Create an ambiguous restraint string for u...
7f9b5a61eb28bbfb4aca0738c2ab80ef9f1baff997b82506aec592ba37373d0d
Python
1,943
51
# 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...
11322ad766c3717d4392e05f8fb3270c19f2d397f7936319f2dcc618715808df
Python
1,944
57
import datetime import os date = datetime.date.today() throwaway_script = 'batch_script.slurm' group = 'spe' k_vals = [0.0001] l_vals = [6] d_vals = [10.0] for k in k_vals: for l in l_vals: for d in d_vals: f = open(throwaway_script,'w') job_name = 'train_hgram_l='+str(l)+'_k='+s...
34681179406de7fe39e6ad9c96ad21d533d7a349db9cdc49f79ece8402918dbe
Python
1,944
54
''' Contains the character class ''' import warnings warnings.filterwarnings("ignore") class Character: ''' Contains all parameters for a given character ''' def __init__(self, opt): ''' Initialises character class. opt should contain the following keys: 'identity'...
1a6f2579ce81150d84aa456754dcaf428f8ca22b7ff00a7887fe0b8bf72559c9
Python
1,946
65
from tensorflow import keras from tensorflow.keras import layers import tensorflow as tf from tensorflow.python.keras import utils def add_default_block(x, kernel_filters): s = layers.Conv2D(kernel_filters, (1,1), padding='same')(x) s = layers.BatchNormalization()(s) s = layers.Activation('relu')(s) x...
2e00012d4a210c3b5cfd8885c6d2f121b3fbbce572d8509eff384bf3daa68712
Python
1,946
41
"""Supervised and semi-supervised loss functions for pose estimation. Loss names follow a ``{domain}_{variant}`` convention. The full registry is returned by :func:`get_loss_classes`; the names below are the strings used in config files under ``cfg.model.losses_to_use`` and ``cfg.model.heatmap_loss_type``. *Supervis...
40bf42315353601e8ba64bd9b186ca0f0e123cb2941643d3a5c0e14b64972dcb
Python
1,948
67
__all__ = ["GlycoPeptideRTTreeLSTM"] from typing import Any, Mapping import torch from dgl.nn.pytorch.glob import GlobalAttentionPooling from torch import nn from ...util.attention import AttentionSum from ..common.data import GlycoPeptideDataBatch from ..common.model import GlycoPeptideTreeLSTM class GlycoPeptide...
ebba007f501d25f6a69e14055682d30f0beb9dcb0fc52cccffaa24d821c2ed9d
Python
1,948
55
import os import numpy as np import pandas as pd def get_CRISPRi_LINCS_dataset(feature_selection): """ Get the CRISPRi-LINCS dataset for the given feature selection method. We have pre-selected 1000 features (genes) that are common between the CRISPRi and LINCS datasets. """ root_dir = "download/d...
f4d0af42ab01075611e6e1a393a9adca28cf2e972879aa0cc07c9080306e9827
Python
1,948
57
import pytest from scripts.check_for_inconsistent_pandas_namespace import ( check_for_inconsistent_pandas_namespace, ) BAD_FILE_0 = ( "from pandas import Categorical\ncat_0 = Categorical()\ncat_1 = pd.Categorical()" ) BAD_FILE_1 = ( "from pandas import Categorical\ncat_0 = pd.Categorical()\ncat_1 = Catego...
62104c66f2129893ca2f937694da88fd4d285150589860f6839972008224e5ce
Python
1,949
49
import json import numpy as np import scipy.io as scio from scipy import sparse import scipy # 输入权限打标(仅仅是权限是否出现)矩阵,输入权限-权限类型json文件 # 输出权限-权限类型打标矩阵(出现的权限属于哪个权限组) 0-8对应 data3定义的危险权限组信息,9就是普通权限 def read_info(i1, data2, data3): flag = 0 value0 = list(data2.values())[0] for i in i1: if i == 1:...
75abd664b9051a45612e96a0c64c6c6ba79304fc90c3bbb8a41d6e759a07ea17
Python
1,949
67
# JN 2015-05-08 adding docstrings to this old, useful code """ Simple signal filtering for spike extraction """ from __future__ import absolute_import, division import numpy as np from scipy.signal import ellip, filtfilt # pylint: disable=invalid-name, unbalanced-tuple-unpacking, E1101 DETECT_LOW = 300 # de...
fa3783762465e679a3f723ff8771f0e5cfb98cfee00ee840bee508fe49f418fc
Python
1,949
66
""" You perform a sequence simulation in IDEA (Siemens), make a sequence plot, and save the save as .txt. Then you can use this script to plot a nice looking sequence diagram for presentations or papers. Author: Zhengguo Tan <zhengguo.tan@gmail.com> """ import matplotlib.pyplot as plt import numpy as np import ...
5f204b9e64050480587dedea3c601a9435b5e6a45ee126510e6372ef99952562
Python
1,950
59
from espnet2.bin.asr_inference import Speech2Text import argparse import numpy as np import wave, time, os def get_args(): parser = argparse.ArgumentParser(description="", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("--wav_path", help="path to wav audio", required=True) prin...
b9ccc0afb45a09fc9db65210cbea6d23b05acf51fb643a21bfbf2adc9ea01c13
Python
1,951
59
# 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...
ba515c6776134ef4848d0ab1de78979c5b12b163faa6e4bad1d3525442080bc8
Python
1,952
51
import numpy as np import h5py import scipy.io as spio import sys from symmetrized_kld import SymmetrizedKullbackLeiblerDivergenceGaussians def compute_space_closeness(train_model_fname, test_model_fname): ''' This script is used to compute latent space distance between states from BSDS models Inputs: trai...
044cd5032dc71d582c3d8c6b9eb0da9202332d8ebea03b201c2af32763d74b51
Python
1,953
57
import os import types import warnings import pytest import pandas.util._exceptions as pue _SRC = ( "import warnings\n" "from pandas.util._exceptions import find_stack_level\n" "def caller():\n" " warnings.warn('boom', UserWarning, stacklevel=find_stack_level())\n" ) @pytest.mark.parametrize( ...
6246959847e3379efad41527632f1c890e4289c2d8a5bef3ea387bd9dc4b8ae5
Python
1,953
52
import numpy as np import torch import os class EarlyStopping: """Early stops the training if validation loss doesn't improve after a given patience.""" def __init__(self, save_path, save_name, patience=7, verbose=False, delta=0): """ Args: save_path (string): patience ...
e8c0cc8b24626f862052cbd8d7d0c4b9d524139269aaa0e1eda954ae011ad6cc
Python
1,953
55
import hydra from hydra import compose, initialize from hydra.core.hydra_config import HydraConfig from omegaconf import DictConfig, OmegaConf from isaacgymenvs.utils.reformat import omegaconf_to_dict OmegaConf.register_new_resolver('eq', lambda x, y: x.lower()==y.lower()) OmegaConf.register_new_resolver('contains', ...
0500412d7975adb0cf85e8c2aecf3bef46e9aba30d8cd546dbaf304ab5f4cce0
Python
1,954
55
""" Guard for the pandas base ExtensionArray test suite. Third-party ExtensionArray authors run the tests in ``pandas/tests/extension/base`` against their own array by subclassing them, and copy ``pandas/tests/extension/conftest.py`` to get the fixtures those tests request. That only works while the base tests stay cl...
cad9e42b118740d13071792fd5e7df8c680c7f8ad88207f9196796ecb806f51d
Python
1,954
47
import numpy as np, matplotlib.pyplot as plt, sys plt.rc('xtick',labelsize=14) plt.rc('ytick',labelsize=14) plt.rc('axes',labelsize=14) to_paper = "--to-paper" in sys.argv a = np.loadtxt("fpbase_spectra.csv").T l = a[0] ex = a[1] em = a[2] a = np.array([[0.9179,-10.5946],[0.9829,-10.5946],[1.0526,-10.5946],[1.1272,...
4b2d4624faedc9f2f813b87408e714bb1424b2c0d12b3442340325025d8cdaca
Python
1,955
52
# -*- 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. #...
e6d79176762b1dad06020d7f873d8427eb71742ecaa44f823e7b91b09cbb661b
Python
1,955
58
__all__ = ["GlycanComparer"] import functools from typing import cast from .glycans import GlycanNode, MonosaccharideCollection class GlycanComparer: def __init__(self, monosaccharides: MonosaccharideCollection): self.monosaccharide_order = list(monosaccharides.keys()) self._compare_sorted_glyca...
9ae3ca6a22fd3bf8f986b93ae7aa96dd8d8479f286c9216581cceb3817f78fcb
Python
1,956
69
import argparse import numpy as np import pandas as pd parser = argparse.ArgumentParser() parser.add_argument("--input_path", type=str, default="data/aggregated/concat/fpt.csv") parser.add_argument( "--save_path", type=str, default="data/aggregated/concat/fpt-del.csv" ) def _add_prev_info( bccwj_eyetrack: p...
b8e61a57f620d13e538616872ba025bf5df4eb3e10f0a66835c21de6742eb253
Python
1,956
58
import numpy as np, matplotlib.pyplot as plt import pumpprobe as pp ds_list = "/projects/LEIFER/francesco/funatlas_list.txt" signal_kwargs = {"remove_spikes": True, "smooth": True, "smooth_mode": "sg_causal", "smooth_n": 39, "smooth_poly": 1, "matchless_nan_th": 0...
60e1b8a11f57e2437c1948ee4537d7014372dd67480617a2204bed56c7c28eef
Python
1,957
68
#!/usr/bin/env python ''' Change the size of a dataset ''' from __future__ import print_function import argparse from windseer.data import change_dataset_compression import time def main(): ''' Main function which parses the arguments and then calls convert_data ''' parser = argparse.ArgumentParser(...
c567420b9f950504e23d64513ccd88406464a57c961d906515fe8d7910b35b9f
Python
1,958
64
"""K-space trajectory from .seq file class.""" from pathlib import Path import torch from einops import repeat from mrpro.data.KTrajectory import KTrajectory from mrpro.data.SpatialDimension import SpatialDimension from mrpro.data.traj_calculators.KTrajectoryCalculator import KTrajectoryCalculator class KTrajector...
012ad1611347c166c44d24729cf6d65f2cedfe866a1c8437dd16493784eeedfb
Python
1,959
29
# Test the preparation of a brain slice data. from Environment import * from Parameter import * def slice_test_data(image_patch_path, label_patch_path, channel, save_test_path, patch_num, test_id): for i in range(1, patch_num + 1): file_path = os.path.join(image_patch_path, 'PatchImage_' + channel, 'patchi...
c940b9640879e163c8647e3a3059f681345a664f351710c5ef3c0c63a9a62437
Python
1,959
50
# Copyright (c) 2021-2023, NVIDIA Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, this # list of condit...
362d4297e2ce3346d14ac0027482c22c05e7391cc0c03701e6aac4f02c25aa9a
Python
1,960
66
# -*- coding: utf-8 -*- # flake8: noqa """Installation script.""" #------------------------------------------------------------------------------ # Imports #------------------------------------------------------------------------------ import os.path as op import re from setuptools import setup, find_packages #-...
8c2a70f694759fd1659e0878f44aa665f33cd76ba5dc2c7ab21b35c38ae62a3b
Python
1,960
72
import typing from collections.abc import abc import torch import numpy as np import pandas as pd class TrainingHistory: def __init__(self): self.data = [] def add(self, epoch_result): """ Add a datapoint to the history """ self.data.append(epoch_result) def frame(self): ...
5308ef33c0de3c2f1323e9c4bb666e3600ec6cb6240cfa74b4b8156b840a1b70
Python
1,962
49
# Grad-CAM from ..utils.process import get_last_conv_layer import numpy as np import tensorflow as tf from tensorflow.keras.layers import Conv2D, Conv3D from skimage.transform import resize # for N-dimensional images def get_grad_cam(model, io_imgs, class_id, LAYER_NAME=None, MODALITY="FLAIR", XAI_MODE="classificatio...
f21a04df9c1ec86dd6408d1164112912b61f4a63fe9d0d352edcb10d9b72f860
Python
1,962
61
from Environment_ui import * from scipy import ndimage as ndi from skimage import measure def label_coords(binary_image): labeled_img = measure.label(binary_image, connectivity=1) properties = measure.regionprops(labeled_img) coords_list = [] for pro in properties: coord = pro.coords co...
5ff120ad94a517780797e8f80d3f343bfb10879e34a7202e58268e0eb8ad07b1
Python
1,963
49
#!/usr/bin/env python # -*- coding: utf-8 -*- # from distutils.core import setup from setuptools import setup, find_packages import changeseq ## conda skeleton can't find readme import os if os.path.isfile("README.MD"): with open("README.MD", "r") as fh: long_description = fh.read() else: long_description="change-...
d9ffc295e264b371b31d4b168ba1a51db6a3521ce13f8cdfaf6f20dea094c8cc
Python
1,963
59
"""Test nimare.decode.continuous. Tests for nimare.decode.continuous.gclda_decode_map are in test_annotate_gclda. """ import pandas as pd import pytest from nimare.decode import continuous from nimare.meta import kernel, mkda def test_CorrelationDecoder_smoke(testdata_laird): """Smoke test for continuous.Correl...
995a929c86b12be14a7acd9ef8e3353023cc7bacac065d0434d92c3c750a60e6
Python
1,965
57
# 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...
4823e756fceefd3ea62aeb32bc50e390f1c71734f990e40985d3714d1bf86ebb
Python
1,966
62
import numpy as np, matplotlib.pyplot as plt, sys import pumpprobe as pp, wormdatamodel as wormdm plt.rc('xtick',labelsize=14) plt.rc('ytick',labelsize=14) plt.rc('axes',labelsize=14) ds_list = "/projects/LEIFER/francesco/funatlas_list.txt" funa = pp.Funatlas.from_datasets( ds_list,merge_bilateral=Tr...