sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
eeba52450461dbe312fffcd717bac64b991a1330eed5ae8b775af966e95a3145 | Python | 3,756 | 100 | import ntpath
from sys import path as sys_path
sys_path.append('..')
sys_path.append('../base')
import os
from base import loggingUtils
import multiprocessing as mp
from multiprocessing import Pool
from glob import glob
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import imageio.v3 as iio
impo... |
a568e98d4b756938b45d107e0f13828ce54697d39fa8ce7cdfe989a808ab987e | Python | 3,757 | 115 | __all__ = ["GlycoPeptideMS2Predictor"]
import itertools
import os
from logging import Logger
from typing import Any, Iterable, List, Mapping, Optional, Union
import pandas as pd
from ....speclib.gpep.spec import GlycoPeptideMS2Spectrum
from ....util.progress import ProgressFactoryProto
from ...common.prediction impo... |
e11289da7c02fa42946f8659f96902c2276cddde2bfb5b0aef1eed7b4ea9b255 | Python | 3,757 | 108 | import queue
from viewContainer import viewContainer
from StimulationSystem.StimulationProcess.PrePareProcess import PrepareProcess
from StimulationSystem.StimulationProcess.StimulateProcess import StimulateProcess
from StimulationSystem.StimulationProcess.FinishProcess import FinishProcess
from StimulationSystem.... |
6f312e71f50e0755da9e64724295fab553cb792c05c44c12774f3ab991ab944a | Python | 3,758 | 86 | """Exercise independent caller storage through compiled public APIs."""
import tempfile
import pytest
from MACS3.Signal.CallPeakUnit import CallerFromAlignments
from MACS3.Signal.FixWidthTrack import FWTrack
from MACS3.Signal.PairedEndTrack import PETrackI, PETrackII
from MACS3.Utilities.Execution import CPUAvailabi... |
e025de7ce79f3b9e02f16a9c2b539f51bb814dd1921fca85534d57da313611b7 | Python | 3,758 | 94 | #! /usr/bin/env python
import csv
import argparse
from Common import loggingUtils
from Common.kernelFunctions import *
from Surfaces import surfaceMatching, surfaces
def runLongitudinalSurface(template, targetList, minL=3,atrophy=False, resultDir='.'):
if atrophy:
pass
else:
pass
wit... |
305a0e21d7771a0c08f0f3a72dd0ef590246cc3f07ce82ce728500f46a38d65c | Python | 3,759 | 104 | """Core for paccmann models."""
import tensorflow as tf
from ..hyperparams import LOSS_FN_FACTORY, OPTIMIZER_FACTORY
from ..metrics import pearson
def paccmann_model_fn(
features, labels, mode, params, model_specification_fn
):
"""
Wrapper for IC50 prediction.
Usage example:
Pass it as model_... |
b0e8e51544f08dcd659e719b0c4adfb6ed371dd7908a4564f35e4f026b9b536f | Python | 3,760 | 118 | import torch
import torchvision
from torch.utils.data import DataLoader
from torchvision import datasets
from torchvision import transforms,utils
from torch import nn, optim
import numpy as np
import torchvision.models as models
import skimage
from skimage import io,transform,util
from PIL impor... |
bc1d0fe968d1dcf7acd64007f77f9026c7bbe23e7229d2eb941a53422ddc7bc3 | Python | 3,760 | 104 | import torch
from torch import nn
from torch_geometric.utils import scatter
import math
from ..mlp import MLP
from ..utils import graph_softmax
# Typing
from torch import Tensor
from typing import List, Optional, Tuple
class NodeAttention(nn.Module):
def __init__(self, dim: int, num_heads: int, edge_dim: int) -... |
6602fd5c6bc2a2216945740184832ae79b88574559499a0f623319b2fdd82a94 | Python | 3,764 | 66 | import urllib.request
import shutil
import ssl
import gzip
def gunzip(inFile, outFile):
with gzip.open(inFile, 'rb') as f_in:
with open(outFile, 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
print('Testing download...')
url = 'https://archive.omnipathdb.org/README.txt'
urllib.request.url... |
8c63818c077832cb5c56bccd918b780a6fbfd5321d95e898ef5ef9bdb7922263 | Python | 3,767 | 115 | import os
from typing import List, Optional
import numpy as np
import torch
import logging
from .architectures import resnet34
from .....image import Stack
from ..... import CHECKPOINT_DIR, IQA2D_URL
def get_iqa2d_checkpoint() -> str:
model_dir = CHECKPOINT_DIR
model_name = "iqa2d.pt"
if not os.path.exist... |
aa3c79bde8ca220ddfda1af7675f55365564d65fb3b2ed8546067f313750f394 | Python | 3,767 | 121 | from typing import List, Union, Optional
import os
import torch
from ..transform import transform_points, RigidTransform
from ..image import Slice, Volume, load_volume, load_mask
from .models import INR
from ..utils import resolution2sigma, meshgrid, PathType
def override_sample_mask(
mask: Volume,
new_mask: ... |
16783ed972ea895cd5c7e56cd8b49603f38fe98a353195644c15292e19452588 | Python | 3,768 | 101 | """
Detection of the CPU allocation actually available to this process.
Used to bound the default worker count for parallel I/O, so that a default
:func:`~pandas.read_csv` does not oversubscribe a machine on which the process
has been given only a slice of the CPUs -- a CPU affinity mask, or a cgroup CPU
quota as set ... |
8d8685e2c61c5bee32af629e0827d006c7add695e8f4e53d62b5573c9f5f341d | Python | 3,769 | 88 | import numpy as np
from scipy.special import hyp1f1
def l12(x):
# Confluent hypergeometric function of the first kind, or Kummer's function
# Another way to define it would be:
# np.float64(np.exp(x / 2) * ((1-x) * np.float64(scipy.special.iv(0, -x / 2)) - x * np.float64(scipy.special.iv(1, -x / 2))))
... |
75cfe1914c6bb589545ea0bc957d2c8864f93132974284560f9f3d1dd8214c23 | Python | 3,772 | 110 | from indices.base import BaseComparisons
class RogotGoldberd(BaseComparisons):
"""Class to calculate the Rogot-Goldberd index.
n=2 formula:
a/(2 * a + b + c) + d/(2 * d + b + c)
Attributes
----------
fingerprints : np.ndarray
Numpy array with the fingerprints that will be compare... |
b969c0fe63ff13873ada2957faffb5dda0832817bca7d18314015421bcf24c56 | Python | 3,772 | 110 | from indices.base import BaseComparisons
class HawkinsDotson(BaseComparisons):
"""Class to calculate the Hawkins-Dotson index.
n=2 formula:
0.5 * (a/(a + b + c) + d/(d + b + c))
Attributes
----------
fingerprints : np.ndarray
Numpy array with the fingerprints that will be compare... |
94f7c5b7630d14c62cbab5e25ddf6840e49d60f6e49c011bd44d39e1a3c527d3 | Python | 3,774 | 105 | ''' dataset_report.py
Report on datasets in MongoDB
'''
import argparse
from operator import attrgetter
import sys
import jrc_common.jrc_common as JRC
#pylint: disable=broad-exception-caught,logging-fstring-interpolation,logging-not-lazy
# Globals
ARG = LOGGER = None
# Database
DB = {}
# -----------------------... |
7d311d2f11412c1a40ce7188c0546bd57c98f7e94a7601b959d2afd25fee97c3 | Python | 3,775 | 109 | #!/usr/bin/env python
import sys, os, argparse
from argparse import RawTextHelpFormatter
###################################################
### 0. script description and parsing arguments ###
###################################################
synopsis1 = "\
select representative gene models from a .gtfParsed.txt ... |
3e195be0df4a52abf154b30c679bf7dfe5d742ba928c1cc76c492a169bfccb8e | Python | 3,776 | 88 | import inspect
from collections.abc import Callable, Sequence
from dataclasses import dataclass
from typing import Literal
import pytest
import torch
from mrpro.operators import functionals
from mrpro.operators.Functional import ElementaryFunctional, ElementaryProximableFunctional
from mrpro.utils import RandomGenerat... |
a4581ee4c45f941c1d286b920f2f84046e5e402b03b92a37befae90b05f375b4 | Python | 3,776 | 82 | """
Script to prepare training csv from ISIC data.
"""
import pandas as pd
import os
data_2018 = pd.read_csv('../data/labels/ISIC2018_Task3_Training_GroundTruth.csv')
data_2018['diagnosis'] = 'unknown'
data_2018.loc[data_2018['MEL'] == 1.0, 'diagnosis'] = 4
data_2018.loc[data_2018['NV'] == 1.0, 'diagnosis'] = 5
data_2... |
fc0cd1c05e01ac125ee8ff53126733a4cc719f0909a4e250902bbb032af7946b | Python | 3,778 | 123 | from datetime import (
datetime,
timedelta,
)
import numpy as np
import pytest
from pandas.core.dtypes.cast import (
maybe_box_native,
maybe_unbox_numpy_scalar,
)
import pandas as pd
@pytest.mark.parametrize(
"obj,expected_dtype",
[
(b"\x00\x10", bytes),
(4, int),
(n... |
d73468db7ed4f64ccfed70249a898a035b0feee639f994a03101433f56d3ac0c | Python | 3,779 | 129 | import copy
import numpy as np
import pytest
from pandas._libs.missing import is_matching_na
from pandas.core.dtypes.common import is_float
import pandas as pd
@pytest.mark.parametrize(
"arr, idx",
[
([1, 2, 3, 4], [0, 2, 1, 3]),
([1, np.nan, 3, np.nan], [0, 2, 1, 3]),
(
... |
284f79d450dcc1b9582186c72d335ddff1102d00f2d26032d6f93fc23fe6e9fe | Python | 3,782 | 94 | ###############################################################################
# This script runs meta-analysis using NIMARE. It does it based on the #
# analysis method each paper employed (GLM or connectivity) #
# #
... |
708289cff28807648314d3b5066a6c7c9a80f257e8bad96d9e26cf1b6ca57232 | Python | 3,782 | 107 | import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from mat4py import loadmat
import scipy as sp
import scipy.io as sio
import glob
# import matdata2py as mtp
# import h5py
def make_data(SubjectName, DistrType):
if DistrType == 'All':
FilenamesList = sorted(glob.glob('data_raw/Sub_%s_*_00*.mat'... |
19aedbe521b21b9d7fecb16d7fc7859578002d8bebdd76693fea1de60bb193a5 | Python | 3,783 | 112 | import numpy as np
from values import *
from defs import *
def ENaC(cell,i,memb_id,hNaMP,area,jvol):
# hNaMP is the activity of ENaC from .dat file
facNaMP=(30.0/(30.0+cell.conc[0,0]))*(50.0/(50.0+cell.conc[0,1]))
ph = np.zeros(NC)
for j in [0,1]:
ph[j] = -np.log(abs(cell.conc[11][j])/1e3)/np.... |
be104a5f95ddc526d9f22c8a1fea85858042c34dee51a7fda1e6a2e98b15a994 | Python | 3,783 | 114 | import numpy as np
import os
import sys
import run_LFP
def make_fig_names(fname_base):
if not os.path.exists('Figures'):
os.makedirs('Figures')
return os.path.join('Figures', fname_base)
def simulate(fname_base, **kwargs):
morphology = kwargs.pop("morphology", 1)
simulate_what = kwargs.pop("... |
05ed73586330ea23ed8cc303c82595de55024ba474a4b7ad9cee1ef051330b8e | Python | 3,788 | 131 | """
list model for guisort
"""
from __future__ import print_function, division, absolute_import
import numpy as np
from PyQt5.QtCore import (QAbstractListModel, Qt, QModelIndex,
QSize, QPoint, QVariant)
from PyQt5.QtWidgets import QStyledItemDelegate, QStyle
from PyQt5.QtGui import QPen
from .. import option... |
efb6cfcb79235df5604d43059eca001bb86ddfd32780202b47e941c90c81b91d | Python | 3,789 | 96 | import torch
from torch import nn
from torch_geometric.utils import scatter
import math
from ..mlp import MLP
from ..utils import graph_softmax
# Typing
from torch import Tensor
from typing import List, Optional, Tuple
class EdgeProcessor(nn.Module):
def __init__(self, dim: int) -> None:
super().__init_... |
fb1dbc7e7fae2aa964922029935df2f16c701397f285afb988b93617e197f47f | Python | 3,790 | 81 | import pandas as pd
import numpy as np
import statsmodels.api as sm
import statsmodels.tools.tools as sm_tools
import os
def fit_LM(specificity_id, es_mu, df_magma):
### Fit linear model between es and MAGMA ZSTAT
### Get cell annotations
annotations = es_mu.columns[1:]
# inner join magma ZSTATs and ES_mu v... |
178acac77d63905dbdc883c8522f2bd6c1568379156201e34f3ca3b03e5c7589 | Python | 3,793 | 122 | """
Generator class for pg-gan.
Author: Sara Matheison, Zhanpeng Wang, Jiaping Wang, Rebecca Riley
Date: 9/27/22
"""
# python imports
import numpy as np
from numpy.random import default_rng
# our imports
import global_vars
import param_set
import simulation
import util
###############################################... |
9413884a8d844588a1685459e50254848433aea946fc7da5316863f5281b1e37 | Python | 3,794 | 106 | from ecgdigitize.common import Failure
import os
from numpy.core.fromnumeric import mean, trace
if 'PYTHONPATH' not in os.environ:
print("Error: Run `source env.sh` to be able to run `/scripts/*.py`")
exit(1)
from time import time
from typing import Optional
from pathlib import Path
import cv2
from cv2 impo... |
e4c70e6fb85d62dbe080af3b4df40e5362297aa7a8e7dfb1795a7fb37bff9f65 | Python | 3,794 | 177 | from typing import List, Tuple, Iterable
import numpy as np
import pandas as pd
RESIDUES = [
"ALA",
"ARG",
"ASN",
"ASP",
"CYS",
"GLN",
"GLU",
"GLY",
"HIS",
"ILE",
"LEU",
"LYS",
"MET",
"PHE",
"PRO",
"SER",
"THR",
"TRP",
"TYR",
"VAL",
]
P... |
5fbd0beb7dd6dff77f49af90b0fb2110e639367974eacf72d16bd97d7480e8d4 | Python | 3,797 | 138 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 10 16:02:58 2023
@author: jlugagne
"""
import os
import json
import sys
import ast
import time
import uuid
import numpy as np
# Make sure the proper package is used:
sys.path.insert(0,'./../')
import deepcellcontrol as dcc
# Training parameters... |
ae20ec20663d32ddf3d9d7f03670b7d47f0d8019d9f8e877ced5ba9f7c6817e8 | Python | 3,802 | 109 | """Summarize the values of a tensor to a string."""
from collections.abc import Sequence
from typing import Protocol, runtime_checkable
import torch
@runtime_checkable
class HasShortStr(Protocol):
"""Object implemtining shortstr."""
def __shortstr__(self) -> str:
"""Return a short string representa... |
5dc13e41a8959961f626731c37736ada65f39542bc5e4b39af7485e197bf9420 | Python | 3,803 | 102 | import datetime
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
pytestmark = pytest.mark.single_cpu
@pytest.mark.parametrize("unit", ["us", "ns"])
def test_store_datetime_fractional_secs(temp_hdfstore, unit):
dt = datetime.datetime(2012, 1, 2, 3, 4, 5, 123456)
dti = pd.Dat... |
39a7fa1f61a974cf6797559cbadb619581b24d178e930c5360804776787508c2 | Python | 3,805 | 111 | import pytest
import torch
from pyaging.models import DNAmFitAge, DNAmFitAgeGait, DNAmFitAgeGrip, LinearModel
def _linear(weight, bias):
model = LinearModel(len(weight)).to(torch.float64)
with torch.no_grad():
model.linear.weight.copy_(torch.tensor([weight], dtype=torch.float64))
model.linear... |
4f3abe7f65002e92dc6441db0eb5976da51358c6d8a054c787997402b5afcd37 | Python | 3,805 | 114 | # 3D-HSFormer parameter
import os
data_name = '20210824_GLX_MHW_C6_16_1'
name = data_name.split('_')
if len(name) == 6:
name_seg = name[1] + str('_') + name[2] + str('_') + name[3] + str('_') + name[4] + str('_') + name[5]
else:
print('Recheck the name of the data')
Raw_data_root = r'U:\VISoRData\MHW\MHW-SD-B2... |
29ab2a3621e46dba76128f10d96bcd5f931ba49ca67c6f752bd759783e6b57c6 | Python | 3,811 | 148 |
import os
import sys
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pytest
os.environ["PATH"] = (
os.path.dirname(sys.executable) + os.pathsep + os.environ.get("PATH", "")
)
@pytest.fixture(autouse=True, scope="session")
def configure_matplotlib():
"""Configure matplotlib for o... |
8a0565ffcef31f8b4fd1851fc4c33296e7d8d40eb9f4f70119f2efd9ae99dba8 | Python | 3,811 | 111 | import importlib.resources
from PyQt6 import uic, QtWidgets, QtCore
class MatrixElement(QtWidgets.QWidget):
_quick_view_instance = None
quickview_selected = QtCore.pyqtSignal()
element_changed = QtCore.pyqtSignal()
def __init__(self, *args, **kwargs):
super(MatrixElement, self).__init__(*arg... |
4018336cdaeac476c0a0d0edba454b72ebc48891babebf874252de13c7895597 | Python | 3,812 | 104 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Create BEM solution, source model and, forward model.
Vinding, M. C., Eriksson, A., Low, C. M. T., Waldthaler, J., Ferreira, D., Ingvar, M., Svenningsson, P., & Lundqvist, D. (2021). Different features of the cortical sensorimotor rhythms are uniquely linked to the se... |
81bddef6bbfa0f2c25c94827db9864826727fcc30c23af9ce425d308aee59108 | Python | 3,812 | 73 | from __future__ import print_function
#Script to generate a table of indexes and sample names
#For each sample name, input the nextera i7 index numbers,
#pcr i7 index numbers, pcr i5 index numbers and nextera i5
#index numbers in the format lig_i7:pcr_i7:pcr_i5:lig_i5.
#To assign multiple indexes, separate numbers bet... |
3e8e63870f07352806b6c2e78f7665fc37e46fa603de71cefdd1636ccf6009b1 | Python | 3,813 | 120 | import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
def load_dataset(dataset_dir, image_size, batch_size):
seed = 7891 #1337 #2162 #6543 #9513
train_ds = tf.keras.utils.image_dataset_from_directory(
dataset_dir+"/training",
validation_split=0.1112,
subset="train... |
d2ee2249b77de568f09dc007b26c4fd77f98cf13ade30c76b9b896523bf071d4 | Python | 3,815 | 83 | import torch
class TrainGlobalConfigShunt_with_all:
num_workers = 8
n_epochs = 16
lr = 0.002
folder = 'weights/Shunt_with_all/'
verbose = True
verbose_step = 1
step_scheduler = False
validation_scheduler = True
target = 'Shunt'
features = ['BGA_Ca', 'BGA_FiO... |
3e354f5094eaab92452ac8949ff9855708a148ca7de08233065e34571a40b61c | Python | 3,819 | 114 | # 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... |
e9d179a8f43d231a3f93b685da7f8721e8b3fcf475340eacb3efab1454c836f1 | Python | 3,821 | 129 | # 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... |
7ff6f5c6d72cf659f72b220fce7c6b93a73baa5532879d7d7d37357334b04c75 | Python | 3,824 | 161 | """
Configuration handling
.. todo::
switch ruamel.yaml to round trip loading
to preserver order and comments?
Authors:
Thomas A. Hopf
"""
import ruamel.yaml as yaml
class MissingParameterError(Exception):
"""
Exception for missing parameters
"""
class InvalidParameterError(Exception):
... |
5c110e43ea626ca1fa2eb5db4ae9b778e2d9ecb9892b8bb462f09eb25a3ccb23 | Python | 3,825 | 82 | """GPU-presence checks: selecting a ``pl.Trainer`` accelerator, and guarding DALI-only
semi-supervised training with a clear error instead of a confusing low-level one.
"""
import logging
import torch
from omegaconf import ListConfig
logger = logging.getLogger(__name__)
# to ignore imports for sphinx-autoapidoc
__a... |
cd22dd2d42f13d6008b203cb054f1c9c0cc184ec512c12c5b29294f91d64c6e5 | Python | 3,829 | 159 | from __future__ import annotations
from contextlib import (
AbstractContextManager,
contextmanager,
)
import os
import sys
from typing import (
IO,
TYPE_CHECKING,
Any,
)
from pandas.compat import CHAINED_WARNING_DISABLED
from pandas.errors import ChainedAssignmentError
from pandas.io.common impor... |
fcaf6fece09c57eaa3806a21c75af19bbbcdd9f8f6004e844bda1049cf63cdea | Python | 3,831 | 139 | import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import matplotlib.transforms as transforms
from pathlib import Path
import sys
sys.path.append('../')
from plotting_functions import *
#create figure
fig, ax = plt.subplots()
#set font
plt.rcParams['font.family'] = 'Gargi'
#point to fi... |
701de57a0ca09297f1e0f7a5a1fd0cbe945c455932d96a9d2a0ad0cd1b59d51f | Python | 3,835 | 115 | # 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... |
4380536c5f1d763475cf756a3efed210752c20fb942631bc7ab552ee1ec094cf | Python | 3,837 | 139 | """
This script demonstrates
* the kx-ky sampling pattern in diffusion MRI,
* the ky-diff sampling pattern in diffusion MRI.
Author: Zhengguo Tan <zhengguo.tan@gmail.com>
"""
# %%
import numpy as np
import matplotlib.pyplot as plt
import argparse
# %%
parser = argparse.ArgumentParser(description='plot sampling ... |
9c57b4de2d1834b9b32b16d96eaf69db0a14f7968a07ac345b4d64bff5d7e4ba | Python | 3,837 | 132 | # emacs: -*- mode: python-mode; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
# ex: set sts=4 ts=4 sw=4 et:
"""
.. _metas_ma_maps:
================================
Generate modeled activation maps
================================
For coordinate-based data, individual studies' statistical maps are mimi... |
cebf7222f52a31b11b59f6e376ef376d56cf277cd11fcb76155b03cc526ae95a | Python | 3,839 | 87 | import numpy as np
from .microstructure_models import MicroStructModel
from .nexi import Nexi
from .functions.nexi_functions import nexi_signal_from_vector, nexi_jacobian_concatenated_from_vector
from .functions.rician_mean import rice_mean, rice_mean_and_jacobian, broad5
class NexiRiceMean(MicroStructModel):
"""... |
e9a1ad949da60dce0f19dfa4a9da4557d5369f4cb98200a95dacfcea71d2247a | Python | 3,840 | 96 | # 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... |
8e22786a37f137b4aeb0ae9178f85154d6a28ddcc0dec5174d96ae0beaf1a16d | Python | 3,841 | 133 | import numpy as np
import pytest
from pandas.compat import CHAINED_WARNING_DISABLED
from pandas.errors import (
ChainedAssignmentError,
Pandas4Warning,
)
import pandas as pd
import pandas._testing as tm
@pytest.mark.parametrize(
"indexer", [0, [0, 1], slice(0, 2), np.array([True, False, True])]
)
def te... |
088e27a9a67eceb286ddc1ba76bbaa5b088f99bd8cfe83cd8fe55382e20fec85 | Python | 3,844 | 96 | import numpy as np
from cc3d import connected_components
def test_overlap(pointlist1,pointlist2):
'''
test_result = test_overlap(pointlist1,pointlist2)
Checks whether any point in pointlist1 is also in pointlist2
'''
# First check trivial cases with fast methods
pa1 = np.asarray(pointlist... |
ed8b525c4ede555f1d48da13084c644da39e14070c84464d31473e2be195d5c0 | Python | 3,844 | 110 | """
Improved Semantic Representations From Tree-Structured Long Short-Term Memory Networks
https://arxiv.org/abs/1503.00075
Modifications
- Add num_layers
"""
__all__ = ["TreeLSTM"]
from typing import cast
import dgl
import torch as th
import torch.nn as nn
# class TreeLSTMCell(nn.Module):
# def __init__(self,... |
01861198502901aac87d7fedaedfafd77f3aa638bf677b61a4d6b4711bc440bc | Python | 3,847 | 101 | import numpy as np
from scipy import ndimage
import torch
threshold_low = 7.0 # this corresponds to roughly 80 m for the unscaled terrain
eps = 1e-1
def compute_prediction_error_sample(label, prediction, terrain, device, turbulence):
'''
Compute the prediction errors for one single sample.
Assumes that ... |
8519a57f508d857d9753a0dba0f67dc9a973fdaafe5ea1b67b3a36db8d9b800b | Python | 3,847 | 80 | import os
import concurrent.futures
import json
import time
# json里存的是列表,列表里存放的每个元素是字典,需要按照json的文件名顺序输出对应的权限类型
# 一次匹配一个,普通权限权限类型就是0
# 单线程的已经写完了,开始写多进程
# 单进程花费时间:consume= 0.0030291080474853516
# 多线程花费时间:consume= 0.7890021800994873
def match(dict):
apkname = list(dict.keys())[0]
permissiontype = []... |
aef590f040969b1c7fcc723cf1d61b014297b079b669c855d3c65332b62ca6e2 | Python | 3,848 | 103 | import torch
import torch.nn as nn
import torch.utils.data
from torch import autograd
from rsl_rl.utils import utils
DISC_LOGIT_INIT_SCALE = 1.0
class AMPDiscriminator(nn.Module):
def __init__( # 86, 2.0, [1024, 512], 'cuda:0', 0.3
self, input_dim, amp_reward_coef, hidden_layer_sizes, device, task_r... |
81aa3292510aa179d88f348cd104eb8140491a09de2867eeb0a547fa3f54fb91 | Python | 3,852 | 115 | """This script produces a figure summarising periodogram parameter options."""
import os
import matplotlib.pyplot as plt
import mne
import numpy as np
import osl
import sails
import lemon_plotting
from glm_config import cfg
from lemon_support import get_eeg_data
#%% -------------------------------------------------... |
9de92e6d7fca0380addc0977d6a49373efe92aea08c4559aadfaead5417fff03 | Python | 3,852 | 140 | # -*- coding: utf-8 -*-
# JN 2016-01-12
# JN 2016-10-18 add support to read jobs from file
"""
Downsample ncs files and save as h5
"""
from __future__ import print_function, division, absolute_import
import os
from argparse import ArgumentParser, FileType
from multiprocessing import Pool
from time import time
import ... |
a2515419c77dfd214f886b6518f5e350099429f757a07fe7ac31f30edaa6312a | Python | 3,852 | 127 | from __future__ import absolute_import
import torch
import torch.nn
import torch.nn.init
import torch.optim
import torch.nn.functional as F
from default_utils import set_seed as set_seed_defaultUtils
def set_parallelism_threads(): # for compatibility
pass
def set_seed(seed):
""" Set the random number seed t... |
47708d57ad34274cbbf487d4b2456f8b971292b366e7d5f9bb4933ca08bd95c8 | Python | 3,853 | 154 | #!/usr/bin/env python3
"""
Support module to read alignments in maf format.
"""
from sys import stderr
packageVersion = "0.1.0" # for comparing versions
# maf_alignments--
# yields the next maf alignment from a file
#
# discardWeeds means that any component 'off in the weeds' is discarded. These
# are component... |
14caf12ffc41bb94a8374f4e6fe7c7b7b2dbb6160599fb51863a5ae58ec652af | Python | 3,854 | 149 | import matplotlib.pyplot as plt
import matplotlib
from matplotlib.colors import LinearSegmentedColormap
import numpy as np
import pandas as pd
import sys
import seaborn as sns; sns.set()
import statistics as stat
import matplotlib.font_manager as mfm
mfm.findSystemFonts(fontpaths=None, fontext='ttf')
sns.set(font_scal... |
e438eba1425d2e114281520ff41e1eeecf580c8af6d2b315619b94d855989cf5 | Python | 3,854 | 96 | import torch
import torch.distributions as distr
import torch.nn.functional as F
class CategoricalMaskedNaive(torch.distributions.Categorical):
def __init__(self, probs=None, logits=None, validate_args=None, masks=None):
self.masks = masks
if self.masks is None:
super(CategoricalMasked,... |
86f4ba441c700369b18e63cbd76d86bfa29228deebe2260e6c1c8f1358c9bf87 | Python | 3,856 | 107 | import torch
import numpy as np
# Typing
from torch import Tensor
from typing import Tuple, List, Optional
####################### Dataset #######################
from torch_geometric.data import Data, Dataset
from sklearn.preprocessing import OneHotEncoder
from scipy.spatial.transform import Rotation
import h5py
c... |
1ceb355a44192d04887556f9f220a5500732409a2d0d4d3cf2e070580b46c1c5 | Python | 3,858 | 123 | """Session 46 — phase 6: delete ``pycaret/internal/pycaret_experiment/``.
The legacy directory (10K LoC) and the five ``oop.py`` thin wrappers
(12K LoC across classification / regression / clustering / anomaly /
time_series/forecasting) were deleted. The default 4.0 workflow runs
without ever importing legacy code.
P... |
3148fbf9454ff40510b8baf59336dac8e1ed350cde103219fddd3183c28ea8fd | Python | 3,860 | 161 | import numpy as np
import pytest
import pandas as pd
from pandas.core.groupby.base import (
reduction_kernels,
transformation_kernels,
)
@pytest.fixture
def df():
return pd.DataFrame(
{
"A": ["foo", "bar", "foo", "bar", "foo", "bar", "foo", "foo"],
"B": ["one", "one", "two... |
e69ea80681b61ec3b5eee177527c594803640c36667a20506c3c08371a18d66e | Python | 3,861 | 107 | """Referemce plotting image tests"""
from unittest import mock
import pathlib
import sys
from PyQt6 import QtCore
from PyQt6.QtWidgets import QApplication
from shapeout2.gui import export
from shapeout2.gui.main import ShapeOut2
here = pathlib.Path(__file__).parent
# instantiate Shape-Out
app = QApplication(sys.arg... |
13c7e0670cf5375d882bad2e3962a0b298a703831eafa4c290404cb35dc06abe | Python | 3,862 | 103 | """
.. _datasets_neurovault:
=========================================
Use NeuroVault statistical maps in NiMARE
=========================================
Download statistical maps from NeuroVault, then use them in a meta-analysis,
with NiMARE.
"""
import matplotlib.pyplot as plt
from nilearn.plotting import plot_st... |
bf226e88e662e3667be8dd4ef651a129c38cea193960c22f49bfd2fb03d7f08c | Python | 3,862 | 118 | """Tests for `multimodal_ad.data.manifest`."""
from pathlib import Path
import polars as pl
import pytest
from multimodal_ad.data.manifest import (
REQUIRED_COLUMNS,
ManifestValidationError,
Modality,
ScanManifest,
ScanRecord,
)
def _valid_row(tmp_file: Path, **overrides: object) -> dict[str, o... |
0f9c4b5b1e8ce4e5bb089d6a10132a9604907cd24f6b957de9c2b9562e58237e | Python | 3,865 | 170 | # 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... |
8130a9036a291a4db580949e0c54f8325c4a639504c52d456ec20238586631c0 | Python | 3,867 | 125 | '''
Created on Mar 19, 2012
@author: robert
'''
import numpy as np
#import matplotlib.pyplot as plt
import neuron
from . import cell_parser
from . import reader
from . import synapse_mapper as smap
class SimControl(object):
'''
Objects of this class control a current clamp simulation. Example of use:
>... |
d7e0cbe4a459a37a6c038f6d976484fabcc01cf617b3ff3e78448be70007e2e7 | Python | 3,867 | 113 | from __future__ import annotations
from collections import abc
from typing import TYPE_CHECKING
from pandas.core.interchange.column import PandasColumn
from pandas.core.interchange.dataframe_protocol import DataFrame as DataFrameXchg
from pandas.core.interchange.utils import maybe_rechunk
if TYPE_CHECKING:
from ... |
f87940bd30211be3c329ddb6ce21bd487a2a307bac74b596e916b74dd231cd83 | Python | 3,867 | 96 | #!/usr/bin/env python3
import sys
import csv
import os
# Helper to strip quotes from a string
def strip_quotes(s):
if s is None:
return ''
return s.strip('"').strip("'")
def main():
if len(sys.argv) < 3:
print("Usage: lang-rt.py <input.tsv> <pfx>", file=sys.stderr)
sys.exit(1)
... |
46fa2f793d4b03dced571ddc4c752be774c7b6a0cd110c8c990786b20b9e0382 | Python | 3,868 | 144 | """
Tests for the `deprecate_nonkeyword_arguments` decorator
"""
import inspect
from pandas.errors import _CurrentDeprecationWarning
from pandas.util._decorators import deprecate_nonkeyword_arguments
import pandas._testing as tm
WARNING_CATEGORY = _CurrentDeprecationWarning
@deprecate_nonkeyword_arguments(
WA... |
a625152b1b9376cc38bfeed0334ef057ea9df69f3b76a61b8a5f43d6af478e37 | Python | 3,870 | 119 | import os
from typing import Any, Callable, Dict, List, Optional, Union
import torch
from ....util.collections.dict import chain_item_typed
from ...common.training import TrainerBase
from ...util.weightloss import (
AutomaticWeightedLoss,
DynamicWeightAverageLoss,
ScaledDetachedLoss,
)
from .data import G... |
8358277d93585baee3a10ecbb4fae4e610df9d88ceb4342a4746a9635c079095 | Python | 3,872 | 116 | __all__ = ["GlycoPeptideBranchMS2Predictor"]
import itertools
import os
from logging import Logger
from typing import Any, Iterable, List, Mapping, Optional, Union
import pandas as pd
from ....speclib.gpep.spec import GlycoPeptideMS2Spectrum
from ....util.progress import ProgressFactoryProto
from ...common.predictio... |
dd2e39bb51b86a36f6ce4b873a1071ec2479e24aee7c4ec4b84f243d6b62d166 | Python | 3,872 | 110 | """Tensorflow learning utilities."""
import tensorflow as tf
from .datasets import (
generate_dataset, feature_name_to_placeholder, validate_feature_names,
record_parser
)
def train_input_fn(params):
"""
Train function given params for paccmann.
Args:
- params: train parameters (<dict>).
... |
3bc5e98007df57b97892989e3a0f7ff79764956a8cff4a43afb9a69e123c58c1 | Python | 3,873 | 182 | font_size = 40
line_size = 5
bundle_names_formal = {
"L_OR": "Left OR",
"R_OR": "Right OR",
"fov_L": "Left Fov. OR",
"fov_R": "Right Fov. OR",
"mac_L": "Left Mac. OR",
"mac_R": "Right Mac. OR",
"periph_L": "Left Per. OR",
"periph_R": "Right Per. OR"
}
directions_formal = {
"fov": "... |
eef1dc36111e90c52a74a24faa6313e05ac137de7c372d60bbf908c951affe0c | Python | 3,875 | 80 | import torch
import torch.nn as nn
class ScoreDynamicsDiffuser:
def __init__(self, sigma_scale=1.0, schedule='linear', t_min=1e-3):
self.schedule = schedule
self.t_min = t_min
self.sigma_scale = sigma_scale
if schedule == 'linear':
beta_0, beta_1 = 0.1, 20
... |
cdf692ee17de50943764c9569ddf2edb8f23e8554fc5968fe7f5322bf80888cc | Python | 3,879 | 152 | # 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... |
e7cb3a0823917ebb98b872f874e6d9376dcc9865b1588f8d43bcc25333cbdb43 | Python | 3,879 | 129 | import sys
from treeshrink._vendor.dendropy import Tree
def list_leaves_below(node):
# list all leaves below a node
stack = [node]
L = []
while stack:
u = stack.pop()
if u.is_leaf():
L.append(u.taxon.label)
else:
stack += u.child_nodes()
return L... |
7d318835b59c6c94ce566359edc20f8d3df48bbae0d3d017aa24de987e7678d2 | Python | 3,880 | 122 | """
Title: utils.py
Author: Matus Tomko
Mail: matus.tomko __at__ fmph.uniba.sk
"""
class RecordingVector:
"""
A class used to represent a vector for recording voltage or current
...
Attributes
----------
section : str
the section name
segment_x : float
the recording site ... |
82520211a10631aec23f6db119577b07b3d3a0bf626c68c9543f3299125bf5d6 | Python | 3,882 | 108 | import queue
from threading import Thread
import threading
import socket
from CommonSystem.MessageReceiver.EventManager import EventManager, Event
from CommonSystem.MessageReceiver.message_fcn import operate_fcn,receive_fcn
class ExchangeMessageManagement:
def __init__(self,role,exchange_message_operator,c... |
091ac18d7360321e433f90c536c703dcbf03704ba9d899a7dd31364cc40f8dd4 | Python | 3,883 | 97 | #!/usr/bin/env python
__author__ = 'etseng@pacb.com'
import os, sys, re
from bx.intervals.cluster import ClusterTree
import cupcake.io.GFF as GFF
from Bio import SeqIO
"""
Given a GFF file and selected loci (ex: PB.45),
create a fake genome that is the concatenation of all seen exons.
"""
extra_bp_around_junctions =... |
bb7a45c5d060f0ec465a952333b23d6fb9ddf5da886436446695b6df0bda2aee | Python | 3,883 | 111 | """Filesystem boundary for merge-proposition input and review decisions."""
from __future__ import annotations
import hashlib
import json
import os
import tempfile
from collections.abc import Mapping
from dataclasses import dataclass
from pathlib import Path
CURATION_FILENAME = 'curation.json'
REVIEW_FILENAME = 'cur... |
2065454b0fdabd2531d6650b8e8cd3dfb13d27e3570428fd6ab487273fd25871 | Python | 3,885 | 112 | """Export command for the lightning-pose CLI."""
from __future__ import annotations
import argparse
import logging
import textwrap
from typing import Any, get_args
from lightning_pose.cli import types
from lightning_pose.utils.inference_types import _ExportRuntime, _OnnxPrecision
logger = logging.getLogger(__name__... |
310dc565262fc780a74d627413936057bd4f3d9385dd94ac521d938fc493a4aa | Python | 3,887 | 124 | """Test correlogram view."""
# ------------------------------------------------------------------------------
# Imports
# ------------------------------------------------------------------------------
import numpy as np
from phylib.io.mock import artificial_correlograms
from phylib.utils import connect, unconnect
fr... |
3cb17a487666ff917146987ee90bc1209a6aa63594ceae6b8ad31fb40366c388 | Python | 3,888 | 114 | # Copyright (C) 2019-2024 PyCaret
# Module: containers.metrics.base_metric
# Author: Antoni Baum (Yard1) <antoni.baum@protonmail.com>
# Contributors (https://github.com/pycaret/pycaret/graphs/contributors)
# License: MIT
from typing import Any, Dict, Optional, Union
from sklearn.metrics import make_scorer # type: ... |
6302084740166184f29413a9e239de2fc39abc46df93d8c72f88c67bdea7164e | Python | 3,888 | 67 | """
Script for calling scanometrics from the command line
"""
import argparse
from scanometrics.core import ScanOMetrics_project
def main():
parser = argparse.ArgumentParser(description='Run scanometrics core features.')
parser.add_argument('bidsDatabase', type=str, help='Path to bids database.')
parser.a... |
9145294b473b3feb9d7a4fff65eca3ba1c28f4e2c72325a1563c3cbb3ac5bbb2 | Python | 3,894 | 98 | # 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... |
24be5e6f5591378db9910bcc0669edd9d5dbc7413e5f670407caef2aaeccb292 | Python | 3,895 | 115 | # 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... |
5a3343a87f0ea9415b86cfc37c40ee797c6054656b188f37475a9034784c88ff | Python | 3,895 | 110 | import queue
from threading import Thread
import threading
import uuid
import socket
from CommonSystem.MessageReceiver.EventManager import EventManager, Event
from CommonSystem.MessageReceiver.message_fcn import operate_fcn,receive_fcn
class ExchangeMessageManagement:
def __init__(self,role,exchange_messa... |
c57f0e576923fe9093b9abc2dc899505b479cee24db91b634cdca1e9aea05ed0 | Python | 3,897 | 121 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
def test_numeric_compat(idx):
with pytest.raises(TypeError, match="cannot perform __mul__"):
idx * 1
with pytest.raises(TypeError, match="cannot perform __rmul__"):
1 * idx
div_err = "cannot perform __true... |
db73d21881d179e7b20a966431fddb2f27d7d0927829c43bea8f3ea5a320cf33 | Python | 3,903 | 116 | # 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... |
66367128436248e7cb7fdacdb88a379e849ad8d74d6a252076177e808333fe62 | Python | 3,904 | 114 | # 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... |
1a60c52811646bb3de051bb2a0a4a4a7313e2a91cc493461e72e43a3dd81535b | Python | 3,905 | 107 | ''' crosscheck_library.py
This program will crosscheck samples in neuronMetadata and publishedURL
'''
import argparse
from operator import attrgetter
import sys
import jrc_common.jrc_common as JRC
import neuronbridge_common.neuronbridge_common as NB
#pylint: disable=logging-fstring-interpolation
# Database
DATAB... |
69731b39dcd35db5c843d72ab2a641e27139b7cf1357b24409948e0c658076a3 | Python | 3,905 | 138 | import numpy as np
from scipy.stats import pearsonr
from shapley import calc_naive_shapley_values
def shapley_values_for_additive_components(y, X, corr_fun=None):
"""
Compute the Shapley values of additive components of x for the value function corr(y,x).
Parameters:
-----------
y : array-like, s... |
821c1e2c3c1c4bda4e13c5d6d6cbb1fa04f1debc371f2326baae89046f528184 | Python | 3,905 | 83 | """Verify native build inputs and third-party notices in release artifacts.
Usage: python scripts/check_native_distribution.py dist/*.tar.gz dist/*.whl
Run against the same source revision that produced the artifacts.
"""
import argparse
from pathlib import Path
import tarfile
import zipfile
ROOT = Path(__file__).re... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.