sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
9b0cb19f87954f9cf4cc09eced949c569b9662525bb989d8f963261b2e86e349 | Python | 1,323 | 32 | ## Ven diagrams from two columns of any dataframe
import pandas as pd
from matplotlib_venn import venn2
import matplotlib.pyplot as plt
df = pd.read_csv('Fig2AB.csv') ##csv with each column a circle in ven diagram. the script takes in two columns at a time to make a ven diagram.
#Change column names here to plot diff... |
b17892cc12259739df1a5910e74bad4a7e51361706f718a29766743501cf49fb | Python | 1,323 | 45 | from __future__ import annotations
from pathlib import Path
import pytest
from ase.build import bulk, molecule
from monty.json import MontyDecoder, jsanitize
from quacc.schemas.atoms import atoms_to_metadata
@pytest.fixture
def test_cifs():
file_dir = Path(__file__).parent
return file_dir / "test_files"
... |
4a3dd53149a3ff6aa843c7518d4adca92d97a57d4d9c8cd8a3eb42d57bef1338 | Python | 1,324 | 60 | import pytest
import smart
@pytest.fixture(scope="session")
def species_kwargs_A():
return dict(
concentration_units=smart.units.unit.uM,
diffusion_units=smart.units.unit.um**2 / smart.units.unit.sec,
initial_condition=0.01,
D=2.0,
name="A",
compartment_name="Cyto",... |
085d2932bc5e967b13fc012ed8779077aa7f173b55a62d9e97d3007c25910db4 | Python | 1,326 | 76 | # Default parameters used in all simulations if not overwritten by local alternative.
# simulation behavior
global_plottiness = None
pause_on_exit = False
num_runs = 200
speedup = 1000
analyze = None
hist_interval = 100
record_weights = False
# skip inputs when computing neuron and synapse dynamics for performance r... |
400f5e6d8427ef635b1cc1913db3c380018a76231e626a49f0e96ad134ba7f6f | Python | 1,326 | 56 | from src.model import ModelSpikeSorter
from torchsummary import summary
# ARCHITECTURE_PARAMS = {
# "conv1_chans": 25,
# "conv1_size": 3,
# "conv1_stride": 1,
# "conv1_pad": 0,
#
# "pool1_size": 2,
# "pool1_stride": None,
# "pool1_pad": 0,
#
# ###########################
#
# "conv2... |
a23dde0a17047985a9928cac9da60fe65fb943b4e315e2f214eb2a3bf2e20765 | Python | 1,326 | 42 | import numpy as np
import os
from tqdm import tqdm
TRAIN_DATA_DIR='audio/train'
TEST_DATA_DIR='audio/test'
VALIDATION_DATA_DIR='audio/validation'
def get_mean_std(data_dir=TRAIN_DATA_DIR):
mean_list=[]
std_list=[]
for i in tqdm(os.listdir(data_dir)):
data=np.load(data_dir+'/'+i,allow_pic... |
aed946420fb0cbe880369ed1ffee74e5a4b22b281a79d8aa76f0637da6b17ac2 | Python | 1,326 | 49 | """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... |
be76b8bd6816476e77a918fba75b740af647938c16b5e1ce769584df3da18425 | Python | 1,326 | 42 | from pathlib import Path
import os
import cProfile
import pstats
# Set environment variables
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
import cryovesnet
dataset_directory = Path("E:/Amin_Khosrozadeh/emd_30365")
def run_pipeline():
dataset_directory = Path("E:/Amin_Khosro... |
32e39adf50e676b05b33fb9143f1ac77e5dd0b515608109f20ed89c151fd4a5c | Python | 1,327 | 23 | # 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... |
b05ee200608320a33181d3d3ec7153fb4bcc2819fb2c129c8b96df44033c5b8e | Python | 1,327 | 64 | class Properties:
"""
Common properties
"""
energy = 'energy'
forces = 'forces'
gradients = 'gradients'
socs = 'socs'
old_socs = "old_socs"
nacs = 'nacs'
dipole_moment = 'dipoles'
charges = 'charges'
phases = 'phases'
# Only for prediction and calculator
hessian =... |
c7669eff5b0aae26fc8289681ab687702d21e026a19bcc1b3aabee6ac1f77539 | Python | 1,327 | 34 | import copy
def name_active_states(state_values, state_names):
named_states = []
for index, value in enumerate(state_values):
if value: named_states.append(state_names[index])
return named_states
def sparsify_rate_matrix(rate_matrix, state_names, transitions=None):
if transitions is N... |
5cee6a31a7f3cb18e2059414b775dcdf131e829c560e0ae0f8bbbf5ea9ab602b | Python | 1,328 | 35 | #
# 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,... |
743294e74d99ab469e24a3237cb252947f48058906b2f8947f40ff5c062c99bd | Python | 1,328 | 52 | import numpy as np
import matplotlib
import matplotlib.pyplot as plt
#import APT_interface
import poseConfig
import PoseTools
conf = poseConfig.config()
conf.brange = [0,0]
conf.crange = [1,1]
conf.rrange = 30
conf.trange = 10
conf.scale_factor_range = 4.
print('brange = '+str(conf.brange))
print('crange = '+str(conf.... |
79ce0609d86438d27b9fd0b29a96f4a1740a82f038c22c99cd99f51ffa74d3f6 | Python | 1,328 | 42 | import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import shortest_path
def find_neighborhood(e, edges):
neighborhood = []
for _e_a, _e_b in edges:
if _e_a == e:
neighborhood.append(_e_b)
if _e_b == e:
neighborhood.append(_e_a)... |
b7eacf5baa1ad5ab1417c9f90abbe9e0c2aed31e572a53b183868e56b53df128 | Python | 1,328 | 43 | from torch import optim
from torch.optim.lr_scheduler import _LRScheduler
from timm.scheduler.scheduler import Scheduler
class PolynomialLR(_LRScheduler):
def __init__(
self,
optimizer,
step_size,
iter_warmup,
iter_max,
power,
min_lr=0,
last_epoch=-1... |
260d207fd5245956310c18a89c81658ea89150eb472c9f8f3bdbbb616686387f | Python | 1,329 | 56 | from ._attribute import Attribute, AttributeConvertable, AttributeMapping, attribute
from .datagraph import DataGraph, Edge, Node, NodeEdgeFactory, ReadOnlyDataGraph
from .datagraph_impl import (
DataGraphImpl,
DefaultIrFactory,
DefaultNodeEdgeFactory,
EdgeImpl,
NodeImpl,
)
from .datagraph_rewriting... |
83be0646ffdb122c84e44eb776e6397274056840ca7c75ead130ba0671702637 | Python | 1,329 | 47 | from ..neuralnodes.params import Params
import dataclasses
from typing import Tuple
class Param():
name: str
value: float
bounds: Tuple[float]
@dataclasses.dataclass
class Params(Params):
stim_gain: float = 1.0
damping: float = -5.0
frequency: float = 10.0
output_gain: float = 2.0
# ... |
bf12b6fda050c32df5eef5d18260ce10b29e10a77898eac0138f7aef7fbe9d51 | Python | 1,329 | 49 | import torch
from torch.autograd import Function
class ShakeFunction(Function):
@staticmethod
def forward(ctx, x1, x2, alpha, beta):
ctx.save_for_backward(x1, x2, alpha, beta)
y = x1 * alpha + x2 * (1 - alpha)
return y
@staticmethod
def backward(ctx, grad_output):
x1,... |
f6f6c5e7950183ec6defff66ee78af98b07ae9a591795d78ff72737f37eeaf47 | Python | 1,329 | 47 | ################################################################################
# Copyright (c) 2021-2024, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
# Written by D. Jones <djones@llnl.gov> and UCSD collaborators in listed in CONTRIB.md
#
# All rights reserved.... |
289615632b52d93fe8d4f1625332876711fcc470fcbb0246e830f0ece5a64a9b | Python | 1,330 | 45 | import os
import torch
import numpy as np
def list_of_distances(X, Y):
return torch.sum((torch.unsqueeze(X, dim=2) - torch.unsqueeze(Y.t(), dim=0)) ** 2, dim=1)
def make_one_hot(target, target_one_hot):
target = target.view(-1,1)
target_one_hot.zero_()
target_one_hot.scatter_(dim=1, index=target, valu... |
92b52a2eec89bb351834d106c39dd3463f645cffc3858bbbdd3df460d490fe71 | Python | 1,330 | 45 | import argparse
import random
import numpy as np
import torch
from src import config
from src.NICE_SLAM import NICE_SLAM
def setup_seed(seed):
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
np.random.seed(seed)
random.seed(seed)
torch.backends.cudnn.deterministic = True
def main():
... |
79d3ff93051c247f28f07bf65201c387aef916d1e437ad3c54df9fe60a647a45 | Python | 1,331 | 38 | """Unit tests for the 2D registered-point display helper (no napari needed)."""
import numpy as np
def test_drops_ccf_index_column_for_2d():
from regtools.registration.output.napari_viewer import _points_for_display
pts = np.array([[234.0, 10.0, 20.0], [234.0, 11.0, 21.0]]) # (ccf_index, y, x)
... |
874a99abeb59f4c70c19fadacdcbdf551c9e8d117d744c4fe090e8e35f27e162 | Python | 1,332 | 43 |
def fishers_workflow(img_list=None, prefix=None, output_dir=None):
from nimare.meta.esma import fishers
from nilearn.datasets import load_mni152_brain_mask
import nibabel as nib
import numpy as np
import os.path as op
import statsmodels.stats.multitest as mc
mask_img = load_mni152_brain_m... |
d7e4b8420c5f857d1950f3951b94e15816dd6fde9f2014e5e8d1721ae4f30f0e | Python | 1,332 | 36 | # -*- coding: utf-8 -*-
# @title Main
# @file main.py
# @author Romain Beaubois
# @date 06 Oct 2023
# @copyright
# SPDX-FileCopyrightText: © 2023 Romain Beaubois <refbeaubois@yahoo.com>
# SPDX-License-Identifier: GPL-3.0-or-later
#
# @brief
#
# @details
# > **06 Oct 2023** : file creation (RB)
# ... |
e3d9a4d57770c716af1bb583858e02bd3fee4679386c3a9cfd3466a66f32db97 | Python | 1,332 | 36 | #! /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... |
e72b1a64493d223aa92bacefafb5de30df0de53798f24a61955069769415040e | Python | 1,332 | 36 | """
Activate virtualenv for current interpreter:
Use exec(open(this_file).read(), {'__file__': this_file}).
This can be used when you must use an existing Python interpreter, not the virtualenv bin/python.
""" # noqa: D415
from __future__ import annotations
import os
import site
import sys
try:
abs_file = os.p... |
8dbd9d73ba1070c25240599c12dade37fc57c642c5c10efe4f12a6e703fa4044 | Python | 1,333 | 37 | # 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... |
909753f2feb3879a27d7b19b470614b8c6e544dc0b3c939a0c1afa9542e3a1ed | Python | 1,333 | 49 | ### Submit script "XY.py" to HPC (Torque) cluster
import subprocess
### Script 1
## Configurable job parameters
job_name = "create_neural_dataframes_from_matrices_upper_CONTROL_length" # Name of the job
output_file = f"{job_name}.out"
error_file = f"{job_name}.err"
script_to_run = "create_neural_dataframes_from_matric... |
dcac4226609cc71bd7fd6a2821c08436fe083539cd67f220bdd5729e8bef9a59 | Python | 1,333 | 40 | import bpy
def enable_gpus(device_type, use_cpus=False):
preferences = bpy.context.preferences
cycles_preferences = preferences.addons["cycles"].preferences
cycles_preferences.refresh_devices()
activated_gpus = []
for device in cycles_preferences.devices:
if device.type == "CPU":
... |
3f591e012c7e14b753654257187f38c8ed3935880df59c5a059d9ec89bf9c020 | Python | 1,334 | 37 | # Librairies
from sklearn.feature_selection import mutual_info_classif, VarianceThreshold
from sklearn.decomposition import PCA
def select_features_with_high_variance(X, threshold):
"""
Return the variance of the features (shape (n_features)).
VarianceThreshold selects all features whose variance is highe... |
9e0ab7fdac22a7ee8dd0a78a0845f181ebc133e7e289f96627c32f8e647ac59c | Python | 1,334 | 43 | import scipy.stats
import autograd.numpy as np
from autograd.extend import defvjp, primitive
from autograd.numpy.numpy_vjps import unbroadcast_f
from autograd.scipy.special import beta, psi
cdf = primitive(scipy.stats.beta.cdf)
logpdf = primitive(scipy.stats.beta.logpdf)
pdf = primitive(scipy.stats.beta.pdf)
def gr... |
38108784b125dd80424a369f00d4a08d13b0daea51042cc52d8f389bebd2b4e7 | Python | 1,335 | 50 | # pylint: disable=too-many-function-args, invalid-name
""" FBIRN 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("fbirn/FBIRN_AllData.h5... |
b048f2a2b15bd876a8dfcfa6de6845aa284b34bbbe95b33043c6855ef9adeb33 | Python | 1,335 | 30 | # MIT License
#
# Copyright (c) 2024 Zihan Zhang, Yi Zhao, Harbin Institute of Technology
#
# 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... |
e22a13b422626f513640fe490accada0d6ebd07283b0b5a3724d6ad549cd6a0d | Python | 1,335 | 37 | # 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... |
59479b19036fab74321684c65cf24cecf92e2ea0839404fcbcb392296a0cdb74 | Python | 1,336 | 35 | #
# 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,... |
8190abadfaa5689af18a99f24025e3051db3a68af3ead9cb7908460ffdfee380 | Python | 1,336 | 51 | import neurokit2 as nk
import numpy as np
import asyncio
from pylsl import local_clock
from ._messages import SampleMessage
from ._rate import Rate
import labgraph as lg
class ECGState(lg.State):
idx: int = 0
ecg: np.array = None
class ECGConfig(lg.Config):
sfreq: float = 100.
heart_rate: float = 60.... |
f67e7b2e3b643d4de68f4ea9220120db21abbe0519aa3a74440766cb53499aec | Python | 1,336 | 45 | import logging
class Log():
def __init__(self, save_dir):
self.logger = logging.getLogger()
self.logger.setLevel(level=logging.DEBUG)
self.f1 = logging.Formatter(
fmt='[time]%(asctime)s %(message)s \n')
self.f2 = logging.Formatter(
fmt='[time]%(asctime)s %(... |
1599855a33df427097eedb08c238f7921779a9d09bae4f49a76687a83991b0f1 | Python | 1,337 | 47 | 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
from .initi_update import soft_update, hard_update, weights_init_
class QNetwork(nn.Module):
d... |
2097fb11ff3158369b1d4562200d3d2bfb4b64e197a19c024836cf7dc4c9ad92 | Python | 1,337 | 49 | import numpy as np
def e_step(matrix, counts):
"""
Performs E-step of EM algorithm: proportionally assigns reads to features
based on relative feature abundances.
"""
colsums = (matrix * counts).sum(axis=1)[:, np.newaxis]
out = matrix / colsums * counts
return(out)
def m_step(matrix):
... |
9bfdda3a65f66736236c6ec18fb12a5f05fd7c4b2723c4d3bb0c3098e478da33 | Python | 1,337 | 38 | #!/usr/bin/env python
# coding: utf-8
import plotly.express as px
import pandas as pd, os
output_dir = "output_dir/"
dry_lab_dir = "dry_lab/"
to_plot = pd.read_csv(os.path.join(dry_lab_dir, "SciData_gt_demux.csv"))
x_min = to_plot.loc[to_plot['cell_counts'] > 800, 'perc_het_consistent'].min()
y_min = to_plot.loc[t... |
b922ce51cb2b5760a223dbd76594df73a1bab691d0e54388ad2f6fc6ffec22b5 | Python | 1,337 | 34 | # regtools/tests/test_ccf_export_section.py
import json
import numpy as np
import pytest
from regtools.ccf_boundary_editor.io import export_session, section_affine
def test_section_affine_shifts_origin_along_section_axis():
aff = np.array([[0.0, 0.0, 0.025, -5.0], [-0.025, 0.0, 0.0, 5.0], [0.0, -0.025, ... |
076b7f4b73596d0a17f94af0fa05cc11d29901028ed15edabab45e8900a2f620 | Python | 1,338 | 44 | # -*- coding: utf-8 -*-
"""
Created on Wed May 16 14:24:17 2018
@author: Francois & Deepak
"""
import csv
'''
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# CSV Communication
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%... |
4b7875b7d228bc84ed692a84d3ae3c2747639913dadcb685599dc2965036cf6e | Python | 1,338 | 41 | """
Spark with Ask-and-Tell
An example showing how to use Optuna's ask-and-tell interface with Apache Spark
to distribute the evaluation of trials.
This script uses PySpark's RDD to parallelize a simple quadratic function.
"""
import optuna
from pyspark.sql import SparkSession
def evaluate(trial_number, x):
# ... |
d666ead2c570f194a83d08461eeffa3cd4681a501bf7ae025554d52592b15430 | Python | 1,338 | 32 | #
# 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,... |
7765d26f991057ed0a03efae48887a0466e15eab3b6cac825b5a921707f0cf07 | Python | 1,339 | 46 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import glob
import os.path
import sys
DIR = os.path.dirname(os.path.abspath(__file__))
REPO = os.path.dirname(os.path.dirname(DIR))
SRC_DIR = os.path.join(REPO, "src")
def check_header_files(component):
component_dir = os.path... |
b6027f4b25f51c111be720450f951081c7934738056c646736b1378286da1060 | Python | 1,339 | 42 | import torch
from ase.data import chemical_symbols, atomic_numbers
def main(
*args,
model="model.pt",
device="cpu",
output="infer.pt",
symbols=None,
double=False,
**kwargs,
):
model = torch.load(model, map_location=torch.device(device), weights_only=False)
if double:
model ... |
cf8a8628daf5a974aac22ca3e2cc4f3e6bad8231ce97f887310fabc0c7069381 | Python | 1,339 | 50 | import importlib.resources as res
from collections.abc import Iterable
from string import Template
from elasticai.creator import ir
from elasticai.creator.ir2vhdl import (
Code,
DataGraph,
EntityTemplateDirector,
Ir2Vhdl,
PluginSymbol,
)
def _load_vhd(component: str) -> str:
vhd_file = res.fi... |
ec59c1f898c3d0ecf24b8701bfe0ed2210dc14fb628cd32c9c013e438742dc89 | Python | 1,339 | 38 | # 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... |
228a86610818d0423cdf1f1d9f6d5311285bac464a868805c92eb83bd4b2275e | Python | 1,340 | 53 | # -*- coding: utf-8 -*-
"""Helper functions for tests"""
import os
import numpy as np
from helpers import *
this_dir = os.path.dirname(os.path.abspath(__file__))
# Example traivial dataset for testing purpose,
# In all trivial datasets, there are three atoms,
# sitting at (0, 0, 0), (1, 0, 0) and (1, 1, 0)
def get... |
3b7ed5a286b3cb7f1643efa3d39f47e93741c20c437c2bf90997db480a6f7627 | Python | 1,340 | 37 | # 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... |
5ee6675325f687c1426cf6e10428654003d930b001d84a5febaa4b1547b413fa | Python | 1,340 | 38 | import os
from torchdrug import data, utils
from torchdrug.core import Registry as R
@R.register("datasets.MUV")
@utils.copy_args(data.MoleculeDataset.load_csv, ignore=("smiles_field", "target_fields"))
class MUV(data.MoleculeDataset):
"""
Subset of PubChem BioAssay by applying a refined nearest neighbor ana... |
9c45cdd78958d514adc6db8b5d4bbd36d21cdf631199796147a6e5e86abe0b95 | Python | 1,340 | 45 | from cknn import cknneighbors_graph
import networkx as nx
import matplotlib.pyplot as plt
import numpy as np
class CKNNGraph:
'''Wrapper for cknn.cknnneighbors_graph'''
def __init__(self,
X,
n_neighbors: int,
delta: float,
t: float
... |
37d6bccdaad7c1d79649997bfdc6f6bd6c15555129a9d37223e86f4f443377da | Python | 1,341 | 37 | from pathlib import Path
from segm.data.base import BaseMMSeg
from segm.data import utils
from segm.config import dataset_dir
PASCAL_CONTEXT_CONFIG_PATH = Path(__file__).parent / "config" / "pascal_context.py"
PASCAL_CONTEXT_CATS_PATH = Path(__file__).parent / "config" / "pascal_context.yml"
class PascalContextData... |
fddb48f84bf922b88ca1bd56ca1f9c4a19a41ff7a56130b9e84d2a7a5e32c61f | Python | 1,341 | 29 |
import torch
def guassian_kernel(source, target, kernel_mul=2.0, kernel_num=5, fix_sigma=None):
n_samples = int(source.size()[0])+int(target.size()[0])
total = torch.cat([source, target], dim=0)
total0 = total.unsqueeze(0).expand(int(total.size(0)), int(total.size(0)), int(total.size(1)))
total... |
bc9a5be2a67a036f925f0ae80d6482f49b5506c1532a5a7e268b0ea51e496e26 | Python | 1,343 | 39 | import os
from torchdrug import data, utils
from torchdrug.core import Registry as R
@R.register("datasets.Tox21")
@utils.copy_args(data.MoleculeDataset.load_csv, ignore=("smiles_field", "target_fields"))
class Tox21(data.MoleculeDataset):
"""
Qualitative toxicity measurements on 12 biological targets, inclu... |
d1390995998d03d4a97dc1c84aea0aaa7a6657693e7b9900ce67707d834e9dc0 | Python | 1,343 | 40 | # 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... |
6021a922e90581a0dc39751de3ce5c1faab1869654c8c9e8015ea8a33b817a3c | Python | 1,344 | 45 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
from lab.environments import LocalEnvironment, MaiaEnvironment
from common_setup import IssueConfig, IssueExperiment, is_test_run
BENCHMARKS_DIR = os.environ["DOWNWARD_BENCHMARKS"]
REVISIONS = ["issue591-base", "issue591-v1"]
CONFIGS = [
IssueConfig(
... |
df31fb466585fcdb289e712ee511dd6fc07202e25b84f034c4ba5d06bc0652c2 | Python | 1,344 | 33 | import numpy as np
def createNeighborMatrix(neighbor_matrix_name, positions_file_path, neighbor_radius):
position_file = open(positions_file_path, "r")
positions = []
for position in position_file.readlines():
positions.append(np.array(position[:-2].split(",")).astype(float))
channel_positions... |
0a34f71de593da6e9e7d23eb17987c7caaea1820d2526e48e1d53ef3699afe6b | Python | 1,345 | 52 | import numpy as np
import collections
import itertools
class CircularBuffer:
def __init__(self, size: int):
self.size = size
self.buffer = collections.deque(maxlen=size)
return
def load(self, data: list):
"""
Clear then load buffer with data.
If data is longer... |
1978090f106b12733d579defaf57ce86646479776a19010709fb6f7dbd929553 | Python | 1,345 | 59 | """
Base class for runners.
"""
from __future__ import annotations
from dataclasses import dataclass
from typing import TYPE_CHECKING, Generic, TypeVar
from quacc.runners.prep import calc_cleanup, calc_setup
if TYPE_CHECKING:
from ase.atoms import Atoms
from quacc.types import CopyFiles
AtomsT = TypeVar(... |
97c42b46827b4de341493ed5d8221030678d7a3bdfaa3aa57f4684a603f6502f | Python | 1,345 | 46 | #! /usr/bin/env python
from __future__ import print_function
class Graph:
def __init__(self, nodes):
self.nodes = nodes
self.neighbours = dict((u, set()) for u in nodes)
def connect(self, u, v):
self.neighbours[u].add(v)
self.neighbours[v].add(u)
def connected_components(se... |
dc30f1045ca6a37520092c5379b841854e767ab34c99c3b94688a63e326da8fe | Python | 1,345 | 44 | import json
import time
import argparse
from intensity.run_coarse import *
from config.utils import load_cfg
from point.run_fine import warpImage
from intensity.run_coarse import runCoarse
def main(args):
# run coarse and fine registration on a single image volume
# which is specified in the configuration f... |
43fd834afb56fe206debd213081fdd76e7ea6ff0b0054f3585786a8992fbbc7e | Python | 1,346 | 25 | # 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... |
bf82a2742fd8536d7aed26b242342f42959f83c5b7eb050e73623db16a5698ca | Python | 1,346 | 43 | """Negative compilation tests for Google Mock macro MOCK_METHOD."""
import os
import sys
IS_LINUX = os.name == "posix" and os.uname()[0] == "Linux"
if not IS_LINUX:
sys.stderr.write(
"WARNING: Negative compilation tests are not supported on this platform")
sys.exit(0)
# Suppresses the 'Import not at the to... |
d2511844bcda00c053919459f1b2176bfb2715e179f7e1d2c9aff23256c4abc9 | Python | 1,346 | 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,... |
43bea2b85a9aa6dac22539ea0a4d3e49104909bc814db3bf5e9842dcd763fdeb | Python | 1,347 | 47 |
from typing import Iterable, Any
from abc import ABCMeta, abstractmethod
class DataProcessor(metaclass=ABCMeta):
@abstractmethod
def prepare_train_dataloader(self) -> Iterable[dict[str, Any]]:
"""
Method must return Iterable (e.g. Dataloader)
to be used during training.
Each ... |
51386b77e76da1a4c1964df31597c2632737ad8a66a3903d22b62b86051d8772 | Python | 1,347 | 35 | #
# 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,... |
6c05a31eea30271fce252798d3ed37e55c9d2044bf3d4e860d8526eba2137f13 | Python | 1,347 | 46 | import numpy as np
class ConstantScheduler:
def __init__(self, steps, lr):
self.steps = steps
self.lr = lr
def __call__(self, step):
return self.lr
class CosineScheduler:
def __init__(self, steps, base_lr, lr_min_factor=1e-3):
self.steps = steps
self.base_lr = ba... |
c1acfb18fe05e0748a2da613eb26aff78eb408d225140cdcf5aa41752076805c | Python | 1,347 | 42 | import unittest
import sys
import tempfile
class TestExitCode(unittest.TestCase):
def setUp(self):
# to be able to import mprof
sys.path.append('.')
from mprof import run_action
self.run_action = run_action
def test_exit_code_success(self):
s = "1+1"
tmpfile =... |
6fd71546c62d7634d0965ea687f8afb4f28ad1b6c58a881707ab4e227e34dfb3 | Python | 1,348 | 36 | ### adapted from Adriano Fonzino et al.
## (ENSG00000160710) ADAR
## (ENSG00000197381) ADARB1
## (ENSG00000185736) ADARB2
import sys, os
print('Sample\tGene\tTPM')
f=open('/media/Scratch_SSD_Voyager/sammi/RNA_editing/fc_OD_v1/counts_all_tpm.txt')
tpm_list={}
for i in f:
if i.startswith('Geneid'):
h=i.strip().sp... |
fe8bad315396b340746aad9276d1810b280eedc86e49cee18a232efc441ca514 | Python | 1,348 | 42 | import pytest
import torch
import elasticai.creator.nn.fixed_point as nn_creator
from elasticai.creator.arithmetic import FxpParams
from elasticai.creator.nn import Sequential
class SimpleReLU(torch.nn.Module):
def __init__(self, total_width: int, frac_width: int):
super().__init__()
self.model =... |
402bfa4ed671a828ee6a1f2ee92b9fda845e5c28b91e3272c82c89df5164ec0a | Python | 1,349 | 25 | # 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... |
6e299877f3aafbce0334cc483f623198486d952e6c89426c818bbcf838ed978b | Python | 1,349 | 64 | """Common elastic constants workflows."""
from __future__ import annotations
from typing import TYPE_CHECKING
from quacc import subflow
from quacc.atoms.deformation import make_deformations_from_bulk
if TYPE_CHECKING:
from typing import Any
from ase.atoms import Atoms
from quacc import Job
@subflow
... |
e3d6c0f2cb80510194075ce02730e4768f792ce3851df4732c2fb3da05a2217f | Python | 1,349 | 40 | import os
import sys
read_dir_path = sys.argv[1]
output_dir_path = sys.argv[2]
read_ids_dir_path = sys.argv[3]
use_case = sys.argv[4]
dir_list = os.listdir(read_ids_dir_path)
batch=64
modeltype = 'default'
model_path = '../../bonito/models/default/'
for dir in dir_list:
test = dir.strip().split(".")
read_... |
7656ce611fde4529d20888adffd300361f645491a73331d21b9bcc7a34ffe5e6 | Python | 1,350 | 41 | from __future__ import annotations
from typing import Any
from wikibaseintegrator.datatypes.string import String
from wikibaseintegrator.wbi_enums import WikibaseSnakType
class Math(String):
"""
Implements the Wikibase data type 'math' for mathematical formula in TEX format
"""
DTYPE = '... |
77aadbb13924990d0296175bad5ffba39ee6b667b6fa5fddf8ddd1d63a18efb6 | Python | 1,350 | 40 | import os
import sys
read_dir_path = sys.argv[1]
output_dir_path = sys.argv[2]
read_ids_dir_path = sys.argv[3]
use_case = sys.argv[4]
dir_list = os.listdir(read_ids_dir_path)
batch=512
modeltype = 'default'
model_path = '../../bonito/models/default/'
for dir in dir_list:
test = dir.strip().split(".")
read... |
c4b0e6360236b8941303c9f3d2cda14b8b918c76949d5e7a31e2b23971c99a9e | Python | 1,350 | 38 | from typing import Dict, Union
import numpy as np
import torch
from ..base_transform import EEGTransform
class ToTensor(EEGTransform):
r'''
Convert a :obj:`numpy.ndarray` to tensor. Different from :obj:`torchvision`, tensors are returned without scaling.
.. code-block:: python
transform = ToT... |
ec8f08cb3997d464931fc4fab1ebf69e81adac7daf042d7485c4c501596a9d2d | Python | 1,350 | 40 | import subprocess
from pathlib import Path
def create_notebooks(script_folder, notebook_folder):
'''Create Jupyter notebooks from Python scripts
For each .py file in script_folder, create a .ipynb file in with the
same name in notebook_folder.
Parameters
----------
script_folder : path-like
... |
73cc355012bcf282827244aed39c7d33c3cb5ae703fded1a070127fcfa69a0ca | Python | 1,351 | 67 | """Euclidean manifold."""
from manifolds.base import Manifold
class Euclidean(Manifold):
"""
Euclidean Manifold class.
"""
def __init__(self):
super(Euclidean, self).__init__()
self.name = 'Euclidean'
def normalize(self, p):
dim = p.size(-1)
p.view(-1, dim).renor... |
f345f2270881f4668269aa3ebd2680a4bec8ae8a1867602e93188fbddf67a7bf | Python | 1,351 | 38 | # 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... |
42ea54b4d73b2b2dba9de92453fa56c978f05af617c4e3db3fbba6d53109ec7e | Python | 1,352 | 36 | import h5py
import os
import glob
import argparse
# from plantsegtools.utils.io import rename_h5_key
from plantsegtools.utils import H5_FORMATS
def parse():
parser = argparse.ArgumentParser()
# Required
parser.add_argument("--path", type=str, required=True, help='path to h5 file or'
... |
8681bc586164ebcce7d8c86339bb75e13ea764ca9e1fcd4e8daaf88cf24af568 | Python | 1,353 | 45 | 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, init",
[
(3, 2, 0.25),
(4, 2, 0.25),
(4, 3, 0.25),
(6, 4, 0.5),
(8, 5, 0.125),
... |
9f79cf401d027454fc224dd3a7f6970ba46b72063bea085149ff9c13023d16a7 | Python | 1,353 | 49 |
import numpy as np
import lavaset.cython_wrapper as cython_wrapper
# from lavaset.cython_wrapper import gbc_p
import pandas as pd
# from _GBCP_python import GBCP
def best_cut_node(method, Data, Labels, minleaf, max_label):
M, N = Data.shape # following the cpp code nomenclature
# N = int(max(1, int(... |
5cc4fd874d67431c8ccbfe1c269237ab3eccfe0c3a9bf298b9ad8b2d58df90ca | Python | 1,354 | 47 | """Functions for static post-hoc analysis
"""
from osl_dynamics.analysis import static
from osl_dynamics.data import Data
def compute_aec(input_data, Fs, freq_range, tmp_dir):
"""Compute subject-level AEC matrices.
Parameters
----------
input_data : list of np.ndarray
Input data containing r... |
17c22ef6e05b2b6b80ed86a8d7bd288629a1016e4a25970070de4510fe74ffaa | Python | 1,355 | 47 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os, sys
from lab.environments import LocalEnvironment, MaiaEnvironment
from common_setup import IssueConfig, IssueExperiment, is_test_run
BENCHMARKS_DIR = os.environ["DOWNWARD_BENCHMARKS"]
REVISIONS = ["issue638-base", "issue638-v1"]
CONFIGS = [
IssueConfig... |
47582d324bbfc48240f7df58ff03e28aa4902fba67ad6f3dbe1cb5602724f91e | Python | 1,355 | 44 | import torch
import torch.nn as nn
from torch import Generator
from typing import Any
from ..prixfixe import FirstLayersBlock
from .utils import initialize_weights
import torch.nn.functional as F
class AutosomeFirstLayersBlock(FirstLayersBlock):
def __init__(
self,
in_channels: int,
out_... |
f85e695a10cb477e6ec542a38c1c1209d17f2e679ef4bf802efdda1b57d3ae8c | Python | 1,355 | 45 | 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, init",
[
(3, 2, 0.25),
(4, 2, 0.25),
(4, 3, 0.25),
(6, 4, 0.5),
(8, 5, 0.125),
... |
ddba053594f996b92b3aa595fca3edfcd23616558f12bd9285d00fb3222729df | Python | 1,356 | 25 | # 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... |
e9e9d408bc7a5fe7eb12de3f46663ef506b289c9395129f2c9a6b2ba6f54048f | Python | 1,356 | 41 | #!/usr/bin/env python
# coding: utf-8
# Copyright (C) 2021 Blue Brain Project, EPFL
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any... |
d827b8b14b2f7be78ee976151b0a3ade9b9e7243a2e551782a9eb0625518f9d3 | Python | 1,358 | 49 | """
Standalone GUI launcher for the OME-Zarr format converter.
"""
import os
import sys
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 PySide6.QtWidgets import QTabWidget
from regtools.gui.app_scaf... |
7549c5152fe609f739795203c021d632a6b574add7620da83c95fc64378d8424 | Python | 1,359 | 42 | import os
from src.methods import Methods
class GanSettings:
def __new__(cls):
cls.DEFAULT_OUTPUT_DIR_NAME = 'output'
cls.GAN_PROCESSING_DIR_NAME = 'gan'
cls.SM4_PROCESSING_DIR_NAME = '4sm'
cls.SEG_PROCESSING_DIR_NAME = 'seg'
if not hasattr(cls, 'instance'):
cls.instance = super(GanSett... |
7ba7ad5726913b851eaf2dbf8c017dc41803db70ae1ceb6af6e8438cc73ff168 | Python | 1,359 | 38 | # 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... |
985be6089ff1ed3f245eed4b3feacdc86d0124830246d315f4e71dc222e7237e | Python | 1,359 | 43 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 28 10:17:00 2023
@author: nct76
"""
# external modules
import matplotlib
import os
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import pickle
# internal modules
import proj_funcs.vis_funcs as vis_funcs
auc_comb_allP =... |
699fdac74b18c7674f4698eba90305e3fd436c0c28659b5cfc174e84e7fa60aa | Python | 1,360 | 40 | # Plot evolution of PSO metaparameters for Fig 9
from get_paths import *
import numpy as np
import matplotlib.pyplot as plt
from colors_paultol import *
save_flag = 0
def sigmoid(gens, n_gen, a, b, amp, offset):
return amp/(1+np.exp((a*gens-b*n_gen)/n_gen))+offset
# Set parameters
n_gen = 300
ge... |
d77659dfcaa57fd5a5f0d59a4d04829179c93a2a2390116a395adcd514c330ee | Python | 1,360 | 48 | import sys
from pybioshell.std import vector_std_shared_ptr_core_data_sequence_Sequence_t
from pybioshell.core.data.io import read_hssp_file, write_clustalo_file, read_fasta_file, read_clustalw_file
from pybioshell.utils import LogManager
LogManager.FINEST()
if len(sys.argv) < 3 :
print("""
Converts multiple s... |
ea58ff4c6c726c905f5fda0c1521bd4431cdf66813099519a0f96f1a844bcf51 | Python | 1,360 | 36 | #
# 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,... |
edfa2c5da6d5c8072fc5171765b6e6f0be26937d08d655d2fc6bf75f9ecb055c | Python | 1,360 | 42 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Copyright (C) 2012 Computational Neuroscience Group, NMBU.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at you... |
f6567026daf99c533c23ac4df3b7b0a4f7e50b525431e32cdf621ff6a060abf1 | Python | 1,361 | 41 | from wonambi import Dataset
from pytest import raises
from bidso.utils import replace_underscore
from .paths import micromed_file, bids_dir
bids_dir.mkdir(exist_ok=True, parents=True)
# TODO: we should generate the name
bids_file = bids_dir / 'sub-test_task-unknown_run-1_ieeg.eeg'
# ================================... |
0e57c2eaea9c5a9e998da2188153a47997ef1467a44bcb4b5ec9be9860ebe4d9 | Python | 1,362 | 36 | ### adapted from Adriano Fonzino et al.
## (ENSG00000160710) ADAR
## (ENSG00000197381) ADARB1
## (ENSG00000185736) ADARB2
import sys, os
print('Sample\tGene\tTPM')
f=open('/media/Scratch_SSD_Voyager/sammi/RNA_editing/fc_CO_v1/counts_all_tpm.txt')
tpm_list={}
for i in f:
if i.startswith('Geneid'):
h=i.strip().sp... |
679335d66b6ff261134370b92c2c0f78e1e26492f99e5d5eb7f655e5a2b20784 | Python | 1,362 | 46 | from tvm.contrib import graph_executor
from torchvision import transforms
from PIL import Image
import tvm
from tvm import relay
import numpy as np
from tvm.contrib.download import download_testdata
import torch
import torch.nn as nn
from torchvision.models import vgg16
from utils import *
batch_size = 256
dev = 'c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.