sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
721304249457a9f13af8ae2fad5b3376bddcdf7f0484c6728b443d204243de9d | Python | 1,403 | 42 | from typing import List
import numpy as np
import torch
from torch import Tensor
import torch_geometric.typing
def lexsort(
keys: List[Tensor],
dim: int = -1,
descending: bool = False,
) -> Tensor:
r"""Performs an indirect stable sort using a sequence of keys.
Given multiple sorting keys, retur... |
7e11d2e5808d12e3185f688fca04ad2e745562ca87b502842f2ed9e4022d81c7 | Python | 1,403 | 33 | from .libs import *
from .func import CNN_net_fixed, CNN_net_flex, dense_post_concat
# Model 3 ---------------------------------------------------------------------------------------------------------------------
class tuner(kt.HyperModel):
def __init__(self, marker_n, ev_n, tune = False):
self.marker_n = ... |
afa7fad6886172f8d3c995363179fc2160361b571f6424a686566b6a382a2aa1 | Python | 1,403 | 31 | """
Copyright 1999 Illinois Institute of Technology
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publis... |
f4587ea6ce9c8419771f41870e08d811878c0c8acef44fae5827a951ea5cb3cc | Python | 1,403 | 59 | #!/usr/bin/env python3
import argparse
import numpy as np
from ase.io import read, write
from KerNNCalculator.KerNNCalculator import *
import argparse
from os.path import splitext
from ase.vibrations import Vibrations
'''
Usage: python ase_vibrations.py -i structure.xyz
'''
#parse command line arguments
parser = ar... |
bbadfa92991ae1beef08b136fea85df44c18ec8912426c181c96d30cf9dbea6b | Python | 1,404 | 39 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images
from .load_model import *
# This is... |
f43abf45a5c19e37849e8c0eadb3f2e0c2f460899e3d38a8d28b0c76e5c59510 | Python | 1,404 | 21 | from testsetclass import TestsetClass
class HEAVYSB11(TestsetClass):
def __init__(self):
self.weak = 1.0
self.molecules = ['asme2', 'snme3', 'teme', 'h2se2', 'p2me4', 'pme2', 'ge2h6', 'br2', 'sh', 'as2me4', 'sbme2', 'pbme3', 'te2me2', 'sn2me6', 'pb2me6', 'br', 'sb2me4', 'h2s2', 'seh', 'cl', 'cl2',... |
11eee144cb1222ae8ed70357dc9dac92874f58164f8ee18f52a52a81c67e027f | Python | 1,405 | 37 | #!/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=['others.zip', 'commit_amico.zip'])
tmp_... |
253d8de9b034d0ca4c15766290c3099901d0977c5755c80a91bc13b71d6a517b | Python | 1,405 | 36 | #!/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... |
2e64232ba1d7eee0dc9c80ae6f1ff2fddfc0b09427d157baf98f8d6366452070 | Python | 1,406 | 37 | #!/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=['connectivity.zip'])
tmp_dir = tempfile... |
8931c0b471bee7a926c9b88ea05a649a6c6236b7cbbcd883b79614dfc0fdc123 | Python | 1,406 | 47 | # Copyright (c) OpenMMLab. All rights reserved.
from torch.utils.data.dataset import ConcatDataset as _ConcatDataset
from .builder import DATASETS
# TODO: may need change
@DATASETS.register_module()
class ConcatDataset(_ConcatDataset):
"""A wrapper of concatenated dataset.
Same as :obj:`torch.utils.data.data... |
df51f65cdd58174df5f882a0ae244369f0633be52f8daecc654b596d7d015255 | Python | 1,406 | 32 | import os,sys
import argparse
from chinn.models import PartialDeepSeaModel, NNClassifier
from chinn import train
import torch
def get_args():
parser = argparse.ArgumentParser(description="Train distance matched models")
parser.add_argument('data_name', help='The prefix of the data (without _[train|valid|test]... |
3c39b5adbce68af4223ae9c8a6eb85fd35180b1f73a4d298391f07aedb23a1af | Python | 1,407 | 33 | # /------------------------------------------------------------------------------+
# | 22-AUG-2022 |
# | Copyright (c) Bone Imaging Laboratory |
# | All rights reserved ... |
67cc60d4d0f5409ad679b00d579daee0c319412b796d082800d5bcb513a8a71c | Python | 1,407 | 43 | # This file is part of connectome-manipulator.
#
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2024 Blue Brain Project/EPFL
import numpy as np
import os
import pandas as pd
import pytest
from bluepysnap import Circuit
from utils import TEST_DATA_DIR
from connectome_manipulator.connectome_manipulation.manipul... |
6dfad77b5584bb4f862448037645ec81f873f5cbe1c681b9ebcfe3b463b36dfe | Python | 1,407 | 47 | import numpy as np
import scipy.interpolate
# Metadata for the Mixed sequence
metadata = {"TR_ir": 8350.0, "TR_se": 11000.0, "TI": 2650.0, "TE": 700.0}
def compute_se_signal(T1, SNR=20):
M0 = 1 # will cancel out
TR = metadata["TR_se"] - 2 * metadata["TE"]
se = M0 * (1.0 - np.exp(-TR / T1))
max_se = ... |
df8fb49453a55fe25acd7f95a40526180d75b0fff81c90a9da7b145f2cd77bde | Python | 1,407 | 48 | # This file is part of Zennit
# Copyright (C) 2019-2021 Christopher J. Anders
#
# zennit/layer.py
#
# Zennit is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your ... |
f1a0c52ded08eb9bc14f9af06e6fb9e8de3721b464be1a95351fa6fae7654cbb | Python | 1,407 | 54 | import matplotlib.pyplot as plt
import pandas as pd
import os
cases = 'Abel_ref1'
# plot for the arterial system
models = 'arterial'
elements = ['A5','A1','A8','A46','A48']
title = ['Carotid','Aorta','Radial','Femoral','Anetrior Tibial']
start = [0,1,1,1,1,0]
mmHg_to_Pa = 133.3616
T = 2000
cm = 1/2.54
#fig, axs = ... |
00d4a008f73c23462a4a9c147ba4b460ffab1a49b39206277838c149e2219cd4 | Python | 1,408 | 34 | from tqdm import tqdm
import torch
import h5py
from pathlib import Path
import argparse
from bce.antigen.antigen import AntigenChain
from bce.utils.loading import load_epitopes_csv
from bce.data.data import create_datasets
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--... |
ea5861422699205a39249ac4abd71425b47e9b73207668ac2bdc8d6ab2ac8ccf | Python | 1,408 | 41 | import io
import os
import sys
import time
import zipfile
from pathlib import Path
import requests
def download_url_and_unpack(url, config_dir):
import http.client
# helps to solve incomplete read erros
# https://stackoverflow.com/questions/37816596/restrict-request-to-only-ask-for-http-1-0-to-prevent-ch... |
fc673d3e65e3bdc03d18541ba48e99783f97ed0f71f63f24ba2d8b2024a2c356 | Python | 1,408 | 45 | import os
import glob
import numpy as np
from pick import pick
import matplotlib.pyplot as plt
from nicety.conf import get_conf
def plot_signals(conf, basename):
basename = ".".join(basename.split(".")[:-1])
fname = os.path.join(conf.output_path, f"{basename}-final_signals.npz")
signals = np.load(fname, ... |
d147e3577a38befb76d8bd59fe95ddf28e2631b627004e2427da6b25e8b6a8ac | Python | 1,409 | 48 | import os
import os.path as osp
import torch
import numpy as np
import scipy
import pandas as pd
import argparse
import os
import torch_geometric.transforms as T
parser = argparse.ArgumentParser(description='display graph features and summary.')
parser.add_argument('-ds','--dataset',help='Specify the dataset you want ... |
f0615f3aedf037e26bc4d23e9375d446c470b53b8ad3de381c5623e7060415a1 | Python | 1,409 | 50 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from __future__ import annotations
from typing import TYPE_CHECKING
from django.db.models import Model
from cvat.apps.engine.rq import (
BaseRQMeta,
ImmutableRQMetaAttribute,
MutableRQMetaAttribute,
RQJobMetaField,
)
if TYPE_CHECK... |
f6a7c80481555cda47e86380e4fcae239097d0a126f3a645711427bf87f6c236 | Python | 1,409 | 42 | # encoding : utf-8
"""This module implements functionailty for loading Matlab .mat files"""
import scipy.io
def insert_into_namespace(name, value, name_space=None):
if name_space is None:
name_space = globals()
name_space[name] = value
# mat = scipy.io.loadmat("simplified (Newton, 2015-03-11_15-09-... |
5dcde4360cdd0f8e0a86130c541e0ffee621440afdde6e8a7bccd6e0ee7069df | Python | 1,410 | 37 | #!/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=['tracking.zip'])
tmp_dir = tempfile.Tem... |
a0a3d4b17ad573782090b63226884945dddd7d058a42b9c35211df79c6e3d253 | Python | 1,410 | 38 | import numpy as np
from sklearn.utils import resample
def bootstrap_ci(data, ci=95, n_bootstrap=1000):
"""
Compute the mean and confidence interval (CI) of input data using bootstrapping.
Parameters
----------
data : array-like, shape (n_samples, n_features)
Input data array where rows re... |
c9051669e6095360ff8a5950257fb9b0c6f3f30f14ca00367e8e090932b427d5 | Python | 1,410 | 32 | from typing import Union, List, Tuple
import torch
from batchgeneratorsv2.transforms.base.basic_transform import BasicTransform
class MoveSegAsOneHotToDataTransform(BasicTransform):
def __init__(self, source_channel_idx: int, all_labels: Union[Tuple[int, ...], List[int]],
remove_channel_from_so... |
559793cff4326623a7805d87d16896f78880042e7c77ea8ed47db6b96a39ec3b | Python | 1,411 | 50 | from pathlib import Path
import dask.array as da
import numpy as np
from distributed import Client, LocalCluster
from sklearn.datasets import load_svmlight_file
import lightgbm as lgb
if __name__ == "__main__":
print("loading data")
rank_example_dir = Path(__file__).absolute().parents[2] / "lambdarank"
... |
14fb3e080722dc65a9e5a23577021928a0c3f914b7d3134d45bb06caa99f48c5 | Python | 1,413 | 36 | import pyvisa as visa
import pyvisascope
import multitimer
import time
import yaml
import logging
visa.log_to_screen('INFO')
logger = logging.getLogger('pyvisa')
log2file = logging.FileHandler('experiment.log')
logger.addHandler(log2file)
def main():
# enter here the ID of your device. On windows, VISA you c... |
0f24ba85b2c99a772e4bead872c6d056f5e3346b1963e6c1cb55fb5ff3d97522 | Python | 1,415 | 56 | """ """
import SVMTK as svm
import numpy as np
from pathlib import Path
if __name__ == "__main__":
print("Start ",__file__)
surf = svm.Surface();
outdir = Path("results")
outdir.mkdir(exist_ok=True)
cube = svm.Surface()
sphere = svm.Surface()
cylinder = svm.Surface()
# E... |
363865796d3c3e9d3f4efdc92037cdffbab16c43b6e265964104a6eca61b7a8f | Python | 1,415 | 39 | import numpy as np
import pandas as pd
import scanpy as sc
import anndata as ad
import os
os.chdir("/data/wuqinhua/phase/covid19/datasets")
adata = ad.read_h5ad('./pre_data/17_Wilk_2021/sce.h5ad')
csv_data = pd.read_csv('./pre_data/17_Wilk_2021/dict_wilk.csv')
sample_ids_to_keep = csv_data['GSE'].tolist()
adata.obs... |
3a3e5c13adf47f7f267dc38fe788ffcee56a93bb22a68181fbdbabe21051c12c | Python | 1,415 | 49 | from pathlib import Path
import hipsta
import os
def main():
hipsta_dir = Path(os.path.dirname(hipsta.__file__))
path = hipsta_dir / "computeCubeParam.py"
if not path.exists():
raise FileNotFoundError(f"computeCubeParam.py not found: {path}")
original_text = path.read_text()
text = origin... |
648bf7abfa4961e6f78c5ed20a15fa5711a348a091e039ae59364835bcba34a1 | Python | 1,415 | 48 | """Deprecated compatibility shim for OpenRouter model loading.
Construction now lives in ``chemgraph.models.endpoints.openrouter`` behind the
shared OpenAI-compatible protocol builder. Prefer
``chemgraph.models.loader.load_chat_model``.
``OPENROUTER_DEFAULT_MAX_TOKENS`` is re-exported for one release.
"""
from __fut... |
d146e9806d8790f53f6704bd6d5813c1bc73b323540c62acf3ce9c8bf7abe143 | Python | 1,415 | 62 | """ impyute: Data imputations library to preprocess datasets with missing dat
impyute.imputations.cs: Imputations on cross sectional data
impyute.imputations.ts: Imputations on time series data
impyute.deletion: Deletion type missing data handling
impyute.contrib: Volatile and experimental code
""... |
5ae50cddca96e522e00c6229c7b4a4955bc587d76c352ed3af843b7a98790967 | Python | 1,416 | 58 | #!/usr/bin/env python3
import argparse
import numpy as np
from ase.io import read, write
from KerNNCalculator.KerNNCalculator import *
import argparse
from os.path import splitext
from ase.vibrations import Vibrations
'''
Usage: python ase_vibrations.py -i structure.xyz
'''
#parse command line arguments
parser = ar... |
2231a842904bbed1970ce66d5197b2bc714af1a04fcf3fd1a59ac2bffbb03189 | Python | 1,417 | 43 | '''Test the logic for the function `ogo img resample`'''
import unittest
import subprocess
import shutil, tempfile
import SimpleITK as sitk
import os
class TestIsotropicResampling(unittest.TestCase):
'''Test the logic for the function `ogo img resample`'''
def setUp(self):
self.test_dir = tempfile.m... |
5f455e029be25e2de39cec2458bed3379d4abc88f547569c51b6849c8b7afd4c | Python | 1,417 | 52 | from skimage import io as skio
import sys
import getopt
from PIL import ImageFile
from PIL import Image
ImageFile.LOAD_TRUNCATED_IMAGES = True
Image.MAX_IMAGE_PIXELS = None
def image_blend_usage():
print("""
Usage : GEMtoolkit.py image_blend -i <input.png>
-s <ssdna.png>
... |
d5e6ca0ec85b952247f1c14e7dc88af3db35fee120e3916350ff162d0c4222ef | Python | 1,417 | 29 | import functools
import torchvision.models
import torch
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images
BIBTEX = """@article{geirhos2018imagenet,
title={ImageNet-trained CNNs are biased towards te... |
01f28d6c06ff5ab158d1d47f59778ebbd6cfd37a3c1d65e600a099d8b044d571 | Python | 1,418 | 43 | """
Custom Sphinx extension to convert type aliases in docstrings to proper cross-references.
This handles cases where Napoleon processes 'pd.DataFrame' as plain text.
"""
import re
from sphinx.application import Sphinx
def process_docstring(app, what, name, obj, options, lines):
"""
Process docstring lines ... |
2e0c27e9f99f3ebb3f19297a06d4f51cd16002427d9dbc78aaf764d43e3d9dde | Python | 1,418 | 50 | """
Demo the MSI task in ./msi_task.py.
Output will be a plot of the stimulus and desired response for
FLAGS.num_trials task trials.
Options: model_type = 'paral' or 'ortho' where paral is parallel (H1)
and ortho is orthogonal (H2) model.
"""
from absl import app
from absl import flags
from matplotlib import pyplot ... |
fec51fb1063b2cbe3dfc22c1156d0022b51e3e1c8baedac75a9c37c7a6c7e8e0 | Python | 1,418 | 46 | import argparse
import os
CURR_DIR = os.getcwd()
DATA_DIR = DIR = os.path.dirname(os.path.realpath(__file__))
# %%
parser = argparse.ArgumentParser(description='load NAViEPI data from Zenodo.')
parser.add_argument('--records', default='10474402', type=str,
help='doi records number on zenodo')
# ... |
43a0e6cfd3724c489003b6980291ca80ee7126702719f4f65aed722ab0c3449c | Python | 1,419 | 40 | # Copyright (C) 2021-2022 Intel Corporation
# Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import zipfile
from datumaro.components.dataset import Dataset
from cvat.apps.dataset_manager.bindings import (
GetCVATDataExtractor,
TaskData,
detect_dataset,
import_dm_annotations,
)
fro... |
b7ce1c212149465ea7a9c224c926a75a64e06bac0fc0445d56e13ce26d6ef8d5 | Python | 1,419 | 35 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
import torch
from ultralytics.models.yolo.detect import DetectionValidator
from ultralytics.utils import ops
__all__ = ["NASValidator"]
class NASValidator(DetectionValidator):
"""Ultralytics YOLO NAS Validator for object detection.
Extend... |
cfce64d93c8c0a3b6c90039e3453afd812f030341c177606c0975369c86f1181 | Python | 1,419 | 41 | from pathlib import Path
from typing import Optional, Tuple
import aicsimageio
from brainways.utils.image import ImageSizeHW, resize_image
from brainways.utils.io_utils.readers.base import ImageReader
class AicsImageIoReader(ImageReader):
def __init__(self, path: Path, scene: Optional[int]):
super().__i... |
1f6e00cdc05df04137b0c39bea54ab10dd680d767d902952d81ac592ff9d7ea1 | Python | 1,420 | 33 | #!/usr/bin/env python3
# Author: Francois Aguet
import argparse
import subprocess
from datetime import datetime
import os
parser = argparse.ArgumentParser(description='Wrapper for RNA-SeQC 2')
parser.add_argument('genes_gtf', type=str, help='Gene annotation GTF')
parser.add_argument('bam_file', type=str, help='BAM fi... |
d612ac53e03bd44a5a50646b969d09a0bcff8ae6de68c524e19c53529667af3e | Python | 1,420 | 38 | from torch import nn
class MLPBlock(nn.Module):
"""
A basic Multi-Layer Perceptron (MLP) block with one fully connected layer.
Args:
in_features (int): The number of input features.
output_size (int): The number of output features.
bias (boolean): Add bias to the linear layer
... |
ee73bb30df145ae6e4659065c99668638a7274705a47b93c66bb772646d10837 | Python | 1,420 | 53 | """LangChain ``@tool`` wrapper for gRASPA simulations.
Delegates to the pure-Python implementation in
:mod:`chemgraph.tools.graspa_core`.
"""
from __future__ import annotations
from langchain_core.tools import tool
from chemgraph.schemas.graspa_schema import graspa_input_schema
from chemgraph.tools.graspa_core impo... |
f7c7d78128ebd1406ab1de95f48713a415b7e3a9ae546618a33089ff2827030d | Python | 1,420 | 33 | from curvature_calculation import from_ply_workflow, new_workflow, extract_curvatures_after_new_workflow
import time
from sys import argv
t_begin = time.time()
fold = r"/gpfs/group/grotjahn/bbarad/Surface_analysis/" # output will be also written there
index = int(argv[1])
filelist = ["TF1_IMM","TF1_OMM","TF2_IMM","TF... |
86e9423d405fd80d51abbb49b9d789c2b2e9e6565d6e38068a04828f516662de | Python | 1,421 | 54 | import argparse
import logging
import ants
from pyment.preprocessing import skullstrip_with_antspynet
logging.basicConfig(
format='%(asctime)s - %(levelname)s - %(name)s: %(message)s',
level=logging.INFO,
)
logger = logging.getLogger(__name__)
def preprocess_with_antspynet(input: str, output: str) -> None:... |
8d1dccf9b8ea5c578612400ed7178697a39275a86e079619f5c0bd91a9fc8c50 | Python | 1,421 | 34 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'mosaic.ui'
#
# Created by: PyQt5 UI code generator 5.7
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_GroupBox(object):
def setupUi(self, GroupBox):
GroupBox.setObje... |
d720597fdc91ef9d3043c3500b60701f9dc7437ca000e7a98265a2a66272ef6c | Python | 1,421 | 45 | import numpy as np
from pyrosetta import init, pose_from_pdb
init(extra_options="-constant_seed -mute all -read_only_ATOM_entries")
def get_distance_map(pdb_path):
pose = pose_from_pdb(str(pdb_path))
coordinates = []
for index in range(1, pose.size() + 1):
residue = pose.residue(index... |
05d2b3f44c8d36c6b0482a7da096a82a613828d0d0d82819269a6a46aa280097 | Python | 1,422 | 44 | import numpy as np
import torch
def worker_seeding(wid):
"""
When using numpy random inside multiple workers in the data loader, they all produce the same random numbers,
as the seed is shared. As a solution, the worker init function can be overwritten. This solution uses the torch
initial_seed, which... |
35230133c60444982090a1c2dbc5833210251aa0f023a9e8aa1b6750b5308649 | Python | 1,422 | 59 | #!/usr/bin/env python3
import argparse
import numpy as np
from ase.io import read, write
from KerNNCalculator.KerNNCalculator import *
import argparse
from os.path import splitext
from ase.vibrations import Vibrations
'''
Usage: python ase_vibrations.py -i structure.xyz
'''
#parse command line arguments
parser = ar... |
63c1a3f7e13199716047d8130bcc45d8e1d537a0648bbc7e4054fd0db4c21def | Python | 1,423 | 52 | """# Chaining functions together
This example demonstrates chaining multiple functions together.
"""
from magicgui import magicgui, widgets
@magicgui(auto_call=True)
def func_a(x: int = 64, y: int = 64):
"""Callable function A."""
print("calling func_a")
return x + y
@magicgui(auto_call=True, input={"... |
69f359e14407e3711c484bedd268121c6a88037e7cef68b65949c1794d8841bc | Python | 1,423 | 39 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images
from .load_model import *
# This is... |
6c79575ae8a9837ec692750ccf247fbe67312071f63aaf5d58adfb26c01533fc | Python | 1,423 | 41 | import tempfile
import zipfile
import shutil
import os
from typing import Tuple
def update_xlsx_datetime(xlsx_path: str, datetime: Tuple[int, int, int, int,
int, int]) -> None:
"""Update xlsx file date time, in order to reproduce identically.
Args:
... |
ae1c6e00fbfd6ca40cf9b4eb84367b8bbe9aa1568e6fdc1b5543e8e479e94a4c | Python | 1,423 | 43 | #%%
import numpy as np
import matplotlib.pyplot as plt
# Load the saved numpy arrays
inputs = np.load('/data1/home/ict08/skinseg/GeoSeg/geoseg/models/results/isic_unet_inputs.npy')
predictions = np.load('/data1/home/ict08/skinseg/GeoSeg/geoseg/models/results/isic_unet_predictions.npy')
ground_truths = np.load('/data1/... |
e00cb0d8a075303f0cc179425c666b789c49dd68569dffc725e338bbb70f9650 | Python | 1,423 | 41 | #!/usr/bin/env python3
import argparse
import itertools
import jinja2
import os
import re
import sys
def semver(v):
if not re.fullmatch(r'\d+\.\d+\.\d+', v):
raise ValueError
return v
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--version', required=True,... |
0d0975301e37b05d9de77dea8d5d368bbd2deda81eecd69f869217b86b4c88d2 | Python | 1,425 | 47 | #!/usr/bin/env python
import subprocess
import threading
import sys
import time
import os
import argparse
import glob
parser = argparse.ArgumentParser(description='mrsFAST CNV pipeline')
parser.add_argument('-o',help="Output file prefix or folder")
parser.add_argument('input',help="File path to input fastq file")
par... |
626de5908fbe3d571c0194762e61a77335f2599626406fadb37894130629d49a | Python | 1,425 | 49 | import sys
import random
# percent = 0.5
file_path = 'conll_03_vi.train_bioes'
percent = 0.8
file_path_out = 'conll_03_vietnamese.train_bioes'.format(percent)
file_out = open(file_path_out, 'w', encoding='utf-8')
with open(file_path, 'r', encoding='utf-8') as file:
lines = file.readlines()
all_samples = []
... |
b0931ee3288111cd41b2c49de8870ffa2a40d955ce8c3a5e4f0e607ee06819c3 | Python | 1,425 | 43 | import torch
import torch.nn as nn
class WindTurbineModel(nn.Module):
def __init__(self, n_metadata, n_classes=3):
super(WindTurbineModel, self).__init__()
self.conv1 = nn.Conv2d(1, 16, kernel_size=3, stride=1, padding=1)
self.bn1 = nn.BatchNorm2d(16)
self.conv2 = nn.Conv2d(16, 32,... |
2b905100dac0a576b67d0079076d3dac4061ab4be02c4ec6558dae3048441dbb | Python | 1,426 | 47 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sb
import warnings; warnings.simplefilter('ignore')
from scipy.stats import mstats, kstest, ttest_ind, fisher_exact
import csv
import math
from scipy.stats import pearsonr
from scipy.spatial.distance import pdist, squaref... |
3c01541ae58d0e3145c20f4fb451b0e941dd1c2f0b40994c4b0273cf6ff35927 | Python | 1,426 | 39 | import numpy as np
import pytest
import nelpy as nel
def test_sosfiltfilt_numpy_lowpass():
t = np.linspace(0, 1, 1000, endpoint=False)
x = np.sin(2 * np.pi * 5 * t) + 0.5 * np.random.randn(t.size)
y = nel.filtering.sosfiltfilt(x, fs=1000, fl=None, fh=10)
assert y.shape == x.shape
assert isinstanc... |
dfaf817c5baf115f70ef945f2479a01e206fad769ff965dda1904b0fad9bebd0 | Python | 1,426 | 46 | """
This module is an example of a barebones QWidget plugin for napari
It implements the Widget specification.
see: https://napari.org/stable/plugins/guides.html?#widgets
Replace code below according to your needs.
"""
from typing import TYPE_CHECKING
from magicgui import magic_factory
from qtpy.QtWidgets... |
09ad569be4d2c779445c732f1d66c376b884b5fdcc9647851b4d167a4a9f98be | Python | 1,428 | 44 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2023/6/2 16:50
# @Author : SONG-LE
# @知乎 : https://www.zhihu.com/people/xiao-xue-sheng-ye-xiang-xie-shu
import xlwt
import os
# 判断数据目录是否存在
fdir='Data'
if not os.path.isdir(fdir):os.mkdir(fdir)
#保存数据
def data_save(data,name):
'''
data,[dict{<str>:<lsit>}],... |
18d2aad3683578e01e3d8a2a9c91cc016aac09ea15dd866fe785dca61f7cb1e7 | Python | 1,428 | 52 | import matplotlib.pyplot as plt
import pandas as pd
cases = 'Abel_ref2'
# plot for the arterial system
models = 'arterial'
elements = ['A16','A1','A8','A52','A49']
title = ['Carotid','Aorta','Radial','Femoral','Anetrior Tibial']
start = [0,1,1,1,1,0]
mmHg_to_Pa = 133.3616
cm = 1/2.54
#fig, axs = plt.subplots(6, 4,... |
47d8d29c04c9cd10019bb3be430bb9e68fb353d31033de50b2e37ecb04db9640 | Python | 1,428 | 47 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import textwrap
from rest_framework import serializers
from cvat.apps.consensus import models
from cvat.apps.engine import field_validation
class ConsensusMergeCreateSerializer(serializers.Serializer):
task_id = serializers.IntegerField(write... |
7aad2a2ac24432aca02385fdf2258892ea4d42a95745f47b780b066744e5a1d9 | Python | 1,428 | 50 | #!/usr/bin/env python
"""
These are for testing HAL's handling of errors.
Hazen 03/18
"""
import time
import storm_control.hal4000.halLib.halMessage as halMessage
import storm_control.hal4000.halLib.halModule as halModule
class TestSimpleError(halModule.HalModule):
def __init__(self, module_params = None, qt_s... |
9dca9bfa87ca79442fd270344fdf1c048516b5117b4696ba4ace313763732dea | Python | 1,428 | 49 | # -*- coding: utf-8 -*-
"""
Make retinotopy movie
The purpose of the following script is to make a movie to illustrate the
travelling waves on a flattened patch.
"""
# python standard library inputs
import os
import glob
# external inputs
import natsort
# local inputs
from fmri_tools.img.get_retinotopy_images impo... |
e15a6f45f1b79ffa3c016c922a5649901b11d39c1a0b2cfac83fc11ffdd0a085 | Python | 1,428 | 28 | from pydantic import BaseModel, Field
class GRASPAInputSchema(BaseModel):
output_path: str = Field(
description="Absolute or relative path to the directory where gRASPA output files will be stored. If not provided, the output will be stored in the current working directory."
)
cif_path: str = Fiel... |
875f584d6f01775deaf43474ff988430a5d8c56f6f1161dd6f152ab8678a02d5 | Python | 1,429 | 36 | import pyvisa as visa
import pyvisascope
import multitimer
import time
import yaml
import logging
visa.log_to_screen('INFO')
logger = logging.getLogger('pyvisa')
log2file = logging.FileHandler('experiment.log')
logger.addHandler(log2file)
def main():
# enter here the ID of your device. On windows, VISA you c... |
b790263ca646d18d375dedcbc4722fea2806b737f9a8000282884d9d4fee8eb5 | Python | 1,429 | 45 | from scipy.stats.qmc import Sobol, scale
import numpy as np
import pandas as pd
import os
# Set number of dimensions and samples
dim = 25
seednum = 42
n_samples = 65536 # Initial samples 2^16
output_file = "sobol_samples_Hab1_local.csv"
# Extract mean and sd of weights in the desired order
means = np.array([0.0657... |
d4049357bb103cea30d50f1a10469675b77fafc7106e13dba3bfeb866dae495e | Python | 1,429 | 60 | #!/usr/bin/env python3
import argparse
import numpy as np
from ase.io import read, write
from KerNNCalculator.KerNNCalculator import *
import argparse
from os.path import splitext
from ase.vibrations import Vibrations
'''
Usage: python ase_vibrations.py -i structure.xyz
'''
#parse command line arguments
parser = ar... |
b98ab2a36c6ef0031eee7bc0f4249e4c4aa4f5da5f04d06ed98fc4a95465e7ae | Python | 1,430 | 39 | #!/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... |
ef1944215245e33c224cb1ffb92ec1dd576759e43f9d488e6c75531758c10803 | Python | 1,430 | 54 | #!/usr/bin/env python
"""
Create a bed file listing all the divergent sites between two specific species
in a maf.
usage: %prog maf_file reference_species_name other_species_name
"""
import sys
import bx.align.maf
import bx.bitset
def main():
bitsets = {}
maf = sys.argv[1]
reference_sp, other_sp = sys.... |
2aa0d42449307a5ffca4987ee9e9d2b33fc6ddabee95afc69bf33764315ca809 | Python | 1,431 | 35 | import os
from sys import argv
from glob import glob
import pymeshlab as pm
import mrcfile
mrcfiles = glob("*_labels.mrc")
deldist = 3
for mrc in mrcfiles:
print(mrc)
with mrcfile.mmap(mrc, 'r', permissive=True) as file:
voxel_size = file.voxel_size.x
print(voxel_size)
ply_base = mrc[:-11]
... |
926d34300e13e6f6b0f9cd13031c0903e6b2d99a75af5688ae19ef454affedeb | Python | 1,431 | 44 | import os
from pathlib import Path
import numpy as np
import pytest
@pytest.fixture(autouse=True)
def restore_numpy_errstate():
old = np.seterr()
try:
yield
finally:
np.seterr(**old)
TEST_DIR = Path(__file__).parent
DATA_DIR = os.path.join(TEST_DIR, "data")
def load_data(type: str = "h... |
9681fba8a6f0c137c34d5c9299f692ced258e22977d4cb3a25b8c3ffde4ea5d6 | Python | 1,431 | 41 | import numpy as np
import matplotlib.pyplot as plt
from sklearn.decomposition import PCA
#Parameters
control_sample_size = 500
genome_size = 20000
causal_pos = 20
control_distribution = [0.10, 0.45, 0.45]
case_distribution = [0.90, 0.05, 0.05]
#Generate case and control mock genomes based on distributions
control_g... |
c6921c2bbfd4d81c8dee33bd0f8b4f80d9b9c72bab3beff04270e3250bf8bc6b | Python | 1,431 | 58 | import sys
import json
import click
import numpy as np
import tensorflow as tf
from mmsplice import MMSplice
from mmsplice.exon_dataloader import SeqSpliter
from mmsplice.utils import predict_deltaLogitPsi, predict_pathogenicity
@click.group()
def cli():
pass
@cli.command(name='run')
def run():
tf.get_lo... |
40a13bfd79f7cd67e59eb7ad2a1588d8e81f94ddda55c6c24ae3ee63ad476ffe | Python | 1,432 | 34 | import logging
from importlib import import_module
from brainscore_vision.model_helpers.activations import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images
from .cornet_s_helpers import cornet as cornet_ctr
from vonenet import get_model
from .cornet_s_helpers import ... |
566be8234e96ab46251fbb7760c63e769b8a8d3f1a604dd89f8a676996a6df44 | Python | 1,434 | 42 | import random
import pandas as pd
from sklearn.ensemble import RandomForestClassifier
import numpy as np
import json
from sklearn.metrics import accuracy_score, f1_score
from tqdm import tqdm
dataset = 'Twibot-22'
idx = json.load(open('tmp/{}/idx.json'.format(dataset)))
idx = {item: index for index, item in enumerate(... |
70db7dd5d75cfcf2acfc456877426b958e2522215f9cff8e37f33372a5b431fc | Python | 1,434 | 66 | import zlib
import gzip
class GzipLengthCalc:
"""
Efficient way to compute both,
len(gzip.compress(data1))
ane
len(gzip.compress(data1 + b" " + data2))
(and can be reused for multiple data2)
Usage: (all data in bytes)
g = GzipLengthCalc(data1)
n1 = g.length1
... |
c01d0f62a9e603a12d34e2248fbf0e3a9a5c1d3771cd9eb67836c5c6c063855e | Python | 1,434 | 41 | from __future__ import annotations
from pathlib import Path
import numpy as np
import pandas as pd
from subprocess import check_call
import sys
def write_subject(folder: Path, sid: str, r: float, cont: float, slope: float):
so = pd.DataFrame([{'Channel': 'EEG C3-LER__EEG C4-LER', 'vector_strength': r}])
so.... |
ca9ca958130f381fc745daf27343f545b7c2d529a1c06762d3f0e8422eebdb63 | Python | 1,434 | 46 | from langchain_ollama import ChatOllama
from chemgraph.models.supported_models import supported_ollama_models
def load_ollama_model(model_name: str, temperature: float) -> ChatOllama:
"""Load an Ollama chat model into LangChain.
This function loads a local Ollama model and configures it for use with
Lang... |
ef0ff8190e3a6d95f6b6e3b65e45533e0038c54bc76f5fab2750121f96c7fbc1 | Python | 1,434 | 40 | #!/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
fetch_data(get_testing_files_dict(), keys=['plot.zip'])
tmp_dir = tempfile.TemporaryDirectory()
def test_help_option(script_runner):
ret = scri... |
c53b298b1d1de07cec673c5fcad24867786e166a3dc485f8ba5b1bbf8213dcd1 | Python | 1,435 | 34 | # Sourced from https://github.com/fwillett/speechBCI/blob/main/NeuralDecoder/neuralDecoder/neuralSequenceDecoder.py
import tensorflow as tf
from scipy.ndimage import gaussian_filter1d
import numpy as np
@tf.function(experimental_relax_shapes=True)
def gaussSmooth(inputs, kernelSD=2, padding='SAME'):
"""
Applie... |
041abaa02825dda4f09a87d72171241920c414960e8a07064a746fe9085b9ecb | Python | 1,436 | 47 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from collections.abc import Sequence
from typing import Any
from rest_framework import serializers
def require_one_of_fields(data: dict[str, Any], keys: Sequence[str]) -> None:
active_count = sum(key in data for key in keys)
if active_coun... |
34bfc4410e064e2abd940e954c1512ea5c58e7cf6800486a8ecfea6a65497161 | Python | 1,436 | 46 | import numpy as np
import pandas as pd
import scanpy as sc
import anndata as ad
import os
os.chdir("/data/wuqinhua/phase/covid19/datasets")
adata = ad.read_h5ad('./pre_data/19_Zhao_2021/seu_obj.h5ad')
adata
adata.obs["Sample"] = adata.obs['patient'].astype(str) + '_' + adata.obs['Sample'].astype(str)
adata.obs.rena... |
dcc1ecfcd98eec57ee5c046940c383cca3a24d8dfde314ad16cd2160095635cd | Python | 1,436 | 47 | import numpy as np
import torch
# define a function to derive the gex from the sphex
def calc_gex(sphex):
"""
Calculates the gene expression matrix from the spherical
"""
# setup the gex
n_genes = sphex.shape[1]+1
gex = torch.from_numpy(np.zeros((sphex.shape[0], n_genes)).astype('float32'))
... |
a26e1511d171e163f513baee4cfb8b3ea4232f7c73ec1739c4a6123afff4cd20 | Python | 1,437 | 42 | # Copyright (C) 2022 Intel Corporation
# Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import re
from http import HTTPStatus
from shared.utils.config import server_get
class TestCachePolicy:
@staticmethod
def _get_js_bundle_url(response):
match = re.search(r'<script.* src="(/ass... |
767daacfc371dcddfadc5e8170179a1a88cf4472b2303d5057351de4ad593ae6 | Python | 1,438 | 50 | #Lucas Sancéré -
import numpy as np
import yaml
from attrdictionary import AttrDict as attributedict
from histo_miner.evaluations import plot_conf_matrix, plot_conf_matrix_doublevalues
# Import parameters values from config file by generating a dict.
# The lists will be imported as tuples.
with open("./../../confi... |
b82838e0c13ec7e0c891aadb9590fb2f0756d4d25d0dabbe3a37f38e34f1987a | Python | 1,438 | 31 | import sys
sys.path.append('..')
import torch
from torch.nn import Module, Sequential, Linear, Dropout
from models.graph_models import GraphModel
from layers.conv import ConvBlock
class NDGraphModel(Module):
def __init__(self, conv_fn: ConvBlock, embed_size: int, hidden_size: int, out_channels: int,
... |
bd131daad090f144e9f45ed43154bb41c1bd1ef1aedd1281afd7c3a887c6f14e | Python | 1,438 | 32 | import numpy as np
from pytest import approx
from brainscore_core.supported_data_standards.brainio.assemblies import BehavioralAssembly
from brainscore_vision.benchmarks.imagenet import Imagenet2012
from brainscore_vision.model_interface import BrainModel
class TestImagenet2012:
def test_groundtruth(self):
... |
46ab56e75c9257da626a7af2285cd41a5863a040fcab33ae69ee00573e21d6b6 | Python | 1,439 | 55 | """This script provides an example of using custom backbone for training."""
import tensorflow as tf
from deepreg.registry import REGISTRY
from deepreg.train import train
@REGISTRY.register_loss(name="lp_norm")
class LPNorm(tf.keras.losses.Loss):
"""
L^p norm between y_true and y_pred, p = 1 or 2.
y_tru... |
128d1cf922daba81d38b69dbfb3aa0762b14f19673835df1092bf95b8bc1fea6 | Python | 1,440 | 37 | import pyvisa as visa
import pyvisascope
import multitimer
import time
import yaml
import logging
visa.log_to_screen('INFO')
logger = logging.getLogger('pyvisa')
log2file = logging.FileHandler('experiment.log')
logger.addHandler(log2file)
def main():
# enter here the ID of your device. On windows, VISA you c... |
0128fca1e0ef63f41429eab476e53dbcbb8cfc0ceaa1e0b03c51ff81f44bd750 | Python | 1,441 | 43 | #!/usr/bin/env python3
"""
=============================================================================
Austin Dibble
University of Glasgow
2026
neurofm/losses.py
Loss functions and metrics registry. These dicts are passed to
get_custom_objects() so TensorFlow can deserialise the model from
a saved .h5 file that was... |
0ddc06bb482f0d461fd65275170f1f9697484455da20fae2502f71fae8bfa219 | Python | 1,441 | 52 | # -*- coding: utf-8 -*-
"""
Created on Sun Mar 27 14:08:48 2022
@author: Artur Klepaczko
"""
import csv
from itertools import product
from pathlib import Path
from typing import Final
import numpy as np
from glcm_extractor import get_glcm_feature_vector
ROOT: Final[Path] = Path(R'D:\TexturesKidneys\NPY-T2')
data... |
a8625a4ac849650c858f59f21928ea23f00475c37ebbea69ba6dee350b49fdc3 | Python | 1,441 | 31 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import timm
import torch
from huggingface_hub import hf_hub_download
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_i... |
a8ac5a63a8d3cb775f3df22461d899eb6a062e6bcbc34aa900cdb53af30fb6af | Python | 1,441 | 50 | from __future__ import annotations
import json
import os
import re
from pathlib import Path
from pydantic import BaseModel
from pydantic import ConfigDict
from pydantic import Field
from chemgraph.academy.runtime.profiles import resolve_builtin_system_profile
class SystemProfile(BaseModel):
"""Site/runtime pat... |
20f9a5ef048ef91c3144ecbb22708347d48299ad419bbfc122b74ceed89d3016 | Python | 1,442 | 47 | '''VGG11/13/16/19 in Pytorch.'''
import torch
import torch.nn as nn
cfg = {
'VGG11': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
'VGG13': [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
'VGG16': [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 'M', 512, 512, 512... |
4487f5919c0f9213834f58f7f4ac70bf5954f78fa2e57863583608450e5465a6 | Python | 1,442 | 47 | # Copyright 2024 Google LLC
# 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
3785f63f6708a627712713c210ed84faaf25155fc02c797654d0446d98815d8c | Python | 1,443 | 59 | from pathlib import Path
import pandas as pd
from omegaconf import OmegaConf
def main():
base_path = Path("pred")
configs = []
for exp_path in base_path.iterdir():
if not exp_path.is_dir():
continue
try:
exp_cfg = OmegaConf.load(exp_path / "config.yaml")
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.