sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
86fef0b3e6d6fa9ae71486735aad201ebc0a9e52efebe4d0b80aac8068341258 | Python | 1,208 | 42 | import torch
import torch.nn as nn
import torch.optim as optim
class SimpleMTL(nn.Module):
def __init__(self, input_size, output_sizes, hidden_sizes):
super(SimpleMTL, self).__init__()
self.hidden_sizes = hidden_sizes.copy()
self.hidden_sizes.insert(0, input_size)
self.towers = []
self.tasks = l... |
b7c9b61118d35ac3b19e341cc2a37016728299a7459d193c198fa8ccdfdcfbc2 | Python | 1,208 | 55 | ## launch a Gaussian beam
import math
import matplotlib
import meep as mp
matplotlib.use("agg")
import matplotlib.pyplot as plt
s = 14
resolution = 50
dpml = 2
cell_size = mp.Vector3(s, s)
boundary_layers = [mp.PML(thickness=dpml)]
beam_x0 = mp.Vector3(0, 3.0) # beam focus (relative to source center)
rot_angle ... |
d1947204d11b8bcfc96d662a3b4419833aedd037d6899215cc3a6ad6b19c7291 | Python | 1,208 | 31 | import argparse
from parse_config import ConfigParser
from mode import multi_cross_validation_bootstrap, multi_train_bootstrap
from utils import set_random_seed
SEED = 1126
set_random_seed(SEED)
def main(config):
if config['mode'] == 'multi cross validation bootstrap':
cross_validation_bootstrap_results ... |
2716885c0331db814cfd3a5a6020ea25219ba7685a8ad53a1c408ff48498eb01 | Python | 1,209 | 35 | from __future__ import absolute_import, print_function, division
import torch
import numpy as np
from typing import Iterator, Iterable, List
def batches(X:Iterable[np.ndarray], batch_size:int=1) -> Iterator[torch.Tensor]:
batch = []
for x in X:
batch.append(torch.from_numpy(x).float())
if len(... |
b3cd806db0a6eda97d23b1c0a571f81bff620c05c66442476b70fc4f2202a532 | Python | 1,209 | 39 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 1 14:16:02 2023
@author: frazaodesouzam2
"""
import mdtraj as md
import os
import sys
import numpy as np
import pandas as pd
os.system('pwd')
path_traj = './' # Path to file with frame number to be written out
file_name = 'Top10.c... |
c7d87fdac5064a716f3b5a8c0dff4e7b1ac3adbaae1805539a56452f7f4d3a5c | Python | 1,209 | 45 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from downward import configs
import common_setup
SEARCH_REVS = ["issue439-base", "issue439-v1"]
LIMITS = {"search_time": 1800}
SUITE = [
"airport:p45-airport5MUC-p6.pddl",
"elevators-sat08-strips:p22.pddl",
"parking-sat11-strips:pfile09-033.pddl",
"scan... |
fd04cc373cdc1cbf322f6425602962f294a45e21f1e7d6ea958267904a33a0ec | Python | 1,209 | 37 | from typing import Sequence
def indices2slice(indices, axis):
"""
converting slice style strings to a list of slices based on the position of the axis
indices: list of indices
axis: list of axis, axis' elements need to be in the ascending order and non-negative
Example
------
>>> indi... |
1e1beeb5fa78cf9a3e886aa3e1e2a90aac9e0ccd7da9ceebf6cfdd477e78c680 | Python | 1,210 | 34 | """
Optuna example that optimizes a simple quadratic function.
In this example, we optimize a simple quadratic function. We also demonstrate how to continue an
optimization and to use timeouts.
"""
import optuna
# Define a simple 2-dimensional objective function whose minimum value is -1 when (x, y) = (0, -1).
def... |
58e27c51ac7edf941d9ac0d42e04ea5e8f1724048bac1323883846073509d222 | Python | 1,210 | 36 | import os
import pandas as pd
import numpy as np
import unittest
import sys
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../../src")
from hornet.uml import get_min_cluster_index
class TestGetMinClusterIndex(unittest.TestCase):
def setUp(self):
# create a sample DataFrame
self.df... |
742d8f87457fc39a55a5897aab16dcc5f5f25bfb0588236a0ef9987370a981fc | Python | 1,210 | 36 | """
Created on 25/05/2020
:author: Chinchien Lin
:summary:
"""
import sys
from src.commands.copy_command import CopyCommand
from src.commands.macro_command import MacroCommand
from src.commands.padding_command import PaddingCommand
from src.commands.rename_files_command import RenameFilesCommand
if __... |
bde64f4d4a11fd681fb0930902e6b9bc399a6a450bec09cdc64831589594c2a8 | Python | 1,210 | 47 | """Configuration for Sphinx that is used to build documentation
Functions of this file are called by conf.py to setup paths and options
"""
class Config:
"""Object of this class will be returned to provide config entries"""
def __init__(self, **entries): self.__dict__.update(entries)
def __str__(self):
... |
a0269d476407234e2bed8dc3d2fb066375514677621a164afd15bc2760fa6901 | Python | 1,213 | 35 | import torch
import numpy as np
import matplotlib.pyplot as plt
def check_cuda():
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
if device.type == "cuda":
print("GPU found and will be used")
else:
print("GPU was not found. Using CPU")
return device
def normalize_... |
e8aeda6c4207f3234bb0b5657f95d055c4dba7be325ca4fff4c8ca6e5c9ea50f | Python | 1,213 | 31 | # 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... |
91534061bb7b939f501e991bc350262ae927a8b9400632c15280877164c00b70 | Python | 1,214 | 43 | #! /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... |
cb964c6062853acea34ce31132abd6d80ade9aaa3052299c589c5484b290730c | Python | 1,215 | 29 | from elasticai.creator.base_modules.sigmoid import Sigmoid as SigmoidBase
from .precomputed_module import PrecomputedModule
class Sigmoid(PrecomputedModule):
def __init__(
self,
total_bits: int,
frac_bits: int,
num_steps: int,
sampling_intervall: tuple[float, float] = (-fl... |
ec15d7ece21cd33d8355dabbf31612b316ad6ab03d0bec13c45a7cbcf9d5dbe9 | Python | 1,215 | 77 | import control.toupcam as toupcam
from control.camera_toupcam import Camera, get_sn_by_model
from control._def import *
import time
model = "ITR3CMOS26000KMA"
sn = get_sn_by_model(model)
camera = Camera(sn =sn,rotate_image_angle = ROTATE_IMAGE_ANGLE, flip_image=FLIP_IMAGE)
camera.open()
camera.set_gain_mode('HCG')... |
f306b522edf93639c0b4aeefaf10d7c4993bf01f4e6fa4334e66ddabf8d09adc | Python | 1,215 | 29 | # 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... |
3b46c0156c9f2fa7ff3f74ea8378aa785af9ff2bfd234570f15fe683788cafea | Python | 1,216 | 44 | """
Shared logging utilities for dual console/file output.
"""
import re
import sys
class TeeLogger:
"""Dual output to console and file with ANSI color stripping for file.
Usage::
tee = TeeLogger("console.log")
sys.stdout = tee
...
tee.close() # restore... |
42e454ead8659bc57a7f5f46a89e449156861888250d048bc1e871f96f7717fa | Python | 1,216 | 35 | #### Edit cafemol input file for path and md step
#### Usage: $ python3 edit_input.py input_file output_path pdb_path
#### given input file is edited in place.
import sys
import fileinput
if len( sys.argv ) < 5:
print("provide cafe_inputfile, output_path, pdb_path, ninfo_path")
sys.exit()
input_file = sys.ar... |
5383fa66f2026f97cfb95208d4ec2a3dcadf6ec48a34b362808b3a83cc728220 | Python | 1,216 | 33 | """Exact comparison of two behaviour captures (scripts/behaviour_capture.py); wall-clock fields are ignored."""
import json
import sys
IGNORED = {"elapsed", "seconds", "tokens_per_second", "generate_pair_256_tokens_s", "continuous_fly_tok_s",
"timestamp_utc"}
def diff(x, y, path, out):
if isinstance(x... |
7d47a0cca6f23b9d3533ddccd0a4e1c0c229a11c6194f2f51248566a24804580 | Python | 1,216 | 49 | ### Submit script "XY.py" to HPC (Slurm) cluster
import subprocess
### Script 1
## Configurable job parameters
job_name = "create_dataframes_upper" # Name of the job
output_file = f"{job_name}.out"
error_file = f"{job_name}.err"
script_to_run = "create_dataframes_from_matrices_upper.py" # Name of the script to run
##... |
b6abe464583a2b9445f42fc9d547e1e99056b396aa4a013a37003f036dcf0050 | Python | 1,216 | 35 | import os
import sys
import numpy as np
import pandas as pd
import subprocess
import re
kappa_num = np.loadtxt('kappa.txt')
n_jobs = len(kappa_num)
# Add your working directory here, such as '<path>/HORNET/DynamicFitting/templates/kappa_scan'
workingdir = '<path>/HORNET/DynamicFitting/templates/kappa_scan'
if not os... |
ec6aaded0356ec1086132a474c28614d85dcfc860cd0148b8dab7c1efac05855 | Python | 1,216 | 38 | import torch
import torch.nn as nn
import math
class lap_ablation_only_width_module(torch.nn.Module):
def __init__(self, channels=None):
super(lap_ablation_only_width_module, self).__init__()
self.learn_width = nn.Parameter(torch.ones([1, channels, 1, 1]))
self.act = nn.Softplus()
@s... |
141ff7ce2b363b3e1f0db7bb3905a137cd6478f8c88008fe0948a225a0eb4b18 | Python | 1,218 | 52 | #!/bin/env python3
"""
Calculate topological charge for a branch cut
"""
import ithildin as ith
import numpy as np
import matplotlib.pyplot as plt
x = y = np.linspace(-2, 2, 50)
xg, yg = np.meshgrid(x, y)
dx = x[1] - x[0]
dy = y[1] - y[0]
zg = xg + 1j*yg
# fg = (zg**2 - 1)**0.5
arg1 = np.angle(zg-1)/2
arg2 = np.angle... |
4c612a6f8959181f0b494a76cdceed59f96e7ebb6b7359ad88720bb26c1a1c7b | Python | 1,218 | 26 | #
# 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,... |
758fdaf947cbebe940f00c5c31d6d633551321f9d5a5a800781217b2e63239ce | Python | 1,218 | 39 | import torch
import torch.nn as nn
import math
class lap_ablation_only_scale_module(torch.nn.Module):
def __init__(self, channels=None):
super(lap_ablation_only_scale_module, self).__init__()
self.learn_scale = nn.Parameter(torch.ones([1, channels, 1, 1]))
self.act = nn.Softplus()
@... |
98b8bcd21971b2840ddaca09ebfd18f66d2c88619bf7e609b46a73fe1ec95a55 | Python | 1,218 | 46 | #!/usr/bin/env python
import sys
import numpy as np
import pandas as pd
import time
from scipy.stats import spearmanr
from pathlib import Path
if __name__ == "__main__":
# Receive the currently active dataset
dataset = sys.argv[1]
output_path = Path("output")
expression = pd.read_csv(f"data/{datase... |
f251a08456b8a6a213ce07d13b3e5ef0935de98058c8b5184437586d4cf441e1 | Python | 1,218 | 40 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
from lab.environments import LocalEnvironment, BaselSlurmEnvironment
from downward.reports.compare import ComparativeReport
import common_setup
from common_setup import IssueConfig, IssueExperiment
from relativescatter import RelativeScatterPlotReport
DIR = ... |
fb5a02d655af0fd5c6703ac8b2db252f5db3fbe5da192644e95ca33e428783bb | Python | 1,218 | 26 | # 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... |
5ade6422016cff884e4330ee23dead3d4d3f1b86c0df5e5dde78e65aa9fc9f66 | Python | 1,219 | 46 | #! /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... |
6535eee2c0e6307577566f44c7f5445f7e268b9d77fc97d4116ac2f1a4b6c5b2 | Python | 1,219 | 43 | #! /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... |
737e6662305e0e2122e128968b78e87cd2fb157e75dd38672554c5778e39652f | Python | 1,219 | 31 | from .iterator_utils import batched
def structure_flat_CxN(vector, channels):
"""Assumes a vector of the following format
(x[1, 1], ..., x[C, 1], x[1, 2], ..., x[C, 2], ..., x[1, N], ..., x[C, N])
and reshapes it to a tensor y, such that
y[i] contains all channels of step i
"""
return tuple(ba... |
005e22a83938a397daa62e06ba388ba74b58a52262363efcbf42b8159f2c92c5 | Python | 1,220 | 26 | # 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... |
6b2c6e8076178ce054f9def7584ea9041c997c816ab888d361316a0542b85e5c | Python | 1,220 | 43 | from .nn import Binarize as Binarize
from .precompute.truth_table_generation import (
generate_input_tensor_1d as generate_input_tensor_1d,
)
from .rules import (
AttachFilterParametersRule,
FilterParameters,
FilterParamsProducer,
InferMaxPool1dInChannelsRule,
InferNodeShapesRule,
binarize_a... |
9df5bcc377e70ef550b36c66864b8ca6c54e57fa90fbfe571084aa7991b61ff5 | Python | 1,220 | 26 | # 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... |
d9d98e384a9ba77409b8b5f9d9aa761ee87a086977eaa22a88399cbbc7bd6f06 | Python | 1,220 | 24 | from neuron import h
class Segment(object):
def __init__(self, segment, loc: list, diam: float, sec_name: str, id: int, pid: int, cate: int) -> None:
self.segment = segment # segment, hoc object
self.loc = loc # location[x,y,z], list of float
self.diam = diam # diam o... |
5d94ef59504b583feda3e8b9b00d5e9c0727bed8df1fa50cc0b5817e7b5de824 | Python | 1,221 | 44 | # Librairies
import os
import sys
code_path = os.path.split(os.getcwd())[0]
sys.path.append(code_path)
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import argparse
from setting import *
from utils import *
set_pyplot()
# Arguments
argParser = argparse.ArgumentParser()
argParser.add_argumen... |
8eb175562ede1b2a85a8c1eb89e8753c83ab194eca782c6160f6676efb66bc66 | Python | 1,221 | 39 | import abc
from pip._internal.index.package_finder import PackageFinder
from pip._internal.metadata.base import BaseDistribution
from pip._internal.req import InstallRequirement
class AbstractDistribution(metaclass=abc.ABCMeta):
"""A base class for handling installable artifacts.
The requirements for anythi... |
f1577e9c2d04277e39f4d11610cf6166c5c863dd0151548b96babf2e1a0dba24 | Python | 1,221 | 25 | """AppScaffold.bootstrap must declare shared OpenGL BEFORE the QApplication.
AA_ShareOpenGLContexts is read only at QApplication construction and silently
ignored if set afterwards. The first GL widget opened later (the tilt/slice
dialog's 3D view) is the process's first OpenGL context, so without this the
native... |
169310ea7e7d30530942cbc5b72f78ed33a835d2cb3ced41364d7fd271bea9cb | Python | 1,222 | 34 | """
Main class of the Library.
"""
from __future__ import annotations
from typing import TYPE_CHECKING
from wikibaseintegrator.entities.item import ItemEntity
from wikibaseintegrator.entities.lexeme import LexemeEntity
from wikibaseintegrator.entities.mediainfo import MediaInfoEntity
from wikibaseintegrator... |
18221e730c49a84a21d123b81b76e6cf7c3d7d834b44bf2b0a08e3193c1b7e56 | Python | 1,222 | 34 | """Regression guard: --flip_h/--flip_v must fold into the 3D moving-image axis
flips. The bug this protects against: they were wired only for 2D, and the 3D
``registration()`` wrapper silently dropped them, so a mirrored input could not
be corrected and hemisphere counts landed on the wrong side.
"""
from regtoo... |
596fdb334cac8efef6e7e0118c8d01de0268a1d22143ab5a5e272f0ba1925f26 | Python | 1,222 | 22 | from .lynxi_backbones import SeqClif2Fc2Lc, SeqClif3Fc2Rg, SeqClif3Fc3Dm, SeqClif3Flif2Dg, SeqClif4Flif2Dg, \
SeqClif5Fc2Cd, SeqCtlif5Fc2Cd, DualFlifp1Fc1Bq
from .lynxi_backbones_itout import SeqClif3Fc3DmItout,SeqClif3Fc3DmItout_test,SeqClif2Fc1CeItout, SeqClif3Fc3LcItout, SeqClif3Flif2DgItout, SeqClif5Fc2CdItout,... |
686065ffd14aa9aa202bc9d940b6afe1b1546386ab07439a9047fbee074867d7 | Python | 1,222 | 43 | # -*- coding: utf-8 -*-
"""
Created on Fri Jul 9 15:20:18 2021
run autoreject on epoched data
output cleaned epoched data
@author: Viviana Leupin
"""
import evoked.autoreject_helper as auto_hp
from base.files_in_out import GetFiles,filter_list,getListOfFiles
import base.files_in_out as in_out
import evoked... |
bf608fa6cd1902a3887f1b373d0686a9714337dd8a1b8751a6feb0c703b67b3c | Python | 1,222 | 12 | """POST HOC (9 Oct 2026). The working whole brain of the atlas (HYB: most probable signs everywhere, the laboratory prior on the
antennal lobe's local neurons; prereg 08f addendum 2) on Shiu et al.'s 164 laboratory checks (SIGN_WORLDS machinery, v630 network).
Not pre-registered for HYB (08f registered the 164 checks f... |
33c835a81006ca2d5ff4e340b5f7cf4c737cc2dc8f491729be7aa70ad26ca39b | Python | 1,223 | 46 | import sys, math
from pybioshell.core.data.io import find_pdb
from pybioshell.core.data.basic import Vec3Cubic
from pybioshell.std import vector_core_data_basic_Vec3Cubic
if len(sys.argv) < 3 :
print("""
Calculates radial distribution function for a trajectory from a molecular simulation.
USAGE:
python... |
82b78161959df2a90fad58441d2a625208542d04f84be2ab8de3f457eb7cb37c | Python | 1,223 | 26 | # 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... |
92b2b5e6888d0684dbc2d6c029fa8fdaf597b024c1fd72be41692082e99adc7f | Python | 1,223 | 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... |
990dccc6f2927d5cb02b9c5e3f18d073aa6e156cb05a9cd57f41dcba377014c7 | Python | 1,223 | 36 | import torch
import numpy as np
import matplotlib.pyplot as plt
import os
def check_cuda():
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
if device.type == "cuda":
print("GPU found and will be used")
else:
print("GPU was not found. Using CPU")
return device
def ... |
bb2397bc81a949ed0026f7084d3a0cc606ad66d91e552a72afe69a0fe7e64e17 | Python | 1,223 | 35 | import unittest
import os
import random
import shutil
from torcheeg.model_selection import KFoldPerSubjectCrossTrial
from torcheeg.datasets import DEAPDataset
class TestKFoldPerSubjectCrossTrial(unittest.TestCase):
def setUp(self):
shutil.rmtree('./tmp_out/')
os.mkdir('./tmp_out/')
def test_... |
7717b243ece1d7ae822c7f96e7ff2713923a90a41651cb824556e2a07229aa17 | Python | 1,224 | 41 | def update_param(name, param):
if name == 'stopping_metric':
param['values'] = ['AUTO', 'anomaly_score']
return param
return None # param untouched
extensions = dict(
required_params=['training_frame', 'x'],
validate_required_params="",
set_required_params="""
parms$training_frame ... |
a00d99757b08460fb79d66cad944173e2c837c7d099a2043b3eb0720a67b879e | Python | 1,224 | 41 | import yacs.config
class ConfigNode(yacs.config.CfgNode):
def __init__(self, init_dict=None, key_list=None, new_allowed=False):
super().__init__(init_dict, key_list, new_allowed)
def __str__(self):
def _indent(s_, num_spaces):
s = s_.split('\n')
if len(s) == 1:
... |
d30e2671d567dc5bd772f9a18182d1e7e3b9ecbe99ae37b0ad2e06556c36cc23 | Python | 1,224 | 35 | # 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... |
28c299c0c124d66559a52ac386fb82fe00962ee4fdf9b17f43230d527052b64c | Python | 1,225 | 25 | import os
import pandas as pd
import unittest
import sys
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../../src")
from hornet.model import featurize
class TestFeaturize(unittest.TestCase):
def test_featurize_creation(self):
# Test case 1: Check if 'afmccpow' column is created correc... |
85ff0127d9a9da636d434baa1e390943d0338e620887031321ee110621d73df5 | Python | 1,225 | 44 | #54121 -+sycu 6y
from psychopy import parallel
import serial
import os
##### Set port address to match your local machine
paddress = '/dev/parport0' # '0xDFF8' or 'COM1' in Windows
##################################################
try:
port = serial.Serial(paddress)
port_type = 'serial'
except NotImplemen... |
f17cd4158c5f71d7a2ed48b21b9eadf3be6d61afc5f957cd9f48ae6e77698620 | Python | 1,225 | 38 | import torch
import torch.nn as nn
import math
class lap_ablation_only_adjust_module(torch.nn.Module):
def __init__(self, channels=None):
super(lap_ablation_only_adjust_module, self).__init__()
self.learn_adjust = nn.Parameter(torch.zeros([1, channels, 1, 1]))
self.act = nn.Softplus()
... |
2af5ac8a7807af173b415d95eb7e8d118fd819313d92268156078c489310943a | Python | 1,227 | 45 |
import matplotlib.pyplot as plt
def get_score(s):
"""Parsuje linijke z alignment score, zwraca liste."""
tmp = s.split()[3:] # usun '#' i napis, pozostaw reszte
return tmp
def get_pv_avg_sdev(s):
"""Parsuje linijke z p-value, avg sdec, zwraca liste."""
tmp = s.split()[5:] # usun '#' i napis, ... |
5f4d1b1a3e8c2251a8592153109667d9639d2ae99a43631f7eef3a527f08f440 | Python | 1,228 | 40 | import numpy as np
from collections import namedtuple
def Convert(lst):
res_dct = {lst[i][0]: lst[i][1] for i in range(0, len(lst))}
return res_dct
class FeatureData:
def __init__(self):
self.features = {}
def readFeatureFile(self,filename,feature_name):
feature_list=[]
value=... |
8e6857992ef3b07cdddbf7cfd9e7e4d8dd832b41acfc7981af6ec1e93953ec00 | Python | 1,228 | 28 | import os
import unittest
import sys
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../../src")
from hornet.model import create_model
import tensorflow as tf
class TestCreateModel(unittest.TestCase):
def test_create_model(self):
# Test case 1: Check if the returned model is an instance of ... |
b12e8b4838323a94073f7aef6e9a363f50eb56a70486d481723eed36718abd5e | Python | 1,229 | 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... |
cdbe458de67cb65b9a573c911027064783735c8d23996d2dd55564022223ed09 | Python | 1,229 | 47 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
from lab.environments import LocalEnvironment, MaiaEnvironment
import common_setup
from common_setup import IssueConfig, IssueExperiment
DIR = os.path.dirname(os.path.abspath(__file__))
BENCHMARKS_DIR = os.environ["DOWNWARD_BENCHMARKS"]
REVISIONS = ["issue68... |
4feead2c3f5cac20a12bc3ae3cb13bb95193dadbea7ef8580db1855e75cce9b9 | Python | 1,230 | 23 | """Sweep the capture layer of a single bypass (capture -> 10) on one prompt.
Run it from the Observatory: Experiments -> Run Python Script... The script is trusted local
code executed with your user permissions. Results go to results/plugins/bypass_sweep/<time>/.
"""
PROMPT = "Ты в курсе, что ты немного муха дрозофил... |
9707e1d6730044326c790cbec19426f0facbc8c1bb22aa1eafd0be8a932c6107 | Python | 1,230 | 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... |
c1883d36b8e4e9a3f2f63e5e2f0c59f422cf2373154f4d05855ec62d693e9c2d | Python | 1,230 | 54 | import numpy as np
import matplotlib.cm as cm
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
f = open("c302_C2_FW.muscles.dat", "r")
fs = open("cut_one_pace.txt", "w") # seq: DR0-24, VR, DL, VL
s = 1600
e = 2400
dt = 0.005
rg = [int(s/dt), int(e/dt)]
time = np.zeros(rg[1] - rg[0])
data = np.zeros((rg... |
fd6c6a27b7acfca2e903cc1bd171dd8dc83a18a1afacc2d940b9c863eee3e0f7 | Python | 1,230 | 51 | import pytest
import elasticai.creator.nn.fixed_point as nn_creator
from elasticai.creator.arithmetic import (
FxpArithmetic,
FxpParams,
)
from elasticai.creator.nn import Sequential
from tests.integration_tests.nn.fixed_point.sequential_routine import (
routine_testing_sequential_module,
)
@pytest.mark.... |
2afc6df3cf02b3312216140d77999ebc5bf9c94f795deb174b82dc4e1e21e2b3 | Python | 1,231 | 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... |
4c10d1d52a9120797fd3b392025cfa04f995808a6e90ae11b3e7913acb2544d4 | Python | 1,231 | 46 | import json
import os.path
import openai
from tqdm import tqdm
openai.api_key = '<API_KEY>'
def get_completion(prompt):
prompt += "\n\n###\n\n"
inference = openai.Completion.create(
# model="curie:ft-llm-hackathon-synthesis-parsing-team-2023-03-29-22-57-05",
model="davinci:ft-llm-hackathon-s... |
96770238e29f692d5ffa853607ced2fd4b8ae65beb6daaf2b11082ff6c903c18 | Python | 1,231 | 50 | """
Standalone GUI launcher for the stitching workflow.
Usage:
python -m regtools.stitching.launch
"""
import os
import sys
# Ensure project root is on sys.path
from regtools import get_project_root
_project_root = get_project_root()
if _project_root not in sys.path:
sys.path.insert(0, _proje... |
9dda88f97ec01f13cb3474930847430fd781a20cdb3a347b400bd255c2df32de | Python | 1,231 | 47 | # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under th... |
a9f0059c3647242939d8236d29e1cd071ee060d0aaf4e3880e2916c731c6b011 | Python | 1,231 | 37 | from torch import nn
import torch
import pandas as pd
class Evaluator:
def __init__(self, model: nn.Module, forecast_horizon: int):
self.losses = []
self.model = model
self.forecast_horizon = forecast_horizon
self.loss_metric = nn.functional.mse_loss
def evaluate(
self... |
f081be0463fc646254ce33fc2d397d3f9001243bc4d9fe657b845b1c1b500492 | Python | 1,231 | 35 | import unittest
import os
import random
import shutil
from torcheeg.model_selection import KFoldPerSubjectGroupbyTrial
from torcheeg.datasets import DEAPDataset
class TestKFoldPerSubjectGroupbyTrial(unittest.TestCase):
def setUp(self):
shutil.rmtree('./tmp_out/')
os.mkdir('./tmp_out/')
def t... |
4c622ccf8f980ed9aa9d0471807501ec4f1db99ece19cf95e2eda1731afbd75c | Python | 1,232 | 37 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 8 03:41:42 2024
@author: felipe
"""
import sys
import os
sys.path.append(os.path.abspath('../../'))
import plot.networks as pltn
import analysis.connectivityMatrices as connectivityMatrices
import numpy as np
import matplotlib.pyplot as plt
import... |
921f066d5e8d8ec3b8a21ccb92eec43746679fa5cdf0750f4b1b811569e77a21 | Python | 1,232 | 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,... |
6f12b87d9793ed9cdc4396d3eb223cf86ef3c772e28e0533cbf1e56037a55cb9 | Python | 1,233 | 32 | from matplotlib import pyplot as plt
import matplotlib
import pandas as pd
import numpy as np
node0 = np.array(pd.read_csv('probe_nodes0.csv')['INTRA'])
node1 = np.array(pd.read_csv('probe_nodes1.csv')['INTRA'])
node2 = np.array(pd.read_csv('probe_nodes2.csv')['INTRA'])
node3 = np.array(pd.read_csv('probe_nodes3.csv')... |
dd9266c9b6486ee60d7b21ea3ad60b5bbcab7f447e9b2c5ec781f872e013ad61 | Python | 1,233 | 27 | import os
import random
import torchaudio
def pick_random_wavs(folder_path, num_files=100):
all_files = [os.path.join(folder_path, f) for f in os.listdir(folder_path) if f.endswith('.wav')]
selected_files = random.sample(all_files, num_files)
return selected_files
# Example usage
folder_path = "/home/kara... |
ba9d3037a85e8625ff2e92a2a2af395ae036504e1b4ee79dd9bc19d500a16506 | Python | 1,234 | 37 | ''' This file generates the first-level GLM analysis for the supplementary
analysis for pvt and nback tasks '''
import os, sys
import numpy as np
import pandas as pd
from glob import glob
import nibabel as nib
from nilearn.image import concat_imgs
sys.path.append('/m/cs/scratch/networks-pm/effects_externalfacto... |
f2c1331792dde0e9d3d48905181609c3134553f14d91f0e7a61010a39ebde09c | Python | 1,234 | 36 | import numpy as np
from sklearn.metrics import mean_squared_error
def getScores(self,targetPSTH,runPSTH,scoreType=1):
if scoreType == 1:
MSE = mean_squared_error(targetPSTH,runPSTH)
print('MSE' + str(MSE))
funcHolder = (1-np.power(MSE,0.5))
print('funcHolder' + str(funcHolder))
co... |
072f264619ab2b361d05131c285703d515ac6e8efcc0004e5c934319b9d009be | Python | 1,235 | 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... |
44de8687433295308b2d7c96b17f8fe413849744e9cdf153635e30d7088e9425 | Python | 1,235 | 53 | import sys
import numpy as np
r = np.load(sys.argv[1])
print("dim:", r.shape)
err = 0
tot = 0
thresh1 = 0.9
#500
#thresh2 = 0.05
#100,200
thresh2 = 0.016
dict1 = {}
dict2 = {}
print ("threshold1:", thresh1, "threshold2:", thresh2)
with open(sys.argv[2]) as ins:
for line in ins:
tot += 1
line = l... |
971f823a78ea1bbc9d29baee211d62283df36d18446a3641219e45c95795526c | Python | 1,235 | 36 | import os
from pathlib import Path as _PyPath
from .savable import File, Path
from .template import Template, TemplateExpander
class OnDiskFile(File):
def __init__(self, full_path: str) -> None:
self._full_path = full_path
def write(self, template: Template) -> None:
expander = TemplateExpan... |
c38714e191781329e8e1d05ef2173b4d25ca1e224d7645f47cca7f48d33a7d38 | Python | 1,235 | 46 | #! /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... |
c95c0e03822e7dcddee16a96bbea643d2040d2e3145eda275f336ef36401d708 | Python | 1,235 | 41 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Setup script for MOFF
@author: Wei He
@email: whe3@mdanderson.org
"""
from setuptools import setup
import re
from os import path
def main():
this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, 'README.md')) as f:
... |
df328e11f4005d77858cce488e4bf98a82db219725d751493846b223ba1d677b | Python | 1,235 | 33 | import torch
import torch.nn as nn
from .gmm_utils import cal_gmm_widthC
class pdfam_gmm_module(torch.nn.Module):
def __init__(self, channels=None, num_T=3, num_K=2):
super(pdfam_gmm_module, self).__init__()
self.learn_eps = nn.Parameter(torch.zeros([1, channels, 1, 1]))
self.lear... |
297630c2320833a7e98bc243459e83357ce7ba8b0c238b23f688b82ff2ba7897 | Python | 1,236 | 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... |
5f4e4a691398d069de74f4baf4c449f5789e45da78c8b1e529f0b6c0f2c244dd | Python | 1,236 | 29 | import torch
import torchvision
from typing import Tuple, Callable, Any
from .trainingwrapper import TrainingWrapper
class VisionTransformer(TrainingWrapper):
"Wrapper around torchvisions VisionTransformer"
def __init__(self, image_size: int, patch_size: int, num_layers:int,
num_heads: int, hi... |
994dacc799a74a6bb839c6a11b1b256900afddbbedd812caf6e7792881f362b4 | Python | 1,236 | 54 | """Generic statistics
---------------------
"""
import numpy as np
import matplotlib.pyplot as plt
def ztransform(x):
'''
Returns signal with zero mean and standard deviation of 1.
If a signal with zero standard deviation is supplied, a zero vector
is returned.
Parameters
----------
x: ... |
a67c820e6286fd5e4f2281606bbee1d0bdf1bd3d6213da0b40df295bd93d4bc7 | Python | 1,236 | 37 | import argparse
import dataset as module_dataset
import datasets_manager as module_datasets_manager
from parse_config import ConfigParser
from utils import set_random_seed
SEED = 1126
set_random_seed(SEED)
def main(config):
Datasets = {project_id: config.init_obj(
f'datasets.{project_id}',
... |
b456a0f8ad6de0f298c3c85ddcb364077cf8965abf86e05916b1a17b6015f3df | Python | 1,236 | 38 | import os
import re
from setuptools import Extension, find_packages, setup
with open('HPRO/__init__.py', 'r') as f:
txt = f.read()
version = re.search("__version__ = '(.*)'", txt)[1]
setup(name='HPRO',
version=version,
description='Hamiltonian Projection and Reconstruction to atomic Orbitals',
# ... |
e811c5be82c9141dd940be3fab72a731bba7be839b1ea0114cc89ec910092ff4 | Python | 1,236 | 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... |
0be217ecffb53093db6ef3269fa4af933fc8efed7c90ef565bc0159d0d7eeb74 | Python | 1,237 | 11 | """posthoc_dominant_doubt_2026-10-02.py — POST HOC, descriptive (after DOMINANT_INPUTS, 2 Oct night).
Of the brain's dominant inputs, which carry a published sign that the evidence makes more likely wrong than right
(p_wrong >= 0.5: a contradicting laboratory label, or most fast-transmitter votes for the other sign)?""... |
133c758550c7f41d13a22da5aa30f52c0f84d52750cf323a8b69eb591666dea7 | Python | 1,237 | 54 | """
Base class for runners.
"""
from __future__ import annotations
from dataclasses import dataclass
from typing import TYPE_CHECKING
from quacc.runners.prep import calc_cleanup, calc_setup
if TYPE_CHECKING:
from ase.atoms import Atoms
from quacc.types import Filenames, SourceDirectory
@dataclass
class B... |
291fe164cce0bedacc8b93c4eb4a79b80310b43465397dbf13ff09aa9f6fd2f0 | Python | 1,237 | 38 | import autograd.numpy as np
from autograd import grad
from autograd.test_util import check_grads
def sigmoid(x):
return 0.5 * (np.tanh(x) + 1)
def logistic_predictions(weights, inputs):
# Outputs probability of a label being true according to logistic model.
return sigmoid(np.dot(inputs, weights))
def... |
7dec41dddad303b91fc8d16a8410e4c4a7d8ed98ce8af09299940e7f2f9295f9 | Python | 1,237 | 35 |
from distutils.core import setup
from setuptools import find_packages
with open('requirements.txt') as f:
required = f.read().splitlines()
setup(
name = 'sc-instant',
packages=find_packages(include=('InSTAnT/*',)),
package_dir={
'InSTAnT': 'InSTAnT',
},
version = '1.2.1',
license='... |
a3b6fae614bf718fbe8c68cf09decfef774de91e14174c7082c69135e8e58ec9 | Python | 1,237 | 39 | import numpy as np
import pyshot
import pytest
@pytest.mark.parametrize("radius", [0.1, 1., 2.])
@pytest.mark.parametrize("n_bins", [10, 20, 100])
@pytest.mark.parametrize("min_neighbors", [3, 5, 6])
@pytest.mark.parametrize("double_volumes_sectors", [True, False])
@pytest.mark.parametrize("use_interpolation", [True, ... |
3f3107a35da9ea17210fac7dfc5daa02c71242e99805dbe97d51f2372bb0bc8e | Python | 1,238 | 39 | from tombo import tombo_helper as th
from tombo._plot_commands import plot_single_read, test_r_imports
test_r_imports()
# plot single read
read_fn = 'path/to/read.fast5'
plot_single_read(fast5_fn=read_fn)
# plot first 10k raw obs from several reads
num_reads = 10
reads_index = th.TomboReads(['path/to/fast5/basedir/... |
6fe1f4d5c406e8bec09b4a996412d883a2788cca24af62a4fc277eecb7a968f9 | Python | 1,238 | 43 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from common_setup import IssueConfig, IssueExperiment
from relativescatter import RelativeScatterPlotReport
import suites
configs = [
IssueConfig(
"cegar-landmarks-10k",
["--search", "astar(cegar(subtasks=[landmarks()],max_states=10000))"]),
Issu... |
dd5f8b5bb7ffc859c2799f8a2ea0eebc7e6e3ad7232baa7ec21803b9a006d27c | Python | 1,238 | 47 | from pathlib import Path
import bpy
_folder_map = {
"API": "api",
"Annotations": "annotations",
}
class MN_MT_templates(bpy.types.Menu):
bl_idname = "MN_MT_templates"
bl_label = "Molecular Nodes"
def draw(self, context):
layout: bpy.types.UILayout = self.layout
assert layout is n... |
240ec356d2e50b782c932b20b4e46d9bdfb851687d916afd1636d76dd42c211a | Python | 1,239 | 38 | import sys
import inspect
import logging
import distutils.log
from . import monkey
def _not_warning(record):
return record.levelno < logging.WARNING
def configure():
"""
Configure logging to emit warning and above to stderr
and everything else to stdout. This behavior is provided
for compatibili... |
b09b2a8904ad9aa214d52d5f042ae82fe665d2a27a89be81e1e1d93f481aacfc | Python | 1,239 | 45 | # Python module to feed Asymptote with commands
# (modified from gnuplot.py)
from subprocess import *
class asy:
def __init__(self):
self.session = Popen(['asy','-quiet','-interactive'],stdin=PIPE)
self.help()
def send(self, cmd):
self.session.stdin.write(cmd+'\n')
self.session.stdin.flush()
def size(self, ... |
56a2b90c7b40714c3eca376963c4a934618334348441a9d1098ac9503a9c9b8a | Python | 1,240 | 55 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from downward import suites
from common_setup import IssueConfig, IssueExperiment
REVS = ["issue592-base", "issue592-v4"]
SUITE = suites.suite_optimal_strips()
CONFIGS = [
IssueConfig("seq-opt-bjolp", [], driver_options=["--alias", "seq-opt-bjolp"]),
IssueConf... |
6fe8507ffb16f1b2b027464809003307400427ce091f21e0266205569aa6262d | Python | 1,240 | 50 | import tensorflow as tf
import sonnet as snt
import enformer5
import importlib
importlib.reload(enformer5)
import tensorflow_probability as tfp
import pandas as pd
import numpy as np
import h5py
import sys
# exec(open("final_submission.py").read())
try:
final_model_dir = sys.argv[1]
except:
final_model_dir="epoch_14... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.