sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
01bec0dd1beaeeb27e95fa100949d938746b25fa80aeb8f1e46f4b5c383e7791 | Python | 8,724 | 240 | import numpy
import torch
import sys
sys.path.append('../../')
from BrainAlign.code.utils import load_data, set_params, evaluate
from BrainAlign.code.module import HeCo
import warnings
import datetime
import pickle as pkl
import os
import random
from BrainAlign.code.utils.logger import setup_logger
warnings.filterwarni... |
b0c955993bffccd8209fae3128befe400237785d7f0b3b7a12e7f5fca56f4aeb | Python | 8,725 | 254 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import sys
if '../../../embeddings' not in sys.path:
sys.path.append('../../../embeddings')
from seq2tensor import s2t
import keras
from keras.models import Sequential, Model
from keras.layers import Den... |
e979c79382537506b1b75cf40dcf0ec19556e0ac01a9047c2c9d742341b7096f | Python | 8,727 | 228 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2023 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for d... |
2208b754c470211eafaeca04a81dede1fab74ffc06d0172d711d0b3411a39430 | Python | 8,730 | 251 | # Copyright (c) 2023 Shihao Ma, Haotian Cui, WangLab @ U of T
# This source code is modified from https://github.com/yuyangw/MolCLR
# under MIT License. The original license is included below:
# ========================================================================
# MIT License
# Copyright (c) 2021 Yuyang Wang
#... |
7b82254bfda65401e9bcf7269a5065752cc6fb4ab0af885108a5f7a2f4ee9047 | Python | 8,735 | 209 | import pytest
@pytest.mark.gpu_needed
@pytest.mark.parametrize("platform_type", ["CUDA","OpenCL"])
def test_gpu_platforms(platform_type):
import logging
import os
import pathlib
import time
import numpy as np
from openmmtools.integrators import PeriodicNonequilibriumIntegrator
from pkg_re... |
dc521a82055079eb9af277c429d72109eb19e71a90a4f60e44a01fbbd1cef1a8 | Python | 8,737 | 254 | # builtin modules
import json
import re
import logging
# third party modules
import numpy as np
try:
from scipy.spatial import cKDTree
except BaseException as E:
from .exceptions import ExceptionModule
cKDTree = ExceptionModule(E)
# pnabind modules
from pnabind.structure.data import data
from pnabind.mesh... |
53d083c6272da2459546058a66f9e9f4c158e80f9b40a9ae11d2309c6f54c557 | Python | 8,739 | 275 | import numpy as np
from fury import actor, window
from dipy.direction.peaks import peak_directions
from scipy.special import erf
from numpy.lib.scimath import sqrt
from scipy.interpolate import interp1d
from numpy.lib.stride_tricks import as_strided
import numbers
## PEAKS
def peak_directions_vol(odfs, sphere, r... |
f6650d46fb430b6d48ae751f4883083b43a1e801aa69feff11f2a43fff5e0b70 | Python | 8,743 | 254 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import sys
if '../../../embeddings' not in sys.path:
sys.path.append('../../../embeddings')
from seq2tensor import s2t
import keras
from keras.models import Sequential, Model
from keras.layers import Den... |
4c1cdb08351ca3a4e290e5b8f77fc171a793d8e5aa906a493d0112ab5fd7104d | Python | 8,753 | 270 | import torch
from bindsnet.learning import (
MSTDP,
MSTDPET,
Hebbian,
PostPre,
Rmax,
WeightDependentPostPre,
)
from bindsnet.network import Network
from bindsnet.network.nodes import CSRMNodes, Input, LIFNodes, SRM0Nodes
from bindsnet.network.topology import Connection, Conv2dConnection
class... |
05c8ffd7b0a4804c7049cf6a4a51826d1768158269a0e1090d93a66994a7d1bd | Python | 8,754 | 229 | # This file aggregates and plots the results from the experiment
# One figure for r2, one for mse
# Label with linear/poly scaling_type linear/ffnn
# Load all files in directory
from os import walk
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import pdb
SMALL_SIZE = 22
MEDIUM_SIZE = 26
BIG... |
dba83c445c391d6a79ae20d5d7fddb964b2baa386888da41bd70ff9bf9b87462 | Python | 8,754 | 218 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2026 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for detai... |
4fbccd82f89762fc53bfd9af3ac61b918cb23724c86a3b512243467ee0a4d780 | Python | 8,761 | 170 | import torch
import torch.nn.functional as F
import torch.nn as nn
from torch import Tensor
from nnunet.network_architecture.neural_network import SegmentationNetwork
import gconv.gnn as gnn
class GMaxSpatialPool3d(nn.MaxPool3d):
"""
Performs spatial max pooling on 3d spatial inputs.
"""
def forward(s... |
7764c88a65e00a8a40f9ec556686696f8482056564e83acac150a2e4bb6ad314 | Python | 8,763 | 184 | import click
import logging
import os
from pathlib import Path
from data import DataLoad
from utils import Utils
from model import Models
import numpy as np
import matplotlib.pyplot as plt
from Download import downloader
from pathlib import Path
import seaborn as sns
from sklearn.model_selection import train_test_split... |
bebae073caf0876b5dc8368a511e515fb551a7665084fe33c9e116edb6882b14 | Python | 8,764 | 172 | import mxnet as mx
import logging
from nowcasting.ops import *
from nowcasting.operators.common import identity, grid_generator, group_add, constant, save_npy
from nowcasting.operators.conv_rnn import BaseConvRNN
import numpy as np
def flow_conv(data, num_filter, flows, weight, bias, name):
assert isinstance(flow... |
dbe49498b1aaba06d09f7315c42d36f7b4ce9c466d4b9ad75e6904e252bbe9c7 | Python | 8,764 | 219 | import copy
import json
import logging
import sys
from io import open
import torch
from torch import nn
logger = logging.getLogger(__name__)
class BertConfig(object):
"""Configuration class to store the configuration of a `BertModel`.
"""
def __init__(
self,
vocab_size_or_config_json_fil... |
767a2ea595654888a313bb701cb1d08f2cfaabb6b572ad48704e548c637647c2 | Python | 8,770 | 218 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2023 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for d... |
48e5eba5bb7a05f27e6399fd01886784e2195f2576d15be8edd2ee948d6cf348 | Python | 8,773 | 251 | """
Util functions for using pre-defined DFT basis sets and even-tempered augmentation.
"""
import itertools
import logging
from typing import Dict, Optional, Sequence
import basis_set_exchange as bse
import numpy as np
from scdp.common.constants import orbital_config
logger = logging.getLogger(__name__)
# Per-elem... |
d930d3f1993eb5472402b547ec2b255153e8f3cd087c17f9f356cdf70a568c72 | Python | 8,787 | 210 | # -*- coding: utf-8 -*-
# :noTabs=true:
import os, sys, subprocess, stat
import time as time_module
import signal as signal_module
class NT: # named tuple
def __init__(self, **entries): self.__dict__.update(entries)
def __repr__(self):
r = 'NT: |'
for i in dir(self):
if not i.star... |
924c26fc4c67751c06068378f96854749f0f64607240e28a1e53be286d47002c | Python | 8,788 | 239 | # Copyright (c) 2023 Shihao Ma, Haotian Cui, WangLab @ U of T
# This source code is modified from https://github.com/yuyangw/MolCLR
# under MIT License. The original license is included below:
# ========================================================================
# MIT License
# Copyright (c) 2021 Yuyang Wang
#... |
d46a89191c644c83ad93c46dac8c37ad9ea355d476ff365634c6061b39a0d246 | Python | 8,796 | 218 | import torch
import numpy as np
from torch import nn
import torch.nn.functional as F
device = "cuda:0" if torch.cuda.is_available() else "cpu"
conv_filters = [[1,32],[3,32],[5,64],[7,128]]
embedding_size = output_dim = 256
d_ff = 256
n_heads = 8
d_k = 16
n_layer = 1
smi_vocab_size = 53
seq_vocab_size = ... |
8a9d869c4dd52e3389ab1e794ad83abe42c4bc455ecb88f6fcf335bbb424c9cf | Python | 8,798 | 174 | # use this in a tutorial as example of building new workflow from existing TwoPhotonImaging
import os
import time
import numpy as np
import matplotlib.pyplot as plt
# grabbing functions from .utils_funcs that are used in this script - Prajay's edits (review based on need)
from imagingplus._archive.paq import PaqData... |
4de86ca9515f5513794c296d89625651b8121e2c2c51c79331e7188d3673f0b5 | Python | 8,802 | 158 | # 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... |
5bcaf4a2b7cb85b4e7a049d639c6050d7abfc850d6506848467e43c27f6406b1 | Python | 8,810 | 245 | import math
import numpy as np
import torch
import torch.nn.functional as F
from tqdm import tqdm
from Bio.PDB.PDBParser import PDBParser
from Bio import SeqIO
import torch
import torch_geometric
import torch_cluster
from scipy.spatial.transform import Rotation
import os
import gc
import pickle
import pdb
NUM_TO_LETTE... |
4d2bd939864d651cb3ae51ef771aa55e74300471c22ab9d7115ade43740f2439 | Python | 8,811 | 302 | """Test logic on base chain class."""
import re
import uuid
from pathlib import Path
from typing import Any
import pytest
from langchain_core.callbacks.manager import CallbackManagerForChainRun
from langchain_core.tracers.context import collect_runs
from typing_extensions import override
from langchain_classic.base_... |
13fc3c879ffc2d6daf07a2c25b78574c5fcfd3374ecc0f39fb3b545e20275d26 | Python | 8,813 | 223 | import os
import numpy as np
import pandas as pd
import torch
import torch.optim as optim
from os.path import join
from tqdm import tqdm
from sklearn.metrics import mean_absolute_error, mean_squared_error
from torch_geometric.data import DataLoader
from core.network.model.encoder.gnn.gnn import GNN_graphpred
from re... |
2683d8c295de99c1eb729690a6a1cb7d337d11df60bae32b97c044ba69ae90d9 | Python | 8,814 | 237 | import os
import torch
import numpy as np
from glob import glob
from torch.utils.data import Dataset
import h5py
import itertools
from torch.utils.data.sampler import Sampler
class BraTS2019(Dataset):
""" BraTS2019 Dataset """
def __init__(self, base_dir=None, split='train', num=None, transform=None):
... |
c4a8a1d1cf18c6e7e7f101119511d57c4b6ba30c4ee6f9c781be848c05343f10 | Python | 8,814 | 189 | import os
from copy import deepcopy
import sys
from shutil import copyfile, rmtree
import json
import configargparse
import configparser
from os.path import expanduser
import click
import numpy as np
from synister.read_config import read_train_config, read_predict_config
p = configargparse.ArgParser()
p.add('-d', '--... |
60c9e72d08eda70cd23f66929022e6c32655a21d4218a9e2017fb7b499f2f72e | Python | 8,815 | 199 | import torch
import torch.nn as nn
import seq_des.util.data as data
import common.atoms
def init_ortho_weights(self):
for module in self.modules():
if isinstance(module, nn.Conv2d):
torch.nn.init.orthogonal_(module.weight)
elif isinstance(module, nn.ConvTranspose2d):
torch.... |
88ee8433fceeffab200baf43686fc3fa50f507c06f135fde5609cd777f9bbe0f | Python | 8,821 | 221 | import os
import h5py
import numpy as np
import scipy as sp
import anndata as ad
import pandas as pd
import scanpy as sc
import scvelo as scv
import loompy as lp
import cellrank as cr
os.chdir('/home/jfleck/projects/cutntag/')
#### Join spliced and unspliced counts ####
all_samples = os.listdir('data/individual_sam... |
73db1404b8b7c081e43fbcbdfd2cb2f0d93cecfde5c390c0ac86579d1c670af4 | Python | 8,825 | 266 | import numbers
import random
import numpy as np
from PIL import Image, ImageOps
import torch
class RandomCrop(object):
def __init__(self, size):
if isinstance(size, numbers.Number):
self.size = (int(size), int(size))
else:
self.size = size
def __call__(self, image, la... |
78b5ecc886e4e216452ee75177eb86031a552237d14cb6a26e832128e98054e0 | Python | 8,825 | 342 | """Specify dummy networks to test vulcan functionality."""
import pytest
import torch
from torch.utils.data import TensorDataset
from vulcanai.datasets import MultiDataset
from vulcanai.models import ConvNet, DenseNet
from torch.utils.data import DataLoader, Subset
@pytest.fixture(scope="module")
def conv1D_net():
... |
42571ff85c2858e59ef445c3984e527ec33967ff83dee4ad1bf77a4124338c37 | Python | 8,828 | 262 | import os
import sys
import re
import types
import itertools
import numpy
import cgat.Stats as Stats
import cgat.IndexedGenome as IndexedGenome
from cgatReport.Tracker import *
from PeakcallingReport import *
##########################################################################
#################################... |
78d0586a0c1cb0b362bfcf9975328ee244285c4c4062a18024496e6066bec0b7 | Python | 8,828 | 253 | """
2023.08.30
author: femke.hurtak@epfl.ch
Script to draw the neurons directly downstream of a given neuron.
"""
import os
import matplotlib.pyplot as plt
import pandas as pd
from tqdm import tqdm
import plot_params
import neuron_params
from loaddata import load_nodes_and_edges, get_name_from_rootid
from common imp... |
aa4daa3b985870a8ef1f3ab90fe391046653b07111877f73bf870df877684610 | Python | 8,828 | 260 | import json
import logging
import os
import re
import time
import numpy
import torch
from openfold.model.model import AlphaFold
from openfold.np import residue_constants, protein
from openfold.np.relax import relax
from openfold.utils.import_weights import (
import_jax_weights_,
)
from pytorch_lightning.utilitie... |
a1f73bce57f59e0ae42f67abc9a9e43d0ab8a8b313010e52ef1b62ba32c965ee | Python | 8,830 | 193 | import torch # torch will allow us to create tensors.
import torch.nn as nn # torch.nn allows us to create a neural network.
import torch.nn.functional as F # nn.functional give us access to the activation and loss functions.
from torch.optim import SGD # optim contains many optimizers. Here, we're using SGD, stochasti... |
e2e361e9512861d3a03ebcb43e1f00e08281913a9649e109ea009f90a8aa3b24 | Python | 8,830 | 187 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import nibabel as nib
import numpy as np
import os
import sys
import traceback
def zscore_normalize_data(data, mask=None, epsilon=1e-6, zero_out_background=True):
"""
Performs Z-scoring on the input data.
If data is 4D, Z-scoring is performed ... |
5f6d3d1ad0872e65ccfda64faee0c5e41973a2b9cd52b0dc2e2dde502008ba6d | Python | 8,835 | 268 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2026 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp,... |
ad6dd72cbee493e53458b762833c6ee0c1a5d3402b223577ae3193e17197f925 | Python | 8,837 | 237 | import pickle
import os
from rdkit.Chem import Draw
from utils import BondAdder
from rdkit.Chem.rdForceFieldHelpers import UFFOptimizeMolecule
from rdkit import Chem
from rdkit.Chem import AllChem
import numpy as np
import scipy as sp
### config
save_mol = True
uff = True
uff_w_rec = False # UFF in the context o... |
1c45d0ffe1cfd2b13324dc4d22b2862e8cd309ad295920a4dc213d9bfad2a004 | Python | 8,841 | 177 | from omegaconf import OmegaConf
from sklearn.metrics import roc_auc_score
import pandas as pd
import numpy as np
from scipy import stats
import nibabel as nib
# calculate p-value from auc using permutation
def calc_pval_auc_permutation(y, x, auc, nsamples=1000):
auc_permut = np.empty(nsamples)
idx_p = np.arang... |
73331726da18b31a0d52c3e33b00ba0c8381b37ceb169a1505b4e1cf839b5e87 | Python | 8,841 | 186 | import os
import glob
import numpy as np
import matplotlib.pyplot as plt
from utils.constants import ALL_MODELS
from paths import TRAINING_DATA_PATH, TEST_DATA_PATH
from utils.distribution_distance import compute_jsd
from utils.compute_ensemble_average import compute_ensemble_average
RECOMPUTE = False
def compile_di... |
4a7e5c8fa18cc63baf0423b5c8bac9404189ff6313669bdbd1f384ae63742fc3 | Python | 8,848 | 221 | import numpy as np
from numba import jit, float32, boolean, int32, float64
from nowcasting.hko_evaluation import rainfall_to_pixel
from nowcasting.config import cfg
@jit(float32(float32, float32, boolean))
def get_GDL_numba(prediction, truth, mask):
"""Accelerated version of get_GDL using numba(http://numba.pydata... |
6d24f740b3c5ecf1caa58457c16a1f1ca3d06055d6f1a3cfa57fed66c3b180ee | Python | 8,848 | 311 | """
2023.08.30
author: femke.hurtak@epfl.ch
Script to compare the network statistics with know graph models.
"""
import os
import numpy as np
import matplotlib.pyplot as plt
import networkx as nx
from scipy import optimize
import seaborn as sns
import plot_params
from loaddata import load_graph_and_matrices
from con... |
419e3c07252fad111dfe522141587b97937ee01dab9b85ddff29800d015692b1 | Python | 8,851 | 268 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2023 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp,... |
0a4cf406846db93044d83ed53cf2a5ffe30b0f8e40cd96d2c3a79ca70c7f6c1e | Python | 8,856 | 281 | # TODO need to update this file to remove duplicates that have been refactored...
import argparse
import sys
from pathlib import Path
from typing import Union
import matplotlib.pyplot
import numpy as np
import pandas as pd
import tifffile as tf
import os
import matplotlib.pyplot as plt
import csv
import math
import co... |
78740151054a4d83eef8c4a0431e386196963cb67fcc57d4bcd803927434e683 | Python | 8,857 | 218 | import torch
import numpy as np
from torch import nn
import torch.nn.functional as F
device = "cuda:0" if torch.cuda.is_available() else "cpu"
conv_filters = [[1,32],[3,32],[5,64],[7,128]]
embedding_size = output_dim = 256
d_ff = 256
n_heads = 8
d_k = 16
n_layer = 1
smi_vocab_size = 53
seq_vocab_size = ... |
c2a083bf0f148a05ee0a72acf4014cfe585b7293bf675077bd58f654b12adb4f | Python | 8,862 | 206 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2023 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for d... |
75c320546bccdfb2e06d132a40bdf8f104328c8b71fca02e0d2e67ddf69eb75f | Python | 8,863 | 181 | import argparse
import h5py
import numpy as np
from sklearn.metrics import confusion_matrix
def extract_chrom_lengths(chrom_file):
"""Extract chromosome lengths from a text file."""
ids = np.loadtxt(chrom_file, usecols=0, dtype=str)
lengths = np.loadtxt(chrom_file, usecols=1, dtype=np.int32)
chrom_len... |
1e757330dd107a08aa2ffcd0cb7964fac175fabd91ddb319744fce0021d4ab9e | Python | 8,870 | 251 | import asyncio
import gc
import math
import threading
import time
import weakref
from collections.abc import AsyncIterator, Callable
from typing import Any, TypeVar
from langchain_core.tracers.event_stream import _AstreamEventsCallbackHandler
from langchain_core.tracers.log_stream import LogStreamCallbackHandler
from ... |
3ae583c85bd1a98edd93afc913ea669b65fc51e02d6258e87ea7e13c0b0cc8b3 | Python | 8,870 | 267 | import numpy as np
import MDAnalysis as mda
import MDAnalysis.lib.distances as ld
import gpcrmining.gpcrdb as db
def read_atom_group_distances(pdb, xtc, sel_a='protein', sel_b='resname LIG',
first_frame=0, last_frame=None, step=1,
naming='plain'):
"""
... |
701267861d538b09f2bfc173f4671a89c9f9ad74e3822c01cfbf3c6dbfec74dd | Python | 8,875 | 239 | import re
import os
import pytest
import mne
import numpy as np
from pyriemann.datasets import make_matrices
from coffeine import make_coffeine_data_frame, compute_coffeine
from coffeine.power_features import compute_features, get_frequency_bands
data_path = mne.datasets.sample.data_path()
data_dir = os.path.join(... |
9c95a58a341ae342bfcf629eddee2161217f950c715edaff2f508c9bc024421e | Python | 8,875 | 206 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2026 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for detai... |
08bf131907678326cdbc39c176b957876bdd3e6644c9e82c50bac7b447cd7c1e | Python | 8,878 | 232 | """
Author: Benny
Date: Nov 2019
"""
import os
import sys
import torch
import numpy as np
import datetime
import logging
import provider
import importlib
import shutil
import argparse
from pathlib import Path
from tqdm import tqdm
from data_utils.ModelNetDataLoader import ModelNetDataLoader
BASE_DIR = os.path.dirna... |
df7c1a72bc05d884bf77fca39ca7dc0dec8feaadeea7a8ff73610d133bc2cf41 | Python | 8,878 | 253 | """Embeddings tests."""
import contextlib
import hashlib
import importlib
import warnings
import pytest
from langchain_core.embeddings import Embeddings
from typing_extensions import override
from langchain_classic.embeddings import CacheBackedEmbeddings
from langchain_classic.storage.in_memory import InMemoryStore
... |
2b5c2b53dc9fb6cd278c0b9668ff51d3f7af7d17e308b3206ecf2b602838d831 | Python | 8,879 | 245 | # Description: This script is used to test the classification performance of the three different harmonization methods against unharmonized data.
# The script performs a one-vs-one classification (each ABCD scanner is compared to each other ABCD scanner) and plots the ROC curves for each comparison.
# Individual cuvers... |
ae7e03eb3b92e327e27f06f36397263cccdf8677486575b4c2a1f3ade8abfb72 | Python | 8,879 | 177 | import logging
import numpy as np
from openmmtools.integrators import PeriodicNonequilibriumIntegrator
from openmmtools.utils import get_fastest_platform
from simtk import unit
from simtk import openmm
import os
import pathlib
from pkg_resources import resource_filename
import time
from perses.app.relative_point_mutati... |
bf01b07bbfd2b21bf1be2686f659ef5df4ef4cbb266e956ffe4d62399135b060 | Python | 8,879 | 231 | """Methods for searching for optimal primers through a genome.
This makes heavy use of the guide_search module.
"""
import logging
from easyDesign import guide_search
from easyDesign.utils import guide
logger = logging.getLogger(__name__)
class PrimerResult:
"""Store results of a primer cover at a site."""
... |
c721e82f7e78d896d25c438b7382683d10f82e9bdac5965cfd422f28d322a059 | Python | 8,880 | 228 | import numpy as np
import platform
import pickle
import json
import os
class Discretizer:
def __init__(self, timestep=0.8, store_masks=True, impute_strategy='zero', start_time='zero',
config_path=os.path.join(os.path.dirname(__file__), 'resources/discretizer_config.json')):
with open(con... |
29927aa6adeee887f8c405c192fcaf45bf678368ab0f0fa54359421e99125658 | Python | 8,881 | 112 | """Field-data figures (Changan EVs, protocol P5).
fig19_field_labels.pdf (a) OCV-SOC table from wake-up pairs, (b) SOH against equivalent full cycles for every vehicle with the fleet trend,
(c) per-vehicle trend with use for three label constructions (BMS start SOC, OCV-calibrated, OCV + te... |
15e9adb547ef47d14c4521dc5db9560aa6316d24619d82ca535acc3b5bbcecfc | Python | 8,885 | 184 | import argparse
import os
import random
import logging
import numpy as np
import mxnet as mx
import mxnet.ndarray as nd
from mnist_rnn_factory import MovingMNISTFactory
from nowcasting.config import cfg, cfg_from_file, save_cfg
from nowcasting.helpers.gifmaker import save_gif
from nowcasting.encoder_forecaster import e... |
56dead65d48ec681cc080293d1bdc20c6a6e06680dc8d64bf1683377e41c3687 | Python | 8,885 | 216 | import numpy as np
import torch
import ttach as tta
from typing import Callable, List, Tuple
from pytorch_grad_cam.activations_and_gradients import ActivationsAndGradients
from pytorch_grad_cam.utils.svd_on_activations import get_2d_projection
from .image import scale_cam_image
from pytorch_grad_cam.utils.model_targets... |
0ee57d263b656972dd9e7aa3285a7ad5e5ef3eddb23e9194293e99b97abd9eba | Python | 8,887 | 253 | """
Defining structural features to be computed
"""
import logging
import numpy as np
import pandas as pd
from scipy import signal
import csv
import itertools
L = logging.getLogger(__name__)
EXPECTED_KEYS = ['distances','angles','areas','ratios','markers']
class StructuralFeatures:
""" The collection of str... |
9ce8b19cd7bc3f3d094cf7ed80f76cba86520cb2b4b8fa3e7e3fd47dcb17de16 | Python | 8,889 | 236 | # this script inference based on trained models
# Mask-RCNN on detectron2:
# the folder structure should be:
# data/test (images)
# pretrained: the pretrained model model_best.pth
# Running:
# module load Detectron2/0.3-fosscuda-2019b-Python-3.7.4-PyTorch-1.6.0
#
import argparse
import os
import random
import shu... |
7fb9042d669095cb5de57b7593318a42817bf0aec169829f27d1a56ac38c2d03 | Python | 8,893 | 185 | from edNEGmodel.edNEGmodel import *
from scipy.integrate import solve_ivp
import numpy as np
def solve_edNEGmodel(t_dur, alpha, I_stim, stim_start, stim_end):
"""
Solves the edNEG model (Sætra et al. 2020) using the solve_ivp function from SciPy.
Arguments:
t_dur (float): duration of simulation [s... |
9d2bc46b7cd1835d3bde1529118d683875843c610087baf0552a2bd89dc753e0 | Python | 8,895 | 201 | import sys
import os
from sklearn.model_selection import train_test_split
import argparse
import h5py
import numpy as np
# Adapted from https://github.com/weberlab-hhu/helixer_scratch/blob/master/data_scripts/n90_train_val_split.py
def split_coords_by_n90(genome_coords, val_fraction):
"""Length stratifying split... |
fe6a0355a9134299fa649e3faf6b884129c92fbb21f1b03bc4df8300bac3dd74 | Python | 8,900 | 262 | """
Base class for toolkit wrappers. Defines the public API and some shared methods
"""
__all__ = ("ToolkitWrapper",)
from functools import wraps
from typing import TYPE_CHECKING, TypedDict
from openff.toolkit.utils.constants import DEFAULT_AROMATICITY_MODEL
from openff.toolkit.utils.exceptions import (
Incorrec... |
b57319c00c8891bc52c53c66e988d9ae76444984bbdd0893de5ef38579f052e7 | Python | 8,901 | 263 | """
Tests for custom collections classes.
"""
import copy
import pytest
from openff.toolkit.utils.collections import ValidatedDict, ValidatedList
class TestValidatedMixin:
def test_pickle(self):
"""Test pickle roundtripping"""
# TODO: implement this test
pass
class TestValidatedList(... |
20d808b52176f02bec5ce05eeb1d3a7d4a63c2b2fbd824ec56c54bf38dfe997e | Python | 8,903 | 185 | """Resolve and validate the DWI, gradient table and native brain mask."""
from __future__ import annotations
import argparse
import json
import sys
from pathlib import Path
if __package__ in (None, ''):
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
import nibabel as nib
import numpy as np
from ut... |
a16964e96f850d4a6f71ecab8c3132ad620469656de90083d2f8c862626bc24e | Python | 8,903 | 328 | r"""
Performance evaluation metrics
"""
from typing import Tuple
import numpy as np
import pandas as pd
import scanpy as sc
import scipy.spatial
import sklearn.metrics
import sklearn.neighbors
from anndata import AnnData
from scipy.sparse.csgraph import connected_components
from BrainAlign.brain_analysis.typehint im... |
b7e27456b8d47d08c6f98483d1340e05ef78a46fe094b9bcdfbc87211fa3e5f0 | Python | 8,905 | 316 | from typing import Union
import numpy as np
import pandas as pd
import plotly.graph_objects as go
import seaborn as sns
from . import stats
def plot_bar(
df: pd.DataFrame,
ddg_cols: str,
error_cols: str,
exp_col: str = "exp",
exp_error_col: str = "dexp",
name_col: str = "edge",
title: st... |
a74b9efc82b0d646b0ae9568545e38e95d35d89ea28f41057c3167b5e4357156 | Python | 8,909 | 218 | """Parts of this file were developed in conjunction with the DiffDock authors.
https://github.com/gcorso/DiffDock
"""
from data import so3_utils
from data import utils as du
import os
import torch
import numpy as np
def f_igso3(omega, t, L=500):
"""Truncated sum of IGSO(3) distribution.
This function approx... |
f23f3d82d115ae707b4199545788633c68db47950ae2b285155a6c45376eecf3 | Python | 8,910 | 265 | "utils"
from glob import glob
import os
import matplotlib.pyplot as plt
from scipy.stats import entropy
import numpy as np
import torch as T
import pandas as pd
import h5py
import yaml
import json
from omegaconf import OmegaConf
#internal
from src.PICNN.PICNN import PICNN
# from tools.flows import Flow
STYLE_TARGET... |
272b7ed6fb9a2f7573358043af513a0a88d0f4041282b18f153bd9f38e157da4 | Python | 8,912 | 232 | import numpy as np
import tensorflow as tf
from utils.linear_unmixing import linear_unmixing
def load_data_as_tensorflow_datasets(file_paths, num_wavelengths, batch_size=1024, load_strategy=None):
spectra, oxy = preprocess_data(file_paths, num_wavelengths, strategy=load_strategy)
print(np.shape(spectra))
... |
9d485a087f8ed3e9ad9ae19aadae3f31d62c61a2f33229d08725ce111d85944f | Python | 8,914 | 291 | import os
import utils
import numpy as np
import tarfile
import torch
from torch.utils.data import DataLoader
from torchvision.datasets.utils import download_url
class PersonActivity(object):
urls = [
'https://archive.ics.uci.edu/ml/machine-learning-databases/00196/ConfLongDemo_JSI.txt',
]
tag_ids = [
"010-0... |
b2e544cf4fd1e8e5a7f45e14490c03e22a5ca30ebdc8df5d67c2f419aac2a192 | Python | 8,915 | 184 | import os
from copy import deepcopy
from collections import OrderedDict
from itertools import groupby
import warnings
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
def read_chronic_animal_npz(npzpath, keep_valid_only=True):
# TODO process keep_valid_only argument
npzdict = np.load(npz... |
ff348dfe337c52b021d3ab5ef8ec33748690d03d5b759131dda03c3b98df0e04 | Python | 8,915 | 221 | import os
import h5py
import numpy as np
import scipy as sp
import anndata as ad
import pandas as pd
import scanpy as sc
import scvelo as scv
import loompy as lp
import cellrank as cr
os.chdir('/home/jfleck/projects/cutntag/')
#### Join spliced and unspliced counts ####
all_samples = os.listdir('data/individual_sam... |
7a1e6f84d4a00e3589c849c1eb861a19c376ccc981f3d3b02906dc9247057def | Python | 8,919 | 303 | import numpy as np
import pytest
import torch
from chroma.data import Protein
from chroma.layers.structure.backbone import RigidTransformer
from chroma.layers.structure.rmsd import (
BackboneRMSD,
CrossRMSD,
LossFragmentPairRMSD,
LossFragmentRMSD,
LossNeighborhoodRMSD,
)
@pytest.fixture
def backb... |
8c975080f062bcc5078acb968fef25f5b85191dbf109f84d98b9106414a7f1f2 | Python | 8,921 | 268 | # -*- coding: utf-8 -*-
"""
Created on Wed May 5 20:08:52 2021
@author: Xingyan Liu
"""
import came
from came import pipeline, pp, pl
import logging
import os
import sys
from pathlib import Path
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt # optional
import seaborn as sns # optional... |
ace7ea1a547a13779b3d4f1a7ca688c767cf3e10bac77e87201953c243cfa35e | Python | 8,922 | 216 | import sys,os,gc
sys.path.insert(1, os.path.join(sys.path[0], '../../../'))
import numpy as np
import pickle
from Simulator.SimulatorPattern import simulatorPattern
from FiguresFunctions.FiguresPattern import *
import matplotlib.pyplot as plt
import argparse
import itertools
from datetime import datetime
parser = argp... |
baffe1eae609ad9e660a8ac9c0cb77f77d20761ab300e7274f9b0c2c07a13b9c | Python | 8,923 | 222 | import sys,os,gc
sys.path.insert(1, os.path.join(sys.path[0], '../../../'))
import numpy as np
import pickle
from Simulator.SimulatorPatternDual import simulatorPatternDual
from FiguresFunctions.FiguresPattern import *
import matplotlib.pyplot as plt
import argparse
from datetime import datetime
parser = argparse.Argu... |
f2decd2a61af86d10b21e503129859bf59a316b2b8dd29242ebe9fa2cb8c8a68 | Python | 8,923 | 226 | #!/usr/bin/env python
# coding:utf8
import argparse
import sys
import time
import torch
sys.path.append('../')
import vectorize
import yutils
import preprocessing
def classify_batch(args, model, targets, targets_seqlen, targets_mask, tweets, tweets_seqlen, tweets_mask):
"""
Predict a single batch
... |
4c996eec4ac96bb99c8cc3e5f256bd874c999120234f96c08ba8be74310fef17 | Python | 8,930 | 260 | from optimization.EPIOptimize import EPIOptimize
from optimization.LinearSolvers import *
import time
import torch
class GaussNewton(EPIOptimize):
"""
A class for performing EPI-MRI distortion correction using Gauss-Newton optimization with Jacobi smoother.
Attributes
----------
corr_obj : EPIMRID... |
cff83656b81c58a3625c3f588014727ddf62e73b43e3b70ee9425eb29221205a | Python | 8,938 | 330 | """Plasticity using SNN. Section ...."""
import csv
import dataset
import model
import matplotlib.pyplot as plt
import trainer
import torch
def convergence(
device,
data_train,
data_val,
data_test,
timesteps,
epochs,
):
"""Convergence study hidden versus num outputs."""
with open(
... |
3c273e3ce41d4ff875bdbbf53162e43bfff45a312810b870781c9ddaaa20d436 | Python | 8,944 | 240 | # Usage example : python3 make_json_rrbs_polish.py -g gs://my-bucket/rrbs/batch3_20191120/fastq_raw -o `pwd` -r rrbs_batch3 -u -a rat-rn6 -n 1 -p my-project
import argparse
import json
import os
import sys
import gcsfs
import numpy as np
def main(command_args: argparse.Namespace):
fs = gcsfs.GCSFileSystem(args.... |
9f9a69890777cba6cc4a54e482693346a65e637c7d5a065ee4658674845383a5 | Python | 8,947 | 236 | """Helper class for handle symmetric assemblies."""
from pyrsistent import v
from scipy.spatial.transform import Rotation
import functools as fn
import torch
import string
import logging
import numpy as np
import pathlib
format_rots = lambda r: torch.tensor(r).float()
T3_ROTATIONS = [
torch.Tensor([
[ 1.,... |
34a7ee6660889c4bf6ea3eaa11e999c6dd4dfc1974b664a57381643c912298e3 | Python | 8,949 | 241 | import collections.abc as collections
import functools
import logging
import random
import warnings
import os
import sys
from typing import Any, Callable, Dict, Optional, TextIO, Tuple, Type, TypeVar, Union, cast
import torch
from torch import nn
import torch.nn.functional as F
from torch.nn import init
from torch imp... |
2d6cf0542c4b82e25eed19165d6f90d004ae4ced1db426962e47fb6086e085d9 | Python | 8,952 | 230 | import argparse
from pathlib import Path
import numpy as np
import torch
import torch.nn.functional as F
from Bio.PDB import PDBParser
from rdkit import Chem
from torch_scatter import scatter_mean
from openbabel import openbabel
openbabel.obErrorLog.StopLogging() # suppress OpenBabel messages
import utils
from light... |
5a4d22710505194c7b0cafae5186b2e6a14711316d6016bf5ae55d1f0cde2ccd | Python | 8,953 | 218 | from __future__ import annotations
from typing import Any
def merge_dicts(left: dict[str, Any], *others: dict[str, Any]) -> dict[str, Any]:
r"""Merge dictionaries.
Merge many dicts, handling specific scenarios where a key exists in both
dictionaries but has a value of `None` in `'left'`. In such cases, ... |
6e91ee5ecfd6dcd3505ade7d7e6fc17f29c2099783e979b296b7285de86604be | Python | 8,954 | 193 | # default classes designed for parsing MicroscopeMetadata from microscope systems
import os
import xml.etree.ElementTree as ET
from dataclasses import dataclass
# need to implement alternative class constructor using cls.method
from typing import List, Union, Any
from imagingplus.main.subcore import MicroscopeMetadata... |
85888b0158d9156e5c0aec648127ea12317b62e1f25c72b4f798f15280d6b53e | Python | 8,957 | 226 | #import libraries
import numpy as np
import scipy as sp
import ants
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.colors import Normalize
import seaborn as sns
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import MinMaxScaler
from... |
9153ef77f66c3d45829a1747e2057be5b683e037b737a85eb65ef896617e4922 | Python | 8,957 | 241 | import sys
sys.path.append(".")
import os
import argparse
from collections import Counter
import tarfile
import numpy as np
import itertools
from tqdm import tqdm
import smact
from smact.screening import pauling_test
from pymatgen.core import Structure
from pymatgen.analysis.structure_matcher import StructureMatcher... |
91eee815bfa35e97a392170ccf12d9460a3cae8d442241dde829fa5d169fe278 | Python | 8,959 | 206 | from __future__ import division
from __future__ import print_function
import os
import time
import h5py
import random
import argparse
import numpy as np
import torch
import torch.nn.functional as F
import torch.optim as optim
from torch_geometric.data import Data
from models import *
def seed_everything(seed):
ra... |
9211d0ed424f1f0679a6a69b1a373c51b5422f17d0596b9dc915ea4e5c74c56e | Python | 8,969 | 283 | """MAST.py - Parser for MAST files
==================================
:Tags: Python
As of biopython 1.5.6, the MAST parser is broken.
"""
import re
import math
import collections
import numpy
class MAST:
# number of matches
def __init__(self):
self.motifs = []
self.matches = []
class Mo... |
22b716f8d7becb1350a1e6e23b868cc1f1c2b638ea83117a0096938fa966fafa | Python | 8,975 | 234 | # Copyright (c) MONAI Consortium
# 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 agreed to in writing, so... |
39d6f58badd20d64a51996f7327a38bda73a45b54a927d665a3e51b4c5e05955 | Python | 8,976 | 217 | """
Inference script for OMTscoring.
Usage:
run_omt_scoring.py [options] [--help] [<args>...]
run_omt_scoring.py --version
run_omt_scoring.py (-h | --help)
Options:
-h --help Show this string.
--version Show version.
--input_data_file=<string> Path to csv file conta... |
ba171dbf061d7292196bf6f5a2c52604434d3582a9eadd4ba86523032a90ef61 | Python | 8,995 | 251 | import numpy as np
from tqdm import tqdm
from rdkit import Chem, DataStructs
from rdkit.Chem import Descriptors, Crippen, Lipinski, QED
from analysis.SA_Score.sascorer import calculateScore
from analysis.molecule_builder import build_molecule
from copy import deepcopy
class CategoricalDistribution:
EPS = 1e-10
... |
a71b689343d8e6c10c1916add6ddef36158c2f38be6e3ea1a1e7c532586ebb49 | Python | 9,002 | 234 | import os
import re
from torch.utils.data import Dataset
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(THIS_DIR, "spacegroups.txt"), "rt") as f:
SPACE_GROUPS = [sg.strip() for sg in f.readlines()]
ATOMS = ["Si", "C", "Pb", "I", "Br", "Cl", "Eu", "O", "Fe", "Sb", "In", "S", "N", "... |
6a42ad9c977041ad47dd754e0b1daf08d27735226fc252e695d90be6d18172a7 | Python | 9,032 | 234 | # Copyright 2020 - 2021 MONAI Consortium
# 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 agreed to in wri... |
0dec58a10fc4af88121ea4ac6233402c1a57201270d772ec74528c312e2809f6 | Python | 9,037 | 218 | # Reconstruction of representations
# Copyright (c) 2021 Laurent Caplette
import numpy as np
import torch
from torch import nn
import torchvision
import h5py
from robustness.datasets import RestrictedImageNet, ImageNet
from robustness.model_utils import make_and_restore_model
import pickle
from kornia.augmentation imp... |
f5b07ad6cf2f534b080f4ce9db546aafdd820e991aee9fb72d9977c5b3a23d83 | Python | 9,038 | 226 | import torch
from torch_geometric.loader import DataLoader
import os
import pickle
from sklearn.model_selection import KFold
import numpy as np
import random
from torch_geometric.nn import global_mean_pool, GATConv
import torch.nn.functional as F
import torch.nn as nn
from torch import optim
import datetime
# 定义图神经网络模... |
6a92f2d9a555df573d54e5a8606a852ffeb82dfc267d34afb5190d6e8359aad3 | Python | 9,044 | 259 | # Copyright (c) MONAI Consortium
# 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 agreed to in writing, so... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.