sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
960c138fa496fbd5862dc16dd8cdc1419cfc37762a1c6e842ebe451a2480352b | Python | 1,848 | 47 | def RSLM(df,hpspace):
import statsmodels.formula.api as smf
from kerastuner.engine.hyperparameters import HyperParameters
from scipy import stats
import pandas
import numpy
#from imblearn.over_sampling import SMOTENC
# removing constant columns
const_cols = [col for col in df.columns if df[col].nunique() == 1]
... |
18f4f0b2de09509602b644d81a3d99f88268cb5b68c81dec2f902b500d7b94a8 | Python | 1,849 | 67 | import bct
import numpy as np
from utils import supp_stats, make_dir, pickle_dump
from joblib import Parallel, delayed
from joblib.externals.loky import set_loky_pickler
set_loky_pickler('pickle')
import os
os.environ['OPENBLAS_NUM_THREADS'] = "1"
os.environ['MKL_NUM_THREADS'] = "1"
direc = os.path.abspath('../../d... |
4364146419c14be588025c8e4da82faaf2f14e3ae552c027c28599156c1a0578 | Python | 1,849 | 59 | from SmilesPE.pretokenizer import atomwise_tokenizer, kmer_tokenizer
import multiprocessing as mp
import functools
from SmilesPE.tokenizer import SPE_Tokenizer, codecs
def tokenize_smiles(smiles_list, tokenizer, ngram_order, num_workers=0):
tokenizer_func = None
toks = None
tok_list = []
spe_vob = co... |
a22e9743fdd4e95a04aea5c02aa6a030c49a8c9a9bfe86219fdd1f80eae7d315 | Python | 1,849 | 63 | # This example creates an approximate Ez-polarized planewave in vacuum
# propagating at a 45-degree angle, by using a couple of current sources
# with amplitude exp(ikx) corresponding to the desired planewave.
import cmath
import math
import meep as mp
s = 11 # the size of the computational cell, not including PML
d... |
eb2ebc173750fbb8f16d28a7e02b8fb26d7d0b748ee490dc1f03b8a5548cf5b7 | Python | 1,849 | 53 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import suites
from lab.reports import Attribute, gm
from common_setup import IssueConfig, IssueExperiment
try:
from relativescatter import RelativeScatterPlotReport
matplotlib = True
except ImportError:
print 'matplotlib not available, scatter plots... |
f385364ba265cc9b31abb7d539a07388994f611eedc385377838bae832075a16 | Python | 1,849 | 64 | # pylint: disable=too-many-function-args, invalid-name
""" ABIDE ICA dataset loading script"""
import h5py
import numpy as np
import pandas as pd
from omegaconf import DictConfig
from src.settings import DATA_ROOT
def load_data(
cfg: DictConfig,
dataset_path: str = DATA_ROOT.joinpath("abide/ABIDE1_AllData.h... |
b2f4049accf01c6f0ed2296a7b04a864794db09cb6996e6f6e8ed22440a59ff7 | Python | 1,850 | 48 | """
Processing for rat somatosensory cortex QuPath Nissl data
"""
import logging
import click
from layer_recognition.app.cell_size.batch import cmd as batch_cell_size
from layer_recognition.app.convert.batch import cmd as batch_convert
from layer_recognition.app.convert.project import cmd as project_convert
from lay... |
c0a92c5ffe33c7696d73d44403d013c97efda61a01a61173965432ae7f36c6f9 | Python | 1,850 | 64 | from threading import Thread
from typing import Iterator
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
from cog import BaseRunner, Input, streaming
MODEL_NAME = "HuggingFaceTB/SmolLM2-135M-Instruct"
class Runner(BaseRunner):
def setup(self) -> None:
sel... |
1a97b6211e667086f028dc469ab03c3443c63d5f7d7a1f0205419b5778069d32 | Python | 1,851 | 43 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# ht... |
a91d35d6a88e56152dbbfd38fd9c7658433f401321ec8e999e9b7f84d10c67b2 | Python | 1,852 | 69 | import numpy as np
from scipy import signal
M1=4.2767e-14
M3=5.1435e-14
M5=13.3093e-14
def cochlearNuclei(anfH,anfM,anfL,numH,numM,numL,fs):
size=len(anfH[0,:])
TF=19; #total no of fibers on each IHC
# HSnormal=13;
# MSnormal=3;
# LSnormal=3;
Acn=1.5;
Scn=0.6;
inhibition_delay... |
c6f2c643ccb50ad3ef156502df7b9b7fe582f6e03d1ac9dfdde1a867aac09af2 | Python | 1,853 | 56 | # coding=utf-8
# Copyright 2026 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... |
357cfd306a5949ff7163323ec8eab187e15c1eaba86444878c768579847dc811 | Python | 1,854 | 68 | # coding=utf-8
# Copyright 2026 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... |
6427eae7ce2c3d90694f90ff2da3a1ac1290495461f5481f361977969a7499c5 | Python | 1,854 | 74 | from typing import Protocol, TypeVar, overload
from .fxp_params import ConvertableToFixedPointValues, FxpParams
T = TypeVar("T", bound=ConvertableToFixedPointValues)
class IntArithmetic(Protocol):
@property
def config(self) -> FxpParams: ...
@property
def total_bits(self) -> int: ...
def integ... |
a73e0e7131e6e542d62848e67543421d3302a578d7b8206fc7cc93a4826fc862 | Python | 1,855 | 52 | '''
Description:
Loss functions.
Author:
Jiaqi Zhang <jiaqi_zhang2@brown.edu>
'''
import numpy as np
import torch
import torch.nn as nn
import torch.distributions as dist
import geomloss
# ===========================================
def MSELoss(true_obs, est_obs):
'''
Mean squared error (MSE).
... |
c037ae64dff9222fc9c4bfe8f4212b812488e34be14cf163dd7abcd2e77b6873 | Python | 1,855 | 64 | """Base jobs for Gaussian."""
from __future__ import annotations
from typing import TYPE_CHECKING
from ase.calculators.gaussian import Gaussian
from quacc import get_settings
from quacc.runners.ase import Runner
from quacc.schemas.ase import Summarize
from quacc.utils.dicts import recursive_dict_merge
if TYPE_CHEC... |
d911035d065caf76902b809482204b07a9ed3b305f5be3d3062e3c7766465827 | Python | 1,856 | 80 | """Setup for the astrovascpy package."""
import importlib.util
from pathlib import Path
from setuptools import find_namespace_packages, setup
spec = importlib.util.spec_from_file_location(
"astrovascpy.version",
"astrovascpy/version.py",
)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_modul... |
02c7ebd4336746f38e987f2704f2b4226a7f8211da81a9048477779132930eeb | Python | 1,857 | 68 | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# This script must run from its own directory
import gen_csharp
import gen_docs_json
import gen_java
import gen_python
import gen_R
import gen_thrift
import bindings
import sys
import os
sys.path.insert(0, "../../scripts")
import run
import atexit
bindings.check_requirem... |
8f2fc51bc53f5793fdf23985134acd07e65d0a5206dc78d4df01ffd40cfade4a | Python | 1,857 | 47 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# ht... |
396706407fd697442985eacadf0c227557e7a4cf56eef5c38b83afdfa78d11bc | Python | 1,858 | 48 | import numpy as np
from pytorch_lightning import LightningModule
import torch
import torch.nn as nn
class EcuacionSimultanea(LightningModule):
def __init__(self, mask_exogena, mask_endogena, bias=None):
super().__init__()
if isinstance(mask_exogena, np.ndarray):
mask_exogena = torch.fr... |
c83db93140b3df1f6796cafe37fe4fd23c65b724bbeb62037a9186e510128395 | Python | 1,858 | 61 | import torch
import torch.nn.functional as F
def get_padding_len(
padding: tuple[int, int] or str,
kernel_size: tuple[int, int] or int,
) -> int:
kernel_size = kernel_size[0] if isinstance(kernel_size, tuple) else kernel_size
if isinstance(padding, tuple):
padding_len = padding[0]
elif is... |
1ad76a985cbfca45524e4cfa31d18bda0dd5e64c6f40a1d35b12990a4e50e7d4 | Python | 1,859 | 72 | import sys
import platform
__all__ = ['install', 'NullFinder', 'Protocol']
try:
from typing import Protocol
except ImportError: # pragma: no cover
# Python 3.7 compatibility
from ..typing_extensions import Protocol # type: ignore
def install(cls):
"""
Class decorator for installation on sys.... |
275f5edfb4711053dd713d86877f9a1f541f7ad833440ef6d50967b4485e3188 | Python | 1,860 | 48 | #!/usr/bin/env python3
'''Small helpers shared by analyze_flex_ddG.py and extract_structures.py.
Standard library only, so that extract_structures.py keeps running without numpy or pandas.
'''
import re
import sqlite3
# Rosetta records the full option list it was invoked with in the "protocols" table of every
# fea... |
918e6a8e2056d98b20611f5625d3f6dee95d59121a02c50a628fad0f2c1d3f9d | Python | 1,860 | 57 | import json
import numpy as np
from pathlib import Path
from sleeplab_format.test_utils.fixtures import *
from sleeplab_format import models
def create_datasets(basedir: Path) -> None:
ds_name = 'dataset1'
ds_version = models.SLEEPLAB_FORMAT_VERSION
series_name = 'series1'
subject_ids = ['10001', '10... |
95037ffa6e67935450ef0daac47af476af9509a0e4fcc7dbdd13e81b9ee41db4 | Python | 1,860 | 62 | # -*- coding: utf-8 -*-
from __future__ import print_function
import os
import re
from . import returncodes
DRIVER_DIR = os.path.abspath(os.path.dirname(__file__))
REPO_ROOT_DIR = os.path.dirname(DRIVER_DIR)
BUILDS_DIR = os.path.join(REPO_ROOT_DIR, "builds")
def get_elapsed_time():
"""
Return the CPU tim... |
d2329157b7c40ae588d7aacd9e4b3464408a03589960220468ff00d59be35122 | Python | 1,860 | 49 | ######################## BEGIN LICENSE BLOCK ########################
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Con... |
32c5f67f171759d1f358207abc709e7642928c1e9b77dbdd365d047b03e80c66 | Python | 1,862 | 55 | """
Optuna example showcasing the new Optuna Terminator feature.
In this example, we utilize the Optuna Terminator for hyperparameter
optimization on a LightGBM using the wine dataset.
The Terminator automatically stops the optimization process based
on the potential for further improvement.
To run this example:
... |
4c345eaff319458e8c33cace9d254c9b9285d233dab217ed085e759c5ceb29c8 | Python | 1,862 | 64 | #!/usr/bin/env python3.9
# train an AI model, track runtime for epochs and save the best models (loss/accuracy)
from ownutil import ParseArgs, PrepareData
# read command line arguments (data set, epoch number, train/validation size)
args = ParseArgs()
#model specific wired setup
args.modelnum = 2 # model 2
arg... |
de3f24936ff21bf8272b7754fffe5f23d9e7c7ba658000a53987ea9ae023c78a | Python | 1,862 | 75 | # coding=utf-8
# Copyright 2026 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... |
ecc3e1e2dced89c3166120a4d40a6d804cdf98bba0a68d780439c2b0b7234490 | Python | 1,862 | 52 | """
LSTM FUNCTIONS
Designed for the AnDePeD algorithm.
"""
from keras.models import Sequential
from keras.layers import Input
from keras.layers import LSTM
from keras.layers import Dense
class Lstm:
def __init__(self, b, num_neurons):
self.model = Sequential()
self.model.add(Input(shape=(b-1, 1)... |
230f6c6cfb4965d3f8af151e6bcd31371d96f94a0f63a3703bfca41bd4565416 | Python | 1,863 | 63 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import itertools
import os
from lab.environments import LocalEnvironment, BaselSlurmEnvironment
from downward.reports.compare import ComparativeReport
import common_setup
from common_setup import IssueConfig, IssueExperiment
DIR = os.path.dirname(os.path.abspath(__fi... |
77e0ebda4cbf42bd7ef29c21209bdb0f475f0351188dd1cacd37c3cef6ecc54d | Python | 1,864 | 44 | # Copyright (c) 2021, Ko Sugawara
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and t... |
834f1a2f1504f700106e6ee65438d2253aa0c6e65ff0aa21cb0c283a5a83e182 | Python | 1,864 | 65 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
from lab.environments import LocalEnvironment, MaiaEnvironment
from lab.reports import Attribute, arithmetic_mean, finite_sum, geometric_mean
import common_setup
from common_setup import IssueConfig, IssueExperiment
DIR = os.path.dirname(os.path.abspath(__fil... |
9d1af9d6e81e81bef23b27b45f9bb687f57d58b599e2445cc2f6055c73a97c51 | Python | 1,864 | 40 | import os
import argparse
import logging
import multiprocessing
import glob
from pipeline import process_image_segmentation
from utils import find_files_with_string_in_name
def main():
"""Main function to process images."""
parser = argparse.ArgumentParser(description='Image Registration and Skull Stripping.'... |
a438678bb518efe12f677ec9fba75173e8d6cdb2c558590ea8ffb2e744ff622e | Python | 1,864 | 54 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 23 14:51:29 2021
@author: leupinv
"""
import base.base_constants as b_cs
from base.files_in_out import GetFiles,filter_list,getListOfFiles
import source.source_constants as cs
import source.source_helper as source_hp
import mne
import os
# raw=mn... |
bed601b2c32914e71d2baeca2d9d35173b32ea9955e0020bae506b2fee22da34 | Python | 1,864 | 39 | from __future__ import print_function
from dimensions.bowls.dimensions import BowlDimensions
CUP = 'cup'
# blue cup: scale = 0.01
THICKNESS = 0.5 # 0.4 - 0.5 cm
# All dimensions strictly increasing
CUP_PROPERTIES = {
'teal': BowlDimensions(4.9, 6.9, 10.3, THICKNESS, (0, 80, 115)),
'orange': BowlDime... |
e0238a6ba183129ca7e98cac5d220d357e9a9b5c3e52630d5e8f44aa21b6fff6 | Python | 1,864 | 61 | """
Use gradient ascent to create a trace that causes the model to predict a spike or maximize location score
"""
from src.model import ModelSpikeSorter
import matplotlib.pyplot as plt
from matplotlib.axes._axes import Axes
import torch
from src import plot
MODEL_PATH = r"/data/MEAprojects/DLSpikeSorter/models/v0_3/2... |
3e0dba2d1a6fd3240307901cfacc605571bb86c035358bdaa45800a597d8cd98 | Python | 1,866 | 57 | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
import sys
from unittest import TestCase, main
from ..ansitowin32 import StreamWrapper, AnsiToWin32
from .utils import pycharm, replace_by, replace_original_by, StreamTTY, StreamNonTTY
def is_a_tty(stream):
return StreamWrapper(stream, No... |
cb42fc97f5c772bf9370767dee72eb6dab39ef763ff50136afb79b8056959ae9 | Python | 1,866 | 50 | # coding=utf-8
# Copyright 2020 The Facebook AI Research Team Authors and The HuggingFace Inc. team.
#
# 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/LIC... |
fc68638db0cb4bd580fe22b0ba35d091c4c8dd8cf586eef81f14314ac2174631 | Python | 1,866 | 25 | """posthoc_blind_share_2026-10-09.py — POST HOC (after BLIND, prereg 09a). Do all rebuilt lobes land at the same balance?
For every start's final state (fresh seeds) and the comparators: the excitatory share of local-neuron synapses onto uPNs,
weighted by each state's own resting rates (as 08d K5), and how many of the ... |
2dd7e78cdd6404a38086b5c7bfc1a787e7a9b621837bcfca4afb88c69c3d29f5 | Python | 1,867 | 55 | """Example of deskewing an ND2 file using pycudadecon."""
# pip install pims_nd2
import os
import numpy as np
from pims import ND2_Reader
from skimage.io import imsave
from pycudadecon.affine import affineGPU
# needed to flip the sign on the transform
DEFAULT_TMAT = np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0.70711, 0... |
0692b73a334c3358e6b04714e9a5e8549283f1521fef176b713288a8c1561bb5 | Python | 1,868 | 53 | from cloudvolume import CloudVolume
from cloudvolume.lib import Vec, Bbox
import numpy as np
from copy import deepcopy
padding = Vec(128, 128, 0)
start = Vec(20002, 12009, 65) - padding
stop = Vec(22050, 14057, 165) + padding
bbox = Bbox(start, stop)
src = CloudVolume('gs://neuroglancer/pinky10/image_rechunked', mip=... |
27ae9c2db246c011653f40921d85b6655f4c765c7423cdcced2364cbdf27c427 | Python | 1,868 | 58 | import csv
from pathlib import Path as PyPath
from typing import Any
from elasticai.creator.file_generation.savable import Path
class Testbench:
@property
def name(self) -> str:
raise NotImplementedError
def save_to(self, destination: Path) -> None:
raise NotImplementedError
def pre... |
ceef4c76127bc81ee1812705f1d3729661b1b2e0df28872e1e1fca7e11584043 | Python | 1,868 | 59 | """
DeepLabCut2.0 Toolbox (deeplabcut.org)
copyright A. & M. Mathis Labs
https://github.com/AlexEMG/DeepLabCut
Please see AUTHORS for contributors.
https://github.com/AlexEMG/DeepLabCut/blob/master/AUTHORS
Licensed under GNU Lesser General Public License v3.0
"""
import os
from pathlib import Path
import deeplabcut
f... |
007bb8e7c978329539d6f8ab69c4485743c404db0c614aa42ef8c067eb4072cf | Python | 1,869 | 58 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
from lab.environments import LocalEnvironment, BaselSlurmEnvironment
import common_setup
from common_setup import IssueConfig, IssueExperiment
from relativescatter import RelativeScatterPlotReport
DIR = os.path.dirname(os.path.abspath(__file__))
BENCHMARKS_DI... |
b0d9104921f1589bbe9e9a3bd0dd4893ada9a8d2ff1ce5e433c8e988c0916179 | Python | 1,869 | 60 | #!/usr/bin/env python
import sys
import re
from datetime import datetime,timedelta
import argparse
parser = argparse.ArgumentParser(description='summary gpu log.')
parser.add_argument('log_file')
parser.add_argument('-s', '--start_time', help='start of effective time')
parser.add_argument('-e', '--end_time', help='en... |
1679f3502541ed7633171ac4eb9811d2aea12b01cea63132a9877f283a90dd38 | Python | 1,870 | 56 | import json
import os
from typing import Any
import numpy as np
from numpy.typing import NDArray
from .inputmodels import InputPath
def xconv(x: NDArray[np.float64], N: int = 5) -> NDArray[np.float64]:
"""Smooth an array with a centered moving-average convolution."""
xf = np.convolve(x, np.ones(N)/N, mode='... |
ddc613426c3d149709c34fab7291585826c79c1abd922d91eb3eda38eed100bd | Python | 1,870 | 56 | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# 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 applicable... |
ef83d4e161be2875cdaa9acfd2c850214b5425796e10f727af519a39a65b7224 | Python | 1,870 | 64 | # coding=utf-8
# Copyright 2026 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... |
b755e2471ffa1158015bc5328ac14113675638d52e36349db7b284b351e4c972 | Python | 1,871 | 77 | import pandas as pd
from cuppa.components.logistic_regression import LogisticRegression
class TestLogisticRegression:
X = pd.DataFrame([
[1, 0, 0],
[1, 0, 0],
[1, 0, 0],
[1, 0, 0],
[0, 0, 0],
[0, 1, 0],
[0, 1, 0],
[0, 1, 0],
[0, 1, 0],
... |
cc3426bb6be8023bf7ab566907e8eda83f019b03bb5879b146d14f3351420cf8 | Python | 1,871 | 48 | import os,sys
import subprocess as sp
import datetime
dt_now = datetime.datetime.now()
d_today = datetime.date.today()
pdblist = ['3TI5','4MKC','5P9H','6M0K']
bslist = [60]
#filist = [True,False]
seednumratio = [0.1]
seedcyclelist = [2]
maxiter = [50]
#sclist = ['nostrcen','0302','noscfr']
#sclist = ['0302']
now = str(... |
9cfc609ece215eb74a154bff04565c007c3a5c121445c37edc7fbcca0f15d4f4 | Python | 1,872 | 77 | import os
import pandas as pd
from calvados.cfg import Config, Job, Components
import subprocess
import numpy as np
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument('--name',nargs='?',required=True,type=str)
args = parser.parse_args()
cwd = os.getcwd()
sysname = f'{args.name:s}'
# se... |
18fa2cf9b7da6a100a90d6803d83ae1f05471c118186297ff98a8886616db814 | Python | 1,873 | 56 | # 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.
from argparse import Namespace
import torch
import torch.nn as nn
import torch.nn.functional as F
from .features import GVPGraphEmbedding
fr... |
3a081d4b79589cdbb60489ab1fe7c9774402f8edbce689c022744787c7986271 | Python | 1,873 | 78 | import os
import anndata
import pytest
import scipy.sparse
from cirrocumulus.anndata_dataset import AnndataDataset
from cirrocumulus.dataset_api import DatasetAPI
@pytest.fixture(scope="module", autouse=True, params=[True, False])
def test_data(request):
adata = anndata.read_h5ad("test-data/pbmc3k_no_raw.h5ad")... |
e5cb79ed1392a21a9ac0b234fb88a488e1991760882f7fea158f9dc5419d20ae | Python | 1,873 | 57 | # coding=utf-8
# Copyright 2026 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... |
75ef17400dddb2df2dbd0eea8360cc02cf66a78eb157f5ee9d30a44ae747beb7 | Python | 1,874 | 37 | from __future__ import print_function
from collections import namedtuple
# brown bowl: scale = 0.0155 m
BOWL = 'bowl'
BowlDimensions = namedtuple('BowlDimensions', [
'bottom_diameter', 'top_diameter', 'height', 'thickness', 'color'])
# TODO: make a cheat sheet that displays each bowl
THICKNESS = 1.0 # 0.8 - 1... |
21aef8da61a2feb040a3544624619fdbb8a56372eea94636c7fdb261332f8ea0 | Python | 1,875 | 59 | #Author: Skye Thompson
#TODO: Rename?
from pybullet_tools.utils import get_pose, ClientSaver, load_pybullet, set_pose, HideOutput
from perception_tools.common import get_body_urdf, get_type
from dimensions.common import load_cup_bowl
from collections import OrderedDict
class Perception(object):
""" For detecting... |
44f6c914385a158fc81dfb005a5e18e2b7d3910a5aa44a419fbafcb90a1cf3dd | Python | 1,875 | 59 | """
Optuna example using RAPIDS library for optimization.
In this example, we perform hyperparameter optimization on Iris dataset using cuML's
RandomForestClassifier. This should be used as a starting point
to extend the search for larger problems, and wider depths.
To run this example:
$ python rapids_simple.py... |
24724081db7146202d52d49689f1811dbe9879c67502591f1d76528904797670 | Python | 1,876 | 62 | """Schemas for storing metadata about Atoms objects."""
from __future__ import annotations
from typing import TYPE_CHECKING, cast
from emmet.core.structure import MoleculeMetadata, StructureMetadata
from pymatgen.io.ase import AseAtomsAdaptor
from quacc.atoms.core import copy_atoms
if TYPE_CHECKING:
from typin... |
04d900603b4d01435e16cf5d9db25de9e4c54dbf048f1a577c0d17910ba7f9c5 | Python | 1,877 | 65 | """Base jobs for Psi4."""
from __future__ import annotations
from typing import TYPE_CHECKING
from ase.calculators.psi4 import Psi4
from quacc.runners.ase import Runner
from quacc.schemas.ase import Summarize
from quacc.utils.dicts import recursive_dict_merge
if TYPE_CHECKING:
from typing import Any
from ... |
b2d79104430bfaebde9b769de7d6fd7ffa002bd287ec2b5dde11f4bba8e2ae8d | Python | 1,877 | 67 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
create jobscripts for clusters running the Slurm Workload Manager
(http://slurm.schedmd.com) for all network-model and LFP simulations in
Hagen et al., 2016. DOI: 10.1093/cercor/bhw237
All jobs will be submitted to the queue.
Modify according to the set up on your clu... |
43fa447e3e952db45885b60f5ae1939b61e132ed40195def2c58eef69f44d3d1 | Python | 1,878 | 64 | """Tests for the decoupled --syn_metric option plumbing."""
import os
import sys
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
if PROJECT_ROOT not in sys.path:
sys.path.insert(0, PROJECT_ROOT)
import pytest
from regtools.registration.cli import build_parser
from regtool... |
4a20e75ee9456977b874fad0338bda17c0f780f94f7bcefad7255ca9110a8416 | Python | 1,878 | 69 | # coding=utf-8
# Copyright 2026 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... |
c4b809e08d395495ec31284e9fae9704cc6a8a48e3e5eda81d4014d44985b335 | Python | 1,878 | 49 | from network.Connection import Connection
from network.Cell import Cell
from network.Segment import Segment
from neuron import h
class Network(object):
def __init__(self) -> None:
self.ncell = 0 # number of cells, int
self.cells = [] # all cells, list of Cell object
... |
06a48cfaa6732b0af8035400bbcf0c874ddfdc9d9f0ceb25df1f6263e0634cbf | Python | 1,879 | 77 | # Node-group asset "Backbone N" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# _build_group() is the source of truth: the docstring, __init__ and accessors are regenerated from it on the next dump.
from typing import TYPE_CHECKING, L... |
25c368d6355065613fb094ff5ca298425b72333a00ea351b6a56a70aeb917373 | Python | 1,879 | 68 | import torch
import numpy as np
import tqdm
import copy
from ..data import get_dataset
from torch.utils.data import DataLoader
def _collate_fn(batch):
coll_batch = {}
number = {}
for key in batch[0]:
coll_batch[key] = torch.cat([d[key] for d in batch], dim=0)
number[key] = [len(d[key]) for... |
e67e18ea9cad1c9ff6c5c1b6e295cb9690d0ca0ddcd502e66aac1df70e7bfae8 | Python | 1,879 | 64 | import scanpy as sc
import numpy as np
import pandas as pd
import scvi
from scvi.external import RNAStereoscope, SpatialStereoscope
import sys
import os
np.random.seed()
def get_freer_gpu():
os.system('nvidia-smi -q -d Memory |grep -A4 GPU|grep Free >tmp')
memory_available = [int(x.split()[2]) for x in open(... |
3c52c2035b6eadc28bfd0ef648333e151a4ca3d07cd38616aa48f44e5f73583e | Python | 1,880 | 63 | """Preparing the Cam-CAN MEG data
[STEP 3] Source reconstruction: forward modelling, beamforming, and parcellation
NOTE: Before running this script, the /coreg directory created by coregister.py
must be copied and renamed to /src.
"""
# Install dependencies
import os
import glob
from osl import source_recon, ut... |
575b1ce06e4ea8d1a70dad1200dbbfb025068f2b2296924973d926dfffe0ff16 | Python | 1,880 | 54 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 18 15:00:04 2021
@author: david
"""
''' Compute forward model '''
import os
import os.path as op
from stormdb.process import MNEPython
from stormdb.access import Query
from sys import argv
proj_name = 'MINDLAB2020_MEG-AuditoryPatternRecognition'
... |
7359c4748711f52f3b46492e1f055494220b719e6cb8621dab5203a4f6294361 | Python | 1,880 | 72 | from .basic_euclidean import eucl_dist
from .basic_spherical import great_circle_distance
######################
# Euclidean Geometry #
######################
def e_lcss(t0, t1, eps):
"""
Usage
-----
The Longuest-Common-Subsequence distance between trajectory t0 and t1.
Parameters
----------... |
7f45266ed39046168947080192260210e7bb55b280968d2ca3c74b7da596127d | Python | 1,880 | 59 | from typing import Any
import torch
import torch.nn as nn
import torch.nn.functional as F
#from torch import nn, Generator
from ..prixfixe import FinalLayersBlock
#from .utils import initialize_weights
class UnlockDNAFinalLayersBlock(FinalLayersBlock):
def __init__(
self,
in_channels: int = 512... |
89aabc42496e54883b46fe90925cfa7bc2cb3ac21dc99b7998df368834046bc1 | Python | 1,880 | 55 | import ants
import numpy as np
import os
import glob
## USER INPUT #######################
os.environ["ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS"] = "8"
base_directory = '/path/to/base/directory/' # Insert Base Directory Path if Applicable
input_directory = base_directory + "2_subjects_rec... |
f8aed50d34dc872b68fa8ef591318c6356c3e789e65a4291bcf1a936f06bc28d | Python | 1,880 | 64 | # coding=utf-8
# Copyright 2026 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... |
601af87d162e587ee44ca4b6b579458ccdb8645d4f76f722afe6b2c278889ea8 | Python | 1,881 | 54 | """
Given a list of integers, made up of (hopefully) a small number of long runs
of consecutive integers, compute a representation of the form
((start1, end1), (start2, end2) ...). Then answer the question "was x present
in the original list?" in time O(log(# runs)).
"""
import bisect
from typing import List, Tuple
d... |
af856b773512d2aa49cea211da39b34543c23f91860184548ec3aa178e6382b3 | Python | 1,881 | 64 | # coding=utf-8
# Copyright 2026 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... |
c573cd2d83f1d8bff626fd7f43667d215a8858d81618278a9b3afb714ec8ace3 | Python | 1,881 | 56 | import cocotb
import pytest
from cocotb.triggers import Timer
from elasticai.creator.arithmetic import FxpParams
from elasticai.creator.testing import CocotbTestFixture, eai_testbench
from elasticai.creator_plugins.act_func.utils import load_and_plugin
def act_absolute(a: list[int], config: FxpParams) -> list:
r... |
1807bfa6b21f084e2253296b9ebff67494659240554546ce89d128203ecb3e81 | Python | 1,882 | 55 | import importlib.metadata
from typing import Any, Optional, Protocol, cast
class BadMetadata(ValueError):
def __init__(self, dist: importlib.metadata.Distribution, *, reason: str) -> None:
self.dist = dist
self.reason = reason
def __str__(self) -> str:
return f"Bad metadata in {self.d... |
8ff6319f6321e95457742ecd5cb6fed9bc47430a6a54fa03ed753cc0567b0d06 | Python | 1,882 | 57 | # from .sem import SEM, sem_run, sem_run_with_boundaries
# Store the version here so:
# 1) we don't load dependencies by storing it in __init__.py
# 2) we can import it in setup.py for the same reason
# 3) we can import it into your module module
# __version__ = '1.2.7'
# This code make keras models pickable
import pi... |
80f5592401cf1dceb53e752e090c9b8f311b527b92a7c7f4c580c11900a4f38b | Python | 1,883 | 103 | import sys
import numpy as np
import math
import matplotlib
dx = 37651
dy = 6350
mx = 6.25
print("-------------------------------------------------------------------\n")
M=float(mx)
X=float(dx)
Y=float(dy)
X=float(dx)
Y=float(dy)
if X>Y:
v=X/Y
L=X
big="X"
small="Y"
else:
v=Y/X
L=Y
... |
9fe9151eed69101925d25f21e0e70f79c57a2d53f848e41e23a5a2b76b405200 | Python | 1,883 | 70 | #
# Simple script for testing acme w/o pip-installing it
#
# Copyright © 2020-2025 Ernst Strüngmann Institute (ESI) for Neuroscience
# in Cooperation with Max Planck Society
# Copyright © 2026 Ernst Strüngmann Institute (ESI) of the Max Planck Society
#
# SPDX-License-Identifier: BSD-3-Clause
#
# Builtin/3rd party pac... |
a529a45f94aa6432d85ffff41f20d42b6222e641141018bba3155c55755d4f86 | Python | 1,883 | 58 | from __future__ import annotations
from shutil import which
import pytest
from quacc import get_settings
pytestmark = pytest.mark.skipif(
which(str(get_settings().VASP_CMD)) is None, reason="VASP not installed"
)
import numpy as np
from ase.build import bulk
from numpy.testing import assert_equal
from pymatgen... |
5f65379bd1d29d44aaea878b9a39f1209d92f8375263b311f37a01d13fe9b106 | Python | 1,885 | 65 | import unittest
# constants pointing to test files
TEST_FILE_LALMER = './tests/files/LALMER.json'
TEST_FILE_OREDIA = './tests/files/OREDIA.json'
TEST_FILE_ZUYHEG = './tests/files/ZUYHEG.json'
TEST_FILE_QM_DATA_OREDIA = './tests/files/OREDIA.qmdata'
TEST_FILE_JSON = './tests/files/test-file.json'
class Utils():
... |
f75848c875cee80e42e9348661d5f8eef53ab3ca55dcf757579635b39562b20d | Python | 1,886 | 41 | from dreamcoder.program import Primitive, Program
from dreamcoder.type import arrow, baseType, tint
turtle = baseType("turtle")
tstate = baseType("tstate")
tangle = baseType("tangle")
tlength = baseType("tlength")
primitives = [
Primitive("logo_UA", tangle, ""),
Primitive("logo_UL", tlength, ""),
Primiti... |
d108d1166fe07a1dd0a4053a186489978e1168f13b161da9491c452899351ea9 | Python | 1,887 | 61 | #! /usr/bin/env python2
# -*- coding: utf-8 -*-
import os
from lab.environments import LocalEnvironment, BaselSlurmEnvironment
from lab import tools
from downward.reports.compare import ComparativeReport
from downward.reports import PlanningReport
import common_setup
from common_setup import IssueConfig, IssueExper... |
22e861944476fe5ae11bd11ec0f4bdc0b3b0563fa6f4e9c55643f9022a561820 | Python | 1,888 | 43 | import pickle
import traj_dist.distance as tdist
from traj_dist.pydist.linecell import trajectory_set_grid
import timeit
import collections
import pandas as pd
import numpy as np
traj_list = pickle.load(open("/Users/bguillouet/These/trajectory_distance/data/benchmark_trajectories.pkl", "rb"))[:100]
time_dict = collec... |
5469d250f5aee776d21d12c3f94b56e74a295c6ceef05633a39e73666750c4cb | Python | 1,888 | 47 | import numpy as np
def create_spikegen(net, indices, spiketimes, numPorts=None, verbose=True):
"""
creates a spikegenerator from a list of indices with corresponding spiketimes
:param net: the nx net in which the spikegen is created
:param indices: the neuron indices that correspond to the spiketimes
... |
a0ea5b020fa2a56c2ea3279c718cef9e77aa85d04f025ba2cae4b6a12036aee4 | Python | 1,888 | 62 | """Decoder pipeline."""
from __future__ import annotations
import numpy as np
import pytest
from msfeature.decode import cross_validate, make_classifier
def test_make_classifier_has_scaler_and_svm():
clf = make_classifier()
assert "scaler" in clf.named_steps
assert "svm" in clf.named_steps
def test_c... |
bd9253b13ab54e216c2c21f30267110d90f555914fb9ef070e4f2a3a7616e0ff | Python | 1,888 | 69 | from pytest import raises
from wonambi.utils import create_data, create_channels
def test_import():
import wonambi
print(wonambi)
def test_simulate_01():
data = create_data()
assert data.data.dtype == 'O'
assert data.data.shape == (1,) # one trial
assert data.data[0].shape[0] == len(data.ax... |
4945d47bc6c69c896874d1ed8509a68fd2798fea221b45e77c5759d4c2722cf3 | Python | 1,889 | 69 | # coding=utf-8
# Copyright 2026 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... |
a646e6921613cb2dc5884058c5b881c46bb4bf8026f0c96f325116723065bec6 | Python | 1,889 | 70 | from __future__ import annotations
from enum import Enum
from typing import TypedDict
from pydantic import BaseModel
from typing import Optional
class CreLabel(str, Enum):
""" Labels used in ChemRxnExtractor """
O = "O"
B_Reactants = "B-Reactants"
I_Reactants = "I-Reactants"
B_Catalyst_Reagents ... |
ed369643bd12e791233e607da292690eb9586f44016baae79431ce6d1a1d2f6d | Python | 1,889 | 65 | import torch
import torch.nn as nn
from typing import List
from collections import OrderedDict
from . import _utils as utils
class EncoderMixin:
"""Add encoder functionality such as:
- output channels specification of feature tensors (produced by encoder)
- patching first convolution for arbitrary input ... |
2106c3947aa07bcdd6fbbc1bbf06cbc6f37578d48ae7a4a2a0f6e9f62549fe5c | Python | 1,890 | 45 | # -*- coding: utf-8 -*-
from pinn.io.base import list_loader, sparse_batch
from pinn.io.tfr import load_tfrecord, write_tfrecord
from pinn.io.ase import load_ase
from pinn.io.runner import load_runner
from pinn.io.qm9 import load_qm9
from pinn.io.ani import load_ani
from pinn.io.cp2k import load_cp2k
from pinn.io.numpy... |
497b05cc1a9b8be7f722bb4a0104d0e76a7588c967907489e66d6e613ebef7d6 | Python | 1,890 | 57 | from string import Template
from elasticai.creator import ir2vhdl as ir
from elasticai.creator.file_generation.resource_utils import get_file_from_package
@ir.type_handler()
def binary_filter(original: ir.DataGraph, registry: ir.Registry) -> ir.Code:
global _template
if _template is None:
_template =... |
dfb350f164bae1584cbb8069fe645876bc3ed01e75a0189edc36f2ef721f6351 | Python | 1,891 | 50 | import sys
import logging
from Bio import SeqIO
import numpy as np
def setup_logger(log_file):
logging.basicConfig(filename=log_file, level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger()
return logger
def calculate_summary_statistics(fasta_file, output_file,... |
17a69e9a555a2d534d467d4be4b96d9ed42e7d26c5272da6290396a2bd3f1be3 | Python | 1,892 | 58 | # coding=utf-8
# Copyright 2026 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... |
2d61fd762b11a70cbf5dd4b13c0620dbe6cfd09caab42a4c26ec79501d0dcf2b | Python | 1,892 | 60 | # coding=utf-8
# Copyright 2026 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... |
90bb6b84ad925f2464ee93e58ef9ecb73538597e79386edafed0ad8e2bbb91af | Python | 1,892 | 60 | from collections.abc import Callable, Sequence
from itertools import chain
from elasticai.creator.vhdl.design.ports import Port
from elasticai.creator.vhdl.design.signal import Signal
def signal_string(name: str, direction: str, width: int | str) -> str:
if isinstance(width, int) and width > 0:
data_type... |
dcb6893f2198b525d60d186beaa156827d9dbf54ce04025b88aea552d8b80098 | Python | 1,893 | 48 | import unittest
import numpy as np
import torch
from torch_geometric.data import Data
from torcheeg.datasets.constants import DEAP_ADJACENCY_MATRIX
from torcheeg.transforms.pyg import ToDynamicG, ToG
class TestPyGTransforms(unittest.TestCase):
def test_to_g(self):
eeg = np.random.randn(32, 128)
t... |
e3f127e57a63ebd388fbf2a2ac1ece0fabde6b5bded202daff58c28f712c63f5 | Python | 1,893 | 60 | from torch import nn
from typing import List
class TemporalDenoiser(nn.Module):
def __init__(
self,
in_channels: int,
t_order: int,
kernel_size: int,
hidden_conv_channels: int,
hidden_dense_layer_dims: List[int],
activation: nn.M... |
0d21eb676fca04c9e1c2d4c0ed1ed7c809c5b07ba01cc05e79ae7542c416ceee | Python | 1,894 | 58 | # coding=utf-8
# Copyright 2026 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... |
2c91928214164c05dc2a3ab17d763d9b5c6a0e3491a6525b4c742d1871c99622 | Python | 1,894 | 46 | import PoseTools as pt
import sys
import os
import deeplabcut
import APT_interface as apt
import tempfile
# Use ~/bransonlab/singularity/pytorch_mmpose.sif
dlc_orig_dir = '/groups/branson/bransonlab/mayank/apt_expts/deepcut_orig2'
main_script = 'run_train.py'
dlc_model_dir = 'dlc-models/iteration-0/aptMayYay-trainset... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.