sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
af0528a77e65a0a21e4360846cc76d62032c5dfd963e4e81415900ac6683ad8f | Python | 3,205 | 93 | import logging
from pdb2sql import pdb2sql
import freesasa
import numpy
from deeprank.config import logger
from deeprank.features import FeatureClass
from deeprank.operate.pdb import get_residue_contact_atom_pairs, get_pdb_path
def get_atoms_of_iterest(environment, variant, distance_cutoff):
pdb_path = get_pdb... |
153295bda868221ded7b5c77712e92ab54c7dacb341ea01982df42bb162af795 | Python | 3,206 | 96 | import prov.model as pm
from .Core import Core, getUUID
from ..core import Constants
class Derivative(pm.ProvActivity, Core):
"""
Class for NIDM-Experimenent Derivative Objects.
Default constructor uses empty graph with namespaces added from NIDM/Scripts/Constants.py.
Additional alternate constructor... |
44d1670f5195e912571ae882e5a40d8487e1f4f1857152e69cbb6d212ed30794 | Python | 3,207 | 76 | #!/usr/bin/python
# encoding=utf-8
import datetime
import os, sys
import threading
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--type', type=str, default=None)
args = parser.parse_args()
def execCmd(cmd):
try:
print("命令%s开始运行%s" % (cmd, datetime.datetime.now()))
... |
70abc00ae0e7a123cdabcd46cc7f2df43d5bdefe905057f77254481e523cefe2 | Python | 3,207 | 90 | import torch
from src.models.tabular.base import BaseModel
from .repository.models.nam import NAM
from .repository.config.base import Config
class NeuralAdditiveModel(BaseModel):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.build_network()
def build_network(self):
cf... |
34f522742ed61304da86f7a6f90099e23bf1f9fa0f63474d3ab9b879d9c0fa0d | Python | 3,210 | 90 | """ Tools for working with NIDM-Experiment files """
from os.path import basename, join, splitext
import click
from rdflib import Graph, util
from nidm.experiment.tools.click_base import cli
# adding click argument parsing
@cli.command()
@click.option(
"--nidm_file_list",
"-nl",
required=True,
help="... |
c9a2f14fa5fa6cfb8f2397e52b9692862b64d8ff0321893c08dc47ce833b5829 | Python | 3,211 | 82 | import numpy as np
import pytest
import xgboost as xgb
from xgboost import testing as tm
from xgboost.testing.interaction_constraints import (
run_interaction_constraints,
training_accuracy,
)
class TestInteractionConstraints:
def test_exact_interaction_constraints(self) -> None:
run_interaction_... |
ace283fc39f48b25a9efc7b03772228087987e40430323324a0f78c83b826e1f | Python | 3,213 | 71 | """Run the Python code of the README and of the documentation pages, and check that every
`cel.<function>` called in their Python code exists and accepts the keyword arguments used.
The README and the quick start page run exactly as written. The tutorial pages train for 500
epochs, so here every `num_epochs_max` is se... |
2ddec706d8d50dbf07690d6fa5fdca418f60c6316d97df547bd911c905e1e9b8 | Python | 3,214 | 42 | # TODO Sep 08 version
from .base_options import BaseOptions
class TrainOptions(BaseOptions):
"""This class includes training options.
It also includes shared options defined in BaseOptions.
"""
def initialize(self, parser):
parser = BaseOptions.initialize(self, parser)
# HTML visuali... |
366013e2fad1baa6624ca52e3b20939177ac2eab8ff4543112fa1439c1da6d2c | Python | 3,217 | 92 | from dragen.run import Run
#Model details
dimension = 3
box_size = 25
box_size_y = None # if this is None it will be set to the main box_size value
box_size_z = None # for sheet rve set z to None and y to different value than x the other way round is buggy
resolution = 1
number_of_rves = 1
smoothing_flag = False
# B... |
f362d852edabd845a8d2d5ee13b7d1b57ade2246dcd041610aa061d412a74d73 | Python | 3,219 | 97 | from torch.utils.data.dataset import Dataset
from torch.utils.data import DistributedSampler
from torch.utils.data.sampler import Sampler
from typing import Iterator, Optional
from operator import itemgetter
import logging
class DatasetFromSampler(Dataset):
"""Dataset to create indexes from `Sampler`.
Args:
... |
f9022805322a62f4e26ab6e5734bfd551ebf7bda367d9c1e487d9f20a7bd763e | Python | 3,219 | 76 | #!/usr/bin/python
# encoding=utf-8
import datetime
import os, sys
import threading
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--type', type=str, default=None)
args = parser.parse_args()
def execCmd(cmd):
try:
print("命令%s开始运行%s" % (cmd, datetime.datetime.now()))
... |
0388578e8046a5e80da0fe73172e58c3262088ca0df36bfca716d74ee02cd620 | Python | 3,220 | 116 | # Original Matlab code https://cs.nyu.edu/~silberman/datasets/nyu_depth_v2.html
#
#
# Python port of depth filling code from NYU toolbox
# Speed needs to be improved
#
# Uses 'pypardiso' solver
#
import skimage
import scipy
import numpy as np
from scipy.sparse.linalg import spsolve
from PIL import Image
#
# fill_dept... |
3a3d509fab404c52fc01a08950ef5d102433836c47dd248ea5bd13f03986fda3 | Python | 3,220 | 96 | import numpy as np
import scipy.io
import os.path as osp
import sys
sys.path.append('..')
from nilearn import plotting
from functions.def_ROIs_EarlyVisualAreas import roi as ROI
from functions.def_ROIs_DorsalEarlyVisualCortex import roi
def eccentricity_plot(subject_id, path, cluster, binarize=False):
"""
Pl... |
4ea3911303fb3679acda33adfe805fdd3b9d291d2a616f1d4f2c1d95e01e8342 | Python | 3,221 | 107 | import numpy as np
from numba import njit
import tensorflow as tf
from helpers import RBF, GP
@njit
def static_params(theta0, T):
""" TODO
"""
B = theta0.shape[0]
D = theta0.shape[1]
theta_t = np.zeros((B, T, D))
for t in range(T):
theta_t[:, t, :] = theta0
return theta_t
def ... |
ad5fd860b4f4c87f33ada2c38332d88dd7c09f609163f186eb3638155191ff68 | Python | 3,222 | 92 | from dragen.run import Run
#Model details
dimension = 3
box_size = 15
box_size_y = None # if this is None it will be set to the main box_size value
box_size_z = None # for sheet rve set z to None and y to different value than x the other way round is buggy
resolution = 2
number_of_rves = 1
smoothing_flag = False
# B... |
b3d8b2cf8b222524177b5de823c298714f19c9d5e0f6b8b14188e888c8cc878a | Python | 3,222 | 99 | from __future__ import division
from unittest import TestCase
import numpy as np
from numpy.testing import assert_equal
from .adjacency import segmentation_adjacency
class AdjacencyTest(TestCase):
def test_segmentation_adjacency_simple_4(self):
segmentation = np.array([
[0, 0, 1, 1],
... |
33789665ccfd2b7e6edcd025a194dccee827a8c781809179d56097c571276e3f | Python | 3,227 | 73 | """This script creates a continous array to mark the boundries of phonemes in Low or High Entropy words"""
from pathlib import Path
import re
import os
import eelbrain
import mne
import trftools
import numpy as np
language = 'Dutch'
DATA_ROOT = Path(os.path.dirname(os.path.abspath(__file__))).expanduser()
STIMULUS_DI... |
b2d3a89fe3e99c99ed01918e7a7136d2fb88a055d2de4a0d841e2d10386dc21e | Python | 3,228 | 99 | import numpy as np
from qutip import *
import cmath, copy
from pylab import *
from copy import deepcopy
from scipy import optimize,integrate
M=2; M2=2
### defined parameters
B1 = tensor(qeye(M), qeye(M), qeye(M), qeye(M), qeye(M), qeye(M), destroy(M2), qeye(M2))
B2 = tensor(qeye(M), qeye(M), qeye(M), qeye(M), qeye(M)... |
b641a51b181d11df6ab7a1b1b92dd0ffc92586c662e5ebb628b5fde00c0975a8 | Python | 3,239 | 154 |
from matplotlib.pylab import *
from numpy import *
from pickle import load
from scikits import bootstrap
import sys
from scipy.stats import *
from joblib import Parallel, delayed
import multiprocessing
from scipy.signal import gaussian
from scipy.ndimage import filters
from pickle import dump
import bz2
num_cores = m... |
95a06016ab38a2bbfae8f1662182335b1fad36c761f83cecebef1491cabeb4e8 | Python | 3,244 | 91 | #!/usr/bin/env python3
# Copyright 2021 Maria Cervera
#
# 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 o... |
2842a1a39b7a4612fb1bf228a00884240810b34478c58ea6bf00d56f85c80cef | Python | 3,246 | 88 | # TODO Sep 08 version
import dominate
from dominate.tags import meta, h3, table, tr, td, p, a, img, br
import os
class HTML:
"""This HTML class allows us to save images and write texts into a single HTML file.
It consists of functions such as <add_header> (add a text header to the HTML file),
<add_imag... |
61ebdcd9e7a5c188e07e3b04c595ce83ad4a96fb3ae21c9763a06b39be3db1ce | Python | 3,247 | 89 | #!/usr/bin/env python3
# Copyright 2021 Maria Cervera
#
# 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 o... |
773d51651da5daca0fb3d9b05e280487f8b4c02c076d6ca1665b8fc0e99e12bb | Python | 3,247 | 93 | import torch.nn as nn
class InitialConv(nn.Module):
def __init__(
self,
input_channels,
output_channels,
conv=nn.Conv2d,
conv_kwargs=None,
norm=nn.BatchNorm2d,
norm_kwargs=None,
act=nn.LeakyReLU,
act_kwargs=None,
dropout=nn.Dropout2d,... |
a746f368e291bc68be6de07df5d05f91f978ad30c9d45f716abefc6096e28b85 | Python | 3,247 | 96 | import logging
from typing import Optional, Union
from typing import Type
from pydantic import BaseModel, ValidationError, create_model
from pydantic_core import ErrorDetails
def initialize_key(
parameters: dict, key: str, value: Optional[Union[str, float, list, dict]] = None
) -> dict:
"""
This functio... |
631f7dbfb8708461a36c1e64e60eed2a2e84f5c55378f90d97810744f58e62ed | Python | 3,248 | 103 | import unittest
import os
from pygenometracks import utilities
import matplotlib.pyplot as plt
ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)),
"test_data")
class FakeAxis:
"""Allow Formatter to be called without having a "full" plot set up."""
def __init__(self, vmin=1, v... |
011e8819032220eea92e01391ac4d2549032265a643500df7bda25869676480f | Python | 3,250 | 105 | # -*- coding: utf-8 -*-
import sys
from setuptools import find_packages, setup
from setuptools.extension import Extension
try:
from Cython.Build import cythonize
except ImportError:
raise RuntimeError(
"Cython required for running the package installation\n"
+ "Try installing it with:\n"
... |
0d8717cefa763102dded2275575966fb094c69e8576f90a0b6a6ea25f5f2e169 | Python | 3,250 | 82 | """Entry point of the substructure pipeline.
`Run().run_damask(store_path)` and `Run().run_abaqus(store_path)` are called from
dragen/main3D.py once the respective solver export has written its mesh. Both drive the same
stages; only the first (read the mesh) and the last (write the solver deck) differ:
adapters ... |
8a4179fb89fb70f616967f8b04ed3160d4c8da2d8a915513bc0e5b4155e6a0c1 | Python | 3,251 | 71 | import numpy
from typing import Annotated, Optional, List, Tuple, Union
from pydantic import Field, validate_call, ConfigDict, BaseModel
from cellprofiler_library.opts.measureimageoverlap import ALL_FEATURES, DM, C_IMAGE_OVERLAP, Feature
from cellprofiler_library.functions.measurement import (
measure_image_overlap... |
1d96632f7f5e837d0619a4a16f00b114395e887f439800c136d935ae807ccee7 | Python | 3,252 | 97 | # JHK
import numpy as np
from netCDF4 import Dataset
import os, pathlib
#==========================================================
# Set main directory
#==========================================================
hdir = '/home/jhkim/model/deep_detection'
#==========================================================
# ... |
070f308f2ca497a64e00a7737b1cad7c31a233213effc5157a5fac23d90513e4 | Python | 3,255 | 81 | from . GenomeTrack import GenomeTrack
import numpy as np
from .. utilities import InputError
DEFAULT_HLINES_COLOR = 'black'
class HLinesTrack(GenomeTrack):
SUPPORTED_ENDINGS = []
TRACK_TYPE = 'hlines'
OPTIONS_TXT = GenomeTrack.OPTIONS_TXT + f"""
# color of the lines
color = black
# To use transparency, y... |
9110c57839d9fe274a4d299d514370e964da54e99afceac56524c189e229af56 | Python | 3,258 | 89 | import datetime
import requests
import wx
import re
from packaging.version import Version, VERSION_PATTERN
from cellprofiler_core.preferences import get_check_update, set_check_update, get_check_update_bool
from cellprofiler import __version__ as current_version
def check_update(parent, force=False):
if not for... |
8f033fe4f13db7a74978a2cfc2209045e13904672949c3eb82ce4678cc66cc67 | Python | 3,266 | 69 | from enum import Enum
from cellprofiler_library.opts.measurement import C_LOCATION
C_INTENSITY = "Intensity"
class IntensityFeature(str, Enum):
"""Raw strings for intensity and location features."""
# General Intensity Features
INTEGRATED_INTENSITY = "IntegratedIntensity"
MEAN_INTENSITY = "MeanIntens... |
7e22e03aca5891f26b61b7c818e0ae031b771585dcb395e1a99e4e848fdb8a1a | Python | 3,268 | 125 | from __future__ import division
from joblib import Parallel, delayed
import sys
sys.path.insert(0, '../../helpers/')
from circ_stats import *
import statsmodels.api as sm
from multiprocessing import Value
from math import atan2
from sklearn.model_selection import train_test_split
from pickle import load,dump
import m... |
a2395fffdf6171e137662e77145d38d690671d374cb5a0068662e16ee7a1908e | Python | 3,268 | 95 | """
File name: calculate_multicollinearity.py
Author: Esra Zihni
Date created: 15.01.2018
This script performs multicollinearity analysis on the clinical predictors. It
reads the path options from the config.yml file. It loads the dataset and
calculates a Variance Inflation Factor (VIF) for each predictor to measure... |
481c230aab8305072ca3829567ff1584ba5a418ae1787ef40930807343f42a3c | Python | 3,270 | 95 | # Pytorch Tabular
# Author: Manu Joseph <manujoseph@gmail.com>
# For license information, see LICENSE.TXT
"""Base Model"""
import logging
from abc import ABCMeta, abstractmethod
from typing import Any, Callable, Dict, List, Optional
import pytorch_lightning as pl
import torch
import torch.nn as nn
from omegaconf impor... |
ca8c86517419c3b2611433447ab10f1e91456c9f9a86a95a5a0a93f32032234c | Python | 3,270 | 107 | from __future__ import print_function
from __future__ import division
import os
import sys
from six.moves import xrange
import numpy as np
def _print_status(data_dir, percentage):
sys.stdout.write(
'\r>> Preprocessing to {} {:.2f}%'.format(data_dir, percentage))
sys.stdout.flush()
def _save(data_d... |
4b0e321496fbc5b6204179ea2541df45b011f1d411ec83d67f2c00c085e0efb1 | Python | 3,272 | 66 | # TODO August 06 verion
from .base_model import BaseModel
from . import networks
class TestModel(BaseModel):
""" This TesteModel can be used to generate CycleGAN results for only one direction.
This model will automatically set '--dataset_mode single', which only loads the images from one collection.
See ... |
adaf9597e149a87b5f83e85d807fa6a4a177c6d2c262b20c92303a0cce243e0d | Python | 3,272 | 80 | import math
import torch
from torch.optim.optimizer import Optimizer, required
class RAdam(Optimizer):
def __init__(self, params, lr=1e-3, betas=(0.9, 0.999), eps=1e-8, weight_decay=0):
defaults = dict(lr=lr, betas=betas, eps=eps, weight_decay=weight_decay)
self.buffer = [[None, None, None] for in... |
428d66c45fdc6dc809f99390e7ca4ae0811b3f0feb2bd503dc6b52ddf496f725 | Python | 3,276 | 95 | #utility library
import re
import sys
from urllib.request import urlopen
from urllib.error import HTTPError
import os
# scientific python libraries
import numpy as np
import scipy as sp
import pandas as pd
import matplotlib.pyplot as plt
#custom thermochemistry modules
from lib.thermodynamic_constants import *
from lib... |
0f14bc2648dd3bd89505e5e119883a4f471e48e56e44b373252a830d1ad6d332 | Python | 3,279 | 100 | """ PyTorch FX Based Feature Extraction Helpers
Using https://pytorch.org/vision/stable/feature_extraction.html
"""
from typing import Callable, Dict, List, Optional, Union, Tuple, Type
import torch
from torch import nn
from timm.layers import (
create_feature_extractor,
get_graph_node_names,
register_not... |
4952ce92819d3e00ef34a88d653c1e7dc264221ac015e5681a30e94ddf248dc8 | Python | 3,281 | 93 | from dragen.run import Run
#Model details
dimension = 3
box_size = 15
box_size_y = None # if this is None it will be set to the main box_size value
box_size_z = None # for sheet rve set z to None and y to different value than x the other way round is buggy
resolution = 2
number_of_rves = 1
smoothing_flag = False
# B... |
6375372150ae544992626429f2ff4c46aec5e9f18e054bb6c3efa386f13af85f | Python | 3,281 | 93 | from dragen.run import Run
#Model details
dimension = 3
box_size = 25
box_size_y = None # if this is None it will be set to the main box_size value
box_size_z = None # for sheet rve set z to None and y to different value than x the other way round is buggy
resolution = 1
number_of_rves = 1
smoothing_flag = False
# B... |
38c0f7b339abb56b64194b265c25ebca35c4799ecb4f0c6ba36c0340be96f68c | Python | 3,287 | 95 | import numpy as np
import matplotlib.pyplot as plt
def plot_signal(signal, time, ax):
ax.plot(time, signal, label='voltage', zorder=0)
ax.set_xlim([0., 1.])
ax.set_ylim([-1.75, 1.75])
ax.set_xticks(np.arange(0, 1.01, 0.25))
ax.set_yticks(np.arange(-1., 1.1, 1.))
ax.set_xlabel("time [s]")
a... |
dfcab6d2a86fd7d58a4039e2c23e0122ebb77cf8233d6da9120544b85b07c966 | Python | 3,288 | 114 | """"
Miscellaneous functions to plot.
Date: September 2018
Author: Ignacio Heredia
Email: iheredia@ifca.unican.es
Github: ignacioheredia
"""
import os
import json
import matplotlib.pylab as plt
import numpy as np
from imgclas import paths
def training_plots(conf, stats, show_val=True, show_ckpt=True):
"""
... |
3537ba3d350afc3daf7db1f944e9a64430f6434bd66b51b41012bb50d172828e | Python | 3,290 | 93 | from dragen.run import Run
#Model details
dimension = 3
box_size = 25
box_size_y = None # if this is None it will be set to the main box_size value
box_size_z = None # for sheet rve set z to None and y to different value than x the other way round is buggy
resolution = 1
number_of_rves = 1
smoothing_flag = False
# B... |
884669c703d028759f8828ce0dd4f37bd4cd7307d3ac3d8838904b6819956858 | Python | 3,291 | 99 | # -*- coding: utf-8 -*-
"""
Created on Sat May 29 23:36:08 2021
@author: Manuel
Implementation of the U-Net structure proposed by Ronneberger et al. (2015)
in the following paper https://www.doi.org/10.1007/978-3-319-24574-4_28
in tf.Keras.
"""
def UNet(n_classes, input_shape = (imgr, imgc, imgdim), dropout = 0.5,
... |
85be6d0f72e181d1bb988eb5644de1952fba7ef3cd6fc38252dbb3b4fcaa1e84 | Python | 3,294 | 93 | from dragen.run import Run
#Model details
dimension = 3
box_size = 15
box_size_y = None # if this is None it will be set to the main box_size value
box_size_z = None # for sheet rve set z to None and y to different value than x the other way round is buggy
resolution = 2
number_of_rves = 1
smoothing_flag = False
# B... |
9595dd36e43f797fb0919f7f7e3e38d78b2b0c5bf644353164e1ef786cad0036 | Python | 3,294 | 100 | ### from the GCN model
import torch
import torch_geometric.transforms as T
import torch.nn.functional as F
from torch.nn import Sequential as Seq, Linear as Lin, ReLU, BatchNorm1d as BN
from torch_geometric.nn import fps, radius
from torch_geometric.nn import knn_interpolate, PointConv, global_max_pool
t = T.Cartesia... |
cfe090b8f19eb692d2a70414b33c6d496089ceb2c06e4298c0cba551ea3dc31d | Python | 3,296 | 98 | import numpy as np
def node_selection(points, size, stride=1, delta=1):
"""Select nodes of an adjacency matrix given their coordinates."""
# Find coordinate max values.
y_min = points[:, :1].min()
x_min = points[:, -1:].min()
x_max = points[:, -1:].max()
w_max = x_max - x_min
# Translate... |
33950fd1e5afb53ae27d4e75a9f50328774a2b407dde9f31e740c662f8ea0fdb | Python | 3,300 | 109 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
######################################################################
#
# Model automatically generated by modelGenerator
#
######################################################################
# -----------------... |
29d7664361371f4350d3acd4a7671a4d8cdece5f9854b5359a62af369fed215b | Python | 3,301 | 96 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 22 16:49:47 2016
Seg Stitch
@author: dpenaherrera
"""
import sys
# ==============================================================================
# WHERE ALL THE MAGIC HAPPENS
# Grab all .seg files in path and convert them to .bed files
def seg_exte... |
b439882e032025dea8a8d9f2d6a6a94a0306d223cbdc7d58070340bb7504e9ab | Python | 3,302 | 73 | import numpy as np
from megsimutils.arrays import BarbuteArraySL
from megsimutils.utils import spherepts_golden
class BarbuteArraySLGrid(BarbuteArraySL):
def __in_imag_vol(self, rmags):
"""
Check which sensors are in the barbute. Return True for the sensors in
the barbute and False for the... |
63c2fc7a61eb2bed8d52bc3b0428765cf63f264f175602a374d8d074eed14627 | Python | 3,303 | 93 | from dragen.run import Run
#Model details
dimension = 3
box_size = 25
box_size_y = None # if this is None it will be set to the main box_size value
box_size_z = None # for sheet rve set z to None and y to different value than x the other way round is buggy
resolution = 1
number_of_rves = 1
smoothing_flag = False
# B... |
d6609244c5f2edf02886f72e60779b7e18416acf1197418764a5791892de4fd3 | Python | 3,304 | 84 | from unittest import TestCase
import numpy as np
from numpy import pi as PI
from numpy.testing import assert_equal, assert_almost_equal
import scipy.sparse as sp
from .augment import (flip_left_right_adj, random_flip_left_right_adjs,
adjust_brightness, random_brightness, adjust_contrast,
... |
4170de2d94d35e7c1e8c6c0d177634d7be2612e1e5229e1efb5512115fa18206 | Python | 3,308 | 92 | import os
import sys
import argparse
from pymatgen.io.cif import CifParser
import re
import numpy as np
parser = argparse.ArgumentParser(
description=(
"generate input file"
"Generate the input file from the cif file"
)
)
parser.add_argument(
"--cif",
... |
bcf2703f7ebc7ce9d82aca0ff5abd6f774878c0486826a65c6c1b7f14eac5bea | Python | 3,311 | 101 | import numpy as np
from netCDF4 import Dataset
import os, pathlib
from scipy import stats
#==========================================================
# Set main directory
#==========================================================
hdir = '/home/jhkim/model/deep_detection'
#============================================... |
fa38df5d1e0694c23a0baf132071b95fcc290bb2fe7f5434cd6335a6c5bc0c98 | Python | 3,311 | 74 | """Input resolution for built-in scripts and exported models.
The legacy config resolvers retain their existing behavior for external callers.
"""
import logging
from typing import Any, Dict, Optional
from timm.models._input import _requested_input, get_model_input_config
from .config import resolve_data_config
from... |
8f17bade2a38fffa0c2171010597d663cc02366efadaa8b51b2ec58698f48d1c | Python | 3,312 | 103 | import argparse
from pathlib import Path
from wget import download, bar_thermometer
def cli():
parser = argparse.ArgumentParser()
parser.add_argument('pdb_file', type=Path)
parser.add_argument('-d','--data-dir', required=False, default=Path("./pdbs"), type=Path)
parser.add_argument('-t', '--pdb-ty... |
08595353bca95f91733c38fe50c0c34174e11e480b7aabcf12d3f2efd759c1d5 | Python | 3,313 | 82 | from pydantic import BaseModel, model_validator, Field, AliasChoices, ConfigDict
from typing_extensions import Self, Literal, Optional
from typing import Union
from GANDLF.configuration.validators import validate_class_list, validate_norm_type
from GANDLF.models import global_models_dict
# Define model architecture op... |
5882a632effdf5dbcb441513de0d5b4b16fde246aa47f6ae4c3b6d9dc0ff2e1f | Python | 3,313 | 86 | import unittest
import cellprofiler_core.pipeline
class TestImagePlaneDetails(unittest.TestCase):
def get_ipd(
self, url="http://nucleus.org", series=0, index=0, channel=0, metadata={}
):
d = cellprofiler_core.pipeline.J.make_map(**metadata)
jipd = cellprofiler_core.pipeline.J.run_scr... |
a544a8a6c9e5e74a4acdde1fedd22962390365d8a68825fb366ecd6abe8bb9de | Python | 3,317 | 79 | # -*- coding: utf-8 -*-
# From https://github.com/jiesutd/LatticeLSTM
import torch
import torch.autograd as autograd
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
import numpy as np
# Build Bi-LSTM to learn character-level features.
clas... |
aa3692cddb039f73395b98f8794376d469274d33d216547c6fdffaf5d6e5fa6f | Python | 3,322 | 94 | from pydantic import BaseModel, ConfigDict, Field, AliasChoices, model_validator
from typing_extensions import Any, Literal, Self
class ThresholdConfig(BaseModel):
min: int = Field()
max: int = Field()
class ClipConfig(BaseModel):
min: int = Field()
max: int = Field()
class RescaleConfig(BaseModel... |
e7c300a73a4740bc93bd5a8d33cc0746bb8ce0fc4d2bc8117ef56e5040db706c | Python | 3,325 | 121 | from typing import Tuple
from pydantic import BaseModel, Field, ConfigDict
from typing_extensions import Literal
from GANDLF.optimizers import global_optimizer_dict
# takes the keys from global optimizer
OPTIMIZER_OPTIONS = Literal[tuple(global_optimizer_dict.keys())]
class SgdConfig(BaseModel):
momentum: floa... |
f6beda1cbdb1bb637a43f2f303d8853f57c5acc315dca2705d157807ecd4c22f | Python | 3,326 | 95 | import os
from .dataset import Datasets, Dataset, GraphDataset
from .mnist import get_pattern
import torch
from torch_geometric.data import (Dataset, Data)
import torch_geometric.transforms as T
from tensorflow.examples.tutorials.mnist import input_data
import numpy as np
from lib.graph import grid_tensor
class GMNIS... |
b584f625b78bdeb71f56dbf105dfd0afd1e92eb0cae8a940f9393ec3ddb38f48 | Python | 3,327 | 94 | import warnings
from typing import List
from typing import Optional
from typing import Tuple
from typing import Union
import numpy as np
import torch
epsilon = 1e-7
def intensity_window(img: torch.Tensor, from_span=(-1150, 350), to_span=(0, 255), output_dtype=None) -> torch.Tensor:
origin_dtype = img.type()
... |
d27cd9a2c07ea2d5d4161fee41b6703fa94038222debc7c4729a082db3af527d | Python | 3,328 | 75 | from typing import Any, Optional
import numpy as np
import xarray
from ptsa.data.readers import BaseReader
class NetCDF4XrayReader(BaseReader):
def __init__(self) -> None:
pass
self.writer_class_name: str = 'NetCDFXRayReader'
self.writer_version: int = 1
def read(self, filename: str... |
96fc0b443dc43ca8ed246b496cd5f0cc46c787ef9d8bf4056e064df33252787d | Python | 3,330 | 97 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022, 2023 IBM. All Rights Reserved.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any... |
b34326d418296b2ca42d9b821312c2dbe48050ae474f9fe6bcd2587f242fac50 | Python | 3,330 | 113 | import os
import sys
import glob
import argparse
import matplotlib
import numpy as np
sys.path.insert(0,"../")
sys.path.insert(1,"./")
# Keras / TensorFlow
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '5'
from keras.models import load_model
from layers import BilinearUpSampling2D
from utils import load_images
from matplotlib ... |
a4bb2c797d2b8e4a18e06c4952e4a6cfe8adf86fdc9bbd1300900823ac45beb3 | Python | 3,335 | 82 |
#!/usr/bin/env python
# coding: utf-8
import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import itertools
import scanpy as sc
import anndata as ad
import warnings
def prepareData(path, annot_pa, model_path, disease):
if disease == "PD":
list_conds = ["... |
951072e3bfcabb656365c64ece88f060f929716eee52f3454aacd8ce412b3d68 | Python | 3,336 | 111 | from copy import copy
from os.path import exists
import nibabel as nib
from traitlets.config import Bool, Dict
from traitlets.config.loader import ConfigError
from mrHARDI.base.application import (ChoiceEnum, ChoiceList,
mrHARDIBaseApplication,
... |
746a0e73d70e0d86b4f5e6775c9a0df88113cf07780a683fb92522620881d71d | Python | 3,339 | 104 | from os import path
import torch
import torch.utils.data as data
class CacheClassLabel(data.Dataset):
"""
A dataset wrapper that has a quick access to all labels of data.
"""
def __init__(self, dataset):
super(CacheClassLabel, self).__init__()
self.dataset = dataset
self.labels... |
c9ae08626ec8bc468e0af34247bc3780f78f7bc8871338bf47d389a7e9ced6a5 | Python | 3,344 | 57 | import utils
import os
preproc_sess = 'preproc-sess -s {subject} -fsd bold -stc up -surface {subject} lhrh -mni305 -fwhm 5 -per-run'
mkanalysis_sess = 'mkanalysis-sess -fsd bold -stc up -surface {subject} {hemi} -fwhm 5 -event-related -paradigm {par_file} -nconditions 2 -spmhrf 0 -TR {tr} -refeventdur 1 -nskip 4 -poly... |
a04bba5d0e980c0bcbb5f0550fd06c643e1c502371fa1e76320553012798c20c | Python | 3,346 | 70 | import torch
from random import shuffle
from .wrapper import Subclass, AppendName, Permutation
def SplitGen(train_dataset, val_dataset, first_split_sz=2, other_split_sz=2, rand_split=False, remap_class=False):
'''
Generate the dataset splits based on the labels.
:param train_dataset: (torch.utils.data.dat... |
c370359f68ef1f9b366e9f66dc4deb517d707752784edff37ce0f728e057a599 | Python | 3,347 | 117 | #!usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
from typing import Optional
from deprecated import deprecated
import click
from GANDLF.cli import copyrightMessage, post_training_model_optimization
from GANDLF.entrypoints import append_copyright_to_help
from GANDLF.utils import logger_setup
def _optimi... |
76656a745c1544b26292ee9297bbad3ccaaa42e66e276cfa9c7178cd8df884e7 | Python | 3,348 | 91 | #!/usr/bin/env python3
# Copyright 2021 Maria Cervera
#
# 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 o... |
ec65620416543426e67353768f73a3b6cc03e3077897755bc9dab9a9b7fbb838 | Python | 3,348 | 88 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022, 2023 IBM. All Rights Reserved.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any... |
0f3985880da5bf2c1902f4ce6299fc193d766650cbe04ec47c31a0189e99c973 | Python | 3,351 | 117 | import pandas as pd
import numpy as np
import argparse
import matplotlib.pylab as plt
from rdkit import Chem
import rdkit.Chem.Descriptors
import os
def pref_split(smiles_string):
"""
splits a string on '|' into a list with two elements, starting from the right
the prefix token must be in '<pref... |
a17259098090a66e1fc9afc0944f411c25adf59c838c8d8d22591133f2930aae | Python | 3,355 | 73 | import numpy as np
def calciOptogenx(input, t, traces):
iOptogenx = None
if input.analysesopt.recordTotalOptogeneticCurrent:
if traces is None:
print(
'try to recordTotalOptogeneticCurrent but not traces recorded (traces is None)')
return iOptogenx
iOpto... |
e1f0ec46bf5736bfaf4f954f1f180c0aa638fdb00ee7f1f5d711bff84ff4ef6f | Python | 3,358 | 93 | from dragen.run import Run
#Model details
dimension = 3
box_size = 25
box_size_y = None # if this is None it will be set to the main box_size value
box_size_z = None # for sheet rve set z to None and y to different value than x the other way round is buggy
resolution = 1
number_of_rves = 1
smoothing_flag = False
# B... |
f8a138849f80c02463c82e5ec7bfdcf178805270db8ea6c8871291b7150e5a96 | Python | 3,360 | 98 | '''
crosstemporal decoders for Barbosa, Stein et al. (Nat Neuro, 2020)
created by H Stein, Mar 2020
input: ../data/meantf_delay_*.npy
../data/meantf_response_*.npy
../data/time.npy
output: ./cross_decoders.pkl
'''
from glob import glob
import numpy as np
import scikits.bootstrap as boot
import pickle
import sy... |
ed7009eaa5c98fa36bb09271333f37d6fba52d9507dfa36e6f0f3676133ede48 | Python | 3,367 | 110 | # -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
import pytest
from pysteps import motion
from pysteps.visualization import plot_precip_field, quiver, streamplot
from pysteps.tests.helpers import get_precipitation_fields
arg_names_quiver = (
"source",
"axis",
"step",
"quiver... |
ee53bbe4d61fbc99fb8d93aadda3a4239e0da120727f6db7f2382508fef80ccb | Python | 3,367 | 112 | #!/usr/bin/env python3
import os
import unittest
import logging
import shutil
import random
import pytest
from unittest.mock import patch
import ciftify.niio as niio
logging.disable(logging.CRITICAL)
class TestDetermineFiletype(unittest.TestCase):
def test_recognizes_dtseries(self):
file_name = "subjec... |
bb6f1cf7cf3e619b447d2523fdc42dbfa0317b04c71606aeea033731c496be59 | Python | 3,370 | 80 | from torch.utils.data import DataLoader, ConcatDataset
from torch.utils.data.sampler import RandomSampler, SequentialSampler, BatchSampler
from torch.utils.data.distributed import DistributedSampler
class MultiTaskBatchSampler(BatchSampler):
def __init__(self, sampler, batch_size, drop_last, cum_thresholds):
... |
732ee3a9e65c8fc600dd27b5f161b3e9110e40e5a8e49789719bf5f976ad80fd | Python | 3,371 | 89 | import numpy as np
from zipfile import ZipFile
from io import BytesIO
# Load test data
def load_test_data():
print('Loading test data...', end='')
def extract_zip(input_zip):
input_zip=ZipFile(input_zip)
return {name: input_zip.read(name) for name in input_zip.namelist()}
data = extract... |
5ecf1a83d24822cb3ca6d65ee5c7c71d84444831023378591bc85b8448c2102a | Python | 3,373 | 113 | # -*- coding: utf-8 -*-
import os
import numpy as np
import pytest
import pysteps
from pysteps.utils import reprojection as rpj
pytest.importorskip("rasterio")
pytest.importorskip("pyproj")
root_path_radar = pysteps.rcparams.data_sources["rmi"]["root_path"]
rel_path_radar = "20210704" # Different date, but that do... |
b55f8aa73ce3d96ee74dd8da20a00f58ef2cf1a39d13d5314359717d411a162e | Python | 3,377 | 129 | from __future__ import division
from joblib import Parallel, delayed
import sys
sys.path.insert(0, '../../helpers/')
from circ_stats import *
import statsmodels.api as sm
from multiprocessing import Value
from math import atan2
from sklearn.model_selection import train_test_split
from pickle import load,dump
import m... |
3bc33074bf26b71421f603e0ea4ff6331033caf39a7d9142e25564b752c18f30 | Python | 3,378 | 98 | from qutip import*
import numpy as np
from exp_errors import *
from qutip.qip.circuit import QubitCircuit, Gate
from qutip.qip.operations import phasegate, rx, gate_sequence_product, cnot, sqrtswap, csign
from scipy import optimize,integrate
list = [ [[1,3], [2,3], [1,4], [2,4]],
[[3,5], [4,5], [3,6], [4,6]] ... |
98e7c79486b39f1f296ae324022bbf362e7bdfcdd8609b66e44d6eb7bfbe92cd | Python | 3,379 | 87 | import torch
import torch.nn as nn
import torch.nn.functional as F
class out_conv(nn.Module):
"""
A class for the output convolution block in a neural network, which includes a convolutional layer,
batch normalization layer, activation function, and final convolutional layer (e.g. sigmoid).
"""
d... |
44862ec97e353adae410ea10ea6610f9814f5d79273ea7c74a796d583ad301f3 | Python | 3,382 | 109 | import imageio
import numpy
from .... import Image
from .....constants.image import MD_SIZE_C, MD_SIZE_Z, MD_SIZE_T
from .....utilities.image import convert_image_to_objects
from .....utilities.pathname import url2pathname
from ._url_image import URLImage
class ObjectsImage(URLImage):
"""Provide a multi-plane in... |
de24442ca80508673c00e375f3a6cb557102c7d11cfcf6eee55616b0d3c6bb11 | Python | 3,383 | 81 | #from model.builders.prostate_models import build_pnet2
from model.builders.go_models import build_pnet2
task = 'classification_binary'
selected_genes = 'tcga_prostate_expressed_genes_and_cancer_genes.csv'
data_base = {'id': 'ALL', 'type': 'diabetes',
#data_base = {'id': 'ALL', 'type': 'lc',
'params': {
... |
5f226f00d7e59b1a6e230d66d92b6f56b286f6167975459079c85bec31fcfed5 | Python | 3,386 | 110 | """Instantiate Flask and set up plugins."""
import os
import click
from flask import Flask
from flask_migrate import Migrate
from afidsvalidator.config import (
DevelopmentConfig,
ProductionConfig,
TestingConfig,
)
from afidsvalidator.learn import learn
from afidsvalidator.model import db, login_manager
... |
8bea19dc83acc142d8472f06259662bd1304817587ca81acd6604e9c5bbbf397 | Python | 3,389 | 122 | import modules.predict as p
import pandas as pd
import numpy as np
from tqdm import tqdm
import math
import matplotlib.pyplot as plt
def predict(plots_path, tables_path, cutoff_ls, shot_ls, file_name):
RMSE = []
miss = []
RMSE_shot = []
RMSE_mix = []
r2_shot = []
r2_cutoff = []
fh = []
... |
b8e417bdfcc2eeb65cc143f235db9252ec8ca7fab65c0649d173ad7f612c0104 | Python | 3,390 | 100 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022, 2023 IBM. All Rights Reserved.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any... |
c0c6209d1fb6a65b1f3cffa4e3eaffa60fea03698e412e9968723043641ad13e | Python | 3,398 | 81 | from cryspnet.utils import FeatureGenerator, load_input, dump_output, group_outputs, topkacc
from cryspnet.models import load_Bravais_models, load_Lattice_models, load_SpaceGroup_models
from cryspnet.config import *
import argparse
featurizer = FeatureGenerator()
def main():
parser = argparse.ArgumentParser()
... |
bac466a5504d9405b20b371d29ed33a65a3c63007c2b53c1ae9171ddacbf03bc | Python | 3,399 | 104 | # -*- coding: utf-8 -*-
"""
molvs.cli
~~~~~~~~~
This module contains a command line interface for standardization.
"""
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
import argparse
import logging
from rdkit import Chem
import sys
from molvs import Stan... |
af99a2751312b09c018c79dc27994bfdaa09973caf9a2226e3b2c7657f83221d | Python | 3,401 | 105 | '''
JHK
Python script for calculating the linear trend of integrated gradient values.
'''
import numpy as np
from netCDF4 import Dataset
import os, pathlib
from scipy import stats
#==========================================================
# Set main directory
#=========================================================... |
90b892fae56ceceaf86547939c5822e53388d0c538b8d41de119edefc95985c7 | Python | 3,402 | 124 | import sys
sys.path.append('../MLP/module/')
import predict as p
import pandas as pd
import numpy as np
from tqdm import tqdm
import math
import matplotlib.pyplot as plt
def predict(plots_path, tables_path, cutoff_ls, shot_ls, file_name):
RMSE = []
miss = []
RMSE_shot = []
RMSE_mix = []
r2_shot = [... |
3cbb55c15a8b6bdb02f21aeab19da3e163bd431e558fdd1f98b51c3552d2a9c7 | Python | 3,405 | 82 | # -*- coding: utf-8 -*-
"""
@author: bartulem
Perform linear regression on train/test split dataset.
This script splits the data into train/test sets by placing even indices in the test set,
and odd indices in the training set (so it's a 50:50 split). It performs a linear regression
on the training set and then pre... |
1b3551ffeb1ac21207eadf7748974048eeed6dded661f9b7e48e12fb2a9554dc | Python | 3,409 | 49 | # NOTE timm.models.layers is DEPRECATED, please use timm.layers, this is here to reduce breakages in transition
from timm.layers.activations import *
from timm.layers.adaptive_avgmax_pool import \
adaptive_avgmax_pool2d, select_adaptive_pool2d, AdaptiveAvgMaxPool2d, SelectAdaptivePool2d
from timm.layers.attention_p... |
66eb15217902e5737b3845f7059e269070d3441db03933eda2115e63c77c06c6 | Python | 3,409 | 82 | from tqdm import *
import time, random
import sys
from rdkit.Chem import AllChem
from rdkit import DataStructs
import rdkit.Chem as Chem
from pandas import Series,DataFrame
import pandas as pd
import numpy as np
elements = set(['As', 'Br', 'C', 'Cl', 'F', 'I', 'N', 'O', 'P', 'S', 'Se'])
All_Atoms = ['As', 'Br', 'C',... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.