sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
6c843733a9d7fd8f1afe65be74d9d6ade7a950daf4a3b8d2983dafdc0d489c31 | Python | 505 | 11 | def calc_sigma (intra_conductivity, extra_conductivity):
return (intra_conductivity*extra_conductivity)/(intra_conductivity+extra_conductivity)
# N-benchmark conductivities
sigma_i_l = 0.17 # Intracellular longitudinal {S/m}
sigma_e_l = 0.62 # Extracellular longitudinal {S/m}
sigma_i_t = 0.019 # Intracellular tran... |
8cb8e937773e10ab904d4283e69325345d3903d7c6ddc3e265137070b6841ab9 | Python | 505 | 17 | """Impedance reconstructions from time domain signals."""
from .cwt_reconstruction import calculate_impedance_spectrum_using_cwt
from .fft_reconstruction import (
calculate_impedance_spectrum_using_fft,
fit_impedance_from_time_domain,
predict_time_domain_signal,
)
from .signals import rectangle
__all__ = ... |
b749c136fd4b3202b45351ecbf449e86156242bc9850ee471f50faea7e3368ba | Python | 505 | 17 | from dataclasses import dataclass
@dataclass
class LatentSamplingConfig:
"""
:param layers_to_sample: list of layers to sample latents from.
:param max_samples_for_viz: maximum number of samples to use for visualizations.
If None, use all samples.
:param batch_size_fo... |
34f6c5a99c07138d723d26dd429752d508d583412c5e388ea13f82a76e5fbc36 | Python | 507 | 22 | import abc
from pathlib import Path
from typing import Optional
import pandas as pd
from brainways.project.info_classes import SliceInfo
class CellDetectionImporter(abc.ABC):
parameters = {}
def __init__(self, **kwargs):
pass
def find_cell_detections_file(
self, root: Path, document: S... |
7435046f0eec995503047628ca47b4f306ccb1d5214ea3f8aa937fcb54587b9f | Python | 507 | 16 | import torch.nn as nn
def get_activation(activation: str) -> nn.Module:
"""Get activation function by name."""
if activation == "relu":
return nn.ReLU()
elif activation == "leaky_relu":
return nn.LeakyReLU(negative_slope=0.2)
elif activation == "gelu":
return nn.GELU()
elif ... |
80d7176dd5a09497706e3a9162cd8ea411a9db1094240b9d3e477d9fee192cae | Python | 507 | 18 | from pathlib import Path
from typing import TYPE_CHECKING
import yaml
from eir.setup.config_setup_modules.input_config_initialization import init_input_config
if TYPE_CHECKING:
from eir.setup.schemas import InputConfig
def load_input_config_from_yaml(input_config_path: Path) -> "InputConfig":
with open(inp... |
9bc7123493027202c9ce9e8af43321e4d5f9ad61f59d88f2653accc310286f91 | Python | 508 | 12 | from tests.utils import pytest_importorskip
def test_qtremoteobjects():
"""Test the qtpy.QtRemoteObjects namespace"""
QtRemoteObjects = pytest_importorskip("qtpy.QtRemoteObjects")
assert QtRemoteObjects.QRemoteObjectAbstractPersistedStore is not None
assert QtRemoteObjects.QRemoteObjectDynamicReplica... |
21303eb413a3d2d20d16347dc3d2e417cdaa36b23fb7454f43ec3da87f278b6c | Python | 509 | 14 | from brainscore_vision import metric_registry
from .metric import RDMMetric, RDMCrossValidated
metric_registry['rdm'] = RDMMetric
metric_registry['rdm_cv'] = RDMCrossValidated
BIBTEX = """@article{kriegeskorte2008representational,
title={Representational similarity analysis-connecting the branches of systems neuros... |
5d02402945a74677c3809e78f66483f780a45e0afdad398b93c94d75be214f8f | Python | 509 | 8 | from brainscore_vision import model_registry
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from .model import get_model, get_layers
model_registry['first_dev_learning_simple'] = lambda: ModelCommitment(identifier='first_dev_learning_simple',
... |
5e5dd10fe817799f1b90c00fc08822dc282b3cc43a6013115a35eef2a4faf348 | Python | 509 | 16 | #!/usr/bin/env python
"""DEPRECATED shim -> `morphometrics refine_mesh`.
This script has moved into the installable `surface_morphometrics` package and is
now invoked as `morphometrics refine_mesh ...`. This thin wrapper forwards to that
command and will be removed in a future release.
"""
import sys
from surface_mor... |
8efee72fa173a2cc3af222eb5d5a6794623b3c2a182d1bc6ca72b769c1e86476 | Python | 509 | 14 | from analognas.search_spaces import config_space
from analognas.evaluators import XGBoostEvaluator
from analognas.search_algorithms import BOptimizer, Worker
CS = config_space('CIFAR-10')
surrogate = XGBoostEvaluator(model_type="XGBRanker", load_weight=True)
optimizer = BOptimizer()
worker = Worker(CS, eval=surrogat... |
316fa35cd37b61d0f4277e8159de76143c393f917a435ce22c9915904f8efdb2 | Python | 510 | 19 | """Remove facial features from structural MRI data"""
import subprocess
import glob
# Set data path
ROOT = '/Users/sebastiandresbach/data/s1Anfunco/openneuro'
# Set subjects to work on
subs = ['sub-05', 'sub-06']
# Loop over participants
for sub in subs:
images = sorted(glob.glob(f'{ROOT}/{sub}/*/anat/{sub}_ses... |
dacdb62a2dbd66f8f37a5c0b8f57233dabcf20284ca973da7ca179d25db9d32e | Python | 510 | 19 | import numpy as np
from scipy.spatial.distance import squareform
def reorder_rdm(utv, new_order):
"""[reorder_rdm]
Args:
utv ([1D array]): pass an upper-triangular vector
new_order ([1D array]): condition list order
Returns:
[reordered utv]: reordered utv.
"""
ax, bx = np... |
db4c22678e5418bde1f8ebfd688ae877775231557c908994cf736687a54193b8 | Python | 510 | 20 | import json
import subprocess
import os
import pytest
import shutil
with open("../cookiecutter.json") as f:
cookie_config = json.load(f)
@pytest.mark.slow
def test_cookiecutter_project_creation():
os.makedirs("./tmp_test_dir/", exist_ok=True)
os.chdir("./tmp_test_dir/")
cmd_ = ["cookiecutter", "--no-... |
48b4bc0023c70a112ede872a028d52ed2f3288f4f4d0b7319114bcfa0842785f | Python | 511 | 19 | """# Image widget
Example of creating an Image Widget from a file.
(This requires pillow, or that magicgui was installed as ``magicgui[image]``)
"""
from pathlib import Path
from magicgui.widgets import Image
try:
test_jpg = Path(__file__).parent.parent.parent / "images" / "_test.jpg"
except NameError: # hack... |
546b15bc1d5954a00b22200c1c833be56e031daf694f228ba302c31f7050e0a4 | Python | 511 | 28 | # -*- coding: utf-8 -*-
import sys
import unittest
sys.path.append('..')
from datasets import load_dataset
class DatasetTestCase(unittest.TestCase):
def test_data_diff(self):
# Predict embeddings
srcs = []
trgs = []
labels = []
for term in range(100):
srcs.a... |
5593945ad1f75550936c4fef35d92c11eca3a1a08b3dd7755ea67d94303a4736 | Python | 511 | 16 | #!/usr/bin/env python
"""DEPRECATED shim -> `morphometrics histogram`.
This script has moved into the installable `surface_morphometrics` package and is
now invoked as `morphometrics histogram ...`. This thin wrapper forwards to that
command and will be removed in a future release.
"""
import sys
from surface_morphom... |
639a8ac3b4101387dfe6a7b592cc3b7e8876b321784d466b7af7b90c77d12624 | Python | 511 | 7 | from brainscore_vision import model_registry
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from .model import get_model, get_layers
model_registry['AdvProp_efficientnet-b2'] = lambda: ModelCommitment(identifier='AdvProp_efficientnet-b2',
... |
878d8486ffcf96c5082e690e8656e83fe2fcb6829b289b36b9b8aa80ec7bf3ab | Python | 511 | 7 | from brainscore_vision import model_registry
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from .model import get_model, get_layers
model_registry['AdvProp_efficientnet-b8'] = lambda: ModelCommitment(identifier='AdvProp_efficientnet-b8',
... |
8d5005f6030cc1167a5bff38f148da1fc7386633f73c9e32fbd71245a1622236 | Python | 511 | 10 | from brainscore_vision import load_metric
from .benchmark import load_assembly as load_rajalingham2018, _DicarloRajalingham2018
class RajalinghamMatchtosamplePublicBenchmark(_DicarloRajalingham2018):
def __init__(self):
super(RajalinghamMatchtosamplePublicBenchmark, self).__init__(
metric=load... |
162b7e2597e893adabd431415dae37262a0b663b570f953726f37c23f93ebcf0 | Python | 512 | 18 | import numpy as np
__all__ = ['calc_wrap_distance']
def calc_wrap_distance(x: np.ndarray,
y: np.ndarray,
upper_bound: int = 150) -> np.ndarray:
"""calculate the distance between two points in the wrapped environment"""
if x.ndim != 1 or y.ndim != 1:
rais... |
301c26fd931697bb8aa5e9b9ccbd108b2e605cad35988d8757b55b1551cf3cc9 | Python | 512 | 19 | from os.path import join, dirname, abspath
import json
from auditwheel import policy
def add_whitelisted_libs():
policies = None
with open(join(dirname(abspath(policy.__file__)), "manylinux-policy.json")) as f:
policies = json.load(f)
for p in policies:
p["lib_whitelist"].append("libxcb.... |
48dcd6f1c3acbececd6f3f3edf6189ff0d9ebbfdf5bc5028010b4330ca887d37 | Python | 512 | 21 | import torch
__all__ = ['pixel_norm']
def pixel_norm(x, dim=1, eps=1e-8):
"""Pixel normalization.
References:
- https://papers.nips.cc/paper/2012/file/c399862d3b9d6b76c8436e924a68c45b-Paper.pdf ("Local Repose Norm")
- https://arxiv.org/pdf/1710.10196.pdf
Args:
x: Input Tensor.
... |
50a8dbec3cc22068bdd7bc46b8610a6db225a998827005b38d7eacba3a85b6cb | Python | 512 | 17 | from eir.setup.schema_modules.tensor_broker_schemas import (
TensorBrokerConfig,
TensorMessageConfig,
)
def set_up_tensor_broker_config(
tensor_broker_config: dict,
) -> TensorBrokerConfig | None:
if not tensor_broker_config:
return None
tensor_message_configs = []
for message_config ... |
d21ff127b0909e54f1179854a5cf3558f43441a06da2e1bc78a2b54733c603eb | Python | 512 | 19 | r"""Graph sampler package."""
from .base import (BaseSampler, NodeSamplerInput, EdgeSamplerInput,
SamplerOutput, HeteroSamplerOutput, NegativeSampling,
NumNeighbors)
from .neighbor_sampler import NeighborSampler
from .hgt_sampler import HGTSampler
__all__ = classes = [
'BaseS... |
1023ea312ee90d89aa23ef0e03119929c64fe352cc129c2255d174d95d7f2d64 | Python | 513 | 7 | from brainscore_vision import model_registry
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from .model import get_model, get_layers
model_registry['antialiased-rnext101_32x8d'] = lambda: ModelCommitment(identifier='antialiased-rnext101_32x8d',
... |
35801e4ea5f2934ae278d8e707b835c7694f6a99562fa2b1fa9c654dc7e210e4 | Python | 513 | 19 | import unittest
from ogo.cli.ReplaceLabels import ReplaceLabels
class Test_ReplaceLabels(unittest.TestCase):
def setUp(self) -> None:
""" Use this method to prep data or files for other tests, if necessary. """
pass
def tearDown(self) -> None:
""" Use this method to clean up after t... |
3767a4c69fd457a356b2c467786c3173d9c24728366357d4da3107e023884463 | Python | 513 | 8 | from brainscore_vision import model_registry
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from .model import get_model, get_layers
model_registry['first_dev_learning_simple2'] = lambda: ModelCommitment(identifier='first_dev_learning_simple2',
... |
c313395c460bbbd4e499c3c32502eef648a65df93aca4641577fb096c30acd27 | Python | 513 | 19 | """
This sub-package provides interfaces to external image processing software
Supported functionality:
* Ilastik interface
Main routines for ilastik classification are:
:func:`~ClearMap.Imageprocessing.Ilastik.classifyPixel`,
:func:`~ClearMap.Imageprocessing.Ilastik.classifyCells`.
"""
#:copyright: Copyright 20... |
4890d7b3d28fc8a882cb9177d2488c76777780ecb21e98a4a3cd5e9b0b71e846 | Python | 514 | 21 | """Remesh a surface."""
import SVMTK as svm
from pathlib import Path
if __name__ == "__main__":
print("Start ",__file__)
outdir = Path("results")
outdir.mkdir(exist_ok=True)
pig = svm.Surface("../Data/pig.off")
target_edge_length = 0.04
nb_iter = 3
protect_border = True
pig.isotro... |
64145ab6590de517acc6ae956565ba84c6fa9fa975e140188583f1824e79203d | Python | 514 | 17 | import matplotlib.pyplot as plt
def plot_img_and_mask(img, mask):
classes = mask.shape[0] if len(mask.shape) > 2 else 1
fig, ax = plt.subplots(1, classes + 1)
ax[0].set_title('Input image')
ax[0].imshow(img)
if classes > 1:
for i in range(classes):
ax[i + 1].set_title(f'Output ... |
659f9aaf24798efe807c5879f370c3ce0be7c66f08abc8786f06cda4922e501a | Python | 514 | 21 | from __future__ import annotations
import numpy as np
from brainways.utils.image import ImageSizeHW
class BrainwaysTransform:
def transform_image(
self,
image: np.ndarray,
output_size: ImageSizeHW | None = None,
mode: str = "bilinear",
) -> np.ndarray:
raise NotImplem... |
14768974593daf11932b388f1755aacdcf51a91a6051a59e634a7cfa342a0745 | Python | 515 | 18 | from django.db import migrations
def update_contenttypes_table(apps, schema_editor):
content_type_model = apps.get_model("contenttypes", "ContentType")
content_type_model.objects.filter(app_label="git").update(app_label="dataset_repo")
class Migration(migrations.Migration):
dependencies = [
("d... |
58a7c6ae8c7b703eccf3873f261a77399377d0bcedb3ad78ed20bae31090a6cd | Python | 515 | 12 | from brainscore_vision import model_registry
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from .model import get_model, get_layers
model_registry['evresnet_50_4'] = lambda: ModelCommitment(
identifier='evresnet_50_4',
activations_model=get_model('evresnet_50_4'),
layers=... |
7487f550092a90876ce316ded6c5998c3318cd1da00c43038b0cd78324ce4115 | Python | 517 | 13 | from brainscore_vision import model_registry
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from .model import get_layers, get_model
model_registry["deepeisnn_ei_cifar10_resnet18"] = lambda: ModelCommitment(
identifier="deepeisnn_ei_cifar10_resnet18",
activations_model=get_m... |
7f88684b128022796403af6563f9f9b0c802c7babbc8b4bea887103454299e54 | Python | 517 | 19 | import math
import torch
class SinusoidalPosEmb(torch.nn.Module):
def __init__(self, dim):
super().__init__()
self.dim = dim
def forward(self, x):
x = x.squeeze() * 1000
assert len(x.shape) == 1
half_dim = self.dim // 2
emb = math.log(10000) / (half_dim - 1)
... |
e65818599823e10cbf3db38d543eb8ad8bbc26c682d6f1e95054ff26545d0b5d | Python | 517 | 15 | import unittest
import base
class Test1(base.BaseScriptTest, unittest.TestCase):
command_line = "./scripts/maf_chunk.py 1 ${out_dir}"
input_stdin = base.TestFile(filename="./test_data/maf_tests/mm8_chr7_tiny.maf")
out_dir = "./test_data/maf_tests/chunk1"
class Test2(base.BaseScriptTest, unittest.TestCa... |
f1c1988c5712f092611cba340401f85df9219f08d3861f28341699feea6fce6a | Python | 517 | 15 | from neuromaps.datasets import fetch_annotation
from neuromaps import transforms
neurosynth = fetch_annotation(source='neurosynth')
fslr = transforms.mni152_to_fslr(neurosynth, '32k')
fslr_lh, fslr_rh = fslr
print(fslr_lh.agg_data().shape)
import nibabel as nib
# Save the left hemisphere data as a GIFTI file
nib.sav... |
05c6e5595dc92178a5040beac352d57d6d9c669160e725717f17da63e87ab8bc | Python | 518 | 8 | from brainscore_vision import model_registry
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from .model import get_model, get_layers
model_registry['hmax_v3_adj2'] = lambda: ModelCommitment(identifier='hmax_v3_adj2',
activations_... |
bf4b5172ea873d2df5b67227303652501e32fc6ef6c81206b3fa82a86f656d2a | Python | 518 | 19 | import unittest
from ogo.util.echo_arguments import echo_arguments
class Test_Echo_Arguments(unittest.TestCase):
def setUp(self) -> None:
""" Use this method to prep data or files for other tests, if necessary. """
pass
def tearDown(self) -> None:
""" Use this method to clean up aft... |
6222f99b408af8e412a10d64472d9e08e32a8a3c7e68098d513d793ada81192c | Python | 519 | 16 | # optimizer
max_lr=1e-4
optimizer = dict(type='AdamW', lr=max_lr, betas=(0.95, 0.99), weight_decay=0.01,)
# learning policy
lr_config = dict(
policy='OneCycle',
max_lr=max_lr,
div_factor=25,
final_div_factor=100,
by_epoch=False,
)
optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2))
# r... |
e77bb95ede1e7c95917d9826fa9a098c59244949bc1abaf10ca0ee79480f5b3d | Python | 519 | 19 | import requests
def send_request(url: str, payload: list[dict]) -> dict:
response = requests.post(url, json=payload)
response.raise_for_status()
return response.json()
payload = [
{
"imdb_reviews_windowed": "This movie was great! I loved it!",
"imdb_reviews_longformer": "This movie w... |
f78876fec48992d4ccc25d88077a556e11d28eb576a9ac9e23eaacfcbc04e568 | Python | 519 | 21 | import pandas as pd
split = pd.read_csv('/data2/whr/czl/TwiBot22-baselines/datasets/cresci-rtbust-2019/split.csv')
user = pd.read_csv('./user_feature.csv')
user_list = list(user['id'])
del_list = []
for i,r in split.iterrows():
if r[0] not in user_list:
del_list.append(i)
print(len(del_list))
split.dr... |
faffbc515b45210c47a7ca04e99b0a456f5a1f616de20611ad5423c69db87c8a | Python | 519 | 16 | from pathlib import Path
import yaml
import shutil
from deep_events.prepare_training import prepare_for_prompt
FILEPATH = Path(__file__).parents[0]
with open(FILEPATH / "test_database/settings.yaml", "r") as stream:
COLLECTION = yaml.safe_load(stream)["COLLECTION"]
def test_prep_prompt():
folder = FILEPATH /... |
1a639e490a5c60e703a4993ffc0740b6252f6d4af7d9722a00077a87826c4b0c | Python | 520 | 18 | import unittest
from deepgo.utils import Ontology
class TestOntologyClass(unittest.TestCase):
@classmethod
def setUpClass(self):
self.go = Ontology('data/go.obo', with_rels=True)
def test_ontology_init(self):
"""
Test if Ontology class attributes are initialized
"""
... |
1b850b6f5d7d7729a71a9cfa18d27810d999c3fda9264b552cc1a45ece6eb1bb | Python | 520 | 16 | #!/usr/bin/env python
"""DEPRECATED shim -> `morphometrics make_meshes`.
This script has moved into the installable `surface_morphometrics` package and is
now invoked as `morphometrics make_meshes ...`. This thin wrapper forwards to that
command and will be removed in a future release.
"""
import sys
from surface_mor... |
6f87cec2536fad797d9eb2c42ee95926f70313342ac461b0da9125184594e861 | Python | 520 | 5 | from brainscore_vision import model_registry
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from .model import get_model, get_layers
model_registry['deit3_base_patch16_224_fb_in22k_ft_in1k_gram_aligned_dinov3'] = lambda: ModelCommitment(identifier='deit3_base_patch16_224_fb_in22k_ft_i... |
c7e5819414deaa6fb1aa6ba4fafc91e3ddf78c56937400d2d3fd8320159976b9 | Python | 520 | 13 | from brainscore_vision import model_registry
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from .model import get_model, get_layers
model_registry['eicircuit_resnet18_abs_group_20260921'] = lambda: ModelCommitment(
identifier='eicircuit_resnet18_abs_group_20260921',
activat... |
127e0101e407ae01dcea988c0d1a4e1049f5c0f72d6f3987358550b1355297a3 | Python | 521 | 25 | # -*- coding: utf-8 -*-
# @Author : LG
from pycocotools import coco as mscoco
import os
import matplotlib.pyplot as plt
import PIL.Image as Image
coco_json = ''
coco_image_root = ''
coco = mscoco.COCO(coco_json)
imgids = coco.getImgIds()
for imgId in imgids:
img = coco.loadImgs([imgId])[0]
annids = coco.ge... |
6a64095da36b3b43f2ba51feaf9c0b7932113ac21b894ffc623e671d05cc4a50 | Python | 521 | 18 | import unittest
from toolkit.utils import Ontology
class TestOntologyClass(unittest.TestCase):
@classmethod
def setUpClass(self):
self.go = Ontology('data/go.obo', with_rels=True)
def test_ontology_init(self):
"""
Test if Ontology class attributes are initialized
"""
... |
891a8bd44c2fad4cd0b54b5eb24b01ae4ce698ee7bd7f1e6a17e288cc59d8164 | Python | 521 | 17 | from low_rank_data import XY, XY_incomplete, missing_mask
from common import reconstruction_error
from fancyimpute import SoftImpute
def test_soft_impute_with_low_rank_random_matrix():
solver = SoftImpute()
XY_completed = solver.fit_transform(XY_incomplete)
_, missing_mae = reconstruction_error(
X... |
1179df89bc07e08f3f8e988f4a0acccd3f9b2fb8afd67839a45aa82bb9959ce6 | Python | 522 | 9 | from brainscore_vision import model_registry
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from .model import get_model, get_layers
model_registry['cvt_cvt-13-384-in22k_finetuned-in1k_4_LucyV4'] = \
lambda: ModelCommitment(identifier='cvt_cvt-13-384-in22k_finetuned-in1k_4_LucyV4... |
b3a39fa993bba96ce41104abb7574567da6cfc1fe4932390a666c2198eb234b0 | Python | 522 | 9 | from brainscore_vision import model_registry
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from .model import get_model, get_layers
model_registry['cvt_cvt-21-384-in22k_finetuned-in1k_4_LucyV4'] = \
lambda: ModelCommitment(identifier='cvt_cvt-21-384-in22k_finetuned-in1k_4_LucyV4... |
f596fad40962fc250f5646c3524745bbc3dfc617d9c1dc7c43afb2e26bee1b94 | Python | 522 | 24 | from abc import ABC, abstractmethod
from numpy.typing import NDArray
class Normalizer(ABC):
"""
Abstract base class for image normalization methods.
"""
def __init__(self):
super().__init__()
@abstractmethod
def normalize(self, image) -> NDArray:
"""
Normalize the inp... |
fc233a4be3b83e53c5389f02bd5ffdf4bcafbbc67ebde38562a60b99c595ca80 | Python | 522 | 13 | from brainscore_vision import model_registry
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from .model import get_layers, get_model
model_registry["deepeisnn_ei_imagenet_resnet18"] = lambda: ModelCommitment(
identifier="deepeisnn_ei_imagenet_resnet18",
activations_model=get... |
1f6bc2ed861b60ee2aa91479f83a53b21e73c9b08bd193ce798d657d04479093 | Python | 523 | 24 | #!/usr/bin/python3
#
class Line:
"""
lists of connected edges
"""
def __init__(self, e=None):
self.eles = set() # elements with a node in line
self.edge = set() # edges forming line
self.nodes = set() # nodes forming line
if e:
self.edge.add(e)
... |
603ebbc224284d010aa291e48e373075f6e8594f39d5fe917981b014ecf19108 | Python | 523 | 16 | #!/usr/bin/env python
from setuptools import setup, find_packages
from os import path
here = path.abspath(path.dirname(__file__))
setup(
name='staticnet',
version='0.0.1',
description='PyTorch implementation of static neural networks for system identification',
author='Fabian Sinz, Edgar. Y. Walker',
... |
8e7abc32df1ccc37621ad912065f462ddd452633617603965c7d5470430f6548 | Python | 524 | 13 | # Copyright (c) OpenMMLab. All rights reserved.
from .backbones import * # noqa: F401,F403
from .builder import (BACKBONES, HEADS, LOSSES, DEPTHER, build_backbone,
build_head, build_loss, build_depther)
from .decode_heads import * # noqa: F401,F403
from .losses import * # noqa: F401,F403
from .... |
99bbec8064d4a433abd239c26044664b9a0123a9ddc0822cf76e93cf12a56dd8 | Python | 524 | 18 | """MNI152 standard brain surfaces.
Pre-extracted surfaces from the MNI152 T1 1mm brain using FSL BET.
Files
-----
- smri.nii.gz: MNI152 T1 structural MRI.
- inskull_mesh.nii.gz, inskull_mesh.vtk, inskull.png
- outskull_mesh.nii.gz, outskull_mesh.vtk, outskull.png
- outskin_mesh.nii.gz, outskin_mesh.vtk, outskin.png
-... |
b1d62242896b443609a2698a6562a4cc03ab5e0edfc0dcb3e61c9c32b9bdfeae | Python | 524 | 16 | #!/usr/bin/env python
"""DEPRECATED shim -> `morphometrics sample_density`.
This script has moved into the installable `surface_morphometrics` package and is
now invoked as `morphometrics sample_density ...`. This thin wrapper forwards to that
command and will be removed in a future release.
"""
import sys
from surfa... |
125e000f61fef58dccf10d16714d8de2b399881a4b7c2de860ebe8f34562e0fa | Python | 525 | 20 | from importlib.metadata import version
def get_home():
import os
""" Set a user-writeable file-system location to put files. """
if 'SCILPY_HOME' in os.environ:
scilpy_home = os.environ['SCILPY_HOME']
else:
scilpy_home = os.path.join(os.path.expanduser('~'), '.scilpy')
return scilpy... |
c51cd63117c5e66ecd2d61976c2cf5897e5d4e0ba7c38ed95e0a86c6ce5f56ec | Python | 525 | 7 | from brainscore_vision import model_registry
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from .model import get_model, get_layers
model_registry['custom_model_cv_18_dagger_408'] = lambda: ModelCommitment(identifier='custom_model_cv_18_dagger_408',
... |
28fb09b8c0283d15483bd9e03603f89ff8f276d316a35053d1d33b3a59357151 | Python | 526 | 15 | # -*- coding: utf-8 -*-
"""
Created on Thu Oct 20 19:39:19 2022
@author: tianj
"""
import torch
def save_G_network(save_path,network, epoch_label):
save_filename = save_path+'resnet_130ch_sd_refined_130ch64ch_ep'+str(epoch_label)+'.pt'
torch.save(network.state_dict(), save_filename)
def save... |
b4694e74fdf66880fde5ebbeac8a3eb303781bf04eb8dfa05be14ff30cf7987d | Python | 526 | 25 | # -*- coding: utf-8 -*-
"""
Created on Fri Oct 21 12:20:03 2022
@author: tianj
"""
import torch
import random
import numpy as np
def setup_seed(seed):
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
np.random.seed(seed)
random.seed(seed)
torch.backends.cudnn.deterministic... |
7fdc0b3e3442f050ee020376c01fd21215fa659955ed2c90b7c2cd7ad958aab9 | Python | 527 | 20 |
import torch
ckp = torch.load('nfs/saves/binsformer/binsformer_swinl_nyu.pth')
new_state_dict = {}
params = ckp['state_dict']
for key, val in params.items():
if 'decode_head.transformer_decoder.decoder.' in key:
new_key = 'decode_head.transformer_decoder.' + key.split('decode_head.transformer_decoder.d... |
213e1634d42ced8f01bf6e2cabb61df621b1bf8af8882986e71c7dd4af03bd4c | Python | 528 | 20 | from pathlib import Path
from typing import TYPE_CHECKING
import yaml
from eir.setup.config_setup_modules.output_config_initialization import (
init_output_config,
)
if TYPE_CHECKING:
from eir.setup.schemas import OutputConfig
def load_output_config_from_yaml(output_config_path: Path) -> "OutputConfig":
... |
accbb108e057d47487ff5f4bdb86e2596ddd736dd43643999c72158092ee2044 | Python | 528 | 30 | import sys
sys.path.append('../')
import jieba
import jieba.analyse
from optparse import OptionParser
USAGE = "usage: python extract_tags.py [file name] -k [top k]"
parser = OptionParser(USAGE)
parser.add_option("-k", dest="topK")
opt, args = parser.parse_args()
if len(args) < 1:
print(USAGE)
sys.exit(1... |
dfc31835c0454c385b134a16c45d8d1dabc295285c7e4018654ba09632cdfa11 | Python | 528 | 16 | # This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press ... |
ff18f640cd5733f8c629c0c1bc73c9ee9e1e3d5a6b617776c94fe6c458892cb5 | Python | 528 | 19 | #!/usr/bin/env python
"""
Test setting the focus lock mode.
"""
from storm_control.test.hal.standardHalTest import halTest
def test_hal_tcp_sflm_11():
halTest(config_xml = "none_tcp_config.xml",
class_name = "SetFocusLockMode1",
show_gui = True,
test_module = "storm_control.tes... |
10952fad87328e8ec130ff39e3901ee05d24010aa0b8cca53b7d84dd86643b9f | Python | 529 | 22 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import cvat_sdk.auto_annotation as cvataa
import cvat_sdk.models as models
import PIL.Image
spec = cvataa.DetectionFunctionSpec(
labels=[
cvataa.label_spec("car", 0),
],
)
def detect(
context: cvataa.DetectionFunctionContext, i... |
2863334c22000162acbb592eb0d174811b31de5d6ffd6b4bb6d2f53663e8a0ee | Python | 529 | 22 | """SFCN with a single linear output for regression."""
from tensorflow import Tensor
from tensorflow.keras.layers import Dense
from .sfcn import SFCN
class RegressionSFCN(SFCN):
"""SFCN for continuous regression tasks.
The prediction head is a single Dense unit with linear activation.
"""
@staticm... |
6aea3f48a3b1e1ce1794ae759794e2da02eadcd565fa1ebee643b0c2a0b2f4a1 | Python | 529 | 17 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from django.conf import settings
from django.db import models
class UserGrowthData(models.Model):
user = models.OneToOneField(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name="growth_data",
)
git... |
c2884b6afb7c9a6a2825510f109f26aa2824986641bd4852c350f8fb8699967f | Python | 529 | 9 | from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from brainscore_vision import model_registry
from .model import get_layers,get_model
from .helpers.vonecornets import VOneCORnetCommitment, _build_time_mappings, CORNET_S_TIMEMAPPING
model_registry['VOneCORnet-S'] = \
lambda: VOneCOR... |
69a4fce63ad8e9a550389e5be61c8aebfbc322d405281f49a57586072fb085a8 | Python | 531 | 24 | import torch
import numpy as np
from parms_setting import settings
from data_preprocess import load_data
from train import train_model
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
# parameters setting
args = settings()
args.cuda = not args.no_cuda and torch.cuda.is_available()
np.random.seed(args.seed)
torch.... |
dc9b02cdc3a9ef760b615080e03980e72e688ccea6750275672ecfaa9ab8db32 | Python | 532 | 27 | import requests
def send_request(url: str, payload: list[dict]):
response = requests.post(url, json=payload)
return response.json()
payload = [
{
"poker_hands": {
"S1": "3",
"C1": "12",
"S2": "3",
"C2": "2",
"S3": "3",
"C3":... |
f4e55634bd9b03bd22dc26ca24f6f43fb4e0e7f5a3cdfd15bac26aad0c75648d | Python | 532 | 17 | import matplotlib.pyplot as plt
# 8个数,从左到右为第一个点的x,y,第二个点的x,y,第三个点的x,y,第四个点的x,y
points = [622.411 ,689.883 ,602.854 ,700.151 ,628.767 ,684.016 ,618.01 ,689.395]
# 创建一个751*751像素的白色背景
fig, ax = plt.subplots(figsize=(7.51, 7.51), facecolor='white')
# 绘制四个点
ax.plot(points[0], points[1], 'ro')
ax.plot(points[2],... |
7b9bba9c7a7b8bd8c97fa44bbf438b4e5bf7f926117cfe939d74c211238661ce | Python | 534 | 22 | import pandas as pd
import numpy as np
import random
df = pd.read_csv('csv/ukb_data_v2.csv')
df_heal = df[df['is_healthy'] == 1].copy()
seed = 12345
train = np.ones([len(df_heal)], dtype=np.int32)
sample_size = int(len(df_heal) * 0.1 + 1)
# 10% of the healthy people for testing
random.seed(seed)
sampl... |
e50492117c520294cb293fab2d6970482193dbcba86a1969822e2e36e2a751b0 | Python | 534 | 13 | from brainscore_vision import metric_registry
from .metric import Dimensionality
metric_registry['factor_dimensionality'] = Dimensionality
BIBTEX = """@inproceedings{esser2020disentangling,
title={A disentangling invertible interpretation network for explaining latent representations},
author={Esser, Patrick and ... |
3709afee5abefe5491da42f0b8e2f62c6ff281984136a08bd424d3d0d4bf6b9a | Python | 535 | 12 | from brainscore_vision import model_registry
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from .model import get_model, get_layers
model_registry['evresnet_50_6'] = lambda: ModelCommitment(
identifier='evresnet_50_6',
activations_model=get_model('evresnet_50_6'),
layers=... |
37edf768d2d6189433466bd52044cc16fbef7ca81ebb9b385e16452482b5f237 | Python | 535 | 21 | import functools
import seisbench
def log_lifecycle(level):
"""
Logs the invocation and termination of a function to seisbench.logger. Should be used as a decorator.
"""
def decorator(func):
@functools.wraps(func)
def f(*args, **kwargs):
seisbench.logger.log(msg=f"Startin... |
77de019ebe56e1bda3f6d04e1f01db80b351c8e83122832eec3c558c29a4f720 | Python | 535 | 12 | from brainscore_vision import model_registry
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from .model import get_model, get_layers
model_registry['evresnet_50_8'] = lambda: ModelCommitment(
identifier='evresnet_50_8',
activations_model=get_model('evresnet_50_8'),
layers=... |
a47a6dea8bf668440a48edb18bf6ff9d3796e1574be3bbcdda4cf1799a4a83a9 | Python | 535 | 21 | import sys
import os
# List of directories to be added to sys.path
directories = ['components',
'data',
'explanation',
'features',
'networks',
'notebook',
'output',
'train',
'... |
c1b84bf27d3da3b600c753cedde43703192fc67d9502b04a131213e31494afbc | Python | 535 | 12 | from brainscore_vision import model_registry
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from .model import get_model, get_layers
model_registry['evresnet_50_7'] = lambda: ModelCommitment(
identifier='evresnet_50_7',
activations_model=get_model('evresnet_50_7'),
layers=... |
0167a1cad879a09c49662552e53df43ce31882986cf3863a7e238ab6b035835c | Python | 536 | 19 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from django.db.models.signals import post_save
from django.dispatch import receiver
from cvat.apps.iam.models import User
from .models import UserGrowthData
@receiver(post_save, sender=User)
def create_user_growth_data(instance: User, created: bo... |
069384938481ed80fcc43c5c6355612822d0ba8b0a5316e5898b0d061d38617f | Python | 536 | 19 | """Constants that user will deal with"""
class PositionScale():
# scale the positional value of array_row, array_col from adata.obsm["spatial"]
MERFISH_SCALE_FACTOR = 500
SEQFISH_SCALE_FACTOR = 400
SLIDESEQV2_SCALE_FACTOR = 500
class SpotSize():
MERFISH_SPOT_SIZE = 20
SEQFISH_SPOT_SIZE = 0.03
... |
b0f0ae71aacebedd195e94780a0bc4277115ebe6da32e191e9fdb25f1c276ed0 | Python | 536 | 18 | import sys
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import Qt
from lyroi.gui.main_window import MainWindow
from lyroi.utils import setup_lyroi
def main():
setup_lyroi()
QApplication.setAttribute(Qt.ApplicationAttribute.AA_EnableHighDpiScaling, True)
QApplication.setAttribute(Qt.Applicatio... |
207bd8f9e328db1368275fb15fa6ef093a5e7ee90dbc4798e6fa19e90b87788e | Python | 537 | 17 | from low_rank_data import XY, XY_incomplete, missing_mask
from common import reconstruction_error
from fancyimpute import IterativeSVD
def test_iterative_svd_with_low_rank_random_matrix():
solver = IterativeSVD(rank=3)
XY_completed = solver.fit_transform(XY_incomplete)
_, missing_mae = reconstruction_erro... |
35403a72700f746cc5177ebe8f7aadd1faeb7c448d71e785d8cbc799739a8680 | Python | 537 | 19 | import unittest
from ogo.cli.IsotropicResampling import IsotropicResampling
class Test_IsotropicResampling(unittest.TestCase):
def setUp(self) -> None:
""" Use this method to prep data or files for other tests, if necessary. """
pass
def tearDown(self) -> None:
""" Use this method t... |
0b9b92fbe3f68615d7f1bed5d4389b1c04be4fb870112168add8998f08b44be0 | Python | 538 | 33 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
class BasicError(Exception):
"""
The basic exception type for all exceptions in the library
"""
class InvalidImageError(BasicError):
"""
Indicates an invalid image
"""
class InvalidVideoError(BasicError):
"""
Indi... |
408d3a683d08d20c830cca9f06aff32fda6c498915d01d1dd071da6207441acd | Python | 538 | 21 | import numpy as np
import csv
import random
from psychopy import visual, core, data, event
font = 'Courier New'
anchorHoriz = 'center'
window = visual.Window(units='pix', color='black', fullscr=True)
word = visual.TextStim(window, text='', font=font, anchorHoriz=anchorHoriz, height=30)
photodiode = visual.Rect(window... |
47f9137b5bfcc7edcff45b5042b00328d143d30109b175da45d5cc95e0e6fb08 | Python | 538 | 21 | import sys
from cx_Freeze import setup, Executable
build_exe_options = {
"packages": ["os", "tkinter", "ui", "numpy", "pandas", "matplotlib", "h5py", "scipy", "PIL"],
"include_files": ["media/logoClair.ico", "media/LogoVclair.png"],
}
exe = Executable(
script="main.py",
base="Win32GUI", # no console
... |
c2b88202fe82aa46541dc053bcbe1798bb0380919ffc26d8a4b6e1bf7c2c0677 | Python | 538 | 16 | """Lightweight calculator defaults shared by schemas and the UI."""
import importlib.util
def mace_polar_available() -> bool:
"""Detect the Polar add-on without importing engines or loading weights."""
try:
return importlib.util.find_spec("graph_longrange") is not None
except (ImportError, ValueE... |
3229891ef52e10cefbaf6d00c099a36a8773f6ae1546c30eb639472aab6b1525 | Python | 539 | 16 | import torch
import numpy as np
from datetime import datetime
import os
import scipy.io as io
# open file and record derived contexts
def context_recd(path):
testlog = open(path + '/test_context.md', mode='a', encoding='utf-8')
print('epoch: %d' % (epoch), file=testlog)
print('true contexts for ... |
64e4a05fae56158b1e2db179acb689274af8e131e8a3a3453a8b5c2dedfd244b | Python | 539 | 16 | #!/usr/bin/env python
"""DEPRECATED shim -> `morphometrics measure_thickness`.
This script has moved into the installable `surface_morphometrics` package and is
now invoked as `morphometrics measure_thickness ...`. This thin wrapper forwards to that
command and will be removed in a future release.
"""
import sys
from... |
da06553b33b0606a0874727623668ef7be301fbb402631d3d2f78652c54eb788 | Python | 539 | 16 | #!/usr/bin/env python
"""DEPRECATED shim -> `morphometrics accept_refinement`.
This script has moved into the installable `surface_morphometrics` package and is
now invoked as `morphometrics accept_refinement ...`. This thin wrapper forwards to that
command and will be removed in a future release.
"""
import sys
from... |
f6a1e28f48373d13e26e75b741eae3a9c91a86f7fa67237a52e981665522c56b | Python | 539 | 16 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import importlib
from django.test import SimpleTestCase
# The lxml and xmlsec wheels bundle libxml2 independently. Importing python3-saml ensures
# that their bundled versions are compatible and prevents SAML failures at runtime.
class SamlDepende... |
00473aa0c4bf2c6b2e53d3d0e11b12ff21b1f27267127b1c02bf4ab183318b29 | Python | 540 | 22 | # Generated by Django 3.2.18 on 2023-03-19 12:52
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("engine", "0065_auto_20230221_0931"),
]
operations = [
migrations.AlterField(
model_name="cloudstorage",
name="crede... |
649ab81c821a924db9facc291d7b4c22a902e28d91980d58c392584ab9e6ff31 | Python | 541 | 25 | #!/usr/bin/env python
"""
Test move stage.
"""
from storm_control.test.hal.standardHalTest import halTest
def test_hal_ms_1():
halTest(config_xml = "none_tcp_config.xml",
class_name = "MoveStage1",
test_module = "storm_control.test.hal.tcp_tests")
def test_hal_ms_2():
halTest(confi... |
0c09bf92f356b7e37f001e78f554e0b416b1e7b193efcf0212b4a873a3a0ee99 | Python | 542 | 26 | """Public configuration API for Waven."""
from __future__ import annotations
from Waven.config import (
DEFAULT_ANALYSIS_PARAMS,
DEFAULT_GABOR_PARAMS,
AnalysisConfig,
GaborConfig,
PipelineConfig,
default_pipeline_config,
parse_literal,
parse_optional_path,
parse_path,
)
__all__ = [... |
612086456d1b6dd22c8d04f61392a18f571e631e61bcc49bf96c79a3a77e06fc | Python | 542 | 22 | import setuptools
setuptools.setup(
name='edge2vec',
description='involving edge semantics into node embedding ',
long_description='transition matrixs with skip gram model',
url='https://github.com/RoyZhengGao/edge2vec',
license='BSD 3-Clause License',
packages=setuptools.find_packages(),
p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.