sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
e9f1a9cc5c2d178c2b271b6783f0d904e9ec166c79e69d724d4c27ccbb80a64a | Python | 1,028 | 27 | import os
import io
from setuptools import setup, find_packages
def read(fname):
with io.open(os.path.join(os.path.dirname(__file__), fname), encoding='utf-8') as f:
return f.read()
setup(
name='schnarc',
version='0.0.0',
author='Michael Gastegger, Julia Westermayr, Philipp Marquetand',
... |
8b35cb44125e1767a61d2c39e33ecc505d41409649ee21fcfce4a376bd9f0dc2 | Python | 1,029 | 38 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 3 10:34:13 2023
@author: emma
"""
import numpy as np
import pandas as pd
import SimpleITK as sitk
import os
def get_mask(label_atlas, region_val):
thresh_filter = sitk.BinaryThresholdImageFilter()
thresh_filter.SetUpperThreshold(region_v... |
c47a65640adc5416cc73e3b8a592f09ffc1cdf8e07cd1c6008aa964e93575c47 | Python | 1,029 | 50 | import math
import meep as mp
from meep import mpb
# A triangular lattice of dielectric rods in air. (This structure has
# a band_gap for TM fields.) This file is used in the "Data Analysis
# Tutorial" section of the MPB manual.
num_bands = 8
geometry_lattice = mp.Lattice(
size=mp.Vector3(1, 1),
basis1=mp... |
cc36678d07beaa99e7e33cdc1ac42e2eeb9b83c6d9a4ff0056b8b0e31dad0e07 | Python | 1,029 | 38 | #!/usr/bin/env jython
from ij import IJ
import os
from mpicbg.ij.clahe import Flat
from ij.process import ImageConverter
# http://fiji.sc/wiki/index.php/Enhance_Local_Contrast_(CLAHE)
# http://fiji.sc/cgi-bin/gitweb.cgi?p=mpicbg.git;a=blob;f=mpicbg/ij/clahe/PlugIn.java;h=663153764493547de560c08ee11f2e6b1e7e1a32;hb=H... |
7a837fe74e577ba726e2eabf67f9e4850fe1132b359c73bb76f9160021e4a57c | Python | 1,030 | 27 | #
# Copyright Bradley Lowekamp
#
# 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.txt
#
# Unless required by applicable law or agreed ... |
e1b426dabd5f1512bb4b3a88d2da283e7fcee08f59b19175f6706770b11d3f8f | Python | 1,030 | 32 | import numpy as np
import torch
def iou_score(pred: torch.Tensor, target: torch.Tensor, n_classes: int = 5) -> (torch.Tensor, np.array):
"""
Calculates IoU between a prediction and true label in a multi-class setting.
:param pred: Predicted label
:param target: True label
:param n_classes: Number ... |
2abb1cba763102f2292d77a9466a9a09ff5cd94ce81910cda8ce2ac0a4f777dd | Python | 1,031 | 60 | from .ir2vhdl import (
Code,
DataGraph,
Edge,
Ir2Vhdl,
IrFactory,
PluginLoader,
PluginSpec,
PluginSymbol,
Registry,
ShapeTuple,
type_handler,
type_handler_iterable,
)
from .language import (
Instance,
InstanceFactory,
LogicSignal,
LogicVectorSignal,
No... |
61ad69c69c74f03e29a12518ca5d1fa380f34a6d2a51cee53acc123bba5070aa | Python | 1,031 | 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... |
c013b32405a73cf1061b202d7b49b035c902931f423928955c5f7bb9cfc5680d | Python | 1,032 | 44 | from numpy.random import seed
from pytest import raises
from wonambi.utils import create_data
from wonambi.trans import filter_, frequency, convolve
seed(0)
data = create_data(n_trial=1)
def test_filter_errors():
with raises(ValueError):
filter_(data, low_cut=1000)
with raises(ValueError):
... |
e3854990cef7ead5294a38469c4475ff01d3ef571b090c13bdceb34808137040 | Python | 1,032 | 37 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from common_setup import IssueConfig, IssueExperiment
from relativescatter import RelativeScatterPlotReport
import suites
configs = [
IssueConfig(
"cegar-10K-original",
["--search", "astar(cegar(subtasks=[original()],max_states=10000,max_time=infinit... |
e3f048e2eb92a3f758470b8ac5daef33f11282630659bffa517d779666d2c8d5 | Python | 1,032 | 31 | import argparse
import json
import numpy as np
from scipy import stats
# For 9045 length data prediction (same as sample_submission.json)
# loc : mean of standardized expression from train data
# scale : 1
def postprocess(x):
return stats.norm.cdf(x, loc=0.06201038511068657, scale=1)
if __name__ == '__main__':
... |
85efb86a01c5b9548613659a919848c8caa6a4bbfbc183ec4f9925289c85e518 | Python | 1,033 | 33 | import subprocess
from sleeplab_format import writer
from pathlib import Path
def test_write_dataset(dataset, tmp_path):
ds_dir = tmp_path / 'datasets'
writer.write_dataset(dataset, ds_dir)
# Assert that the created dataset is equal to tests/datasets
tests_ds_dir = Path(__file__).parent / 'datasets'... |
9a9f905a89cfe34237c4918add754ef86b3d6b7523ce5aaa126a7d88b247f45e | Python | 1,033 | 39 | # SPDX-FileCopyrightText: 2015 Eric Larson
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import division
from datetime import datetime
from pip._vendor.cachecontrol.cache import BaseCache
class RedisCache(BaseCache):
def __init__(self, conn):
self.conn = conn
def get(self, key):
... |
c4349a16f244c3520b55f128eb6a66971c77cd6991939a17ca95061503120bef | Python | 1,033 | 34 | import pytest
import elasticai.creator.nn.fixed_point as nn_creator
from elasticai.creator.arithmetic import FxpArithmetic, FxpParams
from tests.integration_tests.nn.fixed_point.precomputed_routine import (
routine_testing_precomputed_module,
)
@pytest.mark.ghdl
@pytest.mark.parametrize(
"total_bits, frac_bi... |
4d3f04b0c13ff903f63112bf5aeba80c47d1d90aadb62016969b3dba6358f4ce | Python | 1,034 | 32 | from typing import Any
import torch
class IdentityStepFunction(torch.autograd.Function):
@staticmethod
def forward(ctx: Any, *args: Any, **kwargs: Any) -> torch.Tensor:
if len(args) != 2:
raise TypeError(
"apply() takes exactly two arguments "
"(x: torch.Te... |
e2bc76f74e4c5941c355b73278a20025f9c2eae5d65defa9682b941eb0896a5f | Python | 1,034 | 37 | import torch
from elasticai.creator.nn.fixed_point.conv1d.layer.batch_normed_conv1d import (
BatchNormedConv1d,
)
def conv1d(signal_length: int, bias: bool, affine: bool) -> BatchNormedConv1d:
return BatchNormedConv1d(
total_bits=4,
frac_bits=1,
kernel_size=2,
signal_length=si... |
ed39cecd1c33aba8b90701f78b33de8131746976298f795a92ba63e380f8b91f | Python | 1,034 | 31 | def calcCcTopScore(guideSeq, otSeq):
"""
calculate the CC top score
see http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0124633#sec002
# no mismatch -> most likely off-target
>>> int(calcCcTopScore("GGGGGGGGGGGGGGGGGGGG","GGGGGGGGGGGGGGGGGGGG"))
224
# mismatch in 5' part
... |
06fb84a876d3ba7bb9fb1fa497dcb854e610e8f10049a18ebf99440691042267 | Python | 1,035 | 38 | #!/usr/bin/env python
import sys, re
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
INFILE = sys.argv[1] if (len(sys.argv) == 2) else "expected_outputs/stdout.out"
x_before = []
y_before = []
z_before = []
x_after = []
y_after = []
z_after = []
for line in open(INFILE) :
tokens = re.sp... |
3d5391f9256611577e6c588d761e342b5916aeb2fdba18fcd256fcd5f8df7346 | Python | 1,035 | 40 | #!/usr/bin/env python
from IlluminaBeadArrayFiles import GenotypeCalls, BeadPoolManifest, code2genotype
import sys
import os
import glob
import argparse
parser = argparse.ArgumentParser("Generate a Callrate report from a directory of GTC files")
parser.add_argument("manifest", help="BPM manifest file")
parser.add... |
d6c7ff66ac134a7ced176debd16d970eef0c7433846e792cb64b7ebd67ea6510 | Python | 1,036 | 37 | from pathlib import Path
import SimpleITK as sitk
from wsilearn.wsi.wsd_image import ArrayImageWriter
def load_mha(path, meta=False):
image = sitk.ReadImage(str(path), imageIO="MetaImageIO")
arr = sitk.GetArrayFromImage(image)
if meta:
keys = list(image.GetMetaDataKeys())
mdata = {k:imag... |
7115a8c8d958ec49cf8ca776a2fe79551320dc82d323f066f6a68c99f3cc5a73 | Python | 1,037 | 31 | '''
Script to display the kinase results in a .html file
'''
from jinja2 import Environment, FileSystemLoader
from matplotlib import colors, cm
import pandas as pd
import numpy as np
file_loader = FileSystemLoader('.')
env = Environment(loader=file_loader)
template = env.get_template('kinase_table_template.html')
R... |
7e55154ad9c9210dafd706e3dad7a771e02ff87019c0c7b55b65bff9b3b1fe70 | Python | 1,037 | 34 | import asyncio
import pathlib
import ssl
import websockets
user1_msp_dir = "/mnt/e/fabricdev/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/"
user2_msp_dir = "/mnt/e/fabricdev/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/us... |
dec18b6ca22d04d60f520ff73fb3f67e5ce0dc484b5e0c2cfdfbe827229acf1b | Python | 1,037 | 37 | """Testing CLI command view."""
import os
import matplotlib.pyplot as plt
from treem import Morph
from treem.utils.plot import plot_neuron, plot_points, plot_section
def test_plot_neuron(tmp_path):
"""Tests plot_neuron."""
os.chdir(os.path.dirname(__file__) + '/data')
fig = plt.figure()
ax = fig.ad... |
dfac41c780646cea3efc672c71622c577e145945c38f8be555e1659d6ed548c8 | Python | 1,037 | 51 | # Parameter values
figdir = "figures/" # where to save figs
datadir = "data/" # where to load data from
resdir = "results/"
stylesheet = "styles/ingie.mplstyle" # fig formatting
# Colors
blue = "#809fff"
pink = "#ff95ff"
green = "#8aff8a"
# Tuning
kappa_pre = 2
alpha_pre = 0.5
kappa_w = 3
alpha_w = 0
# Network size ... |
f281be9bb261def76a7f9d3b35ae63599ae9cba843ed364b8db2b226a5088150 | Python | 1,037 | 43 | from numba import jit, prange
import numpy as np
@jit(nopython=True, nogil=True, fastmath=True, cache=True)
def raf(params, stim, fs: float = 1000.0):
Vr = 1
x = 0
y = 0
dt = 1 / fs
stim_amp = params[0] / dt
b = params[1]
w = 109 * 2 * np.pi#params[2] * 2 * np.pi
nonlinearity_gain = ... |
e585cf5b5b1a6d59f98e9676e6c523785ea28f7ff8a1d262c145a2e27443d837 | Python | 1,038 | 34 | from functools import reduce
from typing import Any, Callable, Dict
from . import formats
from .error_reporting import detailed_errors, ValidationError
from .extra_validations import EXTRA_VALIDATIONS
from .fastjsonschema_exceptions import JsonSchemaException, JsonSchemaValueException
from .fastjsonschema_validations ... |
275677922c2bc1a9c9e3645d4daaab9c219d092e7deeca4b7479b242873d68b5 | Python | 1,039 | 40 | """
Standalone GUI for NIfTI creation from TIFF images.
"""
import os
import sys
# Ensure project root is on sys.path for module imports
from regtools import get_project_root
_project_root = get_project_root()
if _project_root not in sys.path:
sys.path.insert(0, _project_root)
from regtools.gui.ap... |
d2e62f5330fb76dcc1eddcd79245a2f961db4e00312d5ab0e096da152539a21b | Python | 1,039 | 36 | """Standalone GUI launcher for the Cellpose model-training tool."""
import sys
from regtools.gui.app_scaffold import AppScaffold
from regtools.cellpose_training.gui import CellposeTrainingTab
class CellposeTrainingApp(AppScaffold):
def __init__(self):
super().__init__(
title="Xu L... |
f6dfc08f6e275801419efc585e9c24b2e36cbf8b82c7b88dcd7096e67426261c | Python | 1,039 | 30 | import importlib
import torch
import torch.nn as nn
import torch.distributed as dist
import yacs.config
def create_model(config: yacs.config.CfgNode) -> nn.Module:
module = importlib.import_module(
'pytorch_image_classification.models'
f'.{config.model.type}.{config.model.name}')
model = geta... |
b8397aa543222adfd21e4df358abd047ac725441e364dd293056b67a280104a0 | Python | 1,040 | 39 | from collections.abc import Iterable
from datetime import datetime
from elasticai.creator.file_generation.resource_utils import read_text
from elasticai.creator.hdl_ir import DataGraph
from elasticai.creator.ir2verilog import (
Code,
Registry,
TemplateDirector,
type_handler_iterable,
)
@type_handler_... |
0990c834b08d7be00daecb8147631119c5631e3b648a3dce404e7e511038bd7d | Python | 1,041 | 25 | #
# Interface for integrating with Syncopy
#
# 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 package imports
i... |
16bc29f98a01af59f349cba7853ccce47954610a62def39d8af40d778fa1f774 | Python | 1,041 | 35 | import os
import io
from setuptools import setup, find_packages
def read(fname):
with io.open(os.path.join(os.path.dirname(__file__), fname), encoding="utf-8") as f:
return f.read()
setup(
name="SPaiNN",
version="1.0.0",
author="Sascha Mausenberger, Carolin Müller, Julia Westermayr, Michael ... |
6b971784b0893f249ff30b42be208b6b5edf2a24be13feda9db33dc884d919cb | Python | 1,041 | 28 | import sys
import os
from pathlib import Path
import numpy as np
import pandas as pd
from cobra.io import read_sbml_model
path = Path.cwd()
base_path = "/".join(os.path.abspath(__file__).split("/")[:-2])
sys.path.insert(0, base_path)
draftModelMS = os.path.join(base_path, "docs/models/E_coli_KTE31_388739.3_draft.sbml... |
6dc0b2301e9933ded87384df0c0fb5f766845cd730f1361333b1ac212ccbd04c | Python | 1,041 | 27 | import unittest
from hed import load_schema_version
from hed.models.basic_search_util import convert_query
class TestConvertQueryToForm(unittest.TestCase):
schema = load_schema_version("8.4.0")
def test_basic_convert(self):
this_input = "@Event, Head-part*, Time-interval/1"
expected_output =... |
c884207b38de97aade64f4337a3c5b4d9d04ff51abffc4893eb546eb1ff19855 | Python | 1,041 | 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... |
e68945ea258cb90ecc7e38a054231b1d1b3687ba46cd9f2837a575509f041471 | Python | 1,041 | 37 | from collections.abc import Iterable
from datetime import datetime
from elasticai.creator.file_generation.resource_utils import read_text
from elasticai.creator.hdl_ir import DataGraph
from elasticai.creator.ir2verilog import (
Code,
Registry,
TemplateDirector,
type_handler_iterable,
)
@type_handler_... |
32a4f49e70dadbaaffd4d07d96a4e2d27566cd6b183c00240967587e845134d4 | Python | 1,042 | 40 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Atchuth Naveen
Code developed at UC Irvine.
3D volume reconstruction utilities
Note: Core utilities have been consolidated into the utils package.
This module re-exports them for backwards compatibility.
"""
import os
import sys
import glob
from natsor... |
7146e2f35ce527d83154f34040f702446ca8b8b682497dc27fd178a63d834457 | Python | 1,042 | 40 | from __future__ import annotations
from pathlib import Path
import pytest
FILE_DIR = Path(__file__).parent
ORCA_DIR = Path(FILE_DIR, "orca_run")
def mock_execute(self, directory, *args, **kwargs):
from shutil import copy
copy(ORCA_DIR / "orca.out.gz", Path(directory, "orca.out.gz"))
@pytest.fixture(auto... |
14ae72bc385660408f60458c8ce25e02c73b8751747fd40f40e81cd9337dcc7f | Python | 1,043 | 52 | from .config import (
DEFAULT_CALCULATORS,
MorphometricsConfig,
)
from .engine import (
MorphometricEngine,
)
from .calculators import (
REGISTRY,
register,
build_calculators_from_config,
)
from .builtin import (
METRIC_DESCRIPTIONS,
CellMorphometrics,
SomaMorphometrics,
Conve... |
29b733bca401bec99fb0a1fc59449524d05f9b66793a382452062bd057b76717 | Python | 1,043 | 32 | """
Left-right flip for point clouds represented as
WHS SD rat coordinate triplets in MeshView JSON format
"""
import json
import os
if __name__=='__main__':
print('\nLeft-right flip for point clouds represented as WHS SD rat coordinate triplets in MeshView JSON format\n---')
folder = input('Fol... |
7d18f0431713bd73b04c2d1d0af82bc61541f75df9452e9d0dd0ebc5b58c4d6f | Python | 1,044 | 39 | import torch
from diff_frech_mean.frechetmean.manifolds import Lorentz
from diff_frech_mean.frechetmean.utils import EPS, darcosh
def frechet_hyperboloid_forward(X, w, K=-1.0, max_iter=1000, rtol=1e-6, atol=1e-6, verbose=False):
"""
Args
----
X (tensor): point of shape [..., points, dim]
... |
83c6293beee41cc63a9f154a7118400afc8a79cd5595896cd5eb50f0892940f8 | Python | 1,045 | 32 | from Models.model_utils import ConvolutionBlock, ResidualBlock, FCBlock
import torch.nn as nn
import torch
class InitialModel(nn.Module):
def __init__(self, num_classes):
super().__init__()
self.num_classes = num_classes
self.feature_extractor = nn.Sequential(
ConvolutionBlock(1... |
8bc983b07f342753ea2ff5603a2914e650e233921140791fba66c53c9f3f504e | Python | 1,045 | 33 |
import torch
from torch_geometric.data import InMemoryDataset
class GNNDataset(InMemoryDataset):
def __init__(self, root, types='train', transform=None, pre_transform=None, pre_filter=None):
super().__init__(root, transform, pre_transform, pre_filter)
if types == 'train':
self.data, se... |
e2b39acafe8de33f91b37eb3f8ad600f69a35846985991cf57c6c91055ab5194 | Python | 1,045 | 37 | from collections.abc import Iterable
from datetime import datetime
from elasticai.creator.file_generation.resource_utils import read_text
from elasticai.creator.hdl_ir import DataGraph
from elasticai.creator.ir2verilog import (
Code,
Registry,
TemplateDirector,
type_handler_iterable,
)
@type_handler_... |
198b8449ee0abe4f56d8564b06af4da5e2da642c3ffd3634a54d762805a5cc0c | Python | 1,046 | 30 | ## Precision Sensitivity based on a comparison between any two columns of a dataframe
import pandas as pd
from matplotlib_venn import venn2
import matplotlib.pyplot as plt
df = pd.read_csv('Fig2AB.csv')
# Step 1: Convert columns to lists while removing NaN values
exp_list = df['ath-Pl-Exp'].dropna().tolist()
target_li... |
12dd09a888a602207c4238502e79287fd9e0d3e806bdcc1dea34b2f220d235e8 | Python | 1,047 | 26 | # This script runs the pipeline on single tomograms
import os
os.environ["TF_CPP_MIN_LOG_LEVEL"]="2"
# Here you can choose which GPU to use
os.environ["CUDA_VISIBLE_DEVICES"]="0"
import cryovesnet
dataset_directory = "/mnt/data/amin/cleaned/2new/"
# dataset_directory = "/home/amin/Pictures/ForAmin/wild_overlap/"
pl2... |
2e49a3d4bedcf23b9395e08ace7084a8e0581e05f835d4f0830c09c7400db89c | Python | 1,047 | 25 | import argparse
import sys
import pandas as pd
def get_passengers(gipz, fasta):
common5s = []
passengers = []
loops = []
dd = pd.read_table(gipz)
titles = dd['pSM2c Oligo ID']
hairpins = dd['Hairpin Sequence']
for hairpin in hairpins:
common5s.append(hairpin[0:18])
passenger... |
30d6c0ec372f6a0292cabad502b10d76c757e0daefbd90c80f01a5f51d6c44db | Python | 1,048 | 35 | import pytest
import molecularnodes as mn
from molecularnodes.nodes.geometry import StyleBallAndStick, StyleSpheres, StyleSurface
from .constants import data_dir
from .utils import GeometrySet
formats = ["mol", "sdf"]
@pytest.mark.parametrize("format", formats)
def test_open(format):
molecule = mn.Molecule.load(... |
a25a7aeb63a17077f73028d3665825fea81bf58dfa53ac2f85797020c6314194 | Python | 1,048 | 39 | from collections.abc import Iterable
from datetime import datetime
from elasticai.creator.file_generation.resource_utils import read_text
from elasticai.creator.hdl_ir import DataGraph
from elasticai.creator.ir2verilog import (
Code,
Registry,
TemplateDirector,
type_handler_iterable,
)
@type_handler_... |
b4e55a755bbd598f1919e2830a66c3db69b38b7fb54b978a79cca58ee7049d27 | Python | 1,048 | 26 | from sphericaltexture import SphericalTextureGenerator
import tifffile, os
from pathlib import Path
import pytest
test_folder = Path(os.path.abspath(Path(__file__).parent / 'test_data'))
@pytest.mark.parametrize('ndim', [2, 3])
@pytest.mark.parametrize('projections', [['Shape'], ['Intensity'], ['Shape', 'Intensity']]... |
a5784e1e175fce941c756cb9a9372ebc8d7f3454dbdea56d2f42c2d77ce47973 | Python | 1,049 | 52 |
@profile
def my_func():
a = [1] * (10 ** 6)
b = [2] * (2 * 10 ** 7)
del b
yield a
@profile
def test_comprehension():
# Dict comprehension
d_comp = dict((str(k*k), [v] * (1<<17))
for (v, k) in enumerate(range(99, 111)))
# List comprehension
l_comp = [[i] * (i<<9) for... |
4df36cb207c8cf58ce3256a63d428e160730ca89d59664f5c3e277c8bcde4d5b | Python | 1,050 | 45 | """Utility functions for interfacing with databases."""
from __future__ import annotations
import uuid
from typing import TYPE_CHECKING
from monty.json import jsanitize
if TYPE_CHECKING:
from typing import Any
from maggma.core import Store
def results_to_db(store: Store, results: dict[str, Any] | list[di... |
8fa834e8f7e2b1d849506bee237e6e3652fee20edcae0d0cbdf769e3185941b0 | Python | 1,050 | 37 | import sys
from pybioshell.core.data.io import read_hhpred, create_pir_string
if len(sys.argv) < 2 :
print("""
Reads an output file produced by HHPred, that contains alignments between a query protein and template protein structues.
Writes PIR input files necessary for Modeller to build structural models ... |
82d66c541719a73cf0699a516b97a21678a146291e1de3a01798f97814699886 | Python | 1,051 | 52 |
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import Normal
from torch.optim import Adam
from collections import deque, namedtuple
import copy
def soft_update(target,source,tau):
"""
Parameters
----------
Returns
... |
25bf9694d67bdf55263b4a37f81f5a09d7c8787ef368b7fef10d85ac7be99835 | Python | 1,052 | 39 | import os
import sys
sam_file_path = sys.argv[1]
readids_file_path = sys.argv[2]
use_case = sys.argv[3]
test = sam_file_path.strip().split(".")
sam_file = open(sam_file_path)
seq_dict = {}
for line in sam_file:
if not line.startswith("@"):
line = line.strip()
words = line.split()
if(words... |
3a48350f938a0d0dc6881fc5b1707a4f926696d9817f6705eef0921286a5d3d5 | Python | 1,052 | 39 | """
Visualize the weights of the model
"""
from src.model import ModelSpikeSorter
import matplotlib.pyplot as plt
from math import ceil
import numpy as np
def visualize_weights(model: ModelSpikeSorter, num_per_row=5):
for param in model.parameters():
if len(param.shape) == 3:
weights = param... |
ae1d01c3a70f864c835a269c499d1c2cef74f5f3e9096a21f64ebd27ad9ce259 | Python | 1,052 | 35 | from typing import Iterable, Iterator, Sequence, TypeVar, overload
T = TypeVar("T")
@overload
def batched(vector: Sequence[T], size: int) -> Iterator[Sequence[T]]: ...
@overload
def batched(vector: Iterable[T], size: int) -> Iterator[Iterable[T]]: ...
def batched(vector, size):
def make_batches(vector, size)... |
f386570868393b4b74a9cef028a9260e97e940b7bb70a1a0ac9901b84af67097 | Python | 1,052 | 31 | import pytest
import torch
from elasticai.creator.arithmetic import FxpParams
from elasticai.creator.nn import fixed_point as nn_creator
@pytest.mark.parametrize(
"total_bits, frac_bits, num_steps",
[(4, 3, 4), (6, 4, 32), (8, 5, 64), (10, 6, 16), (12, 7, 128), (12, 11, 64)],
)
def test_hard_tanh_compared_to... |
dc2d605eeb755178f3ea59fa852125ed073959ded0605572b5b45b335f74dc82 | Python | 1,053 | 39 | base_architecture = 'resnet152' # or see in vgg_features.py, resnet_features.py, densenet_features.py
img_size = 224 # to check
prototype_shape = (200, 128, 1, 1)
num_classes = 2
prototype_activation_function = 'linear'
add_on_layers_type = 'regular'
experiment_run = '12092022-200_prototypes'
data_path = '/home/melan... |
440f20bedbc0b01cbd5303115db53e49cd7bd29b81d8c4d81b7041ecfec37322 | Python | 1,054 | 38 | import setuptools
setuptools.setup(
name="MolNexTR",
version="1.0.0",
description="MolNexTR, a novel graph generation model",
entry_points={
"console_scripts": ["molnextr = MolNexTR.molnextr:main"],
},
url="https://github.com/Kohulan/MolNexTR",
packages=setuptools.find_packages(),
... |
514e1406a2d8e443b60ed1076fa4018ab8c4fe20b7c5cfc81517c5eb703424fa | Python | 1,054 | 36 | import pytest
from elasticai.creator.file_generation.on_disk_path import OnDiskPath
from elasticai.creator.nn.fixed_point import Linear
from elasticai.creator.nn.fixed_point.lstm.layer import (
FixedPointLSTMWithHardActivations,
LSTMNetwork,
)
@pytest.mark.simulation
def test_lstm_network_simulation(tmp_path... |
5f95b1054c21a154a96e897c774ac6125d2d3373e09f0a534feff2650b23b3d5 | Python | 1,054 | 55 | """Python wrapper for CUDA-accelerated 3D deconvolution."""
from importlib.metadata import PackageNotFoundError, version
try:
__version__ = version("pycudadecon")
except PackageNotFoundError:
__version__ = "uninstalled"
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from . import _libwrap as li... |
690d781ae32d99e68ea53fdda7eaa41b8159177143ea7d515ab244dc5a10e64c | Python | 1,054 | 53 | """
General utility functions
(c) 2015 C. Schmidt-Hieber
GPLv3
"""
import numpy as np
import bottleneck
def affine_transform_matrix(dx, dy):
"""
Compute affine transformations
Parameters
----------
dx : int
Shift in x
dy : int
Shift in y
Returns
-------
matrix :... |
7ad3927c1c4eff6788e8db791995e75ad2dcbf80703d048f6fdb367136627056 | Python | 1,054 | 40 | import sys, os
sys.path.append(os.path.abspath("."))
import torch
from prosper_nn.models.ensemble import Ensemble
from prosper_nn.models.feedforward import FFNN
# %% Set parameters
batchsize = 10
input_dim = 100
hidden_dim = 20
output_dim = 5
n_models = 5
batchsize = 1
device = torch.device("cuda" if torch.cuda.is_a... |
b51a1cc7f7e05f99e007b4e2cc8132bc54340f6fc5b3af4b671bccdbb993bbc4 | Python | 1,056 | 34 | extensions = dict(
required_params=[('training_frame', "NULL")],
validate_frames="""
# training_frame is required if pre_trained frame is not specified
if (missing(pre_trained) && missing(training_frame)) stop(\"argument \'training_frame\' is missing, with no default\")
training_frame <- .validate.H2OFrame(trai... |
be6e44e9b60625c095e4916ec333bc4d3531bc862b5a7c4902d84dac1fef5944 | Python | 1,056 | 32 | import numpy as np
import os
from PIL import Image
import time
from matplotlib import pyplot as plt
fname = "s6"
dataset_dir = f"//path_to/new_WSIs/Inference/{fname}/"
# dataset_dir = "/path_to/new_WSIs/Inference/INC_SM_0141/"
t_files = os.listdir(dataset_dir)
total_fusedmasks = [f for f in t_files if ... |
e71587e59644255729fdbd098dc0324ee4d7da2cf51f717662d8bb7cf231b9e5 | Python | 1,056 | 37 | import os
import sys
from typing import Union
_Path = Union[str, os.PathLike]
def ensure_directory(path):
"""Ensure that the parent directory of `path` exists"""
dirname = os.path.dirname(path)
os.makedirs(dirname, exist_ok=True)
def same_path(p1: _Path, p2: _Path) -> bool:
"""Differs from os.path.... |
b9f720d5e314e360be21a477175e183ffe936dc7670ebfc7e29f5d417bfff79b | Python | 1,057 | 29 | # Reformats data from CNN matrix to single vector for XGBoost
import numpy as np
data_path = "../data/m6A_train_more_large.npz"
train_val_data = np.load(data_path, allow_pickle=True)
# Get the dictionary from the containing relevant data
train_val_data = train_val_data['save_data_dict'][()]
# Load training and vali... |
458ffb2114b4d988d3039cb4228ba322df6884f9d6ebc685bf6820d438eaa553 | Python | 1,058 | 31 | from PyInstaller.__main__ import run
import shutil
import os
# -F:打包成一个EXE文件
# -w:不带console输出控制台,window窗体格式
# --paths:依赖包路径
# --icon:图标
# --noupx:不用upx压缩
# --clean:在构建之前清理PyInstaller缓存并删除临时文件
FILE_PATH, FILE_FULL_NAME = os.path.split(os.path.realpath(__file__))
NEW_PATH = FILE_PATH + '/dist/main'
if __... |
d0498bcd7f3e9c62641f94c3eeec02ed89b401ef736edaf4b7b6daacc281bec1 | Python | 1,058 | 41 | import pickle
import numpy
import scipy
from scipy import io
ecgs = pickle.load(open('ecgs.pl', 'rb'), encoding='latin1')
print ('Reading pickled file...')
t = ecgs['t']
idx_end = int(numpy.floor(max(t)*1000))
V1 = []
V2 = []
V3 = []
V4 = []
V5 = []
V6 = []
I = []
II = []
III = []
aVL = []
aVR = []
aVF = []
ts = []
fo... |
de6b5d083ffb1a2b2712c2c029c16c8037bfe5ada6a64a9e37bb6d9e9b33074e | Python | 1,059 | 40 | from collections.abc import Iterable
from datetime import datetime
from elasticai.creator.file_generation.resource_utils import read_text
from elasticai.creator.hdl_ir import DataGraph
from elasticai.creator.ir2verilog import (
Code,
Registry,
TemplateDirector,
type_handler_iterable,
)
@type_handler_... |
f0fcf7bda1fb8659729d9d4e6dbe3695c76f708ab4e466aef07d799da2606287 | Python | 1,059 | 36 | import pytorch_lightning as pl
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from models.common import create_decoder, create_encoder
class Classifier(pl.LightningModule):
def __init__(self):
super().__init__()
self.encoder = create_encoder([3, 32, 32, 64, 64])... |
564bd09a566c153b8d9beff54c0eaea6f8bd07617176d45c0fb63a15eb39f5b7 | Python | 1,060 | 44 | import setuptools
with open("README.md", "r") as f:
long_description = f.read()
dependencies = [
"numpy",
"matplotlib"
]
setuptools.setup(
name="treem",
version="1.1.0",
author="Alexander Kozlov",
author_email="akozlov@kth.se",
description="Tree-like morphology data processing",
l... |
b8c3e2e94641b288ebf4f1b7c105b952e9eeefa7065383ca822c569d5dda0098 | Python | 1,060 | 44 | import setuptools
with open("README.md", "r") as f:
long_description = f.read()
dependencies = [
"numpy",
"matplotlib"
]
setuptools.setup(
name="treem",
version="1.0.0",
author="Alexander Kozlov",
author_email="akozlov@kth.se",
description="Tree-like morphology data processing",
l... |
8e5bc8b578df3957072b6f6f3d81ca5c453270f379e02207b18c8ec82ca4fcad | Python | 1,061 | 41 | import warnings
warnings.filterwarnings("ignore",category=DeprecationWarning)
import numpy as np
import tensorflow as tf
import os
import random
from glob import glob
import shutil
seed_value= 7
os.environ['PYTHONHASHSEED']=str(seed_value)
random.seed(seed_value)
np.random.seed(seed_value)
tf.random.set_seed(seed... |
d29698f36259f64ed6bfc133dead7f609074f2f13521c935ce69546545828eb6 | Python | 1,061 | 29 | #!/usr/bin/env python
# ===================== #
# Preprocess of dataset #
# ===================== #
# Usage: python <path-to-this-file>/preprocess.py <your_config>.ini [-n NUM_THREADS]
# Default config for preprocessing data is DeepH-E3/deephe3/default_configs/base_default.ini
# You only have to fill in fields in [dat... |
126b65fde7ff9c21937435cd8c3180581c2876a87434fd2f1bf5c21b62379ab4 | Python | 1,062 | 40 | import cocotb
from cocotb.clock import Clock
from cocotb.triggers import RisingEdge, Timer
from elasticai.creator.testing.cocotb_prepare import read_testdata
@cocotb.test()
async def rom_call_test(dut):
data = read_testdata(dut._name)
clock_period_ns = 10
dut.en.value = 0
dut.clk.value = 0
dut.a... |
1906866feaad945adf5ace348b0156639040c36361a3c8e91323743563974414 | Python | 1,062 | 35 | from typing import cast
import pytest
from elasticai.creator.file_generation.in_memory_path import InMemoryFile, InMemoryPath
from elasticai.creator.nn.fixed_point import BatchNormedLinear
@pytest.fixture
def batchnorm_linear_design() -> BatchNormedLinear:
return BatchNormedLinear(
total_bits=16,
... |
29d0a7958a2a88af9c9668d1014144c8de3e40dcdc3bb9bcea912ee718a9f863 | Python | 1,062 | 39 | # 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... |
382f0862a456a7e593fd126951dea4e1a5a9255f5c3574b5b2d8c9f0bc4287e3 | Python | 1,062 | 36 | import numpy as np
import matplotlib.pyplot as plt
moldata = np.loadtxt('sirius_data.dat')
for i in range(len(moldata)):
pKa = moldata[i,1]
logp0 = moldata[i,2]
logp1 = moldata[i,3]
p0 = 10**(+logp0)
p1 = 10**(+logp1)
ka = 10**(-pKa)
pHexp = [1.0,1.2,2.0,3.0,4.0,5.0,6.0,6.5,7.0,7.4,8.0,9... |
6465bf7c690704cf5e379b0f75c83542bc13e10c032fb524a86d6009de559e5c | Python | 1,063 | 37 | import pytest
import elasticai.creator.nn.fixed_point as nn_creator
from elasticai.creator.arithmetic import FxpArithmetic, FxpParams
from tests.integration_tests.nn.fixed_point.precomputed_routine import (
routine_testing_precomputed_module,
)
@pytest.mark.ghdl
@pytest.mark.parametrize(
"total_bits, frac_bi... |
7c05ff07cc90a44a667f99970b5c63aa6e0d3988aee3d83a6649d63a5fa9c30e | Python | 1,063 | 47 | import numpy as np
import plotly.express as px
from plotly.subplots import make_subplots
import plotly.graph_objects as go
def plot_pts(src: np.ndarray, dst: np.ndarray, symbol1='circle', symbol2='diamond-open'):
fig = go.Figure()
# trace of source point cloud
fig.add_trace(go.Scatter3d(
x = src[... |
f927a6a8f70af37df9762fc9ea7afdddd753df01dd2758d1f6901b73a981b748 | Python | 1,063 | 32 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
class ImgNormalize(nn.Conv2d):
"""Normalize images with the given mean and std value.
Based on Conv2d layer, can work in GPU.
Args:
pixel_range (float): Pixel range of feature.
img_mean (Tuple[float]): Ima... |
58382381e99fe628d222e14e02734d9a2f7963a04a182e879736a6ee3845a4f0 | Python | 1,064 | 42 | import warnings
warnings.filterwarnings("ignore",category=DeprecationWarning)
import numpy as np
import tensorflow as tf
import os
import random
from glob import glob
import shutil
seed_value= 7
os.environ['PYTHONHASHSEED']=str(seed_value)
random.seed(seed_value)
np.random.seed(seed_value)
tf.random.set_seed(seed... |
9a58361869fb55580b69a254d9107a5f1fb998af7c963a0b5bfdb80e12a264d1 | Python | 1,064 | 38 | import numpy as np
import torch
from typing import *
def assign_score(x):
if x < 0.25:
return 0
if 0.25 <= x < 0.75:
return 0.5
if 0.75 <= x < 1.5:
return 1
if 1.5 <= x:
return 2
def assign_bin_single(x, bin_locations) -> int:
for i in range(len(bin_locations)):
... |
7944963f3430960acff4409d82771070fefe5190a5e0bfbb6f0a1ba4b1c3a80e | Python | 1,066 | 48 | # -*- coding: utf-8 -*-
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""
tedana: A Python package for TE-dependent analysis of multi-echo data.
"""
import warnings
from .due import Doi, due
from .info import (
__author__,
__copyright__,
... |
b8bdfab006450835588e91553065f12297d225232dbdd2b7e895c7bbf808d0ac | Python | 1,066 | 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... |
50da110992c73a25ec3775b860994210ab7c3211bb5b4124f765fa29fc79221c | Python | 1,067 | 39 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from downward import suites
import common_setup
from common_setup import IssueConfig, IssueExperiment
from relativescatter import RelativeScatterPlotReport
configs = [
IssueConfig(
"cegar-10K-original",
["--search", "astar(cegar(subtasks=[original()... |
eb4d7c43d51ecc2acacc8e8f33e82d7f088285ff2d5b3f872765150a8f8cbb3d | Python | 1,067 | 39 | from collections.abc import Iterable
from datetime import datetime
from elasticai.creator.file_generation.resource_utils import read_text
from elasticai.creator.hdl_ir import DataGraph
from elasticai.creator.ir2verilog import (
Code,
Registry,
TemplateDirector,
type_handler_iterable,
)
@type_handler_... |
063dce11c887d314cf7b5baea7628ca6163e157afcab557d4d447e0f38563f70 | Python | 1,068 | 34 | # 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... |
2a2964872fa19cd2d191829869c7489e6453fb7eb1735ca256fa29e44c83a9c9 | Python | 1,068 | 31 | # 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... |
ba0310b6d7f844901f17f6c15fb67b7bc17bcb09ee44e042bb28dd358c4ef189 | Python | 1,069 | 32 | #! /usr/bin/env python
from lab.parser import Parser
def add_dominance_pruning_failed(content, props):
if "dominance_pruning=False" in content:
failed = False
elif "pdb_collection_construction_time" not in props:
failed = False
else:
failed = "dominance_pruning_time" not in props
... |
6e19464dcf20bbd80c4e628444c12f8564b3d2aa143e6474b392f745970e8d11 | Python | 1,070 | 35 | def filter_dataframe(df, filters):
df_filter = None
for fi, (key, vals) in enumerate(filters.items()):
df_f = df[key] == vals[0]
for i in range(1, len(vals)):
df_f = (df_f | (df[key] == vals[i]))
if fi == 0:
df_filter = df_f
else:
df_filter = (... |
d529526f1e0cea757efcacdcaa08e8037da4270de22733eb10c50b0cadf79d7d | Python | 1,070 | 38 | import numpy as np
import scipy.signal
import scipy.ndimage
# from numba import jit
from . import utils
# @jit
def ln(input, filter):
try:
outputLinear = utils.conv(input, filter)
except: # Exception as e:
outputLinear = input
return outputLinear[:input.shape[0], :]
# @jit
def synapse(i... |
81f8e9e35ecb46f163e2c162bae220f43c5b77701caef4a19d523ddfa3a612ec | Python | 1,071 | 31 | from torch.utils.data import Dataset
import numpy as np
class Dataset(Dataset):
def __init__(self, temp_data):
self.kssw_list = temp_data['ksw_1'].transpose()[:, 0]
self.fss_list = temp_data['fss_1'].transpose()[:, 0]
self.len = temp_data['ksw_1'].transpose().size
if 'fss_0' in tem... |
85d04b1ef3f10340174632bbefd7c7194f6328ecc30337e3d68f45cbd8732fd9 | Python | 1,071 | 36 | import os
from torchdrug import data, utils
from torchdrug.core import Registry as R
@R.register("datasets.BBBP")
@utils.copy_args(data.MoleculeDataset.load_csv, ignore=("smiles_field", "target_fields"))
class BBBP(data.MoleculeDataset):
"""
Binary labels of blood-brain barrier penetration.
Statistics:
... |
d8f42b468f3d85b1e4fd380c02ee00fa6a763681c67f4270381c51311b9d79d1 | Python | 1,072 | 25 | import gdown
import os
def download_weights(model_name, url, num_class):
output_dir = 'pretrained_{}_weights'.format(model_name.upper())
if not os.path.exists(output_dir):
os.mkdir(output_dir)
output = output_dir + '/{}_{}_pretrained'.format(model_name, num_class)
info = 'Downloading pretraine... |
13c8b1e91ce3cdbba9eae990e4926cf3ec70398c84e586421bec7214e0c6a9c7 | Python | 1,073 | 41 | # 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... |
138cc75a9d31c85c60e8c3b3ef5bf9b06331708cb0cd508d236eb9d014540a8d | Python | 1,074 | 39 | from collections.abc import Iterable
from datetime import datetime
from elasticai.creator.file_generation.resource_utils import read_text
from elasticai.creator.hdl_ir import DataGraph
from elasticai.creator.ir2verilog import (
Code,
Registry,
TemplateDirector,
type_handler_iterable,
)
@type_handler_... |
82823b9796c19cda8783ec43c81611bedb931102f31ad374219b77fae2b6f9ca | Python | 1,074 | 40 | # external
import pytest
# project
import textdistance
ALG = textdistance.Editex
@pytest.mark.parametrize('left, right, expected', [
('', '', 0),
('nelson', '', 12),
('', 'neilsen', 14),
('ab', 'a', 2),
('ab', 'c', 4),
('ALIE', 'ALI', 1),
('', 'MARTHA', 12),
])
def test_distance(left, r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.