sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
a7abf37b07f00e77b1631dbab93b5b2d0011f7ad824993e1d26faa5d2d349976 | Python | 4,788 | 142 | import pandas as pd
import re
import numpy as np
from sys import exit
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
def explode(df, column, sep='|', keep=False):
"""
Split the values of a column and expand so the new DataFrame has one split
value per row. Filters rows... |
9a4c416209b14018bb1a937ea01b0e6498b4b102463e596569e6c6df29bdd9ff | Python | 4,790 | 120 | import mdtraj.utils
import os
import shutil
import logging
logger = logging.getLogger(__name__)
from openmoltools.utils import getoutput
# Functionality below adapted from openmoltools.amber.run_tleap
def run_tleap(molecule_name, mol2_filename, frcmod_filename, prmtop_filename=None, inpcrd_filename=None, log_debug_ou... |
015531de065eb1988b9436e4fab1c01bcb5a9b04878470e5da91d0903d081dd8 | Python | 4,791 | 110 | #%%
import numpy as np
import pandas as pd
import os
import anndata
import scanpy as sc
import torch
import warnings
import stlearn as st
import argparse
dataset_dir = "/spatial_prompt/"
dt_dir = "/benchmark/"
import time
#%% import data
libd_data_dir = dataset_dir+"benchmark/spatiallibd/st_data/spatialLIBD/"
libd_st... |
ef5b86763f06c198e2f321115dee7eb175398379aac5aba3e3ecbb5f67bc9862 | Python | 4,794 | 158 | """
Full-Overlap L-BFGS Implementation with Stochastic Wolfe Line Search
Demonstrates how to implement full-overlap L-BFGS with stochastic weak Wolfe line
search without Powell damping to train a simple convolutional neural network using the
LBFGS optimizer. Full-overlap L-BFGS is a stochastic quasi-Newton method tha... |
88bbed140bdb2c171eb50941f03ad61ee06288be1a2168373c6c990e01d6a839 | Python | 4,795 | 148 | import os
import sys
module_path = os.path.abspath(os.path.join('..'))
if module_path not in sys.path:
sys.path.append(module_path)
from utils.io import preprocess_data
import matplotlib.gridspec as gridspec
import numpy as np
from paths import TRAINING_DATA_PATH, EXAMPLE_PATH
import glob
import simpa as sp
import ... |
1de0a1c0a8a01e7cf82d8427815edea8b216a18d1f71c38a9299d63a9401483d | Python | 4,798 | 67 | """Figure 2: dataset overview. (a) capacity-fade trajectories per dataset (SOH vs cycle, thin lines, one panel each);
(b) distribution of cycle life / record length; (c) initial capacity by dataset. Also writes tables/table1_datasets.csv."""
from __future__ import annotations
import os, sys
import numpy as np, pandas a... |
09351b83941744005ec8ecf7b54bfb4f0fa436af07b5d1dcbee7b9ac19ce011b | Python | 4,801 | 141 | """ Console script for running subset of dataset, a part of parallel
processing"""
import argparse
import sys
from pathlib import Path
from typing import Union
from MRdataset import import_dataset, save_mr_dataset, BaseDataset
from mrQA import logger
from mrQA.config import THIS_DIR
from mrQA.utils import txt2list
... |
b535591aac62e3daf36e427e8b0a7459911c5343cd53edef60917417c5b64dbf | Python | 4,801 | 116 | import os
import sys
import json
import torch
from src.utils import Print
class DataConfig():
def __init__(self, file=None, idx="data_config"):
""" data configurations """
self.idx = idx
self.with_esa = True
self.path = {}
# load config from json file
if file is n... |
577889d8face6b897bd35896cc5412e6e7a5e93978ba95390f9e6790c894b341 | Python | 4,803 | 106 | import numpy as numx
import pydeep.base.numpyextension as numxExt
def DBM_trainer(object):
def __init__(self, model):
''' This function initializes the weight layer.
:Parameters:
model: Model, basically a list of layers
-type: Weight_layer o... |
63af182d8a246222efe94734f912c5148c080af7f28474dc158309496314ed9f | Python | 4,803 | 155 | """
Multi-Batch L-BFGS Implementation with Fixed Steplength
Demonstrates how to implement multi-batch L-BFGS with fixed steplength and Powell
damping to train a simple convolutional neural network using the LBFGS optimizer.
Multi-batch L-BFGS is a stochastic quasi-Newton method that performs curvature
pair updates ... |
61fad8a3f7fa9c81d24c3d0e1bdd2d4c3d36c6d421612da625f21811cf1adc20 | Python | 4,805 | 115 | #!/usr/bin/env python
"""
LDfeatureselect.py -
LD (Lang-Domain) feature extractor
Marco Lui November 2011
Based on research by Marco Lui and Tim Baldwin.
Copyright 2011 Marco Lui <saffsd@gmail.com>. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
... |
001ab171ebce3dfbc86b78dc58be88de584e0f938aee394eec8a7f4757e0be2b | Python | 4,807 | 151 | import numpy as np
import pandas as pd
from scipy import stats
from ._base import _CITestResult
from .pearsonr import Pearsonr
class PearsonrEquivalence(Pearsonr):
r"""
Pearson equivalence test [1] for conditional independence on continuous data.
This test first computes the partial correlation coeffici... |
8f044313e24c4f3dee0ce7ee539a8b81bc762c0e9b723d369ab92f580a2bfcbb | Python | 4,807 | 138 | import networkx as nx
import numpy as np
import pandas as pd
from pgmpy.base import DAG, PDAG
from pgmpy.metrics import BaseSupervisedMetric
class AdjacencyConfusionMatrix(BaseSupervisedMetric):
"""
Computes confusion matrix based metrics for comparing causal graph skeletons.
Treats edge presence/absenc... |
bab392c4f1a06ebd36b7a420d91a9a9134da6a240b3252729f2692468d7fe270 | Python | 4,807 | 133 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2023 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for d... |
3c209a65c24693f1df0401c14adc82e0ad2d092a22b04a5fb6adc2ac6b53fb8c | Python | 4,808 | 149 | """
Write TIP3P-FB parameters into a SMIRNOFF force field. Based on
https://github.com/pandegroup/tip3p-tip4p-fb/blob/master/OpenMM/tip4p-fb/tip4p-fb.xml
Ion Lennard-Jones parameters from $AMBERHOME/dat/leap/parm/frcmod.ionslm_126_fb4
"""
from pathlib import Path
import pandas
from openff.toolkit.typing.engines.smirn... |
6cffabaced2745153816fad0ce3c9cea50ddd1fae154cdb7d64b1d680ad757c3 | Python | 4,811 | 111 | #!/usr/bin/python
import tensorflow as tf
from tensorflow.keras import datasets, layers, models, losses, Model, callbacks
from random import randint
import numpy as np
import math
import pandas as pd
from time import time
import keras
import sys
from numpy.random import seed
from tensorflow import set_random_seed
impo... |
0caf06d56f194cc1b6597f055f60c6b1c4a76d0e226c2fcf14c345643b5319b3 | Python | 4,812 | 139 | # -- coding: utf-8 --
# @Time : 2022/10/15 16:11
# @Author : Biao Zhang
# @Email : littlebiao@outlook.com
# @File : heco_config.py
import time
from yacs.config import CfgNode as CN
# --------------------------------------------------------------
# Config of model
# -----------------------------------------------------... |
bf807c7d2097ad56ff1871d70621679f57836c96dae2fa4a2e3e1623c3a9640e | Python | 4,812 | 142 | import pandas as pd
from PoET.utils import check_hand_
from tqdm import tqdm
def extract_tremor(pc):
# define set of distance for analysing tremor
marker_features ={'right':[['index_finger_tip_right','x'], ['index_finger_tip_right','y'], # kinematic
['middle_finger_tip_righ... |
e40c9179334f08198a1266d4409f1cd4ff7543f7fb5cfa12205bae0b17523fc9 | Python | 4,814 | 124 | import mxnet as mx
import numpy as np
from nowcasting.operators.common import constant
def CDNA(data, kernels, mask, batch_size, num_filter, kernel_size):
"""We assume that the kernels and masks are the output of an identity activation
Parameters
----------
data : mx.sym.symbol
Shape: (batch_... |
789fac0299176e9e0899479a84620fd177d83a9b91c307f0744f34b0ac4a393d | Python | 4,815 | 161 | import unittest
import steps.interface
from steps.geom import *
from steps.model import *
from steps.rng import *
from steps.saving import *
from steps.sim import *
import numpy as np
from scipy.integrate import quad
from . import tol_funcs
tolerance = 8/100
#unormalised for now
def Qnew(beta, sigma):
return (... |
f08718ec454baf07282e8b2b12e2c5f17abec9e42cb8446c4b419674130a64ae | Python | 4,817 | 93 | # -*- coding: utf-8 -*-
"""
Created on Fri Jun 26 15:51:13 2020
@author: nishe
"""
#%%
import connection as cn
import numpy as np
#%%
class get_inter_ijwd:
def __init__(self, *param_dict, **kwargs):
self.Ne = 64*64 # excitatory neurons in both areas
self.Ni = 1024 # inhibitory neur... |
4a5107e6074439b35e55db7bc2383e1f69bf4ae422e2998bfbb1935cd264ff07 | Python | 4,818 | 120 | # Copyright (c) MONAI Consortium
# 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, so... |
7c371d4efaa4adca53ac25a0788d815667f9ba623b0bf67e928edaddd4e3f166 | Python | 4,818 | 169 | import pandas as pd
import random
import numpy as np
from datetime import datetime
# Define number and length of cases
num_cases = 1000 # 50000
length = 12
num_events = num_cases * length
# Variables for timestamp
time_str = '01/01/2020 08:00:00'
date_format_str = '%d/%m/%Y %H:%M:%S'
time = datetime.strptime(time_st... |
8bf83673200314fd7180e191a591ba312cba54260328ae521ffc05d96d3e36a2 | Python | 4,819 | 83 | #!/usr/bin/env python
import os
import sys
import gzip
from datetime import datetime
from joblib import Parallel, delayed
from .annotations import Annotations
from .annotationsbed import AnnotationsBed
from .intersectedbed import IntersectedBED
from ..constants.constants import HUMAN_SOMATIC_CHROMOSOMES
def annotat... |
3467b32b4b2ca0c9466a6a61f7c9ed00a4dee43120fc3083aecfc19ac16aa537 | Python | 4,820 | 145 | from __future__ import annotations
import random
import numpy as np
from libs.function.function import Normalize
from libs.function.utils import aline_spatial
def Img_horizontal(size: int, barsize: int) -> tuple:
slide = barsize * 2
img_1 = np.zeros((size, size))
for i in range(0, size, slide):
... |
8c8125fd00fb8f23e491f177903b0ab7f213de05bffda9deba202b1057f53d00 | Python | 4,820 | 121 | import sklearn.neighbors as sk
from ..utils.utils import *
def build_springs(
container,
load_nn,
nn_max,
verbose=False,):
"""Build nearest-neighbor spring network for spatial regularization.
Build KDTree of nn_max nearest neighbors around each annotation. These connections
are used to c... |
4a4114d49d84a15156d82b87872b1fff34d8dc0e5d163eb4a897d456296eebdd | Python | 4,822 | 179 | """
Functions to plot free energy maps for sets of ligands
"""
__author__ = 'Hannah E. Bruce Macdonald'
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
from scipy.stats import linregress
import logging
logger = logging.getLogger(__name__)
def pathway(nodes):
"""
Converts a list o... |
360df7ac3e9b635e4e7e0f3c817c7b7727ea61d9f19c76f1c0ec5f0b8fcf7505 | Python | 4,823 | 89 | import numpy as np
import pandas as pd
import pytest
from sklearn.gaussian_process.kernels import RBF, DotProduct
from pgmpy.base import DAG
from pgmpy.ci_tests import HSIC, KCI, get_ci_test
@pytest.fixture
def kci_data():
df_ind = pd.DataFrame(np.random.default_rng(seed=42).standard_normal((200, 3)), columns=["... |
462904f1e67329a2452c5227ddb5f6666db13405519a27ac667f9201294cfb74 | Python | 4,824 | 164 | # Copyright 2021 AlQuraishi Laboratory
# Copyright 2021 DeepMind Technologies Limited
#
# 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
#
# U... |
51fdd3a99c16498b94df493dee7378726e50c9637c6df2c9b98188de72193dd6 | Python | 4,824 | 134 | import os
import numpy as np
import torch
import torch.nn.functional as F
cuda = True if torch.cuda.is_available() else False
def cal_sample_weight(labels, num_class, use_sample_weight=True):
if not use_sample_weight:
return np.ones(len(labels)) / len(labels)
count = np.zeros(num_class)
for i in r... |
b10349013dd7c58aa94e15c7c1c895e9f905193ed0b8d6aad0dd469a6f84c623 | Python | 4,824 | 121 | """
Tests for folding at home generator suite in perses
TODO:
* Write tests
"""
import os
from unittest import skipIf
import pytest
running_on_github_actions = os.environ.get('GITHUB_ACTIONS', None) == 'true'
#default arguments for tests
DEFAULT_PLATFORM_NAME='CPU'
DEFAULT_PROJ_ID = {'complex': 1000, 'solvent': 100... |
cbf916cfb5b1e7c83059e890c93298799fed0f9a93a3b560b3562ec36a0e4e46 | Python | 4,826 | 139 | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Author: Yulia Rubanova
###########################
import numpy as np
import sklearn as sk
import numpy as np
#import gc
import torch
import torch.nn as nn
from torch.nn.functional import relu
import lib.utils as utils
from lib.utils impo... |
f9c38591d31284668ab46d975322c30954c3b4436059179de6628bf6b8369b61 | Python | 4,827 | 75 | #!/usr/bin/env python
import tempfile
import sys
import argparse
import os
from .partitionedheritability import PartitionedHeritability
from ..model.ld import LDScores
from ..model.weights import Weights
from ..model.frequencies import Frequencies
from ..model.summarystatistics import FormattedSummaryStatistics
from ... |
0cb7b0ba4c71029cf5fae058a21115556c0f44f4df912a7cc31f26a441633ca8 | Python | 4,829 | 143 | import logging
import numpy as np
def get_n_lower_triangular_values(n_time_series: int) -> int:
return int(n_time_series * (n_time_series - 1) / 2)
def slice_covariance_structure(full_covariance_structure: np.array, edge_indices: tuple) -> np.array:
"""
Select a certain edge from a full covariance stru... |
59b2afb1f1c3f6119ca43b22d6efe6cb4709f9881b3591eecb09bac50de49da0 | Python | 4,829 | 155 | # -*- coding: utf-8 -*-
# author: Felix Repp felix.repp@mpikg.mpg.de
#!/usr/bin/env python
import os
import numpy as np
import pdb
import networkx
import scipy
import scipy.stats
import pandas as pd
#import tina_main
"""@package tinacell
%This module provides the tools to analyze the cells: the size, shape, orientatio... |
800b4ee44ec852b02040c013b5bc7bc9b5ce20f417b442e707aebc962ad9904e | Python | 4,829 | 144 | import itertools
import glob
from cgatReport.Tracker import *
from cgatReport.Utils import PARAMS as P
import cgat.Pipeline as Pipeline
import cgatPipelines.PipelineTracks as PipelineTracks
###################################################################
#############################################################... |
50f19e47a4bc6e9cae920c27f688e317c90d9d97af1061375b08c3bdfd21298a | Python | 4,830 | 112 | import glob
import os
import pandas as pd
import seaborn as sns
class nebula:
from .circos import circos_plot
from .MultipleVisualization import barplot
from .MultipleVisualization import circular_path
from .MultipleVisualization import similarity_heatmap
from .MultipleVisualization import simila... |
7cb99e51f99e9cfe87d64678bc9ef12fa3619b9c2a6697dba7278aa738424afb | Python | 4,831 | 157 | """
Process nanopolish methylation calls for evaluation.
"""
import multiprocessing as mp
import sys
import pandas as pd
sys.path.append("..")
from utils.constants.final_analysis import METHYL_BED_COLS
from utils.constants.final_analysis import NANOPOLISH_BINARY_SUMMARY_COLS
BUFFER = 5
SINGLETON_LEN = 11
NUM_NANOP... |
de0908200e6a3ea71a77cc30cb68a81bf848c4afefd978311ec66c2b1d35ca29 | Python | 4,832 | 129 | import numpy as np
import matplotlib.pyplot as plt
from oset.generic.lp_filter import lp_filter_zero_phase, tikhonov_regularization
def common_mode_noise_canceller(x, fs, fc=None, itr=10, lambda_val=100, optim_indexes=None, plot_results=False):
"""
Estimates and removes common-mode noise from multichannel data... |
c47f75285cf5db190c33659cb8cfc95f1c4ef3fe1ffdea7d4cfb73a4ad68af66 | Python | 4,834 | 126 | import re
from typing import Literal
from langchain_core.agents import AgentAction, AgentFinish
from pydantic import Field
from typing_extensions import override
from langchain_classic.agents import AgentOutputParser
def _unescape(text: str) -> str:
"""Convert custom tag delimiters back into XML tags."""
re... |
ca3e78cfef9a9bd39242df5a9790f8c2963b36945504b40ea85888c03306670a | Python | 4,836 | 166 | """
2023.08.30
author: femke.hurtak@epfl.ch
Script to overlay the neurotransmitter type on the connectivity matrix.
"""
import os
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import plot_params
from loaddata import (
load_graph_and_matrices,
load_nodes_and_edges,
)
from common impor... |
cb265dacb025eb0b57f8cb2ae063566b90faa7b282211337926846a2a11e659a | Python | 4,836 | 128 | import pytest
import torch
from chroma.data import Protein
from chroma.layers.structure import backbone, protein_graph
from chroma.models.graph_backbone import GraphBackbone
def test_denoiser(dim_nodes=32, dim_edges=32):
X, C, S = Protein("1SHG").to_XCS()
model = GraphBackbone(dim_nodes=dim_nodes, dim_edges=... |
6b4fbe509d67783f242ebfe0bae155035ee145626abaf74c731f26be84514712 | Python | 4,837 | 109 | import matplotlib.pyplot as plt
import torch
from Grad_Cam.grad_cam import GradCAM
from pytorch_grad_cam.utils.model_targets import ClassifierOutputTarget
from pytorch_grad_cam.utils.image import show_cam_on_image
from torchvision.models import resnet50
from skimage.io import imread
from torchvision import transforms
f... |
2c5646427cfd1ecf6cf61c79d0b801890f8ec575c1eecf6b1b1ba4f9c452f29c | Python | 4,841 | 271 | import string
letters = string.ascii_uppercase
rename_chains = {i: letters[i] for i in range(26)} # NOTE -- expect errors if you have more than 26 structures
skip_res_list = [
"HOH",
"GOL",
"EDO",
"SO4",
"EDO",
"NAG",
"PO4",
"ACT",
"PEG",
"MAN",
"BMA",
"DMS",
"MPD"... |
ac26c9fd8a0006300f2757ecdd99c3ccd7b0759c409d20d5fd68ea2501b0da4c | Python | 4,841 | 143 | import torch
import torch.nn as nn
import sys
import numpy as np
from torch.nn.init import calculate_gain
#torch.set_num_threads(36)
def off_diag_init(m):
if isinstance(m, nn.Linear) or isinstance(m, LogSigProdLayer):
with torch.no_grad():
m.weight.copy_(torch.triu(m.weight, diagonal = 1) + to... |
de4920b1dfc25678cfbf2c8eb014cb60e5138f13822a2ac4c3bef739e9372de5 | Python | 4,842 | 122 | ##!/usr/bin/python
#############################################################################
#Package: stamp
#Coded by: Yiqin wang
#Usage:
#
#
##############################################################################
import sys, os
prog = "stamp"
version = "0.1.2"
def print_help():
help_msg = """
Program... |
649d9e6077d32fdee8affdcef385ab85d48900eeefae779bd797093db8ece59a | Python | 4,845 | 158 | import pandas as pd
import os
import argparse
import json
import subprocess
from datetime import datetime
def parse_args():
parser = argparse.ArgumentParser(
prog='send_run_summary.py',
formatter_class=argparse.RawTextHelpFormatter,
description=(
'Generate a run summary from a ... |
a78c06794f9bc4d8a7e9b67f5e83c25e7ca1b36c94d497d7c224c8e0d3f94de8 | Python | 4,847 | 140 | from numba import jit, float64
import numpy as np
@jit(float64[:](float64[:], float64[:]), nopython=True, nogil=True, cache=True)
def _cross_vec3(a, b):
c = np.zeros(3)
c[0] = a[1]*b[2] - a[2]*b[1]
c[1] = a[2]*b[0] - a[0]*b[2]
c[2] = a[0]*b[1] - a[1]*b[0]
return c
@jit(float64(float64[:]), nopytho... |
23032fec4620e385f8e8182a649ffc99777414906db37f910fa368743f209b76 | Python | 4,850 | 169 | #!/usr/bin/env python
import nrrd
import numpy as np
import argparse
import warnings
import os
# with warnings.catch_warnings():
# warnings.filterwarnings("ignore", category=FutureWarning)
import nibabel as nib
PRECISION= 17
np.set_printoptions(precision= PRECISION, suppress= True, floatmode= 'maxprec')
def _sp... |
cd611d7aed5bca21cb74599fb9eee9d6366393d16b7eb446d80fe28fc7c23047 | Python | 4,850 | 141 | """Output parsers using Pydantic."""
import json
from typing import Annotated, Any, Generic, Literal, overload
import pydantic
from pydantic import SkipValidation
from typing_extensions import override
from langchain_core.exceptions import OutputParserException
from langchain_core.output_parsers import JsonOutputPar... |
93daf14931f3a0c1fa667014a59fc5bb782e0694eefb1bad7e02bd965b4d2327 | Python | 4,854 | 143 | """
##############################################################################
#
# Filter tandem pas according to the expression
# (keep tandem pas expressed in all samples)
# (+ sort the output tables with pas expression & position)
#
# AUTHOR: Maciej_Bak
# AFFILIATION: University_of_Basel
# AFFILIATIO... |
0bb3bd1d128214a795459b0335ff5dd97adcac6bcb68324f96eb48dab692eb3b | Python | 4,855 | 135 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 3 10:57:50 2019
@author: ngritti
"""
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (QApplication, QVBoxLayout, QDialog, QPushButton)
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt5agg import FigureCanvas
from ma... |
02018bc1fa6dfc3238ddf1bc9083fccc5e115706f31870883735a1703e5709cc | Python | 4,857 | 155 | """Parse the YAML configuration."""
import logging
import shutil
from pathlib import Path
from typing import Optional, Dict, Callable, Tuple, Union
import yaml
from . import utils
logger = logging.getLogger("casanovo")
class Config:
"""The Casanovo configuration options.
If a parameter is missing from a u... |
511ea408d451bacfb5443ebb77bb105986537667ebff4be38789d428e91b6b2f | Python | 4,858 | 97 | # 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
#
# http://w... |
c5966ae53b7752e038baa6b6c21f2d4eebeb6499e8a33793a9cf36645ef84038 | Python | 4,858 | 133 | from sklearn.model_selection import train_test_split
from sklearn.model_selection import StratifiedKFold
import pandas as pd
import random
import sys
from mantis_ml.config_class import Config
class BalancedDatasetRandomGenerator:
def __init__(self, cfg, df, Y, balancing_ratio, kfold, random_state, stratif... |
1b2fcde0718c226dfa0d7cdb0cc93dd9ec24ad810d3212ad90feae094b06e8a2 | Python | 4,859 | 133 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2026 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for detai... |
51ae72268e1918261c454e9520432e8314b1b8267c40ad9f988afc07bd741371 | Python | 4,861 | 127 | """Extract Laplacian from structural connectome based on
transmission speed and oscillatory frequency"""
import numpy as np
def decompose_regular_laplacian(C, alpha=1, num_ev=86):
""" Get regular laplacian without frequency tuning and and transmission velocity
"""
nroi = C.shape[0] # get number of ROIs
... |
c4c72b3ee65d22cd56f4c60196471cacfda7e5a647863b3f44a072743490b1ff | Python | 4,861 | 141 | import warnings
import multiprocessing as mp
# third party modules
import numpy as np
# pnabind modules
from pnabind.mesh._zernike import meshDescriptors
from .laplacian_smoothing import laplacianSmoothing
from .map_point_features_to_mesh import mapPointFeaturesToMesh
class MeshDescriptor(object):
def __init__(s... |
8255cdc933c0194654beef4743c7a12739c048d4eae6c1df7618e89b96a3c40d | Python | 4,862 | 121 | # Copyright (c) DP Technology.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import absolute_import, division, print_function
import os
import pandas as pd
import numpy as np
import csv
from typing import List, Optional
impor... |
ec483049f97a6d032309057922f098b18c339d58f9815b925eda393debc59ca1 | Python | 4,864 | 134 | from sklearn.model_selection import train_test_split
from sklearn.model_selection import StratifiedKFold
import pandas as pd
import random
import sys
from mantis_ml.config_class import Config
class BalancedDatasetRandomGenerator:
def __init__(self, cfg, df, Y, balancing_ratio, kfold, random_state, stratif... |
4d396d3bbaf40ba5df625f8d4c6ba32af833a7da5d58d1897a624c17b84ead11 | Python | 4,866 | 168 | """Test for Serializable base class."""
import json
import os
from typing import Any
from unittest.mock import patch
import pytest
from langchain_core.load.dump import dumps
from langchain_core.load.serializable import Serializable
from pydantic import ConfigDict, Field, model_validator
class Person(Serializable):
... |
95911b2de3700e1cd3a0a940a3b483a936abc3825044cf79d05bda2e53c7a26c | Python | 4,866 | 90 | import logging
import os
import socket
import sys
from configs.configs import get_config_dict
from helpers.slurm import send_slurm_job_to_queue
if __name__ == "__main__":
hostname = socket.gethostname()
assert hostname == 'hivemind'
model_name = 'MGARCH'
data_set_name = sys.argv[1] # 'd2', 'd3d... |
c7e9d42d05008da3e79e1f0be76af168b8d8638aa448612b1ab33230a085787e | Python | 4,866 | 125 | import yaml
import argparse
import torch
from torch.optim.lr_scheduler import _LRScheduler
from torch import nn
import torch.nn.functional as F
from torch_geometric.transforms import BaseTransform
from torch_geometric.data import Data
from torch_geometric.nn import radius_graph
from os.path import dirname
import pyto... |
09d3753c5733d952051943a231b71ffc7b53b121694483f2872e0851463c2754 | Python | 4,869 | 131 | # Load in model weights and evaluate its goodness (ECE, MCE, error) also saves logits.
# ResNet model from https://github.com/BIGBALLON/cifar-10-cnn/blob/master/4_Residual_Network/ResNet_keras.py
import keras
import numpy as np
from keras.datasets import cifar10, cifar100
from keras.preprocessing.image import ImageDat... |
72be0269518a683e29a5d4e2e4ececf4f999ef93438871b7d4b270ced0d11ffb | Python | 4,869 | 120 | """
Computes streamline curvature based on the spatial displacement of the central streamline of the barrel column.
The deflection is measured at at average minimal and maximal depth of the streamline. Then maximal deflection is reported.
Intuitively, we measure by how much does the curved barrel deflects from a stra... |
45b45285c7862d53e2f1f9adb0da788e7c56ce75b80176be47da35dbd78193a4 | Python | 4,870 | 148 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2026 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for detai... |
61019c139de5e3c466a5b65859a63896cdb1946f2aada79aea2c3e0bef2a75a1 | Python | 4,873 | 141 | import unittest
import numpy as np
from SMdRQA.utils import *
# The assert_matrix function
# Test case class for assert_matrix
class TestAssertMatrix(unittest.TestCase):
def test_1d_array(self):
# Test with a 1D array, which should be converted to a 2D array
input_array = np.array([1, 2, 3])
... |
77b5f4be251e97caa11fa077d9455b528cd859b6f389f4693038e79039b59475 | Python | 4,873 | 134 | import argparse, importlib, math
from data import generate_recog_data_batch
import torch
import torch.nn as nn
import numpy as np
from net_utils import random_weight_init, load_from_file
from networks import HebbNet
#haba_loop.py args
#script = 'script_recog_vary_w1init.py'
#argsList = [
# ('--... |
e159d7e4cd87184c8302eded3ab885dc847455c53ebe9f98daaa827382399a6f | Python | 4,874 | 139 | # import math
# import shutil
# from datetime import datetime
# from pathlib import Path
#
# import numpy as np
# import pytest
# from MRdataset import load_mr_dataset, import_dataset
# from mrQA import check_compliance
# from mrQA.config import report_fpath, mrds_fpath, past_records_fpath, \
# DATE_SEPARATOR
# fro... |
ce03a0cc8c66046886163e2bc864e0f95f2f34047c56a053e1c90369644a366d | Python | 4,875 | 83 | """Conformal calibration on real data with a LightGBM point model under P3 (cell-disjoint) and P4 (LODO).
For each fold: training cells are split into fit (80%) / calibration (20%) cells. Intervals at 90% target:
split : global quantile of |residual|
mondrian : quantile per training DATASET (chemistry proxy... |
88797b848228fda217c873fdfc06e0acd1c76e94bd1f128acd46e272b7043ed6 | Python | 4,876 | 157 | '''cgat_tsv2links.py - create a series of file links with renaming
==================================================================
Purpose
-------
Create links from a tab-separated table. The table should have two
columns, for example::
source dest
abc.fq.gz sample1-condition-R1.fastq.1.gz
def.fq.g... |
d1d79f1a5aae6bfaa27db9922f6b2adbb2510d6f76698243147f44c2139bfabd | Python | 4,878 | 122 | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import Optional
from pytorch_lightning import LightningDataModule
from torch_geometric.loader import DataLoader as pyg_DataLoader
from torch.utils.data import DataLoader
from pdearena.data.registry import DATAPIPE_REGISTRY
f... |
5f64d1d4e9e18dde541773fd43c41bbd173a173d4b3fcb7212f109531e72e38f | Python | 4,879 | 123 | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import json
from mmcv.runner import OPTIMIZER_BUILDERS, DefaultOptimizerConstructor
from mmcv.runner import get_dist_inf... |
641b9d8455190fd178c0dacb26496083bea85a884574735346abdc3703e577bf | Python | 4,880 | 150 | import numpy as np
import plot_params
import neuron_params
import params
from louvain_clustering import load_communities
from common import identify_name_from_rid
def name_has_probably_a_genetic_match(name: str):
"""
This is a very simple heuristic to determine whether a neuron has a genetic line.
"""
... |
61bbe1972d85893fb718bc82d4a86127a9e85c4c2af6d53b6ada21a7cd47b160 | Python | 4,882 | 151 | #!/usr/bin/env python
# Copyright (c) MONAI Consortium
# 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 a... |
bea3017bff4b28c9a62c0abb9bc1076936fd51d8f0beaadea1b0715f39ecf2ce | Python | 4,883 | 117 | import pytest
from langchain_classic.chains.qa_with_sources.base import QAWithSourcesChain
from tests.unit_tests.llms.fake_llm import FakeLLM
@pytest.mark.parametrize(
("text", "answer", "sources"),
[
(
"This Agreement is governed by English law.\nSOURCES: 28-pl",
"This Agreem... |
93973c144455bf81cae069571e33c4ac03dd3f61f52ebd7705cb66e4cf132751 | Python | 4,885 | 156 | import re
import numpy as np
import torch
# from utils.encoding_methods import onehot_encoding, pssm_encoding, position_encoding, hhm_encoding, cat
# from torch_geometric.data import Data, DataLoader
def load_seqs(fn, label=1):
"""
:param fn: source file name in fasta format
:param tag: label =... |
7db2c77b39813fbafbfd2c9252dc75dd40d5b0553ea2339b693cc0cae0aa7432 | Python | 4,887 | 148 | """Functionality for loading agents."""
import json
import logging
from pathlib import Path
from typing import Any
import yaml
from langchain_core._api import deprecated
from langchain_core.language_models import BaseLanguageModel
from langchain_core.tools import Tool
from langchain_classic.agents.agent import BaseM... |
e8fbe56dcd95e51e7f597a2c97b3214eba0f6d5231a7bffe92be347e0f06f67f | Python | 4,887 | 135 | import argparse
import numpy as np
from scipy.signal import butter, filtfilt, convolve
def peak_det_pan_tompkins(data, fs, *args):
"""
peak_det_pan_tompkins - R-peak detector based on Pan-Tompkins method.
Args:
data (numpy.ndarray): Vector of input ECG data
fs (float): Sampling rate in H... |
d79fa6ee415b0b566c8be6c14b86bf0ad90272e57fc67ce52a5acfd855ae93f5 | Python | 4,894 | 142 | # -*- coding: utf-8 -*-
"""
Created on Sun Mar 21 11:36:41 2021
@author: gritti
"""
import sys, time, tqdm, copy, os, glob
from skimage.io import imread, imsave
import numpy as np
import PyQt5.QtWidgets
import matplotlib.pyplot as plt
import matplotlib as mpl
import warnings
warnings.filterwarnings("ignore")
from mor... |
65f2783cbaadccd90d3727035bd5da3c273af0469cf85e464d9c81313a83506b | Python | 4,906 | 124 | """
Parse TTD
"""
import pathlib
import pandas as pd
class ParseTTD:
"""
"""
def __init__(self, root=None , debug=False):
self.debug = debug
f_dict = {'target': 'P1-01-TTD_target_download.txt',
'drug': 'P1-03-TTD_crossmatching.txt',
'mapping': 'P1-07-Dr... |
719f985b8ec62830fd2fcc0470647c4ca6aafb9a06c36dcd613697d14e19479e | Python | 4,908 | 95 | # 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
#
# http://w... |
c58423788b97149d5fee751496e4108c4be9f01049ca69b2c24f88e535573b20 | Python | 4,910 | 162 | """
Full-Overlap L-BFGS Implementation with Stochastic Armijo Backtracking Line Search
Demonstrates how to implement full-overlap L-BFGS with stochastic Armijo backtracking
line search and Powell damping to train a simple convolutional neural network using
the LBFGS optimizer. Full-overlap L-BFGS is a stochastic quas... |
1b16acd0be0f51a62da5ae918a66b622d43e46a30e9b575dd0c5ca93a5f56da1 | Python | 4,913 | 148 | # coding: utf-8
import os
from absl import flags
from absl import app
import numpy as np
from sklearn.model_selection import train_test_split
from retchat.dataset import DataFinder
from retchat.dataset import Annotation
from retchat.dataset import Stack, MaxBlockStack, PercentileNormalizedMaxBlockStack, Max2R10Prepr... |
5673fb9524979f73d8348d9eda7bf1b01ef646163088eeca9c0fb14dbcc3d984 | Python | 4,913 | 138 | import tempfile
import zipfile
from collections import defaultdict
from datetime import datetime
from pathlib import Path
import pydicom
from pydicom import dcmread
from mrQA.utils import convert2ascii
def make_test_dataset(num_noncompliant_subjects,
repetition_time,
echo... |
077862860169fbf0059b3f0d49509a7df7439529f62005a847afe82a272a20a7 | Python | 4,916 | 127 | # Copyright (c) MONAI Consortium
# 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, so... |
0e311cd74bf778cd8b9a28f42c8cf234f347e106c0357c8fd6ab67b6b2c386e1 | Python | 4,916 | 144 | """
------------
Description:
------------
This is a short demo file to make it easier to use this respository. It will
show you how to:
- Load a h5 shape model and the submodels
- Draw random samples from it
- Add texture to the file
- Store the shape as a vtp file (or as a ply file without texture)
-------------
Req... |
ca2a9e60a92e32b928fab8da41fccd59bb7099c31f4249061f88f13acc05d68c | Python | 4,916 | 138 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2023 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for d... |
2dd4d52a78392be2a67f497c7bcbc83461aeffeb16149da1680fd3ff5a6ac715 | Python | 4,917 | 138 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2026 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for detai... |
920cb8e5edf9c32863d83c678dfe2eb7fa00023134b23568cda731bdad5f1632 | Python | 4,920 | 144 | import copy
import os
import random
import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.optim as optim
import torch.utils.data as data
import torch.backends.cudnn as cudnn
import math
import numpy as np
from config import get_train_config
from data import ModelNet40
from models import Me... |
ce9889849df2a354dc3a3a068b01ad89a0398304e9d6b4d338e4f5bcd5411cf8 | Python | 4,920 | 124 | import logging
import os
import socket
import sys
from fcest.models.mgarch import MGARCH
import pandas as pd
from configs.configs import get_config_dict
from helpers.data import load_data
from helpers.evaluation import leave_every_other_out_split
if __name__ == "__main__":
hostname = socket.gethostname()
p... |
9de7b920bb47c9e2766db7ba62b32ec68c82b93729f624796dc770fe5d547358 | Python | 4,921 | 127 | import torch
from torch.autograd import Variable
import torch.optim as optim
import torch.nn.functional as F
import sys
sys.path.append("../../")
from TCN.mnist_pixel.utils import data_generator
from TCN.mnist_pixel.model import TCN
import numpy as np
import argparse
parser = argparse.ArgumentParser(description='Seque... |
9e0582bb85ab45b5bab2d0d95ce1682ab045db57741b293ee4e5b838537d4c85 | Python | 4,922 | 131 | # Copyright 2024 DeepMind Technologies Limited.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed... |
e9601bfe1fc8af5fd6271c5182c1d74aaa10cda6fc162f22cd8ce812dab89f76 | Python | 4,925 | 121 | #!/usr/bin/env python
# Imports
import unittest
import os.path
import sys
import subprocess
import tempfile
###############################################################################
path_to_script = os.path.join(os.path.dirname(os.path.realpath(__file__)),'..','bin','enrichm')
path_to_data = os.path.join(os.pat... |
9783a8bf790f0928dfc00319f3cada0f5faa152652ca2bc1093c61599e5a21e0 | Python | 4,929 | 130 | # -- coding: utf-8 --
# @Time : 2022/10/15 16:11
# @Author : Biao Zhang
# @Email : littlebiao@outlook.com
# @File : heco_config.py
import time
from yacs.config import CfgNode as CN
# --------------------------------------------------------------
# Config of model
# -----------------------------------------------------... |
2a7d95eff78afb75c5076bedcdbf477aedf78a7123852263142e92b8eeb7b1a2 | Python | 4,934 | 144 | """Use the outer-layer-shells to find the border positions between layers for each barrel column"""
import numpy as np
import pandas as pd
import voxcell as vc
from tqdm import tqdm
from scipy import ndimage
from utils import indices_to_mask, positions_to_mask
def is_adjacent_voxel(voxel1, voxel2, distance=1):
""... |
14f7417869ea89306bf94367689af1daa66d6131731648488a297d5ffff6235a | Python | 4,936 | 154 | # Utilities
import os, sys, time, math
import pyqtgraph as pg
import numpy as np
import zmq
# Qt
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QThread, QTimer, pyqtSignal
DEFAULT_NB_CHANNELS = 16
DEFAULT_NB_DT_PER_TRANSFER = 190
DEFAULT_TARGET_IP = "tcp://192.168.137.16:5558"
DE... |
0307e4c681465062c1da371c1ea60ddf55bf2aaed849d21a173f289e61589ae5 | Python | 4,939 | 130 | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import datetime
from collections import OrderedDict
import torch
import mmcv
from mmcv.runner import HOOKS
from mmcv.r... |
80a3a788423c56b8ce2860cf677d928b6379a5b52c5d709fa178139caaf9a644 | Python | 4,939 | 123 | import numpy as np
def get_one_hot_of_activity_sim(x, max_blood_pressure, max_heart_rate, current_blood_pressure_value, current_heart_rate_value):
if x['Activity'] == 'ER Registration':
ret = [0, 1] # No additional information, so normal one hot
elif x['Activity'] == 'Medication B':
ret = [1,... |
9d0775a86169d81abdbb216c3a7c1ca3bdf6e5b8e2b00d6955d5d66cb60cb6b4 | Python | 4,940 | 164 | from funlib.run import run, run_singularity
from subprocess import check_call
import os
from synister.read_config import \
read_worker_config, \
read_predict_config, \
read_train_config
from synister.synister_db import SynisterDb
import threading
import time
def monitor_prediction(
predict_config,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.