sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
83bd46182236332fe3d019e8a70be7953ccddbc10236328bb37f89fecb6b2a55 | Python | 14,799 | 442 | ###########################################################################################
# Utilities
# Authors: Ilyes Batatia, Gregor Simm and David Kovacs
# This program is distributed under the MIT License (see MIT.md)
###########################################################################################
imp... |
8525887a29ec2f6435b5d137e28dca74b282f035546096317864cbbf65d5ec0a | Python | 14,838 | 446 | import multiprocessing as mp
import os
import h5py
import numpy as np
from .. import config, log
# torch is imported inside the three bodies that use it. Nothing here subclasses
# a torch type, so deferring it keeps `import nearl.io` from pulling ~580 ms of
# torch into every featurization run.
__all__ = [
"Dat... |
ebb478a03cea3487eab07e1481d378536d6b81caa01ab53daac9a02cb0e5d913 | Python | 14,840 | 278 | # coding=utf-8
# Copyright 2022 IDEA-CCNL The HuggingFace Inc. team. All rights reserved.
#
# 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
#
... |
50b4a1623baf10aed8c74fcf53302cbf6fbf7a63e0aafe0d37ca55fb9c5f0129 | Python | 14,841 | 405 | from __future__ import annotations
import os
import re
from dataclasses import dataclass
from enum import Enum
from pathlib import Path
from typing import Any, Dict, Optional
import pandas as pd
def define_new_path_column(
df: pd.DataFrame, output_dir: str, tag: str, col: str = "img", ext: str = ".nii.gz"
) -> ... |
7cb4f30391ebdc8abf3b673a4884afc80ed4e0b02970da4a20c3362fde0fde25 | Python | 14,841 | 421 | import json
import logging
import sys
from collections import namedtuple
from datetime import datetime
from io import StringIO
import six
from prov.constants import PROV_QUALIFIEDNAME, PROV_ATTRIBUTES_ID_MAP, PROV_ATTRIBUTES, PROV_MEMBERSHIP, \
PROV_ATTR_ENTITY, PROV_ATTRIBUTE_QNAMES, PROV_ATTR_COLLECTION, XSD_ANY... |
c6cdc72029a145d6e4d7bff40c8c3bc6d2c62f212853aa95b889d16562a4fcca | Python | 14,841 | 432 | import torch
import torch.nn as nn
import torch.utils.checkpoint as checkpoint
from nnunet_mednext.network_architecture.mednextv1.blocks import *
class MedNeXt(nn.Module):
def __init__(self,
in_channels: int,
n_channels: int,
n_classes: int,
exp_r: int = 4, ... |
cc1f19c8eb16f57444dd06399b2261ae61c8361cb8d5e1d89d0aa544022f1cdc | Python | 14,841 | 220 | #!/usr/bin/python
"""
This file to run ABC-DLS for parameter estimation of a given model for specifically Sequential Monte Carlo Approach
"""
import argparse
import os
from Classes import ABC
from Classes import Misc
from _version import __version__
# input argument is done
parser = argparse.ArgumentParser(descripti... |
27f954c16ec1a84ac7df7d551ae19ffa1886f338c6700f4bf9363eb5be7afd19 | Python | 14,867 | 364 | # Copyright (c) OpenMMLab. All rights reserved.
import logging
from typing import List, Optional
import torch.nn as nn
import torch.nn.functional as F
from mmengine.logging import print_log
from torch import Tensor
from mmseg.registry import MODELS
from mmseg.utils import (ConfigType, OptConfigType, OptMultiConfig,
... |
727bc95c1448d3ccec3d59b6b7dd750780ee9bc57e194adcfdbb11b6138f8885 | Python | 14,891 | 470 | import numpy as np
import pathlib as pl
from sklearn.neural_network import (
MLPClassifier,
MLPRegressor
)
from sklearn.multioutput import MultiOutputRegressor
from sklearn.model_selection import GridSearchCV
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
from sklearn.preprocessing import ... |
825f4c50488e0fe275d61d1edae45ec54cfb50fbaf4572eb911b3036ce748dc2 | Python | 14,892 | 386 | import logging
import numpy as np
from .io_utils import is_continuous_label
from .realignment import concatenate_and_realign_data, realign_ttl_timestamps
logger = logging.getLogger(__name__)
def retained_chunk_indices(timestamps: np.ndarray, coords: np.ndarray) -> list[np.ndarray]:
"""
Index the samples th... |
f4bbeadb6da53a001b85a43c6642ddfa13d4a1366e79eaffad8714fb93b43604 | Python | 14,893 | 368 | import numpy as np
import pandas as pd
class Clinical_outcome:
"""
Predicts modified Rankin Scale (mRS) distributions for ischaemic stroke
patients depending on time to treatment with intravenous thrombolysis (IVT)
or mechanical thrombectomy (MT). Results are broken down for large vessel
occulusion... |
fa719c5c5d4e4954dff12ed9008740506526fa6e0d54123b0e0c8b3458dff804 | Python | 14,907 | 453 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 18 11:05:54 2022
@author: george
"""
%matplotlib qt
%gui qt
import numpy as np
import os, glob
import json, codecs
from distutils.version import StrictVersion
from qtpy.QtCore import QUrl, QRect, QPointF, Qt
from qtpy.QtGui import QDesktopServic... |
7fb57784dcf9cfffd9d692e32c6981c412637044ff25291c6563c4f343b087cb | Python | 14,908 | 340 | """Discover how a Babel source contributes to the build outputs.
Given a source name like "EMAPA", walks every
``<intermediate_root>/<pipeline>/ids/<name>`` and
``<intermediate_root>/<pipeline>/concords/<name>`` and assembles a structured
description that the source-impact report tool can render.
A Babel source can v... |
65a54efb0f089e9350141779a832cf2cbce101209f6c31e7318514187fb84c81 | Python | 14,915 | 351 | """ Vision Transformer (ViT) in PyTorch
A PyTorch implement of Vision Transformers as described in
'An Image Is Worth 16 x 16 Words: Transformers for Image Recognition at Scale' - https://arxiv.org/abs/2010.11929
The official jax code is released and available at https://github.com/google-research/vision_transformer
St... |
4ba3f11f383f2e4d328d0c460911df40e342f85c769308487f092a3614abed97 | Python | 14,922 | 484 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader
import numpy as np
class MyDataset(Dataset):
def __init__(self, x, y):
self.x = x
self.y = y
self.len = self.x.size(0)
def __getitem__(self, index):
return self... |
683b2795b175af1c79240c790250c6a2eba83250af69f26e4fce4a3277cf36ef | Python | 14,939 | 367 | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from models.diffusion import (
categorical_kl,
extract,
index_to_log_onehot,
log_1_min_a,
log_add_exp,
log_categorical,
log_sample_categorical,
to_torch_const,
)
class ContigousTransition(nn.Module):... |
af5f5fb933ee1259437ba322fa949ecb2680bd3f3a57bd83eb7356f8147eb7a5 | Python | 14,952 | 474 | import hashlib
import re
import os
import shutil
import tarfile
from pathlib import Path
from subprocess import DEVNULL, Popen
import pandas as pd
import yaml
from rano_monitor.constants import (
BRAINMASK_BAK,
DEFAULT_SEGMENTATION,
BRAINMASK,
MANUAL_REVIEW_STAGE,
DONE_STAGE,
REVIEW_FILENAME,
... |
2089897cc35071e929b891c843cddf9fecfd37bf4fb957a3fb1356c7c705e071 | Python | 14,969 | 297 | import mne
from scipy.signal import detrend
import sys, os
import numpy as np
import matplotlib.pyplot as plt
import copy # deep copy of dicts
import pickle
# go to base directory and import globals
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
os.chdir(base_dir)
sys.path.append(base_dir)
alt_... |
4e449ec671ff436c72d5701f2abdb2c68db9e27837911cd2b49aeb7234ec84a4 | Python | 14,981 | 307 | import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from matplotlib.lines import Line2D
from glob import glob
import scienceplots
import matplotlib.gridspec as gridspec
import scipy.stats as st
from matplotlib.colors import LinearSegmentedColormap
import matplotlib.colors as col... |
1bdb83f7d8f2d6c8d99c75ac40e678ac55a870b0e3456d0594cebf4e9050f2cb | Python | 14,990 | 418 | """
Mixin Classes for GNODEVAE
This module provides mixin classes that add specific functionality to the
main agent and environment classes. Mixins follow the composition pattern
to separate concerns and promote code reuse.
Key Components:
- scviMixin: Single-cell variational inference utilities
- adjMixin: Adjacency... |
6dd049e6b11dbd62491c8e728ae257f2f54aa2621bfb79e7e0ec257e6cc38064 | Python | 14,992 | 376 | # -*- coding: utf-8 -*-
from ast import literal_eval
import json
from typing import List
import yaml
from guardian.shortcuts import assign_perm
from django.http import HttpResponse
from django.test.client import Client
from django.test import TestCase
from catmaid.control import importer
from catmaid.control.common... |
6c4cb8f677ce116db009da31509f2c9f74b37d34831b098238df580ae3088ac5 | Python | 14,993 | 483 | """Stimuli classes"""
"""
Copyright (c) 2016-2020, EPFL/Blue Brain Project
This file is part of BluePyOpt <https://github.com/BlueBrain/BluePyOpt>
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License version 3.0 as published
by the Free ... |
02b58d31b2bc89b2316f9c85e7f4c7d68613fc5762d7eafc26eec015dd4e19cf | Python | 14,999 | 416 | import torch
import itertools
import json
import hashlib
import os
from matplotlib.ticker import FormatStrFormatter, StrMethodFormatter
import umap
from matplotlib import pyplot as plt
import torch.nn as nn
import torch.optim as optim
import torch_geometric
import torch_scatter
import torch.multiprocessing as mp
from ... |
3879d07b5530e4367df5ac21d195896cbb33794c3a3b8cfa60bb2e453733f0b5 | Python | 15,001 | 416 | # Author: Hauxu Yu
# A module to annotate metabolites based on their MS2 spectra
# imports
import os
import pickle
import numpy as np
import pandas as pd
import json
import re
from tqdm import tqdm
from ms_entropy import read_one_spectrum, FlashEntropySearch
from .utils_functions import extract_signals_from_string, ... |
95e52c43a97c5807b8f02dd688ff1c5c5c5febf73a28e2a787f38e6a4b711ca4 | Python | 15,002 | 358 | import os
import sys
import anndata
import numpy as np
import pandas as pd
import scanpy as sc
import cv2
from skimage.feature import graycomatrix, graycoprops
from tqdm import trange
import numba
import scipy
from scipy import sparse
from scipy.sparse import issparse,csr_matrix
from metrics import eval_mclust_ari,res_... |
5e82bf0bcd5f0e2fef94a95165555f84623af957c3602b389c5be3c9b1496bf0 | Python | 15,029 | 371 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2021
#
# Distributed under terms of the MIT license.
"""
This script contains layers used in AllSet and all other tested methods.
"""
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch import Tens... |
33227e535bc46dd85e8bee84f5bb3a319db090b665a8e0b5a8fa80ee516ebecf | Python | 15,035 | 375 | import os
#from matplotlib import test
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec
import seaborn as sns
import torch
import torch.nn as nn
#import torchvision
import pickle
from surrogateParams import surrParams
import simLogger
dtype = torch.floa... |
b540a8337894b90f808b53f2cb95c0c80a1308ec9055fb9a7f1f9be93a637387 | Python | 15,035 | 285 | from __future__ import print_function, division
from keras.models import Model, Input
from keras.layers import (Conv2D, Conv3D, Conv2DTranspose, Conv3DTranspose, BatchNormalization, LeakyReLU, Concatenate,
Activation, Add, UpSampling2D, UpSampling3D, MaxPooling2D, MaxPooling3D, AveragePooling... |
4f7089eb97742c55e4d079bb3c0b49d9d8f5d20e30f99c1504b99b4535c24ec5 | Python | 15,041 | 344 | # Copyright 2020 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... |
2655e99000702860dd70b4b81a02106356ca7d860570a39a8f54eb7ff6c79eb0 | Python | 15,053 | 454 | import pytest
import os
import tarfile
import shutil
import uuid
import functools
import urllib
import numpy as np
import random
import keras
from keras import ops
import sklearn.metrics.pairwise
from unittest import mock
from functools import wraps
import tsgm
def skip_on(exception, reason="default"):
def deco... |
0ec2b9ef66bfc8a7089f2de8503eb40d2238cbbe187d71e7559480cf2ee82b25 | Python | 15,060 | 400 | #!/usr/bin/env python3
"""Compare MassCube's independent TDF2 reader with Bruker's official TDF-SDK.
Run this script on Windows or Linux with the official SDK dynamic library. It
uses no SDK code at import time and does not make TDF-SDK a MassCube runtime
dependency. The comparison is performed on exact detector coord... |
7931efb94d04c5783053fdd859e6f2b0e11af86a2bb46f0657b21d50ae7632e6 | Python | 15,064 | 407 | # tests/test_router_worker.py
"""Tests for worker heartbeat and deletion endpoints using shared fixtures."""
import time
from uuid import UUID
from conftest import make_room_address
from zndraw_joblib.exceptions import ProblemDetail
from zndraw_joblib.schemas import (
JobResponse,
PaginatedResponse,
Task... |
fd2a1998ad15b248641a61482432bc5fee7e57edb523058d09c8f3f898388f67 | Python | 15,076 | 340 | '''
Computes regional attributions for all patients with all fold models.
Authors: Hanna M. Tolle
Date: 2025-12-19
License: BSD 3-Clause
'''
import matplotlib
matplotlib.use('Agg')
import sys
sys.path.append('graphTRIP/')
from sacred import Experiment
from experiments.ingredients.data_ingredient import *
from expe... |
2af84981de081a9300f72c44ff40c0cb6ce8904ff861a5280568195066d68bc0 | Python | 15,084 | 387 | from tkinter import N
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import os, json
import seaborn as sns
# from sklearn import ensemble
sns.set_style('ticks')
sns.set_context('paper')
from draw_rna.ipynb_draw import draw_struct
import nupack
from matplotlib.backends.backend_pdf import PdfPages... |
6e93f097d4549195b93fc35e4e7a1c3374e50588164467548080fc3fb7cf7b65 | Python | 15,091 | 432 | import sklearn
import sklearn.manifold
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import math
import os
from tsgm.backend import get_backend
import tsgm
backend = get_backend()
DEFAULT_PALETTE_TSNE = {"hist": "red", "gen": "blue"}
def _to_numpy(tensor):
"""Convert tensor to numpy a... |
aeb2d2f65e7abed41253929920b8c7267789f0be72a0199cd1931c69c1bf14b9 | Python | 15,098 | 316 | import numpy as np
from collections import Counter, defaultdict
from sklearn.base import clone as CLONE
import sklearn.metrics as metrics
# Imputation
from sklearn.experimental import enable_iterative_imputer
from sklearn.impute import IterativeImputer
from pickle import dump, load
# Models
from sklearn.model_selecti... |
45e73bd0630decc3c4a53179b52ea875105d539ad597b8ce2ebeda3ef2612352 | Python | 15,112 | 467 | import numpy as np
import random
from scripts import load
import multiprocessing
def c_(alpha, x_, y_, x_peak, y_peak):
return alpha * np.sqrt((x_ - x_peak) ** 2 + (y_ - y_peak) ** 2)
def c_gauss(c_0, lambda_, x_, y_, x_peak, y_peak):
return c_0 * np.exp(-((x_ - x_peak) ** 2 + (y_ - y_peak) ** 2) / (2 * lam... |
48cae9c154e3f2bb35aa18e6d85821914bbde9e9d3df35a6c2d2a848b428e660 | Python | 15,123 | 334 | """
MetaWIBELE setup
To run: python setup.py install
"""
import os
import sys
# check for either of the required versions
# required python versions (3.6+)
required_python_version_major = [3]
required_python_version_minor = [6]
pass_check = False
try:
for major, minor in zip(required_python_version_major, required_... |
c5c613f013d62bcfd675d3c389b80ea6551208bfd461a22209f9a9395ba81e4f | Python | 15,124 | 358 | from __future__ import annotations
import sys
from abc import ABC, abstractmethod
from chgnet.utils import write_json
class Node:
"""A node in a graph."""
def __init__(self, index: int, info: dict | None = None) -> None:
"""Initialize a Node.
Args:
index (int): the index of thi... |
b0eee93f6b7a953276a4e0e4502ea4ade3322816613d73122180f8673ccb4523 | Python | 15,141 | 401 | # -*- coding: utf-8 -*-
# tests/test_interactive_plotting.py
################################################################################
# EncoderMap: A python library for dimensionality reduction.
#
# Copyright 2019-2024 University of Konstanz and the Authors
#
# Authors:
# Kevin Sawade, Tobias Lemke
#
# Encoderm... |
8a3290fcf68bc41e327c415ac8cfca81d0d3dbc967aa524cbcde8dc94e41ed7d | Python | 15,143 | 378 | '''
1. Normalize features of shape (N, sphere_basis, C),
with sphere_basis = (lmax + 1) ** 2.
2. The difference from `layer_norm.py` is that all type-L vectors have
the same number of channels and input features are of shape (N, sphere_basis, C).
'''
import math
import torch
import torch.nn as n... |
b3ada315c761ecbe05235b2ebeb52569ac960b3bfa742cfb355104e1c6ac5f3d | Python | 15,151 | 274 | import os
import tqdm
import torch
import numpy as np
import argparse
import json
import cv2
import scipy.io as sio
import time
from scipy.interpolate import interp1d
from skimage import io
from nns.model import ISOSNet
from utils import fix_random_seeds
from tools.visualizations import draw_asterisk, generate_distinct... |
a9837b375f82ab8ddfd84b488c348414f91e6b09c35e0c190f50a3ede04e899d | Python | 15,159 | 427 | import os
import json
import gzip
from typing import Dict, Optional, Any, List
import jsonlines
from kgx.sink.sink import Sink
from kgx.config import get_logger
log = get_logger()
class TrapiSink(Sink):
"""
TrapiSink is responsible for writing data in TRAPI (Translator Reasoner API) format.
This sink con... |
da286750dc58497d8309dbba4a9a3809935d81f9c319d69b3aa093f91060520d | Python | 15,184 | 420 | """Main functions for launching 3D reconstruction with BrainBuilder."""
import argparse
import logging
import os
from pathlib import Path
import pandas as pd
import brainbuilder.utils.utils as utils
from brainbuilder.downsample import downsample_sections
from brainbuilder.initalign import initalign
from brainbuilder... |
48a3e1a102188ae12499f0d436696e1b30a1d6762d46f0206c67f7afd6214adc | Python | 15,193 | 395 | """Unit tests for eggnogmapper.annotation.batch_annotate.
Tests focus on the annotate_batch() adapter function: hit parsing,
target_orthologs filtering, warning emission, and output tuple structure.
All annotation logic is mocked — only the adapter layer is exercised here.
Annotation tuple layout (14 elements, v3 ref... |
a2d511678c25691309053f143fe9d5a5f6fd9b37b00d876b9a2acb7252c9e629 | Python | 15,204 | 351 | import torch
import random
import numpy as np
from itertools import compress
from rdkit.Chem.Scaffolds import MurckoScaffold
from collections import defaultdict
from sklearn.model_selection import StratifiedKFold
from tqdm import tqdm
# splitter function
def generate_scaffold(smiles, include_chirality=False):
"""
... |
fbc57a2467c1999c8a1902db465bd15a5ff7ce8e7204a17272c051daac9f9bb7 | Python | 15,204 | 439 | """
Copyright (c) 2016-2020, EPFL/Blue Brain Project
This file is part of BluePyOpt <https://github.com/BlueBrain/BluePyOpt>
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License version 3.0 as published
by the Free Software Foundation.
... |
5c20b2201f8150ff58610484c97b2fb4557197798dbc5453fe72b4fdd0f8374b | Python | 15,220 | 365 | import numpy as np
import pytest
from guppy.analysis.artifact_removal import (
addingNaNtoChunksWithArtifacts,
addingNaNValues,
eliminateData,
eliminateTs,
processTimestampsForArtifacts,
remove_artifacts,
removeTTLs,
)
def test_remove_artifacts_raises_for_invalid_method():
with pytest... |
3c0a1918752820f3cfc2a55d9d6702b48ea81288f14ca689b0a6b7346e194c2f | Python | 15,223 | 419 | """
IO module for train/test regression datasets
"""
import numpy as np
import pandas as pd
import os
import h5py
import tensorflow as tf
def generate_cubic(x, noise=False):
x = x.astype(np.float32)
y = x**3
if noise:
sigma = 3 * np.ones_like(x)
else:
sigma = np.zeros_like(x)
r =... |
30e8666f8870c75b114979c699be08a5ac7ed20838652d587ddbdd1dc1c6608a | Python | 15,237 | 442 | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# 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 ... |
f368428d97517c088cd7bd88b84ab0a413cf7d316befbcf2fb7b51ca6fffbd13 | Python | 15,249 | 367 | # Copyright (c) OpenMMLab. All rights reserved.
# Modified from https://github.com/facebookresearch/detectron2/tree/master/projects/PointRend/point_head/point_head.py # noqa
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule
try:
from mmcv.ops import point_sample
except ModuleNotFoundError:
p... |
9b1c53df67e2b311d0ebd85dfd729b7ae36bacfd5ec7de16d75ccf80b42dffbb | Python | 15,254 | 350 | """Step 7 orchestration: export selected GuPPy sessions to NWB.
Each selected ``(session, run)`` pair is written to one NWB file in its output directory, by
whichever of two routes the session's source calls for. A session recorded in a raw acquisition
format is bundled with its GuPPy outputs by the neuroconv :class:`... |
c0454a1683bfd0d9ebc770a95bfab9f05111bd6dd0ae5ccb7656941a2566e7dc | Python | 15,268 | 449 | #!/usr/bin/env python
"""
MetaWIBELE: mspminer_protein_family_taxonomy module
Summary taxonomy annotation for each protein family
Copyright (c) 2019 Harvard School of Public Health
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "S... |
24fae87ae0cc4e9230b6a6ca6f5ca25448a0ad435c83dc8de119ecb76d8b7397 | Python | 15,270 | 446 | import torch
import torch.cuda
import glob
import os
from collections import namedtuple
import pandas as pd
import json
from collections import *
import random
import diskcache
from torch.utils.data import Dataset
from torch.utils.data import DataLoader
import numpy as np
import cv2
import torchvision.transforms.functi... |
66589755044c4fc8951a734dee00100fad97997f7422731a4ab9a551a42cbce6 | Python | 15,274 | 303 | ## ref: https://github.com/s3vqa/s3vqa.github.io/blob/main/code/preprocessing/data.py
import json
import string
import re
from tqdm import tqdm
from collections import Counter
from nltk import word_tokenize
import nltk
from nltk.stem import PorterStemmer
from nltk.tokenize import word_tokenize
from nltk.tokenize impor... |
2f7cba95df335e9b4fc43687ae8c0a54216797b1242970736353503284ec22e1 | Python | 15,278 | 483 | import pandas as pd
import numpy as np
from scipy import stats
from scipy.signal import find_peaks
from scipy.special import logsumexp
from sklearn.mixture import GaussianMixture
from collections import Counter
import math
from typing import Tuple, List, Optional
import itertools
def annotate_seg(seg_all: pd.DataFrame... |
938c6bf8a58f70ff50688a95eb0d5da540af18b288249a469dcb3e6ecf3bd0c0 | Python | 15,282 | 448 | import torch
import torch.cuda
import glob
import os
from collections import namedtuple
import pandas as pd
import json
from collections import *
import random
import diskcache
from torch.utils.data import Dataset
from torch.utils.data import DataLoader
import numpy as np
import cv2
import torchvision.transforms.functi... |
2801a0c096d2887ecd489fd437740fa9a104195c9ab685101dd11dec2de44c9f | Python | 15,294 | 464 | #!/usr/bin/env python3
import matplotlib
#matplotlib.use("pgf") # Produces smaller files than Agg
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import matplotlib.patches
import os
geodata_qualitative = [
"#FF1F5B", "#00CD6C", "#009ADE", "#AF58BA", "#FFC61E", "#F28522",
"#A0B1BA", "#A6761D", "#E9002D"... |
6bd6bd50583c7fe5beb4b3162eddfdcbebdce024741acc0069288ba60302fca8 | Python | 15,304 | 474 | #!/usr/bin/env python
# coding: utf-8
# In[2]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import scipy.stats as ss
import seaborn as sns
import os
import math
from data.sequencing import data_import
from data.sequencing import data_analysis
# Plot settings
plt.rcParams.... |
19ee4c1a9d56b51aff27d5c2bac34717a4578d495909fc1678ed2ab12c0136eb | Python | 15,306 | 501 |
"""################################################################################
> # **Introduction**
> The notebook is divided into 4 major parts :
* **Part I** : import dataset and visulization expert params
* **Part II** : define DANTE algorithm
* **Part III** : optimization using DANTE
#################... |
1bd9b92bde5e991875e23811ec98130a0af586b48cdbbec43e60e7315a349ae9 | Python | 15,311 | 339 | # pytest unit tests for sct_run_batch
import glob
import os
import json
import yaml
import pathlib
import itertools
import pytest
from stat import S_IEXEC
from textwrap import dedent
from spinalcordtoolbox.scripts import sct_run_batch
@pytest.fixture
def dummy_script(tmp_path):
"""Dummy executable script that ... |
d5c6c8b38563638a8346c878a238a95afd0f02f4563aafed35f83b552d6630d0 | Python | 15,312 | 344 | # This module is to estimate the sequence or position biases. It provides
# ways to access and save the bias parameters.
import pysam
import numpy as np
# import pylab as pl
# TODO: pylab is not a standar libary, avoid using it like this
def norm_pdf(x, mu, sigma):
return 1 / (sigma*np.sqrt(2*np.pi)) * np.exp(-1/... |
8249287adac6b725a142259c3e3755e05799e22e8eedf7f170eb38a9078fe765 | Python | 15,327 | 435 | """Morphology classes"""
"""
Copyright (c) 2016-2020, EPFL/Blue Brain Project
This file is part of BluePyOpt <https://github.com/BlueBrain/BluePyOpt>
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License version 3.0 as published
by the Fr... |
cbae690b1063bc48beb0f18615ee1eba9311acf675652afe254dde51373de6cc | Python | 15,332 | 415 | import dgl
import torch
from torch import nn
import torch.nn.functional as F
from dgl import function as fn
from functools import partial
import copy
import math
from .util import get_func
# dgl graph utils
def reverse_edge(tensor):
n = tensor.size(0)
assert n % 2 == 0
delta = torch.ones(n).type(torch.lo... |
95dbb403d9afe0805de386d2850584c0523ed5499f5f0f6fb6b8871b2168095f | Python | 15,339 | 379 | from __future__ import annotations
from gymnasium import Space, spaces
from CybORG import CybORG
from CybORG.Agents.Wrappers import BaseWrapper
from CybORG.Simulator.Actions import Action, Sleep
from CybORG.Simulator.Scenarios.EnterpriseScenarioGenerator import (
EnterpriseScenarioGenerator,
)
import functools
im... |
8000ef6d6872fc40f1ffc9bcd283efdc18e3b04ab638835d62ba250d22f8dfb8 | Python | 15,342 | 354 | import numpy as np
import torch
from torch import nn
from collections import OrderedDict
class Core(nn.Module):
""" core convolutional layers.
depth separable conv structure from https://github.com/sinzlab/neuralpredictors
"""
def __init__(self, n_channels, kernel_size, stride, out_channels=None, dens... |
223aad15231821244986bfec765c7c46c64da1d0145f7a08c82c153a23414f8f | Python | 15,374 | 408 | ###########################################################################################
# Data parsing utilities
# Authors: Ilyes Batatia, Gregor Simm and David Kovacs
# This program is distributed under the MIT License (see MIT.md)
###################################################################################... |
80e426c07095d859ad18847cae19c2dc5b2e80464d64fce36e7712823c3b826e | Python | 15,376 | 369 | # -*- coding: utf-8 -*-
import json
from django.utils.decorators import method_decorator
from django.shortcuts import get_object_or_404
from django.views.decorators.cache import never_cache
from typing import Optional
from guardian.utils import get_anonymous_user
from rest_framework.exceptions import PermissionDen... |
f1c72babbc2e80621a843b317d54e85dd0e31db0a7b5ea34c2ccdc149402f86b | Python | 15,378 | 437 | # -*- coding: utf-8 -*-
import psycopg2
from psycopg2.extensions import register_adapter, adapt, AsIs
from psycopg2.extras import CompositeCaster, register_composite
import re
from typing import Any, ClassVar, Dict
from django import forms
from django.contrib.postgres.fields import ArrayField
from django.contrib.post... |
49ec70d7a7ad266a961728fa166082a42f9fea8477bef67e7a8b1e4b653c0e36 | Python | 15,404 | 886 | ATOM_MAPPING = {
1: 0,
6: 1,
7: 2,
8: 3,
9: 4,
}
SAM_CHARGED_ATOM_MAPPING = {
1: 0,
6: 1,
7: 2,
8: 3,
9: 4,
3: 5,
12: 6,
15: 7,
16: 8,
17: 9,
}
qm9_with_h = {
"name": "qm9",
"atom_encoder": {"H": 0, "C": 1, "N": 2, "O": 3, "F": 4},
"atom_decoder"... |
23c02b0824ac6d0f3f67ee8b73fbbd91e955030ef40e5fe5f41a15d5c624230d | Python | 15,411 | 393 | # Transform images with multiprocessing
# Author: David Young, 2019, 2020
"""Transform large images with multiprocessing, including up/downsampling
and image transposition.
"""
from time import time
from typing import Optional, Sequence, Tuple
import numpy as np
from skimage import transform
from magmap.cv import c... |
a343370c059d2e8cad7fb93287938880f4b1aed0e8c53fc7086e2b2ab5228ac8 | Python | 15,429 | 461 | import logging
import os
import shutil
from pathlib import Path
from typing import Union
from pyalfe.data_structure import PipelineDataDir, Modality
from pyalfe.image_processing import ImageProcessor
from pyalfe.inference import InferenceModel
from pyalfe.roi import roi_dict
from pyalfe.tasks import Task
class Segme... |
5630bd999330ba16e654700f188476287303e8dda46bba36c44e471a8a1231a9 | Python | 15,430 | 450 | import os
import glob
import pickle
import math
import sys
import numpy as np
import pandas as pd
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import util.config as config
from lib.heart_volume import heart_classes as hc
import lib.heart_volume.heart_utils as hu
from skimage.filters imp... |
11671deb1349439068d4d0233545265e7e08dc9f6707e8daad73e4bb1c4b6688 | Python | 15,434 | 521 | """Extra features functions"""
"""
Copyright (c) 2016-2020, EPFL/Blue Brain Project
This file is part of BluePyOpt <https://github.com/BlueBrain/BluePyOpt>
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License version 3.0 as published
by ... |
6cc52f7c9baff9a9e6104bf16e63820fb13aa4e122cd126665c6a21dfc1623d9 | Python | 15,449 | 337 | # Copyright (c) OpenMMLab. All rights reserved.
# Modified from https://github.com/open-mmlab/mmdetection
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.ops import sigmoid_focal_loss as _sigmoid_focal_loss
from mmseg.registry import MODELS
from .utils import weight_reduce_loss
# This me... |
938d38f4b3bb34ba52c06716d01b140dec87827e3ab06cd3ae0de18a1637dd9d | Python | 15,465 | 326 | #!/usr/bin/env python2.7
import os, sys
os.environ["OMP_NUM_THREADS"] = "1"
os.environ["OPENBLAS_NUM_THREADS"] = "1"
os.environ["MKL_NUM_THREADS"] = "1"
os.environ["VECLIB_MAXIMUM_THREADS"] = "1"
os.environ["NUMEXPR_NUM_THREADS"] = "1"
import shlex
import argparse
import subprocess as sp
from multiprocessing impo... |
b8ededf01cbcbec1128c3a3d6d3996f77ff5cb852629b737639eacb05998c04c | Python | 15,472 | 446 | import os
import time
import numpy as np
import argparse
from copy import deepcopy
from scipy import interpolate
from sklearn.metrics import mutual_info_score
from scipy.stats import pearsonr
from scipy.spatial import distance_matrix
import scipy.sparse
import sys
import pickle
import csv
# Preprocess network for sc
p... |
894fa44f2defa12a79ed9aad4e273cda457d987ba34c20b6922934e03fb5b12c | Python | 15,474 | 375 | import numpy as np
import pandas as pd
class Clinical_outcome:
"""
Predicts modified Rankin Scale (mRS) distributions for ischaemic stroke
patients depending on time to treatment with intravenous thrombolysis (IVT)
or mechanical thrombectomy (MT). Results are broken down for large vessel
occulusion... |
d4e7f420d5358709813dd6ca0ff1ee67a6040541109c56cd2e01dc1e2d4ba2fd | Python | 15,480 | 372 | import logging
import os.path as op
import sys
from . import __version__, __packagename__
from .bids import populate_bids_templates, tuneup_bids_json_files
from .convert import prep_conversion
from .due import due, Doi
from .parser import get_study_sessions
from .queue import queue_conversion
from .utils import anonym... |
a58c2198f43e45944929bee39775b5051a66c1226b4f6477d7b16880b8827e75 | Python | 15,489 | 444 | import torch
import torchvision
from torch import nn
import torch.nn.functional as F
import torchvision.transforms.functional as fn
import logging
logger = logging.getLogger(__name__)
def transfer_weights_to_model(path: str, target_model, device = 'cpu'):
"""
Function which transfer weights from the model giv... |
6ff0b3b9a0b7ff4c926de5ab8a4fbfd5e6434742e358afdbe90d9beb1d00ecc8 | Python | 15,493 | 437 | # -*- coding: utf-8 -*-
import json
import logging
import random
import requests
import string
import sys
from typing import Any, DefaultDict, Dict, List, Optional, Set, Tuple, Union
from collections import defaultdict
from django.db import connection
from django.conf import settings
from django.http import HttpReq... |
6318a0063b4d01535db9da6763c5ac5593016b7523fe71b79c7cab0272dcf3a5 | Python | 15,527 | 448 | import os
import time
import numpy as np
import argparse
from copy import deepcopy
from scipy import interpolate
from sklearn.metrics import mutual_info_score
from scipy.stats import pearsonr
from scipy.spatial import distance_matrix
import scipy.sparse
import sys
import pickle
import csv
# Preprocess network for sc
p... |
5bbec21f5781e6d29a402d685fda30327e273cfc184501bfbaf294482a10f1fb | Python | 15,541 | 359 | import os
import keras
from keras import ops
import typing as T
from tsgm.backend import get_backend
import tsgm.utils
class BetaVAE(keras.Model):
"""
beta-VAE implementation for unlabeled time series.
"""
def __init__(self, encoder: keras.Model, decoder: keras.Model, beta: float = 1.0, **kwargs) ->... |
c642cb3f6ef2d0b5290d0798cdb5bea55f4c03a1add6692fd414ffb6bf6fb73b | Python | 15,548 | 408 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, DepthwiseSeparableConvModule
from mmengine.model import BaseModule
from mmseg.models.decode_heads.psp_head import PPM
from mmseg.registry import MODELS
from ..utils import InvertedResidual, resize
clas... |
d3afa7e5ac30a4df85583c9e9bfef534cc6a9074249ba38aed7e7f41c48d2c27 | Python | 15,556 | 338 | import torch
import numpy as np
import copy
def grid_rot90(m, i=None):
if i is None: i = np.random.randint(24)
if i == 0 : return m
if i == 1 : return np.rot90(m, 1, (0, 2))
if i == 2 : return np.rot90(m, 2, (0, 2))
if i == 3 : return np.rot90(m, ... |
8bf45ae73581f6c66b9cd70094dfad2070ef89da35969bc6937ce062e5fbf164 | Python | 15,567 | 158 | """
This module holds useful properties dictionaries used by other objects in the yarp package
"""
# element label to atomic number
el_to_an = { "h": 1, "he": 2,\
"li":3, "be":4, "b":5, "c":6, "n":... |
09e400bcb9fa49f1ff5bb0f59b191593ce5650cb30927a4565ff7aa5bd81b52e | Python | 15,569 | 507 |
import collections
import itertools
import numpy as np
import pandas as pd
import sys
def _zero_runs(a):
iszero = np.concatenate(([0], np.equal(a, 0).view(np.int8), [0]))
absdiff = np.abs(np.diff(iszero))
ranges = np.where(absdiff == 1)[0].reshape(-1, 2)
return ranges
def concatenate_subsegments(df_unfiltered, ... |
96f56a19ef030c825b84534eddb97338f441e3acd67bc3de4f069fbb8d7e3dfd | Python | 15,570 | 353 | """Code for finetune_huatuo"""
import os
import copy
import json
import torch
import logging
import argparse
from tqdm import tqdm
import torch.distributed as dist
from torch.utils.data import Dataset, DataLoader
from torch.utils.tensorboard import SummaryWriter
import wandb
from accelerate import Accelerator, DeepSp... |
c06c3b015beb1722d773abcb7bd53526f945ae7f418484030a2bee61db8628f5 | Python | 15,614 | 352 | """Contract tests for TdtRecordingExtractor."""
import shutil
from pathlib import Path
import numpy as np
import pytest
from guppy.extractors.tdt_recording_extractor import TdtRecordingExtractor
from guppy_test_data import STUBBED_TESTING_DATA
from .recording_extractor_test_mixin import RecordingExtractorTestMixin
... |
fa1d39cb379c8920be9e2595fdcdfc5e3aa51dcf2e4a642cc21fbf87c5c3d004 | Python | 15,622 | 457 | from pyhealth.data import Patient, Visit
def drug_recommendation_fn(patient):
samples = []
for i in range(len(patient)):
visit = patient[i]
conditions = visit.get_code_list(table="DIAGNOSES_ICD")
procedures = visit.get_code_list(table="PROCEDURES_ICD")
drugs = visit.get_code_lis... |
8671f33bdaafcdb05476a2f58da5c3d4a5c8fbb1617e8be6b2a80c34405f726a | Python | 15,624 | 497 | from __future__ import absolute_import
from __future__ import print_function
import pytest
import os
import numpy as np
from numpy.testing import assert_allclose
from keras import backend as K
import keras
from keras.models import Sequential
from keras.layers import Dense, Activation
from keras.utils import np_utils
f... |
d809189a991ee20e9e5365d07155a936a0a524429d2f97be2fdce305269c9a72 | Python | 15,630 | 446 | # Author: Huaxu Yu
# A module for feature detection
# imports
import numpy as np
from scipy.signal import find_peaks
from scipy.ndimage import gaussian_filter1d
from copy import deepcopy
import bisect
from .feature_evaluation import calculate_noise_score, calculate_gaussian_similarity, calculate_asymmetry_factor
"... |
1fd02fdd0af4ab19befeb54fbdadc71adb96adc094b065bac7dd20fab0939e95 | Python | 15,651 | 452 |
import sys
import time
import numpy as np
import multiprocessing
class BayesianRegress:
def __init__(self, lambda_=0.1, sigma_=2.5, coef_=None, intercept_=None,
fitsigma=True, fitlambda=False):
"""Initialize a Bayesian regressor.
_lambda: L2 constrains of weights
_sigma: ... |
96faba90a448af2f38a2669bb41dfaa4d94ad1f7dbfb0ab9a430e3c2f07e54e5 | Python | 15,657 | 500 | import os
from textwrap import dedent
import pytest
from dnaio import SequenceRecord
from cutadapt.adapters import (
LinkedAdapter,
BackAdapter,
FrontAdapter,
InvalidCharacter,
PrefixAdapter,
RightmostFrontAdapter,
RightmostBackAdapter,
SuffixAdapter,
)
from cutadapt.parser import (
... |
2355ab1e92bbbf7b0c25074a4134642c2898cba436568b7032f155764f174009 | Python | 15,677 | 460 | """
Utility Functions for GNODEVAE
This module provides utility classes for graph structure manipulation and
decoding in GNODEVAE models. These utilities handle the conversion between
different graph representations and enable flexible graph reconstruction.
Key Components:
- AdjToEdge: Convert adjacency matrices to e... |
21297a8f15c1fa1ce14508ec8b0cd574428ed429d05f1ec42925aa06496bf568 | Python | 15,691 | 423 | import numpy as np
import random
import re
import pickle
from rdkit import Chem
import sys
import time
import torch
from torch.utils.data import Dataset
from rdkit import Chem, DataStructs
from rdkit.Chem import AllChem
from fragment_utils.mol_utils import split_molecule, join_fragments
from MCMG_utils.utils import Va... |
2fe06ba0abb749cb9f51824dcfea745c31e95c10305ac6bb46625da6bf15b3df | Python | 15,694 | 459 | """Prepare surfaces for surface-based interpolation."""
import os
import re
from typing import Optional, Tuple
import nibabel as nb_surf
import numpy as np
import pandas as pd
import brainbuilder.utils.ants_nibabel as nib
from brainbuilder.utils import utils
from brainbuilder.utils.mesh_io import load_mesh, load_mesh... |
4c6127fb0f70dbdedb210cbef3ef837de31fe6485ecf26ba94ed5babb2612835 | Python | 15,701 | 535 | # This file is part of h5py, a Python interface to the HDF5 library.
#
# http://www.h5py.org
#
# Copyright 2008-2013 Andrew Collette and contributors
#
# License: Standard 3-clause BSD; see "license.txt" for full license terms
# and contributor agreement.
"""
Implements operations common to all high-lev... |
ecad342e7b438ef7749a14432d621b9ac757f9744ba69e95185e31af0097e0f2 | Python | 15,707 | 492 | """Test neuroml functions"""
import os
import sys
import efel
import neuroml
import numpy
import pytest
from pyneuroml import pynml
from bluepyopt import ephys
from bluepyopt.neuroml import biophys
from bluepyopt.neuroml import cell
from bluepyopt.neuroml import morphology
from bluepyopt.neuroml import simulation
L5... |
b5f2cb91f2b5c6cf3296e642d47429b6de2d9f835cf25e4927a695f2bd486fdb | Python | 15,708 | 458 | import logging
import os
from typing import Optional
import yaml
from fastapi import APIRouter, Depends, Form, Request
from fastapi.responses import HTMLResponse, JSONResponse
import medperf.config as config
from medperf.account_management import get_medperf_user_data
from medperf.commands.association.approval import... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.