sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
d8f990f940543d60392687825d7c0b866e5286ed20c9cf7187f786ccb23ae2ce | Python | 6,125 | 104 | # 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... |
029b68295ef713bc398f4a351d7c241ca0148ad959b413ca322e1361eb46de0c | Python | 6,126 | 113 | import argparse
from anndata import AnnData
import torch
import sys
from vgae import agent
import scanpy as sc
import joblib
def str2bool(v):
if isinstance(v, bool):
return v
if v.lower() in ('yes', 'true', 't', 'y', '1'):
return True
elif v.lower() in ('no', 'false', 'f... |
9e72d206448c2fbeb10746065a74c2fa17bb2391f58480e9f9e6596ffafabb87 | Python | 6,127 | 139 | import numpy as np
from . import gems
from freesurfer.samseg.warp_mesh import kvlWarpMesh
from freesurfer.samseg.utilities import requireNumpyArray
import freesurfer as fs
class ProbabilisticAtlas:
def __init__(self):
pass
def getMesh(self, meshCollectionFileName,
transform=None,
... |
b86cea6d00586e23d73e45c4284b82279f94d4a75e88bdd5f5ce55eea30fda51 | Python | 6,127 | 113 | import argparse
from anndata import AnnData
import torch
import sys
from vgae import agent
import scanpy as sc
import joblib
def str2bool(v):
if isinstance(v, bool):
return v
if v.lower() in ('yes', 'true', 't', 'y', '1'):
return True
elif v.lower() in ('no', 'false', 'f... |
7762da83a5236fe8111c5ed94fad6b8824ab0fabe9b0ef82fac20e950f5b45ae | Python | 6,130 | 184 | import numpy as np
import pandas as pd
import ssm
DEFAULT_THREE_STATE_TX = np.array(
[[[0.98, 0.01, 0.01], [0.04, 0.94, 0.02], [0.04, 0.01, 0.96]]]
)
DEFAULT_FOUR_STATE_TX = np.array(
[
[
[0.97, 0.01, 0.01, 0.01],
[0.04, 0.92, 0.02, 0.02],
[0.04, 0.01, 0.94, 0.01],
... |
09b5074cfe974117f84e05e015bb4d7f3e13ac264e42ac56b2291ac82c6f9dad | Python | 6,132 | 136 | from sklearn.decomposition import PCA
from matplotlib.patches import Ellipse
import numpy as np
import matplotlib.pyplot as plt
def fig_ax_by_dim(dim):
'''
Create a figure and axis object based on the dimension of the data
input:
dim: int, the dimension of the data. 2 or 3
'''
if dim == 2:
... |
3060eea1f14f7154fb303cb2fc020d017530c07ed040ae04e490eb00e5b1743f | Python | 6,132 | 181 | """Utilities used in convolutional layers.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from six.moves import range
import numpy as np
from .. import backend as K
def normalize_tuple(value, n, name):
"""Transforms a single int or iterable of int... |
404fb55a26f13ba6dc4dc337b34283056d3ed4e19c8eeae42a6afa6fde9b2638 | Python | 6,132 | 158 | #!/usr/bin/env python
#
# Copyright 2013 Google Inc. All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of... |
c79fa6d5687c30ac6077dcc4c5bacdab79f55520ae902e94da21cf5f020271e6 | Python | 6,132 | 146 | # 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... |
731c0c5c158ce5cff73e2a0d59d1dcf71193f92621b6e674b3db82c93da93b35 | Python | 6,133 | 133 | """End-to-end tests for baseline-epoch control fitting (issue #200).
Runs step1 -> step2 -> step3 headlessly on the synthetic injection CSV session
(``stubbed_testing_data/csv/sample_data_csv_injection_1``), whose 465 nm signal has a
sustained step at the injection time (t=60 s) while the 405 nm isosbestic control doe... |
6b1d30911c4f3030b5c1cd1289d49d525055765d3f03f0244c5f9aec3077d342 | Python | 6,137 | 131 | import os, argparse, time, json
import numpy as np
from collections import OrderedDict
import nearl.featurizer, nearl.features
from nearl.io.traj import MisatoTraj
# Define the way to generation labels for the misato trajectories
def parser():
parser = argparse.ArgumentParser(description="Featurize the misato tr... |
983ffd9b7b48d9d1b1a52c88d1677f7011c474086a846e4bb3567d9020fde2cc | Python | 6,137 | 177 | #!/usr/bin/env python
#
# This script will ask you for a Django authentication group name
# and possible permission options for CATMAID projects to grant
# those permmisons to all CATMAID projects.
#
# You may need to install psycopg2, e.g. with:
# sudo apt-get install python-psycopg2
#
# Requires the file .catmaid-db ... |
08d805154731e83799dd5f70932b2a7412ad9cf294f18d26433f88dfc1edd6e8 | Python | 6,138 | 168 | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import torch
from torch_scatter import segment_csr
def repeat_blocks(
sizes,
repeats,
continuous_indexing: bool = True,
sta... |
e3b8e946395d34df6bab34f48f4bd1a01a0e962510eeeaaa51b6bf16fbf59c61 | Python | 6,149 | 113 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 3 16:11:58 2022
@author: george
"""
###Creates macro to run thunderStorm for a batch of iles in ImageJ - works for >1 file
####TODO! run macro directly using python
#pip install pyimagej
#need to install maven and set PATH (export PATH=/Users/geo... |
f62a57f99fedafa33b1da921813bee4b3eb0518e2f910c7230bcd3d1a0f1bf30 | Python | 6,151 | 133 | import pandas as pd
from os.path import join
from pathlib import Path
import os, re
# load csv file
def extract_bids(filename: str, key: str) -> str:
'''
Extracts BIDS information based on input 'key' prefix.
If filename includes an extension, code will remove it.
'''
bids_info = [match for match i... |
7ff15bd569f9ebb0d49c6c9e5a386c4c9e40bad2df0c2d4f9057a4465274724a | Python | 6,154 | 135 | import h5py
from utils_final import *
# Configuration
folder_name = "h5_result"
threshold = 5.0
threshold2 = 7.0
save_figure = True
R = 1e-3 # Measurement noise covariance
Q = 9e-5 # Process noise covariance
output_folder = f"results/{folder_name}/{threshold}"
os.makedirs(output_folder, exist_ok=True)
# Initializ... |
d4a1afd0a24dae0e3d9578ea43ee8335895a78afc966f55d8ed03cee702036e5 | Python | 6,154 | 178 | import yaml
import os
import shutil
def generic_setup(output_logs):
tmpfolder = os.path.join(output_logs, ".tmp")
os.makedirs(tmpfolder, exist_ok=True)
# NOTE: this should be set before any code imports tempfile
os.environ["TMPDIR"] = tmpfolder
os.environ["RESULTS_FOLDER"] = os.path.join(tmpfolder... |
007646678b71a3a343e43709ca6d5698551f3fad6d94f4603186047d985a0145 | Python | 6,157 | 164 | from .load_backend import epsilon
from .load_backend import set_epsilon
from .load_backend import floatx
from .load_backend import set_floatx
from .load_backend import cast_to_floatx
from .load_backend import image_data_format
from .load_backend import set_image_data_format
from .load_backend import reset_uids
... |
6e7a319b41d68313cda001efb5f5f008939382bffbc9354e0aabb6cdf5d5f644 | Python | 6,157 | 161 | import os
import platform
import torch
from transformers import AutoTokenizer
from transformers import AutoModelForCausalLM
import re
import argparse
def load_model(model_name, device, num_gpus):
if device == "cuda":
kwargs = {"torch_dtype": torch.float32}
if num_gpus == "auto":
kwargs... |
f5632cefca6a80c07bc132e64f1c01698f9e67af15dec87953924f167d80fc35 | Python | 6,157 | 183 | """Constraints: functions that impose constraints on weight values.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import six
from . import backend as K
from .utils.generic_utils import serialize_keras_object
from .utils.generic_utils import deserialize... |
38da9ba999ddf946e5660783085ec10c0cc0982d4a11a2343575b257fa88c6aa | Python | 6,158 | 177 | """Test ephys.parameterscalers"""
import json
import pathlib
import tempfile
import arbor
import pytest
from bluepyopt.ephys.parameterscalers import (NrnSegmentLinearScaler,
NrnSegmentSomaDistanceScaler, )
from bluepyopt.ephys.serializer import instantiator
import blue... |
7fa5aa5b3f7b1fd70058efc19c242a29c73a80669156072dc5808ebde3a89bc4 | Python | 6,160 | 111 | ## Restormer: Efficient Transformer for High-Resolution Image Restoration
## Syed Waqas Zamir, Aditya Arora, Salman Khan, Munawar Hayat, Fahad Shahbaz Khan, and Ming-Hsuan Yang
## https://arxiv.org/abs/2111.09881
## Download training and testing data for Image Denoising task
import os
# import gdown
import shutil
i... |
fe0065c6a32393b867da3ba965c395d465097fab5f5413bafc3d46a0480fd519 | Python | 6,163 | 204 | """Room-scoped AsyncBlobIO registry with provider frame count support."""
import base64
from typing import Any
import msgpack
from asebytes import AsyncBlobIO
from asebytes._async_adapters import AsyncObjectToBlobReadWriteAdapter
from asebytes._async_backends import AsyncReadWriteBackend
from redis.asyncio import Red... |
842ef5fdaea684255a6eb40aac571c4bae30bd52166729fa1e1026f98874afe6 | Python | 6,166 | 160 | from selenium.webdriver.support.ui import WebDriverWait, Select
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
class BasePage:
NAVBAR = (By.CSS_SELECTOR, "nav[data-testid='navbar']")
USER_DROPDOWN = (By.CSS_SELECTOR, "button[data-testid='user-menu-... |
c6ec553f0176c4b779c538e71a8e564da7d4d04fd7612bf9e264817924150642 | Python | 6,166 | 187 | #!/usr/bin/env python
# coding: utf-8
import os.path as op
import time
import torch
import numpy
import random
import sklearn
import numpy as np
import networkx as nx
import torch.nn.functional as F
from torch.nn import Linear
from sklearn import preprocessing
from collections import defaultdict
from IPython.display ... |
852d4b8bd0a471199d5b05cae3441c716e9e731150e43fe3e1d6368307765543 | Python | 6,167 | 206 | #!/usr/bin/env python
"""
Simple Pytorch tools
"""
import argparse
import glob
import importlib.util
import os
import pickle
import sys
import time
import matplotlib
import numpy as np
import torch
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
def standardize(np_input):
mean = np.mean(np_... |
311a034f6a45566795bed847531faa757c8c795a325d396f5d3cb5ce06812ad7 | Python | 6,168 | 185 |
import copy
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_geometric.nn import GCNConv, GlobalAttention, GATConv
import torch_geometric.transforms as T
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Implementation of Twin Delayed Deep Dete... |
d7e8319ae38f89210a234dc5459bd055f4bc4f09a7cd2acf5a54c0c688ef317e | Python | 6,169 | 208 | """Test l5pc example"""
import json
import os
import sys
from contextlib import contextmanager
if sys.version_info[0] < 3:
from StringIO import StringIO
else:
from io import StringIO
import pytest
L5PC_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__),
'... |
e6ad56cc94ef1e3f88997a2c97e8e7cce6a9f5034ad15b4fec567893b582dcc8 | Python | 6,172 | 218 | from typing import List, Optional, Tuple
from collections import OrderedDict
from uuid import uuid4
import torch
# from pl_trainer import DDPMModule
from potential_module import PotentialModule
from pytorch_lightning import Trainer, seed_everything
from pytorch_lightning.callbacks.progress import TQDMProgressBar
from ... |
04f766f8eff5c290fdd11cb87018d265b6df998e4e1fdde230a1d56486b5cb11 | Python | 6,174 | 160 | from pathlib import Path
from typing import Union
import cv2
import numpy as np
import tifffile
from czifile import CziFile
def path_dict(path: Union[Path, str]):
"""
Replace Path with a dict that contains relevant information (safer for pickle)
:param path: Windows or unix path to the file
"""
i... |
cb80cf80408cd949594ac6d576085f5a8a97157ab10b1c297755256004653e5e | Python | 6,176 | 187 | #!/usr/bin/env python
# coding: utf-8
import os.path as op
import time
import torch
import numpy
import random
import sklearn
import numpy as np
import networkx as nx
import torch.nn.functional as F
from torch.nn import Linear
from sklearn import preprocessing
from collections import defaultdict
from IPython.display ... |
72873153e09d816a294f95bd8bac745eaf1df19b5e25cd13a5ec782649bba8a0 | Python | 6,183 | 198 | from typing import List, Optional
from medperf.exceptions import MedperfException
import medperf.config as config
from medperf.entities.interface import Entity
from medperf.entities.schemas import ModelSchema
from medperf.entities.cube import Cube
from medperf.entities.asset import Asset
from medperf.account_managemen... |
e8911da062ab44d86a6ebbab79bad9da397c2a7ee82eb5d916dc332c106b85e9 | Python | 6,183 | 163 | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os.path as osp
from collections import OrderedDict
import mmengine
import torch
from mmengine.runner import CheckpointLoader
def convert_vitlayer(paras):
new_para_name = ''
if paras[0] == 'ln_1':
new_para_name = '.'.join(['ln1'] +... |
31ec36e2ece69cdeae536335976a3124dc336d297eebb1c56fe43e4c03df90a8 | Python | 6,184 | 178 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os, json
import pandas as pd
class metadata():
collected_keys = [
'epochs', 'learning_rate', 'batch_size', 'date',
'model_type', 'sigma', 'seq_type', 'mutation_scheme',
'seq_len', 'seqs_file', 'out_dir', 'output_dims']
... |
ab9093a7925492184ec087c536bbd98c8c7678fafc26f3a5c89f37ee0e3bb238 | Python | 6,184 | 144 | import time
from builtins import print
import sys
import os
import torch
import argparse
import pytorch_lightning as pl
from pytorch_lightning import Trainer, loggers
from transformers import MT5ForConditionalGeneration
from pytorch_lightning.callbacks import LearningRateMonitor
# os.environ["CUDA_VISIBLE_DEVICES"] = '... |
3dd3bc97249a15561f620ee4dea20347895dea8edaf0b19cbea8e8951435b174 | Python | 6,186 | 146 | from PyQt5 import QtGui, QtWidgets, QtCore
import pyqtgraph as pg
import numpy as np
from util.conf import es_params
from util.functions import movingAverage
from features.Feature import Feature
import math
class EventShape(Feature):
def __init__(self, data, parent=None, liveplot=None):
# Init Feature
... |
3320ce2fa5eec47d3809636ce157be66d3138843415f5e8de80d6dd78dfeb227 | Python | 6,187 | 161 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmcv.cnn import ConvModule
from mmengine.model.weight_init import constant_init
from torch import nn as nn
from torch.nn import functional as F
class SelfAttentionBlock(nn.Module):
"""General self-attention block/non-local block.
Please refer ... |
7eeced80d5a07bc4d4d224f05620d890f1fc5499574bceed184ef23d36d1f09d | Python | 6,188 | 188 | import einops
import numpy as np
import pytest
import torch
from ase import Atoms
from mace.tools import AtomicNumberTable
from simgen.calculators import MaceSimilarityCalculator
from simgen.generation_utils import (
ExponentialRepulsionBlock,
batch_atoms,
calculate_path_length,
check_atoms_outside_thr... |
9c2562fc9585c92378e81a17d9696b2c3b17438047de041874602a97211714ce | Python | 6,188 | 146 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader
import numpy as np
import scanpy as sc
from anndata import AnnData
from sklearn.neighbors import NearestNeighbors
from sklearn.cluster import KMeans
from tqdm import tqdm
# --- Core Model Components ---
... |
3044a4890b01f39cb352803c412cfd26af9fb053fb111a4f53a95f14e7bb9866 | Python | 6,190 | 176 | from pathlib import Path
from typing import List
import hydra
import numpy as np
import torch
import omegaconf
import pytorch_lightning as pl
from hydra.core.hydra_config import HydraConfig
from omegaconf import DictConfig, OmegaConf
from pytorch_lightning import seed_everything, Callback
from pytorch_light... |
76e11e330c4e863b94cfaef4eb07903a1228457cbcd8de8638c9993a2d255541 | Python | 6,190 | 177 | import logging
import os
import sys
from typing import List, Optional, Tuple, Union
import numpy as np
import torch
from ase import Atoms
from mace.tools import torch_geometric
def assign_num_hydrogens_and_parent_heavy_atoms(
atoms: Atoms,
) -> Tuple[np.ndarray, np.ndarray]:
positions = atoms.get_positions()... |
c0c3156b2a1b54be249beae05217d01d6aca6d7cdefeba5c54ed779589ef5763 | Python | 6,192 | 141 | from functools import partial
from typing import Callable
import torch
import math
# SLAYER surrogate gradient function
def SLAYER(x: torch.Tensor, alpha: float, c: float) -> torch.Tensor:
return c * alpha / (2 * torch.exp(x.abs() * alpha))
def spike_grad_injection_function(x: torch.Tensor, alpha: float, c: float... |
95cfee3cd75bfc868ab8e8850a1dd30a78d2ba3afdd8757fc8989d120f621c4a | Python | 6,196 | 130 | #!/usr/bin/env python
import sys, os
use_message = '''
'''
def get_aligners():
mac = (sys.platform == "darwin")
if not os.path.exists("aligners"):
os.mkdir("aligners")
os.chdir("aligners")
if not os.path.exists("bin"):
os.mkdir("bin")
programs = ["HISAT", "Bowtie2", "Bowtie", "TopH... |
c79a1f5ce938436462b9afc7feae609cf81870262c946def43224165d9c78f1e | Python | 6,198 | 180 | import mne
from scipy.signal import detrend
import sys, os
from tqdm import tqdm
from glob import glob
import numpy as np
import itertools
import pandas as pd
try:
from braindecode.preprocessing import exponential_moving_standardize
from braindecode import EEGClassifier
from braindecode.util import set_ran... |
30bdac524c07e5a6dfdfc46e733e9db4c2adf0c1804b5221036c128e0c754413 | Python | 6,203 | 185 | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.backbones.vit import (TransformerEncoderLayer,
VisionTransformer)
from .utils import check_norm_state
def test_vit_backbone():
with pytest.raises(TypeError):
# pretrained m... |
6a379351151e50ff7bef42323208cd23b5dc5cba0a312c6f9253bdd9d558fccc | Python | 6,206 | 199 | # Containing API to load the count matrix data
import anndata
import numpy as np
import pandas as pd
from scipy.sparse import csc_matrix
from anndata import read_h5ad
from .gtf_utils import load_genes as read_gff
def convert_to_annData(Rmat_dict, effLen_tensor, cell_note, gene_note,
fill_missing=True):
"""... |
939edbcf85f6d1ce134f5019f8151f07c6c43fa41c295b08f1f9e184baeb9169 | Python | 6,212 | 193 | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import logging
import torch
from ..utils import read_value_json, update_json
class AutomaticFit:
"""
All added va... |
d280cd7855b8647f7c6a05632692d2e3644d0787273f30cb1a91c566d8c7b8d0 | Python | 6,212 | 204 | from __future__ import annotations
import json
import os
import numpy as np
import torch
from torch import Tensor
def _default_accelerator() -> str:
"""Return the name of the best available torch accelerator backend.
Returns:
str: "cuda", "xpu" or "cpu" depending on what torch can see.
"""
... |
15b2ac417a81300456b8d9262b6f0da7b563ad2ce697ad6d507d3e826a72316f | Python | 6,213 | 203 | import torch
import torch.nn.functional as F
import torch.nn as nn
from math import exp
import numpy as np
def gaussian(window_size, sigma):
gauss = torch.Tensor([exp(-(x - window_size//2)**2/float(2*sigma**2)) for x in range(window_size)])
return gauss/gauss.sum()
def create_window(window_size,... |
4fc499e84bffbb61d0a80072a2006e3fdb45ca47804db2b21e2d98e0199b3844 | Python | 6,217 | 164 | import scanpy as sc
import numpy as np
import pandas as pd
import h5py
###
###
### reading expression data
###
###
filename = "ppfctx_snRNAseq_processed_data_2024_05_16.h5seurat"
with h5py.File(filename, "r") as f:
cols = np.array(f["assays"]["RNA"]['features'])
indices = np.array(f["cell.names"])
age_li... |
3c7cf8be81733b61542cd46a022ecf35772346e9f5497f6f9d2298575b80a755 | Python | 6,218 | 183 | '''
Created on 18 Nov 2022
@author: Francois STÜDER
'''
from io import TextIOWrapper
#from multiprocessing import Pool
from os import path,remove
from subprocess import Popen, PIPE
#from threading import Thread
from SysISTD import tools
cmdAlignment = "bowtie2 --reorder --very-sensitive -p __core__ -x __genome__ -1... |
ff6a9cbac4cc2c4d043fac693d7ac817691a2a582cd9b5d22330de02f5f0a48e | Python | 6,218 | 170 | from importlib import resources
import yaml
from pathlib import Path
import logging
from medperf.logging.utils import log_machine_details
import typer
from starlette.middleware.base import BaseHTTPMiddleware
from fastapi import FastAPI, Request
from fastapi.responses import RedirectResponse
from fastapi.stat... |
6be95b870f169457ecf2096dd1258c93989c5f10199862d8bb88222ed0013b83 | Python | 6,220 | 158 | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import shutil
from collections import OrderedDict
from typing import Dict, Optional, Sequence
try:
import cityscapesscripts.evaluation.evalPixelLevelSemanticLabeling as CSEval # noqa
import cityscapesscripts.helpers.labels as CSLabels
exce... |
f766a0cdc5f50bc9a1e9fa0b47d9311eaecfed36f2572d79d3c2a28fb9a8f384 | Python | 6,220 | 132 | # pytest unit tests for sct_fmri_moco
import numpy as np
import pytest
import logging
from spinalcordtoolbox.scripts import sct_fmri_moco, sct_deepseg, sct_maths, sct_create_mask, sct_image, sct_apply_transfo
from spinalcordtoolbox.image import Image
from spinalcordtoolbox.utils.sys import sct_test_path
logger = log... |
2c59352fb0dd77193b5a0560b70cc60e29ee6cd73f511a859d91dbc356d758db | Python | 6,222 | 202 | #!/usr/bin/env python
"""
MetaWIBELE: download_databases module
Download dependent databases used by MetaWIBELE
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 "Software"), to deal... |
4cba41d86bd0e12d0ea803e1511e5e4009c7bb7c2bfddfc9b8f64f436d21f97c | Python | 6,222 | 166 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import os
import shutil
import itertools
from multiprocessing import Pool
import numpy as np
from dmriqcpy.analysis.stats import stats_mean_in_tissues
from dmriqcpy.io.report import Report
from dmriqcpy.io.utils import (add_online_arg, add_overwrite_arg,... |
4bcfaa15f0a990e04ef3e9c5171988e23c6cf5ff6b87ea3f36bbe62d9859ea93 | Python | 6,223 | 110 | # 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... |
268d2dcc274c1ca65264c9b456237bff97f693068a8547c9440466237f9a018e | Python | 6,224 | 200 | """Equivalence + timing tests for the Rust backend.
Usage:
python test_rust_equivalence.py
Runs multitaper_spectrogram twice for each of several parameter sets — once
with use_rust=False (pure Python) and once with use_rust=True (Rust backend) —
and asserts that outputs agree to a small tolerance. Also runs a one... |
8023e5287c724949b4feaffce14f0850516c6cb98b440bedb25039ae0c145390 | Python | 6,224 | 126 | """End-to-end test for tonic/basal fluorescence analysis (issue #210).
Runs step1 -> step2 -> step3 -> tonic_analysis headlessly on the synthetic injection
CSV session (``stubbed_testing_data/csv/sample_data_csv_injection_1``), whose 465 nm signal
holds three equal 60 s phases: a flat baseline, a sustained plateau fro... |
2be2d6693da595b6fc88091eb63ad456d60909afcea7b89c7db2f72c8ab96171 | Python | 6,225 | 126 | import matplotlib.pyplot as plt
import torch
import seaborn as sns
import scienceplots
import matplotlib.gridspec as gridspec
import matplotlib.colors as colors
import glob
from natsort import natsorted
import pandas as pd
import numpy as np
from sklearn.manifold import MDS
import math
from scipy import stats
gs = gri... |
5e50e08367ab5d48ed2b79f1644ea261ba03b51b458176ddc5939eaaec6ac88e | Python | 6,229 | 134 | import matplotlib.pyplot as plt
import torch
import seaborn as sns
import scienceplots
import matplotlib.gridspec as gridspec
import matplotlib.colors as colors
import glob
from natsort import natsorted
import pandas as pd
import numpy as np
from sklearn.manifold import MDS
import math
from scipy import stats
import ma... |
f5dbe7c9f3fdc28b17a218907d4e64a67587f9dcc86cf597a4ad16ef2c209a1b | Python | 6,234 | 171 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import itertools
from multiprocessing import Pool
import os
import shutil
import numpy as np
from dmriqcpy.analysis.stats import stats_mean_in_tissues, stats_mean_median
from dmriqcpy.io.report import Report
from dmriqcpy.io.utils import (add_online_arg,... |
1b04b7ed7fc3d766a0711663a82aaa71245b4a967cf47dce166b7f0ce14216a5 | Python | 6,239 | 154 | from PyQt5.QtWidgets import QWidget, QHBoxLayout, QTabWidget
import pyqtgraph as pg
from ..core.backend import DataInstance
from typing import List
import numpy as np
from matplotlib import cm
class Cofiring2DWidget(QWidget):
def __init__(self, session: DataInstance, name: str, parent=None, nums_to_visualize: str ... |
e83e8c66bda9b09a0e3039564c6bf3ee9fee97dab1438ccdb7841a78e4a808ea | Python | 6,243 | 171 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 7 17:48:04 2022
@author: george
"""
import numpy as np
import pandas as pd
from tqdm import tqdm
import os, glob
pixelSize = 0.108
def getStats(df):
stats = df.agg(
{
'n_segments':['mean','std'],
'track_length':['me... |
976dbac7c4aba08883b5d3fa024dcdf4b44bad4ad2765ce271965e187c5b4fa9 | Python | 6,247 | 151 | # Copyright (c) OpenMMLab. All rights reserved.
from numbers import Number
from typing import Any, Dict, List, Optional, Sequence
import torch
from mmengine.model import BaseDataPreprocessor
from mmseg.registry import MODELS
from mmseg.utils import stack_batch
@MODELS.register_module()
class SegDataPreProcessor(Bas... |
d7b1e7f2c34b18cb8569aaae5bcbd37a1e78f6088438914447e116bcf55a9673 | Python | 6,248 | 168 | import pytest
import numpy as np
from numpy.testing import assert_allclose
from keras import backend as K
from keras.models import Sequential, Model
from keras.layers import convolutional_recurrent, Input, Masking, Lambda
from keras.utils.test_utils import layer_test
from keras import regularizers
num_row = 3
num_col... |
09cb98fe6ea942ef4837f648d31e5ac37eff079f32bc7574d3d09777af431663 | Python | 6,249 | 211 | #!/usr/bin/env python
from __future__ import print_function, division
import numpy as np
import pandas as pd
from rdkit import Chem
from rdkit import rdBase
from rdkit.Chem import AllChem
from rdkit import DataStructs
import rdkit.Chem.QED as QED
from MCMG_utils import scripts as sascorer
import pickle
# from chemprop... |
e21f3d2bbe3dcd8a9d6c80d4f604175bf38a7670c4f2d81dacfcf27c8db3f55e | Python | 6,251 | 239 | import tempfile
from contextlib import contextmanager
from pathlib import Path
from typing import TypeVar
import numpy as np
import pytest
from torch.utils.data import Dataset
from ocpmodels.common.data_parallel import BalancedBatchSampler
DATA = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
SIZE_ATOMS = [1, 1, 1, 1, 1, 1, 1, 1, ... |
c932267d92f1f5424c68de2116e52e85c2c4190a18cba982094dce9039c94879 | Python | 6,254 | 211 | #*******************************************************#
# Classes used as configuration files
#*******************************************************#
class datasetConfig:
'''
Class for defining dataset parameters: shape, split ratio, augumentation etc.
'''
'''
Labes_csv_path: Root directory w... |
e1eb7d2c0495e15e28acbf33f51b577681bd7ce012e042095ef69c865118b3ca | Python | 6,257 | 165 | import sys
import unittest
import pytest
import numpy as np
import xgboost as xgb
from hypothesis import given, strategies, assume, settings, note
from xgboost import testing as tm
rng = np.random.RandomState(1994)
shap_parameter_strategy = strategies.fixed_dictionaries(
{
"max_depth": strategies.intege... |
e475d9a28075b7c68713a37ef9550337c0a744901ecfbb6343f703b2d3278371 | Python | 6,260 | 175 | """E2E tests for run_kwargs support in register_job / register_extension.
Covers:
- register_job(cls, run_kwargs={...}) forwards to JobManager
- register_extension(cls, run_kwargs={...}) forwards through deprecated shim
- _execute_task unpacks run_kwargs into extension.run()
"""
import threading
import warnings
from ... |
7c511275e46577faa80066717b69b870f82029e3396ec29b28b7dd2788555882 | Python | 6,264 | 198 | """
Module defining base interfaces.
"""
from abc import ABC, abstractmethod
from matplotlib import pyplot as plt
from matplotlib.widgets import Button, TextBox
from visualqc import config as cfg
from visualqc.utils import remove_matplotlib_axes
class BaseReviewInterface(ABC):
"""Class to layout interaction e... |
dbb4f301be394c314df6a2b5f3052dc1bf92c8a9d1b47deba955aebe3d1edbf9 | Python | 6,264 | 175 | import datetime
import logging
import time
from .dist_util import get_dist_info, master_only
initialized_logger = {}
class MessageLogger():
"""Message logger for printing.
Args:
opt (dict): Config. It contains the following keys:
name (str): Exp name.
logger (dict): Contains... |
f85498efadadf05bcb54acfcda2289463d6a997e2e6fecfc15f5fb6ffee8fef6 | Python | 6,265 | 181 | import sys
sys.path.append("/tudelft.net/staff-bulk/ewi/insy/DBL/plent/NeuralODEs/jax_neural_odes")
sys.path.append("/home/plent/Documenten/Gitlab/NeuralODEs/jax_neural_odes")
import pandas as pd
import numpy as np
import diffrax
import jax.numpy as jnp
import jax
import optax
import argparse
jax.config.update("jax_... |
2047b429beb1265bb3a0f0c75fad86840bc79065738632279ce2d3363c71762b | Python | 6,266 | 117 | import numpy as np
import os
import itertools
import matplotlib.pyplot as plt
from sklearn.decomposition import PCA
from grid_cell.manifold_fitter import Avg_Fitter
from grid_cell.ggpr import GGPR_Fitter
from grid_cell.gkr import GKR_Fitter
from grid_cell.gwpr import GWPR_Fitter
from grid_cell.manifold_fitter import la... |
a4ccc1b93adae97dcf016cfc53bc9a8c21a3e37a3c207e415a77ebaf90a0a2b4 | Python | 6,270 | 140 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 7 13:23:00 2022
@author: george
"""
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.transforms as transforms
import numpy as np
import pandas as pd
import seaborn as sns
from importlib import reload
from matplotlib.color... |
bfbacac94a9ee3261404813cbfb0769c04ffbcc665b8dbe7453490dfe91ee800 | Python | 6,270 | 215 | #*******************************************************#
# Classes used as configuration files
#*******************************************************#
class datasetConfig:
'''
Class for defining dataset parameters: shape, split ratio, augumentation etc.
'''
'''
Labes_csv_path: Root directory w... |
1734446a55039d6e854a244e8392e53b6a140a0dd077ae5c2c2ecc11b8430825 | Python | 6,272 | 160 | import math
from os.path import join as pjoin
from collections import OrderedDict
import torch
import torch.nn as nn
import torch.nn.functional as F
def np2th(weights, conv=False):
"""Possibly convert HWIO to OIHW."""
if conv:
weights = weights.transpose([3, 2, 0, 1])
return torch.from_numpy(wei... |
7b722a3ef6ae88e7e45db485508a036f92cc876b3ae01ae83ce84c536a219862 | Python | 6,272 | 176 | # -*- coding: utf-8 -*-
"""Layers that operate regularization via the addition of noise.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from ..engine.base_layer import Layer
from .. import backend as K
import numpy as np
from ..legacy import interfaces
... |
f86326b7acfc50c3f73252ffb9b072fe186caae9b95f91cdf3650d70397c52b0 | Python | 6,273 | 148 | # %% libraries
import os, glob, re
import shutil
import gzip
from os.path import join
import nilearn
from nilearn import image, plotting, masking
import numpy as np
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import itertools
import pathlib
import argparse
# %% ------------------------------... |
586eb2feaf5329644915ed77d24b558d266654ff91eb979f1f437a0354e4d5ac | Python | 6,274 | 182 | """Lineage cache for taxonomy lookups.
Provides efficient access to species lineages from taxa.db or traverse.pkl.
Used by tax_scope filtering to determine if species belong to a taxonomic clade.
"""
import os
import pickle
import sqlite3
class LineageCache:
"""Cache for species lineages.
Maps species taxi... |
bd3638339462031060cb4e1680fa34cc03c564368ef6863d3f7a648cbb8f3dd9 | Python | 6,274 | 169 | """Step-5 dashboard tab for PSTH significance comparisons.
Reads the ``significance_<comparison>.h5`` tables written into
``psth_significance_output/`` and plots the selected comparison. Output directories
analyzed without the significance parameter hold no such tables, so the tab renders a
short note instead and can ... |
0c89b66b476997de090e1a13f924e1d7c65281a8e2d97ea7298fbefaeabd4c39 | Python | 6,276 | 127 | # 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... |
b1ec5be1aa8a92d11b9bb6547beaa866e58578e3ffddccf63cd4d8770525e792 | Python | 6,277 | 215 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 27 16:03:36 2023
@author: george
"""
%matplotlib qt
%gui qt
import warnings
warnings.simplefilter(action='ignore', category=Warning)
import numba
import numpy as np
import pandas as pd
from tqdm import tqdm
import os, glob
import json, codecs... |
549ee7ad421429e1263a51e73b8de1a642905985db77cabfb97bd465d261b832 | Python | 6,280 | 190 | import logging
from functools import partial
import numpy as np
import torch
from e3nn import o3
from fire import Fire
from mace import data, modules, tools
from mace.tools import torch_geometric
from mace.tools.scripts_utils import get_dataset_from_xyz
import wandb
from energy_model.diffusion_tools import (
EDML... |
73f94efbc1614bf3e3ec10593173faed32c5dbf5ef6032511a03f9cbbc3ced8c | Python | 6,280 | 185 | import numpy as np
import pandas as pd
import torch
import torch.nn as nn
import torch.nn.functional as F
from torchdiffeq import odeint
from .mixin import scviMixin
device = torch.device('cuda') if torch.cuda.is_available() else 'cpu'
class VAE(nn.Module, scviMixin):
def __init__(self, input_dim, hidde... |
bea669a9f353b6bfe132fd4beb227179ba9f53bf7faf516602a808ff8477a35b | Python | 6,283 | 217 | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File : zhipuai_llm.py
@Time : 2023/10/16 22:06:26
@Author : 0-yy-0
@Version : 1.0
@Contact : 310484121@qq.com
@License : (C)Copyright 2017-2018, Liugroup-NLPR-CASIA
@Desc : 基于智谱 AI 大模型自定义 LLM 类
'''
from __future__ import annotations
import l... |
7c483aabb8d6a2b29e6a50215dee312ad69d8ab59f1827d763a28b5931947733 | Python | 6,285 | 135 | # 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... |
6c1aaa25992bc95c5f1a11eca844e819699267330d8d3703ac1ec6d2314df024 | Python | 6,288 | 149 | import torch
import torch.nn as nn
import torch.nn.functional as F
from timm.models.layers import trunc_normal_, DropPath
from functools import partial
class LayerNorm(nn.Module):
r""" LayerNorm that supports two data formats: channels_last (default) or channels_first.
The ordering of the dimensions in the inp... |
c780af73a56cad5e3dbecd1ff3ade88701c7bdccf131bfcaffcd6b899155e490 | Python | 6,288 | 206 | import os
from itertools import product
from collections import namedtuple
import torch
from einops import rearrange, repeat, reduce, einsum
from equiformer_pytorch.irr_repr import (
irr_repr,
rot_to_euler_angles
)
from equiformer_pytorch.utils import (
torch_default_dtype,
cache_dir,
exists,
... |
3a22df064607ca2c38424b8ae5f323029b79cab7cb4b4c097e5753f8270db3a3 | Python | 6,291 | 165 | """
This scripts trains the main graphTRIP model on the primary dataset.
Dependencies:
- experiments/configs/graphtrip.json
Outputs:
- outputs/graphtrip/weights/
- outputs/graphtrip/permutation_importance/
- outputs/graphtrip/transfer_atlas/schaefer200/
- outputs/graphtrip/transfer_atlas/aal/
- outputs/graphtrip/pred... |
526435f2987d28f162c3acd71d6d738962ab8240743b600812f430a664cb7c78 | Python | 6,292 | 126 | import os
import re
# import lmdb
import json
import pickle
import numpy as np
import pandas as pd
from p_tqdm import p_map
from pyxtal.symmetry import Group
from sklearn.model_selection import train_test_split
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
from ocpmodels.datasets import SinglePointLmdbDatas... |
7ba1cb44e6cec5821db60ac2a34760dce3ce67c85ec794e5084bd7dc76206a62 | Python | 6,294 | 137 | import time, os, sys
import numpy as np
import dask
from dask.distributed import Client, performance_report, LocalCluster
import nearl
from nearl import features, utils, _tempfolder
# Only needs the fingerprint of the
def parallelize_traj(traj_list, focused_res):
traj_list = [i for i in traj_list]
st_this = time... |
be15673a923ae7daf15e03f891d22ae8f7212e1a501e5eadc7e09c3f303a9344 | Python | 6,294 | 210 | from rest_framework import status
from medperf.tests import MedPerfTest
from parameterized import parameterized, parameterized_class
class DatasetTest(MedPerfTest):
def generic_setup(self):
# setup users
data_owner = "data_owner"
prep_mlcube_owner = "prep_mlcube_owner"
self.crea... |
121c138e0e16a6e7db2e9987ba119b6cf0df72bd34c82dc8b9f8bbff3b4df616 | Python | 6,295 | 185 | """
Cutadapt doesn’t have a stable API, yet. This is an attempt to document how
one currently needs to use Cutadapt from Python to do certain things,
mostly in order to figure out where improvements need to be made.
The tests in this module do not check results, they are just here to
ensure that the code as shown can ... |
4afb198c0d5a55cd0de786060310cf51c2045520476f7d757cc32260c35dcbf7 | Python | 6,297 | 143 | import requests
import os
from .ProvenanceObject import ProvenanceObject
from .transformation import Transformation
from .attribute import Attribute
from .attribute_type import AttributeType
from .set import Set
from .set_type import SetType
dfa_url = os.environ.get('DFA_URL', "http://localhost:22000/")
class Dataf... |
245c1c5e3a79d38dbf7ffdbcc011d3c81ab12b22b3767c7e8657ecab5279d36c | Python | 6,298 | 204 | import pytest
import numpy as np
from keras.utils.test_utils import get_test_data
from keras.models import Sequential
from keras.layers.core import Dense, Activation
from keras.wrappers.scikit_learn import KerasClassifier, KerasRegressor
input_dim = 5
hidden_dims = 5
num_train = 100
num_test = 50
num_classes = 3
bat... |
475a8012518240196ac5f079284d031ec26b7b245a6f24b9795ee1ed99d66bd4 | Python | 6,298 | 177 | """Checks for the installation validator, in particular the GPU-less paths."""
import contextlib
import os
import subprocess
import sys
import textwrap
import numpy as np
import pytest
from nearl import valid_installation as V
def _extension_built():
try:
# The import itself is the check: the .so can e... |
f5b53d8de1355a51fc5f96a97d06cfdb3c4ece5271329167c43ae4e23685a4ff | Python | 6,307 | 169 | from dfa_lib_python.dataflow import Dataflow
from dfa_lib_python.transformation import Transformation
from dfa_lib_python.attribute import Attribute
from dfa_lib_python.attribute_type import AttributeType
from dfa_lib_python.set import Set
from dfa_lib_python.set_type import SetType
from dfa_lib_python.task import Task... |
c021916b591aac874e3aada554cd9e17ea1d250cf72dbc2d5c9b3030bbf61c73 | Python | 6,311 | 168 | from __future__ import print_function
from config import cfg
import os.path as osp
import pdb
import tqdm
import os
import sys
import json
import numpy as np
from model import Vector
from data.data_init import Dictionary, filter_answers, create_ans2label, compute_target, compute_target
class Runner:
def __init__... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.