sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
cf87a82a89a933d73727edb0683b0c71b6e855c04a0698b98f98c5acbc79e418 | Python | 2,798 | 63 |
import torch
from tqdm import tqdm
import numpy as np
from transformers import pipeline, T5Tokenizer, T5EncoderModel
import os
os.environ['CUDA_VISIBLE_DEVICE'] = '1'
import json
each_user_tweets=json.load(open("src/twibot22_Botrgcn_feature/id_tweet.json",'r'))
pretrained_weights = 't5-small'
tokenizer = T5Tokenizer... |
699535d11ed2c7c7a24b9c55429ff1b827b8313b6dacc33875f0d2c0f513463e | Python | 2,799 | 72 | import shap
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from pathlib import Path
from config.paths import FIGURE_DIR
RENAME_MAP = {
'bps1': 'Systolic BP',
'gcs_total': 'GCS',
'c_weight': 'Weight',
'bpd1': 'Diastolic BP',
'pulse1': 'Pulse',
'c_age': 'Age',
'ADI_N... |
0ac68a64b286c2cd66febeeb1db20133808895f8f1e35464f09cf16ac21f43b5 | Python | 2,800 | 58 | # SPDX-FileCopyrightText: Copyright © Jørgen Riseth and Timo Koch
# SPDX-License-Identifier: GPL-3.0-or-later
import matplotlib.pyplot as plt
import numpy as np
import click
sec_to_days = 1.0/(24*60*60)
# plot time series data from total.txt, whitematter.txt, and graymatter.txt
@click.command()
@click.option('--fold... |
115e2f4ace3bd0a8b3ad59646234ad5e0aa77a533c5541fa12a04e91074314bd | Python | 2,800 | 64 |
import torch
from tqdm import tqdm
import numpy as np
from transformers import pipeline, T5Tokenizer, T5EncoderModel
import os
os.environ['CUDA_VISIBLE_DEVICE'] = '1'
import json
DEVICE = 1
each_user_tweets=json.load(open("src/twibot22_Botrgcn_feature/id_tweet.json",'r'))
pretrained_weights = 't5-small'
tokenizer = ... |
c4ffb2c40556dc3694c39862f805ae655ca22e81f8cdce447955ca8b94fe8d52 | Python | 2,800 | 91 | import os.path as op
import dipy.core.gradients as dpg
import nibabel as nib
import nibabel.tmpdirs as nbtmp
import numpy as np
import numpy.testing as npt
from dipy.data import default_sphere
from dipy.reconst.gqi import GeneralizedQSamplingModel
import AFQ.data.fetch as afd
from AFQ._fixes import gaussian_weights, ... |
09bb975616a7844c6c86fca9fde2215622d756e9d9b84bb0ebc30190a9d70dc1 | Python | 2,801 | 82 | # This file was automatically generated by SWIG (http://www.swig.org).
# Version 4.0.2
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info as _swig_python_version_info
if _swig_python_version_info < (2, 7, 0):
raise Runtime... |
1229a4db01b30ddaf8fc5a38d80a89a326ff7a442d8f7973e4387c03c49e607e | Python | 2,802 | 68 | # wfield - tools to analyse widefield data - svd utils
# Copyright (C) 2020 Joao Couto - jpcouto@gmail.com
#
# 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, o... |
a42203ee45890270c6f9c89b86e937d16a0fde4da301bb62f99378f26e94f6b3 | Python | 2,802 | 89 | import pytest
import numpy as np
from MEGnet.prep_inputs import ICA
def test_main_requires_results_dir():
with pytest.raises(TypeError, match='results_dir'):
ICA.main('input.fif')
def test_cmdline_requires_results_dir(monkeypatch):
monkeypatch.setattr(
'sys.argv',
['ICA.py', '-filen... |
03bd428aaca303cd498a100245da43326479e7f7ea5ce9fffa865f03df6f730b | Python | 2,803 | 68 | import csv
import json
import os
from os.path import join as ospj
import re
import sys
# This script identifies CUBIDS acquisition variants and non-variants to use for sample selection for a given dataset
###########################
## Set variables and dirs #
###########################
dataset = sys.argv[1]
config_... |
776f74c4ca9a6e87f0e3981cd561ba1cb2b72846ff83cf75894605822020afe1 | Python | 2,803 | 83 | import os
import shutil
import asyncio
from unittest.mock import MagicMock, patch
# Mock dependencies to avoid needing API keys or real models
import sys
sys.modules["chemgraph.models.openai"] = MagicMock()
sys.modules["chemgraph.models.alcf_endpoints"] = MagicMock()
sys.modules["chemgraph.models.local_model"] = Magi... |
c2745733a32cbbb271d5ec1702c03f2ce561bc2852b5c4bc209a9ae718382b1a | Python | 2,803 | 78 | from typing import Literal
import numpy as np
from argclz import AbstractParser, argument
from neuralib.plot import diag_histplot, plot_figure
from neuralib.util.deprecation import deprecated_class
from rscvp.visual.main_response import VisualPatternCache, ApplyPatternResponseCache
from rscvp.visual.util_plot import ... |
3b495d22234a084f5e7bbb0bccc4fedc7b031817387819cfdc31a342c8b09140 | Python | 2,804 | 92 | # Generated by Django 3.2.12 on 2022-06-10 18:29
import django.db.models.deletion
from django.db import migrations, models
import cvat.apps.engine.models
class Migration(migrations.Migration):
dependencies = [
("engine", "0053_data_deleted_frames"),
]
operations = [
migrations.CreateMo... |
a4c0b66504ae761d1f0f085b313cc533cc383df93c0fd9def48332a61878a963 | Python | 2,805 | 67 | import importlib
from zigzag.classes.hardware.architecture.accelerator import Accelerator
import logging
logger = logging.getLogger(__name__)
class AcceleratorParser:
"""Parse an accelerator module path into an accelerator object.
"""
def __init__(self, accelerator) -> None:
"""Initialize the pa... |
4ee5076d9353d04a0a5d12baac3fbb1be55c1c141d7339d3ce5f6a17fa3c3794 | Python | 2,806 | 118 | import re
import nltk
from nltk import WordNetLemmatizer
from nltk.corpus import stopwords
STOP = stopwords.words("english")
STOP += [
"like",
"gone",
"did",
"going",
"would",
"could",
"get",
"in",
"up",
"may",
"wanted",
"actually",
"likely",
"possibly",
"wa... |
de43d153e3d32a4236d900b99230adcfdd08a8f1a5f210d3e05446750b931a37 | Python | 2,806 | 77 | """What MEA-NAP needs from a place raw data lives.
Deliberately three operations, not a filesystem. Everything the pipeline does
with raw data reduces to *list a folder*, *ask how big a file is*, and *get me
the bytes* — it never seeks, appends, or writes back (once
:mod:`meanap.catnap.derived` moved the derived files... |
02cdcfef9ab3a898c0a0a3e26689f8efab1f558373872485cfacf5ef8c7c1b6c | Python | 2,807 | 60 |
import numpy as np
import xarray
from marques_utils import gen_sample
from brainscore_core.supported_data_standards.brainio.packaging import package_data_assembly
from brainscore_core.supported_data_standards.brainio.assemblies import DataAssembly
ASSEMBLY_NAME = 'schiller.Schiller1976c'
SPATIAL_FREQUENCY_STIM_NAME =... |
3c3aa710bb09b34053f4f208ff010e24c5724505e45f7813055d76396d372238 | Python | 2,807 | 94 | import os,sys,json
import numpy as np
import pandas as pd
from io import StringIO
def usage():
print("""
Usage : python3 reset_obj.py < -i in.obj>
-o output prefix>
[ -b binsize default 20]
""")
def MesheStr(objfile):
mesh_str = ''
file1 ... |
6bea2d6cc3e5bca9bd97b9e62e2d33fd96016ab590a370f95ebe0224969efce4 | Python | 2,809 | 78 | # -*- coding: utf-8 -*-
"""TODO"""
import collections
import sys
import core.core_global as core
from core.core_definitions import simulation_timestep
from core.monitor import Monitor
class VoltageMonitor(Monitor):
"""TODO"""
def __init__(self, source, uid, filename, stepsize=simulation_timestep,
... |
d27d566af822b139f5ba1ef01d03d2fe4d5af5d030529252a66977c91931043a | Python | 2,809 | 90 | # 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... |
d5c7dde0cde0bc242fbc4482af84d6f00a9d42286022339a13aeac80c78855e6 | Python | 2,809 | 91 | import unittest
from io import StringIO
import bx.pwm.position_weight_matrix as pwm
basicPwm = """>MA0101 c-REL REL
0 5 8 4
0 1 15 1
1 0 15 1
5 1 9 2
6 5 3 3
5 1 1 10
1 0 0 16
2 0 0 15
0 15 0 2
1 16 0 0
"""
transfacPwm = """ID TATA
XX
P0 A C G T
01... |
273cefa6f3d558f201051dade3faf4a5b04d3520ed6816d9d374fd0c57ceef98 | Python | 2,810 | 78 | import torch
from torch import nn
from torchvision.models.vgg import vgg16, VGG16_Weights
class GeneratorLoss(nn.Module):
def __init__(self, in_channels):
"""
初始化 GeneratorLoss
:param in_channels: 输入数据的通道数
"""
super(GeneratorLoss, self).__init__()
# 加载预训练的 VGG16 模型并... |
52dbb0f061892961b1e063c2db8226405388d77c0458047cc873956eb17a0539 | Python | 2,810 | 71 | """Remove stimulation-artifact & stim-electrode spikes.
Port of ``Functions/batchProcessSpikesFromStim.m``. Runs between detection and
analysis:
1. Empties spike times on every stimulating electrode (``elecStimTimes`` > 0).
2. Removes spikes falling in any stim electrode's artifact window
``[blankStart, blankStart... |
8d02f235073b30ae7d67179c2bc42908fde7c5c46bce1ec3248cf3883b3a9d11 | Python | 2,810 | 76 | #!/usr/bin/env python3
"""Record several nodes into one capture file, then export each separately.
A real Thalamus experiment records many nodes into a single ``.tha`` file -- for
example an eye tracker, an EMG sensor, and a trigger channel all at once. Each
node's data is tagged with its node name, so analysis tools... |
a202f06f79ee5e473dc92c8a2f42a4c827d9d92daf08101bcce0fe9716e237c9 | Python | 2,812 | 54 | import os, sys, gzip, argparse, subprocess, random
from utils import read_maybe_gzip, check_iupac, revcomp
parser = argparse.ArgumentParser(description="Process 1st-seq FASTQ to build spatial barcodes")
parser.add_argument("--fq", type=str, required=True, help="FASTQ file")
parser.add_argument("--format", type=str, de... |
c75dd60be02668bf5a096495b012be49ae945090621cb40267eb1a45c25cb482 | Python | 2,812 | 79 | # Copyright (c) 2026 Rohit Jena. All rights reserved.
#
# This file is part of FireANTs, distributed under the terms of
# the FireANTs License version 1.0. A copy of the license can be found
# in the LICENSE file at the root of this repository.
#
# IMPORTANT: This code is part of FireANTs and its use, reproduction, or... |
38f18f136ffd7a18f8762eb90c1568349c14074d4bfa8edc2e7e3036b85f9855 | Python | 2,813 | 82 | from lasagna.tree.tree import Tree
# Generate an example if run from the command line
if __name__ == '__main__':
_ROOT, _DEPTH, _WIDTH = list(range(3))
print("\n\n --------- Tree of life --------- \n")
tree_of_life = Tree()
tree_of_life.add_node("Life") # root node
tree_of_life.add_node("Arch... |
b6fca879f1105c7982b6a2b990a57e82a050faeb7071814cbf7ee234cb17ab77 | Python | 2,813 | 75 | from __future__ import annotations
from collections.abc import Sequence
from PySide6 import QtCore
from PySide6 import QtWidgets
class ModelPicker(QtWidgets.QComboBox):
model_changed = QtCore.Signal(str)
manage_requested = QtCore.Signal()
def __init__(self, *, options: Sequence[tuple[str, str]]) -> Non... |
bfc400f28b51b647b764cdb0847ec305d661cea3961b34e7696c4e51a0db55cb | Python | 2,813 | 63 | import torch
from tqdm import tqdm
import numpy as np
from transformers import pipeline, T5Tokenizer, T5EncoderModel
import os
os.environ['CUDA_VISIBLE_DEVICE'] = '1'
import json
DEVICE = 1
each_user_tweets=json.load(open("src/twibot22_Botrgcn_feature/id_tweet.json",'r'))
pretrained_weights = 't5-small'
tokenizer = T... |
d43487864b48f1243c3d66a5837f01e160b3392e7c0572c7f2e99c99ce3669f7 | Python | 2,813 | 84 | from dataclasses import dataclass
import numpy as np
from sklearn.preprocessing import KBinsDiscretizer
from eir.data_load.label_setup import (
al_label_transformers,
al_target_columns,
merge_target_columns,
)
from eir.setup import schemas
from eir.setup.schema_modules.output_schemas_survival import Survi... |
fe1184bfa0eb5c6d66dc824fef831b161f20ec895064b88bcb1b9dd7a7ca49a7 | Python | 2,813 | 64 |
import torch
from tqdm import tqdm
import numpy as np
from transformers import pipeline, T5Tokenizer, T5EncoderModel
import os
os.environ['CUDA_VISIBLE_DEVICE'] = '1'
import json
DEVICE = 1
each_user_tweets=json.load(open("src/twibot22_Botrgcn_feature/id_tweet.json",'r'))
pretrained_weights = 't5-small'
tokenizer = ... |
04040c9c7dce1ea61232871544109340b9571fe3a4788b6d23a0a47d695f0de2 | Python | 2,814 | 64 |
import torch
from tqdm import tqdm
import numpy as np
from transformers import pipeline, T5Tokenizer, T5EncoderModel
import os
os.environ['CUDA_VISIBLE_DEVICE'] = '1'
import json
DEVICE = 1
each_user_tweets=json.load(open("src/twibot22_Botrgcn_feature/id_tweet.json",'r'))
pretrained_weights = 't5-small'
tokenizer = ... |
11b44d0a68e172e18362985235585f05b8fd24511036daf2cccba1c5cea3bc9a | Python | 2,814 | 90 | import argparse
import os
import os.path as osp
import time
import numpy as np
import torch
import torch.nn.functional as F
from sklearn.metrics import f1_score
import pandas as pd
import json
import torch_geometric.transforms as T
from tqdm import tqdm
import spacy
import re
from vaderSentiment.vaderSentiment import S... |
66d0c3acb000aada8dcff370477d86c02da7a3371e3f4df08b6fc9b92d870ce8 | Python | 2,814 | 68 | from train_gtex import *
def main():
parser = argparse.ArgumentParser(description="Run a training experiment")
parser.add_argument("--config_path",type=str)
parser.add_argument("--fold",type=int)
parser.add_argument("--seed",type = int)
parser.add_argument("--train_gene_path",type = str)
parse... |
8741b513f554a753d0dad4d85d6fe9ed1dca9941b45aa69cf9d8807e471d2192 | Python | 2,814 | 90 | import argparse
import os
import os.path as osp
import time
import numpy as np
import torch
import torch.nn.functional as F
from sklearn.metrics import f1_score
import pandas as pd
import json
import torch_geometric.transforms as T
from tqdm import tqdm
import spacy
import re
from vaderSentiment.vaderSentiment import S... |
8d241c979b1912ad3664ca7f22baddfbae4f0f10b0b5114e4002650d0539e947 | Python | 2,814 | 64 |
import torch
from tqdm import tqdm
import numpy as np
from transformers import pipeline, T5Tokenizer, T5EncoderModel
import os
os.environ['CUDA_VISIBLE_DEVICE'] = '1'
import json
DEVICE = 1
each_user_tweets=json.load(open("src/twibot22_Botrgcn_feature/id_tweet.json",'r'))
pretrained_weights = 't5-small'
tokenizer = ... |
a0ee58525b1865430a577259e1b2a0addb2468cc283aaaaa27514d163abdecd7 | Python | 2,814 | 83 | # Generated by Django 3.2.18 on 2023-06-13 13:14
import uuid
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("engine", "... |
a98961ea517a756f3bc1cdeb378c4944f796c9aa7ad1450579b0bfd8ed427e69 | Python | 2,814 | 64 |
import torch
from tqdm import tqdm
import numpy as np
from transformers import pipeline, T5Tokenizer, T5EncoderModel
import os
os.environ['CUDA_VISIBLE_DEVICE'] = '1'
import json
DEVICE = 1
each_user_tweets=json.load(open("src/twibot22_Botrgcn_feature/id_tweet.json",'r'))
pretrained_weights = 't5-small'
tokenizer = ... |
d209b4cde21e1ce365cb80fcdb4da8ddf6f8ccf8eabeb81c968a92079f7ea3df | Python | 2,814 | 65 |
import torch
from tqdm import tqdm
import numpy as np
from transformers import pipeline, T5Tokenizer, T5EncoderModel
import os
os.environ['CUDA_VISIBLE_DEVICE'] = '1'
import json
each_user_tweets=json.load(open("src/twibot22_Botrgcn_feature/id_tweet.json",'r'))
pretrained_weights = 't5-small'
tokenizer = T5Tokenizer... |
ed611ab4bd766fa856114dc03cc7ed57621ff2c99367ec8297d889570a4c0f01 | Python | 2,814 | 64 |
import torch
from tqdm import tqdm
import numpy as np
from transformers import pipeline, T5Tokenizer, T5EncoderModel
import os
os.environ['CUDA_VISIBLE_DEVICE'] = '1'
import json
DEVICE = 1
each_user_tweets=json.load(open("src/twibot22_Botrgcn_feature/id_tweet.json",'r'))
pretrained_weights = 't5-small'
tokenizer = ... |
c37845d95d60fe2fd4f29f920ae7b755e244463b5016656ac6c3bcd5754dc9a3 | Python | 2,815 | 71 | """Run the Python pipeline's steps 2-4 on MATLAB's OWN spike times.
The straight MATLAB-vs-Python comparison conflates two things: (a) spike
detection is not bitwise identical between the two ports (wavelet CWT), and
(b) whatever the network-metric code itself does. Because a small firing-rate
difference changes which... |
3cc8f529b6d05a563693082f0a3ba47e24f16f0a08302abb77669b69faedb03c | Python | 2,816 | 58 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import plotting_related_functions
import os
import pandas as pd
import scipy.stats as st
# Plot the correlation of the KD model with different overlaps
extensions = ['png', 'pdf'] # Figure save extension
fsd = r'../figure... |
bec06d2aacdfde90d270e2635358768ec8b413a75a7533b9aa83b1337a8fb50b | Python | 2,816 | 79 | import numpy as np
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
import TwoD_fun
import brainpy.math as bm
#set default ramndom seed for reproducibility
bm.random.seed(1)
#set backend to cpu
bm.set_platform('cpu')
#xlabel = ['Super-diffusion', 'Brownian-diffusion', 'Stationary', 'T... |
0bf90fef1d7ad50ff485427be1456b80a8c273a8224b46c0d688522d3850348a | Python | 2,817 | 102 | """mobilenetv2 in pytorch
[1] Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, Liang-Chieh Chen
MobileNetV2: Inverted Residuals and Linear Bottlenecks
https://arxiv.org/abs/1801.04381
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
class LinearBottleNeck(nn.Module):
... |
cc22c674bff886c9b0bd326d9481b74c34d3fb2d48c76f7f134567e8b41b8b72 | Python | 2,817 | 90 | import argparse
import os
import os.path as osp
import time
import numpy as np
import torch
import torch.nn.functional as F
from sklearn.metrics import f1_score
import pandas as pd
import json
import torch_geometric.transforms as T
from tqdm import tqdm
import spacy
import re
from vaderSentiment.vaderSentiment import S... |
15b0238ef646a3ca34012a1045354a15d06c2fe04b0b1d375e065b67fbcbf2af | Python | 2,819 | 43 | xanes_single_agent_prompt = """You are an expert in X-ray Absorption Near Edge Structure (XANES) spectroscopy and computational materials science.
Your primary tools are:
- **fetch_xanes_data**: Fetch optimized crystal structures from the Materials Project database for a given chemical system. Requires a chemical form... |
1f2b2abd9441dc3ffcb5af59e03a8ba3130f1f2262cff84ef112ec2813df7dca | Python | 2,819 | 77 | import collections
import numpy as np
from argclz import try_int_type, argument
from neuralib.persistence.cli_persistence import get_options_and_cache
from neuralib.plot import plot_figure
from rscvp.statistic.persistence_agg.core import AbstractPersistenceAgg, data_region_dict
from rscvp.topology.cache_ctype_cord imp... |
42e71ba8dd84ec2aa04d45b0efb674b96d2afadb438072e032d15fb09aafcc7e | Python | 2,819 | 69 | """
Plot estimated look-locker versus mixed data
"""
import click
import matplotlib.pyplot as plt
import numpy as np
from plot_noise_look_locker import generate_look_locker_data
from plot_noise_mixed import generate_mixed_data
def plot_mixed_versus_look_locker(snr, samples, sequence_duration, ax_c=None, ax_t1=None):... |
35009b6038325f9a8cb2930277b963e84ca8b43a98c2b2af98a30236435ee7d6 | Python | 2,820 | 92 | import numpy as np
from collections import MutableMapping
class Bidict(MutableMapping):
"""Bidirectional dictionary.
Implementation following in part https://github.com/jab/bidict/
"""
def __init__(self, *args, **kwargs):
self._fwd = dict()
self._inv = dict()
self.update(dict... |
994ac1e4703c1bc6c6ec17baa388301cd6224caa064da910d06f6d441dddc854 | Python | 2,820 | 84 | from pathlib import Path
from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet
from brainscore_core.supported_data_standards.brainio.packaging import package_stimulus_set
stimuli = []
image_paths = {}
stimuli_directory = '../datasets/cue-conflict'
'''
*** NOTE: This benchmark (cue-conflict... |
9bac83e24fea136160fee09245a23eb9f398dfd9d116cabbd19b8089efbdffef | Python | 2,820 | 78 | # !/usr/bin/env python
# coding: utf-8
# @Time : 2022/7/17 13:54
# @Author : Z.-H. G.
# @Email_0 : guozhenhao17@mails.ucas.ac.cn
# @Email_1 : guozhenhao@tongji.edu.cn
# @File : params.py
# @IDE : PyCharm
import pandas as pd
# TODO yaml
PARAMS = \
{'preprocess':
{
'path': './dataset/... |
9cc3b26020a08ffcb69b85b90d6897cc379380970703af6ca66d0b3fd2547fd5 | Python | 2,820 | 85 | import os
import cv2
import numpy as np
def calculate_mse(image1, image2):
# 计算均方误差 (MSE)
mse = np.mean((image1 - image2) ** 2)
return mse
def calculate_psnr(image1, image2):
# 计算峰值信噪比 (PSNR)
mse = calculate_mse(image1, image2)
psnr = 10 * np.log10((255**2) / mse)
return psnr
def calcula... |
1128943126340a1a49f9f6f381917018e5499717f3848fd4fa72f4a879f41bf1 | Python | 2,821 | 54 | import os,sys
import argparse
import h5py
import glob
import numpy as np
from sklearn.utils import shuffle
from sklearn.metrics import roc_auc_score, precision_recall_curve, roc_curve
import xgboost as xgb
from sklearn.externals import joblib
from sklearn.metrics import precision_score, recall_score, f1_score, average_... |
348d738b1283c7e187c68f0ac251b3294453ba011ba9db8729b3cf982f6ecaf8 | Python | 2,821 | 89 | #!/usr/bin/env python
import argparse
import logging
import os
# Create a logger
logging.basicConfig(format="%(name)s - %(asctime)s %(levelname)s: %(message)s")
logger = logging.getLogger(__file__)
logger.setLevel(logging.INFO)
mqc_main = """#id: 'biotype-gs'
#plot_type: 'generalstats'
#pconfig:"""
mqc_pconf = """#... |
9df54f04f30c48b1771cf2aec9088a5f3ae10f15fcba9aab2855c360e8ca49e1 | Python | 2,821 | 122 | """Train an HMM.
"""
#%% Run ID and output directory
import os
from sys import argv
# We get the run ID from the command line arguments
if len(argv) != 2:
print("Please pass a run id, e.g. python 2_train_hmm.py 1")
exit()
id = int(argv[1])
# Create directory for results
results_dir = f"results/run{id:02d}"... |
5109f106a0897d12e362e8180966cc49d583685df950133fee5217b5a7402fdc | Python | 2,822 | 84 | from typing import Union
import numpy
import torch
""" General utility functions """
def random_tensor(
cfg: Union[dict, list], *, size: tuple = None, device: str = "cpu", **__
) -> torch.Tensor:
"""Generates a multi-dimensional random tensor. Each entry can be initialised separately, or a common
initial... |
0384e6b629702d33555b405fd1724ceb6d808758ad32a56415c665f9493abd91 | Python | 2,823 | 92 | import argparse
import os
import os.path as osp
import time
import numpy as np
import torch
import torch.nn.functional as F
from sklearn.metrics import f1_score
import pandas as pd
import json
import torch_geometric.transforms as T
from tqdm import tqdm
import spacy
import re
from vaderSentiment.vaderSentiment import S... |
175e9360dcc1e3e331ee4540335197ba955028ad66c37d6f8fe2fc16326053e8 | Python | 2,823 | 91 | import argparse
import os
import os.path as osp
import time
import numpy as np
import torch
import torch.nn.functional as F
from sklearn.metrics import f1_score
import pandas as pd
import json
import torch_geometric.transforms as T
from tqdm import tqdm
import spacy
import re
from vaderSentiment.vaderSentiment import S... |
53e444127fb3f3e1e8b0567a790b2f0b4b4026a287714d8cad25745242a51f4f | Python | 2,823 | 70 | import argparse
def settings():
parser = argparse.ArgumentParser()
# public parameters
parser.add_argument('--seed', type=int, default=0,
help='Random seed. Default is 0.')
parser.add_argument('--no-cuda', action='store_true', default=False,
help='Disa... |
80a41030e6ee37c5df557446010c34af6c62e2c57914bbd5897b6a380f20bd24 | Python | 2,823 | 71 | import torch
from torch_geometric.nn import MessagePassing
from torch_geometric.nn import global_add_pool, global_mean_pool, global_max_pool, GlobalAttention, Set2Set
import torch.nn.functional as F
from torch_geometric.nn.inits import uniform
from conv import GNN_node, GNN_node_Virtualnode
from torch_scatter import ... |
8c5da53e8b33f5f52226fdc80034c3d34f9abb90b20d6a33cbfcbce9f020510e | Python | 2,823 | 72 | from brainvoice.data.fmri import load_fMRI_data
from torch.utils.data import Dataset
import os
from tqdm import tqdm
import pandas as pd
import numpy as np
import pickle
import time as t
class BrainVoiceDataset(Dataset):
def __init__(self, root_path, spectrogram_dir_name,labelfile='BrainVoice_15-03... |
083e58f8e2191adfac1e405cfafea8d56e0619d3eef6637cca89442a10f7bc7f | Python | 2,824 | 62 | from brainscore_vision.model_helpers.check_submission import check_models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images
import torchvision
import functools
import torch
import os
import timm
dir_path... |
d06eb2a3795de10a34574394175e0f033cf997e077b6f1adbdc0bffb24059b3b | Python | 2,824 | 83 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import io
from logging import Logger
import pytest
from cvat_sdk import Client, models
from cvat_sdk.api_client import exceptions
from cvat_sdk.core.proxies.organizations import Organization
class TestOrganizationUsecases:
@pytest.fixture(auto... |
d466acc0409e8528c03f9d87dca0e69fbd6296588bd4c01c050b1a1eacddbbc9 | Python | 2,824 | 82 | import bism.utils.cropping
import waterz
import os.path
import os
import torch
import torch.nn as nn
from torch.cuda.amp import GradScaler, autocast
import torch.optim.swa_utils
from bism.models.construct import cfg_to_bism_model
from bism.utils.io import imread
from tqdm import tqdm
import fastremap
import numpy a... |
713af089fd0d1c649d00b7edbbd66a4ab3f03cc70c2bd9ed323091a81a9051b3 | Python | 2,825 | 77 | import torch
import torch.nn as nn
def eval_model(loader, model, n_metadata, device):
model.eval()
total_loss = 0.0
iteration_counter = 0
pred_collector = [] # for evaluation metrics
labels_collector = [] # also for evaluation metrics
for i, batch in enumerate(loader):
images = ... |
24174d6337184c380c38940f7bbe445049ef17637034509a824381cf354e73f2 | Python | 2,826 | 88 | #: Source: https://github.com/neuraloperator/neuraloperator/blob/main/neuralop/utils.py
from typing import List, Optional, Union
from math import prod
Number = Union[float, int]
def count_model_params(model):
"""Returns the total number of parameters of a PyTorch model
Notes
-----
One complex num... |
72b0c3effc434691b472767d3ea6e9dacbc9ab741adcb744bc8cbe3813ec53da | Python | 2,826 | 88 | # This file is part of Mooney computational modeling project.
#
# Mooney computational modeling project 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) an... |
a7add6132fbcb66be1243d46bb4b016863eacb8bd63aca05a5201c766cc803fb | Python | 2,827 | 73 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from __future__ import annotations
import json
from pathlib import Path
from ultralytics.utils import LOGGER, YAML
from ultralytics.utils.checks import check_requirements
def onnx2deepx(
onnx_file: str | Path,
imgsz: tuple[int, int],
d... |
db147308dcb096ba054c61e7bd0a1e2e901fbe4e2c6863eb76669346405cb47e | Python | 2,827 | 99 | # Copyright (C) 2019-2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
import itertools
import operator
import os.path as osp
from hashlib import blake2s
from datumaro.util.os_util import make_file_name
DEFAULT_COLORMAP_PATH = osp.join(osp.dirname(__file__), "predefined_label_colors.txt")
def _get_color_from... |
1821788668733035cc9f44be28d7808492027b7b7596068640c444a1d0961fdf | Python | 2,828 | 83 | # %%
# imports
from io import BytesIO
import numpy as np
import requests
import torch
import torchvision
from PIL import Image
from torchvision.transforms import functional as F
# %%
# read_and_preprocess_image
def read_and_preprocess_image(path, cropbox = None):
if path.startswith('http'):
# use request... |
c0384596d8c4f0c054d75b34ddcb5ce6a1789b817d1559ea92882781db5f7e25 | Python | 2,828 | 69 | import torch
import torch.nn as nn
import torch.nn.functional as F
def resize_to_match(source, target):
target_size = target.size()[2:] # Extract spatial dimensions of target
source_resized = F.interpolate(source, size=target_size, mode='trilinear', align_corners=True)
return source_resized
class Simple3... |
01c20087490b58b3b610dd832b68f0e6591137234181b2baf1730c0e0d44f9fe | Python | 2,829 | 80 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from __future__ import annotations
from functools import partial
from pathlib import Path
import torch
from ultralytics.nn.modules import Pose, Pose26
from ultralytics.utils import LOGGER, YAML
from ultralytics.utils.checks import check_executorch_... |
51e0b0f2a354c2130ba01263082c65fa8650106bb301e2f2f8c0d77552b45c66 | Python | 2,829 | 79 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy.io.dvc import pull_test_case_package
# If they already exist, this only takes 5 seconds (check md5sum)
test_data_root = pull_test_case_package("aodf")
tmp_dir = tempfile.TemporaryDirectory()
def test_help_option(script_runner):
... |
eaf9102a9da881c7bcf36397a8526d7e847f4b9ccc60f347f42b17bf638dc863 | Python | 2,829 | 95 | import os
import functools
import json
from pathlib import Path
import ssl
import timm
import numpy as np
import torchvision.transforms as T
from PIL import Image
from brainscore_vision.model_helpers.activations.pytorch import (
PytorchWrapper, disable_activation_caching)
# Disable SSL verification
ssl._create_... |
87454af6860c9f6f1eb61e08d01b6ccd27d5fec8d211592b153a935fa51b8f4b | Python | 2,830 | 78 | #!/usr/bin/env python
# coding: utf-8
# Combine the barcodes we found from flexiplex discovery and mapping, per fasta chunk.
import argparse
import pandas as pd
from Bio.SeqIO.FastaIO import SimpleFastaParser
def combine_read_cnt_and_map(barcode_mapping_file, reads_fasta_file, output_filename):
"""
Merges re... |
a139ad0a37856d1314c458325e1a4f34c0651bde9c17abe8036ee3529bf37c59 | Python | 2,830 | 94 | from typing import Optional
import torch.nn.functional as F
from torch import Tensor
from torch.nn import Linear
from torch_geometric import EdgeIndex
from torch_geometric.nn.conv.cugraph import CuGraphModule
from torch_geometric.nn.conv.cugraph.base import LEGACY_MODE
try:
if LEGACY_MODE:
from pylibcugr... |
a20005280883ea31a229b83e29ec588227eeccfe133ceef3bac840c206087154 | Python | 2,830 | 87 | import torch
from distances import CosineSimilarity
from reducers import AvgNonZeroReducer
from utils import common_functions as c_f
from utils import loss_and_miner_utils as lmu
from losses.generic_pair_loss import GenericPairLoss
class CircleLoss(GenericPairLoss):
"""
Circle loss for pairwise labels only.
... |
0ffa9e182e19c1c6d47934751cfd85c5ced2f3cf398a5f67ba6050d3c03e56bd | Python | 2,831 | 80 | import torch
from timeit import default_timer
from torch_geometric.loader import DataLoader
from torch_geometric.data import Dataset
from deepcardio.meshdata import MeshDataset
DATAPROCESSOR_SAVEDIR = "./cardiac_models/electrophysio/"
from deepcardio.electrophysio import load_dataprocessor
def load_dataset(
mo... |
72b3fbf594b5552b86acf3eb13d7bf4336578abdb01911061da3a7db30dccbc9 | Python | 2,831 | 76 | # Copyright (c) DP Technology.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import math
from typing import List
from unicore.optim.lr_scheduler import UnicoreLRScheduler, register_lr_sche... |
6f076c3617891ec56eb97cf4f2bee6a2b5fb6ff471722cee8419ea0a39896a19 | Python | 2,832 | 98 | """
Tests for `bx.seqmapping`.
"""
import unittest
from io import StringIO
from numpy import (
allclose,
array,
)
import bx.seqmapping
class CharMappingTests(unittest.TestCase):
__test__ = False
def test_DNA(self):
assert allclose(bx.seqmapping.DNA.translate("ACGTacgt-?X"), [0, 1, 2, 3, 0,... |
ab9fc6bd46f73c5dbe4e631bb056ecbd742441bc46943bb3bce0f8ff06641f37 | Python | 2,832 | 93 | import numpy as np
import pandas as pd
from sklearn.preprocessing import RobustScaler, StandardScaler
def load_and_format_data(dataset, first_iqm, move_iqms=False):
"""Load and format a dataset"""
df = pd.read_csv(dataset)
cols = df.columns.tolist()
xy_index = cols.index(first_iqm)
if move_iqms:
... |
242824991e169b97fb5d774c01b276a97c6bad748cd5e91b1b952ca1ad00cf97 | Python | 2,833 | 92 | from collections.abc import Sequence
from pathlib import Path
import numpy as np
import torch
from eir.data_load.data_preparation_modules.common import (
process_tensor_to_length,
)
from eir.setup.input_setup_modules.setup_sequence import (
ComputedSequenceInputInfo,
al_encode_funcs,
get_sequence_spli... |
657838640c2979ec03148da27abd953eaa689e717160529cf00588cbb962a6e4 | Python | 2,834 | 84 | import numpy as np
import pandas as pd
from sklearn.model_selection import KFold
from sklearn import tree
from sklearn.metrics import roc_auc_score
from sklearn.metrics import recall_score
from sklearn.metrics import precision_score
from sklearn.metrics import accuracy_score
from sklearn.metrics import f1_score
from sk... |
857c3ed9d1693cd97ad345242ca96b5425cf2b2c2898223f2468a4b03a4066c1 | Python | 2,834 | 76 | """
Tools for tiling / projecting alignments onto an interval of a sequence.
"""
import bx.seq.nib
def tile_interval(sources, index, ref_src, start, end, seq_db=None):
"""
Tile maf blocks onto an interval. The resulting block will span the interval
exactly and contain the column from the highest scoring ... |
ade5c188922465e942126b2c88181d2e3e55cf5b739cd317163574154ad0fb7f | Python | 2,834 | 79 | # Copyright (C) 2022 Intel Corporation
# Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from enum import StrEnum
from typing import Any
from django.conf import settings
from rest_framework.exceptions import PermissionDenied
from cvat.apps.engine.permissions import DownloadExportedExtension
from c... |
2ab2e02df5de2339a3e1a89ac90ffd504281c6405c4de7a0e1ff53426308b0d1 | Python | 2,835 | 96 | import nibabel as nib
import nibabel.processing as nbp
import numpy as np
def crop_to_nonzero(img):
"""Crops the image to the bounding box of non-zero voxels."""
data = img.get_fdata()
nonzero_coords = np.array(np.nonzero(data))
start_coords = nonzero_coords.min(axis=1)
end_coords = nonzero_coord... |
9fd9fce0b67e912420ce05a6a045ec70911d58f5ec2d9ebadfe4f596964decaf | Python | 2,835 | 94 | """ChemGraph Streamlit application entry point.
Run with: ``streamlit run src/ui/app.py`` (or ``chemgraph ui``)
This thin module handles page configuration (which **must** be the first
Streamlit call) and navigation via ``st.navigation``, which gives each
page its own URL and a native sidebar entry. All page conte... |
78b0db8b45639e1690f084b91028a43e398b1266bf9cd0cf8a715f7d3d496e94 | Python | 2,836 | 75 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from torch import nn
from torch.nn import functional as F
class Encoding(nn.Module):
"""Encoding Layer: a learnable residual encoder.
Input is of shape (batch_size, channels, height, width).
Output is of shape (batch_size, num_codes, channels)... |
a2fb41e03994e32947a57a30848ac6dad65e78004155bca13d7f97e05cc8fd62 | Python | 2,836 | 72 | #!/usr/bin/python3
#
import os
import sys
import argparse
import shutil
from uac import utils
# Create the parser
my_parser = argparse.ArgumentParser(description="UAC fibre mapping")
# Add the arguments
my_parser.add_argument("target_path", metavar="path", type=str, help="Path for the new target mesh")
my_parser.add... |
4912b3f0b1fb16b90327330395f89d03e11d38761714a422fd60799e599ba0f2 | Python | 2,837 | 113 | """
# multipermute - permutations of a multiset
# Github: https://github.com/ekg/multipermute
# Erik Garrison <erik.garrison@bc.edu> 2010
This module encodes functions to generate the permutations of a multiset
following this algorithm:
Algorithm 1
Visits the permutations of multiset E. The permutations are stored
in a... |
b10e70e6e5aa58860d9b34a45dbd47662005f89c1e14f9697cbe50d43d7beceb | Python | 2,837 | 94 | # 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... |
7d8929867b99e01c33cb4c0fbbd145abef3da75cddcd341c21c629413f3eb7c2 | Python | 2,838 | 65 | from models.diffusion.ddpm2 import DDPM
from modules.utils import *
class LDM(DDPM):
def __init__(self, vqvae_config=None, condition_type="none", *args, **kwargs):
super().__init__(condition_type=condition_type, *args, **kwargs)
self.vqvae = instantiate_from_config(vqvae_config)
self.vqvae.... |
8fa621142adbf8b357170b917ab48642728e572e616dd196eefbde8c4b02de9a | Python | 2,838 | 50 | from pathlib import Path
import pandas as pd
from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet, StimulusSetLoader
from brainscore_core import Score
from brainscore_vision import load_metric
from brainscore_vision.benchmarks import BenchmarkBase
from brainscore_vision.model_interface imp... |
13fcca3ea28550ff607f317ae12eb1781cd98246a9ece984116fcba2a86ed0e6 | Python | 2,840 | 100 | #!/usr/bin/env python
"""
Read a compressed file as created by 'lzop' from stdin and write a table to
stdout containing the blocksize and the start offset (in bytes) of each
compressed block.
usage: %prog < FILENAME.lzo > FILENAME.lzot
"""
import struct
import sys
MAGIC = b"\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a"
F_... |
3e81570bcbc9f25cae5b4243756eb3b00fceda23c0445b38eac77c6e5f29e53a | Python | 2,840 | 71 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from __future__ import annotations
import shlex
import shutil
import subprocess
import tempfile
from pathlib import Path
from ultralytics.utils import LOGGER, YAML
def _check_atc() -> None:
"""Raise if the CANN ATC compiler is not on PATH."""
... |
a03a69203b2e4fc37743bad9bda69418bd4e3b9ab72a3626c3d32363d8040a73 | Python | 2,840 | 72 | # This file is part of Mooney computational modeling project.
#
# Mooney computational modeling project 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) an... |
693fd1c6a165ff803c471d6f9db0638592f4a25ad426803480dfbe129bfd24ab | Python | 2,841 | 60 | #!/usr/bin/env python3
"""Stage 1 (Cao 2019) -- extract features and cache windowed arrays per lead."""
from __future__ import annotations
import argparse, json, logging, sys, time
from pathlib import Path
import numpy as np
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
from rgnft.data_cao imp... |
6e529822848ddb96e2d14f21497df4dbd69b360ff2c9a4ec65356603575da4a1 | Python | 2,841 | 100 | # -*- coding: utf-8 -*-
#
# test_schedules.py
import unittest
import arbor as A
from arbor import units as U
import functools
"""
all tests for profiling
"""
def lazy_skipIf(condition, reason):
"""
Postpone skip evaluation until test is ran by evaluating callable `condition`
"""
def inner_decorato... |
195d4f8544e0d9a0a3571d1cc7de7b584ab100d56efeb970f7dc74b6a825cae5 | Python | 2,842 | 90 | import math
import numpy as np
def raster_to_spike_times(raster, fs):
"""Convert spike raster to a list of spike time arrays.
Parameters
----------
raster : np.ndarray.
Binary spike raster of shape (T, N), where T is the number of time bins
and N is the number of neurons.
fs ... |
5760338cdc5ead0453096bf10c98bd2910697ef8e570a4d7a98bc2a70f0cb829 | Python | 2,842 | 69 | import numpy as np
from scipy.stats import gamma,spearmanr
def get_interval_stats(tints,stimes,minisis=5):
isis, isis1, isis2 = collect_intervals(tints,stimes)
if np.size(isis1) >= minisis:
#print (np.size(isis1))
M = np.corrcoef(isis1,isis2)[0,1]
else:
M = None
if np.s... |
13d8259fc2f438d60ea84aed65836461ab9d3fb10355421a7fb717007a958e8b | Python | 2,843 | 69 | # -*- coding: utf-8 -*-
import numpy as np
from scilpy.reconst.fiber_coherence import (compute_coherence_table_for_transforms,
compute_fiber_coherence)
def test_compute_fiber_coherence_fliptable():
# Just checking that we get 24 values.
# See below for the real tes... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.