sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
306ba7e00c677269c2742afff4cb6986f4d1819cd5dfff7fa1b0f6e1182cccaa | Python | 4,307 | 120 | import os
from medperf import config
from medperf.entities.ca import CA
from medperf.entities.event import TrainingEvent
from medperf.exceptions import InvalidArgumentError, MedperfException
from medperf.entities.training_exp import TrainingExp
from medperf.entities.aggregator import Aggregator
from medperf.entities.cu... |
dbc41ef9324f00a6337b9834898932630e73977cbe21323bda8eddbb54d26538 | Python | 4,308 | 153 | import pytest
import base64
from medperf.tests.mocks.certificate import TestCertificate
from medperf.entities.encrypted_key import EncryptedKey
from medperf.exceptions import (
MedperfException,
PrivateContainerAccessError,
DecryptionError,
)
PATCH_EK = "medperf.entities.encrypted_key.{}"
# -------------... |
8563c04bfbcefd52673e441f8ab4d1539472a875137f3528baf3ebde6e21cdc5 | Python | 4,309 | 122 | import argparse
import os
import urllib.request
import nibabel as nib
import numpy as np
from brainbuilder.reconstruct import reconstruct
from brainbuilder.tests.generate_synthetic_data import generate_synthetic_data
def preprocess_input_data(input_path, output_path):
"""Preprocess the input data by downloading ... |
cc564b5a77e141fdc5b380722b9d922d295328149dae152e17ecc994fadeecd6 | Python | 4,311 | 143 | #!/usr/bin/env python
"""DocString"""
from __future__ import division
from builtins import range
from past.utils import old_div
from itertools import cycle
import matplotlib
import matplotlib.colors as mplcol
import matplotlib.pyplot as plt
import colorsys
import numpy
import collections
def adjust_spines(ax, spines... |
1b0cbf4cdd78e763d0cde7e27071565503d4b3d9e8d9d46f7ad56fe0ca23e0b4 | Python | 4,312 | 97 | import pandas as pd
import numpy as np
from scipy.spatial import Delaunay
import matplotlib.pyplot as plt
from matplotlib.tri import Triangulation
path = f'./data/spatial_8months-disease-replicate_1.csv'
df = pd.read_csv(path, skiprows=[1])
cell_type_num = sorted(df['top_level_cell_type'].unique())
#colors = ['b', 'g'... |
475275865cda4183676458a10a3d2394e1f108757ede65b3cb89435fa8f34983 | Python | 4,312 | 150 | from __future__ import annotations
import uuid
import webbrowser
from typing import Annotated
from uuid import UUID
import typer
from zndraw.schemas import (
CollectionResponse,
RoomCreate,
RoomCreateResponse,
RoomResponse,
)
from .connection import (
EXIT_CLIENT_ERROR,
EXIT_CONNECTION_ERROR... |
250494dc2990c0c2ad6593b2ea29d87ef3a8ac6828cb2a421b24441b6a6d5289 | Python | 4,315 | 81 | # This script loads weight matrices from file
# and then runs the network saving the simulation
from ast import parse
from contextlib import redirect_stderr
from surrogateParams import surrParams
import simLogger
import surrogateTraining
import weightAnalysis
import argparse
import matplotlib.pyplot as plt
from matpl... |
30b90afafaa21ad6a5e7aecd632c2f7ac3f6ca548b6a041ec75304d8c824fa82 | Python | 4,315 | 97 | import time
import itertools
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import rdkit.Chem as Chem
from rdkit import DataStructs
from rdkit.Chem import rdFMCS, AllChem
def compute_sim_topk(df, top_k_range):
start_time = time.time()
mols = [Chem.MolFromSmiles(smiles) for smiles in d... |
a1cd8dd04958bc61ecafc16e5ce8c4fdb330d06a0ca6a7a652fd79708f72ef31 | Python | 4,317 | 101 | import shutil
from pathlib import Path
import pandas as pd
import pytest
from guppy.testing.api import locate_run_folder, step1, step2, step3, step4
from guppy_test_data import STUBBED_TESTING_DATA
SESSION_SUBDIR = "csv/sample_data_csv_1"
STORE_ID_TO_STORE_LABEL = {
"Sample_Control_Channel": "control_region",
... |
bbff35fbbb1948ee096c6559656099fb17abbda2cb29f453305a54fc0fe04e50 | Python | 4,317 | 142 | import numpy as np
from . import lookups
from .lookups import LookupTable
from .lookups import RecodingLookupTable
from .ndarray import ArrayContainerTemplate
def recode(seg, mapping):
"""
Recodes a hard segmentation via a label mapping.
Parameters:
seg: Segmentation to recode.
mapping: ... |
c38be3fef3563c0f1581961d16d65d5572fc314a844fd237944f37500a42eeed | Python | 4,317 | 92 | import os
import glob
from typing import TYPE_CHECKING
# This is just to silence nnUNet warnings. These variables should have no purpose/effect.
# There are sadly no other workarounds at the moment, see:
# https://github.com/MIC-DKFZ/nnUNet/blob/227d68e77f00ec8792405bc1c62a88ddca714697/nnunetv2/paths.py#L21
os.environ... |
04d6ff2b57ed9213d846d275e6b473ed8fcd5c06bb931fa4c2780eaa96fb3e53 | Python | 4,320 | 129 | """Test ephys.parameterscalers"""
import json
import pytest
from bluepyopt.ephys.parameterscalers import (NrnSegmentLinearScaler,
NrnSegmentSomaDistanceScaler, )
from bluepyopt.ephys.serializer import instantiator
import bluepyopt.ephys as ephys
@pytest.mark.unit
de... |
24e7dabd969cbb4dacda1394a8e9af6346153d460d9e548a2f92112feb73046f | Python | 4,323 | 87 | import sys
import pandas as pd
import numpy as np
# データを読み込む
infile = sys.argv[1] # 入力ファイル例: "m1_1_1_12.0s_100px_6.0mmps_track.tsv"
outfile = sys.argv[2] # 出力ファイル例: "m1_1_1_12.0s_100px_6.0mmps_track_modified.tsv"
total_duration = float(sys.argv[3]) # トラッキングデータ全体の時間(秒)
cut_duration = float(sys.argv[4]) # 出力したい後半部... |
09798fada87d3fa91c2493dc27a62da4ea965bc9039426bdb199f30e8db0b074 | Python | 4,326 | 119 | from typing import Any
from unittest import mock
from unittest.mock import MagicMock
from cwltool.loghandler import _logger
from cwltool.main import main
from .util import get_data
class MockResponse1:
def __init__(
self, json_data: Any, status_code: int, raise_for_status: bool | None = None
) -> No... |
0f2785cf3df992c26664f920319c096cdf904fd1fc25e227efed3fef041c67ea | Python | 4,326 | 107 | import logging
# holoviews must be imported before the first pn.extension() call so Panel wires up the HoloViews
# bokeh opts namespace that the visualization step relies on; importing this module first (it sorts
# ahead of store_ids in home.py) would otherwise leave those opts unregistered. Mirrors the
# import-then-... |
3318b4fde5c982d0f0573e638dddc1ea3f1fc00fa1cc2c12718ff456dcc3f4b0 | Python | 4,329 | 121 | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os.path as osp
import time
import numpy as np
import torch
from mmengine import Config
from mmengine.fileio import dump
from mmengine.model.utils import revert_sync_batchnorm
from mmengine.registry import init_default_scope
from mmengine.runner imp... |
51cfa2423d1ec2eb1b50a372215e6c34caf51d8165e48c651f6e7176c33be710 | Python | 4,332 | 99 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://w... |
ca529af92fc3c3ea3155427d317c5b55ba9aa9cb55ef3332c1e261e0db7a3984 | Python | 4,332 | 132 | """
This script is used to cache features for a given DNN model and neural dataset.
Args:
dataset_name: str ['ucsf', 'ucdavis'], -d
ind: int, index of the DNN model to be used (read from config), -i
contextualized: bool, -c
shuffle: bool, -s
mVocs: bool, -v
factor: float, relevant for shuffled ... |
7722af751f142162c93d6c5a4ea326a26d9e118370d3fee7b58e833c8d5e499f | Python | 4,335 | 161 | """Tests for --print-inputs-deps."""
import json
import os
from io import StringIO
from pathlib import Path
from cwltool.main import main
from cwltool.process import CWL_IANA
from .util import get_data
def test_input_deps() -> None:
"""Basic test of --print-input-deps with a job input file."""
stream = Str... |
bffcb2fec753c99e434bd7f179678953661777fbad2f617b11df81ee041fc7e9 | Python | 4,337 | 123 | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os
import os.path as osp
from mmengine.config import Config, DictAction
from mmengine.runner import Runner
# TODO: support fuse_conv_bn, visualization, and format_only
def parse_args():
parser = argparse.ArgumentParser(
description='M... |
edf691a8c2ffb84a92e6e59c9d454f41a9fd0731d1612b32f71a504fdb95f809 | Python | 4,337 | 123 | """
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.
---
Script for calculating the scaling factors used to even out GemNet activation
scales. This generates the `scale_file` specified in ... |
bdc04c375ae1784572d299d3556c1915b7eee70cadfce1bf945c36acdc850c1c | Python | 4,338 | 99 | import pandas as pd
import matplotlib.pyplot as plt
import torch
import seaborn as sns
import scienceplots
import matplotlib.gridspec as gridspec
import matplotlib.colors as colors
import numpy as np
import nilearn
import nibabel as nib
from nilearn import plotting, datasets, surface, image
from nilearn.plotting import... |
f27ddb54d392641274810ef4cad35db746d5f520c0cd274980205b708f9ddd41 | Python | 4,338 | 117 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: Andrei Istudor andrei.istudor@hu-berlin.de
"""
# from EthoCNN import EthoCNN
from TestInterval import TestInterval
from Logger import Logger
import torch
import numpy as np
class TestModel:
'''
Class for testing the model found at :data:`modelPa... |
3f43921f16a6a81c86cc73ea69877617a5a4e4dd207a5f7065e3aec600d35d6f | Python | 4,340 | 136 | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import os
import argparse
import csv
import logging
import pickle
from pathlib import Path
import numpy as np
import torch... |
f4fd42a3ef79723665fb4bc7aa81ea498cc725924e5a4078ebec3939de1d3224 | Python | 4,340 | 110 | # -*- coding: utf-8 -*-
import json
from catmaid.models import TreenodeConnector
from catmaid.state import make_nocheck_state
from .common import CatmaidApiTestCase
class LinksApiTests(CatmaidApiTestCase):
def test_delete_link_failure(self):
self.fake_authentication()
connector_id = 202020
... |
54a131adba60d3fae6de3ecbfc1867a30ad1f8d9adbb1ec904cd3a7b1e37757c | Python | 4,341 | 136 | ##
## CPCantalapiedra 2020
import os
import subprocess
from tempfile import NamedTemporaryFile
from collections import defaultdict
from ...common import HMMFETCH
##
# Create a new temp fasta file including only
# the queries in the list "queries"
def filter_fasta_file(queries, orig_fasta, temp_dir):
Q = Nam... |
2e610d974c66d43b8d53c8d81bd909e57119d7eb93a37ecb1f87ec01342a5dd5 | Python | 4,342 | 142 | # -*- coding: utf-8 -*-
import json
import networkx as nx
from networkx.readwrite import json_graph
from typing import Dict, List
from django.http import HttpRequest, JsonResponse
from django.db.models import Count
from catmaid.models import Treenode, TreenodeConnector, UserRole
from catmaid.control.authentication i... |
fada98011b57391567bcf40644b274283c32fe2a00c60ac2f8e8924c4985abee | Python | 4,342 | 157 | """MLCube handler file"""
import os
import yaml
import typer
import shutil
import subprocess
from preprocess import Preprocessor
from check import Checker
from statistics import Stats
app = typer.Typer()
def exec_python(cmd: str) -> None:
splitted_cmd = cmd.split()
subprocess.run(splitted_cmd, cwd=".", ch... |
2489fe9f2d87d02ada6f473c380604999bf91b77ee93ff1f42a0b2cfde538981 | Python | 4,347 | 154 | # load Modules
import numpy as np
from copy import deepcopy
from scipy import signal
from scipy.optimize import curve_fit
from scipy import ndimage
from scipy import sparse
from scipy.signal import butter, lfilter, lfilter_zi
## LEAST SQUARES FITTING ##
def func_exp(x, a, b):
return a * np.exp(-b * x)
def func... |
a911c2ddde12a1af854410696cfa28c24e92b3541a03039f0dcd60f25c0ed232 | Python | 4,347 | 135 | """
Written by Tim Lawn 16/12/2024
Summary for eventual methods section
1. Normalizes masked images to 0-1 range using the same approach as react_normalize
2. Computes and saves summary statistics for each normalized image
"""
import os
import glob
import numpy as np
import nibabel as nib
import pandas as pd
from d... |
5cc42e5c74c3b5d9387a0aa7dd92fabbe17f24b8ceb73fcc5b85461e5c1f2117 | Python | 4,350 | 125 | import pytest
import numpy as np
from numpy.testing import assert_allclose
from flaky import flaky
import keras
from keras import metrics
from keras import backend as K
all_metrics = [
metrics.binary_accuracy,
metrics.categorical_accuracy,
metrics.mean_squared_error,
metrics.mean_absolute_error,
m... |
b4f2d4acd23fad2d5f39d4e5eb0a135894aa5bbbb126370db47989a9c8f71756 | Python | 4,352 | 114 | """Dev tool: render the Step 6 metadata form and screenshot it.
Serves :func:`guppy.orchestration.metadata.build_metadata_template` on a free port,
drives a headless Chromium to the page, optionally expands every collapsible card,
and writes a full-page PNG. Used to iterate on the form's visual design; it is not a
tes... |
bbb87a39f18c10814000f17fff1ae2c6d8da6534b2da0142bd6c5c6fa7d8609d | Python | 4,354 | 98 | import numpy as np
import torch
from sklearn.inspection import partial_dependence
from torch_geometric.data import Data
from scipy.stats.mstats import mquantiles
import os
import pandas as pd
from tqdm.notebook import tqdm
SEX_COLUMN_NAME = "Sex"
AGE_COLUMN_NAME = "Age"
HGB_COLUMN_NAME = "HGB"
WBC_COLUMN_NAME = "WBC"
... |
228df7f14d109a521ae9173ed05214abeb6116354ae1eb20abdcd559bdfb08a4 | Python | 4,355 | 112 | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os
import os.path as osp
import tempfile
import zipfile
import mmcv
from mmengine.utils import mkdir_or_exist
HRF_LEN = 15
TRAINING_LEN = 5
def parse_args():
parser = argparse.ArgumentParser(
description='Convert HRF dataset to mmseg... |
07bcb2c87a9034bd1a2751cb1f0ba64fbba3230f5ed2387e3a820807b8f054a7 | Python | 4,356 | 139 |
from jaxkineticmodel.load_sbml.export_sbml import SBMLExporter
import diffrax
from jaxkineticmodel.kinetic_mechanisms import JaxKineticMechanisms as jm
from jaxkineticmodel.building_models import JaxKineticModelBuild as jkm
import jax.numpy as jnp
import jax
import equinox
import matplotlib.pyplot as plt
import pandas... |
6f36a97285f6385eb656be3152c2aad3511b217b53aa078e74c707e901fd7b24 | Python | 4,359 | 121 | # -*- coding: utf-8 -*-
from setuptools import setup, find_packages
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()
path_version = path.join(here, 'spinalcordtoolbox', 'version.tx... |
374f813bf4e94eb693f7489659352bc9f6be66427109a08b60ba43c327f6410c | Python | 4,361 | 118 | # tests/test_pagination.py
"""Tests for pagination boundary conditions across list endpoints."""
import pytest
from zndraw_joblib.schemas import JobSummary, PaginatedResponse
@pytest.fixture
def five_job_client(client):
"""Client with 5 global jobs registered."""
for i in range(5):
resp = client.put... |
554727cc0e8cb4bb771728e9badfd06738d95daed3786cc195c93794a9e5e6dc | Python | 4,361 | 115 | """Regression: @internal providers are decoupled from the Worker table.
@internal providers are server-owned (dispatched by the in-process
taskiq worker, not a remote client). They have ``worker_id=None`` by
construction, mirroring how @internal jobs have no ``WorkerJobLink``
entries.
This test pins down two invarian... |
dac4a736a82baacafafcff5bac57a77f1cf7d56d673ff80c4c2f028a14406dc5 | Python | 4,362 | 142 | from rest_framework import status
from medperf.tests import MedPerfTest
from parameterized import parameterized, parameterized_class
class EncryptedKeyTest(MedPerfTest):
def generic_setup(self):
# setup users
container_owner = "container_owner"
cert_owner = "cert_owner"
ca_owner ... |
39f670854678e3e6ae51589b13fdf9aeb600731146abfcebf41b70a5efaf68c2 | Python | 4,364 | 116 | """Workflow utils."""
# Copyright (c) 2022 EPFL-BBP, All rights reserved.
#
# THIS SOFTWARE IS PROVIDED BY THE BLUE BRAIN PROJECT ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EV... |
22f89d5b3857a4751e19e618798aef08bcf7606581eedac15eb47200f5d035d1 | Python | 4,368 | 137 | #!/usr/bin/env python
"""
MetaWIBELE: abundance_filtering module
Filter out potential bad proteins
Copyright (c) 2019 Harvard School of Public Health
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 Softw... |
2da92e52eb947fe32e88328d1a511aabc93e78b68db7bd5b0f153a1df0a9506c | Python | 4,369 | 113 | import numpy as np
from scipy.interpolate import interp1d
from copy import deepcopy
from PyQt5 import QtWidgets, QtGui
from util.conf import af_params
from features.Feature import Feature
class AdjustFrequency(Feature):
def __init__(self, data, parent=None, liveplot=None):
Feature.__... |
c65a8b70ec704bf9606dd2a008f781120adccf9993b363d1e89d320dca945d65 | Python | 4,370 | 102 | # pytest unit tests for sct_image
import logging
import os
import pytest
import numpy as np
from spinalcordtoolbox.image import Image
from spinalcordtoolbox.utils.fs import extract_fname
from spinalcordtoolbox.utils.sys import sct_test_path
from spinalcordtoolbox.scripts import sct_image, sct_crop_image
logger = lo... |
f0d931147e7f18223aa507db9498a313c577982cbcdd08bbc8d4e30b3011b322 | Python | 4,371 | 96 | import matplotlib.pyplot as plt
import matplotlib.figure
import numpy as np
import os
import seaborn as sns
from src import config as cfg
from src import computation as comp
from src import helper_functions as hf
def make_timecourse_figures(time_varying_df, targets_df, title='') -> tuple([matplotlib.figure.Figure, ... |
121edea40ce99e41bf4fb26bf6d37a63a31b814fe990d7e5048c7f94e22ef39c | Python | 4,372 | 99 | import os
import cv2
import json
import numpy as np
import random
from data.transforms import ISOSTransform
from data.datasets import AOOCTConeSeg
from tools.visualizations import generate_distinct_colors, draw_asterisk
random.seed(42)
np.random.seed(42)
if __name__ == '__main__':
with open('cfg/model/segformer... |
81ec75b2065f3ca1045ba9ae4f261e3ca76613a7c9bd6a7a54504bf6d7dd5bac | Python | 4,372 | 99 | # -*- coding: utf-8 -*-
from django.http import Http404
from django.utils.decorators import method_decorator
from django.shortcuts import get_object_or_404
from django.views.decorators.cache import never_cache
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.... |
2e4a6f77b6a53984c1be01f0e6e4246442db0ca639872fb0ae301ef188915afa | Python | 4,375 | 133 | from django.http import Http404
from rest_framework.generics import GenericAPIView
from rest_framework.response import Response
from rest_framework import status
from drf_spectacular.utils import extend_schema
from .models import MlCube
from .serializers import MlCubeSerializer, MlCubeDetailSerializer
from .permission... |
a23caac1046fa412985fb09a8b4c683e070d9a784a8aa4b6b3c998ab9321e8e9 | Python | 4,376 | 125 | """End-to-end scope refactor smoke test hitting a real uvicorn server.
Uses ``server_auth`` fixture so dev-mode auto-promote is OFF; registered
users are ordinary active users.
"""
import pytest
from httpx import AsyncClient
async def _register_and_login(
client: AsyncClient, email: str, password: str = "test12... |
65d87074e18c0be80d15b20eae6a858e376215b72293673d02a13793a55dff1d | Python | 4,377 | 106 | def scaffold_split(csv_list, op_path, blk, frac_train=0.8, frac_valid=0.1, frac_test=0.1):
# Initialize an empty list to store DataFrames
dfs = []
# Read each CSV file into a DataFrame and append it to the list
for file in csv_list:
df = pd.read_csv(file)
dfs.append(df)
# Concaten... |
f44edb4398ff5047bb9d1e762f802dbf27836105520679ce00e297bf04a56e3a | Python | 4,378 | 122 | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.backbones import MixVisionTransformer
from mmseg.models.backbones.mit import (EfficientMultiheadAttention, MixFFN,
TransformerEncoderLayer)
def test_mit():
with pytest.raises(TypeE... |
606ee89952dc81dbda68940f7f0dd5186767bc1d7e070f0ab3b404e62b56a256 | Python | 4,384 | 108 | #!/usr/bin/env python
#
# Copyright 2009, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... |
9c1c6f89a6681b32461b9c77ac06c14d17a73e5195f812c3982f6158f7e9b264 | Python | 4,386 | 95 | #!/usr/bin/env python2.7
import os
import argparse
import subprocess as sp
import multiprocessing as mp
import shlex
import datetime
import re
import chisel
src = os.path.dirname(chisel.__file__)
from ..Utils import *
def parse_args():
description = "CHISEL command to re-create the plots."
parser = argpars... |
43051ab3d622c1d97c17af3e9450be6691822b1101de22db2c1edbdec329aab7 | Python | 4,387 | 129 | from medperf.exceptions import InvalidArgumentError, MedperfException
from medperf import config
from pydantic.datetime_parse import parse_datetime
def validate_args(benchmark, training_exp, dataset, model, approval_status):
training_exp = bool(training_exp)
benchmark = bool(benchmark)
dataset = bool(data... |
a768c0019af28b28e4d2aead96168ad42f01b3bfdec3b4c21b963bc23b60753c | Python | 4,387 | 130 | from PIL import Image
import numpy as np
import pandas as pd
from tqdm import tqdm
import os
import yaml
import argparse
import inspect
import importlib
from shutil import copytree
import torchxrayvision as xrv
import torchvision
class Preprocessor:
def __init__(self, img_path, csv_path, params_file, output_path)... |
3f8563f1dbde07220f67500cf0a6310f22704a891c42641f9be123bd2769079e | Python | 4,388 | 143 | """
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 torch
from ocpmodels.modules.scaling import ScaleFactor
from .basis_utils import get_sph_harm_basis
from .radial_basis import Gaussia... |
c3cd82285de54c479bbbcb67aecef28e0cda5caaea255242921e2a4d2549a2a3 | Python | 4,388 | 133 | import torch
import torch.nn as nn
import scipy.stats.stats as stats
import numpy as np
def get_rank(batch_score, dim=0):
rank = torch.argsort(batch_score, dim=dim)
rank = torch.argsort(rank, dim=dim)
rank = (rank * -1) + batch_score.size(dim)
rank = rank.float()
rank = rank ... |
cc3e7d7a1186b771710c06d21ba0e375368442b06f2644b1fa1d0a769dfff699 | Python | 4,390 | 111 | """Generate a mock NWB file for testing the NWB recording extractor.
IMPORTANT: This script must be run with ndx-fiber-photometry==0.2.3 and ndx-events==0.2.2 installed.
To run, create the isolated conda environment defined alongside this script:
conda env create -f src/guppy/testing/scripts/environment_ndx_fiber... |
3e550fbd1f042adda5bb44e4b6d62d59c81be4aeeca50de6fc16c21b3fc78503 | Python | 4,392 | 155 | """Objective classes"""
"""
Copyright (c) 2016-2020, EPFL/Blue Brain Project
This file is part of BluePyOpt <https://github.com/BlueBrain/BluePyOpt>
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License version 3.0 as published
by the Fre... |
a8ab9312a225544d29a895daac6a1a9c39fc6040a23ce81a96ca3ff1b41938f2 | Python | 4,392 | 124 | import os
import torch
import pandas as pd
from PIL import Image
import numpy as np
import torchvision.transforms as transforms
from models import model_attributes
from torch.utils.data import Dataset, Subset
from data.confounder_dataset import ConfounderDataset
class MultiNLIDataset(ConfounderDataset):
... |
6daf24e13ec9a14bd51bed83d448a06504fdb7630c79547cf6efd64cdd3b801c | Python | 4,393 | 112 | import utility
from types import SimpleNamespace
from model import common
from loss import discriminator
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
class Adversarial(nn.Module):
def __init__(self, args, gan_type):
super(Adversarial, self).__init__()
... |
7cabb9f807d51664d36603080c45647348842ec4001422662ace10845a041a36 | Python | 4,393 | 155 | """Objective classes"""
"""
Copyright (c) 2016-2020, EPFL/Blue Brain Project
This file is part of BluePyOpt <https://github.com/BlueBrain/BluePyOpt>
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License version 3.0 as published
by the Fre... |
a9e3708f3a8e6afc7ac3abb4114ace41058f1c460b28fb0ac5da721b60c191d1 | Python | 4,396 | 86 | import subprocess
import os
def gff3_to_bed12(mm2_prog_path, gff3_file, bed12_file):
if mm2_prog_path != "":
cmd = "{_k8} {_paftools} gff2bed {_gff3} > {_bed}".format(
_k8=os.path.join(mm2_prog_path, "k8"),
_paftools=os.path.join(mm2_prog_path, "paftools.js"),
_gff3=gff... |
f074a0d07314b62ed9bb162f9600a9aada420dde94df80059a05ea9698b2ffd0 | Python | 4,396 | 110 | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from copy import deepcopy
from typing import Tuple
import numpy as np
import torch
from torch.nn import functional as F
f... |
48c34df80b0e985b05c3824a591e2542b2509046b45a050cb29ca5c9b2f93046 | Python | 4,397 | 124 | from medperf.commands.dataset.prepare import DataPreparation
from medperf.commands.dataset.submit import DataCreation
from medperf.utils import get_folders_hash, remove_path, store_decryption_key
from medperf.exceptions import InvalidEntityError
from medperf.entities.model import Model
from medperf.comms.entity_resourc... |
07cf160a635b55af2712660b335d06556889768d2061beecd0a727157d87b421 | Python | 4,400 | 114 | import numpy as np
import tensorflow as tf
def split_dataset(f, response, label, test_ratio=0.2):
"""
Split the data into training and testing sets.
Args:
f (array-like, shape [n_samples, n_features]): Predicted neural response.
response (array-like, shape [n_samples, n_features]): True ne... |
084c558037e94f3c341626d298b390653ef88b46f4ff0f5e78ea849409664b6a | Python | 4,402 | 139 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import os
import shutil
import itertools
from multiprocessing import Pool
import numpy as np
from dmriqcpy.io.report import Report
from dmriqcpy.io.utils import (add_online_arg, add_overwrite_arg,
assert_inputs_exist, asser... |
10fe4cd7b1b917d65eaf66c488d4abea12d1c05d11626adb87432dec77e8582e | Python | 4,406 | 84 | #execution script to initialize snakemake pipeline of HybriDetector
import argparse
import os
import sys
import pandas as pd
from snakemake.shell import shell
def main(sysargs = sys.argv[1:]):
# Initialize parser
parser = argparse.ArgumentParser(description='HybriDetector.py: run HybriDetector snakemake workf... |
c002b448f204f08bad540a9483676630686d75e12e11d30d43a36bb7727ebe9b | Python | 4,408 | 146 | # ---
# jupyter:
# jupytext:
# formats: ipynb,py,md
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.16.1
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---
# + [markdown] ... |
ddaefd38e74d5857ec0c9b8120f1a87bf4a4c3ae5c078bd845fdec67a8d38e85 | Python | 4,409 | 146 | """Utils function"""
"""
Copyright (c) 2016-2022, EPFL/Blue Brain Project
This file is part of BluePyOpt <https://github.com/BlueBrain/BluePyOpt>
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License version 3.0 as published
by the Free S... |
fbd39fad5cf26831e2d3ca42b94138169f6d35a5a6636005c834a82ba600bb88 | Python | 4,409 | 116 | from torch.utils.data import Dataset
from fengshen.metric.utils_ner import get_entities
import os
def get_datasets(args):
processor = DataProcessor(args.data_dir, args.decode_type)
train_data = TaskDataset(processor=processor, mode="train")
valid_data = TaskDataset(processor=processor, mode="dev")
te... |
993424e013cff52ca45b89367d0c838cefe31571734ab6da40587bb0dbc2f5fc | Python | 4,413 | 122 | # MCMC design based on Colabdesign
import numpy as np
import random
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
import time
import os
import random
from get_sc import *
# Set the random seed for reproducibility
# random.seed()
pdb = '4ib5.pdb' # Define the pdb file here.
seq_len = 1... |
f6f7fc76b3c983223d9e90545f0dcd7ca6ea4036cd982e3893e31f378d7fd496 | Python | 4,416 | 108 | # Install dependencies.
# pip3 install torch torchvision torchaudio transformers sentencepiece accelerate --extra-index-url https://download.pytorch.org/whl/cu116
# pip3 install -U "huggingface_hub[cli]"
# pip install esm
# Import necessary libraries
import torch
import re
import pandas as pd
import time
# ---------... |
570bcd108f53b33827696ba4c64fa62a969e28d27fea83f255086ca86c919b3a | Python | 4,419 | 106 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import json
import glob
from zoo_bids.functions import find_root
project_name = 'zoo-bids'
path_root = find_root(project_name=project_name)
participants_tsv = glob.glob(os.path.join(path_root, 'participants.tsv'))[0]
participants_json = glob.glob(os.path.join(pat... |
5560852f3419a7949e096ee6c474dfe59c73efec68f96b811a8767abd73595fa | Python | 4,422 | 104 | import pytest
from CybORG.Simulator.Actions.ConcreteActions.PhishingEmail import PhishingEmail
from CybORG.Simulator.Actions.GreenActions.GreenAccessService import GreenAccessService
from CybORG.Simulator.Actions.GreenActions.GreenLocalWork import GreenLocalWork
from CybORG.Simulator.SimulationController import Simulat... |
362a8badb7b993ec3ec4302e13c2e6709e1b7ebcd6c399b9df89b18711b86d91 | Python | 4,423 | 101 | """
MIT License
Copyright (c) 2019 Ildoo Kim
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, publish, dis... |
9ca8bef0bf595d6f7489208215e1c315aefff8b738aae4125f13afcd72aff212 | Python | 4,427 | 112 | import glob
import numpy as np
import os
import torch
from model import RSTN
def coarse_testing(imgs_path, output_path, ckpt_path, device, plane, params):
crop_margin = params["crop_margin"]
crop_prob = params["crop_prob"]
crop_sample_batch = params["crop_sample_batch"]
low_range = params["low_range"... |
b894ce6c9b36472fc2b3bc6bc5aed3a4c3086d3db6b6963176d2f13e375c4856 | Python | 4,430 | 136 | import os
import pandas as pd
import numpy as np
from pathlib import Path
from typing import List, Union
from ..logger import logger
def prep_input_table(cell: str,
hetsnp_dir: Union[str, Path],
bin_dir: Union[str, Path],
chroms: List[str] = None) -> pd.Da... |
d2e2625c5dbfd8dc8d2f0410e53854d7f0503ce1b0856b3b911d9f9549aeba69 | Python | 4,431 | 109 | #!/usr/bin/env python3
import os
import sys
import argparse
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("--baseDir", help="base directory in which your network will live", default='models')
parser.add_argument("--name", help="name of your network", defa... |
c0ebc07f48ce4fa40e2c08a81535661ae9410448e5c5dd5164a3752d3b7d011d | Python | 4,432 | 93 | """Drift guard: `slurm/README.md`'s hotspot table must match the snakefiles it documents.
That table is what an operator reads before deciding whether a rule can be given less memory, so a
row that disagrees with the rule sends them after a setting that isn't there. It drifts silently --
nothing else reads it -- and i... |
ebda14b5cc5a094a3e003af693f2a211ee951f2d39c2ab397137444fb371eae9 | Python | 4,432 | 96 | import matplotlib.pyplot as plt
import torch
import seaborn as sns
import scienceplots
import matplotlib.gridspec as gridspec
import matplotlib.colors as colors
import glob
from natsort import natsorted
import pandas as pd
import numpy as np
from sklearn.manifold import MDS
gs = gridspec.GridSpec(1, 3, width_ratios=[0... |
5fcbf02ee3f40a03c96943784b0fbaebdeceed760acf18fb257e2fbb9666c19f | Python | 4,433 | 130 | import json
from medperf.asset_management.gcp_utils import (
GCPOperatorConfig,
CCWorkloadID,
download_file_from_gcs,
download_string_from_gcs,
check_gcs_file_exists,
run_workload,
wait_for_workload_completion,
)
from medperf.asset_management.operator_check import verify_operator_setup
from ... |
c09b69ec3ae44e9597036de644a1c50512aecbc098bcb8b34eb2ede553a78195 | Python | 4,433 | 148 | """Selection extensions for choosing atoms in the scene.
These extensions modify which atoms are selected in the 3D view.
"""
import random
import typing as t
import networkx as nx
from pydantic import Field
from zndraw.extensions.abc import Category, Extension
class Selection(Extension):
"""Base class for al... |
c173e067e17429e74390d94cfe31f52893af03d899562b4ebaa3b68b3bcfae7d | Python | 4,433 | 110 | ##################################################################
# Calculating the co-occurrence values of motifs and plaque spatial distance
# Reproducibility for Figure.4L
##################################################################
import numpy as np
import pandas as pd
import scanpy as sc
import squidpy as... |
734d02898a8c5b0aa1fb17edac038e12dbe53b939524bf1b67518aa169712046 | Python | 4,435 | 140 | from src import *
import optuna
import argparse
import re
import os
import torch
import pandas as pd
import numpy as np
# -----------------------------------
# 🧪 Argument Parsing
# -----------------------------------
parser = argparse.ArgumentParser(description="Run inference on triplets")
parser.add_argument(
... |
88d68ce1b8d819aa6aab11f9e3cddff6b73f84b3450937facd842ddda6f98e7b | Python | 4,435 | 136 | # Copyright (c) OpenMMLab. All rights reserved.
import collections
import copy
from typing import List, Optional, Sequence, Union
from mmengine.dataset import ConcatDataset, force_full_init
from mmseg.registry import DATASETS, TRANSFORMS
@DATASETS.register_module()
class MultiImageMixDataset:
"""A wrapper of mu... |
54c7c70811ca5a51f49adbc085984ffea9e8175e8713ac10b4811151e0aecc92 | Python | 4,437 | 144 | from __future__ import annotations
from collections.abc import Iterable, Iterator
import os.path as op
from pathlib import Path
import sys
from typing import TYPE_CHECKING, Any, Generic, NamedTuple, Optional, TypeVar
from unittest.mock import patch
import pytest
try:
from tinydb import Query, TinyDB
except Impor... |
68ec4b901a24aad2ce51a91f27df3323a24ef2759969a87dd26be2401f5bdf2e | Python | 4,438 | 119 | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import shutil
from unittest import TestCase
import numpy as np
import pytest
import torch
from mmengine.structures import PixelData
from mmseg.evaluation import CityscapesMetric
from mmseg.structures import SegDataSample
class TestCityscapesMetri... |
82354515b3ad0841b3ed8b9e0b8730774ed2bd94d93dfb0073ca55393768453b | Python | 4,438 | 108 | import os
import torch
import pandas as pd
from PIL import Image
import numpy as np
import torchvision.transforms as transforms
from models import model_attributes
from torch.utils.data import Dataset, Subset
from data.confounder_dataset import ConfounderDataset
class CelebADataset(ConfounderDataset):
"... |
1d6b4f4222c6f8d39984369b63272cee5e305a8e2fd5126edb69da462214d3b0 | Python | 4,442 | 132 | import logging
from pathlib import Path
import ase.io as ase_io
import numpy as np
import typer
from simgen.element_swapping import SwappingAtomicNumberTable
from simgen.integrators import IntegrationParameters
from simgen.manifolds import LinePrior, MultivariateGaussianPrior
from simgen.particle_filtering import Par... |
8f896e7533a1de2d506b0cc3d2cac4c6de65f0609bc8ca0aaf7cd595927e23cd | Python | 4,442 | 119 | import pandas as pd
import numpy as np
def get_df_for_scores(session_dict, measure_attribute='score'):
data_keys, values = [], []
for key, unit_array in session_dict.items():
for value in unit_array:
data_keys.append(key)
values.append(value)
df = pd.DataFrame({'dataset':da... |
99463e34b4c00500b68967977237afb34b1f3b879c56dc9cac38ce60a262855d | Python | 4,443 | 84 | import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import math
import scienceplots
import matplotlib.gridspec as gridspec
from functools import reduce
from brokenaxes import brokenaxes
selected_tasks = ['peterson2021using', 'ruggeri2022globalizability']
df_random = pd.read_c... |
23936ba6ff49bcc641c757bd53670c7be96bdfbe0b7f6ccccefbfe7c6cfe18fc | Python | 4,450 | 156 | #!/usr/bin/env python3
"""
Module for pytorch transformations of particle images
"""
from typing import Tuple, TypeVar, Dict, Any, Union
import numpy as np
import torch
from .grid import dft, idft, dht, idht, spectrum_to_grid, get_spectral_indices
Tensor = TypeVar('torch.tensor')
class SquareMask(object):
"... |
ef1908e66b839942b13ab44fbe5d9d8cbcc3bce26ace1f8089fa605a48063bee | Python | 4,451 | 127 | # FCN model
# when tuning start with learning rate->mini_batch_size ->
# momentum-> #hidden_units -> # learning_rate_decay -> #layers
import tensorflow.keras as keras
import numpy as np
from sklearn.model_selection import train_test_split
import time
import tensorflow as tf
from utils.utils import save_logs
from utils.... |
98cc27d0e87131ebcc8d0e83f9a8fbdc52d78212735c9629e30b26e58b8a1465 | Python | 4,456 | 101 | import os
import pandas as pd
from sklearn.metrics import adjusted_rand_score, normalized_mutual_info_score, silhouette_score, \
homogeneity_completeness_v_measure
from sklearn.metrics.cluster import contingency_matrix
from sklearn.preprocessing import LabelEncoder
import numpy as np
... |
82569a79ae3d4a57ef7b5eff6cf42432be960568aa15ec78512174a143311212 | Python | 4,457 | 147 | ###########################################################################################
# Statistics utilities
# Authors: Ilyes Batatia, Gregor Simm, David Kovacs
# This program is distributed under the MIT License (see MIT.md)
########################################################################################... |
aa459a34ff4de862a45d81c9739d80d16bc99c4f5918bdfcfd316d70d6db55c8 | Python | 4,457 | 121 | # tests/test_writable_room.py
"""Tests for WritableRoomDep — verifies the DI override point and default behavior."""
import uuid
from conftest import make_room_address
from fastapi import HTTPException, Path
from starlette.testclient import TestClient
from zndraw_joblib.dependencies import verify_writable_room
from ... |
00803ed453099d50ef0b467afa87695313ba49958c1779786ea865c6ab6ad7f5 | Python | 4,458 | 121 | """IMDB sentiment classification dataset.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from ..utils.data_utils import get_file
from ..preprocessing.sequence import _remove_long_seq
import numpy as np
import json
import warnings
def load_data(path='i... |
b06ba0104fd87e36459188c47dd527a9cfb3b180d2316d246f7c831b5af2d262 | Python | 4,458 | 131 | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.backbones import STDCContextPathNet
from mmseg.models.backbones.stdc import (AttentionRefinementModule,
FeatureFusionModule, STDCModule,
STDCNet... |
b7981226f712ee5f5d73cc59314578d7fcfba4b63249652667ef5bde8a2d351a | Python | 4,459 | 132 | #!/usr/bin/env python3
"""
===============================
Dynamic Dataset Catalog Builder
===============================
This script scans subdirectories of a specified folder (or the current folder by default)
for `.json` files containing DICOM metadata, and creates a CSV catalog of selected fields.
==============... |
a613e251d2f3ee59209af8e2bc08598e99fe5e4865963325501e04555211e26b | Python | 4,460 | 165 | """Tests for CLI selection and selection-groups commands."""
from __future__ import annotations
from typing import TYPE_CHECKING
from zndraw.schemas import (
GeometrySelectionResponse,
SelectionGroupResponse,
SelectionGroupsListResponse,
StatusResponse,
)
from .conftest import invoke_cli
if TYPE_CH... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.