sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
c5cfd7d4b62cdfcd8dc6189e566b2f1db0fc725c1aa476b12667459f6290be8a | Python | 8,153 | 264 | """Some type hints that are used in multiple places in the codebase but not part of mrpro's public API."""
from collections.abc import Callable
from typing import TYPE_CHECKING, TypeAlias
from typing_extensions import Any, Protocol, TypeVar, runtime_checkable
if TYPE_CHECKING:
from dataclasses import Field
f... |
b881f4d3a6ff0235b94f2c56a7413ba1abbfe8f10b8a2608cac53af232877a95 | Python | 8,154 | 250 | import collections
import functools
import pathlib
import shutil
from dclab.util import hashfile
from dclab.rtdc_dataset.feat_anc_plugin import plugin_feature
SUPPORTED_FORMATS = [
".py",
]
class ExtensionManager:
def __init__(self, store_path):
"""Extension manager
This class can be used ... |
7505c88bcbc5a71417d5e2d6ee008b60e52ea7561cd681d016726846668ab7b8 | Python | 8,160 | 195 | import numpy as np
import pandas as pd
import seaborn as sns
from sklearn.preprocessing import MinMaxScaler
import rdkit
from rdkit import Chem
from rdkit.Chem.rdmolops import GetAdjacencyMatrix
# Pytorch and Pytorch Geometric
import torch
from torch import nn
from torch.nn import functional as F
from torch_geometric.d... |
659ee6bee7e827f802539a567382dbff3b80228c9cf4c5df21f12238660e16f0 | Python | 8,163 | 217 | import numpy as np
import torch
from torch.autograd import Variable
import torch.nn.functional as F
def partition_batch(ls, size):
"""
Partitions a list into buckets of given maximum length.
"""
i = 0
partitioned_lists = []
while i < len(ls):
partitioned_lists.append(ls[i: i+size])
... |
bc9d2c6673d0346f1d28889981e0e0c6295d036e83e1a500e24c8d49a2afbb24 | Python | 8,164 | 163 | import logging
from base import surfaces
from base import conjugateGradient as cg ,kernelFunctions as kfun ,pointEvolution as evol ,loggingUtils ,bfgs
from base.surfaceMatchingNormalExtremities import SurfaceMatching
from base.surfaceMatching import SurfaceMatchingParam
from base.affineBasis import *
from base import e... |
79334f222aed0766ca22d2557f789f80a547e335987e6e86aeb23d7a186eaa95 | Python | 8,167 | 234 | """Dataset/data module utilities."""
from __future__ import annotations
import logging
import os
import numpy as np
import torch
from jaxtyping import Float
logger = logging.getLogger(__name__)
# to ignore imports for sphinx-autoapidoc
__all__: list[str] = []
def split_sizes_from_probabilities(
total_number: ... |
4ff6acf58d8c8b7caae0418d48065ae2f2531059bac85003df421531102c7380 | Python | 8,172 | 174 | ################################################################
import numpy as np
from scipy.interpolate import interp1d
import matplotlib.pylab as plt
import matplotlib.gridspec as gridspec
import matplotlib
matplotlib.rcParams.update({'text.usetex': False, 'font.family': 'stixgeneral', 'mathtext.fontset': 'stix',})... |
105ad783ccf96632ad8f50c09469366a681e901d41f045a1ea933ecf24b03db2 | Python | 8,175 | 207 | import torch
from torch import Tensor
import torch.nn.functional as F
from torch.nn import Sequential, Linear, ReLU, BatchNorm1d, GRU
import torch_geometric
from torch_geometric.nn import (
Set2Set,
global_mean_pool,
global_add_pool,
global_max_pool,
NNConv,
DiffGroupNorm
)
from tor... |
a0acf99fa988df89afcff30c9cfd06903dfd00ada4fc029da70d33c2e7226b03 | Python | 8,175 | 254 | from __future__ import annotations
import functools
from typing import (
TYPE_CHECKING,
Any,
)
if TYPE_CHECKING:
from collections.abc import Callable
from pandas._typing import Scalar
import numpy as np
from pandas.compat._optional import import_optional_dependency
from pandas.core.util.numba_ imp... |
8c08d41f2c063d87baf2d1715e4c0c1299fb10e2f883f779c6bda4ee85a64ec4 | Python | 8,177 | 232 | """Session 36 — native setup() phase 2: ``normalize`` + ``transformation``.
Phase 1 (session 35) shipped native setup for the simple supervised
case. Phase 2 extends the native preprocessing chain with two more
common options:
- ``normalize=True`` → ``StandardScaler`` on numeric columns (z-score).
- ``transformation=... |
ae44496de9ef2e0e9e30f564332305f4ec6e3194d861d048a3651edfc422043d | Python | 8,183 | 236 | from plastid.genomics.genome_array import BAMGenomeArray
import re
import numpy
import itertools
# Regular expressions for identifying the number of mismatches at the 5' end of a read
NMIS_RE_PLUS = re.compile(r'^(0[ACGTN])*')
NMIS_RE_MINUS = re.compile(r'([ACGTN]0)*$')
def read_length_nmis(read):
"""Get the 5'-... |
640ff002b51f31eb2bfb4bf58803d76a3f1b8ecdab9625979efb165578eb3837 | Python | 8,195 | 219 | # 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... |
5aa5863d556d5fe082f0928d9f7bbd1819407c0841b4b72fd68696d5e1db7c60 | Python | 8,199 | 228 | #%%
from pathlib import Path
import pandas as pd
from src.paths import Paths
from src.data_description import load_worklist
#%% set paths
data_dir = Path(__file__).parent.parent.parent / 'data'
paths = Paths(data_dir / "paths.json")
database_dir = Path(paths("CIMBI_DATABASE_DIR"))
#%% 1. combine worklist and database... |
1761ef5f16653aa95cf5fa8ccd6dd0c78b525041dd555dc4e997ddd4b563066d | Python | 8,201 | 177 | import argparse
import os
import ete3
import pandas as pd
from ete3 import NCBITaxa
def get_args():
"""
Get arguments from command line with argparse.
"""
parser = argparse.ArgumentParser(
prog='Adjust-kreport-taxonomy',
description="""Update a kraken-style report using the most current... |
4fa3bffdf4ced61ec532c0d7e39e4ef648cb53a56b45fb5b25ea17a678b4f4d8 | Python | 8,202 | 181 | import numpy as np
import warnings
from skimage.filters import threshold_otsu
from skimage.util import view_as_windows
from PIL import Image, ImageFilter
from utils import singledispatch_instance_method, Observable
class ImagePreprocessor(Observable):
def __init__(self, config) -> None:
"""
args... |
e14a90d4cf8d7828d81f945d788123d2d2810cf1b93a63d9bdfc282c93a1909b | Python | 8,204 | 235 | """``predict_age`` runs a clock's declared cohort transform for it.
A cohort-relative clock cannot read a sample in isolation, so its feature
matrix is not sliced out of ``adata.X`` but computed from the whole cohort
first. The model declares ``cohort_transform``; ``predict_age`` resolves that
name to a transform, run... |
48d0918a89a739464c3bf5db8ebb6c3118f403ba73f0484df694467afa974070 | Python | 8,208 | 228 | '''
Created on Apr 2, 2012
@author: regger
'''
import numpy as np
import single_cell_parser as scp
from model_data_base.mdbopen import mdbopen
def compute_synapse_distances_times(fname, cell, t=None, synTypes=None):
synDistances = {}
synTimes = {}
activeSyns = {}
synCnt = 0
if synTypes is None:
... |
a61b001ea881bca508cbbe20a5853f351eb70663ae02859fe857bff3d68baa95 | Python | 8,211 | 239 | import sklearn.compose
from sklearn.base import BaseEstimator, ClassifierMixin, clone
from sklearn.compose import TransformedTargetRegressor
from sklearn.preprocessing import PowerTransformer
from sklearn.utils.validation import check_is_fitted
class PowerTransformedTargetRegressor(sklearn.compose.TransformedTargetRe... |
5f92ab17297f7f1684949cd6ef88cd21529a427dd1c35c31337821337da60f86 | Python | 8,213 | 165 | # MIT License
#
# Copyright 2026 Broad Institute
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, ... |
ab9afb086291fca1e2378dccabc417bb1319d21a006404b8e029ba1f18019f08 | Python | 8,214 | 228 | """Session 37 — native setup() phase 3: ``remove_outliers`` + ``feature_selection``.
Phase 1 (s35) shipped impute + ordinal-encode + label-encode + split +
fold + registry. Phase 2 (s36) added ``normalize`` + ``transformation``.
Phase 3 finishes the supervised tabular preprocessing flags:
- ``remove_outliers=True`` →... |
e6769b57e1481eb95788626ad08b835199692c00e79fe6bc85c9876f88f6ba17 | Python | 8,215 | 238 | # To run this script, execute "python doc/convert_notebooks.py" from the root
# of the repository.
import glob
import os
import shutil
import subprocess
import sys
import nbformat
from nbconvert.preprocessors import ClearOutputPreprocessor
EXAMPLES_DIR = os.path.abspath(
os.path.join(os.path.dirname(__file__), "... |
8f9da96780c4c32b394527aa981404eafbc4eb175f6462f0c4ed2c86eb1c77c8 | Python | 8,217 | 231 | # Copyright (C) 2019-2024 PyCaret
# Module: containers.metrics.clustering
# Author: Antoni Baum (Yard1) <antoni.baum@protonmail.com>
# Contributors (https://github.com/pycaret/pycaret/graphs/contributors)
# License: MIT
# The purpose of this module is to serve as a central repository of clustering metrics. The `clust... |
e287da0d6de06b7a765eaeb4a261c44d52071eddd88084e2b1f926fc16772105 | Python | 8,220 | 211 | """Test nimare.meta.mkda (KDA-based meta-analytic algorithms)."""
import numpy as np
import nimare
from nimare.correct import FDRCorrector, FWECorrector
from nimare.meta import KDA, MKDAChi2, MKDADensity, MKDAKernel
def test_MKDADensity_kernel_instance_with_kwargs(testdata_cbma):
"""Smoke test for MKDADensity wi... |
2723a0b4a3d41f683a648eb132295648ba34689a04b501c8325bf828cb3a4a6e | Python | 8,224 | 245 | import torch
import numpy
import matplotlib.pyplot as plt
import bionetwork
import pandas
from sklearn.decomposition import PCA
from sklearn.linear_model import LinearRegression
#from sklearn.manifold import TSNE
import umap
from scipy.stats import pearsonr
from sklearn.model_selection import KFold
import seaborn as sn... |
de0396ab781e492521d54389212ee36d6b0d0672649ec873273e001e464f09b3 | Python | 8,225 | 169 | import argparse
import sys
from mol2vec import features
def do_corpus(args):
print('Generating corpus file.')
features.generate_corpus(args.in_file, args.out_file, args.radius, sentence_type='alt', n_jobs=args.n_jobs)
if args.uncommon:
print('Finding uncommon identifiers and replacing them with %s... |
377bf1ac563f13e17fd40a7355d40a338a09396bbe161eeeb7920cc81a442642 | Python | 8,227 | 238 | """
Tests that features that are currently unsupported in
either the Python or C parser are actually enforced
and are clearly communicated to the user.
Ultimately, the goal is to remove test cases from this
test suite as new feature support is added to the parsers.
"""
from io import StringIO
import os
from pathlib i... |
6f91df2f7619cb1162b099704f6d2473f99ca8e8a480dd4de679ad7d096c5afa | Python | 8,228 | 247 | # coding: utf-8
# Copyright (c) Pymatgen Development Team.
# Distributed under the terms of the MIT License.
from __future__ import division, unicode_literals
"""
This module contains an algorithm to solve the Linear Assignment Problem.
It has the same functionality as linear_assignment.pyx, but is much slower
as it ... |
26ce96e98218f6fd92d0e8d4a128ebf8c78f96a47e7da9a1639e30294b20217c | Python | 8,230 | 245 | ''' neuronbridge_lib.py
Function library for NeuronBridge processing
'''
from datetime import datetime
import glob
import os.path
import re
import socket
import time
from simple_term_menu import TerminalMenu
RELEASE_LIBRARY_BASE = "/groups/scicompsoft/informatics/data/release_libraries"
def get_all_s3_objects(s... |
9d3068615e18b94264b8359fba943761508201f1203356261794da950aa8f018 | Python | 8,233 | 248 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
class TestMultiIndexPartial:
def test_getitem_partial_int(self):
# GH 12416
# with single item
l1 = [10, 20]
l2 = ["a", "b"]
df = pd.DataFrame(index=range(2), columns=pd.MultiIndex.from_produ... |
35c68c717244334e14bef1f909534c00e0ce1a5e5915c006f6e3cde15a18a0ba | Python | 8,239 | 201 | ######################
### Import Library ###
######################
# general library
import os as os
import numpy as np
import pandas as pd
import random as random
import time as time
import argparse
# pytorch
import torch
###########################
### Experiment Function ###
###########################
# parser... |
fecf751a528dc0bb85e661da598abf4b2d4e4ade43b4737684a5ab02a888d6bb | Python | 8,239 | 250 | # Some helpers to work with Redis
import sys
import yaml
import redis
import datetime
import sys
import argparse
import errno
#############################################
#############################################
## Load the YAML file
#############################################
###############################... |
82e610a47a806d1edffdba3fede2208b3954f72a8d5dc1781a1b6c0ccd0ca157 | Python | 8,241 | 236 | """Run "plans" — named sequences of engine-verb calls.
A `RunPlan` tells the orchestrator what to actually do after `.fit(data)`:
- ``"setup"`` — just fit; no model training.
- ``"create"`` — fit + `create_model(model_id, **plan_params)`.
- ``"compare"`` — fit + `compare_models(**plan_params)`; returns leaderboard... |
21d9536ecbb2807387f47e1a7e4e76e32e2f2a4e8481c7ccc42467935baf589d | Python | 8,248 | 229 | # 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... |
63970ac7a5c7e1b612e53a1b9d1ee8b0d3fde0678ae216afc1819af2d9002b59 | Python | 8,248 | 289 | # -*- coding: utf-8 -*-
"""
Created on Sun May 1 17:33:44 2022
@author: jeanbaptiste
"""
import os
import json
import pycromanager_tessie as pmt
from pycromanager_tessie.acquisitions import experiment
# Start platform:
platform = pmt.microscope.platform.Platform(load_synchronizer=True)
# Set LED ring
platform.neop... |
b5eda219fac56afec987fb3c6b497ae23e90400c70c77b3550ee64f01dea743e | Python | 8,248 | 248 | # 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... |
d08860392d856b0034a89e93506642066987ec8557ba65f0d10548ca70865842 | Python | 8,250 | 285 | import json
import logging
from io import StringIO
from pathlib import Path
from .loaders.csv import CsvLoader
from .loaders.excel import ExcelLoader
from .loaders.json import JsonLoader
from .loaders.text import TextLoader
from .loaders.toml import TomlLoader
from .loaders.xml import XmlLoader
logger = logging.getLog... |
6a4d1904c69b8c59558147c920117e29c51bda1708e30bedb5a4fb3592171d41 | Python | 8,251 | 177 | import argparse
import os
import ete3
import pandas as pd
from ete3 import NCBITaxa
def get_args():
"""
Get arguments from command line with argparse.
"""
parser = argparse.ArgumentParser(
prog='Convert_metamaps-WIMP_to_kreport-mpa.py',
description="""Convert a WIMP file obtained from m... |
8fe144948daae324aac43e639e27bb7ce44bcd4c82dff79a17ff50d008b49e34 | Python | 8,253 | 243 | import pickle
import numpy as np
import pytest
from pandas.errors import Pandas4Warning
import pandas as pd
import pandas._testing as tm
from pandas.tests.copy_view.util import get_array
def test_astype_single_dtype():
df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6], "c": 1.5})
df_orig = df.copy()
df... |
ef08b01a7a9de160de5e104c82e086e2cf22cd262151c4d956dedcbb89a70645 | Python | 8,256 | 223 | # BRAND node template
# Author: Mattia Rigotti
# Adapted from code by: David Brandman and Kushant Patel
import sys
import argparse
from redis import Redis
import logging
import signal
import json
import time
class BRANDNode():
def __init__(self):
# parse input arguments
argp = argparse.ArgumentPa... |
c010f17e83d3a75276002a0544df5a1238d6c1be7d2f4088fcef4612bc82d34e | Python | 8,262 | 171 | """AAL2 atlas region-importance ranking, ported from `exploration.ipynb`.
**The AAL2 atlas volume is bundled**: `atlas.nii.gz` is checked into the
repository root ((91, 109, 91), 2mm voxels, 120 nonzero region intensities
matching `AAL2_Atlas_Labels.csv`); load it with `load_atlas` below. This is
a research/reference ... |
2b7f866cbfce8c25f099ff071b08c4df1fb904b0445828062f1dfbc84804abbc | Python | 8,271 | 296 | from __future__ import print_function
import windseer.plotting as plotting
import argparse
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
import numpy as np
import os
parser = argparse.ArgumentParser(description='Script to plot prediction errors')
parser.add_argument(
'-data',
dest='d... |
c69acff6fae4b92b05f8398e4f76d34d41716818f1b3e31f29478720d67847b4 | Python | 8,273 | 210 | from PyQt5 import QtWidgets, QtCore
import pyqtgraph as pg
from brainflow import BoardShim, DataFilter, FilterTypes, DetrendOperations
# This object is created to display in real time ENOPHONE's data, using self as argument, a variable that can be updated is created
# The argument board allow to call the specific boar... |
f585cd32eab18bac54b55395989b7cb745da66c0ccac5ca986c9baad297abeae | Python | 8,273 | 293 | import sys
import numpy as np
import pandas as pd
def fix_trial(row):
docid = row['docid']
trialid = row['trialid']
sentid = row['sentid']
sentpos = row['sentpos']
if docid == 'part3' and trialid == 99 and sentid == 3820 and sentpos > 6:
return 100
return trialid
df = pd.read_csv(sys.s... |
594768943d08076a13d5f75cee096e25f7745f5d97d92805cc51339785f3990c | Python | 8,274 | 290 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
def test_infer_objects(idx):
with pytest.raises(NotImplementedError, match="to_frame"):
idx.infer_objects()
def test_shift(idx):
# GH8083 test the base class for shift
msg = (
"This method is only implemen... |
7081f326a02099963b4c74d0fd6f4a1fd7211ddf606e4281fe0e87b38c875e6d | Python | 8,274 | 183 | import numpy as np
import pandas as pd
import torch
from torch.utils.data import Dataset
def cleanup_schema(df,schema_options, infer_all=False):
#These are the names of the MHC sequence columns
allele_seq_cols = ['mhc_dr1_1', 'mhc_dr1_2', 'mhc_dr3_1', 'mhc_dr3_2', 'mhc_dr4_1', 'mhc_dr4_2', 'mhc_dr5_1', 'mhc_dr... |
f798e29bac102223b898fec4826542d5f4d92210d93ddfeee987520897bb7596 | Python | 8,279 | 183 | import numpy as np
import pandas as pd
import torch
from torch.utils.data import Dataset
def cleanup_schema(df,schema_options, infer_all=False):
#These are the names of the MHC sequence columns
allele_seq_cols = ['mhc_dr1_1', 'mhc_dr1_2', 'mhc_dr3_1', 'mhc_dr3_2', 'mhc_dr4_1', 'mhc_dr4_2', 'mhc_dr5_1', 'mhc_dr... |
6804ba7de635a42191465cf253a9b0175b0ccff6eda60986abb3a3f98fd56ac2 | Python | 8,280 | 222 | import copy
import os
import subprocess
import time
from dataclasses import dataclass
from typing import Dict, List
from IPython.display import clear_output
from pcntoolkit.util.output import Messages, Output, Warnings
@dataclass
class JobStatus:
job_id: str
name: str
state: str
time: str
nodes:... |
e69f0420caacc7e4855eeb5ba464f349a8e0c7f4811e7a2d2c1ef49ef1b7ee1f | Python | 8,280 | 154 | from Environment_ui import *
from PySide2.QtWidgets import QWidget, QFileDialog, QPushButton, QMessageBox
from PySide2.QtUiTools import QUiLoader
from PySide2.QtCore import Signal, QObject
from threading import Thread
from pages.Registration.brain_registration import read_freesia2_image, write_freesia2_image
from pages... |
405940b429a7aff60a76df3a01fb7e2f6a7e0bcee9d0d544c8a63bcd7a0844cf | Python | 8,282 | 157 | import argparse
import sys
import os
import pandas as pd
from cdr.config import Config
from cdr.io import read_tabular_data
from cdr.formula import Formula
from cdr.data import preprocess_data, filter_invalid_responses
from cdr.model import CDREnsemble
from cdr.util import filter_models, get_partition_list, paths_from_... |
70f3e1ae5d29b3ba323cf21012fd0a06d707c522d37b41fb98c78bb0e0463379 | Python | 8,282 | 177 | # some codes are from official tutorials https://captum.ai/tutorials/Segmentation_Interpret
import os
import cv2 as cv
import numpy as np
import torch
import shutil
import utils.image_transforms as image_transforms
from torch.utils.data import DataLoader
import op_dataset as dataset
from utils.loss_function import *
f... |
3f2e85cb50fe97f97785515ba628c29f051f3b4f493ad8f44da3ff386d81af02 | Python | 8,288 | 210 | """Module that contain iterator used for dynamic data."""
from itertools import cycle
from torchtext.data import batch as torchtext_batch
from onmt.inputters import str2sortkey, max_tok_len, OrderedIterator
from onmt.inputters.corpus import get_corpora, build_corpora_iters,\
DatasetAdapter
from onmt.transforms imp... |
def930b5b866bb1098fd6844e0a11cc75f53ff61b7e0dad44b494cdf79cea08e | Python | 8,289 | 330 | #!/usr/bin/env python
# coding: utf-8
# <a href="https://colab.research.google.com/github/Cyberbullying-Detection/Cyberbullying-Detection-on-Social-Media-using-Deep-Learning-and-Conventional-Machine-learning/blob/main/Twitter_16k_Glove.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-ba... |
012139629275b7a73b00dbd17eab14017f86af31f2d14b99e78dc1ee366cfda4 | Python | 8,290 | 173 | # emacs: -*- mode: python-mode; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
# ex: set sts=4 ts=4 sw=4 et:
"""
.. _datasets_object:
=========================
The NiMARE Dataset object
=========================
This is a brief walkthrough of the :class:`~nimare.dataset.Dataset` class and its methods.
... |
d3d0be16bbdf4062eb51a0e2116325b55cec5c04f2e737cd69d24649d430ee14 | Python | 8,290 | 252 | """
Test cases for mutate stage of EVCouplings pipline
Author:
Anna G. Green
"""
import unittest
import os
import tempfile
import pandas as pd
import ruamel.yaml as yaml
from copy import deepcopy
from unittest import TestCase
import evcouplings
from evcouplings.mutate.calculations import *
from evcouplings.mutate... |
4e5be24cd8f630cc025bc1a5bfbc1f4ecb8a56be6425095c2172e14cc014e160 | Python | 8,291 | 234 | """
Protocols for concatenating sequences based
on distance in genomes (DNA sequences).
DNA sequences are extracted from the EMBL ENA databse,
and may refer to whole genome sequences, contigs, and plasmids.
Authors:
Anna G. Green
Thomas A. Hopf
Charlotta P.I. Schärfe
"""
import pandas as pd
import matplotlib.pyp... |
9427b47dd6e3333f0fdf32f7bbfe46810357254b54cbecda68932fc35bcf6831 | Python | 8,293 | 273 | """
:func:`~pandas.eval` source string parsing functions
"""
from __future__ import annotations
from enum import Enum
from io import StringIO
from keyword import iskeyword
import token
import tokenize
from typing import (
TYPE_CHECKING,
Any,
)
from pandas.core.computation.scope import DEFAULT_GLOBALS
if TYP... |
5d0957d2e862a265a37168b88c62b9827733628823491111a608cf0307df1160 | Python | 8,294 | 286 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Code to prepare the audio, visual couplings for the Supervised Audiovisual
Correspondence (SAVC) task.
"""
import pandas as pd
import numpy as np
from pathlib import Path
from functools import partial
import itertools
from random import shuffle
# %% Read in AVMIT cs... |
44b1117a53e5205642cebfb05756484142cbee7dea2673683dc54aa0472302dd | Python | 8,295 | 271 | from io import StringIO
import time
import numpy as np
from kilosort import spikedetect, preprocessing, CCG
import torch
from torch.nn.functional import conv1d, max_pool2d, max_pool1d
from tqdm import tqdm
def prepare_extract(ops, U, nC, device=torch.device('cuda')):
ds = (ops['xc'] - ops['xc'][:, np.newaxis])**2... |
8a2007a6d77f947f2c8860438ce1b0b9f2879b77af822d07224efc636e2a2493 | Python | 8,298 | 219 | """Test nimare.meta.mkda (KDA-based meta-analytic algorithms)."""
import logging
import numpy as np
import nimare
from nimare.correct import FDRCorrector, FWECorrector
from nimare.meta import KDA, MKDAChi2, MKDADensity, MKDAKernel
def test_MKDADensity_kernel_instance_with_kwargs(testdata_cbma):
"""Smoke test fo... |
4d34632e67774ce7662b3505fb136435649227fe388d70c5422b69d1492b1ec2 | Python | 8,299 | 231 | import numpy as np
import pytest
from pandas.errors import (
IncompatibleFrequency,
Pandas4Warning,
)
import pandas as pd
import pandas._testing as tm
class TestPeriodIndex:
def test_view_asi8(self):
idx = pd.PeriodIndex([], freq="M")
exp = np.array([], dtype=np.int64)
tm.assert... |
c35684ba7aa6bd36268063f6d766d26187869ea7751ecfa50c30f858cc1279fa | Python | 8,299 | 203 | import numpy as np
import pytest
import pandas as pd
def test_repr_with_unicode_data():
with pd.option_context("display.encoding", "UTF-8"):
d = {"a": ["\u05d0", 2, 3], "b": [4, 5, 6], "c": [7, 8, 9]}
index = pd.DataFrame(d).set_index(["a", "b"]).index
assert "\\" not in repr(index) # we... |
5d291b2fe53cb449b8660c7adcad05c76108f2b2ead719442411e034273706c9 | Python | 8,305 | 256 | # 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... |
9da4a3041b2051355e8b589d9a166211bc224649c5de187aaebf50acf679a54d | Python | 8,305 | 246 | """Unit tests for samalg.utilities module."""
from __future__ import annotations
import numpy as np
import scipy.sparse as sp
from samalg import utilities as ut
class TestWeightedPCA:
"""Tests for weighted_PCA function."""
def test_basic_pca(self, dense_matrix: np.ndarray) -> None:
"""Test basic P... |
509ce4e393b7bce38d7b5c5d15f33e3c1017b022e95b9c66ea8bcefac1600fef | Python | 8,309 | 241 | import logging
import math
import readline
import sys
from itertools import islice
from pathlib import Path
from typing import TYPE_CHECKING, Dict, Literal
import torch
import torch.nn as nn
from torch.nn.parallel.distributed import DistributedDataParallel
from ocpmodels.common.data_parallel import OCPDataParallel
fr... |
52513dfb3718f4445a770c227f97d7d6851aa9a11fccef058deef2a01e95368d | Python | 8,312 | 286 | import json
import os
import re
import subprocess
from itertools import groupby
from string import ascii_uppercase, digits
from monty.fractions import gcd
from pymatgen.core.composition import Composition
from pymatgen.io.vasp import Poscar
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
mult_file = os.path... |
8ef5fa8c4417e2df3f3959743f7ed06a60652f76b46f44f8e64ea756bb0612d6 | Python | 8,312 | 197 | __author__ = 'etseng@pacb.com'
import os, sys, glob
from collections import defaultdict
from csv import DictReader, DictWriter
from bx.intervals import IntervalTree
import vcf
import phasing.io.SAMMPileUpReader as sp
def read_fake_mapping(fake_genome_mapping_filename):
"""
:param fake_genome_mapping_filename:... |
9d68b7884561512adfb87e910139902a3ffea58b8f1f0f3981fc9c2978cc9c67 | Python | 8,312 | 277 | import os
import numpy as np
import pandas as pd
from deepglyco.chem.common.elements import ElementCollection
from deepglyco.chem.gpep.glycans import MonosaccharideCollection
from deepglyco.chem.pep.aminoacids import AminoAcidCollection
from deepglyco.chem.pep.mods import ModificationCollection, ModifiedSequenceParse... |
f62c46b7fb05b7cd6a26496de17ee5c5ba9a83351e334026f53a5d4a05b72c67 | Python | 8,313 | 183 | import torch
from tqdm import tqdm
import os
import time
from src import math
from collections import OrderedDict
from human_body_prior.body_model.body_model import BodyModel
from src import functions as sf
from model.net import FIP
from src.eval_tools import *
body_parm = [[0,186,84.24332236,55.0763866... |
ee001273b553d4daaeff3417db5cf4216c2f3e03820ba9c164828700c844eede | Python | 8,315 | 271 | """
This script performs DWI reconstruction
Stepwise,
1. shot phase estimation
2. MUSE or JETS reconstruction
Author: Zhengguo Tan <zhengguo.tan@gmail.com>
"""
import argparse
import h5py
import os
import torch
import numpy as np
import sigpy as sp
import torchvision.transforms as T
from sigpy.mri import ... |
73bf8d77a4f9b3b19cd11bbb6978a849647257ab43ab92b4a2143b647eb073e1 | Python | 8,317 | 254 | #
# File to train networks built from the hnn.py class.
#
# This file establishes the clebsch gordan coefficients, sets up an hnn with given parameters,
# loads holograms from .npy files, and then tests the network via a function call.
#
from argparse import ArgumentParser
import logging
import os
import sys
import ... |
27944df5baaa899815436d944401ca856a9f092f29704c3c7bc40b79e317ea99 | Python | 8,318 | 227 | """Test nimare.io (Dataset IO/transformations)."""
import os
import pytest
import nimare
from nimare import io
from nimare.tests.utils import get_test_data_path
from nimare.utils import get_template
def test_convert_sleuth_to_dataset_smoke():
"""Smoke test for Sleuth text file conversion."""
sleuth_file = o... |
ef4883afb4757755d6ee07f6a5a6dbc107590ab7a79fc55ed3742b31272c7a6e | Python | 8,319 | 119 | import sys, os, re, collections
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'resource-gcg', 'scripts'))
import tree
VERBOSE = False
################################################################################
def deps( s, ops='abcdghirv' ):
lst = [ ]
d,h = 0,0
for i in range( len(s)... |
40545d24866264911a44716e148d8f0dbcc4c103d7ec6d55fda3e8e74b548b63 | Python | 8,320 | 266 | from datetime import (
date,
datetime,
)
import zoneinfo
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
def test_insert(idx):
# key contained in all levels
new_index = idx.insert(0, ("bar", "two"))
assert new_index.equal_levels(idx)
assert new_index[0] == (... |
24c00f57a36ad8e25a22e0cffb0acd1fd1fc1c38e4f4dbc7e5c184dc64be9534 | Python | 8,323 | 147 | import pandas as pd
import os
import sys
from glob import glob
import argparse
import logging
"""
Description: parse output files in /out into combined results files in /results.
"""
def main(BASE_OUTPUT_DIR, logger):
BASE_OUTPUT_DIR = os.path.abspath(BASE_OUTPUT_DIR)
if not os.path.exists(BASE_OUTPUT_DIR... |
2a831ab338fc386f03d39a0da48ac7a191242e378949b23018a33059caad851f | Python | 8,323 | 167 | import sys
import os
import pickle
import string
import itertools
import numpy as np
import pandas as pd
import argparse
from cdr.synth import SyntheticModel
if __name__ == '__main__':
argparser = argparse.ArgumentParser('''
Create synthetic data using randomly generated IRFs.
''')
argparser.add_... |
bd56bbeb58d86cadcfe15da4c86046e769e0c5f418a189ca482aea6413633b60 | Python | 8,323 | 231 | import numpy as np, matplotlib.pyplot as plt, sys, re, matplotlib.gridspec as gridspec
import pumpprobe as pp, wormdatamodel as wormdm
plt.rc("xtick",labelsize=18)
plt.rc("ytick",labelsize=18)
plt.rc("axes",labelsize=18)
jid = "RID"
vmax = 1
matchless_nan_th = None
matchless_nan_th_from_file = "--matchless-nan-t... |
19f477f6ec1bafe262c9999a4a4a1ccde81b2b46fb3768ba80748ee1712bf8f5 | Python | 8,326 | 194 | # 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... |
aafa1c3e5bfa5436ae518cb71e2bba8fe5377002a195e3fcf110ae87a2d99cd1 | Python | 8,340 | 193 | # 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... |
e0c045f88327d4cbbeeb92104ac312881d64cfca07b7dcc441ac9c1f3fcb6e19 | Python | 8,340 | 225 | """ Subclasses of the tensorflow.keras.Model class.
These objects should be hidden from the user
"""
import os
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
import tensorflow as tf
import logging
tf.get_logger().setLevel(logging.ERROR)
from apnet.layers import DistanceLayer, FeedForwardLayer
#################
tar... |
63b8724a2fbc4f7742201a4b4d0808c8e64ba1246711fa95fb8c18e0a22c200d | Python | 8,341 | 267 | """
Tests of the groupby API, including internal consistency and with other pandas objects.
Tests in this file should only check the existence, names, and arguments of groupby
methods. It should not test the results of any groupby operation.
"""
import inspect
import pytest
import pandas as pd
from pandas.core.grou... |
c39890ab6f3895c7bf0d57f5a8b34b62fc6cf169658375d11b493f277434c87c | Python | 8,348 | 269 | import copy
import re
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
def test_assert_numpy_array_equal_shape_mismatch():
msg = """numpy array are different
numpy array shapes are different
\\[left\\]: \\(2L*,\\)
\\[right\\]: \\(3L*,\\)"""
with pytest.raises(AssertionErr... |
bdeb8b2696f2d024650c64d5fd16aeae403039a4049d32fd5b93a91f0a91c21b | Python | 8,349 | 250 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
class TestMultiIndexPartial:
def test_getitem_partial_int(self):
# GH 12416
# with single item
l1 = [10, 20]
l2 = ["a", "b"]
df = pd.DataFrame(index=range(2), columns=pd.MultiIndex.from_produ... |
22f0db7cba4df4d130e1d6cc133069d41263ed3ea2d8a33e60c6924b762b0931 | Python | 8,353 | 280 | import glob
import os
import random
import logging
import pathlib
import argparse
import numpy as np
import pandas as pd
import torch
import torch.nn as nn
from skorch import NeuralNetClassifier
from skorch import NeuralNetRegressor
from sklearn.pipeline import Pipeline
from sklearn.model_selection import GridSearchCV... |
32dfb1b442a149622beeba9fc16bce5daabc5285499184e5ebacdd9ab6241848 | Python | 8,353 | 211 | # License: see [LICENSE, LICENSES/legged_gym/LICENSE]
from .base_config import BaseConfig
class LeggedRobotCfg(BaseConfig):
class env:
num_envs = 4096
num_observations = 235
num_privileged_obs = None # if not None a priviledge_obs_buf will be returned by step() (critic obs for assymetric t... |
54ad3056651a5e02445dd72bc6d6cc34de9f676caeb80fc0da24d31eb2d5cd03 | Python | 8,358 | 205 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
def monotonic_index(start, end, dtype="int64", closed="right"):
return pd.IntervalIndex.from_breaks(
np.arange(start, end, dtype=dtype), closed=closed
)
def empty_index(dtype="int64", closed="right"):
return pd.In... |
6c997de48703ac56e300f1fe51685d1c64402bbde4eff82ad9cba25c949d56ff | Python | 8,359 | 254 | from __future__ import annotations
import functools
from typing import (
TYPE_CHECKING,
Any,
)
if TYPE_CHECKING:
from collections.abc import Callable
from pandas._typing import Scalar
import numpy as np
from pandas.compat._optional import import_optional_dependency
from pandas.core.util.numba_ imp... |
e940b91706e892965a9915549ac6392af3decf07bac0352ab9daebd5d17ccc1e | Python | 8,363 | 229 | # 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... |
0752f04476154ad351be4fd2e932b5c901289a48b47a1f6cb960274abfc8ba45 | Python | 8,364 | 188 | # Inspired from https://towardsdatascience.com/bert-text-classification-using-pytorch-723dfb8b6b5b
# and from: https://curiousily.com/posts/multi-label-text-classification-with-bert-and-pytorch-lightning/
import torch.nn as nn
import pytorch_lightning as pl
from transformers import BertModel, AdamW, get_linear_schedule... |
58bfe9f90abf1b40fd8293a8a6f78646f893bacbccc3b244e16d2665a5d5bba8 | Python | 8,364 | 236 | from typing import Literal, Optional
import numpy as np
import pandas as pd
_reference2 = Optional[Literal["hg38", "mm10", "sacCer3"]]
def combine_annotation(
peak_data: pd.DataFrame,
peak_annotation: pd.DataFrame,
) -> pd.DataFrame:
"""\
Combine peak information and annotation information.
:p... |
f18da15b23f6c25bb01d7a2d81cd8137ff274bbdd393640b17a88c665e6fb2c0 | Python | 8,366 | 221 | import numpy as np
from math import ceil
from math import log
def calculate_counters(data_sets, c_threshold=None, w_factor="fraction"):
"""Calculate 1-similarity, 0-similarity, and dissimilarity counters
Arguments
---------
data_sets : np.ndarray
Array of arrays. Each sub-array contains m + 1 ... |
ab9546d53609e59a52515c623d3620c6c3876cb05095088d0dede8492eaeb9e5 | Python | 8,369 | 188 | from VISoR_Brain.visor_brain import VISoRBrain
from Parameter import *
from Environment import *
from math import ceil
from elastix_files import get_align_transform
ROOT_DIR = os.path.dirname(__file__)
PARAMETER_DIR = Registration['parameters_root']
def generate_freesia_input(input_path: str, shape, channel, pixel_si... |
ea964885beaa7707d82d259b8da8cf1befa3240c6f5366df7913cba98f08b967 | Python | 8,372 | 232 | """Separable Sum of Proximable Functionals."""
from __future__ import annotations
import operator
from collections.abc import Iterator
from functools import reduce
from typing import cast
import torch
from typing_extensions import TypeVarTuple, Unpack, overload
from mrpro.operators.Functional import ProximableFunct... |
38bff9b804dad2851b0a8ebc9a90c4d4a917e394faf474a7ed572f9c2a10682e | Python | 8,376 | 195 | # -*- coding: utf-8 -*-
import sys
import random
import os
import numpy as np
from collections import defaultdict
sys.path.append(os.getcwd()) #add the env path
from sklearn.model_selection import train_test_split,StratifiedKFold
from main import train
from config import DRUG_EXAMPLE, RESULT_LOG, PROCESSED_DATA_DIR, L... |
caa988d458c196ea7b72db1e71983f6f77c5403f293e6cc8d7fe8e3d115f26d4 | Python | 8,376 | 237 | # -*- coding: utf-8 -*-
import numpy as np
from .. import autocorr
from ..state import State
__all__ = ["Backend"]
class Backend(object):
"""A simple default backend that stores the chain in memory"""
def __init__(self, dtype=None):
self.initialized = False
if dtype is None:
dt... |
81a9a6f75f45988cc7cf2543d0c3fb9a2099d931cba0993dd3fa6f0d99d608c5 | Python | 8,377 | 232 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
class TestDataFrameRound:
def test_round(self):
# GH#2665
# Test that rounding an empty DataFrame does nothing
df = pd.DataFrame()
tm.assert_frame_equal(df, df.round())
# Here's the test fr... |
a95f3d4ec572f3c4bf76e098c27ce6f21a6e57036514cd63b0db33021eab469f | Python | 8,380 | 177 | import argparse
import os
import ete3
import pandas as pd
from ete3 import NCBITaxa
def get_args():
"""
Get arguments from command line with argparse.
"""
parser = argparse.ArgumentParser(
prog='Convert_MEGAN-NCBI-c2c_to_kreport-mpa.py',
description="""Convert a NCBI c2c file obtained f... |
f406208098425ed0e92e5d390e83a98ea040d5152a5f73b5cd9a0a7598fc93e2 | Python | 8,381 | 234 | # coding: utf-8
import math
from .utils import approx_equal
from atropos.adapters import BACK
from atropos.align import (
locate, compare_prefixes, compare_suffixes, Aligner, InsertAligner
)
from atropos.util import RandomMatchProbability
class TestAligner():
def test(self):
reference = 'CTCCAGCTTAGA... |
411ae5fff83d675fb5959959ba67140c8750a4f73e23de5991d8618befff9852 | Python | 8,383 | 266 | # 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... |
204668e495e8ec1eb3cf38ffe96f99ec3ae027f688faa124bb3b7820d67bcd1d | Python | 8,384 | 225 | from datetime import datetime
import re
import zoneinfo
from dateutil.tz import gettz
import numpy as np
import pytest
from pandas._libs.tslibs import (
OutOfBoundsDatetime,
Timestamp,
conversion,
)
from pandas._libs.tslibs.dtypes import NpyDatetimeUnit
from pandas.compat import WASM
import pandas.util._t... |
6035f8819a1670b1add818c784927f737479e5eb3a95f0ea597d45c8290ec06f | Python | 8,388 | 189 | import os
import matplotlib.pyplot as plt
import numpy as np
import pymc as pm
import pytest
from pcntoolkit.math_functions.factorize import *
@pytest.mark.parametrize("mu, sigma", [(0, 1), (1, 2), (-1, 0.5)])
def test_approximate_normal(mu, sigma):
samples = np.random.normal(mu, sigma, 100000)
approximatio... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.