sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
e0d8d28930978641fed9021f71018458c2979192b7bbfde35585c33ff703453a | Python | 5,692 | 162 | from pathlib import Path
import numpy as np
import numpy.testing as npt
import pandas as pd
import pandas.testing as pdt
import pytest
import astrovascpy.report_reader as test_module
from astrovascpy.exceptions import BloodFlowError
TEST_DIR = Path(__file__).resolve().parent
TEST_DATA_DIR = TEST_DIR / "data/reportin... |
ddb6dedf3a75c35b772ba7951aef887d19843ecc94e0e9c8c9eddafa3fd09b20 | Python | 5,693 | 171 | # 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... |
a7604dc11f18249deeb1339ed16fba5d1cb3424a6e6e768b9f89112eba9b5e9f | Python | 5,694 | 161 | import sys
from numpy.core.records import array
sys.path.append('../../4K_HETU/app')
import arrayexp
import numpy as np
# import arrayparams
import time
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
sns.set_style('ticks')
matplotlib.rcParams['font.family'] = 'sans-ser... |
6a35f9fa15260ce7f615fc83643e298a4349497459f4d5241b955cdd3fa058ba | Python | 5,695 | 99 | import pandas as pd
import numpy as np
from scipy.spatial.distance import pdist
import matplotlib.pyplot as plt
from scipy import stats
for model in ['CUR', 'RND', 'CRF', 'CTR']:
# Load the CSV file into a Pandas DataFrame
file_path = rf"G:/McGraw 2024 Source/Experiment 2 - Progressive Grouping over Developmen... |
b1b059880451734e7442ab8e29c0af3abd8add72eca1879b2ca646462fff8942 | Python | 5,697 | 174 | import logging
import shutil
import sys
import textwrap
import xmlrpc.client
from collections import OrderedDict
from optparse import Values
from typing import TYPE_CHECKING, Dict, List, Optional
from pip._vendor.packaging.version import parse as parse_version
from pip._internal.cli.base_command import Command
from p... |
d230f397bb424e240193206f3e05de11e5b155c4c1657449702a684d2ab55b67 | Python | 5,697 | 159 | import torch
import torch.nn as nn
import math
def init_layer(L):
# Initialization using fan-in
if isinstance(L, nn.Conv2d):
n = L.kernel_size[0]*L.kernel_size[1]*L.out_channels
L.weight.data.normal_(0,math.sqrt(2.0/float(n)))
elif isinstance(L, nn.BatchNorm2d):
L.weight.data.fill_(... |
24cfb5e803369371c56c3186b3b29ff66b0079a88b32cc91ca1cd2ae8603e6c5 | Python | 5,698 | 172 | # 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... |
3fa4cdd49133caa1127893047798c2650ee7affaa844da61a3b240746a3b079d | Python | 5,699 | 204 | # Copyright (c) 2023-2024 Blue Brain Project/EPFL
# 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 ... |
728024106c77c21375b79e1153618d1ae6f78ce34152113e5df86cfee60c1b43 | Python | 5,701 | 123 | import torch
import numpy as np
from tqdm import tqdm
def torch_intersect(a,b):
a_cat_b, counts = torch.cat([a, b]).unique(return_counts=True)
intersection = a_cat_b[torch.where(counts.gt(1))]
return intersection
def topk_statistics_cuda(y_true, y_pred):
# Prints the following information: top-kL sta... |
c4672388fe47399c2c6f80fd18ece52b1b13c4140ae0be4fa3b113535dae0f59 | Python | 5,702 | 137 | from __future__ import print_function
import copy
from . import conditions
class Action(object):
def __init__(self, name, parameters, num_external_parameters,
precondition, effects, cost):
assert 0 <= num_external_parameters <= len(parameters)
self.name = name
self.param... |
5a2739cada367a54a4d2b4fcbb48b50d2b76304b01b6b2e183a55580ff4f89b1 | Python | 5,703 | 153 | import torch
from torch import nn
from einops import rearrange, repeat
from einops.layers.torch import Rearrange
# helpers
'''
if the argument that is passed in the function is a tuple, then return else return it as a tuple
'''
def pair(t):
return t if isinstance(t, tuple) else (t, t)
# classes
class PreNorm(n... |
6cb5a91583aaa57a52c25430db6636cb67c7eb36113e7b3fd4a14f07a73e33fd | Python | 5,703 | 154 | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import Normal
from torch.optim import Adam
from collections import deque, namedtuple
import copy
from .replay_memory import ReplayMemory
from .replay_memory import HerReplayMemory
from .gaussianpoli... |
218fb839a3cc8caa0cc884e03883b10552dc56a6837a8333a47c1376c9abdc86 | Python | 5,704 | 180 | """Enumeration constants and string literals used throughout HED schema loading and validation."""
from enum import Enum
class HedSectionKey(Enum):
"""Keys designating specific sections in a HedSchema object."""
# overarching category listing all tags
Tags = "tags"
# Overarching category listing all... |
297794c71c8f931fa26fb4cb4ec0baa2d988724b41399ee60773f20f80e82647 | Python | 5,704 | 161 | """Run HMM on the LEMON EEG dataset (age-matched)
"""
# Set up dependencies
import os
import numpy as np
from sys import argv
from osl_dynamics import data
from osl_dynamics.inference import tf_ops
from osl_dynamics.models.hmm import Config, Model
from utils.data import load_data, save_data
if __name__ == "__main__... |
749960c28288a6bbe89500753414350f7bf4c09bdd4cd7f830466e042ad0e8a2 | Python | 5,705 | 89 | """SIGN_OWN.py 2026-10-07. Pre-registration: 04-NOTES/PREREG-2026-10-07b-OWN-SIGN.md
Is each laboratory-checked prediction of Shiu et al. (2024) carried by the sign of the neuron it tests, and are the
predictions the laboratory found wrong the ones that stand on an uncertain own sign? W0 network, protocols and random s... |
86f2f71e86bd55a628faa10e664062d88ab0db9d540f13f3fae30755a5a62e91 | Python | 5,705 | 155 | """Utilities to lazily create and visit candidates found.
Creating and visiting a candidate is a *very* costly operation. It involves
fetching, extracting, potentially building modules from source, and verifying
distribution metadata. It is therefore crucial for performance to keep
everything here lazy all the way dow... |
c63c31371f40795a231b970a1abb4227c1c45e04a6a6d21df65ca6396af80bd8 | Python | 5,705 | 136 | # SPDX-FileCopyrightText: 2024 Blue Brain Project / EPFL
#
# SPDX-License-Identifier: AGPL-3.0-or-later
'''Description: Functions to extract (and cut) spike trains in topo-sample format
Author: C. Pokorny
Date: 11/2022
'''
import json
import numpy as np
import os
import scipy.sparse as sps
from bluepy import Ce... |
ed83d68613396ef5b4fa3ab39bc52feb3fca96b52a879d33983cf390c9fe1f1b | Python | 5,705 | 154 | #!/usr/bin/env python
# Copyright (c) 2020 Intel Corporation
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
"""
This module provides a wrapper to access/use user-defined actor
controls for example to realize OpenSCENARIO controllers.
At the mome... |
4fd935b5194571ad1a74b4043112de2ed1c89c339318ea4484067b990a72b6e6 | Python | 5,707 | 172 | from __future__ import annotations
from typing import Iterable, Any
import numpy as np
import pandas as pd
from sklearn.base import BaseEstimator
from sklearn.preprocessing import QuantileTransformer
from sklearn.utils.validation import check_is_fitted
from cuppa.constants import PREDICT_NA_FILL_VALUE
from cuppa.log... |
a896275c0df86e0a970d2ecd59b5db9e5c6c8aa07fadc67b685927c44b8282f9 | Python | 5,708 | 150 | # -*- coding: utf-8 -*-
r"""
This file implements the atomic dipole model with an oxidation state term (AD(OS)).
Atomic vectorial property predictions from the network are interpreted as atomic dipoles to
which a dipole contribution is added calculated from the oxidation states of the atoms.
Note that this model requi... |
bfba58ecf8aa1438a3e39f512ba8b9d375c2b8d99ec1c5d205effd2d4855ed44 | Python | 5,708 | 180 | """
Simulate mixture of conductances
"""
import numpy as np
import matplotlib.pyplot as plt
import cmasher as cmr
import seaborn as sns
import pandas as pd
from src.constants import pink, green, blue, min_rate, max_rate
from src.constants import V_reversal, V_cutoff
from src.constants import figdir, stylesheet
from src... |
35978da43dc7e64cf43fcb731ed58802751647bbfc67f1625845cb49f4248271 | Python | 5,709 | 92 | import math
import numpy as np
from utils import insert_sorted, get_nan_value
def djikstra(source_id_list, djikstra_nodes_xyz, djikstra_unfoldedEdges, djikstra_edgeVEC, djikstra_neighbours,
approx_max_path_len):
"""approx_max_path_len: this parameter is not a hard constraint, but an approximate valu... |
6a9b7450e5d0060a97ae055d0a7257a28d0259d67eec30945fcf4fbbf04fac21 | Python | 5,709 | 102 | import os
import pandas as pd
import numpy as np
import fnmatch
from functools import reduce
import time
import resource
def run_STRIDE(st_counts_path, sc_counts_path, sc_labels_path, output_dir="."):
if not os.path.exists(output_dir):
os.makedirs(output_dir)
sc_counts = pd.read_csv(sc_counts_path,... |
24a00ffd2c59d7570a8a38725b94e1492295f20bb55de4fd76defe9ebd844fe4 | Python | 5,710 | 125 | import math
def compute_layer_rf_info(layer_filter_size, layer_stride, layer_padding,
previous_layer_rf_info):
n_in = previous_layer_rf_info[0] # input size
j_in = previous_layer_rf_info[1] # receptive field jump of input layer
r_in = previous_layer_rf_info[2] # receptive field si... |
33ac0d1afe8a6d736e5fcd7310862817ff14badfeaa6fe0fd454c829ab49cd97 | Python | 5,710 | 90 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import suites
from lab.reports import Attribute, gm
from common_setup import IssueConfig, IssueExperiment
try:
from relativescatter import RelativeScatterPlotReport
matplotlib = True
except ImportError:
print 'matplotlib not availabe, scatter plots ... |
3faa411c24476a9b4c64770327a30a4a325370d9c3977732ece3da7ab328f95c | Python | 5,711 | 94 | """CRASH_BANC.py 2026-10-01. Pre-registration: 04-NOTES/PREREG-2026-10-01g-CRASH-BANC.md
The crash test (CRASH_TEST.py, first-order theory) on a second fly: the BANC antennal-lobe cut-out (PHASE_MAP BANC.pkl)
under its laboratory prior (Blab). Does the theory point at the same neuron type, and does that neuron's wron... |
a722783f8d47f52e830347fab57749d70bfe43e85787250bca6fb45c3257ccf9 | Python | 5,711 | 141 | import os
import pandas as pd
from scipy.io import loadmat
from sklearn.model_selection import train_test_split
from datasets.SequenceDatasets import dataset
from datasets.sequence_aug import *
import numpy as np
from tqdm import tqdm
signal_size = 1024
ADBdata_source=[['KA05'],['KA03'],['KI03']]
ADBdat... |
faf5ef466f245a2f47c1cf94680dd51cc1b8fdd50af97e9bf8a30b5e231635e1 | Python | 5,712 | 201 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import os
import glob
from math import ceil
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
import pancancer_evaluation.config as cfg
get_ipython().run_line_magic('load_ext', 'autoreload')
get_ipython().r... |
fe65029e7a10a3cb7ef5b602f6b02dc5b07a505ee431bed11a6b089a585f5274 | Python | 5,715 | 136 | import os
import numpy as np
import pandas as pd
import anndata as ad
import scanpy as sc
import scvi
from time import time
from memory_profiler import memory_usage
def my_func(adata):
scvi.model.SCVI.setup_anndata(net_adata, layer="counts", batch_key="batch")
vae = scvi.model.SCVI(net_adata, ... |
09106a6c7ed0de47133c61ccbe599600da07915a5fecbb9c9b9e046eecd69ab6 | Python | 5,716 | 188 | """ Other functions for osNMF"""
def geneReconstructionAcccuracy(_PPs, _coeffs, _filtered_data):
""" function create gene-by-gene reconstruction accuracy """
import numpy as np
gene_rec_accuracy_lst = []
# loop through each gene
for i in range(len(_coeffs)):
# reconstruct gene
gene_rec = np.matmul(_coeffs... |
31fd9d03fb60cc4e94426fcbc5e20619b16fb32ec845318f67235108840ef484 | Python | 5,717 | 144 | import time
from collections import namedtuple, OrderedDict
from pddlstream.language.constants import is_plan, get_length
from pddlstream.language.conversion import evaluation_from_fact, obj_from_value_expression, revert_solution
from pddlstream.utils import INF, elapsed_time, check_memory
# Complexity is a way to ch... |
3be6dd703388b11a4f3c6db77ebe0f0a0fb751fd2ac008cf190b4e7e52236f75 | Python | 5,717 | 126 | """Everything related to loading and manipulating datasets."""
from typing import Tuple
import anndata
import numpy as np
import pandas as pd
import scanpy as sc
from . import types
def augment_for_analysis(adata: types.AnnData) -> None:
"""Augment dataset for visual analysis."""
sc.pp.scale(adata, max_valu... |
8bd5e031eacd58ee355abfa2a71fcef270147a03b34f7f6221e15a23652fb0f8 | Python | 5,718 | 70 | import numpy as np
import random
import warnings
warnings.filterwarnings('ignore')
import numpy as np
from torch.utils.data import Dataset
import pickle
import json
class NetTrainDataset(Dataset):
def __init__(self, args, train_group):
super(NetTrainDataset, self).__init__()
self.train_group = tra... |
ae3e4cf950668752199d1b2f205e2e643d3ba6f588d722b3399d45c1afe6e9d0 | Python | 5,718 | 77 | """CENSUS_CHECK.py 2026-10-02. Pre-registration: 04-NOTES/PREREG-2026-10-02j-CENSUS-CHECK.md
Is "two cells stand alone" verified beyond the census's 40 checks, and does it depend on the laboratory prior?
A: full rate theory for the next 200 inside candidates (lobe cut-out). B: full rate theory on the olfactory-system c... |
dbd06f71edb9ee7c0cb45ff9fdaa1c2c79d4adcfb41feedfed732f515c57cd59 | Python | 5,718 | 140 | """
Copright © 2023 Howard Hughes Medical Institute, Authored by Carsen Stringer and Marius Pachitariu.
"""
from qtpy import QtGui, QtCore, QtWidgets
from qtpy.QtWidgets import QMainWindow, QApplication, QWidget, QScrollBar, QSlider, QComboBox, QGridLayout, QPushButton, QFrame, QCheckBox, QLabel, QProgressBar, QLineEdi... |
b86cc8921be77998db2857cca7295547c676d09af580fd6f4bb5c84e5f8341c9 | Python | 5,719 | 169 | from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
import torch
from scipy.io import loadmat
from sklearn.model_selection import StratifiedKFold
from sklearn.model_selection import KFold
import torch.nn as nn
import torch.nn.functional as F
def train_val_test_split(kfold = 5, fold = 0):
#n... |
d77f26fc787fb27521c68ae55d288bbfee9f79bef7a15a3e90a6acfbd88b6840 | Python | 5,719 | 157 | import matplotlib
matplotlib.use("Agg")
import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
from utilities.Log import define_root_logger
import logging
logging.info("")
import pickle
# from utilities.script_func import init
from utilities.subset_func import Grad_AUC, Grad_ROC, Grad_COV... |
6089973f22364d01ead41132791e33c566b3bdc3a9b90de85c630830b29ae6e1 | Python | 5,720 | 114 | from ..region_1020 import (FRONTAL_REGION_LIST, GENERAL_REGION_LIST,
HEMISPHERE_REGION_LIST)
from ..standard_1005 import STANDARD_1005_CHANNEL_LOCATION_DICT
from ..utils import (format_adj_matrix_from_adj_list,
format_adj_matrix_from_standard,
format_... |
b74f62888eb47a8f9ef72df468895dc94d455a27d79b6ff12917dedd23a5edfc | Python | 5,720 | 131 | # -*- coding: utf-8 -*-
"""
VGG-Net for CIFAR-10.
Introduction
----------------
VGG is a convolutional neural network model proposed by K. Simonyan and A. Zisserman
from the University of Oxford in the paper 鈥淰ery Deep Convolutional Networks for
Large-Scale Image Recognition鈥? .
Download Pre-trained Model
-----------... |
15098bf0d0c1f64081e6dd887790cfe5fa5cb856329a8c2f0195a8ff656ad83d | Python | 5,721 | 145 | import nn
import pickle
from random import shuffle
'''neural net currently throws out all but 10 of the datapoints as the extra noise from 400000 of them was preventing
it from training in a reasonable time.
Solution - strip out all data that does not have a high variance?
'''
class Classifier():
def __init__(s... |
7001795adedab6c91f66a037d60c9bfefa445cca5c4db2faa7f860039a09a822 | Python | 5,721 | 164 | from sklearn.metrics import roc_curve, precision_recall_curve, auc, accuracy_score, recall_score, precision_score, f1_score, matthews_corrcoef, classification_report
import torch
from torch import nn
from torch.amp import autocast, GradScaler
from tqdm import tqdm
from . import utils
def train_loop(dataloader, model, ... |
a16848c928f5593ee7b51b9828d48e54e91abeccf7d908cd8f95da72b2ea38cf | Python | 5,721 | 144 | """Tests for regtools.ccf_boundary_editor.propagate."""
import numpy as np
import pytest
class TestPropagateComponentToSlice:
def test_same_geometry_propagates_same_displacement(self):
"""When the source and neighbour slices have identical
pristine boundaries, the displacement transports... |
3d890e078f2c071036b680145cd0aaf73146d9a58d0fcdc367617c9d531b45b3 | Python | 5,722 | 191 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# TGAN documentation build configuration file, created by
# sphinx-quickstart on Fri Jun 9 13:47:02 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autoge... |
402074371a7e1f57e25804e8a186b0af88a26500e66055a3678b960e23b640a1 | Python | 5,723 | 123 | import torch
from torch.optim.optimizer import Optimizer, required
class PIDAccOptimizer_SI_AAdRMS(Optimizer):
r"""Implements stochastic gradient descent (optionally with momentum).
Nesterov momentum is based on the formula from
`On the importance of initialization and momentum in deep learning`__.... |
91e29f50ee824aa933c02f7b0824faa443cabf91e7f8fb1ca67a3409b46a8f12 | Python | 5,724 | 149 | """
Class Plane provides methods for crating and manipulating n-1 dimensional planes
in n dimentional space, in addition to methods defined in its base class
Segment.
Note: This class is depreciated.
# Author: Vladan Lucic (Max Planck Institute for Biochemistry)
# $Id$
"""
from __future__ import unicode_literals
fro... |
145081961a82e69369125d02327d27cd1383b48ab5446feeb3891b9768b6bd80 | Python | 5,725 | 259 | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.15.1
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---
# +
import n... |
7ef240abbdd674a613be066cd5339c5f280d5c8d3a62b47352a6064d18ecf096 | Python | 5,726 | 142 | from scipy import signal
import numpy as np
def FilterEEG(EEG: np.array, cutoff: list, sample_rate: float, butterworth_type: str, order: int):
r"""
Simple Butterworth filter, with zero-phase filtering
Importance of use of 2nd order sections:
https://stackoverflow.com/questions/21862777/bandpass-butter... |
40b1d7abeeef5bb37c8c70321867909f8d6ddcaac3479d645258a474ebeb7ed4 | Python | 5,727 | 144 | from typing import Any, Optional, Dict
import numpy as np
from models.model import Model
import torch
import torch.optim as optim
import torch.nn as nn
from torch.nn import init
import torch.nn.functional as F
class Luo3DCNN_Net(nn.Module):
"""
HSI-CNN: A Novel Convolution Neural Network for Hyperspectral I... |
c84e4ce5b1eb426d78a2ffdf54e60112489ea3d4391b1158911db9e05b242b1f | Python | 5,727 | 143 | """Tests for regtools.cell_counting_legacy.launch_helpers."""
import os
import sys
import pytest
class TestGetPythonExe:
def test_returns_a_path(self):
from regtools.cell_counting_legacy.launch_helpers import get_python_exe
exe = get_python_exe()
assert isinstance(exe, str)... |
e7c614309e9a2b4c8dfe877ee40e0ec33aedefb9609fcc7baa131b5eca791365 | Python | 5,728 | 181 | import os
import pandas as pd
import numpy as np
SOURCE_FILE_PATH = "E:/Projekty/Sonata_repo/Data/Wieloparametrowe/raw_data"
EXTENSION_FILE = ".csv"
# Function to read file
def read_file(file_name, separator = None, decimal_sign = None, delete_column = None):
print(file_name)
dataset = pd.read_csv (file_... |
abd38c0ab0fa2879870eab4fb7d9341dad9dfa90aae0857efa3f42bc44e6511e | Python | 5,729 | 180 | from dataclasses import dataclass
from unittest import TestCase, main
from torch import Tensor, cat, tensor, testing, zeros
from torch.nn import BatchNorm1d, Linear, Sequential
from elasticai.creator.nn import Sequential as SequentialCreator
from elasticai.creator.nn.fixed_point import (
BatchNormedLinear as Batc... |
94bcd58fbe14d1957dd039bb381c0bd3cc2e54e046390c060dbb3a6ccdcaea2d | Python | 5,730 | 145 | import os
import csv
import glob
import torch
from torch.utils import data as torch_data
from torchdrug import data, utils
from torchdrug.core import Registry as R
@R.register("datasets.GeneOntology")
@utils.copy_args(data.ProteinDataset.load_pdbs)
class GeneOntology(data.ProteinDataset):
"""
A set of prote... |
e53bd08fec06faab36ab9959e47b21352e7cb6c9c99e614d57a17b78e5bd06ba | Python | 5,730 | 142 | from rdkit import Chem
from rdkit.Chem import Descriptors, AllChem, RDKFingerprint, DataStructs
from rdkit.Chem.QED import qed
import logging
from typing import List, Iterable, Tuple
import numpy as np
import pandas as pd
from pandarallel import pandarallel
pandarallel.initialize(progress_bar=True)
from tqdm import tqd... |
7ea99e958a2df666dc535cdb04448e21601c1c03ceefdee28d8800a0b2ee3831 | Python | 5,731 | 133 | '''
Description:
Run PRESCIENT on single-cell data.
Author:
Jiaqi Zhang <jiaqi_zhang2@brown.edu>
'''
import numpy as np
from datetime import datetime
import torch
import sys
sys.path.append("../")
sys.path.append("../baseline/")
sys.path.append("../baseline/prescient_model/")
sys.path.append("../baseline/presc... |
6b57f650ad298abd269bbf4bc39cfbe8c780b51222250d6950a0e9742c26d43b | Python | 5,732 | 130 | import os
import re
from copy import copy
from typing import Tuple, Union, Dict
import pandas as pd
from sklearn import model_selection
from torcheeg.datasets.module.base_dataset import BaseDataset
class KFold:
r'''
A tool class for k-fold cross-validations, to divide the training set and the test set. One o... |
9f3320190f4605132563dba4bc6b72e0e4326b2bc7918774fe88bbe7cef71f9a | Python | 5,732 | 163 | # 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... |
b7bcac7b8fb4b4f5841244e3908ea89d15ab24571fd91b8f0882eb5ae8f85e62 | Python | 5,732 | 170 | class Tools:
@staticmethod
def get_one_hot_encoded_feature_dict(feature_dict: dict, class_feature_dict: dict) -> dict:
"""Gets the one-hot encoding of a given feature list according to a given dict.
Returns:
dict: Dict of features.
"""
one_hot_encoded_feature_dict... |
e632c584502b09de0333d938414730132b7a1177cc9d0457031cbddfbcae4add | Python | 5,732 | 170 | import numpy as np
from elasticai.creator.file_generation.savable import Path
from elasticai.creator.file_generation.template import (
InProjectTemplate,
module_to_package,
)
from elasticai.creator.nn.integer.math_operations import get_padded_count
from elasticai.creator.nn.integer.ram.design import Ram
from e... |
03f062e87071205bd42cbf34e71facdb092f65de9cde053d4b9acc411450d826 | Python | 5,733 | 143 | import subprocess
import uuid
from io import StringIO
from . import *
def parse_afa(f, ref):
seqs = read_seq(f)
refseq, queseq = seqs[ref], seqs['query']
ref2que = {}
shift = 0
for i in range(len(refseq)):
if refseq[i] == '-':
shift -= 1
ref2que[i+shift] = i
re... |
be177cac69c512c746049c19f6270809e2a29515124a5473bcedb4c1e6f81e28 | Python | 5,733 | 171 | import torch
import torch.nn as nn
import torch.nn.functional as F
from einops import rearrange
from math import log2, floor
# Conditional positional encoding layer (Chu et al. arXiv:2102.10882v2)
class PEGLayer(nn.Module):
def __init__(self, width, p_drop=0.0):
super().__init__()
self.conv = nn.Co... |
8f01a41b560c769a6fe92ae6b61b8ee6765987bacbdc3a2c7caf5cbb10601768 | Python | 5,734 | 145 | # Various helper functions to read from BioCam data files
# 3Brain 3rd gen .brw (HDF5)
import h5py
import ctypes
import json
import numpy as np
def read_flat(d, t0, t1, nch):
return d[t0*nch:t1*nch].astype(ctypes.c_short)
def openHDF5file(path, **kwargs):
return h5py.File(path, 'r', **kwargs)
def getHDF5pa... |
6342685a6568440015a29e33011c49533f9cf2f14367e54f2c5d5d54ca655fcf | Python | 5,736 | 103 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'ABFbot_ui.ui'
#
# Created by: PyQt5 UI code generator 5.13.0
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):... |
6521b6eb8048cf3269de1f1b580df03fa1a449a06084c22de93a75f1eda4603b | Python | 5,737 | 182 | # 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... |
77affa41ce46639232c8288110b78e67ee63697e7e4041310416a54dc443649a | Python | 5,737 | 218 | # 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... |
38c49e8078e646480bdc2c2c634bfed84333eeaf62b8245756c881c18c09ac66 | Python | 5,741 | 133 | '''
Description:
Run our scNODE on the single-cell dataset.
Author:
Jiaqi Zhang <jiaqi_zhang2@brown.edu>
'''
import matplotlib.pyplot as plt
import torch
import numpy as np
from benchmark.BenchmarkUtils import loadSCData, tpSplitInd, tunedOurPars, splitBySpec
from plotting.__init__ import *
from plotting.visu... |
8bafa6b4c7f8ddd69e7b2926ee5af504b319d68afc043c658c47ea7abb802ed7 | Python | 5,741 | 162 | import math
from collections import defaultdict
from functools import lru_cache
from codex.utils.formatting import display, UNDEFINED_THINGS
ALL = "All"
UNKNOWN = "Unknown"
COUNT_TYPE_OPTIONS = ["Synapses", "Connections", "Reciprocal Connections"]
@lru_cache
def for_display(val):
if val is None or val.lower() i... |
39bbbcd231d864d907428475de1e060f24096f4ff33fe6e3b59b7de680fb8d9f | Python | 5,742 | 170 | import numpy as np
from elasticai.creator.file_generation.savable import Path
from elasticai.creator.file_generation.template import (
InProjectTemplate,
module_to_package,
)
from elasticai.creator.nn.integer.math_operations import get_padded_count
from elasticai.creator.nn.integer.ram.design import Ram
from e... |
14ad71014dc26c2d09764e81dc241303f918f83dc87abf3f59ac80a45cd70249 | Python | 5,743 | 128 | # Copyright (c) 2023-2024 Blue Brain Project/EPFL
# 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 ... |
1f7213776ea625d5bcab9eb928cb6ccdb3454b4faca29a91a20eb2768a35478f | Python | 5,744 | 101 | #!/usr/bin/env python
#Some function for doublets handle
import itertools
from SCanSNP.VCFUtils import *
from sklearn.linear_model import LogisticRegression
def ExtractOrderedDoublets(vcf):
'''
Extraction of possible doublets belonging to different donors
'''
doublets=list(itertools.permutations(ExtractSamples(... |
48dd20b0603a9653c25359023e3169691018e982c9e37486bcd19a629788471c | Python | 5,744 | 188 | # -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup ------------------------------------------------------------... |
00694ac71a30eb42c504517b7f95010cc76c5a689fa294bc4827f3769d507a08 | Python | 5,747 | 137 | # 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... |
5ef74fde65d47f142ac6232ec37571f1528d1dbd868ee94704937374d7f6b6a0 | Python | 5,747 | 116 | # ------------------------------------------------------------------------
#
# 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
#
# Unle... |
d916de1fecbcbef487b53e5b2708ea6e4779e7631a3a5c7fcf566b443e1c1cfd | Python | 5,747 | 161 | """Run HMM on the Cam-CAN MEG dataset (age-matched)
"""
# Set up dependencies
import os
import numpy as np
from sys import argv
from osl_dynamics import data
from osl_dynamics.inference import tf_ops
from osl_dynamics.models.hmm import Config, Model
from utils.data import load_data, save_data
if __name__ == "__main... |
c0622702106208645acc69b9d597717e6d646aeee3e43ea85e8af3d05cd236e2 | Python | 5,748 | 146 | import os
import shutil
import torch
import torch.utils.data
# import torch.utils.data.distributed
import torchvision.transforms as transforms
import torchvision.datasets as datasets
import argparse
import re
from helpers import makedir
import cnn_model
import train_and_test as tnt
import save
from log import create... |
c9636485d7efd2a3a89efa5e6658c7764bb86d66207bfabaed35dbbb53beea03 | Python | 5,748 | 128 | """Sparse leaky rate dynamics; not a biophysical simulation."""
from __future__ import annotations
import hashlib
import json
from dataclasses import asdict, dataclass, replace
from pathlib import Path
import numpy as np
from scipy import sparse
@dataclass(frozen=True)
class Dynamics:
dt: float = 0.2
tau: f... |
d5c8c123769a2f8b37aa20b91b8d5f4ef015ee81cab004ef0d2d267b148f9edf | Python | 5,749 | 143 | """Custom image-format atlas spacing override (issue #3).
A custom atlas in an image format (TIFF/PNG/...) carries no spacing metadata, so
the unified loader falls back to ~1.25 µm/px - usually wrong. The registration
GUI now offers an opt-in "Override pixel size (µm/px)" that flows to BOTH the
template preview (... |
7cc4db6a7fcfe9d848d646d75f1655ef923f074ee89e9678f572827f82ae7290 | Python | 5,751 | 96 | """REAL_PN.py 2026-09-29. Pre-registration: 04-NOTES/PREREG-2026-09-29b-REAL-PN.md (written before the data were downloaded)
Seki et al. 2017 (BMC Biol 15:56, CC BY 4.0): real receptor responses (Table S3) in, real PN responses (Table S2) out.
Which LN signs make the model's projection neurons answer like the real ones... |
c3101eaf07661ff8310845a4927b108414882e6cd1c3308fa4b3e64c7b9e8bfc | Python | 5,753 | 143 | """
DeepLabCut2.0 Toolbox (deeplabcut.org)
copyright A. & M. Mathis Labs
https://github.com/AlexEMG/DeepLabCut
Please see AUTHORS for contributors.
https://github.com/AlexEMG/DeepLabCut/blob/master/AUTHORS
Licensed under GNU Lesser General Public License v3.0
"""
"""
Class to drag,annotate and remove the data points.... |
11252389e72b451a1c07999528bf21eb9a451e98e361535c3143d54cac3eb2e3 | Python | 5,754 | 144 | import os, numpy as np
import pandas as pd
from PIL import Image
__all__ = ['NSDBenchmark']
def average_rdms(rdm_array):
def fisherz(r, eps=1e-5):
return np.arctanh(r-eps)
def fisherz_inv(z):
return np.tanh(z)
return 1 - fisherz_inv(fisherz(np.stack([1 - rdm for rdm in rdm_array]))
... |
f8ba88fa05777dac9f7df354c6d7c14f75dd1de77d19aa76959cba3354e01c47 | Python | 5,754 | 171 | # 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... |
0f7de96edc6f076fbfd30cf6889aca2354eb0164139b781374eea63ecff84f17 | Python | 5,755 | 167 | # 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... |
2ae81cf65618cc8b51fd64b10fb2ffb1e5c8276b9cbf4b28814447af52d89f78 | Python | 5,755 | 155 | """GAN Models."""
import tensorflow as tf
from tensorpack import StagingInput, TowerTrainer
from tensorpack.graph_builder import DataParallelBuilder, LeastLoadedDeviceSetter
from tensorpack.tfutils.tower import TowerContext, TowerFuncWrapper
class GANTrainer(TowerTrainer):
"""GanTrainer model.
We need to se... |
9550787f845b93c52962f12dec0e85a8e012652afc9c17eb0b2d776d519c9160 | Python | 5,756 | 175 | """Read files into sleeplab format. The data will be validated while parsing.
"""
import json
import logging
import pandas as pd
import pyarrow.parquet as pq
import zarr
from sleeplab_format.models import *
from pathlib import Path
logger = logging.getLogger(__name__)
JSON_ANNOTATION_SUFFIX = '.a.json'
PARQUET_ANN... |
eee70aab7ae96162181b964fb043a1311d1e54ab02d3c92e7d26eb479c4cdefc | Python | 5,756 | 184 | '''
Author: Xiaoxiao Li
Date: 2019/02/24
'''
import os.path as osp
from os import listdir
import os
import glob
import h5py
import torch
import numpy as np
from scipy.io import loadmat
from torch_geometric.data import Data
import networkx as nx
from networkx.convert_matrix import from_numpy_matrix
import multiprocess... |
227babf79273f647446356a0b0686d5b94ebe474c4fc5b2e872fe8d8d18985f8 | Python | 5,757 | 154 | import argparse
from loader import MoleculeDataset
from torch_geometric.data import DataLoader
from torch_geometric.nn.inits import uniform
from torch_geometric.nn import global_mean_pool
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tqdm import tqdm
import numpy... |
d642c78836efd52b3ab3fa8e7ad935a4f84c5819302d5d63de3d940efce246f4 | Python | 5,757 | 88 | import argparse
import torchvision.models as models
model_names = sorted(name for name in models.__dict__
if name.islower() and not name.startswith("__") and callable(models.__dict__[name]))
criterion_list = ["CrossEntropy", "FocalLoss", "MaskedCrossEntropy"]
optimizer_list = ... |
eadb2a4d138e52abf69ba59716176379749c475b82c8d067351af98807318642 | Python | 5,757 | 185 | """Plot decoding times."""
from __future__ import annotations
import csv
from enum import Enum
from pathlib import Path
from typing import Literal
import numpy as np
import pandas as pd
import pte_decode
import scipy.stats
from matplotlib import pyplot as plt
import motor_intention.plotting_settings
import motor_int... |
1183635a047daf1a1b02adfb608f66daa4b01479b10a8349b514ad5593c8f235 | Python | 5,758 | 184 | '''
Author: Xiaoxiao Li
Date: 2019/02/24
'''
import os.path as osp
from os import listdir
import os
import glob
import h5py
import torch
import numpy as np
from scipy.io import loadmat
from torch_geometric.data import Data
import networkx as nx
from networkx.convert_matrix import from_numpy_matrix
import multiprocess... |
c70a36ceb0e3aaaf76971bd1747b4d9a529305c55336eb975d0298ba34fa12e6 | Python | 5,758 | 159 | """Implementation of CLI modify command."""
import math
from itertools import chain
import numpy as np
from treem.morph import Morph
from treem.io import SWC
from treem.utils.geom import rotation
def modify(args):
"""Modifies selected parts of morphology reconstruction."""
# pylint: disable=too-many-local... |
422fbd0310b2dbaddc42ca778831025f2c645f0a610c20eac46c7d3d93dd705c | Python | 5,759 | 140 | import os
import sys
import pdb
import glob
import json
import numpy as np
import pandas as pd
import tensorflow as tf
import util_tfrecords
import util
def process_example(example,
model,
key_inputs='x',
key_outputs='y',
key_activations... |
ae32c5468ebd8e3770675d8e23c2399f4c92f09ebde94589af48eb5777596f6c | Python | 5,760 | 162 | import syncopy as spy
from syncopy.synthdata.analog import white_noise
import numpy as np
import pytest
has_mne = False
try:
import mne
has_mne = True
except ImportError:
pass
skip_no_mne = pytest.mark.skipif(not has_mne, reason="MNE Python not installed")
class TestSpyToMNE:
numChannels = 64
... |
07eb8b4232f02ddf3f7d09a6ac7a1354d670027b68b783e8aafe42fbc28a65fb | Python | 5,762 | 173 | from collections.abc import Iterable
from functools import partial
from typing import Any, cast
import numpy as np
from elasticai.creator.arithmetic import (
FxpArithmetic,
FxpParams,
)
from ._common_imports import (
Design,
InProjectTemplate,
Path,
Port,
Rom,
Signal,
calculate_ad... |
66180194d2f51013337e833b2e3ee36f944133c4661f8205967f6ab0707d2a88 | Python | 5,763 | 145 | # 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... |
ed7ef8387294b0f8e1f8069d202745239b2b469be2150c6739a9149b076132bd | Python | 5,763 | 137 | import argparse
from datetime import datetime
from pathlib import Path
from warnings import filterwarnings
import lightning.pytorch as pl
import pandas as pd
import torch
import yaml
from tqdm import tqdm
from dataset import TCGA_Program_Dataset
from datasets_manager import TCGA_Balanced_Datasets_Manager, TCGA_Datase... |
fa8f7f44813f1a2d4cb7ac9b0f1d9ff2ee593e9bceea5a3ea1b2435981965de3 | Python | 5,764 | 160 | # 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... |
3ce326983c1130336101ebc5d6105156c2e8a7a8270a1c948d809c2f441878d6 | Python | 5,765 | 147 | # Node-group asset "oxDNA Realize Vectors" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# _build_group() is the source of truth: the docstring, __init__ and accessors are regenerated from it on the next dump.
from typing import TYPE_... |
7a295d1bef9d11775162977534cd7f858f05946f722027d2a514904ee63756ec | Python | 5,765 | 179 | import numpy as np
from scipy.stats import gamma, norm
import matplotlib.pyplot as plt
import sys
sys.path.append("../useful_functions/")
import useful_functions as uf
import warnings
# simulate RL model with learning variability
def simulate_noisy_rl(rewards, complete, idx_blocks, choices, forced_actions, sample, app... |
ee2d97fca19465bdb61da1b9dc5c6fdb39a863155afd4cd78e97f435cbb32ef2 | Python | 5,765 | 189 | # 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... |
8ba98937bc188e45132aef7cc928dae3e26427f5651e31dc1e4bf0034a41a829 | Python | 5,767 | 173 | """Plot earliest prediction timepoints."""
from __future__ import annotations
import csv
from enum import Enum
from pathlib import Path
import numpy as np
import pandas as pd
import pte_decode
import scipy.stats
from matplotlib import pyplot as plt
import motor_intention.plotting_settings
import motor_intention.proj... |
16bf578a908aae37ad6316a9c163b7ae7f0f096864bf918f5f60576e4f20e73c | Python | 5,768 | 168 | # pylint: disable=no-member, invalid-name, too-many-locals, too-many-arguments, consider-using-dict-items
""" Scripts for creating dataloaders """
from importlib import import_module
from copy import deepcopy
from numpy.random import default_rng
from sklearn.model_selection import StratifiedKFold, StratifiedShuffleSp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.