sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
a69c46af7df65abb8cf12a3171ac1bef8fecc791bfb8f085bb57aacb248ae7ab
Python
2,933
60
# GoPro should be connected via wifi # make sure the 2.4ghz connection is selected and connect via the computer's wifi # need to cite this github repo https://github.com/KonradIT/gopro-py-api from goprocam import GoProCamera, constants # imports GoPro capabilities gpCam = GoProCamera.GoPro() # defines gpCam as variabl...
56294e3264d0a04d43530a40f13f7189027c003f8e231ca317087b53533824d3
Python
2,934
104
# %% ''' Want to find how long occured between MRI and behavioural session ''' import numpy as np import pandas as pd import datetime import glob from tqdm import tqdm import sys import pydicom as dicom import nibabel.nicom.csareader as csareader sys.path.insert(0, '..') # import my own code from functions.data_helpe...
80e4085044101edb97455804e42bd46c4f0d5e5ff24219189a58009dc654492c
Python
2,934
109
""" Larvaworld : A Drosophila larva behavioral analysis and simulation platform """ from __future__ import annotations import os __author__ = "Panagiotis Sakagiannis" __license__ = "MIT License" __copyright__ = "2024, Panagiotis Sakagiannis" # TODO : the automatic version naming requires the package itself to be in...
f898fd71b9fa6bd9d7681638450182d9bef5a19525038cffc5abfe2be9b0af44
Python
2,936
70
import pandas as pd ARI1952 = r"./data/ari-1952.csv" # 1 ARI1953 = r"./data/ari-1953.csv" # 1 ARI2049 = r"./data/ari-2049.csv" # 2 ARI1885 = r"./data/ari-1885.csv" # 2 ARI1727 = r"./data/ari-1727.csv" # 1 ARPA = r"./data/arpa.csv" # GT class DataCollection: def __init__(self, drop_null:bool=True): ...
2877602a98350cf041f5eb4fb69906d54d314d8a769eafbe7cfa68ddb616b0c3
Python
2,937
71
"""The smooth l1 loss layer for detection related targets""" # pylint: disable=redefined-builtin import torch def smooth_l1_loss(input: torch.Tensor, target: torch.Tensor, beta: float, reduction: str = "none") -> torch.Tensor: """ Smooth L1 loss defined in the Fast R-CNN paper as: | 0.5 * x...
a75e045174b1fc971dbbb03afc82d332f9e91cbf0cb98d4ec1327c76fe7ca97a
Python
2,937
114
#!/usr/bin/env python # coding: utf-8 # In[1]: import tensorflow as tf import tensorflow.keras as keras from tensorflow.keras.layers import Reshape, Input, Flatten, concatenate, Dense, BatchNormalization ,Conv1D,Conv2D,Conv3D,MaxPool1D, MaxPool2D,MaxPool3D, GlobalMaxPool2D, Dropout from tensorflow.keras.optimizers i...
10d09c6c0bce19c9a92d0c006dc95fe181eff2dc2c3a96254a73b07e0127e5c9
Python
2,939
78
from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import numpy as np import pandas as pd import argparse import os import sys import pdb import csv def generate_data(input_csv, binarize=False, head_only=False, head_row...
653213395139e9c75c32a5c456152f397a7df7156d0282e0a74a2e7373cd634d
Python
2,939
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "surface" _...
7cb88db751738e09ce97c88b518ba74462e8dba8b0b2b55947f178fcdf97e5ef
Python
2,939
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "heatmap" _...
862adb93c34b92ece02dc11b0e9ca0743c5bf1646434419222202112fd8d14b6
Python
2,939
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "scatter" _...
8f0434848bad090aaf4637f725853cfc81dbfeadd80e09a5c4a7bf09876c2679
Python
2,939
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "parcats" _...
b34a56ffa388acf20a57fd019d69315510506b595234bab0089b2adaa6c6d1c5
Python
2,939
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "contour" _...
d94f56a59f66d433385ec3a7dc40cbe6ff643d27904e7b675001e0f8a926f7af
Python
2,939
71
import sys # setting path sys.path.append('../TM2_segmentation') import os import numpy as np import nibabel as nib import itk import pandas as pd import tarfile from scripts.preprocess_utils import find_file_in_path # load metadata file input_annotation_file = 'data/csv_files/NYU_2_phenotypic_data.csv' df = p...
f0d0edc10b00364e2d781dcaebc140822a693c02481bcaaeb51c8ffbf4855089
Python
2,939
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "treemap" _...
5edffb7e7effe3c1c9cec1d50168c88f76efaee1fa1c2d22d804bad2164bf15b
Python
2,940
91
'''Example for comparing two populations using the violin plots from their morphometrics''' import neurom as nm import numpy as np import pylab as plt import pandas import seaborn feat_list = ['number_of_neurites', 'number_of_sections_per_neurite', 'number_of_terminations', 'n...
baf287942fa1b3b2ada5b94663d5ef6678f77f23b5a2ad814b1f8c8baa0514a8
Python
2,940
91
#!/usr/bin/env python #========================================================================= # # Copyright NumFOCUS # # 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://...
e5570e2b5f0a3426075962b84924bdfd6f33f4b09457dc2fbe4f24cbc054bfd9
Python
2,940
93
import os from scripts.constants import PARTICIPANT_IDS_FILE, OUTPUT_DIRS, MIN_MS, MAX_MS from scripts.analysis_steps import Analysis, save_aggregated_spoc_patterns from scripts.data_types import Epochs def prepare_output_dirs(): for output_dir in OUTPUT_DIRS: if not os.path.exists(output_dir): ...
26a33b8ec4b36f4bb9857e0925a22ec6c8c147ec898fd1ce5b07871839991958
Python
2,942
98
import collections.abc import hashlib import numbers import pathlib import numpy as np def dict_update_nested(orig_dict, new_dict): """Update nested dictionaries (does not override subdicts)""" for k, v in new_dict.items(): if isinstance(v, collections.abc.Mapping): orig_dict[k] = dict_up...
b76318b70ad0680009cf917f4ab45a011c32848ebf0e803680fe16ac8ee7e0ed
Python
2,943
87
import os import subprocess import pysam from TestUtils import force_str def build_fetch_with_samtoolsshell(fn): retval = os.popen("samtools view {} 2> /dev/null | wc -l".format(fn)).read() return int(retval.strip()) def build_fetch_with_samtoolspipe(fn): FNULL = open(os.devnull, 'w') with subproce...
015b20ad93eefe8ba47efc845a4d86155d0b635b8c329fa4b45691761a8200dd
Python
2,944
103
from . import utils from . import extract_signals def fit_dim_reduce_model(trial_data, model, signal, train_trials=None, fit_kwargs=None): """ Fit a dimensionality reduction model to train_trials Parameters ---------- trial_data : pd.DataFrame data in trial_data format model : ...
9a2b4fdf111cb94470784a5778d593932d97e344d1c10c821eaf474037d5c9bd
Python
2,944
99
""" ==================================================================== ERP EEG decoding in Tangent space. ==================================================================== Decoding applied to EEG data in sensor space decomposed using Xdawn. After spatial filtering, covariances matrices are estimated, then project...
aef9b651e6f627723ef77dda8746f544811b25ede9fc1bbab81b527fdf2d3241
Python
2,944
91
import Code_General_utility_spikes_pickling as util import numpy as np import matplotlib.pyplot as plt from copy import deepcopy as dcp import matplotlib import warnings import logging logging.getLogger('matplotlib.font_manager').disabled = True warnings.filterwarnings("ignore") font = {'family' : 'normal', ...
fde848a07f27400c1b1dbf839a1cb187162f66c2a67745029735b3f11f9a7d2d
Python
2,944
84
import os from math import sqrt import h5py import numpy as np import pandas as pd import scanpy as sc from dca.api import dca from scipy.stats import pearsonr,spearmanr from sklearn.metrics import mean_squared_error from scbig import setup_seed for sparity in ['0.8', '0.85', '0.9', '0.95']: print('-------------...
09a4e7d70014aaa4befde3edb4f146509770a803e9e6ad87a02a681fc4f9ae2c
Python
2,945
83
import numpy as np import nitorch as ni import json from metrics.labels import min_distance_boundary, hausdorff_boundary LABELS_INFRA_MRI = [2] LABELS_SUPRA_MRI = [3] LABELS_INFRA_SPIM = [4, 5] LABELS_SUPRA_SPIM = [1, 2, 3] LABEL_INFRA = 1 LABEL_SUPRA = 2 ROOT = '.' MRI_SEG = ROOT + '/warp2lsfm/slide_center_oct/inf...
3c002903c07bc42ec881688e3c69a83bcce7b6d5bd81c20f308a400b0d5bd2c8
Python
2,945
79
import matplotlib.pyplot as plt import numpy as np from scipy.stats import kde def find_closest(A, target): idx = A.searchsorted(target) idx = np.clip(idx, 1, len(A)-1) left = A[idx-1] right = A[idx] idx -= target - left < right - target return idx def sinaplot(y, pos, ax=None, direction='le...
485046c533cf1a9042452b5e537fe1b323c0a369d95b5d07e5d3fe07c79fc206
Python
2,946
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "sunburst" ...
715bd83797f333305ff21712261f972440fd52599af7134ea03bc559c4bd412d
Python
2,946
105
"""Permutation related functions.""" import numpy as np from scipy.stats import zmap from spiketools.plts.stats import plot_surrogates ################################################################################################### ##################################################################################...
b1e787f249bb506415f996c014adca95f6668548b1fff14a1c60d3baab7e4921
Python
2,946
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "barpolar" ...
e093fd9f7c214fc14928a642bd58de4b8cf17e5716b8390a50084753b11eef7f
Python
2,946
85
import numpy as np import pandas as pd from anndata import AnnData from scipy.sparse import csr_matrix from ._weighting_matrix import ( _PLATFORM, _WEIGHTING_MATRIX, impute_neighbour, weight_matrix, ) def sme_normalize( adata: AnnData, use_data: str = "raw", weights: _WEIGHTING_MATRIX = "...
f42ed2ae67db968e2be3bba8ce33a26b2b91b7ed01c66a473c47e1426543f250
Python
2,946
78
import mxnet as mx from mxnet.gluon import nn from mxnet.gluon.nn import HybridBlock # pylint: disable-all __all__ = ['PAM_Module', 'CAM_Module'] class PAM_Module(HybridBlock): r""" Position attention module from the paper `"Dual Attention Network for Scene Segmentation" <https://arxiv.org/abs/1809.02983...
9d707693904879571eb24096781f00b0d5e04d0c40afb6a024df290a6fa02817
Python
2,947
68
import json import os import time import mne import nibabel import numpy as np from mne.datasets import fetch_fsaverage from atlasreader.atlasreader import read_atlas_peak from mp_dip.utils.mne_freesurf_labels import read_freesurfer_lut # multiprocessing not safe # trying to make it safe while True: try: ...
713bf3f3558b62baa1ad92c57da21dc94fdb6d53c462f829b2187a22adbedcb2
Python
2,948
74
"""03. Multiple object tracking with pre-trained SMOT models ============================================================= In this tutorial, we present a method, called `Single-Shot Multi Object Tracking (SMOT) <https://arxiv.org/abs/2010.16031>`_, to perform multi-object tracking. SMOT is a new tracking framework tha...
4be5fa41d76cdb66d4cc0874c1a91bf0ec3235eec2158ce2fe913473112309bf
Python
2,949
108
# ------------------------------------------------------------------------------ # Copyright (c) Microsoft # Licensed under the MIT License. # Written by Bin Xiao (leoxiaobin@gmail.com) # Modified by Bowen Cheng (bcheng9@illinois.edu) # ------------------------------------------------------------------------------ fro...
7c8fd81c95ac2a019027cf09ff74389c9f2ac224177511bcd7b1fd50341aa169
Python
2,949
97
import argparse import numpy as np from mordred import Calculator, descriptors from rdkit import Chem from rdkit.Chem.rdmolfiles import SDMolSupplier def convert_errors_to_nan(el): """ Remove elements from the Mordred dataframe which are not in float or int format """ if type(el) == bool: ...
b672ee8ed01775c8c6df2c415f1ce9c4c3e71413a366f0d0bad3b86989991905
Python
2,949
64
import torch import torch.nn as nn from torch_geometric.nn import GCNConv, GATConv, SAGEConv, global_max_pool as gmp, global_mean_pool as gep class CPI_regression(torch.nn.Module): def __init__(self, device,emb_size, max_length, n_output=1, hidden_size=128, num_features_mol=78,dropout=None): super(CPI_re...
c993b960a254c86b4451b2556e5047a5893dd1520d31c28f8488f092e4403b7d
Python
2,949
77
''' utils ''' from Bio import SeqIO import torch import numpy as np import os import re from subprocess import call import shlex c_s = ['K', 'R'] def esm_feature(data_list, device): import esm model, alphabet = esm.pretrained.esm1_t12_85M_UR50S() model = model.to(device) batch_converter = alphabet.ge...
d7400f93e46f6e83946cf46d22e0180c77ce8f7c73b328a41e6ad3ab8d772abd
Python
2,951
99
from __future__ import annotations from pathlib import Path import pytest from larvaworld.portal import landing_app as landing_module from larvaworld.portal import serve, workspace_ui from larvaworld.portal.workspace import ( get_active_workspace_path, initialize_workspace, set_active_workspace_path, ) ...
a24205d0654f35514e58149707ac62effcef86931e7e13238494f4e1da55c55f
Python
2,952
81
"""01. Predict depth from a single image with pre-trained Monodepth2 models =========================================================================== This is a quick demo of using GluonCV Monodepth2 model for KITTI on real-world images. Please follow the `installation guide <../../index.html#installation>`__ to inst...
4ae125f73fa59032c566341c3709c400e52f7999d98bd9ffbf8ec71aee74492e
Python
2,953
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "scatter3d" ...
4eab23e42f80bbc77e7eea968d9749168d07dd55a51edf8856d665527cbfe96e
Python
2,953
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "histogram" ...
66d18d5804cda35ff9536b4d7403a867946b76505a174d229237a689d326aafb
Python
2,953
90
#!/usr/bin/env python #========================================================================= # # Copyright NumFOCUS # # 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://...
8f7dc28bea75435acda0cd95d6595c717fedc9f05acfaeb816d3476c92f01bd7
Python
2,953
60
# -*- coding: utf-8 -*- """ Created on Tue Feb 28 16:28:17 2023 @author: cbri3325 """ import SimpleITK as sitk import pandas as pd import os from ImageAnalysisFunctions import getMaxRoi,getMeanRoi data_supradir = 'Path to data directory' subjs_path = [ f.path for f in os.scandir(data_supradir) if f.is...
942bd5b39056fce163567519b5296f0d05d6ac766d56d4ad90b83bac92b34e7c
Python
2,953
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "indicator" ...
ac558471cf7dc02ebdb800b2ed6f8b4294567b3b82c556a573aa878fe6dd00a2
Python
2,953
91
import logging import tarfile from galaxy.datatypes.binary import CompressedArchive from galaxy.datatypes.data import ( get_file_peek, Text, ) from galaxy.datatypes.protocols import DatasetProtocol from galaxy.datatypes.sniff import ( build_sniff_from_prefix, FilePrefix, ) from galaxy.util import nice_...
ad1e3ec403a9d7bc503394d82dfa0f960005ea25dcbb038722aea29e73858fdf
Python
2,953
72
"""Default configs for image classification""" # pylint: disable=bad-whitespace,missing-class-docstring from typing import Union, Tuple from autocfg import dataclass, field @dataclass class ImageClassification: model : str = 'resnet50_v1' use_pretrained : bool = True use_gn : bool = False batch_norm :...
ef35276f94df63deb3c22b08f2caa7571754c8e60e1070d44e5a905554fc3878
Python
2,953
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "waterfall" ...
fd864045b2c71090944506ca7ac34a35fd648949b27f5b2c87ed9a97633054dc
Python
2,953
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "parcoords" ...
fff15464a60f592ea451fc08d4af65b826f9a80ac6192d2e2dd2b704619d79a1
Python
2,953
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "scattergl" ...
07eee56c4c830ac59397e84eb40c6e583c7da8ebe8abcff3ca9c6f48df2437d0
Python
2,954
83
"""1. Getting Started with FCN Pre-trained Models ============================================== This is a quick demo of using GluonCV FCN model on PASCAL VOC dataset. Please follow the `installation guide <../../index.html#installation>`__ to install MXNet and GluonCV if not yet. """ import mxnet as mx from mxnet imp...
dfdaafc6f593f3d99d77bb0a0ec93dc958b746c1eb8cd9181c60ffcc705e00c7
Python
2,954
92
import matplotlib.pyplot as plt import seaborn as sns from geopandas import GeoDataFrame from matplotlib import colors def lisa_quantiles(df: GeoDataFrame): """Scatterplot of the gene expression and its spatial lag. Categorization into the four regions (HH, HL, LH, LL) is also annotated. This function should ...
eab543b60a5ddf73e0a8e48951667a3830c754ffbbfe9f660e9f1d36dcfb70d3
Python
2,956
102
#Autors: Carlos Alberto Hernández Nava #ASVspoof2017 Assembly for classification import cv2, os, sys, csv import numpy as np import pandas as pd import keras.models import tensorflow from keras.models import Sequential from keras.layers import Activation, Dense import matplotlib.pyplot as plt import seaborn as sns fro...
64e58acab51328a4c763edf8ddd7857bc615992f7d49a74fa9c315401052ffdc
Python
2,957
72
#!/usr/bin/python3 # -*- coding: utf-8 -*- """Unified gridsearch and shuffled controls. Run from the command line with a condition name argument. Optionally, pass the name of the settings file to use as a second argument. """ import time import sys import os import crf_util import logging from gridsearch_t...
8c39f99b51e444521c228f1b122b935130c533b33cd9060454cfbf4bdc997e2f
Python
2,958
87
"""Support functions for Bitmask.""" from typing import List, Tuple import numpy as np from scalabel.common.typing import NDArrayF64, NDArrayI32, NDArrayU8 MAX_DET = 100 def gen_blank_bitmask(shape: Tuple[int, ...]) -> NDArrayU8: """Generate blank bitmask given the shape.""" assert shape[-1] == 4 bitma...
b2a840a196db0bd9c9a2fb06c713c546522b5eb8c32f125113a584d1a106ccfa
Python
2,958
95
import platform import subprocess import re import time from carbontracker.components.handler import Handler from typing import Union, List, Pattern class PowerMetricsUnified: _output: Union[None, str] = None _last_updated: Union[None, float] = None @staticmethod def get_output(): if ( ...
1eff407bcc7b9a6e01873cae069979be76d66739873de66cc432f2824e774498
Python
2,959
97
import torch import numpy as np import pandas as pd from tqdm.auto import tqdm from .gia._perturb import perturb_seq_torch from ._utils import _model_to_device # Reference vs output difference methods def delta(y, reference): """Difference between output and reference""" return (y - reference).sum(axis=-1) de...
0eb1bbe175679e0ac8ea26244d1175e17ef2c3b52c907268638188f3456b8917
Python
2,960
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "choropleth" ...
233ea772c6de73ab6b02e48e00cb2c63a30d04cfd6c6da978a4d9b53e110ff94
Python
2,960
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "scattergeo" ...
29ea81dffe23c4090bd73ecdcec17e4b836f116f30d1bc53e3f012125a7a1aad
Python
2,960
80
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license from __future__ import annotations import shutil from functools import partial from pathlib import Path import torch from ultralytics.nn.modules import Pose, Pose26 from ultralytics.utils import LOGGER, YAML from ultralytics.utils.checks import che...
2cf82226b0a63750415c314f862fdf119a243497504b30135f71716e796a13cf
Python
2,960
86
from typing import Dict, Tuple import torch from rbm.potts.grad import compute_gradient from rbm.potts.sampling import sample_hiddens, sample_state def update_parameters( data : dict[str, torch.Tensor], chains : dict[str, torch.Tensor], params : dict[str, torch.Tensor], lr : float, centered : bo...
34a2b5fea01e11bb29c777463c4958fd606284baf2956a9ea7f1af69bdc2157c
Python
2,960
104
import logging import time from ethoscope.hardware.interfaces.interfaces import BaseInterface class WrongSerialPortError(Exception): pass class NoValidPortError(Exception): pass class OptoMotor(BaseInterface): _baud = 115200 _n_channels = 24 def __init__(self, port=None, *args, **kwargs): ...
3819deb222f4c5871fedeb19c7ae67ad65e71c552c20ba6a35302d0f6aa3ed71
Python
2,960
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "densitymap" ...
611fbec604e1d877f20e441f4ebb0e6daa6b2a921a4432d2976ef014f3c86781
Python
2,960
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "streamtube" ...
666c2f38d6617c6d24d74b11ee70a652cf2933ce739dffc25e709ab5d3f0e073
Python
2,960
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "funnelarea" ...
9b8bbd6be5a51f22d729f700553d4a2dc45902be9808fdc6a9fa1351dd2d5fdf
Python
2,960
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "scattermap" ...
d4bb8aa95d1965da1b940b37d7aae656abd06f89d5509be649bf89de5e590ec0
Python
2,960
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "isosurface" ...
9861bc086a7cf0887596a78c3f4bb12450c39ad60f3c7b1535aea61f0ed636cd
Python
2,961
86
"""Tests for bdpy.dl.torch.domain.feature_domain.""" import unittest import torch from bdpy.dl.torch.domain import feature_domain as feature_domain_module class TestMethods(unittest.TestCase): def setUp(self): self.lnd_tensor = torch.empty((12, 196, 768)) self.nld_tensor = torch.empty((196, 12, 7...
cdd96377c3c096824616cff48c366f73013e27b7c67c93131d037dec5bbac0b2
Python
2,961
75
from copy import deepcopy import tensorflow as tf import tensorflow.keras as keras import tensorflow_addons as tfa from sklearn.model_selection import StratifiedKFold from tf_spiking.helper import TrainingHistory from tf_spiking import DenseLIF, DenseLIFNoSpike, IntensityToPoissonSpiking import numpy as np from traini...
18403c5daf1f859cb3d4a75474ff29ed1d0b191ae9c8b5b58fad80f0d2a9783c
Python
2,962
93
""" Unit tests for stimulators/optomotor_stimulators.py. Tests OptoMidlineCrossStimulator class. """ import unittest from unittest.mock import Mock from ethoscope.hardware.interfaces.optomotor import OptoMotor from ethoscope.stimulators.optomotor_stimulators import OptoMidlineCrossStimulator from ethoscope.stimulato...
293cd994b8bbc61b43eb29da4637ba7c50ccfd2a87dc2197159a3d6df40293fb
Python
2,962
99
"""Regression tests for selective-save child-version snapshots.""" from __future__ import annotations import pytest import torch from torch import nn import torchlens as tl from torchlens.backends.torch.aliasing import detect_torch_alias_contract from torchlens.ir.intervention import FunctionEventInput class FastP...
cf5b66844fd79255fdaf7054430aacb93877c8a6cb22a35e83831bd6d2e6d17e
Python
2,962
96
# 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. """ Chamfer distance in Pytorch. Author: Charles R. Qi """ import torch import torch.nn as nn import numpy as np def huber_loss(error, del...
f8252d419d5b870ec8fea2a4ecaad16a32fc5c8f872d34a08f4d14ce38b44960
Python
2,962
84
import tensorflow as tf import tensorflow.keras as keras import tensorflow_addons as tfa import numpy as np from copy import deepcopy from sklearn.model_selection import StratifiedKFold brightness_offset = 42 #90 # THIS OFFSET IS SUBTRACTED def load_local_fashion_mnist(path, kind='train'): import os import g...
87481f3c5e63ca50c44b1fc81e017a6d9304ed0004387cd01dd9fae463fe8eb1
Python
2,963
78
from __future__ import absolute_import from pip._vendor.packaging.utils import canonicalize_name from pip._internal.cli.base_command import Command from pip._internal.exceptions import InstallationError from pip._internal.req import parse_requirements from pip._internal.req.constructors import install_req_from_line f...
142357f7bbb4bad493126e15cba99a55a34fa4091d86e1ceeaf801b30f1570e3
Python
2,964
120
import pytest import rpy2.robjects as robjects rinterface = robjects.rinterface import array def test_init_empty(): env = robjects.Environment() assert env.typeof == rinterface.RTYPES.ENVSXP def test_init_invalid(): with pytest.raises(ValueError): robjects.Environment('a') def test_get...
20eaeeeba33a2a3b9bdf1bbee19e2129c7e8c2d58c9e016fd6e7df6434b0512a
Python
2,965
100
""" A script to exctract frames from a .db file and create a video. There are to external deps: ffmpeg and imagemagick. """ import sqlite3 import io import tempfile import shutil import os from optparse import OptionParser import datetime import glob from multiprocessing import Pool def annotate_image(args): inp...
37ad768d3b31c23bf1ec70b184d17f57f96007e525e95c1aa578e4222b260fbe
Python
2,965
76
"""Plain pickles of a Trace must not embed builtin facet recipe function identities. FW2-B item 12-A. ``Trace.facet_registry_snapshot`` is session-time state (``FieldPolicy.DROP``) whose ``_RegisteredRecipe.func`` entries pickle the builtin recipe FUNCTIONS by import identity. Carrying it through ``Trace.__getstate__`...
7278c8e342e64ce0e80225868d5c89ed7f5e0c944c548ea5d623005421abb413
Python
2,966
64
import unittest from os.path import join, abspath from numpy.testing import assert_allclose from tests.tabulation.nonadiabatic_defect_equilibrium.rebless import run from spitfire.chemistry.library import Library from spitfire.chemistry.ctversion import check as cantera_version_check if cantera_version_check('atleas...
d878e4664380b8a9a84c32f69fcb96d62279e0e4bd8fdba92b90b2a71cad155b
Python
2,966
83
import warnings warnings.filterwarnings("ignore", category=RuntimeWarning) import os, glob import argparse import numpy as np import pandas as pd import nibabel as nib from fmri_encoder.logger import console from fmri_encoder.lazy import default_process_multipleX_and_cv_encode if __name__ == "__main__": parser ...
76f7d97929ac3db36b06d8ca68dc36ccaf3234e70b31f30b16101605e8ab7678
Python
2,967
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "candlestick" ...
dc8561d8f52ef36ea022293cb5b5726d516222ecc57ef820f610176e46068213
Python
2,967
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "histogram2d" ...
3178bd1131c4dcdf7052b2c9c01639cdfcbf343c261f759774c49ff535453d23
Python
2,968
93
from setuptools import setup, find_packages from setuptools.command.build_py import build_py import os import subprocess import shutil import platform class BuildPyCommand(build_py): """Modified build command to compile C library.""" def __build_c_library(self): this_dir = os.path.dirname(__file__) ...
745754ca73f02c976b078ead85ea91f86733096a17631ceaf96acc7cf4e11ac7
Python
2,968
102
""" ==================================================================== One Way manova with Frequenty ==================================================================== One way manova to compare Left vs Right for each frequency. """ import numpy as np import seaborn as sns from time import time from pylab import p...
abd8ea3e8f369b653e4b45b978d3ec7556384a0d86a1837fcceefbd65d80d830
Python
2,968
87
from abc import ABC, abstractmethod import torch.nn as nn import torch.nn.functional as F class LinearEffects(nn.Module, ABC): """ Represents how to compute true motifs when effects are linear. In effect, we set up the optimization problem (where m0 is the input and m is the true motifs we output...
b854300de869cc7b9c645bdce344de5ab3cd4b2ee188a8744d780c226a7e1db7
Python
2,968
76
import json import statistics import time import statsmodels.stats.api as sms from angorapy.utilities.datatypes import mpi_condense_stats from angorapy.agent.ppo_agent import PPOAgent try: from mpi4py import MPI except ImportError: MPI = None def evaluate_agent(agent: PPOAgent, n_episodes: int, act_confide...
8a16637672a096ae599e1a7910a7dc78764765c444da3413dd1d235f6c66a2e6
Python
2,969
98
#!/usr/bin/env python3 """ Analyze what domains powerstat reads by examining all RAPL domains and comparing with powerstat output. """ import os print("=" * 80) print("All available RAPL domains on your system:") print("=" * 80) # Find all RAPL domain directories rapl_dirs = [] for base in ["/sys/class/powercap", "/...
c5e0bd34943c582b2c477ed608fd70f3f2713e6f742ce4d488fea419b8aa587d
Python
2,970
119
"""Model configuration JSON export utilities.""" from __future__ import annotations import json from typing import Any __all__ = ["export_model_config_to_json"] def export_model_config_to_json( model_id: str, config: dict[str, Any], compare_model_id: str | None = None, compare_config: dict[str, Any...
0b56ca2ccde54e22c0af3303bad9a978144edbd96c87cc3c4f9cd8763b8c1fe0
Python
2,971
84
import os import shutil from qtpy import QtCore from llspy.gui.mainwindow import main_GUI from llspy.llsdir import LLSdir from .conftest import requires_cuda @requires_cuda def test_basic_processing(qtbot): testdata = os.path.join(os.path.dirname(__file__), "testdata", "sample") deconFolder = os.path.join(...
5fbbe4dc74d107211ba83dd521919462c06376ba4e2dd5bfea71de1cef609f07
Python
2,971
94
# -*- coding: utf-8 -*- """ Tier 1: import every pyoperant/behavior/*.py module standalone, with hardware modules stubbed out. Catches import-time bugs (missing dependencies, broken imports) that Tier 0 (syntax) can't, without needing real GPIO/serial/audio hardware. Unlike py-behaviors' Tier 1 (which loads each file ...
f01d2b0589061852c9eb9889cf5374874be2195652858d382472e73906479b9e
Python
2,971
74
import torch.nn as nn import torchvision.models as models import torch from exceptions.exceptions import InvalidBackboneError class ResNetSimCLR(nn.Module): def __init__(self, base_model, out_dim): super(ResNetSimCLR, self).__init__() print("HEREEEEEE?") self.resnet_dict = {"resnet18": m...
5536b1d7fca609c21c6d09b333b0634aa9790ed08501413a948ab30d706e39db
Python
2,972
104
""" Tests to make sure the dataload module isn't busted """ import os import torch import numpy as np import eugene as eu import pytest from pathlib import Path from eugene.dataload import SeqData, SeqDataset HERE = Path(__file__).parent def check_random1000_load(sdata, has_target=False): assert isinstance(sdat...
9070cbdfd6077873cb6cf8a265bae5a1e0007e333d3d22293d5e12775f31bf95
Python
2,972
87
from typing import Optional, Tuple import numpy as np import pytest import gym from gym import spaces from gym.wrappers.filter_observation import FilterObservation class FakeEnvironment(gym.Env): def __init__( self, render_mode=None, observation_keys: Tuple[str, ...] = ("state",) ): self.obs...
de2955f962c0d9067bdb6a5c8f47ff4781d455fc81ab48efd2e5494c9a501fd6
Python
2,972
101
# !/usr/bin/env python """ Modified version of code examples from the chemfp project. http://code.google.com/p/chem-fingerprints/ Thanks to Andrew Dalke of Andrew Dalke Scientific! """ import argparse import chemfp import matplotlib matplotlib.use("Agg") # noqa from matplotlib import rcParams # noqa rcP...
36c873b17c85046edd39634330dddeb5a69059e3c1faf5b5422d9a02d7a6ae8b
Python
2,973
63
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'score_session_manager_control_ui.ui' # # Created by: PyQt5 UI code generator 5.6 # # WARNING! All changes made in this file will be lost! from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Form(object): def setupUi(self, Form): ...
6d1e763c05c62a18274b95bf1df08b04c867257882503a8f0488154f39a58f71
Python
2,973
82
import sys from ij import IJ # Fiji Jython interpreter implements Python 2.5 which does not # provide support for argparse.\ input_file = sys.argv[-7] operation = sys.argv[-6] expression = sys.argv[-5] if sys.argv[-4] in [None, "None"]: bin_constant = None else: bin_constant = int(sys.argv[-4]) if sys.argv[-3...
a916863ed0721c3d0d87fe18cc0ea0c38999b9ed370683f72dde25aaa80d623e
Python
2,973
64
import unittest from os.path import join, abspath from numpy.testing import assert_allclose from tests.tabulation.nonadiabatic_defect_burke_schumann.rebless import run from spitfire.chemistry.library import Library from spitfire.chemistry.ctversion import check as cantera_version_check if cantera_version_check('atl...
b1d42943ea0f03bc0043d2a1ef0693e55c512eff5d57a6704feca99aeee5a50a
Python
2,973
87
import numpy as np import scipy.spatial.distance, scipy.cluster.hierarchy from tqdm.auto import tqdm import scipy.sparse from . import xpu, stats, spatial from .xpu import cupy_wrapper, iscupy, to_numpy #TODO: remove this function and use spatial.pdist below def pdist(X, Y, metric='euclidean'): if iscupy(X): ...
13c213d47d1090b6e1f693986df5ae8449ad629008b47314f756a7e164745cd7
Python
2,975
98
"""The ``celery events`` program.""" import sys from functools import partial import click from celery.bin.base import (LOG_LEVEL, CeleryDaemonCommand, CeleryOption, handle_preload_options, handle_remote_command_error) from celery.platforms import detached, set_process_title, strargv de...
49d683e5fd0d6757ddf4febdcb959c9240b42418b88c36332d52f4f3077c7829
Python
2,975
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "scattersmith" ...
8321500516297f04b6e75665b2f737aae412456e2e9cb78357e3553866329977
Python
2,975
104
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Legendgrouptitle(_BaseTraceHierarchyType): _parent_path_str = "scatterpolar" ...
8ce514d19cae32773a27e87481938399375686994893b0617dfd0f70efa50388
Python
2,975
87
import torch.nn as nn from .residual_unit import HalfResidualUnit, ResidualUnit class ResidualStack(nn.Module): """ Represents a stack of ResidualUnits. The number of ResidualUnits is determined by the `depth` parameter, which can be an integer or a half integer. If it is a half integer, the ...
b009f5433d847aec98c757b950f785dc0addff17f1dd749456e1df8f16ebde66
Python
2,975
78
import numpy as np from larvaworld.lib.util import fft_max, detect_strides def test_fft_max_basic(): a = np.array([0, 1, 0, -1]) dt = 1.0 fr, yf = fft_max(a, dt, return_amps=True) assert np.isclose(fr, 0.25), f"Expected dominant frequency to be 0.25, but got {fr}" assert len(yf) == 2, f"Expected l...