sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
cbb32eb0d30f86bf3ccc92a395c8abdd41366dd2664ebbeb7215a6b8d27aff73 | Python | 3,528 | 105 | """Common Crawl file source plugin using fsspec.
This plugin wraps the ``commoncrawl-fsspec`` library's
:class:`~commoncrawl_fsspec.filesystem.CommonCrawlFileSystem` to provide
read-only access to the `Common Crawl <https://commoncrawl.org/>`_ archive
through Galaxy's file source framework.
Users can browse crawl rel... |
7a770d3b8cdcd8e728c5975725fba64ddb5a4e72ddc713e34268a1717f9e440a | Python | 3,529 | 100 | def get_osm_filter(network_type):
"""
Get OSM filter for different kinds of network types: 'driving', 'walking', 'cycling'.
Applies same filters as in OSMnx,
see: https://github.com/gboeing/osmnx/blob/master/osmnx/downloader.py#L19
"""
if network_type == 'driving':
return driving_filte... |
03f9a63461eb8ece4c27aaf1bbb5756164231e3fd3b008397a3d1781234f61fc | Python | 3,532 | 95 | """Raw hooks returning ALREADY-TRACED tensors must not bless functionless ops.
grind-p3-fixplan T3 (fix-patching lane, tripwire-adjacent): when a raw
``register_forward_hook`` returned a traced tensor other than the module's own
output, capture stamped the PRODUCING op ``intervention_replaced=True`` (a
correct interve... |
aab79ed9e59d6badfe87021a115d5ad82ffc6d0eff2936bbbc31d5422101be9a | Python | 3,532 | 113 | """
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 EVENT SHALL THE BLUE BRAIN PROJE... |
19b3587dea70dd0557946150903377eb638586e6f47838860bfc7dd52413c769 | Python | 3,533 | 93 | import pandas as pd
import numpy as np
from tqdm import tqdm
def print_to_latex(matrice_similarity, all_name_df, col_type):
latex_table = "\\begin{table}[h]\n\\centering\n\\begin{tabular}{lcccc}\n\\toprule\n\\textbf{Dataset Name} &"
for dataset_name in all_name_df:
latex_table += "\\textbf{" + dataset... |
3f39cc3a1029413f653afe2f720259db796b0a64bcda1816f4f75dddb6cb94fc | Python | 3,533 | 107 | import os
import json
import torch
from src.eval.Scorer import Scorer
from src.eval.Writer import Writer
def eval(config, model, batch_iter, scorer):
'''
Evaluate model
:param config:
:param model:
:param batch_iter:
:param scorer:
:return:
'''
model.eval()
with torch.no_grad(... |
8b6a97e97b52318989d3ddee2a585cad6a597026c63d46d8fd06f50410841b5d | Python | 3,533 | 107 | from cvnn.losses import ComplexAverageCrossEntropy, ComplexWeightedAverageCrossEntropy, \
ComplexAverageCrossEntropyIgnoreUnlabeled
import numpy as np
import tensorflow as tf
from tensorflow.keras.losses import CategoricalCrossentropy
from cvnn.layers import ComplexDense, complex_input
from pdb import set_trace
d... |
cac54298e4cdd240907e4931f42bbf61694b8eefb13a2290839f2aef96063e74 | Python | 3,535 | 105 | """tvscope B1 + composition row 1: trace-side provenance population + survival.
The B1 stamp: any capture that APPLIED an input transform carries an honest
provenance record (never a guess); bridge stamps override it; captures
without a transform keep the historical ``None``. Composition row 1: the
record survives sav... |
de9464b4f23cde837ee9ef26cdfa00bb8e2ec6e12017ca0bfeb72e5d56e7a8d1 | Python | 3,535 | 54 | #==============================================================================#
# Author: Dominik Müller #
# Copyright: 2024 IT-Infrastructure for Translational Medical Research, #
# University of Augsburg ... |
481836729b7fc9d88972fda6fa8a1c85a98c4421a2c48a5c4b522089898eff4d | Python | 3,536 | 115 | # Test single model functionality
from pathlib import Path
import numpy as np
import pandas as pd
import pytest
from polyid import Parameters, SingleModel
from polyid.models import global100
from polyid.preprocessors import PolymerPreprocessor
from sklearn.preprocessing import RobustScaler
pwd = Path(__file__).parent... |
76c2cfa957d63d0dba0e8b813f211ef3ede8c998c975fe4137887a21294f6607 | Python | 3,536 | 94 | """The travel-policy arm on a REAL model (lane F40a; foldA s6 F40 bullet).
Capture a real generation episode on distilgpt2 (the R0 roster's REAL
upstream class built from its vendored config, zero network), re-run on
different inputs, and assert no foreign ledger and no
VERIFIED-with-foreign-evidence product.
"""
fro... |
9a3d4e3f9c85442fd6f134410b5130fa11dcdad0fa7c18276f74e3e9147e423a | Python | 3,536 | 112 | # --- 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 Line(_BaseTraceHierarchyType):
_parent_path_str = "indicator.gauge.bar"
_... |
ae807350cef7cb3c28051a22f5347efe9afc75355276abd38b453280b01b6aa0 | Python | 3,536 | 115 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseLayoutHierarchyType as _BaseLayoutHierarchyType
import copy as _copy
class Center(_BaseLayoutHierarchyType):
_parent_path_str = "layout.geo"
_path... |
0ea1c2eeb7cc188eb32bdfa2595b741ef172e03fa6ec95446fd3f2aab92f83eb | Python | 3,537 | 126 | import unittest
from typing import List, Tuple
import os
from glob import glob
import tempfile
import numpy as np
from numpy.testing import assert_array_equal
import scipy.io as sio
import hdf5storage
from bdpy.dataform.features import Features
def _prepare_mock_data(
tmpdir: str,
mock_layer_names... |
1800b7b31beeda63efbf2d4bd1d6a138a096364863eb48bc71da34ea5badff6b | Python | 3,537 | 111 | """Anti-reach or anti-saccade task."""
import numpy as np
from neurogym.core import TrialEnv
from neurogym.utils import spaces
class AntiReach(TrialEnv):
"""Anti-response task.
During the fixation period, the agent fixates on a fixation point.
During the following stimulus period, the agent is then sho... |
ebfc43c974fd9c943dd6f13f2573f94d9b0bfd5f7d5f9d0564aa5b166a4a7b57 | Python | 3,537 | 107 | import matplotlib.pyplot as plt
import sys
sys.path.append("src")
import pandas as pd
from prodict import Prodict
import utils
import numpy as np
def produce_survival_curves(cfg: Prodict):
print("ready to make survival curves")
run_path = f"{cfg.DATA.OUTPUT_DIR}/{cfg.TEST.RUN_ID}/e{cfg.TEST.EPOCH_TO_TEST}"... |
207140bec48cd561d40a6134d13857f68ccd6d3519d40493e687c945f1eddbe4 | Python | 3,539 | 134 |
from __future__ import division
import time
import numpy as np
from libmushu.amplifier import Amplifier
class ReplayAmp(Amplifier):
def configure(self, data, marker, channels, fs, realtime=True, blocksize_ms=None, blocksize_samples=None):
"""
Parameters
----------
data
... |
20d13312a8ba7aa39dfa384efbd7a1ae7245b35c932420ce2745b4b392e8ba1b | Python | 3,539 | 105 | import math
import torch
import torch.nn as nn
import torch.distributions as D
def logNBdensity(k, m, r):
"""
Negative Binomial NB(k;m,r), where m is the mean and r is "number of failures"
r can be real number (and so can k)
k, and m are tensors of same shape
r is tensor of shape (1, n_genes)
... |
7bd1d4e61dd612f8c9dbb46a1416dd226ae9e4f3ebea0693a5a588cc562d6319 | Python | 3,539 | 75 | ##########################################################################
## ##
## Copyright (c) 2019-2025 Philipp Lösel. All rights reserved. ##
## ##
## This file is par... |
b42ef1ed55dd465f7c06f8c6c1a5342cc76761b243404dd51b45dc252d5d3cbd | Python | 3,540 | 93 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# 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://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by app... |
0d44c3cf5561742ddeddbccd563f211e3f1681ebdb685cd3d4138a52a5e8c9e2 | Python | 3,541 | 128 | def scale_term_ph(p, rate=1.0):
def scale_term(p, rate):
d = np.abs(np.subtract(p[0], p[1]))
d_star = np.float(d) / rate
start = np.min([p[0],p[1]])
new_end = start + d_star
return [new_end, start] + p[2:]
return [scale_term(i, rate) for i in p]
def scale_bif_ph(p, ra... |
32b6fec95070353d5d515bac2964cf4bb1dc8000ccef1dbe74e875286fa730a6 | Python | 3,541 | 104 | from ._RL_agent import *
from numba import njit
@njit
def mb_forget_0_diffa_session_value(choices, second_steps, outcomes, n_trials, transition_type, params):
# Unpack parameters.
alpha_pos, alpha_neg, weight_mb, forget = params[:4]
if transition_type == 1:
trans_prob = [0.8, 0.2]
else:
trans_prob = ... |
3b6c9c2a16d6c6aba899a6e9ee50cc37b9b5be775a415151ce7ef9fd0a149e25 | Python | 3,541 | 112 | # --- 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 Line(_BaseTraceHierarchyType):
_parent_path_str = "indicator.gauge.step"
... |
791b1bc0d91a8c0737aafc17a2bffcf05153927c757483c38baac6fff7301030 | Python | 3,541 | 85 | """
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 EVENT SHALL THE BLUE BRAIN PROJE... |
cb3d822b15947827d0949d9d158b31605f05c159a5d6861c9be9b7cc4c269489 | Python | 3,541 | 79 | 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/ICBM_T1-Weighted_12_13_2022.csv'
... |
d766580a977893b59b516e56374f6fbe95b8373fdcf4918334a6108cbaae84ac | Python | 3,541 | 129 | import cv2
import numpy as np
import sys
def genGaussiankernel(width, sigma):
x = np.arange(-int(width/2), int(width/2)+1, 1, dtype=np.float32)
x2d, y2d = np.meshgrid(x, x)
kernel_2d = np.exp(-(x2d ** 2 + y2d ** 2) / (2 * sigma ** 2))
kernel_2d = kernel_2d / np.sum(kernel_2d)
return kernel_2d
def... |
37916827d885a3294e92c1478c40ba024deb3390a0066386e21b081494818563 | Python | 3,542 | 100 |
import numpy as np
from .utils import sample_dist
import scipy.stats as stats
def generate_gabor_param(features, seed=0, rand_flag=False, sf_corr=0, sf_max=9, sf_min=0):
# Generates random sample
np.random.seed(seed)
phase_bins = np.array([0, 360])
phase_dist = np.array([1])
if rand_flag:
... |
eec0b2e9e4c4b62947208a5b917ab5ce54d8cbc9807b09165ee3d2de8ae97463 | Python | 3,542 | 106 | """Tests for facets and portable serialization."""
from __future__ import annotations
from typing import Any
import torch
from torch import nn
import torchlens as tl
from torchlens.semantic import facets as facets_mod
class _LinearModel(nn.Module):
"""Small model used for serialization tests."""
def __in... |
eedd08959be657ff8f922b9cc491d2fad868e87dc2c9037ecc0d43b00877a004 | Python | 3,542 | 114 | import torch
import datetime
import os
import sys
import argparse
import subprocess
from shutil import copytree, ignore_patterns
import random
import numpy as np
import logging
import re
import sys
global device; device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
def set_global_logging_level(level=... |
226cb0d3db31c431e44785c4aef7deda785d7de815ea07526983061cd5dcab6a | Python | 3,543 | 106 | import re
from typing import Any, List, Mapping, Optional, Tuple, Callable
from imodelsx.llm import get_llm
def generate_synthetic_strs(
llm: Callable[[str], str],
explanation_str: str,
num_synthetic_strs: int = 20,
template_num: int = 0,
verbose=True,
) -> Tuple[List[str], List[str]]:
"""Gene... |
6d6c423a96cbbb4c4011cdaad36a4b3bb1cfb99128e180cd25d538a1a7de4149 | Python | 3,543 | 128 | from types import SimpleNamespace
import numpy as np
import matplotlib.pyplot as plt
from permacache import permacache, stable_hash
from modular_splicing.utils.construct import construct
def plot_rocs_with_and_or(
motifs,
donor_strengths,
true_donors,
donorlikes,
*,
pbar,
thresholds=np.l... |
67b85b8a6d8c2d52b425c8d6f1c21e5bd67e3dba077014867b5aa388fb2c192f | Python | 3,545 | 148 | import matplotlib.pyplot as plt
def pca(
sdata,
var,
pc1=0,
pc2=1,
loadings=None,
labels=None,
n=5,
return_axes=False,
**kwargs
):
"""
Plot the PCA of the data.
Parameters
----------
sdata :
SeqData The SeqData object.
var :
str The key of the S... |
b80a4c68fc54777ed757c8f241decbb3005e0750a9fefc1254fca01593e9af3f | Python | 3,546 | 104 | import os
import shutil
import sys
# Dirty fix, :TODO rewrite tools as a package - joined directly to Snudda or the lab
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, "tools")))
import unittest
from transfer.morphology import transfer_morphologies
from transfer.selected_models impo... |
43875c277ff65e22a0446e3269d3a35631881a99245e92a674ce597b06e81e0f | Python | 3,547 | 79 | import argparse
import importlib
import os
import re
import sys
from .helpers import secs_to_hours
from collections import Counter
def get_counter():
return Counter({'all': 0, 'failed': 0, 'invalid_label': 0, 'too_short': 0, 'too_long': 0, 'imported_time': 0, 'total_time': 0})
def get_imported_samples(counter):
... |
6dd5960158a4eac182acd4e06928a0eaca1992ebe7ea32f20e81b346adff3a1e | Python | 3,547 | 96 | """
Author: Derek van Tilborg -- TU/e -- 08-06-2022
Script to pretrain a LSTM using next-token-prediction. We used 10x data augmentation, 100 epochs with early stopping,
and 10% validation data. The weights of this model are later used to initialize all LSTM regression models.
"""
import tensorflow as tf
physical_de... |
994fe670a5ce227470f474e361787d9a8a33cb4a6d970049670215113c697a7b | Python | 3,548 | 86 | """
Code here will demonstrate how to create an ABF1 file de novo (from scratch).
It will be episodic, and its source data will be the NPY created yesterday.
"""
import os
import numpy as np
import struct
import random
FOLDER_HERE = os.path.abspath(os.path.dirname(__file__))
DEMO_NPY = os.path.join(FOLDER_HERE, "2018... |
26690df76e8747905b94058a22e0af68fa0ecd90e7f890e19880090a024f5f51 | Python | 3,549 | 121 | from openpyxl import Workbook
from openpyxl.utils.dataframe import dataframe_to_rows
import os
import sys
import pandas as pd
import sqlite3
def get_db_uri(db_fpath):
uri = f'file:{db_fpath}?mode=ro'
return uri
def get_tables(db_fpath):
db_uri = get_db_uri(db_fpath)
query = "SELECT name FROM sqlite... |
2071c6a2b7ca026a76e5ebd6c2f34ddd70ac31ec42a4c18c48d50f7f986af44e | Python | 3,550 | 99 | import sys
sys.path.append('../')
import torch
import argparse
from multiprocessing import Pool
import numpy as np
import os
from tqdm import tqdm
import time
import math, random
import pickle
from BatmanNet.data.molgraph import mol2graph
from BatmanNet.data.datautils import split_data, node_random_masking, edge_random... |
d8e88fbda5155f4c056bfb0d7ce91e9d7c63841df84327eb1e5cbbbc90db3e4d | Python | 3,550 | 90 | import sys
from robustness.datasets import jsinV3
from robustness.model_utils import make_and_restore_model
from model_analysis_folders.all_model_info import JSIN_PATH, MODEL_BASE_PATH
import os
# Make a custom build script for audio_rep_training_cochleagram_1/l2_p1_robust_training
def build_net(include_rep_in_model... |
26bd4bc145a623b0a9e987c15d367ba54da24b6863d017f0c81c2d456ff68204 | Python | 3,551 | 120 | #!/usr/bin/env python3
"""
Test script to verify complete logger name fix workflow.
This tests the complete flow of logger name updates from IP-based to
device-name-based when device info is fetched.
"""
import logging
import os
import shutil
import sys
import tempfile
from unittest.mock import patch
import pytest
... |
4330f60fe60a8c6fc2dd63e729ce05bf2462eb03bade440ea492732f3e2ed2bb | Python | 3,552 | 121 |
import numpy as np
import scipy.stats as stats
'''
Get correlation between two one-dimensional variables
Can be either Pearson's r or Spearman's r
Do this instead of np.corrcoef to get stats and eliminate nans
'''
def corr_vars(a, b, typ='Pearson'):
if isinstance(a, list):
a = np.stack(a)
if isinstanc... |
bde0781ff0091168c14e62ce184ccb9af767dde21b19d8d579a84aa57d7c92c8 | Python | 3,552 | 98 | #!/usr/bin/env python
# coding: utf8
__doc__ = """GLM fitting with weighted data points
Copyright (C) 2014 Ingo Fründ
This code reproduces the analyses in the paper
Fründ, Wichmann, Macke (2014): Quantifying the effect of inter-trial dependence on perceptual decisions. J Vis, 14(7): 9.
Permission is hereb... |
5ef4451eb0ba7410af94bc8d9ca5d3c6ee07b03ed56191df1dc6c4a65971e9f4 | Python | 3,555 | 92 | import warnings
import numpy as np
from mirp._images.generic_image import GenericImage
from mirp._masks.base_mask import BaseMask
def create_tissue_mask(
image: GenericImage,
masks: list[BaseMask],
mask_type: None | str = None,
mask_intensity_range: None | tuple[float, ...] = None,
... |
5b8b4addcdad4dbc2f4971020a561f217d387246d8499a5b671dc3b24880b7b3 | Python | 3,556 | 137 | """Tests for extrafeats"""
import os
import numpy
import pytest
from efel.pyfeatures import extrafeats
testdata_dir = os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'testdata', 'extrafeats'
)
waveforms_fpath = os.path.join(testdata_dir, 'mean_waveforms.dat')
waveforms = numpy.loadtxt(waveforms_fpath)... |
afe65bea0347dc30a296ff24918c5c8dfa256c02cd531b70d7e51c6497cda592 | Python | 3,556 | 119 | """Utility functions for working with trial-level data."""
import numpy as np
from spiketools.utils.checks import check_param_lengths, check_param_type, check_axis
###################################################################################################
#####################################################... |
bb03b0c788e7727808c5010f5788d23142801d9880c72e70294ac2690e71547e | Python | 3,556 | 90 | import torch
import torch.nn as nn
import torch.nn.functional as F
from lib.modules.unet_modules import *
class UNet(nn.Module):
def __init__(self, in_channels, num_classes, kernel_size=3, depth=5, norm_type=None, act_type=nn.PReLU,
padding=0, padding_mode="zeros", up_type="upsample"):
su... |
d95a5bbf45e52ccbf2aaab5b15d3d663fc66473ee53ef7cea8622da89d04a69d | Python | 3,557 | 103 | """
This script loads every ABF in the data folder and generates a summary of its
header (in both HTML and markdown format).
"""
import platform
import matplotlib.pyplot as plt
import pytest
import glob
import os
import sys
import warnings
PATH_HERE = os.path.abspath(os.path.dirname(__file__))
PATH_PROJECT = os.path.a... |
e95a52081dccd74db6301a8b6d87aa54e430096901931e820b445af8afa45699 | Python | 3,557 | 93 | from unittest import TestCase, main
from os.path import join, abspath, dirname
from os import environ
import subprocess
from biom import load_table
from deblur.workflow import sequence_generator
from tempfile import mkdtemp
def _system_call(cmd):
# this is a wrapper so tests pass in the github actions
cmd = ... |
3d6a598816e8b2787fee85fc1da6485611417aeb9c47b023fc5f6c2897f26d09 | Python | 3,558 | 103 | from keras.src import backend
from keras.src.api_export import keras_export
from keras.src.backend.common import get_keras_mask
from keras.src.backend.common import set_keras_mask
from keras.src.layers.merging.base_merge import Merge
@keras_export("keras.layers.Multiply")
class Multiply(Merge):
"""Performs elemen... |
f556027843fd2a4094df8e4fe8d8e71d77fd3dac41ef4cfebce25f50fd7fcb8c | Python | 3,558 | 105 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
"""Pre-download every asset CI tests and benchmarks use.
CI's Assets job runs this once per manifest change and saves the result as one cross-OS cache that every other job
restores, so no job downloads from GitHub Releases at run time. Locally, run it... |
e8699405df758f63d4b3ea588da766a2bbdfeadc3c83f5e24a49add69c15be26 | Python | 3,559 | 116 | '''
Keras implementation of B networks
'''
import tensorflow as tf
def b_layer(x, filters, kernel, layer_num, pooling=True):
'''Base layer for B models
'''
if pooling:
x = tf.keras.layers.MaxPool2D(
pool_size=(2, 2),
name='MaxPool_Layer_{}'.format(layer_num))(x)
x = t... |
044fbdea8e37bb6645c555039ad1c34ce3677577e58549955951d7fd0cfc91a8 | Python | 3,560 | 110 | # for rgenetics - lped to pbed
# where to stop with converters
# pbed might be central
# eg lped/eigen/fbat/snpmatrix all to pbed
# and pbed to lped/eigen/fbat/snpmatrix ?
# that's a lot of converters
import os
import subprocess
import sys
import time
prog = os.path.split(sys.argv[0])[-1]
myversion = "Oct 10 2009"
g... |
0fba3815d6c332b05ad8f42b5abbe99427f5e10392cd9ebb77d79637d6c763e3 | Python | 3,560 | 117 | #!/usr/bin/env python3
# coding: utf-8
"""
Created in April 2022
@author: Simon Delarue <sdelarue@enst.fr>
@author: Thomas Bonald <bonald@enst.fr>
"""
from typing import Union
import numpy as np
from scipy import special
from sknetwork.gnn.base_activation import BaseActivation
class ReLu(BaseActivation):
"""Re... |
6930c5807fe2729913e78a7c258e9935426a4f1585343694e76d57e3c814afb0 | Python | 3,562 | 134 | """Container for sequences"""
import logging
from collections import defaultdict
from Bio import SeqIO
import numpy as np
# pylint: disable=C0103
# Invalid constant name
logger = logging.getLogger('pipe.sequence')
def get_file_handle_by_type(file_name, _mode, _type):
"""Open a file according to its mode and re... |
74d84e43cb2280ed85453c70deabb36137d1a8d39d61f37ef7f608f63250dc58 | Python | 3,563 | 81 | '''
Vgg-based model for neural system identification
Author: Santiago Cadena
Last update: April 2019
'''
import numpy as np
import os
from scipy import stats
import tensorflow as tf
import hashlib
import inspect
import random
from tensorflow.contrib import layers
from tensorflow import losses
from collections import ... |
3625a656d66dabfcaebeb138f1964d7c5e169dc2b8bdf6b746435e8f52eb9db5 | Python | 3,564 | 130 | # --- 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 Title(_BaseTraceHierarchyType):
_parent_path_str = "carpet.aaxis"
_path_s... |
4017b509e8bd6aedbe09842289d16071ee6673f0a8bcfc8deb04595e7199c24b | Python | 3,564 | 130 | # --- 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 Title(_BaseTraceHierarchyType):
_parent_path_str = "carpet.baxis"
_path_s... |
d2deaf2adf505db2a303b823c4b5037f69b8e5c2ce348a2bdb066a6df52db7a4 | Python | 3,565 | 101 | """Utility functions for gluon parameters."""
import re
import numpy as np
def recursive_visit(net, callback, **kwargs):
"""Recursively visit and apply callback to a net and its sub-net
Parameters
----------
net : mxnet.gluon.Block
The network to recursively visit
callback : function
... |
cad16a2c30ead409f52f0a83b076f00a9a3c00fdbc697e95e4b1f5d8ad587d16 | Python | 3,566 | 101 | import os
import mmcv
import os.path as osp
import random
import numpy as np
from PIL import Image
from ..builder import DATASOURCES
from .base import BaseDataSource
@DATASOURCES.register_module()
class LDPolypVideo(BaseDataSource):
def __init__(self,
data_prefix,
classes=Non... |
453cc0188b018cc6f77086271b5e7b31acdb38d67fa7741718c051a2c0dab367 | Python | 3,567 | 99 | import numpy as np
import pytest
import torch
from chemprop.data import BatchMolGraph, MoleculeDatapoint, MoleculeDataset, collate_batch
from chemprop.models import MPNN
from chemprop.nn import BondMessagePassing, MeanAggregation, RegressionFFN, SumAggregation
def make_batch(smiles: list[str]) -> BatchMolGraph:
... |
82ad23f649dd20e22fb4f0cd62e58a4d471bb064f2013e83cacc6d16cf5627c0 | Python | 3,568 | 89 | """Render customizable templates e.g. emails with Jinja.
Templates are preferentially read from a custom template directory (the value
of `templates_dir`, passed to the `render` function). If the requested
template path cannot be resolved with respect to this directory, the default
template will be read from `config/t... |
f0d25e2f5e14a46b9d4c50a040968d0ce5ecdbe6921cb0a5e4b1d77b117fc6e4 | Python | 3,568 | 98 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created in May 2023
@author: Thomas Bonald <bonald@enst.fr>
"""
from typing import Iterable, Optional, Union, Tuple
import numpy as np
from scipy import sparse
from sknetwork.utils.format import get_adjacency
def get_distances(input_matrix: sparse.csr_matrix, sourc... |
b2eaceb8c149639c611efca9e7a888807fdb637403e9d1c87006452eb81e7bda | Python | 3,569 | 85 | from NICE import NICE
import argparse
from utils import *
"""parsing and configuration"""
def parse_args():
desc = "Pytorch implementation of NICE-GAN"
parser = argparse.ArgumentParser(description=desc)
parser.add_argument('--phase', type=str, default='train', help='[train / test]')
parser.add_argumen... |
faac0121c177818e836d690300304d3f660add83867f23a6a5c8355ed8248805 | Python | 3,569 | 85 | import logging
import threading
from typing import Optional
from grpc import RpcError
import bream4.pb.bream.protocol_communication_pb2 as protocol_communication
from bream4.device_interfaces.devices.base_device import BaseDeviceInterface
from bream4.toolkit.procedure_components.command.keystore import set_state, wai... |
f28ca730632ad362dc02c8d1a4ca079a01bdc3fa79d192353fa678c84770e226 | Python | 3,570 | 112 | #!/usr/bin/env python
import fnmatch
import os
import re
import sys
from os import system
from shutil import make_archive
from sklearn import metrics
def sh(script):
system("bash -c '%s'" % script)
fasta_dir = sys.argv[1]
results_dir = sys.argv[2]
dataNames = os.path.join(fasta_dir, "data.names")
listOfCluste... |
a7b9066bffaded4dbf2f4e79d84ece29d5d0de4448ac542e8b7912b1f33270be | Python | 3,572 | 95 | import pandas as pd
from rdkit import Chem
from rdkit.Chem import AllChem
from tqdm import tqdm
tqdm.pandas()
class DoV:
def __init__(self):
self.fingerprint_col = "smiles_polymer"
self.radius = 2
def get_fp(self, smiles: str) -> pd.Series:
"""Gets a the fingerprint hashes for a sing... |
e256be011d59f82d9c18332af5879ca37cae05511edbeec56dab38a495756665 | Python | 3,572 | 105 | """Retained-bytes accounting oracle (F20, brainpipe memo D-17).
``Trace.saved_activation_memory`` must equal the summed REAL physical bytes
of the activations capture actually retained, in all four transform/raw
cells. The pre-fix aggregate summed the raw ``activation_memory`` field for
every saved op, over-reporting ... |
16ba63b52b69ecfe69e2811ebe5a9c56d4dd717d15c01e8ab2ffa9b199a6fd32 | Python | 3,573 | 116 | #!/usr/bin/python
#-*-coding:utf-8-*-
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# 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://www.apache.org/licenses/... |
4f9ecc33b33e5573b4b591c252f7faa8d956b3238b1bdaee8741fa46930a06a1 | Python | 3,573 | 102 | #!/usr/bin/env python
import HTSeq
import csv
import sys, getopt
import numpy
import os
import re
def calculate_rpm(PATH_LIBRARY_SIZE,data):
with open(PATH_LIBRARY_SIZE, "r") as file_library_size:
library_size = 0.0
for row in file_library_size:
bam_name = row.split('\t')[0]
if bam_name == data:
library... |
7066e964b2027e6335b40569aae29d21ae9825375b8f37de2e85bf6471f500ef | Python | 3,573 | 117 | import os
import shutil
import numpy as np
import gym
from gym.utils.save_video import capped_cubic_video_schedule, save_video
def test_record_video_using_default_trigger():
env = gym.make(
"CartPole-v1", render_mode="rgb_array_list", disable_env_checker=True
)
env.reset()
step_starting_ind... |
0ddab132f87ab944f4dace4dc073abadb89f6b89cd24ee440f404febdebac157 | Python | 3,575 | 110 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseLayoutHierarchyType as _BaseLayoutHierarchyType
import copy as _copy
class Activeselection(_BaseLayoutHierarchyType):
_parent_path_str = "layout"
... |
2ce96f8d417eabe1ec7e2badcf1f5fb6b76194d4dd18674409d1e40479d78534 | Python | 3,575 | 101 | from typing import Iterable, Tuple, List
import torch.nn as nn
import torch
from torch import Tensor
from FrEIA.modules import InvertibleModule
class SequenceINN(InvertibleModule):
"""
Simpler than FrEIA.framework.GraphINN:
Only supports a sequential series of modules (no splitting, merging,
branchi... |
8688d69965dcd21b7ea0476c73f1d0a37eabc2b9c39c2807dee6a3b7c6159084 | Python | 3,575 | 94 | from __future__ import division
import unittest
import numpy as np
from wyrm.types import Data
from wyrm.processing import subsample
from wyrm.processing import swapaxes
class TestSubsample(unittest.TestCase):
def setUp(self):
raw = np.arange(2000).reshape(-1, 5)
channels = ['ca1', 'ca2', 'cb1'... |
884a69837172b22f1d408c3db08761acd368d5c5aca6908dbb18b65c0678514a | Python | 3,575 | 104 | # This example requires the following dependencies to be installed:
# pip install lightly
# Note: The model and training settings do not follow the reference settings
# from the paper. The settings are chosen such that the example can easily be
# run on a small dataset with a single GPU.
import copy
import pytorch_l... |
6b5bf56af91dcf7f1091b9ad1774a90c57d6545451f1056178d9027cbd2e7d9d | Python | 3,576 | 105 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_panel.py -- Run the full panel component test for a Magpi panel.
Detects the board revision from /etc/magpi_revision and loads the correct
panel configuration. Runs an autonomous pass followed by interactive user
confirmation for each component.
Usage:
python... |
9e25804245260be098be41ed698847f8bde3de36f25b81281de90a08f87e1f92 | Python | 3,577 | 85 | #The related files involved in tutorials are available at: http://www.cellgo.world
from CellGO import Analysis
import pandas as pd
import numpy as np
#####Step1 Importing modeling results and pathway information
#Use the modeling results from an adult human PFC dataset
ModelingResults=pd.read_csv('Processed_1.csv.gz')... |
913bcea2f0c6d434944ebc564c915d85cad24fc19713b0fd0286bba09ec6b5db | Python | 3,578 | 102 | import numpy as np
import pytest
import gym
from gym.wrappers import RecordEpisodeStatistics, VectorListInfo
from gym.wrappers.record_episode_statistics import add_vector_episode_statistics
@pytest.mark.parametrize("env_id", ["CartPole-v1", "Pendulum-v1"])
@pytest.mark.parametrize("deque_size", [2, 5])
def test_reco... |
a02126c4d9a26c7eb673201b3f96ce3a9d7f2182fd5ff882a642119bbd8b9212 | Python | 3,578 | 98 | import os
import importlib
def find_launcher_using_name(launcher_name):
# cur_dir = os.path.dirname(os.path.abspath(__file__))
# pythonfiles = glob.glob(cur_dir + '/**/*.py')
launcher_filename = "experiments.{}_launcher".format(launcher_name)
launcherlib = importlib.import_module(launcher_filename)
... |
945a121c2847972195a75203b85a5fd74dbfbb5d5f384f43c78ab21b7d77dfa7 | Python | 3,579 | 115 | """Crash-durability helpers for atomic artifact publishes.
The temp-write + rename pattern used by the ``.tlspec`` writers survives a
*process* crash, but not a power loss / OS crash: without ``fsync`` the rename
can be journaled before the renamed files' data blocks reach disk, leaving a
"successfully saved" artifact... |
ed7f9615e76664077f7648515af9426d6b566e9676e2475cdedd797b591770d1 | Python | 3,579 | 106 |
import itertools as itt
from collections import defaultdict
import numpy as np
from scipy import sparse, stats
from scipy.ndimage.interpolation import map_coordinates
class GK_image_aligner:
"""
Align two images using Lucas-Canade algorithm and Greenberg-Kerr parametrization model
"""
def __call_... |
4f308c672fcdc0d1dc1872f89d47b4b9bbd1fc3b25569338f906e276251a7224 | Python | 3,580 | 90 | import sys
from robustness.datasets import jsinV3
from robustness.model_utils import make_and_restore_model
from model_analysis_folders.all_model_info import JSIN_PATH, MODEL_BASE_PATH
import os
# Make a custom build script for audio_rep_training_cochleagram_1/l2_p1_robust_training
def build_net(include_rep_in_model=... |
50ad0c52b6a685e19578e369def421107de02de184adff7eac0a44f8f1ea5fad | Python | 3,580 | 102 | # coding=utf-8
# Copyright 2025 The Google Research Authors.
#
# 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://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
7f8299c92fa97e67679fb4e63aebd73cb17557748fc407ed2687af3e2d9fecdc | Python | 3,580 | 43 | from .base_options import BaseOptions
class TrainOptions(BaseOptions):
"""This class includes training options.
It also includes shared options defined in BaseOptions.
"""
def initialize(self, parser):
parser = BaseOptions.initialize(self, parser)
# visdom and HTML visualization para... |
0bb9a9f590935acca2161f68c0ab147a9838f7bd43336d7c360facb799dae7ad | Python | 3,581 | 90 | import sys
from robustness.datasets import jsinV3
from robustness.model_utils import make_and_restore_model
from model_analysis_folders.all_model_info import JSIN_PATH, MODEL_BASE_PATH
import os
# Make a custom build script for audio_rep_training_cochleagram_1/l2_p1_robust_training
def build_net(include_rep_in_model=... |
201481a3b2a3283b78b8851552ae3288a6c3fc2b6b3d482f0cf1aa79dc13e046 | Python | 3,581 | 93 | """add storage operation run tables
Revision ID: 6925fe4c8a17
Revises: b75f0f4dbcd4
Create Date: 2026-04-15 16:04:34.330085
"""
from sqlalchemy import (
Boolean,
Column,
DateTime,
ForeignKey,
Integer,
String,
UniqueConstraint,
)
from galaxy.model.custom_types import (
JSONType,
U... |
8ddc75bba39a01b18085be8998ade0e5fb43106f025cd54a18d6857940758521 | Python | 3,581 | 96 | from collections import defaultdict
import argparse
import pandas as pd
import numpy as np
import pylab as pb
from sklearn.cluster import KMeans
from mp_dip.utils.utils import classes_d
from mp_dip.utils.signal_reconstruction import gabor
segment_length = 20
timeline = np.arange(0, segment_length, 1/128)
def main... |
eca3f86bb5cf39d96a80e39c099677a24a1d78029f2af347ad530c429d28b213 | Python | 3,581 | 112 | import numpy as np
from numpy.random import default_rng
import pathlib
from mpi4py import MPI
from causal_optoconnectics.tools import conditional_probability, joint_probability, roll_pad
from causal_optoconnectics.generator import (
construct_connectivity_filters,
construct_connectivity_matrix,
simulate,
... |
579bb9bc5a102f8dc5537081ffc5f0ddf5da59d7f4d706b8c02ce9de5fc7fad3 | Python | 3,583 | 98 | #!/usr/bin/env python
import glob
import os
import tarfile
import pandas
from deepspeech_training.util.importers import get_importers_parser
COLUMN_NAMES = ["wav_filename", "wav_filesize", "transcript"]
def extract(archive_path, target_dir):
print("Extracting {} into {}...".format(archive_path, target_dir))
... |
5de311cb76c1d0c91d5988a617fc582e9948b546a012905c0de01e97d483ca56 | Python | 3,583 | 90 | import sys
from robustness.datasets import jsinV3
from robustness.model_utils import make_and_restore_model
from model_analysis_folders.all_model_info import JSIN_PATH, MODEL_BASE_PATH
import os
# Make a custom build script for audio_rep_training_cochleagram_1/l2_p1_robust_training
def build_net(include_rep_in_model=... |
5e159c28907b5396735abf4192fc0b9f2b4cff22b44c1a644dd36d932d918eb0 | Python | 3,583 | 103 | #!/usr/bin/env python
import glob
import json
import os
import tarfile
import numpy as np
import pandas
from deepspeech_training.util.importers import get_importers_parser
COLUMN_NAMES = ["wav_filename", "wav_filesize", "transcript"]
def extract(archive_path, target_dir):
print("Extracting {} into {}...".forma... |
cc610f646990f31754dfc7c8472db3dee86f528139b20214d765aa49e1b19343 | Python | 3,583 | 94 | import os
import argparse
from transformers import GPT2Tokenizer
from irnlm.utils import read_yaml, check_folder, save_yaml, save_pickle, get_progress
from irnlm.models.gpt2.modeling_hacked_gpt2_integral import GPT2LMHeadModel
from irnlm.models.gpt2.modeling_hacked_gpt2_semantic import (
GPT2LMHeadModel as GPT2L... |
7c8376ebe5edb7ea39457652305f86f999dae2f0ef1ad96bc02ad1073b86dfde | Python | 3,584 | 106 | import os
from mirp.extract_features_and_images import extract_features
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
def test_pet_suv_conversion_none():
data = extract_features(
image=os.path.join(CURRENT_DIR, "data", "sts_images_raw", "STS_001", "FDG_PET", "image"),
mask=os.path.joi... |
8da787b9e71e4d93dc20ccaf7c6d9c9a747448076f9fad1181c55115c7020ceb | Python | 3,584 | 90 | import sys
from robustness.datasets import jsinV3
from robustness.model_utils import make_and_restore_model
from model_analysis_folders.all_model_info import JSIN_PATH, MODEL_BASE_PATH
import os
# Make a custom build script for audio_rep_training_cochleagram_1/l2_p1_robust_training
def build_net(include_rep_in_model=... |
8615e8cfb46da4d2fcc6f37c21b903268cb722ddf0696640eaff365ad85bb647 | Python | 3,585 | 90 | import sys
from robustness.datasets import jsinV3
from robustness.model_utils import make_and_restore_model
from model_analysis_folders.all_model_info import JSIN_PATH, MODEL_BASE_PATH
import os
# Make a custom build script for audio_rep_training_cochleagram_1/l2_p1_robust_training
def build_net(include_rep_in_model=... |
e5d5bb62d42f0d92e73c611a42b0f58f2d49e7275aa214b88c7f436757740d5f | Python | 3,585 | 90 | import sys
from robustness.datasets import jsinV3
from robustness.model_utils import make_and_restore_model
from model_analysis_folders.all_model_info import JSIN_PATH, MODEL_BASE_PATH
import os
# Make a custom build script for audio_rep_training_cochleagram_1/l2_p1_robust_training
def build_net(include_rep_in_model=... |
402fcc4c96796043496c92092c2db3623a06467298f6c80fdd950589c2a3aa03 | Python | 3,587 | 99 | """PyTorch-Spiking SpikingActivation MLP: rate-coded spiking activations in an MLP.
Rasmussen (2021), "Nengo-PyTorch / PyTorch-Spiking: SpikingActivation".
Source: https://github.com/nengo/pytorch-spiking
Distinctive primitive: SpikingActivation layer.
A standard activation function (e.g. ReLU) is applied over T time... |
9d6f3becf159bd5b27717630892bb9378f828a27fee36f4f1686aa9427cedd71 | Python | 3,587 | 102 | """The netron serve/widget one-liner (lane F14, netron memo D-20).
Gotchas locked by execution during the panel: ``bytearray`` not ``bytes``
(bytes falls into an experimental sniffing branch), the served route is
``/data/<basename>``, the name must end ``.json``, loopback-only default
with an ephemeral port, clean sto... |
abb7b7b30f88c31ef4231cb7246757e646801cea5485f6077863246f60fc3821 | Python | 3,587 | 84 | """Shared input datatype resolution for declared and discovered outputs."""
import json
import logging
import re
from collections.abc import Mapping
from typing import (
Optional,
TYPE_CHECKING,
)
if TYPE_CHECKING:
from galaxy.model import (
DatasetInstance,
HistoryDatasetCollectionAssocia... |
7e21832d865a147453b3c1a52eca77a4ec51c931cbd58e37a0fbebcefb150d56 | Python | 3,588 | 122 | """Random dot motion task."""
import numpy as np
from psychopy import visual
from neurogym.utils import spaces
from .psychopy_env import PsychopyEnv
class RandomDotMotion(PsychopyEnv):
"""Two-alternative forced choice task: subject has to integrate two stimuli to decide which is higher on average.
Args:
... |
a77b84dcb8d440cb6616089ec64831d6b62b5d6a36047e9b6ff09bc20d9717ff | Python | 3,588 | 1 | import numpy as np
import pandas as pd
import time
import random
# [1] data load #
df1 = pd.read_csv('./data/GSE76312_Single_cell_HSCs_expression_RPKM_table_gene_filtering_log_normal232tumor902_deg.csv', index_col=0) # dimension = (genes x cells)
df2 = pd.read_csv('./data/GSE76312_Single_cell_HSCs_expression_RPKM_tabl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.