sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
1233d576aff552f80228397664fdddc70904eb9c5bd4542ec37b6f300107dc39 | Python | 1,241 | 39 | # Overwrite where to preserve native Python types
import numpy as _np
from autograd.tracer import Box
from . import fft, linalg, numpy_boxes, numpy_jvps, numpy_vjps, numpy_vspaces, numpy_wrapper, random
from .numpy_wrapper import *
from .numpy_wrapper import numpy_version as __version__
_original_where = numpy_wrapp... |
51cb7cf7aef83ffd4d5d8adbbb86a0d2335cd281a8eb1fb3e0a5c58cb8edc791 | Python | 1,241 | 27 | from __future__ import division, print_function
import argparse
from topaz.utils.conversions import file_boxes_to_coordinates
name = 'boxes_to_coordinates'
help = 'convert .box format coordinates to tab delimited coordinates table'
def add_arguments(parser):
parser.add_argument('files', nargs='+', help='path to... |
798791464387c79c0663cf47009ffefad3c7e4e011969f6cffbcb32e4ec64029 | Python | 1,241 | 17 | from .functional import multinomial, masked_mean, mean_with_nan, shifted_softplus, multi_slice, multi_slice_mask, \
as_mask, _extend, variadic_log_softmax, variadic_softmax, variadic_sum, variadic_mean, variadic_max, \
variadic_cross_entropy, variadic_sort, variadic_topk, variadic_arange, variadic_randperm, var... |
cf6d8fbad242887964520dcc984acc0eeefb75fc79e7255f8bdfe69599d80dd8 | Python | 1,241 | 43 | """ The convert click command """
import click
from layer_recognition.convert import single_image_conversion
from layer_recognition.io import list_images
from layer_recognition.utilities import get_config
@click.command()
@click.option("--config-file-path", required=False, help="Configuration file path")
def cmd(co... |
0774d8f1688abc82e73b95d42fdbfcaa06ece32a1d5d642d61e46df94ff42bab | Python | 1,242 | 39 | """
Utilities to support HED searches based on strings.
"""
from hed.models.hed_string import HedString
from hed.models.hed_tag import HedTag
def convert_query(search_query, schema):
"""Converts the given basic search query into a hed_string
Parameters:
search_query(str): The basic search query to c... |
283e1533af2e1071598020308679bd5e88d187dd84145023fd2ed462c0cdf05d | Python | 1,242 | 28 | #
# MIT License
#
# Copyright (c) 2022 GT4SD team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge,... |
7d952cc0b3a82617bd25247e3dc86532510b35d4528df0440cdce301b04b9aa9 | Python | 1,242 | 39 | import numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler
from .simulation_functions import relu, elu, sigmoid, elu_sigmoid
def simulate_exposure(
dfE: pd.DataFrame,
num_exp: int,
activation: str = "relu",
scale: float = 1.0,
weight: float = 0.0,
threshold_binary_... |
916d850629dcf8f39b66561d39a478c52a6252c8c3f27f75331dbcf50a760d43 | Python | 1,242 | 29 | #!/usr/bin/env python
# ============================================ #
# Getting hamiltonians.h5 using trained models #
# ============================================ #
# Usage: python <path-to-this-file>/eval.py <your_config>.ini [-n NUM_THREADS] [--debug]
# Default config file for evaluation is DeepH-E3/deephe3/defa... |
9ee08a930460d773638d902ed8ee72d455be417bc7a141ef7db756af218c3a5d | Python | 1,242 | 45 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from downward import suites
from lab.reports import Attribute, gm
import os
from common_setup import IssueConfig, IssueExperiment
from relativescatter import RelativeScatterPlotReport
def main(revisions=None):
suite = suites.suite_optimal_with_ipc11()
configs ... |
f0be315fa643b58af3fc308689fe2dcaf9e8b8483f45c9f71f69bc024be13021 | Python | 1,242 | 45 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from downward import suites
from lab.reports import Attribute, gm
import os
from common_setup import IssueConfig, IssueExperiment
from relativescatter import RelativeScatterPlotReport
def main(revisions=None):
suite = suites.suite_optimal_with_ipc11()
configs ... |
f383bc9de3b1bce84d7981084b4a23c625e679274ffe62978682b0a446446f89 | Python | 1,242 | 56 | from __future__ import print_function
import unittest
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from soundsig.quasirand import quasirand
class QausirandlTest(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test2... |
08c01b53c8dc419c6f40827e20d5e1233de76c83c56f4a35e6269a52b7472014 | Python | 1,243 | 53 | #!/usr/bin/env python
import boto3
import zipfile
from StringIO import StringIO
def get_lambda_function(script_name='lambda_function.py'):
buf = StringIO()
with zipfile.ZipFile(buf, 'w') as z:
z.write(script_name)
buf.seek(0)
return buf.read()
client = boto3.client('lambda')
# delete the fu... |
1705cd62616249f1eff83dea1efd7b92c989c71077d766c5c275944f01933d6c | Python | 1,243 | 31 | #
# MIT License
#
# Copyright (c) 2022 GT4SD team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge,... |
9aecd0854245250c5e8aa5e4541bd99eea1f9be5a4d32e1a090942e57522f78b | Python | 1,243 | 14 | """posthoc_sff_general_t1_2026-09-29.py (POST HOC, descriptive). SFF_GENERAL truth T1 ended at the noise floor (1.02x the
truth's own loss) but only 83.2% correct. Which types are wrong there, and how big are they?"""
import sys; sys.path.insert(0, 'D:/eucys/03-CODE')
import pandas as pd, SIGN_FROM_FUNCTION as F, SFF_G... |
bd0c18888f221b3ab0a7c0193b4ec7779137c2080616fe4316b407810eeb9c8a | Python | 1,244 | 49 | ### Submit script "XY.py" to HPC (Slurm) cluster
import subprocess
### Script 1
## Configurable job parameters
job_name = "create_neural_dataframes_upper" # Name of the job
output_file = f"{job_name}.out"
error_file = f"{job_name}.err"
script_to_run = "create_neural_dataframes_from_matrices_upper.py" # Name of the scr... |
178a4e81ebfaa6a62b7af4dbd15d0df0554da341054b0a97bfd46efe4bbf0c55 | Python | 1,245 | 36 | """Run analysis
---------------
Analyze the spiking network activity of the mesocircuit.
"""
###############################################################################
# Import the necessary modules.
import os
import sys
import mesocircuit.mesocircuit_framework as mesoframe
import mesocircuit.analysis.spike_ana... |
dd2c2764f62c460bc6b4038354ac2cbdef25063e6687c3288cc4d3ea6e1b746c | Python | 1,245 | 45 | import math
class Item:
def __init__(self, fn: str, assessment_id: int, item_id: float, score: float, visible: float, right_place: float,
drawn_correct: int):
self.__filename = fn
self.__assessment_id = assessment_id
self.__item_id = item_id
self.__score = float(s... |
2a441e8f9c0879b08c070b66442c0e5736b31483e18afb7b10aad194285c6088 | Python | 1,246 | 32 | # regtools/tests/test_preview_points_overlay.py
import os
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
import numpy as np
import pytest
pytest.importorskip("PySide6")
from PySide6.QtWidgets import QApplication
from regtools.registration.gui.dialogs import Preview2DDialog
_app = QApplication.insta... |
0fb0615217b39a68c5c511d94301ce73d56148f174ca0074708e0d30fa0d6346 | Python | 1,247 | 28 | #
# MIT License
#
# Copyright (c) 2022 GT4SD team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge,... |
5a9fa655d897f7d9f6754601493facd348be4240302d319113a4606301967166 | Python | 1,247 | 14 | """Post hoc audit of WORM_REAL (5 Oct): orientation, response-sign asymmetry, strain. Not a test."""
import numpy as np
D = np.load('D:/eucys/02-DATA/celegans/randi2023/worm_atlas.npz', allow_pickle=True)
chem, gap, occ, q, dFF, prod, nts = D['chem'], D['gap'], D['occ'], D['q'], D['dFF'], D['producers'], [str(x) for x ... |
731181ceecb646ba3778b83c637957e352c40d9708e0c89b094e8e6a19755bb4 | Python | 1,247 | 36 | import argparse
import torch
import torch.onnx
from basicsr.archs.rrdbnet_arch import RRDBNet
def main(args):
# An instance of the model
model = RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=4)
if args.params:
keyname = 'params'
else:
keyname = 'pa... |
d21055ce8d75788460fd5effced5abd1329e73672adb8783fc27c432ad8285bf | Python | 1,247 | 27 | # Copyright 2019 Murdoch Children's Research Institute,
# Melbourne, Australia
#
# 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 req... |
48784b0662570eceb115e289fba4267a906a7320fb1edca1bead411cec2bc772 | Python | 1,248 | 58 | '''
Module that queries the database for easier coding in other scripts.
20 Oct. 2021 By Jordy Schifferstein
'''
import sqlite3
class DBConnection:
def __init__(self, conn):
self.conn = conn
self.cur = conn.cursor()
def query(self, sql):
'''
Function that queries the loaded d... |
b68f8a1f10368801e590e956d291720a50fe1654b93a4f60cbe7095657c11a35 | Python | 1,249 | 43 | import dill
import sys
import time
import traceback
import pickle as pickle
try:
import binutil # required to import from dreamcoder modules
except ModuleNotFoundError:
import bin.binutil # alt import if called as module
from dreamcoder.utilities import eprint
if __name__ == "__main__":
sys.setrecursio... |
06871c67c0dbfa55f21f181cc2a1034a12e1adeb775d94f15c493c06d6ce9204 | Python | 1,250 | 50 | import sys
sys.path.append("/Users/dgront/src.git/bioshell/bin")
from pybioshell.core.data.io import Pdb
if len(sys.argv) < 2 :
print("""
Checks if a given structure has chain breaks
USAGE:
python3 check_structure.py input.pdb
EXAMPLE:
python3 check_structure.py 2gb1.pdb
CATEGORIES: core/calc/struc... |
44c2344915c43213dd3bb0d7ec79bb341933bdc7b2edbee4b6f86e1b09228585 | Python | 1,250 | 55 | #!/usr/bin/env python3
from scipy.special import gamma, factorial, hyp2f1
"""
This script provides DOTNB functions
Written by Ruoyu Chen
"""
def DOTNB_mean(r1, p1, r2, p2, k):
q1 = 1-p1
q2 = 1-p2
dmean = ((r1*q1)/p1) - (r2*q2/p2)
return dmean
def DOTNB_var(r1, p1, r2, p2, k):
q1 = 1-p1
q2 =... |
8a0f151bac16fe07d8ac1f19e3b3e8d666b67db4f862f177479531cdb063abff | Python | 1,251 | 37 | import numpy as np
import yacs.config
class RandomErasing:
def __init__(self, config: yacs.config.CfgNode):
aug_config = config.augmentation.random_erasing
self.p = aug_config.prob
self.max_attempt = aug_config.max_attempt
self.sl, self.sh = aug_config.area_ratio_range
self... |
bacaf24656e4167c463fb821ed6177846ecc808761932ae19fee192a0a5eeb4e | Python | 1,251 | 47 | from __future__ import annotations
import pytest
redun = pytest.importorskip("redun")
from pathlib import Path
from quacc import flow, job
from quacc.utils.files import copy_decompress_files
@pytest.fixture
def scheduler():
return redun.Scheduler()
def test_copy_files(tmp_path, monkeypatch, scheduler):
... |
01001ebfcf23900b7c04e13bed74cc28925637e1d13b196234fba5ad34b3a704 | Python | 1,252 | 37 | import segm.utils.torch as ptu
from segm.data import ImagenetDataset
from segm.data import ADE20KSegmentation
from segm.data import PascalContextDataset
from segm.data import CityscapesDataset
from segm.data import Loader
def create_dataset(dataset_kwargs):
dataset_kwargs = dataset_kwargs.copy()
dataset_name... |
3dab82abdcd2dffcabc611c36f2fdb1a1796e1c3544c0706cc442806d13f7f7e | Python | 1,252 | 44 | # 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... |
f148be0b6ff63ea6661f0e40a0142225d66c6d980173a2443b70dc7d6cab729e | Python | 1,252 | 64 | """
Tests module image
# Author: Vladan Lucic
# $Id$
"""
from __future__ import unicode_literals
__version__ = "$Revision$"
from copy import copy, deepcopy
import unittest
import numpy
import numpy.testing as np_test
import scipy
from pyto.grey.image import Image
#import common
class TestImage(np_test.TestCase... |
f4db5c5b276c62a059448d7a9827324330e191ce1fe5093d9e790f03d7aabda2 | Python | 1,252 | 27 | # 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... |
8baaf5a62c65c2ddd514b6496cd824616eaa073cb6941e72ca9096865d3357e5 | Python | 1,253 | 50 | #!/usr/bin/env python
# Copyright (c) 2019 Intel Corporation
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
"""
This module provides the key configuration parameters for a route-based scenario
"""
import carla
from agents.navigation.local_planne... |
5b046da9444011f12424dc271094d24366a19516ef1c936eef8f35c3a4dd56c4 | Python | 1,254 | 32 | """
toposampling - Topology-assisted sampling and analysis of activity data
Copyright (C) 2020 Blue Brain Project / EPFL & University of Aberdeen
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation... |
15ac143daa7c44bbb05595ed8f18a5f69b348a153f6c46103f54bf6e04eedf73 | Python | 1,255 | 46 | from __future__ import annotations
import pytest
dask = pytest.importorskip("dask")
pytest.importorskip("distributed")
from pathlib import Path
from dask.distributed import get_client
from quacc import flow, job
from quacc.utils.files import copy_decompress_files
client = get_client()
def test_copy_files(tmp_pa... |
866f7ac149690a7a306bf5410aa16e563b90604aed6eff8ef7e21124b9d26614 | Python | 1,255 | 32 | # 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... |
dbbc38523eb8bf917a05406a9dcc0925f7c8da6f085337de867d32d2fdb0106f | Python | 1,255 | 43 | from pathlib import Path
from typing import Any
import elasticai.creator.ir2verilog as ir
from elasticai.creator.file_generation import find_project_root as get_path_to_build
from elasticai.creator.ir import Registry, attribute
from elasticai.creator.ir2verilog import Ir2Verilog, factory
def load_and_plugin(
typ... |
3586e0b2554bb186bc2c3e1da4e57d05e558702441d64bdfef8e33ffd9a9bc7a | Python | 1,256 | 30 | #
# MIT License
#
# Copyright (c) 2022 GT4SD team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge,... |
53912913a88f444b9acb1a35423ec88af15aab207d84b185cf113a896bcd6008 | Python | 1,257 | 42 | """Tests for util methods.
Author: Seth Axen
E-mail: seth.axen@gmail.com
"""
import pytest
import warnings
class TestUtil:
def test_deprecated(self):
from e3fp.util import deprecated, E3FPDeprecationWarning
@deprecated("1.1", remove_version="1.3", msg="DEPRECATED!!!")
def dep_method():
... |
6602c346030cd09f836f94d411d7c3ec148ca8f5f508d046099750109a5d5939 | Python | 1,257 | 35 | from poseConfig import aliceConfig as conf
import numpy as np
import os
import PoseUNet_resnet
from sklearn.metrics import precision_recall_curve
from matplotlib import pyplot as plt
conf.cachedir += '_moreeval'
conf.use_unet_loss = True
conf.pretrained_weights = '/groups/branson/bransonlab/mayank/PoseTF/data/pretrain... |
86a19d5570a5727754aa58e0f354b3caad22430e760718689bb2f6f409cb9f21 | Python | 1,257 | 28 | #
# MIT License
#
# Copyright (c) 2022 GT4SD team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge,... |
a5b53e4ef3023129dd3c7f8f1543b48ebf3fc38b9170e5e5f358458ebc6b45df | Python | 1,257 | 48 | """
Parallelized superlets time-frequency transform of multiple trials.
Author: James Bonaiuto <james.bonaiuto@isc.cnrs.fr>
Adaptation: Sotirios Papadopoulos <sotirios.papadopoulos@univ-lyon1.fr>
"""
import numpy as np
from joblib import Parallel, delayed
from superlet import scale_from_period, superlet
def supe... |
d47a93641d7069200bc08936d4b2bd5732c24c59daddef4a1cc67253fe8c860f | Python | 1,257 | 27 | import tensorflow as tf
import numpy as np
# Elman dynamics
class RNN():
def __init__(self, input_size, hidden_size, add_noise):
xav_init = tf.contrib.layers.xavier_initializer
self.input_size = input_size
self.hidden_size = hidden_size
self.W = tf.get_variable('W... |
08188d5045ac8e61cd2e8309cbc36f1752b75e8bf32497f1fdbee51497e549ac | Python | 1,258 | 51 | import math
import meep as mp
from meep import mpb
# Compute the band structure for a Bragg mirror consisting of a
# sinusoidally-varying dielectric index.
# The index will vary sinusoidally between index-min and index-max:
index_min = 1
index_max = 3
# Define a function of position p (in the lattice basis) that r... |
3e7b7d1a28143de1fdf6a9ea146e73142eadfebc9c7524c02c1972be4d9bf2bf | Python | 1,258 | 39 | """Force field selection and padding resolution unit tests."""
import pytest
from openmm import unit
from colabmda.openmm.modular.em import _resolve_padding, _select_forcefield
def test_forcefield_selection():
# Valid pairings
ff_opc = _select_forcefield("ff19SB", "opc")
assert ff_opc["protein_xml"] == ... |
ab87716e3d8f5eb392e1ea60cc2f8a3cbf7d65f67d81cfc7b69752eae30b6f30 | Python | 1,258 | 52 | """napari plugin."""
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import napari.types
def deconvolve(
image: "napari.types.ImageData",
psf: "napari.types.ImageData",
image_pixel_size: float = 0.1,
image_zstep: float = 0.5,
psf_pixel_size: float = 0.1,
psf_zstep: float = 0.1,
it... |
f153e9c0bf8867eadc80d23701cc1405cdf57e387e1145801457930b177dee8a | Python | 1,258 | 25 | from sklearn.neighbors import NearestNeighbors
def sort_min_diff(amat):
'''this function takes in a SNP matrix with indv on rows and returns the same matrix with indvs sorted by genetic similarity.
this problem is NP, so here we use a nearest neighbors approx. it's not perfect, but it's fast and generally perf... |
14da7b4bf1d31ea283341deda7f48780c21c004bb61006f7dd98027aaa8e1806 | Python | 1,260 | 37 | import numpy as np
import jax.numpy as jnp
from ase import Atoms
from sella.internal import make_internal
def _scaled_distance(pos, scale):
return scale * jnp.linalg.norm(pos[1] - pos[0])
def test_make_internal_preserves_kwargs():
"""Fixed eval kwargs passed to make_internal must survive instantiation.
... |
5c8d78c84d5b4ceee88f23176d92f5632faa88d04f6f46a19a37de0abb32efc8 | Python | 1,260 | 41 | #!/usr/bin/env python
#================================================================
# Copyright (C) 2021 Yufeng Liu (Braintell, Southeast University). All rights reserved.
#
# Filename : image_utility.py
# Author : Yufeng Liu
# Date : 2021-07-03
# Description :
#
#=================... |
ddb3bff161ee34fb9893a54623202fa47b07002a57419b55e86f216484ab8f3d | Python | 1,260 | 52 | def train_model(config):
## Instantiate model
if config['model'] == 'gmm':
from BEBE.models.gmm import gmm as m
elif config['model'] == 'kmeans':
from BEBE.models.kmeans import kmeans as m
elif config['model'] == 'vame':
from BEBE.models.vame import vame as m
elif config['model'] =... |
6faab574197ff0c6dfb2d0c9654a6a7fba25f559d8cbc9ed93c77aeb69c4b3b1 | Python | 1,261 | 35 | # ----------------------------------------------------------------------
# Copyright (C) 2015, Numenta, Inc. Unless you have an agreement
# with Numenta, Inc., for a separate license for this software code, the
# following terms and conditions apply:
#
# This program is free software: you can redistribute it and/or mo... |
8779297a17abe1c4cd81d0df37689b39163fe98ed8f2e5cbee5de840b7e34df9 | Python | 1,262 | 42 | # -*- coding: utf-8 -*-
#
__version__ = '2.1.1'
from pinn.networks import get as get_network
from pinn.models import get as get_model
from pinn import report
def get_calc(model_spec, **kwargs):
"""Get a calculator from a trained model.
The positional argument will be passed to `pinn.get_model`, keyword
a... |
ca8476f328c867f27fb95b0b3d1e3506e8c94ea5e9429a39449a2f2503ce2922 | Python | 1,262 | 43 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
from downward import suites
from lab.environments import LocalEnvironment, MaiaEnvironment
from common_setup import IssueConfig, IssueExperiment, is_test_run
REVS = ["issue551-base", "issue551-v4"]
BENCHMARKS = os.path.expanduser('~/downward-benchmarks')
SUI... |
30a712037f7b8330748474a3b5f4a10d871b5d77b69293db901fff0f3cb8c0db | Python | 1,263 | 46 | from collections.abc import Iterable, Iterator
from pathlib import Path
from elasticai.creator.hw_function_id import HwFunctionIdUpdater as _generalUpdater
def _replace_id_in_vhdl(code: Iterable[str], id: bytes) -> Iterator[str]:
def split_hex(hex: str):
for i in range(0, len(hex), 2):
yield ... |
b48dff715f643610028abd22492a6f5993e0d7a87a8c4d201b9a6cbc95d0eada | Python | 1,263 | 48 | # SPDX-FileCopyrightText: 2024 Blue Brain Project / EPFL
#
# SPDX-License-Identifier: AGPL-3.0-or-later
'''
Compute maximal simplex lists for all connectomes
Author(s): Daniela Egas S.
Last updated: 01.2024
'''
import sys
sys.path.append('../../../library')
from structural_basic import *
def main():
for conn in... |
d8de96cd253c62c9a568b553b00229865ba851440b6297cf84f945d69cc8fcf4 | Python | 1,263 | 41 | import torch
from torch.nn import Linear as Lin, Sequential as Seq
import torch.nn.functional as F
from torch import nn
class EDGE(torch.nn.Module):
def __init__(self, input_dim, dropout=0.2):
super(EDGE, self).__init__()
hidden=128
self.parser =nn.Sequential(
nn.Linear(inpu... |
002c69379be806ff4a1d2fccb4942796047cd5c695ae30f3bcd9b13f30e9ab5c | Python | 1,264 | 44 | # 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... |
29065cf3216ce6f8c92c2d4dd81e146fab188c65e2e6bf070a3a51e8886c3902 | Python | 1,264 | 52 | import sys
from pybioshell.core.data.io import Pdb
from pybioshell.core.calc.structural import ProteinArchitecture
if len(sys.argv) < 2 :
print("""
Shows how to use BetaStructuresGraph class from Python
USAGE:
python3 betastructures_graph.py input.pdb
EXAMPLE:
python3 betastructures_graph.py... |
4535a466b9d67cc7120a3d52692c98c34e6c55a6d6c3ed035a4f5d2c84d6572b | Python | 1,264 | 36 | import os
import tempfile
from elasticai.creator.nn.integer.vhdl_test_automation.create_makefile import (
create_makefile,
)
def test_makefile_creation():
with tempfile.TemporaryDirectory() as temp_dir:
stop_time = "5000ns"
create_makefile(temp_dir, stop_time=stop_time)
makefile_path... |
4e03ada0e740a7e220b3ba4ec26cd551b85efa773aa9fe593779c4883e863825 | Python | 1,264 | 47 | import numpy
import torch
from torch.utils.data import Dataset
def get_torch_dtype(numpy_dtype):
if numpy_dtype == numpy.float32:
return torch.float32
elif numpy_dtype == numpy.float64:
return torch.float64
def torch_fill_diag(t, number, dtype, device):
size = t.shape[0]
mask = torch... |
925317ec1542f8580a50472d8246a59fe8348dd261a3bb751d5443ee32be038f | Python | 1,264 | 31 | from elasticai.creator.base_modules.adaptable_silu import (
AdaptableSiLU as AdaptableSiLUBase,
)
from .precomputed_module import PrecomputedModule
class AdaptableSiLU(PrecomputedModule):
def __init__(
self,
total_bits: int,
frac_bits: int,
num_steps: int,
sampling_int... |
b014f1240ee30d7e10ed29a5aeeeab8a2e6f62e97969f51771d5d0b58e5e97e4 | Python | 1,264 | 48 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
from lab.environments import LocalEnvironment, BaselSlurmEnvironment
import common_setup
from common_setup import IssueConfig, IssueExperiment
DIR = os.path.dirname(os.path.abspath(__file__))
BENCHMARKS_DIR = os.environ["DOWNWARD_BENCHMARKS"]
REVISIONS = ["i... |
be17d6fadccf5be318beb7a5d557f12b3e453a1ae3db1ec64baa1a48ec37a871 | Python | 1,264 | 54 | from io import StringIO
from time import sleep
from memory_profiler import profile
try:
import tracemalloc
has_tracemalloc = True
except ImportError:
has_tracemalloc = False
output = StringIO()
# allowable error in MB
EPSILON = 0.0001
def test_memory_profiler(test_input, expected):
mem_prof(test_i... |
fcc9b0708def3cc9625c5435ef5aa66a2b1825ae72e2d91be95f456a3ee416fc | Python | 1,264 | 55 | '''
Created on 1 May 2018
Utility functions.
@author: Miguel Molina Romero, Technical University of Munich
@contact: miguel.molina@tum.de
@License: LPGL
'''
import numpy as np
class DryException(Exception):
def __init__(self, message, errors=0):
# Call the base class constructor with the parameters it... |
4a391497bb0320eb1b5a017fc568ac4ab5df6cd408d2f257cadfbcbeb441a722 | Python | 1,265 | 49 | #### Markos et al 2024
#### CytoTRACE pseudotime calculation based on integrated data
#### Can be run from bash by `python 03_Cytotrace_pseudotime.py` (with designated conda environment activated!)
# setup ####
import os
print("Current working directory: {0}".format(os.getcwd()))
import scanpy as sc
import numpy a... |
5277db2262a5b6049c82156aafca124ebba0d6794561abf2a96f1084e91fae9c | Python | 1,265 | 29 | import pandas as pd
from typing import Tuple
import torch
from torch.utils.data import DataLoader, WeightedRandomSampler
from src.dataloaders.tdrg_dataset import TDRGDataset
def get_dataloader(data_root: str,
labels: pd.DataFrame,
batch_size: int,
image_size:... |
ed06e266aa6acdb65d34e91081ce7b3689d59b266a0b7f6e93f050c738c4c864 | Python | 1,265 | 32 | """
Main run function for finding getting single cell features
last modified: András Ecker 01.2023
"""
import os
import logging
from assemblyfire.spikes import SpikeMatrixGroup, single_cell_features_to_h5
from assemblyfire.utils import get_nrn_df
from assemblyfire.plots import plot_r_spikes
L = logging.getLogger("as... |
621ee97ddf3baa098236d4ee72688f9e23f89ed71954a8c6931c167ddf1b0a27 | Python | 1,266 | 49 | import os
import argparse
from source.utils import JsonSaver
import scripts.train as train
import scripts.inference as inference
def get_parser():
parser = argparse.ArgumentParser()
# add subparsers
subparsers = parser.add_subparsers(required=True)
subparsers = train.get_parser(subparsers)
subpa... |
6eb2b172da96e699b311648f62c7c32bc8a748ff4800132aba9f0cc21de57a39 | Python | 1,266 | 32 | """
toposampling - Topology-assisted sampling and analysis of activity data
Copyright (C) 2020 Blue Brain Project / EPFL & University of Aberdeen
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation... |
784b4c80c2a3f251a469a860b2294479e3fa871e76a6930e62e57c80ea696f2c | Python | 1,266 | 30 | from __future__ import division, print_function
import argparse
from topaz.utils.conversions import file_coordinates_to_eman2_json
name = 'coordinates_to_eman2_json'
help = 'convert coordinates table to EMAN2 json format files per image'
def add_arguments(parser):
parser.add_argument('paths', nargs='+', help=... |
62a3f53099414b04b0a375ab087f9aae1eb51862b58aff2484955e12036083e3 | Python | 1,267 | 33 | import pytest
import torch
from lit_models import LitFullModel
@pytest.fixture
def lit_model():
return LitFullModel()
def test_shared_eval_for_checking(lit_model):
# Create a sample batch
batch = (
(torch.randn(128, 10), torch.randn(128, 5), torch.arange(128), torch.tensor([0])),
(torch.ra... |
a25746b97968581eb57deecd3fd64fd9f865bc19818048f16fb3c895ca9d478d | Python | 1,267 | 44 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 10 15:41:01 2021
@author: eveshalom
"""
import numpy as np
from plots_and_filters import MedianFilter
def createR10_withref(S0ref,S0,Tr,fa,T1ref,datashape):
R10_ref = 1/T1ref
ref_frac = (1-np.cos(fa)*np.exp(-Tr*R10_ref))/(1-np.exp(-Tr*R10_... |
769b59950a81702d2bd502383c2d42163ef5bb98b297bff4f414c6abe9d87646 | Python | 1,268 | 48 | # SPDX-FileCopyrightText: 2024 Blue Brain Project / EPFL
#
# SPDX-License-Identifier: AGPL-3.0-or-later
'''
Compute simplex lists for all connectomes and their controls
Author(s): Daniela Egas S.
Last updated: 04.2024
'''
import sys
sys.path.append('../../../library')
from structural_basic import *
def main():
... |
a75b790971a1c1987b30bc53486467c1006aac4cc4f35a3210c24d8642a512e3 | Python | 1,268 | 54 | # external
import pytest
# project
import textdistance
ALG = textdistance.Gotoh
# https://en.wikipedia.org/wiki/Needleman%E2%80%93Wunsch_algorithm
NW_MATRIX = {
('A', 'A'): 10,
('G', 'G'): 7,
('C', 'C'): 9,
('T', 'T'): 8,
('A', 'G'): -1,
('A', 'C'): -3,
('A', 'T'): -4,
('G', 'C'): -5,... |
a87dd9d49c1c95a7f650ea7bb2c8d0c5f5a0ad4a144fedc8a27755ff4bf6d9df | Python | 1,269 | 37 | import os
import cachecontrol
import google.auth.transport.requests
import requests
from flask import request
from google.oauth2 import id_token
from cirrocumulus.auth_exception import AuthException
from cirrocumulus.envir import CIRRO_AUTH_CLIENT_ID
class GoogleAuth:
def __init__(self):
session = reque... |
1f13817dfebd8e658dfe1c2ef14cf621d9b40eb15a85ddcd621f19f2a5719175 | Python | 1,270 | 17 | """POST HOC (not pre-registered), 1 Oct 2026: why does ORN_DA3 ignite on one side only in MIRROR_SCREEN?
Receptor output synapses per side for DA3 and two comparison glomeruli (Shiu et al.'s file).
output: 06-OUTPUT/posthoc_da3_wiring.txt"""
import sys
sys.path.insert(0, 'D:/eucys/03-CODE')
import numpy as np, OFFICIAL... |
9516642e8048f396c8024fe3ce4362f5f64027543f95ecea9df93b2b1fda964e | Python | 1,270 | 33 | # 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... |
9ac34d93dffbab03880cf901d6eb7705881fa00f4dffd57e40afcf84db7201f6 | Python | 1,270 | 48 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import itertools
import os
from lab.environments import LocalEnvironment, MaiaEnvironment
from downward.reports.compare import ComparativeReport
import common_setup
from common_setup import IssueConfig, IssueExperiment, RelativeScatterPlotReport
DIR = os.path.dirname... |
c30344c1f5b11f2909cfec80d9f885b0a670e2667fc30de007b9bc88c228b3eb | Python | 1,270 | 24 | # 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... |
e86cd647977bd13c4dc742e9620804760b92ce240f6a842bf652488eb4cee4f8 | Python | 1,270 | 38 | import os
from torchdrug import data, utils
from torchdrug.core import Registry as R
@R.register("datasets.PCQM4M")
@utils.copy_args(data.MoleculeDataset.load_csv, ignore=("smiles_field", "target_fields"))
class PCQM4M(data.MoleculeDataset):
"""
Quantum chemistry dataset originally curated under the PubChemQ... |
235b6e6aab01b6d86c56c36b111a504b4531c206ac946d9340fde44f55206f76 | Python | 1,271 | 40 | #!/bin/env python3
"""
Plot wave front, wave back and phase singularity
"""
import ithildin as ith
import numpy as np
import matplotlib.pyplot as plt
import sys
from scipy.interpolate import RectBivariateSpline
sd = ith.SimData.from_stem("results/pdl-detection/phase_68")
it = -40
x = sd.linspace(3)
y = sd.linspace(2)
... |
f07bb77b2cce4a8400c33ef6cf76906842076f2ed904566251ccb6338aafcd34 | Python | 1,271 | 28 | #
# MIT License
#
# Copyright (c) 2022 GT4SD team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge,... |
5e2dbd782586abf1b027122cf9dbf870d766d2885cb1dce114b8d9b214837c15 | Python | 1,272 | 28 | #
# MIT License
#
# Copyright (c) 2022 GT4SD team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge,... |
b30e3aa65b06155a2c7638b2c45b1a8ff52f4d80c1a8a8f6d7c5d8e0f85ac5a1 | Python | 1,272 | 39 | """
Optuna enqueue_trial example that optimizes a classifier configuration using sklearn.
In this example, we optimize a classifier configuration for Iris dataset. We start a study with
given parameter values, such as a default and a manually suggested one.
"""
import optuna
import sklearn.datasets
import sklearn.m... |
942026c96895cee2dd60886a9549158113adb28c155a095f513602a0837e2b4a | Python | 1,273 | 36 | from numpy import cos, pi, sqrt, logical_and, ndarray, nan
def tetrachoric_corr(vec1: ndarray, vec2: ndarray) -> float:
"""
Calculates the tetrachoric correlation between two binary vectors, vec1 and vec2.
:param vec1: A 1D binary numpy array of length n representing the 1st dichotomous (1/0) variable.
... |
ffd1ad7077bc74369a8806f45b4f5ea33c48a7ff2a28118261ee7d5c21cb7d25 | Python | 1,273 | 53 | import autograd.numpy as np
import autograd.numpy.random as npr
from autograd import grad
try:
from autograd.misc.flatten import flatten
except ImportError:
from autograd.util import flatten
def time_flatten():
val = {
"k": npr.random((4, 4)),
"k2": npr.random((3, 3)),
"k3": 3.0,
... |
1c08d7c8d8b9f8453a19314e9d520d2a93f937bcf0982e9515243271d3d2870c | Python | 1,274 | 50 | """Utility functions for dealing with deformations."""
from __future__ import annotations
from typing import TYPE_CHECKING
from pymatgen.analysis.elasticity.strain import DeformedStructureSet
from pymatgen.io.ase import AseAtomsAdaptor
if TYPE_CHECKING:
from collections.abc import Sequence
from ase.atoms i... |
b9281cd093f4484940bff5182a76a9dacfcd65994d4877dabf2aa45582eceee3 | Python | 1,274 | 27 | #
# MIT License
#
# Copyright (c) 2022 GT4SD team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge,... |
19822849ce7d0e2878693e8148ec5aaaa4134c8110c603e41735f03de6da9f87 | Python | 1,275 | 30 | # 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... |
9717e46d8c29e6e0ed0229e4f2c894016e716e3fdaa44cde0e13f100f930b7bc | Python | 1,275 | 41 | import torch
import math
import torch.nn as nn
from torch.nn.parameter import Parameter
class GraphConvolution(nn.Module):
"""
Simple GCN layer, similar to https://arxiv.org/abs/1609.02907
"""
def __init__(self, in_features, out_features, bias=True):
super(GraphConvolution, self).__init__()
... |
fd20dd42456034d785a6fe81f65af21bde1419e4d20d643c34e4aabbaa114261 | Python | 1,275 | 44 | import cv2
import numpy as np
"""
This module contains code for performing filtering operations on images
"""
def high_pass_filter(image: np.ndarray,
windowSize: int,
sigma: float) -> np.ndarray:
"""
Args:
image: the input image to be filtered
windowS... |
26adfc133675710a87634763ff89500c4e01bf77e70198f2cccf1eee668c25cb | Python | 1,276 | 49 | ### Submit script "XY.py" to HPC (Slurm) cluster
import subprocess
### Script 1
## Configurable job parameters
job_name = "create_dataframes_upper_CONTROL_length" # Name of the job
output_file = f"{job_name}.out"
error_file = f"{job_name}.err"
script_to_run = "create_dataframes_from_matrices_upper_CONTROL_length.py" #... |
4c04291e902df7dc37c1f0432d8c38b0cfc4d107c69d311f72f4a62b2057cbf2 | Python | 1,276 | 47 | import yaml
def load_config(path, default_path=None):
""" Loads config file.
Args:
path (str): path to config file
default_path (bool): whether to use default path
"""
# Load configuration from file itself
with open(path, "r") as f:
cfg_special = yaml.load(f, Loader=yaml.Lo... |
85d65aabf18cde63274bf9e8779321dbe8c9d1444767552ea1ea9086f7fb8e6d | Python | 1,276 | 33 | import torch
from torch.func import functional_call, vmap, jacrev
# adapted from https://pytorch.org/tutorials/intermediate/neural_tangent_kernels.html (2023-12-28)
def get_parameters(net: torch.nn.Module):
return {k: v.detach() for k, v in net.named_parameters()}
def functionalize(net, neuron_indices=None):
... |
90100b0324bf90865e33b3c84a8eb822b746d9ead7e0327c9a1c418d12f7dc9c | Python | 1,276 | 43 | from pathlib import Path
from typing import Any
import elasticai.creator.ir2verilog as ir
from elasticai.creator.file_generation import find_project_root as get_path_to_build
from elasticai.creator.ir import Registry, attribute
from elasticai.creator.ir2verilog import Ir2Verilog, factory
def load_and_plugin(
typ... |
b61df602436adbc7ac7fad3944333c61c9be06b51dbbf46c655f036a6479bf6e | Python | 1,276 | 47 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import suites
from lab.reports import Attribute, gm
from common_setup import IssueConfig, IssueExperiment
def main(revisions=None):
benchmarks_dir=os.path.expanduser('~/projects/downward/benchmarks')
suite=[
'airport',
'depot',
... |
bf2101ae0e25d85da021da87010cc108016d16b5b0d916c473f11b60d86b8eaf | Python | 1,276 | 49 | DIVIDER_LENGTH = 100
DIVIDER_CHAR = '#'
def template_beg():
print()
print(DIVIDER_CHAR * DIVIDER_LENGTH)
def template_mid(text):
print(DIVIDER_CHAR + ' ' + text)
def template_end():
print(DIVIDER_CHAR * DIVIDER_LENGTH)
print()
def begin_offline_preparation(algorithm: str, dataset: str, mode:... |
7e593c96433987de8a32294b5c603a9481a8aeed7c2dd95e7cbcf2c7180de428 | Python | 1,278 | 38 | """Load and resolve the per-file h5ad field mapping.
A run may carry several ``.h5ad`` points files with different coordinate
layouts, so the mapping travels as one JSON object keyed by points-file path::
{"/data/section09.h5ad": {"obsm_key": "spatial", "order": "yx",
"units": ... |
87b1fd10fd5018a2967404f274f63b4b4382c724e6b69ad34a6a385678789981 | Python | 1,278 | 52 | import sys
from pybioshell.core.data.io import find_pdb
if len(sys.argv) < 2 :
print("""
Moves a given protein structure so its geometric center is located at (0,0,0).
USAGE:
python3 center_protein.py input.pdb [which_model]
EXAMPLE:
python3 center_protein.py 2kwi.pdb 51
CATEGORIES: core/data/io/fi... |
1896d1569d2f12bd5b5fc562ec8ffc0a088391739f9de8ad9bb1a52e74a303f9 | Python | 1,279 | 41 | import numpy as np
try:
import cityscapesscripts.helpers.labels as CSLabels
except:
pass
from pathlib import Path
from segm.data.base import BaseMMSeg
from segm.data import utils
from segm.config import dataset_dir
CITYSCAPES_CONFIG_PATH = Path(__file__).parent / "config" / "cityscapes.py"
CITYSCAPES_CATS_PA... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.