sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
ffdaccb0af9b65b17b77651a026e4b5b2fe24ae080fabbc1401ab27b1bf74234 | Python | 850 | 28 | # Copyright (c) DP Technology.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from functools import lru_cache
import torch
from unicore.data import Dictionary
from functools import lru_cache
from . import BaseWrapperDataset
class TokenizeD... |
5a39d2d73108724d27cdc35e211dde6474627b64981f40a9f821251795ca7aa7 | Python | 851 | 31 | import pytest
from qtpy import PYQT5, PYQT_VERSION
from tests.utils import pytest_importorskip
def test_qtdbus():
"""Test the qtpy.QtDBus namespace"""
QtDBus = pytest_importorskip("qtpy.QtDBus")
assert QtDBus.QDBusAbstractAdaptor is not None
assert QtDBus.QDBusAbstractInterface is not None
asser... |
64a6a249a6e15030e205e82b3f5f7b5ac822a3f651fc914fc1534e60ed115138 | Python | 851 | 39 | import os
import sys
from datetime import datetime
sys.path.insert(0, os.path.abspath("../eir"))
project = "EIR"
author = "Arnór Ingi Sigurðsson"
copyright = f"{datetime.now().year}, {author}"
html_logo = "source/_static/img/EIR_logo_white.svg"
html_theme_options = {
"logo_only": True,
"navigation_depth": 3... |
1a1e4c1380fc83fdbc1385680a33ec2bfcb2ea49a85a7d62604d034a93d41445 | Python | 852 | 26 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys='surface_vtk_fib.zip')
tmp_dir = tempfil... |
7dfa56058b6f51dfcf339bf83fe4e2b235c448eaec96e9acc94e1eb5f222a835 | Python | 852 | 24 | import os
import pandas as pd
from pathlib import Path
root_path = Path("/data2/whr/czl/TwiBot22-baselines/datasets")
datasets = os.listdir(root_path)
def calc_bot_rate(dataset):
dataset_path = root_path / dataset
label = pd.read_csv(dataset_path / "label.csv")
split = pd.read_csv(dataset_path / "split.c... |
19e5ca28b87da4ada2e8fc7e7d4cb8f4ab5d734efe8d3d2dd61fd824e7d36f4a | Python | 853 | 26 | import numpy as np
from PIL import Image
import os
def main():
data_path = os.path.join(os.path.dirname(__file__), 'cadena2017')
images = np.load(os.path.join(data_path, 'images.npy'))
_show_image(images[0])
np.testing.assert_array_equal(images.shape, (7250, 140, 140)) # images x width x height
r... |
21b7df875213724657dcd27828014efbbe443826693f09bf3a6fbb96b8b5af76 | Python | 853 | 25 | import pandas as pd
import dask.dataframe as dd
import csv
labels = pd.read_csv("/data2/whr/czl/TwiBot22-baselines/datasets/cresci-2017/label.csv")
user_final = list(labels['id'])
df = dd.read_csv("/data2/whr/czl/TwiBot22-baselines/datasets/cresci-2017/edge.csv")
user_to_post = {}
for i, row in df.iterrows():
if... |
3a39fab19993c6696ac6ed97f21058e949253acd6377c1dd10d898412c96c314 | Python | 853 | 29 | import pytest
from qtpy import PYQT5, PYQT6, PYQT_VERSION, PYSIDE6, QtMultimedia
def test_qtmultimedia():
"""Test the qtpy.QtMultimedia namespace"""
assert QtMultimedia.QAudio is not None
assert QtMultimedia.QAudioInput is not None
if not (PYSIDE6 or PYQT6):
assert QtMultimedia.QAbstractVide... |
ab67f1d17ee1d12c86f6920e167d3a6b4b300166b82307ba621f84f55346dede | Python | 853 | 27 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['tractometry.zip'])
tmp_dir = tempfile.... |
f40367e9d5443f59738280c2ea0334e7ee37fcdfe1f2367a724d3d857e1efb68 | Python | 853 | 30 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import PIL.Image
import cvat_sdk.auto_annotation as cvataa
import cvat_sdk.models as models
from ._torchvision import TorchvisionFunction
class _TorchvisionDetectionFunction(TorchvisionFunction):
_label_type = "rectangle"
def detect(
... |
00e102341d8e06128b334906b198e7bd6b4a5d1ae49b64a489ecef0ed7c4a0a7 | Python | 854 | 27 | import numpy as np
import torch
from utils import common_functions as c_f
from losses.large_margin_softmax_loss import LargeMarginSoftmaxLoss
class ArcFaceLoss(LargeMarginSoftmaxLoss):
"""
Implementation of https://arxiv.org/pdf/1801.07698.pdf
"""
def __init__(self, *args, margin=28.6, scale=64, **k... |
3c38625be70b6f216204991583b2d17d3a8d6e6a4f9838a6916261af592464ec | Python | 854 | 43 | # Configuration file for the Sphinx documentation builder.
import os
import sys
sys.path.insert(0, os.path.abspath(".."))
# -- Project information
project = 'ivim'
copyright = '2025, Oscar Jalnefjord'
author = 'Oscar Jalnefjord'
release = '1.0'
version = '1.0.0'
# -- General configuration
extensions = [
'sph... |
e6a148cbe802d5d64d41bce18e6054042aa5a3e4d9ec214942d974cc76de174d | Python | 854 | 25 | # -*- coding: utf-8 -*-
import os
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
from scilpy.tractograms.lazy_tractogram_operations import \
lazy_streamlines_count, lazy_concatenate
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_te... |
1e3945817bde27f6610b8da4db54c515c1e83a292afec71ec56c072b8352f428 | Python | 855 | 18 | from imblearn.under_sampling import RandomUnderSampler
class ActivitySubsetRandomSampler(RandomUnderSampler):
def __init__(self, samples_per_activity):
self.samples_per_activity = samples_per_activity
print(f'Do under sampling with {samples_per_activity} samples per activity...')
def fit_resam... |
b57adf6a10f3df3a5e478b706825de3cf674e7c34d402f2734a8c783922b5f38 | Python | 855 | 20 | from efficientnet_pytorch_3d import EfficientNet3D
import torch.nn as nn
class EfficientNet3DB0(nn.Module):
def __init__(self, num_classes=2, in_channels=1, use_bce=True):
"""
Args:
num_classes: Output classes (for compatibility, ignored when use_bce=True)
in_channel... |
2fd0dee401bffbe0f3c132dd4bbc8401c7d9220db5d8b661c6d3f1f67c1a1d68 | Python | 856 | 41 | from cProfile import label
import numpy as np
import pandas as pd
import json
import torch
from pathlib import Path
def str_to_int(s):
if s == 'human':
return 1
else:
return 0
path1 = Path('datasets/Twibot-20')
data = pd.read_csv(path1 / 'label.csv')
data_label = {}
for id in data['id']:
... |
34a65a76e5179cdddab2468405917db6e0ea0a8c0245af6db78b31e5841b297a | Python | 856 | 25 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# If they already exist, this only takes 5 seconds (check md5sum)
# fetch_data(get_testing_files_dict(), keys=['bundles.zip'])
# tmp_dir = tempfile.TemporaryDirectory()
def test_help_option(script_runner):
ret = script_runner.run(['scil_viz_bundle', '--help'])
... |
5d3a654d0d17868e49995fc421ae10a0df578b546b4567a667ddc7b3bb0b46ca | Python | 857 | 26 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['filtering.zip'])
tmp_dir = tempfile.Te... |
78929ef5bba028fecfd2b1d1154f97e5fa58c75dbd310680ec53891dd3e7453d | Python | 857 | 30 | #!/usr/bin/env python3
"""
Convert every PDF in the current directory to Markdown.
Install docling first:
pip install docling
"""
from pathlib import Path
from docling.document_converter import DocumentConverter
PDF_DIR = Path.cwd() / "pdf" # folder to scan
OUTPUT_DIR = Path.cwd() / "md" # folder ... |
756472983214914548d8c7849811b9585e11ea339b65eb1e48157d1ba14d7e37 | Python | 858 | 31 | import functools
import inspect
import warnings
from typing import Any, Callable, Optional
def deprecated(
details: Optional[str] = None,
func_name: Optional[str] = None,
) -> Callable:
def decorator(func: Callable) -> Callable:
name = func_name or func.__name__
if inspect.isclass(func):
... |
bc6dbb592930bc37867b3c5d54e45a97a7628b9a294e3872933881d251c1ed89 | Python | 858 | 31 | # Generated by Django 3.1.13 on 2021-10-26 10:10
from django.db import migrations, models
def update_default_format_field(apps, schema_editor):
GitData = apps.get_model("dataset_repo", "GitData")
for git_data in GitData.objects.all():
if not git_data.format:
git_data.format = (
... |
2f120b07907b8235bc0a9f0d0fd0d2c1b89dc66231df259713a8de64fe3b8e3c | Python | 859 | 34 | #!/usr/bin/env python
"""
Test that HAL modules handle messages in the expected order.
"""
import os
import pytestqt
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
import storm_analysis.sa_library.datareader as datareader
import storm_control.hal4000.hal4000 as hal4000
import storm_control.sc_library.hdebug a... |
53e707d25233c79ba54c92b7515e2106a82f6af707b824c05e4ea242f473a03c | Python | 860 | 43 | import unittest
import torch
import torch.nn as nn
import torch.testing as ptt
from torch.utils.data import DataLoader
if __name__ == "__main__":
unittest.main()
class TestSet(torch.utils.data.Dataset):
def __init__(self, ten: torch.Tensor):
self.ten = ten
def __len__(self):
return le... |
78e995459f649a064b5fe781de003c1b4fc5089fcdc5ace2091ed16932074771 | Python | 860 | 27 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['bst.zip'])
tmp_dir = tempfile.Temporar... |
b10e463642578e31292083beb7b82bbdbac293cf38df256868a1a00e565447a8 | Python | 860 | 25 | import logging
import sys
import pytest
from pytest import approx
from brainscore_vision import score
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
@pytest.mark.slow
@pytest.mark.travis_slow
@pytest.mark.memory_intense
@pytest.mark.parametrize("model_identifier, benchmark_identifier, expected_score",... |
f522562118745d1aca0125bf38dfa8fbe8a109c7f43e95beb2a0fc2167a3b76e | Python | 860 | 41 | import re
import io
import sys
import time
import zlib
import json
import shutil
import typing
import struct
import pickle
import pathlib
import argparse
import threading
import traceback
import itertools
import contextlib
import subprocess
import collections
from multiprocessing.pool import ThreadPool
import yaml
imp... |
4a0bc28b1c412a83bb3ed19e0acba8221152bb160a5d699dfa2b3eedc3ba1ee8 | Python | 861 | 28 | import subprocess
import sys
import yaml
script_compare = 'enrichments/compare_datasets.py'
pathpath = 'PATHS/filepaths_carlen.yml'
with open(pathpath, 'r') as myfile: pathdict = yaml.safe_load(myfile)
sys.path.append(pathdict['code']['workspace'])
from pfcmap.python import settings as S
setkeys = [key for key in S.... |
bd87456cebf5517edc9fe19e62017fae9c018ecae63b9e014094a5283f83b444 | Python | 861 | 28 | import pathlib
import json
import sys
def summarize_test_report(input_file:str, output_file:str):
file = pathlib.Path(__file__)
report_path = file.with_name(input_file)
with report_path.open() as f:
report_info = json.load(f)
summary = []
for test_case in report_info['tests']:
if 'u... |
e7c80927f045e59a66e67392b80f720cb19add64bb53e051ea6c0f6561fe00ea | Python | 861 | 27 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from typing import ClassVar
import attrs
from cvat.apps.redis_handler.rq import RequestIdWithSubresource
@attrs.frozen(kw_only=True, slots=False)
class QualityRequestId(RequestIdWithSubresource):
ACTION_DEFAULT_VALUE: ClassVar[str] = "calcula... |
f240b8f4111c8e12890e74545cfd135f14b96de4b50bba8c4cb91ab913501f28 | Python | 861 | 22 | from brainscore_vision import stimulus_set_registry
from brainscore_core.supported_data_standards.brainio.s3 import load_stimulus_set_from_s3
BIBTEX = """@INPROCEEDINGS{5206848,
author={Deng, Jia and Dong, Wei and Socher, Richard and Li, Li-Jia and Kai Li and Li Fei-Fei},
booktitle={2009 IEEE Conference on Compute... |
5f21a4ed41496226159e5adbccbd481d22dd42ceca297760285032a25c858a01 | Python | 862 | 41 | from cProfile import label
import numpy as np
import pandas as pd
import json
import torch
from pathlib import Path
def str_to_int(s):
if s == 'human':
return 1
else:
return 0
path1 = Path('datasets/cresci-2015')
data = pd.read_csv(path1 / 'label.csv')
data_label = {}
for id in data['id']:
... |
9309d01fad41bf8cf3bdec7088453c8601cbdbf945cc44b67a065eaea3540d72 | Python | 862 | 26 | '''
Ludl (voltage controlled) Z stage functionality
George 02/18
'''
from PyQt5 import QtCore
import storm_control.sc_hardware.baseClasses.voltageZModule as voltageZModule
class LudlVoltageZ(voltageZModule.VoltageZ):
"""
This is a Mad City Labs stage in analog control mode.
"""
def __init__(self, m... |
c0b533e35d05b2fd318735e44e3410750ec54b07be07e5b5ba26be94cf9297a6 | Python | 862 | 41 | from cProfile import label
import numpy as np
import pandas as pd
import json
import torch
from pathlib import Path
def str_to_int(s):
if s == 'human':
return 1
else:
return 0
path1 = Path('datasets/cresci-2017')
data = pd.read_csv(path1 / 'label.csv')
data_label = {}
for id in data['id']:
... |
d932cc76b912259a1e984f70a6742498737e9175a478931348f3c4f94cc25107 | Python | 862 | 35 | """# Snell's law demonstration using magicgui
Demo app for calculating angles of refraction according to Snell's law.
"""
import math
from enum import Enum
from magicgui import magicgui
class Medium(Enum):
"""Enum for various media and their refractive indices."""
Glass = 1.520
Oil = 1.515
Water =... |
1734e0663a7c9f92d6b07cd3f700477b0d2ff82f0dee5a12b87bfa5e3625ea22 | Python | 863 | 33 | import sys
import toml
import subprocess
import configparser
def main():
config = toml.load('pyproject.toml')
version = config['project']['version']
parts = [int(i) for i in version.split('.')]
if sys.argv[1] == 'major':
parts[0] += 1
parts[1] = 0
parts[2] = 0
elif sys.argv[1] == 'minor':
pa... |
1be189fac20572d98419ea43adbaf9f844d64b16488ec1cb4bb5f3c623902751 | Python | 863 | 43 | r"""GNN profiling package."""
from .benchmark import benchmark
from .profile import (
get_stats_summary,
print_time_total,
profileit,
rename_profile_file,
timeit,
torch_profile,
trace_handler,
xpu_profile,
)
from .utils import (
count_parameters,
get_cpu_memory_from_gc,
get_... |
7f17cf0aff0d1d24a4c4742ff0791097dc13452beea962dfa2a84f5b632e4c47 | Python | 863 | 33 | import torch
import time
from torch import nn
import torch.nn.functional as F
class LSTHM(nn.Module):
def __init__(self,cell_size,in_size,hybrid_in_size):
super(LSTHM, self).__init__()
self.cell_size=cell_size
self.in_size=in_size
self.W=nn.Linear(in_size,4*self.cell_size)
self.U=nn.Linear(cell_size,4*sel... |
e18cbc16ba27fecb20ee417db2d9a50d043d2fbdc0b53968829b35d4c2b04d3b | Python | 863 | 34 | # 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.
"""isort:skip_file"""
import importlib
import os
from unicore import registry
from unicore.losses.unicore_loss... |
e39cc3a8513a8869382f79c62a4d3529851fa843d766b6ae4875f3c09987a83a | Python | 863 | 25 | import numpy as np
def reconstruction_error(XY, XY_completed, missing_mask, name=None):
"""
Returns mean squared error and mean absolute error for
completed matrices.
"""
value_pairs = [
(i, j, XY[i, j], XY_completed[i, j])
for i in range(XY.shape[0])
for j in range(XY.shap... |
b12ab1ec5c532feb17764ae505dc4cbec139e50a761674217ca54ac74eac675a | Python | 864 | 33 | import pandas as pd
from brainways.utils.contrast import calculate_contrast
def test_contrast():
results_df = pd.DataFrame(
[
{
"cond": condition,
"animal_id": animal_id,
"is_parent_structure": False,
"is_gray_matter": True,
... |
cf48b9acc2f6933c7b83c00868aba4f590aae07ad5a9c3963437833b132a6cc8 | Python | 864 | 24 | import pickle
from joblib import Parallel, delayed
from mne import read_source_estimate, compute_source_morph
models = ["symbolic", "dino_last", "IT", "skel_1", "skel_2"]
subs = [f"sub-{(i+1):02}" for i in range(20) if i != 2]
based = "../../bids_data/derivatives"
def process_one_sub(s, name):
basemsm = f"{based}... |
dd31b1b87d7a116f31028b51ec95720a5aa5d6a9f3323cc35bb7aa653b8ff267 | Python | 864 | 37 | #!/usr/bin/env python
"""
Read a maf file from stdin and write out a new maf with only blocks having all
of the required in species, after dropping any other species and removing
columns containing only gaps.
usage: %prog species,species2,... < maf
"""
import sys
import bx.align.maf
def main():
species = sys.... |
e43507e3c141cb20c87961b385f2a2a31ec3cbab9adc6a22302ae74fc1354311 | Python | 864 | 30 | # -*- coding: utf-8 -*-
import torch
import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence
class CHAR_LSTM(nn.Module):
def __init__(self, n_chars, n_embed, n_out):
super(CHAR_LSTM, self).__init__()
# the embedding layer
self.embed = nn.Embedding(num_embeddings=n_char... |
02652958b344dec64c3bf97fa919f2581fecec05535b14890117583e9805152c | Python | 865 | 28 | """Get training data.
This script will download source reconstructed task MEG data collected using
an Elekta scanner.
The data is from the Wakeman-Henson dataset: https://www.nature.com/articles/sdata20151
It consists of 19 subjects performing a visual perception task.
Each subject performed 6 runs.
"""
import os
... |
5bcd0faec640346d881560491e8eb179e703556265e8ab09ba00f774abea5f21 | Python | 865 | 30 | from __future__ import absolute_import, print_function, division
from .solver import Solver
from .nuclear_norm_minimization import NuclearNormMinimization
from .matrix_factorization import MatrixFactorization
from .iterative_svd import IterativeSVD
from .simple_fill import SimpleFill
from .soft_impute import SoftImput... |
d0445a30edaac3fb90547967c2298825a3f2feb110e6da534ff8fa7d7b3cb9c8 | Python | 865 | 20 | import torch.nn as nn
class BendNet(nn.Module):
def __init__(self):
super().__init__()
self.model = nn.Sequential(
nn.Linear(6, 1024), nn.BatchNorm1d(1024), nn.ReLU(),
nn.Linear(1024, 2048), nn.BatchNorm1d(2048), nn.ReLU(),
nn.Linear(2048, 4096), nn.Batch... |
0748befd57d07c25b8b3090b6e666cbbabef5d2f688165f76b5c692f3eae2870 | Python | 866 | 31 | import argparse
import os.path
import shutil
def parse_args():
parser = argparse.ArgumentParser(
description=('add a prefix to each file as it is copied'
' into a destination directory'))
parser.add_argument('prefix', help='the prefix to add to each file')
parser.add_argument(... |
2dcf3b7e198e8e9e347edce40ebd5693df8a4c244a4b17870f9b98aad288b79f | Python | 866 | 40 | from machine import ADC
import time
# --- Configuration ---
ADC0_PIN = 26 # GPIO26 = ADC0
ADC1_PIN = 27 # GPIO27 = ADC1
VREF = 3.3
VMID = 1.1
GAIN = 2.6
ADC_MAX = 4095
adc0 = ADC(ADC0_PIN)
adc1 = ADC(ADC1_PIN)
def read_adc_voltage(adc, samples=8):
acc = 0
for _ in range(sa... |
2a7e2535b468d8ec530968c6c39fba8263a4e86a844244af153009a5e7814ec2 | Python | 867 | 25 | # This updates usage/kwargs.rst to the latest API kwargs
# Developers can run this after modifying any arguments the user can see
from AFQ.api.utils import AFQclass_doc
prologue = """
.. _kwargs_docs:
The pyAFQ API optional arguments
--------------------------------
You can run pyAFQ on either a subject or participa... |
b6b547c4f983e2caa6c6eb1bbaf82db5958c6e21625ef38d58ce90203782538d | Python | 867 | 27 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from django.core.exceptions import ValidationError
DEFAULT_MIN_PASSWORD_LENGTH = 8
DEFAULT_MAX_PASSWORD_LENGTH = 256
class MaximumLengthPasswordValidator:
def __init__(self, max_length: int = DEFAULT_MAX_PASSWORD_LENGTH) -> None:
self.... |
b9a5aeef4e27a80c0933f1588b16d36d795a2465f037a018994e504283c26543 | Python | 867 | 39 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import io
import logging
import pytest
@pytest.fixture
def fxt_stdout(capsys):
class IoProxy(io.IOBase):
def __init__(self, capsys):
self.capsys = capsys
def getvalue(self) -> str:
capture = self.capsys... |
c16b6e9a7af0f8e3412daced4b572d6006e5fad109ed7a414e68f5f8e23bc3ae | Python | 867 | 26 | import torch
from sklearn.model_selection import StratifiedKFold
class StratifiedBatchSampler:
"""Stratified batch sampling
Provides equal representation of target classes in each batch
"""
def __init__(self, y, batch_size, shuffle=True):
if torch.is_tensor(y):
y = y.numpy()
... |
4eba7b1643246f0b4c535eaf1e438b7e1ebe2690058641959fd0a45e5fa0e58f | Python | 868 | 31 | # -----------------------------------------------------------------------------
# Copyright © 2009- The Spyder Development Team
#
# Licensed under the terms of the MIT License
# (see LICENSE.txt for details)
# -----------------------------------------------------------------------------
"""Provides classes and functio... |
68a71033c26d08647f785fc8eede7b36f31154a28a48c59102fd33d19f6ba8d4 | Python | 868 | 26 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['atlas.zip'])
tmp_dir = tempfile.Tempor... |
75b32605138da90f6e042f28222d1effdd9aab3efe3d1c0898f402cbd2d4f580 | Python | 868 | 28 | import yaml
from typing import Dict, Any
class Config:
"""Class to handle configuration loading and management."""
@staticmethod
def load_config(config_file: str) -> Dict[str, Any]:
"""Load configuration from YAML file."""
with open(config_file, 'r') as file:
config = yaml... |
581d07c7df7740d4fc854cff840920e4dd18b943c4ba0fbc6edc7ae4e3872328 | Python | 869 | 32 | #!/usr/bin/env python
import codecs
import json
import numpy
import fnmatch
import os
matches = []
for root, dirnames, filenames in os.walk('.'):
for filename in fnmatch.filter(filenames, '*00000.vti'):
matches.append(os.path.join(root, filename))
splits = []
for match in matches:
splits.append(match.split('/... |
ed435aa45613cfd6d04bf90eb06c5b3d75e19b8df775b9dd6250248a5c6f9341 | Python | 870 | 24 | #!/usr/bin/env python
import os
def dataDirectory():
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "data/")
def daveXmlFilePathAndName(filename):
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "dave_xml", filename)
def halXmlFilePathAndName(filename):
return os.path.jo... |
fda571274589fb2cd2a3450d4858cf729a2c416f848897facd4572112f2108cf | Python | 870 | 34 | from __future__ import annotations
import io
import pytest
from ruamel.yaml import YAMLError
from labelme import _yaml
def test_safe_load_parses_string_into_nested_structure() -> None:
assert _yaml.safe_load("a: 1\nb:\n - 2\n - 3\n") == {"a": 1, "b": [2, 3]}
def test_safe_load_accepts_file_like_stream() ->... |
45e9b6aae2fbfdb98e57dc641de01b378ceffc357ac440f973a77650a84de647 | Python | 871 | 27 | import pathlib
from thalamus.pipeline.thalamus_window import Factory, UserData, UserDataType
from thalamus.task_controller.task_context import TaskDescription
#import ext_task
import platform
import ceci_stim_task
def widgets():
return {
'EXT_CECI': Factory(None, [
UserData(UserDataType.DEFAULT, 'Device 1'... |
f799027d37f17ce5f43a98e0f5159bb67af5f7fd2f3fea58d10edfc5d37c3d95 | Python | 871 | 35 | # -*- coding: utf-8 -*-
"""
Created on Tue Jan 18 20:57:03 2022
@author: Artur Klepaczko
"""
import nibabel as nii
import numpy as np
from pathlib import Path
root = Path(r'D:\TexturesKidneys\NiFTI-T2')
# patient = 'PK11'
# patient_path = root / patient
for nii_path in root.glob('**/*.nii.gz'):
in_image = ni... |
ec8d237d0183b7fd422e91fdf8a439a7c7e9a65b140a4b8c8ac3b4879225e1b4 | Python | 873 | 28 | #encoding=utf-8
from __future__ import print_function
import sys
sys.path.append("../")
import jieba
def cuttest(test_sent):
result = jieba.cut(test_sent)
print(" ".join(result))
def testcase():
cuttest("这是一个伸手不见五指的黑夜。我叫孙悟空,我爱北京,我爱Python和C++。")
cuttest("我不喜欢日本和服。")
cuttest("雷猴回归人间。")
cuttest(... |
8e389a0c8a30df64ab5bd98527a4f4d3a76bed24631be383c1259b53d28e7cd3 | Python | 874 | 23 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors: Agatha Schmidt, Henrik Zunker
#
# Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in complian... |
9873074edb2c60577d7943d1a9fafbade7cefad89ff5c38d60c877ce96c46ecf | Python | 874 | 30 | from setuptools import setup
setup(name='heig',
version='1.2.0',
description='Highly Efficient Imaging Genetics (HEIG)',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
url='https://github.com/Zhiwen-Owen-Jiang/heig',
author='Zhiwen Jiang',
... |
731b6e0ac507073435bda0ed484be5eab1a3a8d54875395e5594ab42419b0ceb | Python | 876 | 39 | from __future__ import absolute_import
import os
import sys
from .osutils import mkdir_if_missing
class Logger(object):
def __init__(self, fpath=None):
self.console = sys.stdout
self.file = None
if fpath is not None:
mkdir_if_missing(os.path.dirname(fpath))
self.fi... |
c5eef7978afe869328bd07763f9636d4bad9e1cd1e866973fd82b9455779d938 | Python | 876 | 27 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['processing.zip'])
tmp_dir = tempfile.T... |
ca8f9054c5853926f9c4ebb453fb0d02cccab32d3d5be4a7d0aaadcc976b7635 | Python | 876 | 26 | import pandas as pd
import dask.dataframe as dd
import csv
labels = pd.read_csv("/data2/whr/czl/TwiBot22-baselines/datasets/cresci-2015/label.csv")
user_final = list(labels['id'])
'''user_final = []
for row in labels.iterrows():
user_final.append(row[1][0])'''
df = dd.read_csv("/data2/whr/czl/TwiBot22-baselines/d... |
d7320beb9386608045d835f77a4320f695522054d7429382bcb23f0dc4b80340 | Python | 876 | 27 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['tractometry.zip'])
tmp_dir = tempfile.... |
d9997f3bb07820ee009391a4ed5d8000356bd6b9ab80e7d7e3ac0339a4a67573 | Python | 876 | 31 | # Copyright (C) 2018-2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
# Inherit parent config
from .base import * # pylint: disable=wildcard-import
DEBUG = False
NUCLIO["HOST"] = os.getenv("CVAT_NUCLIO_HOST", "nuclio")
# Django-sendfile:
# https://github.com/moggers87/django-sendfile2
SENDFILE_BACKEND = "dj... |
05fc91618bec5a935e334262a7b9db04afe630b8068c7cc3beae1d9779b7b464 | Python | 877 | 36 |
import pandas as pd
import numpy as np
from tqdm import tqdm
import os
import networkx as nx
dataset_name='Twibot-22'
edge_path=r'Twibot-22/edges.npy'
edge_index=list(np.load(edge_path))
edges=edge_index
dataset_name='Twibot-22'
id_include=(np.load(dataset_name+'/id_include.npy',allow_pickle=True))
if not os.path.exi... |
a1747a2c820eebf76d9872d9a9d3d0e6c91cb4e15b6535a235b2fc925ba69147 | Python | 877 | 27 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['processing.zip'])
tmp_dir = tempfile.T... |
102dec178f0a85d00dd04977ba47a9663e46d01f3dd6072a94a88e7fc4f54a86 | Python | 878 | 32 | import os.path
import subprocess
import tornado.autoreload
import tornado.ioloop
#an alternative:
#watchmedo shell-command --pattern="*.rst;*.py" --recursive --command="make html" .
included_ext = ['.py', '.rst', '.css', '.html']
def build():
subprocess.call('make html'.split())
#restart dev server
#subp... |
587239e313f5922c321afc989c167e716be901be30d7ac31a0655d2807dfeb29 | Python | 878 | 30 | #!/usr/bin/python3
import os
import numpy as np
from nibabel.testing import data_path
import nibabel as nib
import numpy as np
from scipy.ndimage.morphology import distance_transform_edt
import sys
source_ventricles = sys.argv[1]
source_cortex = sys.argv[2]
target = sys.argv[3]
ventricles_filename = os.path.join(dat... |
8729cf96737e1dfc3641f9390cf660ceb908a3e1818c58c020e795143a8f261b | Python | 878 | 29 | import torch
from torch.utils.data import Dataset
class BotDataset(Dataset):
def __init__(self, name):
self.name = name
# different features dataset
# self.cat_features = torch.load(path + "cat_properties_tensor.pt")
# self.prop_features = torch.load(path + "num_properties_... |
c5e931b9a1f0a58e1fbf14777d31d3e2d1c48881805e7a91011510c36c4c28dc | Python | 878 | 26 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['filtering.zip'])
tmp_dir = tempfile.Te... |
75ef627a1e29054b93361e474e235d46959985701a49f368dd1d4534cb7618e1 | Python | 879 | 23 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
def adjust_bboxes_to_image_border(boxes, image_shape, threshold=20):
"""Adjust bounding boxes to stick to image border if they are within a certain threshold.
Args:
boxes (torch.Tensor): Bounding boxes with shape (N, 4) in xyxy forma... |
e6b342149922a7bf0539a88c6b8e7a3391100385d21953f03a29e546cf3a3f77 | Python | 879 | 37 | import sys
import matplotlib
import pandas as pd
import pkgutil
from io import StringIO
from .internals import *
# grab module
__pub = sys.modules['pubplot']
def set(style: str = 'default', encoding: str = 'utf-8', sep: str = ';'):
'''
'''
assert(type(style) is str) or critical(ref = 'pubplot::styles... |
ead3973eb3913e7cdcdef066f67b3bb0548983759e896d29ed34d773ccad2a83 | Python | 880 | 16 | from testsetclass import TestsetClass
class AL2X6(TestsetClass):
def __init__(self):
self.weak = 1.0
self.molecules = ['alf3', 'al2me4', 'al2me5', 'alh3', 'al2f6', 'al2me6', 'al2cl6', 'alme3', 'alcl3', 'al2h6', 'alme2']
self.exp_values = {'0': 38.5, '1': 51.6, '2': 32.5, '3': 38.4, '4': 31... |
7090e21a36cf8a59d9ab509ee5428206c0cfb4903e77a13c5a7f29c2b8407fa3 | Python | 881 | 33 | """Convert a surface to a triangular mesh."""
import SVMTK as svm
from pathlib import Path
if __name__ == "__main__":
print("Start ",__file__)
outdir = Path("results")
outdir.mkdir(exist_ok=True)
sphere = svm.Surface()
# Surface mesh edge length:
edge_length = 0.2
# Sphere center c... |
829089dab314641f944c391f2bda549e7538443217616a617269faa47d576378 | Python | 881 | 33 | """
Reads in COM3D pickle file, takes median across camera pairs, and saves the result
into a target Label3D file for access w/ dannce.
**This is included for backwards compatibility. dannce v1.0.0 and later will not
require this conversion**
Usage: python COMmat_to_Label3D.py [path_to_com.mat_file] [... |
e7914bc5e6f26fe95f615ab05ec514f002ce741211ae3c2020f1744ad2253bea | Python | 881 | 22 | # -*- coding: utf-8 -*-
# genbed: A Python toolbox for generative embedding based classification
# Copyright 2019 Sam Harrison
# Translational Neuromodeling Unit, University of Zurich & ETH Zurich
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public L... |
03d8fb83547d822ceac873c96e5eceb96a6af7e562a9f9a4ed288322b54a0ff6 | Python | 882 | 32 | # -----------------------------------------------------------------------------
# Copyright © 2009- The Spyder Development Team
#
# Licensed under the terms of the MIT License
# (see LICENSE.txt for details)
# -----------------------------------------------------------------------------
"""Provides QtOpenGLWidgets cla... |
1cfadaabe2824a0177e64d7795d92545661d89fb4ee230ee610f726e8028e377 | Python | 882 | 33 | # Generated by Django 4.2.26 on 2026-04-29 15:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("engine", "0102_add_task_media_type"),
]
operations = [
migrations.AlterField(
model_name="data",
name="compressed_c... |
222cf4329f7047bfdf6eb8119b55e4f63a6a5c01e8d9be19f197fedfd6c9ace3 | Python | 883 | 33 | #!/usr/bin/env python3
import arbor as A
from arbor import units as U
import matplotlib.pyplot as plt
# Create a single segment morphology
tree = A.segment_tree()
tree.append(A.mnpos, (-3, 0, 0, 3), (3, 0, 0, 3), tag=1)
# Create (almost empty) decor
decor = (
A.decor()
.paint("(all)", A.density("hh03"))
... |
3e53c87e210037cfd1ef59d2b53e9805355907fa6ecf87cbacbaba531951ffd4 | Python | 883 | 34 | import pandas as pd
import numpy as np
from itertools import product
import random
import os
def four_in_row(sequence):
for i in range(len(sequence)-4):
if len(np.unique(sequence[i:i+4])) == 1:
return True
return False
df = {}
modalities = ['dot', 'digit', 'word']
combos = list(product... |
70f13b02b5087662a69b7aa4700120912d1e55421cd53b28261b345c5a170100 | Python | 883 | 33 | #!/usr/bin/env python3
import arbor as A
from arbor import units as U
import matplotlib.pyplot as plt
# Create a single segment morphology
tree = A.segment_tree()
tree.append(A.mnpos, (-3, 0, 0, 3), (3, 0, 0, 3), tag=1)
# Create (almost empty) decor
decor = (
A.decor()
.paint("(all)", A.density("hh06"))
... |
7c0e003745b194bc1d20c3f032c86238ee5bb587be025f5a3be374ba80b55466 | Python | 883 | 33 | #!/usr/bin/env python3
import arbor as A
from arbor import units as U
import matplotlib.pyplot as plt
# Create a single segment morphology
tree = A.segment_tree()
tree.append(A.mnpos, (-3, 0, 0, 3), (3, 0, 0, 3), tag=1)
# Create (almost empty) decor
decor = (
A.decor()
.paint("(all)", A.density("hh04"))
... |
a3c42470a65d66ff6e5ae1596c12d7ee857be46cea9e4846a79c40e74f4b6469 | Python | 883 | 33 | #!/usr/bin/env python3
import arbor as A
from arbor import units as U
import matplotlib.pyplot as plt
# Create a single segment morphology
tree = A.segment_tree()
tree.append(A.mnpos, (-3, 0, 0, 3), (3, 0, 0, 3), tag=1)
# Create (almost empty) decor
decor = (
A.decor()
.paint("(all)", A.density("hh05"))
... |
e5fa8e8314f9e1b55f81b95232033e3288c9a75155fb3c8af8e5cb259a15841a | Python | 883 | 32 | def in_notebook() -> bool:
"""
Checks whether code is executed within a jupyter notebook
"""
try:
from IPython import get_ipython
if "IPKernelApp" not in get_ipython().config: # pragma: no cover
return False # Not in jupyter notebook
except ImportError:
return ... |
46b911931207b519150f217262de8c098a3ae1ecb4a448f7dd7ae0c3021e6fdf | Python | 884 | 18 | from brainscore_vision import benchmark_registry
# neural predictivity
from .benchmark import DicarloMajajHong2015V4PLS, DicarloMajajHong2015ITPLS
benchmark_registry['MajajHong2015.V4-pls'] = DicarloMajajHong2015V4PLS
benchmark_registry['MajajHong2015.IT-pls'] = DicarloMajajHong2015ITPLS
# public
from .benchmark imp... |
47d19ac6bbc9eafe00c0fa31c5a423f2c3f16d09f4f8927445e6ccdbea23cb8f | Python | 884 | 34 | import pytest
from qtpy import (
PYQT5,
PYQT6,
PYQT_VERSION,
PYSIDE2,
PYSIDE6,
PYSIDE_VERSION,
_parse_version,
)
from tests.utils import pytest_importorskip
@pytest.mark.skipif(
not (
(PYQT6 and _parse_version(PYQT_VERSION) >= _parse_version("6.2"))
or (
PY... |
5f10ecb24a60f74de93e0171cd9af56a383b6e6774fe3d4052e264b5e47b3b34 | Python | 884 | 30 | from zigzag.classes.io.onnx.parser import Parser
from zigzag.classes.workload.dummy_node import DummyNode
class DefaultNodeParser(Parser):
"""Parse an ONNX node into a DummyNode."""
def __init__(self, node_id, node, nodes_outputs) -> None:
super().__init__(node_id, node, nodes_outputs, mapping=None, ... |
802b6e490b5b628c6cf5b16dfc61ddff33c919947083c6bf302cedd7f93a8d15 | Python | 884 | 27 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['tractometry.zip'])
tmp_dir = tempfile.... |
827b201f7ff8fbc4b6e0bf95af454d5951aec0f9ff7daf008bfbeb8808d22a67 | Python | 884 | 26 | import pandas as pd
import numpy as np
#age_set = pd.read_csv("../results/TMS_matrices/tabula_muris_senis.csv", sep="\t")
age_set = pd.read_csv(snakemake.input["age_set"], sep="\t")
#harmonized_set = pd.read_csv("../results/TMS_matrices/harmonized_metadata.csv", sep=",")
print(age_set.head())
print(age_set.shape)
pri... |
de6014b1fc4bc634e9ee061824e4a0e24bbc1e31596ba6f4af515ac8159a6c2c | Python | 884 | 22 | import torch
import torch.nn as nn
from models import *
class Net(nn.Module):
def __init__(self, my_pretrained_classifier, bottle_neck, fc_layer_num, prob_drop, context_dim, feature_num=512):
super(Net, self).__init__()
self.pretrained_clf = my_pretrained_classifier
fc_layer = [nn.L... |
c5bf350b96f2ce272e543aee8a8210440fc7ddab72eee51ddb1e4873983003c4 | Python | 885 | 25 | #!/usr/local/bin/python3
from pipeline import experiment, reso, meso, fuse, stack, pupil, treadmill, posture
from stimulus import stimulus
from stimline import tune
import time
import logging
import datajoint as dj
## database logging code
logging.basicConfig(level=logging.ERROR)
logging.getLogger('datajoint.connect... |
507e1a4ecc68b0d3429bd3371fd42c92adcac3593f1ae8baf411dfc450aa485e | Python | 887 | 28 | import nibabel as nb
import numpy as np
colFile = '/home/sebastian/Desktop/testRelativeResolution/sub-06_rim_columns1000.nii.gz'
voxelIDsFile = '/home/sebastian/Desktop/testRelativeResolution/sub-06_ses-001_task-restBA3b_run-001_T1w_voxelIDs_scaled.nii'
colArr = nb.load(colFile).get_fdata()
voxelIDsArr = nb.load(vox... |
ad80f4f66e2879ae90b08ec9b07ab6ed7913dd2b0ff19d354d3a2a43acb9f34c | Python | 887 | 25 | """Computational frameworks for fitting Models.
To include: SciPy (default), TensorFlow, ... (others)
NOTE: There are no public API imports here so that backend dependencies are
only imported if used. For example, users don't need to install TensorFlow
unless they want to fit models using `Model.fit(..., ... |
bfc3c936575bed96802d41ce51ccba4f625ec387a55b7c8749eb7773969b5c70 | Python | 887 | 16 | # Copyright (c) 2022, Kwanhyung Lee. All rights reserved.
#
# Licensed under the MIT License;
# you may not use this file except in compliance with the License.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT W... |
3363e6030817c6af7a7450fa97bddfed359d1a2852d9d4abfc00483826dea007 | Python | 888 | 32 | inch = 25.4
col1Width = 87 / inch
__colors = [
(214, 39, 40), (255, 152, 150), #redish
(31, 119, 180), (174, 199, 232), #blueish
(44, 160, 44), (152, 223, 138), #greenish
(148, 103, 189), (197, 176, 213), #purple
(255, 127, 14), (255, 187, 120), #orangish
(140, ... |
a075116eb35740d617602ff3ab5f2e1d7b0134ec99f2b8ba5e7669c704c2f6e5 | Python | 888 | 33 | #!/usr/bin/env python3
# imports
import argparse
from ase import Atoms
from ase.visualize import view
from ase.io import read, write
from ase.calculators.mopac import MOPAC
from ase.optimize import *
from ase import units
from ase.md.velocitydistribution import MaxwellBoltzmannDistribution
from ase.md.langevin import ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.