sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
506e622e7e67a301bc16f8cde4670bb0ed5493109d8f8581bbee8b14c65c181c
Python
9,397
229
import schnetpack as spk import readline import os from sys import argv import numpy as np from ase import Atoms from ase.units import Bohr from schnetpack.data import AtomsData def read_dataset(path,numberofgeoms,filename): atom_buffer = [] property_buffer = [] charge_buffer = [] metadata = {} for...
db3ad2eeb76eece7b6d78df1b260a577c1fad486d2a709ebbbd1837920902db6
Python
9,397
291
"""distutils.core The only module that needs to be imported to use the Distutils; provides the 'setup' function (which is to be called from the setup script). Also indirectly provides the Distribution and Command classes, although they are really defined in distutils.dist and distutils.cmd. """ import os import sys ...
fd8549afe00f1a92e3e728ce1b5df15388cb68871adb575b83009d431a73f148
Python
9,397
263
import numpy as np from torchvision.models.resnet import Bottleneck from wsilearn.utils.cool_utils import * from wsilearn.dl.np_normalizer import create_input_normalizer from wsilearn.dl.models.model_internal_utils import ModelHook from wsilearn.dl.np_transforms import NumpyToTensor from wsilearn.dl.torch_utils import...
37bfa489072d523fbcb29b793e2b9af21fc9e65791da3ca12624e5cb7b510a9a
Python
9,399
240
# 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 # # ht...
8e31634aa35fed6dbe4dae98524cb02b43f87768b4073fcca8b39f97b3b54e4c
Python
9,399
328
"""Handwritten parser of dependency specifiers. The docstring for each __parse_* function contains ENBF-inspired grammar representing the implementation. """ import ast from typing import Any, List, NamedTuple, Optional, Tuple, Union from ._tokenizer import DEFAULT_RULES, Tokenizer class Node: def __init__(sel...
50b7b4a78a86674cf42a33e74cd74aacaf9b6b7d7fadb7c3838b086cb8da89fc
Python
9,402
229
import schnetpack as spk import readline import os from sys import argv import numpy as np from ase import Atoms from ase.units import Bohr from schnetpack.data import AtomsData def read_dataset(path,numberofgeoms,filename): atom_buffer = [] property_buffer = [] charge_buffer = [] metadata = {} for...
ac4ea7d123694ba9cd5b1f04f0c36deaf5a998afe5a7c778170a266bb26f2b82
Python
9,402
281
from __future__ import annotations import os from importlib.util import find_spec from pathlib import Path import pytest from ase import units from ase.io import read from pymatgen.io.qchem.inputs import QCInput from quacc.calculators.qchem import QChem has_obabel = bool(find_spec("openbabel")) FILE_DIR = Path(__f...
e173adab2bd40a5a74c2933e926edc3917049a06a5a2b92bc2f39fc982206e59
Python
9,409
335
# coding=utf-8 # Copyright 2026 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
7a19a1fd089bce5d8918f96dfbee7802eb6e64addb1386f8536c558d27b76ec3
Python
9,413
221
from pathlib import Path from collections import defaultdict import numpy as np import pandas as pd from pathlib import Path from tqdm import tqdm import pandas as pd from torch.utils.data import DataLoader from wsilearn.utils.cool_utils import read_json_dict, mkdir, Timer, is_string_or_path from wsilearn.datacon...
e47b81723df0b8d9fa810786ff5c924380e18d9cb270f1989658deaf81c93eb0
Python
9,418
317
# pylint: disable=invalid-name, missing-function-docstring, missing-class-docstring, unused-argument, too-few-public-methods, no-member, too-many-arguments, line-too-long, too-many-instance-attributes """ FBNetGen model sub-modules from https://github.com/Wayfear/BrainNetworkTransformer""" import time import numpy as...
a0fff19bd588fdf24b9d0a14314546ed6b771bcf6725953f744af030717cfbfa
Python
9,420
218
from pathlib import Path import natsort import numpy as np import PIL.Image import matplotlib.pyplot as plt import pandas as pd import cv2 import glob import os import re import Dicts def get_cts(patient, use='mod', w='1', mods='gaussian'): path = '' if use == 'original': path = r"../../data/output_da...
f8fadc009d01447222c15ff323560e99a65839408fda2325b6da3d94af260c26
Python
9,421
243
#!/usr/bin/env python """ Copyright (C) 2012 Computational Neuroscience Group, NMBU. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later ver...
33cd79e0ccf5a1bf63a9cd2b4c6554e77030aaf971d6cd385781f45f90e1cf2f
Python
9,422
253
# Script to perform polynomial regressions on TVAT data try: from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.Get_rank() nhost = comm.Get_size() except ModuleNotFoundError: rank = 0 nhost = 1 from os.path import join from get_paths import * import h5py import numpy as np import matplo...
4ac3fc3f776eee7358d125ed13c39b4ed66d690eee8b570bfc77b55807cefbed
Python
9,428
220
''' Script to run and plot stats on sensor-level decoding patterns. Cluster based permutations in space and time are used.''' proj_name = 'MINDLAB2020_MEG-AuditoryPatternRecognition' import sys sys.path.append('/projects/' + proj_name + '/scripts/working_memory/') import mne import numpy as np from matplotlib import ...
79a4c5fae2196fa7a2db30ee8cc3f744e743fc87562bb809c8dd18ba53018684
Python
9,430
313
#!/usr/bin/env/python # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. from collections import defaultdict import os import pickle import json import torch.nn as nn import ...
dbdbadbc0a136734b01415dbf371b516198efecb11430e5722b72fda9d3cc973
Python
9,431
273
from __future__ import annotations import os.path import re import shutil import tempfile import zipfile from glob import iglob from ..bdist_wheel import bdist_wheel from ..wheelfile import WheelFile from . import WheelError try: from setuptools import Distribution except ImportError: from distutils.dist imp...
f60b6b5a4fa2b753c7320990b173cfe39e79d9ea4504ebae56fd4b5e76b151fe
Python
9,431
237
from argparse import ArgumentParser import ast import pytorch_lightning as pl import torch import os import torch.nn as nn os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # tf warnings set to silent in terminal from pytorch_lightning.callbacks import ModelCheckpoint from torchvision.models import resnet18, resnet34 from mode...
86243744c39c1be0a6ed30e620822a95aa4cfb6e29834cf19774ebae68136036
Python
9,433
179
# Want to take 50% of task evoked and resting state trials (resting state trials are dummy) # Want to compute CCA for both # Want to store evoked time course of component 1 # Repeat 1000 times # Get correlation between time courses - should be higher for task evoked versus resting state import numpy as np import panda...
b7ab9ad0bd82524fe2bf3564ece7541ad5ca1c3a7d2f3546d5490fbbde1c29a5
Python
9,433
260
# # MIT License # # Copyright (c) 2022 GT4SD team # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge,...
1d01b88d1b6a9e425cb9147ecfb604598825a7df2e8bbaab98b38f90e2f76b03
Python
9,435
275
# coding=utf-8 # Copyright 2026 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
029b04b3de15f1c923d91ca84748a4463a162208ed6b466f019757f5de3b3c8f
Python
9,437
303
# pylint: disable=invalid-name, missing-function-docstring, missing-class-docstring, unused-argument, too-few-public-methods, no-member, too-many-arguments, line-too-long, too-many-instance-attributes, too-many-locals """ MILC model module from https://github.com/UsmanMahmood27/MILC""" from copy import deepcopy impor...
96ae6a314876f458c49a08be98012f0e4400d65df9b3b0f7ce8ff974fb56451e
Python
9,437
244
""" Created on 29/06/2020 :author: Chinchien Lin :summary: """ import sys import SimpleITK as SITK import json import datetime import os from src.utils import sitk_utils as sutils class RegistrationFromMaps: """ Perform map-based registration using the pre-generated transformation parameter f...
d3f9cd76add69b04906cec484265ea656480ae81f2714dba6636011f25a8927a
Python
9,437
248
#!/usr/bin/env python #================================================================ # Copyright (C) 2023 Yufeng Liu (Braintell, Southeast University). All rights reserved. # # Filename : micro_env_features.py # Author : Yufeng Liu # Date : 2023-01-18 # Description : # #============...
666b78c0c02d5d96cb7155f22907a4277f2701eb844dbfdc137da45a390b7901
Python
9,438
307
from __future__ import print_function, division, absolute_import import torch import torch.nn as nn import os import sys class BasicConv2d(nn.Module): def __init__(self, in_planes, out_planes, kernel_size, stride, padding=0): super(BasicConv2d, self).__init__() self.conv = nn.Conv2d(in_planes, ou...
c42045472e7ea6ab81e4135e41c1f54edb641ba9c9f3b426041e61a0c17a462f
Python
9,442
230
from typing import List from typing import Union import numpy as np from skimage import transform from skimage import feature from skimage import registration import cv2 from merlin.core import analysistask from merlin.util import aberration from merlin.util import imagewriter class Warp(analysistask.ParallelAnalysis...
10b34161adfe67b682eb30cc043256aaff79c9b87b394db7401c27254f753477
Python
9,443
292
################################################################################ # Copyright (c) 2021-2024, Lawrence Livermore National Security, LLC. # Produced at the Lawrence Livermore National Laboratory. # Written by D. Jones <djones@llnl.gov> and UCSD collaborators in listed in CONTRIB.md # # All rights reserved....
2f1444827aa2805519d619f4a7508a4b6b4f45df3dec9fd92e37585e8a564585
Python
9,443
313
import os import argparse import torch from sklearn.metrics import roc_auc_score import numpy as np from maldi_nn.models import AMRModel from maldi_nn.utils.data import DRIAMSAMRDataModule from lightning.pytorch.callbacks import ModelCheckpoint, EarlyStopping from lightning.pytorch.loggers import TensorBoardLogger from...
4fa78504a699858c7422e957c4a067d5e3bd4515c41eff133f4cf09241c0bd74
Python
9,443
267
''' This code is modefied based on a TCN impelemtation by https://github.com/locuslab/TCN ''' import os import csv import math import joblib import argparse import numpy as np from pathlib import Path from scipy.stats import pearsonr, spearmanr import torch import torch_xla import torch_xla.core.xla_model as xm impor...
aabb948eb314dd41aad02f8c724bcd02807ccd41445c0c66cba7ca044b723d9a
Python
9,445
246
# coding=utf-8 # Copyright 2026 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
61dcb2735817c1a34fc396785f487b27f7b0e7c7002b987508fa1290d1426d41
Python
9,446
250
"""Wrapper for converting a Meep simulation into a differentiable JAX callable function. Usage example: ``` import jax.numpy as jnp import meep as mp import meep.adjoint as mpa sources = [ mp.EigenModeSource(...) ] monitors = [ mpa.EigenmodeCoefficient(...), mpa.EigenmodeCoefficient(...), ] design_regions = [...
b91764361f685f2e86dc765f8875e2944c67659d34711a2376ef8a81dc9459e1
Python
9,446
233
import numpy as np import sys from pydrake.all import ( BasicVector, LeafSystem, PortDataType, ) from pydrake.util.eigen_geometry import Isometry3 from pydrake.trajectories import ( PiecewisePolynomial ) from pydrake.math import RollPitchYaw from robot_plans import * class ManipStationPlanRunner(Lea...
f9aece5b33622d1836f5611d1e9aa8114245dca3d034b03dbc7b0d647b752d12
Python
9,446
262
""" Created on Fri Jul 17 16:59:51 2020 @author: Leonardo Bonetti, Francesco Carlomagno leonardo.bonetti@clin.au.dk """ #To use this script please do the following: #-place the provided stimuli folders in your favorite directory #-assign to the variable 'stimidr' (few lines below) such directory #-define your log ...
3634263fd35b82ecf7ad4426d993d3cae1edaacb4bd8bcb558311886699e9bd8
Python
9,449
349
# coding=utf-8 # Copyright 2026 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
6226d4cece5f33a72a038b2bad7afa6ed6df26ed0f3dc2cbf1e0de6fed3da427
Python
9,450
312
#adapted from: Pingjun Chen # https://github.com/PingjunChen/tissueloc/blob/master/tissueloc/locate_tissue.py # MIT License Copyright (c) 2018 Pingjun Chen ## Changes: output asap tif masks, support for spacing parameter ## Note: fat is sometimes not recognized import argparse import sys from pathlib import Path fro...
639632a2d6a7912e8c894b1244f2cc791a1cffc843a1ee8eef2960f8daa5ddb0
Python
9,450
310
# -*- coding: utf-8 -*- # # syncopy.connectivity backend method tests # import numpy as np import matplotlib.pyplot as ppl from syncopy import synthdata from syncopy.connectivity import csd from syncopy.connectivity import ST_compRoutines as stCR from syncopy.connectivity.wilson_sf import wilson_sf, regularize_csd, ma...
ebba0eb5d0c626444479c80a9308052a13669f9478f5ef4be958cd301661d2c4
Python
9,451
275
"""Test the full PREP pipeline.""" import matplotlib.pyplot as plt import mne import numpy as np import pytest import scipy.io as sio from pyprep.prep_pipeline import PrepPipeline from .conftest import make_random_mne_object @pytest.mark.usefixtures("raw", "montage") def test_prep_pipeline(raw, montage): """Tes...
c8ac7b8b3a8d877a69b6250031fee609f1dde78df272aeb45a4344d21639ae19
Python
9,452
339
""" ============= Preprocessing ============== Extracts relevant data and removes artefacts. Authors: José C. García Alanis <alanis.jcg@gmail.com> License: BSD (3-clause) """ # %% # imports import sys import os import warnings from pathlib import Path import numpy as np import matplotlib.pyplot as plt from mne i...
f82c1603dc9e354d9798b7645b6657c105f1b01ea9ba614776a29c1495e3ba8e
Python
9,454
197
from argparse import ArgumentParser, Namespace, FileType from Bio.PDB import PDBParser,MMCIFParser from Bio.PDB import PDBIO, MMCIFIO, Select import os,copy from tqdm import tqdm from utils.relax import openmm_relax, openmm_relax_protein_only from rdkit.Chem.rdmolfiles import MolToPDBBlock, MolToPDBFile import rdkit.C...
3b7651c91a754a9ed6ccdd67b071d0648945b4905e1e4e145cbe4591d1c3b949
Python
9,455
153
""" Builds the database in two main steps: 1) Imports all the data from ontologies, databases and experiments 2) Loads these data into the database The module can perform full updates, executing both steps for all the ontologies, databases and experiments or a partial update. Partial updates can e...
b2ff812956e07156b2f66dfd1c580ddfa12dd9fceab7d95614396a3ff79293fd
Python
9,456
289
from collections.abc import Callable, Iterator from pathlib import Path import cocotb as ctb import pytest from cocotb.clock import Clock from cocotb.triggers import RisingEdge from cocotb.types import LogicArray import elasticai.creator.function_dispatch as FD import elasticai.creator.ir as ir from elasticai.creator...
e72ed2899a96bb6d387cb774a49fadd708df4906e2fc1478273188d8f3ec5732
Python
9,456
210
from __future__ import print_function import argparse import os # os.environ['KMP_DUPLICATE_LIB_OK'] = 'True' # this code is for windows platforms import sys from AdaHB import Adaptive_HB from PIDAO_SI_AAdRMS import PIDAccOptimizer_SI_AAdRMS from PIDopt import PIDOptimizer from PIDAO_SI import PIDAccOptimizer_SI proje...
13a31861a1ed1246d2a7a3e8401718594b21a0ce87daefe8a7660f7d3b8b0181
Python
9,457
213
""" creates a methylation plot over a given cohort """ import sys import seaborn as sns import pandas as pd import numpy as np import matplotlib.pyplot as plt import matplotlib.patches as patches import argparse import os.path def parse_args(): parser = argparse.ArgumentParser(description="Script to create a met...
5d8f922aaf51937e77e2fe828af0622028e28d8b2823bdf3f14286df8d316ff2
Python
9,459
214
from typing import List, Union import numpy as np from rdkit import Chem import torch import torch.nn as nn from torch_geometric.nn import global_add_pool from torch_geometric.utils import softmax, degree from .mpn_att import MPN #from torch.nn.utils.weight_norm import weight_norm from chemprop.args import TrainArgs ...
68e20dd16bd473b119c755d6346b22b7f830a792559892e8b099a7f49062ecd1
Python
9,463
248
import os import torch import numpy as np from tqdm import tqdm from monai.transforms import LoadImaged, ScaleIntensityRangePercentilesd, Compose from monai.data import ITKReader from scipy.stats import entropy from torch.nn.functional import softmax from sklearn.metrics.pairwise import haversine_distances from trimesh...
336d1075642b92c8f2ff592683f04b711eeaea891f34dc369628fdce38fde8f7
Python
9,467
205
"""The HED character sets of specification section 2.2, loaded from the specification's own file. ``hed/validator/data/character_sets.json`` is a verbatim copy of ``character_sets.json`` as published by hed-specification (``docs/source/_static/character_sets.json``). Both validators load the same file, so the named se...
ee21d485426200abb4212467e6985422e4205a1d2174e7beb315f56d032d5372
Python
9,467
264
""" Created on Fri Jul 17 16:59:51 2020 @author: Leonardo Bonetti, Francesco Carlomagno leonardo.bonetti@clin.au.dk """ #To use this script please do the following: #-place the provided stimuli folders in your favorite directory #-assign to the variable 'stimidr' (few lines below) such directory #-define your log ...
6898ad5b22e90a6cc34cd49f6bea5f2bb93bfb8f7a72faa74234c43745cce9d1
Python
9,468
291
# # Copyright Bradley Lowekamp # # 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.txt # # Unless required by applicable law or agreed ...
77a85688e256c8378ada949994ad5d3b6fd128bdbd76bb254045014218dc8c87
Python
9,468
273
# 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, software # distributed under th...
35bc333d5db614da83e40d6616039e19cbfdf5740e5c7da4c9a34fe4b6d18e29
Python
9,469
231
r''' This model fits the dipole and quadrupole of the inputs to the atomic charges and predicts dipoles and quadrupoles. The dipole prediction uses a contribution from atomic dipoles. The dipole moment is expressed as: $$ \begin{aligned} \mu = \sum_{i}{}^{3}\mathbb{P}_{i} + q_{i} \cdot \mathbf{r}_{i} \end{aligned} ...
3a3c78d0f22f7d8348d939d24a92640ba224c845534c393aeaf1e1f99773740d
Python
9,470
286
import os from utils.embedding_utils import * from classifiers.CustomClassifiers import AggregateClassifier import numpy as np from sklearn.base import BaseEstimator, ClassifierMixin from sklearn.utils.validation import check_X_y, check_array, check_is_fitted from sklearn.utils.multiclass import unique_labels from skle...
7fa5ddbfa9d338c5b8577fecc6ea5965eff2b3973cabff473f01ee6dbb3216a7
Python
9,471
184
''' Description: Main codes for scNODE and Dummy model training and prediction. Author: Jiaqi Zhang <jiaqi_zhang2@brown.edu> ''' import torch from tqdm import tqdm import numpy as np import itertools from model.layer import LinearNet, LinearVAENet from model.diff_solver import ODE from model.dynamic_model imp...
a6193311bdba9811cd0e390dd1f214695f1bcb8f76d558e69662f53dbc2ddec6
Python
9,474
230
"""Batch orchestration for the tissue-masking tool. Wraps :func:`process_group` in an iterable pipeline that supports progress callbacks and cooperative cancellation, suitable for use from a Qt worker thread. """ from __future__ import annotations import os import time from dataclasses import dataclass, f...
d7e0d813b96c148c9d16e5f777c0f3a71a9aa0f9a02420c071c45772ceba1380
Python
9,475
323
# This code calculates the particle level gr for a binary system and then calculates the caging potential at a particle level. The local caging potential is coarse-grained to avoid fluctuations. local sop is reciprocal of the caging potential. # Inputs : linked coordinates of big and small particles respectively. To ma...
ee0d34194bed79a1035d6203c8af096109d68d151953f6530a81262720cefd68
Python
9,477
264
from abc import abstractmethod import numpy as np from typing import Tuple from typing import List from shapely import geometry from merlin.core import analysistask class GlobalAlignment(analysistask.AnalysisTask): """ An abstract analysis task that determines the relative position of different field of...
b23602a280133ec6f9fa5fa73d987f3352549f7533ecfb28026d1dc49895a27c
Python
9,478
193
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Created on Fri Apr 8 11:29:57 2022 # @author: caroline """ This script compute the weights given to reports of priors and implicit priors. with a logistic regression (considering priors and sensory likelihood). It select trials after the prior report. Weights from th...
0d7589c0ef8e896bf7ca8cee5f15bed591dd5692b47da12ad81279823a068f6a
Python
9,481
210
# -*- coding: utf-8 -*- # # Parameterization of neural power spectra with FOOOF - fitting oscillations & one over f. # # # # Builtin/3rd party package imports import numpy as np from fooof import FOOOF import logging import platform # Constants available_fooof_out_types = ["fooof", "fooof_aperiodic", "fooof_peaks"] d...
452c7ac7be471b3be75533b98e6eb9c197ab89be92b05ce07e44113c6f401d9f
Python
9,481
210
# coding=utf-8 # Copyright 2026 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
5f72418f3760c8aaab05c543c1afb0c6b279ee27d081e37b3a620d061c158f2c
Python
9,482
273
""" Created in 2018 :author: Mahyar Osanlouy :summary: """ import SimpleITK as sitk import numpy as np from skimage.exposure import match_histograms __all__ = ['read_images_to_sitk_vector', 'read_image_to_sitk', 'calculate_origin_offset', 'sitk_resample_to_spacing', ...
0c2a2cefb267e8aa22af4b80eb090e192e990cfdbb20d5bae9fe915f36b18548
Python
9,483
179
import os import re from copy import copy from typing import Dict, Tuple, Union import numpy as np import pandas as pd from sklearn import model_selection from torcheeg.datasets.module.base_dataset import BaseDataset class KFoldCrossSubject: r''' A tool class for k-fold cross-validations, to divide the train...
5cfa1f28301090539734d459850e63afee2901974a03dcc5d97375412060d7b6
Python
9,484
228
from typing import Tuple import torch from einops import rearrange, repeat from einops.layers.torch import Rearrange from torch import nn def pair(t): return t if isinstance(t, tuple) else (t, t) class PreNorm(nn.Module): def __init__(self, in_channels: int, fn: nn.Module): super(PreNorm, self).__i...
ce177bf1450f77bf7b324c36a3f5d3ddaa175f38dd213652ec485350dbdcab06
Python
9,484
272
# coding=utf-8 # Copyright 2026 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
a17712da37884c4e4571621de805eeb57f6da83f83b42c91f783bdbe47c89136
Python
9,486
263
import contextlib import logging from abc import abstractmethod from collections.abc import Generator from contextlib import AbstractContextManager, contextmanager from pathlib import Path from time import sleep from typing import Protocol class _SynthesisFn(Protocol): """Synthesis function protocol. A synth...
14adae18ff2ee3a79de3b75cea452ff464f5d113398325332d3d316e2827712c
Python
9,491
245
"""Implementation of input/output functions for .flag files.""" import warnings import numpy as np import scipy.sparse as sp from ._utils import _extract_unweighted_graph, _extract_weighted_graph def load_unweighted_flag(fname, fmt='csr', dtype=bool): """Load a ``.flag`` file and return the adjacency matrix of ...
9434729dbae49fbe9766815521c6f40b532abb4bf3758e267590298c1be1a52b
Python
9,491
300
import numpy from collections import namedtuple from time import sleep import sys import time #@@@ import numpy as np from scipy import misc import cv2 try: import gi gi.require_version("Gst", "1.0") gi.require_version("Tcam", "0.1") from gi.repository import Tcam, Gst, GLib, GObject except ImportError...
7e0d8d8cfe6b880bd9be58b79776f608dd7b6c21d4291fd28b9be13460d6be55
Python
9,492
281
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.parameter import Parameter import matplotlib.pyplot as plt import operator from functools import reduce from functools import partial from timeit import default_timer from utilities3 import * import os import sys sys.p...
953a54341ab438f84430eff125964f954ce437a4870cadd04e2a2b00e878b678
Python
9,493
226
""" Curates an output STAR file from Relion to work as input for pyseg.pyorg scripts for microtubules Input: - STAR file with the particles to curate - STAR file to pair tomograms used for reconstruction with the one segmented used to pick the particles Output: - A curated output STAR file ...
8e02fbafea1a58614afa273c0f9646a014da9e552b352bb22f202f4b713d474a
Python
9,496
298
import numpy as np from scipy.sparse.linalg import cg, spsolve from scipy.sparse import kron, diags, csr_matrix, eye, csc_matrix from autograd import numpy as npa from autograd import grad from typing import List solvers = [spsolve, cg] def constraint_connectivity( rho: List[float] = None, nx: int = None, ...
6d8fde2949d10bf66e46c24abcf8b80daf69aea2ec6098e7ca6a3099132f95a6
Python
9,498
231
""" This script train a VQ-VAE style embedding network on Nanopore sequencing signal. @author: Haotian Teng """ import os import sys import torch import argparse import numpy as np from typing import Union,List from itertools import chain from torchvision import transforms import torch.utils.data as data from torch.ut...
4784d5e10e62e7b86562d96119337a58f420bf7b31bf1bdc402f1f9b12287aa9
Python
9,499
242
""" Elastix registration functions. Runs elastix **in-process** via the ``itk-elastix`` library. The bundled command-line ``elastix`` / ``transformix`` binaries were retired: every operation the pipeline needs - registration, image transformation, and point-set transformation - has a library equivalent here. T...
2c2ad34035fb1cb49eaa5514f83bfafcb883677375a71a808f9df507eb781e30
Python
9,500
318
import torch import torch.nn as nn def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1): """3x3 convolution with padding""" return nn.Conv2d( in_planes, out_planes, kernel_size=3, stride=stride, padding=dilation, groups=groups, bias=False, ...
81a39d12a705af9c210a522ae83e48b09ecfeeaffbe09e41a10960c65c96b396
Python
9,503
287
import copy import logging import numpy as np import scipy.signal from importlib import import_module from sleeplab_format.extractor.config import ArrayAction, ArrayConfig, SeriesConfig from sleeplab_format.models import ArrayAttributes, SampleArray, Series, AASMSleepStage, Subject from typing import Callable logger...
326dbe2065e870bcffca3ae3599f862446e200c63642a524f8a448b1603b8a41
Python
9,505
314
import re from abc import abstractmethod from collections.abc import Callable from itertools import chain from typing import Concatenate, Iterable, Protocol, cast import elasticai.creator.ir as ir from elasticai.creator.graph import find_all_subgraphs from elasticai.creator.ir import ( AttributeMapping, Edge, ...
2293f5e3dfb0be301e114e1be9da86fc2c4ee5e21469fcf53d45e1c04e7143eb
Python
9,506
203
# coding=utf-8 # Copyright 2020 Google and The HuggingFace Inc. team. # # 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...
031b44433e173b5585ed91f7f91c131620eba6c6bea3f5f4e8877e46d5a7bb93
Python
9,507
225
# coding=utf-8 # Copyright 2020 The Facebook AI Research Team Authors and The HuggingFace Inc. team. # # 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/LIC...
2a724f88e69b935e392cc9e13dd2735ee67d1f7706d3011ce9e394ef9f679382
Python
9,510
208
# imports import numpy as np import pandas as pd from sklearn.linear_model import Lasso, Ridge, ElasticNet, RidgeCV from sklearn.kernel_ridge import KernelRidge from sklearn.pipeline import make_pipeline from sklearn.svm import SVR, LinearSVR from sklearn.compose import ColumnTransformer from sklearn.compose import ...
1d69f4f4f41e4585e5ba31bdccda326f69a26d5dedb15e2bf99fc38f8a2942bc
Python
9,511
272
# encoding: utf-8 import _init_paths import fire import time import pandas as pd import os import numpy as np import torch import torch.nn as nn import torch.backends.cudnn as cudnn import torchvision import torch.nn.functional as F from tqdm import tqdm from collections import OrderedDict from torchvision import da...
5a965634594881fa7c6a5fb5cd68c17b8e5a9ed4edaf885d95c906605c404eb6
Python
9,511
235
'''MIT License Copyright (c) 2020 Duncan Forster Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, p...
bf5e555959a975a1b8030d5b06f6578416ce819fb3abba8cda1965f16a9a5d6a
Python
9,511
262
import nibabel as nib from nibabel import processing import matplotlib.pyplot as plt import numpy as np import os import argparse import pandas as pd from sklearn.preprocessing import QuantileTransformer import logging from tqdm import tqdm def create_logger(log): """ Creates a logger that logs to both a file ...
dab3784b63c4f19153af41314d95c4532e3608b6d6d4948a5b8b16cf07c5aa26
Python
9,512
253
#!/usr/bin/env python # -*- coding: utf-8 -*- '''Defines classes and methods used by example_parallel_network.py script Copyright (C) 2018 Computational Neuroscience Group, NMBU. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by t...
8b31ca5ec8db594ef397753e79742614aeba082a6e948dcccf0c64c770acf79e
Python
9,513
276
import os import copy import yaml import argparse import ray import utils as u logger = u.getLogger(__name__) if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument( '-c', '--experiment_config', required=True, type=str, help='Format: exper...
a0bd5b04ff99ec9310823800ebd4903efd734bdce3bf1827e92e0d4232b89fb1
Python
9,513
231
# -*- coding: utf-8 -*- """ Created on Mon May 23 22:07:30 2022 @author: ftead """ import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns from scipy import stats import math import re from matplotlib_venn import venn2 import gseapy as gp #%% #Took the data th...
d30e72ce006f3ac5e7ac4250c775f07b02711ead1238794eaa555102f6100ec7
Python
9,513
260
import sys import random import os import argparse import sys import pwd import time import subprocess import re import shutil from sklearn import metrics import re from sklearn.metrics import roc_curve,roc_auc_score import numpy as np import glob from sklearn.metrics import roc_curve,roc_auc_score from sklearn.metrics...
22cb23946553897c596cc454dd76b95aaa9089c798852c9733264e909ea93e4d
Python
9,515
249
from itertools import chain from typing import List, Tuple import numpy as np import pytorch_lightning as pl import torch import torch.nn as nn import torchmetrics from torch.autograd import Function from torch.utils.data import DataLoader from ..classifier import ClassifierTrainer, classification_metrics class Dua...
2f0f043648a121e08e97d4551b9dc44df2864684917cddb82db9b7f2fa2e9f70
Python
9,516
269
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/03_models.ipynb. # %% auto 0 __all__ = ['ToyODE', 'make_model', 'Autoencoder', 'ToyModel', 'ToySDEModel'] # %% ../nbs/03_models.ipynb 3 import itertools from torch.nn import functional as F import torch.nn as nn import torch class ToyODE(nn.Module): """ OD...
41e7ba2bc3978c6b1ebc2d714cdf251505b62796079e395fa9353302eef6bee3
Python
9,518
261
import math import torch from torch import nn class PositionalEmbedding(nn.Module): """Positional embedding layer for sequence data. Args: d_model (int): The dimension of the model. max_len (int): Maximum sequence length. (default: :obj:`5000`) """ def __init__(self, d_model: int, ma...
d9621d2044b8a07413c9ff16eff253373a7e9373899dc5080c0b480be4e42feb
Python
9,518
157
r"""Test OpenBabel executables from Python Note: Python bindings not used On Windows or Linux, you can run these tests at the commandline in the build folder with: "C:\Program Files\CMake 2.6\bin\ctest.exe" -C CTestTestfile.cmake -R pytest -VV You could also "chdir" into bu...
0bef2956d57662db3837d6736895f13794d203eff5a0448eecd84ee7e6a28e59
Python
9,521
250
# -*- coding: utf-8 -*- # # Logging functions for Syncopy. # # Note: The logging setup is done in the top-level `__init.py__` file. import os import sys import logging import socket import syncopy import warnings import datetime import platform loggername = ( "syncopy" # Since this is a library, we should not u...
3811420cd4403bb50fb7235ef2bbad9b343676087eb9b5799edbde51da16f0a2
Python
9,521
277
# coding=utf-8 # Copyright 2026 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
2f4a019d640ef833bbf96e51a9aba31331842406bb8270181e0786167744e801
Python
9,522
246
import os import glob import pandas as pd import re import matplotlib.pyplot as plt import numpy as np from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score import mne from mpl_toolkits.axes_grid1 import make_axes_locatable directory = "Results_files/KMER_gamma_free_0.1-1-10/" # Get all files m...
e3137adc38dfb03d6c72d25ce2b9667f105def6964d7dbc1660c2a062cab7f74
Python
9,523
276
# coding=utf-8 # Copyright 2026 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
e8973a5b5783641cf216ed49d18adc74d155042f9120dba3666bde4a707c471c
Python
9,523
299
# exceptions.py import re import sys import typing from .util import ( col, line, lineno, _collapse_string_to_ranges, replaced_by_pep8, ) from .unicode import pyparsing_unicode as ppu class ExceptionWordUnicode(ppu.Latin1, ppu.LatinA, ppu.LatinB, ppu.Greek, ppu.Cyrillic): pass _extract_alp...
060db14a23e3d8ede2375034528def441728d610cb6ac2a51cd1c292a96f1f8f
Python
9,524
208
# -*- coding: utf-8 -*- from __future__ import annotations from typing import List, Optional import torch from supar.structs.dist import StructuredDistribution from supar.structs.semiring import LogSemiring, Semiring from torch.distributions.utils import lazy_property class LinearChainCRF(StructuredDistribution): ...
a547953d13d7e2fa38cf9c31c12a6eb91ec3e809ae35b596c89f7133cf9addde
Python
9,524
278
import sys from collections import defaultdict as d import re from optparse import OptionParser, OptionGroup #Author: Martin Kapun #Modified by: Siyuan Feng ######################################################### HELP ######################################################################### usage="""python %pro...
6b810c9b319412e395d41ddeb78247f653ec1fe3adc10602340acc9d4c6d23d8
Python
9,529
191
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm import matplotlib.animation as animation import time import ray import os from neuron_model_parallel import NeuronSim from elec_field import sparse_place_human from pulse_train import PulseTrain_Sinusoid...
d2de5cc42829ebb11bb66ca6f1984f9689fa8035869111054d72c762f07530f9
Python
9,531
269
""" Script for applying RWR to GraphMCF Input: - GraphMCF instance (pkl) Output: - GraphMCF with the result of RWR added as a new prop """ __author__ = 'Antonio Martinez-Sanchez' # ################ Package import import sys import time import getopt from graph import GraphGT from globals import * f...
dcfb910c3b6956949103e6344e6666f0b4a07d0c2495a4eae63b3a3ac814cedb
Python
9,531
225
""" Authored by: Neel Kanwal (neel.kanwal0@gmail.com)""" # This is the main file provides MULTICLASS (CNN and ViT) models for end-to-end solution for what is mentioned in the paper. # Update paths to processed datasets if __name__ == '__main__': import warnings warnings.simplefilter(action='ignore', ca...
a0b7a5f3620b097b03432f5ea065f0c8cdab0c7796825cf1e6b6b0f19c703ae9
Python
9,533
270
# # Result post-processing utilities for ACME # # Copyright © 2026 Ernst Strüngmann Institute (ESI) of the Max Planck Society # # SPDX-License-Identifier: BSD-3-Clause # # Builtin/3rd party package imports import os import sys import shutil import logging import h5py import numpy as np from typing import Union, List, ...
566389055e630eb22993acf774dd7276e2b2548e1256ea1d495dfbb93e2d2df9
Python
9,535
285
from collections.abc import Callable from functools import singledispatchmethod from re import Match, Pattern from re import compile as _regex_compile from typing import Iterable, Protocol, runtime_checkable @runtime_checkable class TemplateParameter(Protocol): regex: str """A regular expression to match what...
6a1caa1f312dfe8d143178c72da5ed7831a7bdf8f6814b4fcc2fc6bbb1673eda
Python
9,535
260
# -*- coding: utf-8 -*- from __future__ import annotations from typing import Callable, Optional import torch import torch.nn as nn from supar.modules.mlp import MLP class Biaffine(nn.Module): r""" Biaffine layer for first-order scoring :cite:`dozat-etal-2017-biaffine`. This function has a tensor of w...
ae0aed432cf309586cd4986f4f74911f6682f3f29fa4817a4954c23bf2275dd3
Python
9,536
163
import time import numpy as np class ParameterSimulator: def __init__(self, adapter, simulator, verbose): if verbose: print('Initialising Evaluator') self.adapter = adapter self.simulator = simulator self.verbose = verbose '''functionality''' def simulate_thet...