sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
683ee287ab86c0f2b13eb10806f992ac41abf03d7ab9d2c2fb1864cd34944d54
Python
2,543
82
import numpy as np from nengo.connection import Connection from nengo.exceptions import ObsoleteError from nengo.network import Network from nengo.networks.ensemblearray import EnsembleArray from nengo.node import Node # Adpated from nengo.networks.InputGatedMemory # A working memory used for the cognitve mapping expe...
2b99752348ebac2a2d7dec7d73da6e18632e1ca7dc20372184d22327b25d87d2
Python
2,544
81
# -*- 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...
922724896e6624425c6c575a89f13ca89c0683475034f511eeef1845b5d65150
Python
2,545
85
#Importing libraries: import pandas as pd import numpy as np import wfdb import ast #Define function to load the data: def load_raw_data(df, sampling_rate, path): if sampling_rate == 100: data = [wfdb.rdsamp(path+f) for f in df.filename_lr] else: data = [wfdb.rdsamp(path+f) for f in df.filenam...
ab234d533374187ab8f2267d12cf55afcd01985dc70bf1676bcb2d8790007615
Python
2,546
87
import argparse from pathlib import Path, PurePath from fabric import Connection, config def push_release( connection: Connection, new_release_path: Path, remote_releases_dir: PurePath, wheel_name: str, ): remote_release_new = str(remote_releases_dir / new_release_path.name) connection.run(f"...
f3c7f983034173975c8b958a7bfcbd832c6849754addd98f76f7b788e71a9088
Python
2,546
66
import unittest import torch import torchdiffeq from problems import construct_problem, DTYPES, DEVICES, METHODS, FIXED_METHODS def rel_error(true, estimate): return ((true - estimate) / true).abs().max() class TestEventHandling(unittest.TestCase): def test_odeint(self): for reverse in (False, Tru...
08c8790bcd549a94e23d37c63fdd8437975fa6641f8e98c19b2aeb7768d3b060
Python
2,547
92
# -*- 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...
2be3a6643b4cced1f32086abb37cf773bd56ea5360abaf438aeb66fb20d1efc5
Python
2,547
98
""" Save 2 TIFs (overlay with cluster labels and colored) using pixel clustering cluster IDs Author: Candace Liu Date: 3/18/21 """ import pandas as pd import numpy as np import os import matplotlib.pyplot as plt from matplotlib import colors from PIL import Image import scipy.ndimage as ndimage clusters_path = "pixe...
5203c36e59ebcba74a5f6fc988430dcd416167ced786377456649fe370002510
Python
2,547
65
from typing import Literal import matplotlib.pyplot as plt import numpy as np import pandas as pd from scipy import integrate def selection_generator(df: pd.DataFrame, unique_values_columns: dict, verbose: bool = False, **kwargs) -> np.ndarray: idx = np.ones(len(df)).astype(bool) for key, val in kwargs.items...
e923084b1cd1bb19735c0f9014e0c4075fe011129fd65162880673321e71710c
Python
2,547
78
""" Author: Mingjian He <mh1@stanford.edu> general helper functions used throughout SOMATA """ import numpy as np from itertools import groupby import scipy.signal as signal def consecutive(data): """ This function takes a list of values and returns a list of tuples. Each tuple contains the value, the ...
273b0fccdcbad0020685141e81e643a7325a4ab02589b221885e233c513519ff
Python
2,548
83
""" Summary utilities Hacked together by / Copyright 2020 Ross Wightman """ import csv import logging import os from collections import OrderedDict try: import wandb except ImportError: pass _logger = logging.getLogger(__name__) def get_outdir(path, *paths, inc=False): outdir = os.path.join(path, *pat...
106fd11141311efb32622ffa087cd23edbcc1ba168205c91442ebf374d3beb03
Python
2,549
83
#!usr/bin/env python # -*- coding: utf-8 -*- import argparse import os import fileinput def in_place_string_replace(filename: str, old_string: str, new_string: str) -> None: """ Replace a string in a file in place. Args: filename (str): The file to replace the string in old_string (str): ...
f8e3a5b3b3b0ef19b277d49d2ba182de85d397b152c935c9ff731c91f426d0e4
Python
2,553
44
import numpy from typing import Annotated, Optional from pydantic import Field, validate_call, ConfigDict from cellprofiler_library.functions.image_processing import smoothing_gaussian, smoothing_median, smoothing_keeping_edges, smoothing_fit_polynomial, smoothing_circular_average, smoothing_smooth_to_average from cel...
1f6b584e77bd264028faca8601d33f9906e51a070835626f0c77cfe68fcaac73
Python
2,560
75
#!/usr/bin/env python3 # Copyright 2021 Alexander Meulemans, Matilde Tristany, 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 ...
2f063480a3ba7658314c9289f9f2c9858b87de2810a702ff1452d16f5aba5960
Python
2,560
75
import pytest import torch from torch.utils.data import DataLoader from torchmeta.toy import Sinusoid from torchmeta.transforms import ClassSplitter from torchmeta.utils.data import Task, MetaDataLoader, BatchMetaDataLoader def test_meta_dataloader(): dataset = Sinusoid(10, num_tasks=1000, noise_std=None) m...
6326b17ffb874173b74f7fb409fb9922bdf9e3c426a40bf1d3b07dee353d975d
Python
2,566
83
# -*- coding: utf-8 -*- import os import numpy as np import pytest from numpy.testing import assert_array_almost_equal import pysteps pytest.importorskip("pygrib") def test_io_import_mrms_grib(): """Test the importer for NSSL data.""" root_path = pysteps.rcparams.data_sources["mrms"]["root_path"] fil...
7c70a6aa7d1abaced6e0aaca1a523e08826b7cf2a16d0e01d96e11e9bc3ffdf3
Python
2,566
75
import traceback from typing import Union import yaml from pydantic import ValidationError from GANDLF.configuration.parameters_config import Parameters from GANDLF.configuration.exclude_parameters import exclude_parameters from GANDLF.configuration.utils import handle_configuration_errors def _parseConfig( conf...
8830243e0712a59125fd375e757e296a58c46a4291d21facf8d69bc95f4bd37b
Python
2,566
73
import pytest from timm.data import CustomDatasetInfo, DatasetInfoLabelMapper, LabelMappingCoverage @pytest.mark.parametrize('label_names', [ ['cat', 'dog'], ('cat', 'dog'), ]) def test_custom_dataset_info_sequence_labels(label_names): info = CustomDatasetInfo( label_names, label_descript...
8eb60566974db85af27aef48d0f33b85a59cda39a4798da503a4e27f25ec05b5
Python
2,567
77
from unittest import TestCase import numpy as np from .svessel import SVESSEL data = SVESSEL() class SVESSELTest(TestCase): def test_init(self): self.assertEqual(4040, data.train.num_examples) self.assertEqual(1010, data.val.num_examples) self.assertEqual(1010, data.test.num_examples) ...
3c450b7b3ac2676799ce2b307a86bdf15593ef55c898872e606d7355d70accb0
Python
2,569
79
import torch.nn as nn import torch.nn.functional as F class ResNetModule(nn.Module): """ A residual block module for use in ResNet-style architectures. Args: input_channels (int): The number of input channels. output_channels (int): The number of output channels. Conv (nn.Module):...
49d19f36ebe89d491bda2b08a63e8104b7226842615bc6148b97a1d8274dfeca
Python
2,569
21
reference_genomes = {"hg19":["hg19", {'1': 249250621, '2': 243199373, '3': 198022430, '4': 191154276, '5': 180915260, '6': 171115067, '7': 159138663, '8': 146364022, '9': 141213431, '10': 135534747, '11': 135006516, '12': 133851895, '13': 115169878, '14': 107349540, '15': 102531392, '16': 90354753, '17': 81195210, '1...
37657c4803f9fab7ff0ff61162a7f683e07f5402069e39359d1ee83a29496e80
Python
2,570
86
import torch import torch.nn as nn from einops import repeat from models.aggregators.aggregator import BaseAggregator from models.aggregators.model_utils import Attention, FeedForward, PreNorm class TransformerBlocks(nn.Module): def __init__(self, dim, depth, heads, dim_head, mlp_dim, dropout=0.): super(...
d1b8caf84f575cc58b66dc92dd7b6a7c2483a1ab313d3d74171b5699e08c0380
Python
2,573
100
import numpy as np from macro_models import * from numba import njit @njit def diffusion_trial(v, a, ndt, zr=0.5, dt=0.001, s=1.0, max_iter=1e4): """ Simulates a single reaction time from a simple drift-diffusion process. """ n_iter = 0 x = a * zr c = np.sqrt(dt * s) while x > 0 and ...
241faf9a413cc69971da958e000c35cd77fb62cf205a10b5b5ea7441fb5ec962
Python
2,576
56
# adapted from https://github.com/fepegar/torchio/blob/main/src/torchio/transforms/augmentation/intensity/random_blur.py from collections import defaultdict from typing import Union, Tuple import torch from torchio.typing import TypeTripletFloat, TypeSextetFloat from torchio.data.subject import Subject from torchio....
64dd60a941dfb77a196211fa83b24b0c9cb875cf5708a16e483a9eb918f57e0d
Python
2,576
104
import pdb import torch from torch import nn from torch import optim from DT_for_WDN_leak_localization.model_architectures import ( dense, transformers, ) from DT_for_WDN_leak_localization.models.wasserstein_AE import ( SupervisedWassersteinAE, UnsupervisedWassersteinAE, ) from DT_for_WDN_leak_localizat...
1fe2ce8409dd3e0e62c88511c72aea6c42bbf0f3f895a03d38d9f1dfd3c0c20b
Python
2,578
79
import numpy as np from .masks import shift_mask def diag_indices(n, k=0): rows, cols = np.diag_indices(n) if k < 0: return rows[-k:], cols[:k] elif k > 0: return rows[:-k], cols[k:] else: return rows, cols def mask_extrema(signal, mask_data=None, order=30, left_comparator=np...
10357dacf19f3bb562eb6e7368acff61fda3fd5a7444d4fda154c917bc570e6a
Python
2,580
65
from __future__ import annotations import importlib.util import sys import tomllib from pathlib import Path import pytest TOOLS = Path(__file__).resolve().parents[3] / "tools" SPEC = importlib.util.spec_from_file_location("dm_r_local", TOOLS / "dm_r_local.py") assert SPEC is not None and SPEC.loader is not None dm_r...
7182012104022ca051bdb8641ef3fd5319771c88f4c40b1420f6264572afaba5
Python
2,582
75
''' crosstemporal decoding matrix for Barbosa, Stein et al. (Nat Neuro, 2020) created by H Stein, Mar 2020 input: ../data/meantf_crossmatrix_*.npy ../data/crosstime.npy output: ./crossmatrix_decoders.pkl ''' from glob import glob import numpy as np import pickle import sys sys.path.insert(0,"../../helpers/") impo...
d9d052046f2eb0406c7c4a3efc8fbcf5be0432e5ac75dcc055c82e5bf86ef515
Python
2,584
99
""" Author: Mingjian He <mh1@stanford.edu> Testing functions for basic state-space models in somata/basic_models """ from codetiming import Timer from test_load_data import _load_data # type: ignore import os os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE" # suppress a duplicate OpenMP library error with pytorch on Ma...
edb620ad2cede177a4b8e82bec9ea58158f1fbe1a4544bbd48d0730209186b57
Python
2,584
74
#!/usr/bin/env python3 import os import unittest import logging import shutil import tempfile import ciftify.config from ciftify.utils import run import pytest from pytest import raises from unittest.mock import patch def get_test_data_path(): return os.path.join(os.path.dirname(os.path.dirname(__file__)), 'data'...
6d7b6ac048b07cd5fdf02e7b3fe19a9159bcfe2317f472ed9a790b577025d54b
Python
2,585
101
config = { 'alpha_di': 0.000451125353657906, 'alpha_fb': 0.611510021981854, 'apical_time_constant_fb': 0.4318893018524684, 'beta1': 0.99, 'beta2': 0.999, 'dt_di_fb': 0.004294669581123954, 'epsilon': 3.210886729268312e-07, 'epsilon_fb': 1.0433715362737473e-08, 'feedback_wd': 0.001, 'k_p_fb': 0.010409666247193437, 'lr': ...
99c4977b4e2a68b0465174731269786fc1f9f92f5585b2fd241e48b537b9bdcf
Python
2,585
100
import pdb import torch import torch.nn as nn from DT_for_WDN_leak_localization.model_architectures.dense import DenseResNetLayer from DT_for_WDN_leak_localization.model_architectures.transformers import DecoderLayer, EncoderLayer, PositionalEmbedding from DT_for_WDN_leak_localization.models.parameter_encoder import (...
e422050fda959a1a5f1c41b28b46ae78ef820f0dcc86184cb30f8979c1d07840
Python
2,589
73
''' adapted from https://github.com/all-umass/ManifoldWarping ''' from matplotlib import pyplot # def show_alignment(X,Y,title=None,marker='o-',legend=True): # '''plot two data sets on the same figure''' # dim = X.shape[1] # assert dim == Y.shape[1], 'dimensionality must match' # assert dim in (1,2,3), ('can...
8be1d1672a57486866da010ac7bd14760176f6c1a99c27eec4bfeba17f883bb3
Python
2,591
50
"""Resize module core functionality. This module contains the extracted resize functions that implement the core image resizing algorithms. """ from typing import Annotated, Optional, Tuple from pydantic import Field, validate_call, ConfigDict from cellprofiler_library.types import ImageGrayscaleMask, ImageAny, Imag...
437e1422d205d2b507f8f3369334d8c41250d3835c48a17bbcb737be5d1bd620
Python
2,597
73
from enum import Enum from .._setting import Setting from .._validation_error import ValidationError class Choice(Setting): """A setting that displays a drop-down set of choices """ def __init__( self, text, choices, value=None, tooltips=None, choices_fn=None, *args, **kwargs ): """I...
4bc839e26886d50e98efb6e5fbf52328b9739869c5e615673f8ae27665bf43b9
Python
2,600
87
"""Fixtures for the bowtie2 command-line test suite (scripts/test/test_*.py). Build first, then run from the repository root: make -j4 allall python3 -m pytest scripts/test Set BOWTIE2_BIN_DIR to test binaries that were built somewhere else. """ import os import random import pytest import bt2_helpers as h de...
563e3547ccdd614c055d1dda7404f7f6e838fc7756762ce4aa2a9c515ec4e2d5
Python
2,604
74
from unittest import TestCase import numpy as np from .mnist import MNIST data = MNIST('data/mnist', val_size=10000, background=True) class MNISTTest(TestCase): def test_init(self): self.assertEqual(data.train.num_examples, 8000) self.assertEqual(data.val.num_examples, 2000) self.assert...
61364cdc0152f215ddeeb000ebaf4ea83d57d85a31e31df375626bfb9d5fb06b
Python
2,608
83
# -*- 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...
5f2f494474a5d0ac2f7ddda92c970e9b4bcba90f9ecaacbc1f2c49e625c32496
Python
2,610
66
import argparse import os import sys from importlib.metadata import version from pygenometracks.tracksClass import PlotTracks def parse_arguments(args=None): parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Facilitates the ...
9ae2f587ea6693a284abf2dc2d1c36553ae3a1ead5a52173506bb9f4a0e4b8fd
Python
2,611
100
# -*- coding: utf-8 -*- """ pysteps.visualization.spectral ============================== Methods for plotting Fourier spectra. .. autosummary:: :toctree: ../generated/ plot_spectrum1d """ import matplotlib.pylab as plt import numpy as np def plot_spectrum1d( fft_freq, fft_power...
f668977077e5bde41e2f0fc3f7e4f2da8b4bdd71521fdfd0ed70b1059c5af671
Python
2,613
65
#!/usr/bin/env python from __future__ import print_function from collections import OrderedDict import re regexes = { 'nf-core/rnaseq': ['v_ngi_rnaseq.txt', r"(\S+)"], 'Nextflow': ['v_nextflow.txt', r"(\S+)"], 'FastQC': ['v_fastqc.txt', r"FastQC v(\S+)"], 'Cutadapt': ['v_cutadapt.txt', r"(\S+)"], '...
db1026f0137d5986ca8cda0d1decbce785f183780548e038a31815ac1061f19a
Python
2,616
67
SHAPE=(2500, 12, 1) def multi_conv2D(x, num_kernel, activation="relu"): kreg = None skip = Conv2D(num_kernel*3, 1, activation=None, padding="same")(x) skip = BatchNormalization()(skip) a = Conv2D(int(num_kernel), 1, activation=activation, padding="same", kernel_regularizer=kreg)(x) a = BatchNormali...
889fb88496f284c0f9aeb3d7af484670b6dc8b39c35af91ac2633713ce9bbc49
Python
2,617
75
# -*- coding: utf-8 -*- import os import numpy as np import xarray as xr import pandas as pd import matplotlib.pyplot as plt from scipy.ndimage.filters import gaussian_filter from allensdk.brain_observatory.ecephys.ecephys_project_cache import EcephysProjectCache from allensdk.brain_observatory.ecephys.ecephys_sessi...
62ceff23131eeb4cc43815290f6c3ce6bd052ec25b388ac0bddc7b475689051d
Python
2,618
69
import time import pandas as pd import torch from sklearn.metrics import accuracy_score, roc_auc_score, f1_score, matthews_corrcoef from DCiPatho_config import Config from DCiPatho_network import DCiPatho from Utils import cal from Utils.combine_fna import combine from Utils.tool import data_preprocess_for_...
563be380d778d6a7cc7152a80ef3678b52481d53b39b7495ec1dab1ec3701e09
Python
2,619
108
import numpy import numpy.random import pytest import cellprofiler_core.image import cellprofiler_core.measurement from cellprofiler_core.constants.measurement import M_LOCATION_CENTER_X, M_LOCATION_CENTER_Y, M_LOCATION_CENTER_Z, \ M_NUMBER_OBJECT_NUMBER, FF_COUNT import cellprofiler.modules.convertimagetoobjects...
35eb3c36527e3de3bf59bfbf44826ad6b962278d3151c3df8265e70d95fda283
Python
2,621
72
import numpy as np # FROM SCILPY def identify_shells(bvals, threshold=40.0, roundCentroids=False, sort=False): """ Guessing the shells from the b-values. Returns the list of shells and, for each b-value, the associated shell. Starting from the first shell as holding the first b-value in bvals, the...
858053a0c72ce0df288d1ba99e1565ae67507253289d64696d0886fdb52843bb
Python
2,621
85
from __future__ import division from __future__ import print_function import sys from six.moves import xrange import numpy as np from sklearn.preprocessing import StandardScaler from sklearn.feature_selection import VarianceThreshold from sklearn.feature_selection import SelectKBest, RFE, f_classif from sklearn.svm i...
f63992e1a28d7230f17778d01925228a9f7b24c2eea083d8745fc7b7f22d710d
Python
2,623
80
#!/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...
ba34a3aeb69376b507dd846dc825f88cea11ff1e988f552a0ee620f740b606c1
Python
2,627
60
import numpy as np from tabulate import tabulate def pad_to_next_multiple_of_32(img): """ Pad each dim to multiples of 2^5 = 32 Assuming the encoder is a ResNet with 5 blocks, it max pools images 5 times. To avoid runtime errors images are padded to the the next multiple of 32. Separately for each dime...
468e6117fd02b3542d982638d1e5cbe37b4cc9f339f8fb01adf9dfacd60f1643
Python
2,628
79
from abc import abstractmethod from functools import partial from ..optimization import NewtonMethod from ..utils.time import get_dt class BayesianSpikingModel: @abstractmethod def sample(self, t, stim, stim_h=0, full=False): if not full: v, r, mask_spikes = None, None, None ...
644b3a5945f43b446b99ffa89f5c3b48fdc8698891bc2615c370f7096607b5cc
Python
2,630
67
""" pysteps.cascade.interface ========================= Interface for the cascade module. .. autosummary:: :toctree: ../generated/ get_method """ from pysteps.cascade import decomposition, bandpass_filters _cascade_methods = dict() _cascade_methods["fft"] = (decomposition.decomposition_fft, decomposition.r...
1f8267107d70d93572851c630ce3d027efeee3dd8db5298b60cb58854a073f66
Python
2,635
75
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jan 13 17:34:20 2021 @author: andrey """ import time import os import pickle import scipy.optimize class _Callback: def __init__(self, out_path): self.__out_path = out_path self.__cnt = 1 def call(self, x, f, accept): ...
1e6b1acef628fce62a780ed04d7c04f2c4bf7bb3db3b229b6fb607d6dc1501cc
Python
2,640
72
# -- coding:utf-8 -- import tensorflow as tf from tensorflow import keras from tensorflow.keras.models import Model from tensorflow.keras.layers import Dense, BatchNormalization, Dropout from tensorflow.keras import losses, optimizers import scipy.io as sio import numpy as np def load_mat_data(file_name): ...
e4664d0c480e0dbfa4a39902c232415e37df02c023d87c74117aac6e54cd95e0
Python
2,641
84
import matplotlib.cm import numpy import skimage.color from ...preferences import get_default_colormap from cellprofiler_library.functions.object_processing import size_similarly as _size_similarly from cellprofiler_library.functions.object_processing import crop_labels_and_image as _crop_labels_and_image def crop_la...
15b2d8a5de2cc5810ba46f8067176aef3d512da4161c123fb82d2540ed32e5d0
Python
2,646
88
from __future__ import division import os import sys from six.moves import xrange import numpy as np from .dataset import Datasets, Dataset from .download import maybe_download_and_extract try: import cPickle as pickle except ImportError: import pickle URL = 'http://www.cs.toronto.edu/~kriz/cifar-10-python...
df582469cc19892e5b2df3cbb424fd5886e75e564bb0188b08c5e72072f98d20
Python
2,647
87
"""test_cellprofiler - test the CellProfiler command-line interface """ import os import shutil import subprocess import sys import tempfile import unittest from tests.frontend.modules import get_test_resources_directory if hasattr(sys, "frozen"): ARGLIST_START = [sys.executable] else: ARGLIST_START = ["-m", ...
636d22b4f07fd7458c67ebe36113ba763e76fb37eb2cdbc4af471ac767e6e063
Python
2,656
67
from Levenshtein import distance as levenshtein_distance from Bio import SeqIO import csv import sys import os def calc_sim_corrected(seq1, seq2): min_len = min(len(seq1), len(seq2)) abs_diff = abs(len(seq1) - len(seq2)) lev_dist = levenshtein_distance(seq1, seq2) - abs_diff return (1 - lev_dist / mi...
673140d9ed629855d2e90700a95f71bb25ffda24f6c3525c28e75a22d2503fbf
Python
2,656
88
# -*- coding: utf-8 -*- import os from tempfile import NamedTemporaryFile import pysteps from pysteps import load_config_file minimal_pystepsrc_file = """ // pysteps configuration { "silent_import": false, "outputs": { "path_outputs": "./" }, "plot": { "motion_plot": "quiver", ...
93367d6f9472dff1d18a62487efc70581aaa476acfe785ce437365a618455bb6
Python
2,657
55
from deeprank.models.amino_acid import AminoAcid alanine = AminoAcid("Alanine", "ALA", "A") arginine = AminoAcid("Arginine", "ARG", "R") asparagine = AminoAcid("Asparagine", "ASN", "N") aspartate = AminoAcid("Aspartate", "ASP", "D") protonated_aspartate = AminoAcid("Protonated Aspartate", "ASH", "D") cysteine = Amino...
c15ec4ba7782da2aa45736ab3e51e3480827267f74ec555311f536b4a8e9a348
Python
2,657
104
config = { 'lr': 0.0010924329072635147, 'alpha_di': 0.0017723664900917734, 'k_p_fb': 0.0713515876863314, 'alpha_fb': 0.39857902933813705, 'feedback_wd': 0.1, 'time_constant_ratio_fb': 0.005870467170683501, 'dt_di_fb': 0.0011421804343878519, 'apical_time_constant_fb': 0.1404664564483908, 'lr_fb_init': 0.0001524121535306...
12d2b30ac16b42cbab2a0f617350e1ed927ac2e2086879f6c5018302c5198fe1
Python
2,662
77
import pandas as pd from src.tasks.metrics import get_reg_metrics import wandb import matplotlib.pyplot as plt import seaborn as sns import torch def save_feature_importance(df, num_features): if df is not None: df.sort_values(['importance'], ascending=[False], inplace=True) df['importance'] = df[...
4255cdb6921265457eb0bd037ea6e534081330d94a482ad6be4ab577af8959e3
Python
2,663
87
import pyb import math # Random functions and classes ----------------------------------------------- max_rand = 1 << 30 # Largest number output by pyb.rng() def random(): #Return a random float x such that 0 <= x < 1. return pyb.rng()/max_rand def withprob(p): # Return a random boolean tha...
daa7858497740eb36abc846a9805a59bcd6b12feb24c6e364dd1bb76b10dab20
Python
2,666
75
from unittest import TestCase import numpy as np from numpy.testing import assert_equal import scipy.sparse as sp from .distortion import (perm_adj, perm_features, filter_adj, filter_features, gray_color_threshold, degree_threshold, area_threshold) class DistortionT...
44dc7e6af6ae96d69c8f464755ba0ae9af548a97a516cba10b71d3edf0df99d0
Python
2,667
77
# Implementation of Collapsible Pane container # importing tkinter and ttk modules import tkinter as tk from tkinter import ttk class CollapsiblePane(ttk.Frame): """ -----USAGE----- collapsiblePane = CollapsiblePane(parent, expanded_text =[string], co...
e1bc4d00ce3899cbcc2f397b8f24674a9a337aef2ec75da16005ad8ead9b8899
Python
2,667
82
# script that allows you to start multiple similuation in parallel independently of eachother # Requires input from user, i.e., path to file that contains paths to input of simulation import os import subprocess import sys import time Narg = len(sys.argv) path_tostoreFinished = "." numprocess = 2 # should not go hig...
9177d966358afbf1be0221b18c5d22c10548fdc98afd08f03b56fcd6c79b402d
Python
2,668
87
import numpy as np from netCDF4 import Dataset from scipy import signal import os, pathlib from scipy import stats #========================================================== # Set main directory #========================================================== hdir = '/home/jhkim/model/deep_detection' #===================...
96c1fcd401d5400c146d9ba08d960a38c78a43c892640a0fdc77fcd17703f259
Python
2,671
80
import numpy as np from netCDF4 import Dataset import os, pathlib from scipy import stats #========================================================== # Set main directory #========================================================== hdir = '/home/jhkim/model/deep_detection' #============================================...
36982306816c0ca8a197129693a5bbe5c52a503cf3c7b5bdfed1cd50630df9cf
Python
2,672
99
# -*- coding: utf-8 -*- import numpy as np import pytest from pysteps.nowcasts.lagrangian_probability import forecast from pysteps.tests.helpers import get_precipitation_fields from pysteps.motion.lucaskanade import dense_lucaskanade def test_numerical_example(): """""" precip = np.zeros((20, 20)) precip...
a2be683f395c258413f6717208fff9cad00a7ef73ad2c270b26ac7455b11ce3b
Python
2,672
84
import prov.model as pm from .Core import Core, getUUID from ..core import Constants class Session(pm.ProvActivity, Core): """Class for NIDM-Experimenent Session-Level Objects. Default constructor uses empty graph with namespaces added from NIDM/Scripts/Constants.py. Additional alternate constructors for...
32fc198d3519d757bc211266a1b1db65f833a5393a2e89923d2cdee6cb7c42c1
Python
2,673
95
# -*- 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...
5be41abbf4de0dabb667c2c50cee886331a6e92f6ff83d67994ae46e4106b51e
Python
2,675
95
# -*- coding: utf-8 -*- # # model_comparison.py # """ Work function for model comparison experiments. """ __author__ = "Severin Langberg, Ahmed Albuni" __email__ = "langberg91@gmail.com, ahmed85@gmail.com" from typing import Dict import numpy as np from pandas import DataFrame from tqdm import tqdm from .comparis...
da3c99208726fd5f4d3f12bf9117ff5ea9f52ef987b0b99d78bd4ee75999c58b
Python
2,677
95
import numpy as np import matplotlib.pyplot as plt # Define parameters Cm = 1 # membrane capacitance g_Na = 120 # maximum sodium conductance g_K = 36 # maximum potassium conductance g_L = 0.3 # leak conductance E_Na = 50 # sodium reversal potential E_K = -82 # potassium reversal potential E_L = -84.4 # leak ...
b1b160c248de42d41934689f088a0c6b4e578b2426cf7f0eb6881da153baad7b
Python
2,678
74
import numpy as np import trimesh import trimesh.sample from megsimutils.arrays import BarbuteArraySL from megsimutils.viz import _load_anatomy # Downsample the head mesh to this number of vertices to speed up # computations _NVERT_HEAD_HEAD = 700 def _map_barbute_to_scalp_point(point, R_inner, R_outer, head_pts, d...
ec26f130f2951be132b1774541370ee9d186d7ef3c8b9811b1598ec339b9d41a
Python
2,678
71
import torch.nn as nn def assemble_architecture(): """ Function assemble_deeper_CNN() assembles a CNN deep learning model with the next architecture: 1. Conv layer - 10 kernels of size 5, stride 1, no padding 2. Max-pool layer - kernel size 2, stride 2 3. ReLU non-linearity 4. ...
2fe762db80081f6440d21cacaea3084447c213387e33bd33ec06721bc3a59b34
Python
2,679
63
#!/usr/bin/env python3 """ Copyright 2017 Ryan Wick (rrwick@gmail.com) https://github.com/rrwick/Filtlong This script was used to get read length/identity stats from a minimap2 PAF alignment file. I used it to make the scatterplot/histogram figures in the Filtlong README. It uses a particularly strict definition of r...
48925bf43e582576db61fba5db84eee3d84ebc0bb6eb01e8eaf4ef423a6a65d6
Python
2,683
76
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
68d49baee74194c9b2e0e2460f83dc1e6468cd7fcae957af3d52e095cb5311d4
Python
2,683
92
# # nate berry # 2023-04-01 # # --------------------------------------------------------- # NOTES: # - this script calcualtes the false nearest neighbors for # the EEG and COM data # - plotting is performed in <03_state_space.py> # - check the excel export to ensure it's not commented out # if runnin...
3a8dae3dfdc6734e31657de1e1463b4da31db68b2ad9be74dbc06d76cee0d7a4
Python
2,684
63
import scipy.ndimage as ndimage import skimage.measure as measure import numpy as np def _keep_connected_binary(binary_mask, voxel_vol, min_volume=None, keep_only_largest=1): if keep_only_largest==0: return np.zeros(binary_mask.shape, dtype=binary_mask.dtype) mask_ind, num_features = measure.label(...
0f23500a05740f26405233334fc44c7183da0f51a94cd65dae092808b40fd339
Python
2,685
51
import numpy as np import pandas as pd from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestRegressor from sklearn.metrics import r2_score from sklearn.metrics import mean_absolute_error from sklearn.metrics import mean_squared_error ls_r2=[] ls_mae = [] ls_rmse ...
d631b67f80a497f2be26dedcc272415e2bd76f0193703090368c45616b3e25b3
Python
2,685
87
import torch import torch.nn as nn class DecodingModule(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, netwo...
f3ef354eb3fc0261371135c8bd050a143d6f98a341cb695f6dcd509ccd5e1883
Python
2,685
106
""" Shared mophology methods used by multiple modules """ import numpy import scipy.ndimage import skimage.morphology def dilation(x_data, structuring_element): is_strel_2d = structuring_element.ndim == 2 is_img_2d = x_data.ndim == 2 if is_strel_2d and not is_img_2d: y_data = numpy.zeros_like(x...
09cb73870648b7d9c1af4263a387c397dc6dd8d5ebff5b3163290c16db75faf8
Python
2,692
72
import os import numpy from pdb2sql import pdb2sql import pandas from deeprank.features.FeatureClass import FeatureClass from deeprank.operate.pdb import get_pdb_path def _get_c_alpha_pos(pdb_root, variant): pdb_path = get_pdb_path(pdb_root, variant.pdb_ac) db = pdb2sql(pdb_path) try: if varia...
b27cb0751ced372218afac273f91e0a2a3812f205d4812e79b038b91227e1c5f
Python
2,692
88
import os import sys import threading from importlib.util import find_spec def find_python(): if hasattr(sys, "frozen"): if sys.platform == "darwin": app_python = os.path.join(os.path.dirname(os.environ["ARGVZERO"]), "python") return app_python return sys.executable def find...
0557d31be9ea127ba71119b323222347c59521c0c4599e87e27a66275fd8e283
Python
2,693
126
BASE_SCRIPT=""" #!/usr/bin/env bash VERBOSE=0 INTERP="Linear" DTYPE="default" IN_DTYPE=0 INTERP_TRANSFORM_LIST=("Linear" "NearestNeighbor" "BSpline" "MultiLabel" "GenericLabel") ANTS_DTYPES=("char" "uchar" "short" "int" "float" "double" "default") IN_DTYPES=("0" "1" "2" "3" "4" "5") USAGE=$(cat <<-END Usage: $...
732f4a652879e8376f0160e2d222caef4800f547e28dc3b6f7b02abb50506d38
Python
2,699
78
from glob import glob import os from typing import Dict, Set from pdb2sql import pdb2sql import numpy import h5py from deeprank.config import logger from deeprank.features.FeatureClass import FeatureClass from deeprank.operate.pdb import get_residue_contact_atom_pairs, get_pdb_path from deeprank.parse.dssp import par...
ca180a13bb2218d4cb094f35593f63b14b064a55a4ed72996bbbf1a7c7706799
Python
2,700
83
from scipy import io import pandas as pd from time import time import torch from torch.nn.utils.rnn import pad_sequence from atom3d.datasets import LMDBDataset import atom3d.util.formats as fo from ase.units import Ha, eV element = {'H': 1, 'C': 6, 'N': 7, 'O': 8, 'F': 9} def qm7(): data = io.loadmat('./qm7.mat'...
69ab5727a8dd25a3401dafed3f31df0b580e42b3d824bb60f9c61e505be433fb
Python
2,701
71
import torch import torch.nn.functional as F from abc import ABC, abstractmethod from GANDLF.utils.tensor import reverse_one_hot, get_linear_interpolation_mode, one_hot from typing import Tuple class AbstractPredictionTargetProcessor(ABC): def __init__(self, params: dict): """ Interface for class...
e39d07cc3cc9e9faafe27e22ee29c6da7a4ac9018bbbe53771562f9bd959d5c2
Python
2,701
88
from unittest import TestCase import numpy as np from numpy.testing import assert_equal import scipy.sparse as sp from .spatial import (node_selection, neighborhood_selection, receptive_fields, fill_features) class SpatialTest(TestCase): def test_node_selection(self): points = np.a...
dc6a2b69c35339a9bc84551f11620c0d6d5752328acbb238a29d580b4debcd3b
Python
2,706
65
import sys from argparse import ArgumentParser import logging import pytorch_lightning from pytorch_lightning.strategies import DDPStrategy from models import SubtypeDataModule, ScanCLSLightningModule, ScanRegLightningModule def run_measurement_job(): parser = ArgumentParser() parser.add_argument("--model_a...
3aa6cf30991a647e24aff87864a93f7d9e32a108fa319dfd10bf9d419fa0cbea
Python
2,708
82
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import pickle import shutil import tempfile import time import numpy as np import torch import torch.distributed as dist from utils.parallel import get_dist_info from utils import ProgressBar def single_gpu_test(model, data_loa...
3b7b89d66e350547babc05c65332d8d95380df31f5b3ad7fe706d096d5c8031e
Python
2,711
52
from src.models.tabular.pytorch_tabular.base import PTBaseModel from src.models.tabular.pytorch_tabular.repository.models.ft_transformer.ft_transformer import FTTransformerModel from omegaconf import DictConfig class PTFTTransformerModel(PTBaseModel): def __init__(self, **kwargs): super().__init__(**kwar...
2c2a9cc3fdad0aa5e9058c9ba3a2dd016250bcfca3e7adc2eba21b0ca685bc66
Python
2,713
79
#!/usr/bin/env python __author__ = "Marc Steffen Seibel and Thomas Jochmann" __email__ = "seibelsteffen@web.de" """ Requires: Dataframe stored at settings.ica_meta_dataframe_path. `preprocess_ica.py` produces this dataframe. It contains positions of EKG windows which are to be extracted. Returns: Dataset ...
0fdba936a2d963e9c3b1025b2db9ffad3f91716827cc655401423392db9ba2f5
Python
2,720
83
# python implementation of scAI optimization model # import packages import numpy as np from numpy import linalg as LA from numpy import matrix def scAImodel_py(X1,X2,K,S=0.25,Alpha=1,Lambda=10000,Gamma=1,Maxiter = 500,Stop_rule=1,Seed=1,W1=None,W2=None,H=None,Z=None,R=None): # parameters d1 = X1.shape...
e8c6a92057864f6b3a1afa26e27fd433aa0f6af7f28a6e09f51050e5b67bb947
Python
2,723
77
from unittest import TestCase import numpy as np from numpy.testing import assert_equal from .dataset import Datasets, Dataset class DatasetTest(TestCase): def test_init_dataset(self): images = np.array([1, 2, 3, 4, 5]) labels = np.array([0, 1, 0, 1, 0]) dataset = Dataset(images, labels)...
089e507e432ada98bec956cab48c3a5819345b9cffd53fa33ae19f6dac8e12f1
Python
2,724
80
# -*- 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...
4e16da4712b445212cf3b547c648a911db21ffee7ff71f2b0d9bab4e5063c101
Python
2,725
83
from cellprofiler_core import workspace from cellprofiler_core.constants.measurement import EXPERIMENT from cellprofiler_core.constants.measurement import GROUP_INDEX from cellprofiler_core.constants.measurement import GROUP_NUMBER from cellprofiler_core.constants.measurement import IMAGE from cellprofiler_core.constan...
b4561d32a90c81847074a004dd06490d5301f84a5e6898dbb799aa989472e6ec
Python
2,727
63
import numpy as np import sys sys.path.append('..') from functions.individual_variability import intra_individual_difference_score from functions.individual_variability import intraIndividual_difference_plots from functions.individual_variability import intraIndividual_difference_plots_sameHemi # All individuals wit...
2c52360f24988a5492b3fa5594381d6bbcc8a054c8cb9e39acdfa443bf1ee074
Python
2,729
91
#!/usr/bin/env python from __future__ import print_function import argparse import markdown import os import sys import io def convert_markdown(in_fn): input_md = io.open(in_fn, mode="r", encoding="utf-8").read() html = markdown.markdown( "[TOC]\n" + input_md, extensions=["pymdownx.extra", "py...
638f83cc0fd5fd2035952ec0a39eb6d4f109a135815431b781d15a019d8668be
Python
2,729
103
# -*- coding: utf-8 -*- import matplotlib as mpl mpl.use('agg') from matplotlib.testing.compare import compare_images from tempfile import NamedTemporaryFile import os.path import pygenometracks.plotTracks ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_data") tracks = """ [n...
53fb83c9546105e674c0f8c3353477f732c1134a358566925378cb4a6ac29b3a
Python
2,733
79
import torch from abc import ABC, abstractmethod from GANDLF.losses import get_loss class AbstractLossCalculator(ABC): def __init__(self, params: dict): super().__init__() self.params = params self._initialize_loss() def _initialize_loss(self): self.loss = get_loss(self.param...
b947d130f8876065c7782ecd1bdd0eae85f3672ea5169d8471220c1b40c7d706
Python
2,733
81
import tensorflow as tf from .layer import GradientLayer,BoundaryGradientLayer class PINN: def __init__(self, network): self.network = network self.grads = GradientLayer(self.network) self.boundaryGrad = BoundaryGradientLayer(self.network) def build(self): TYR_dmn0 = tf.k...