sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
a89bc61f62569fdf0e03483f5f43f30c916dc3eb3785b3d20c9543152382cc65 | Python | 2,526 | 59 | import torch.nn as nn
import torch
import torch.nn.functional as F
from models.pointnet2_utils import PointNetSetAbstractionMsg,PointNetSetAbstraction,PointNetFeaturePropagation
class get_model(nn.Module):
def __init__(self, num_classes, normal_channel=False):
super(get_model, self).__init__()
if ... |
ca4c0c5362b9f8e3e22e1c88b53acd5b2ca21252f917933e540d6908a0d92d1f | Python | 2,526 | 96 | import logging
import os
import hydra
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from matplotlib.ticker import MultipleLocator
from omegaconf import DictConfig, OmegaConf
from src import PROJECT_DIR
log = logging.getLogger(__name__)
@hydra.main(
config_path=os.path.join(PROJECT_D... |
1e1eab7591d641de299b233b8b8dffadaed7599f3bf17c1cbf7bec291d9d2c7f | Python | 2,530 | 55 | # coding: utf-8
""" MIT License """
'''
Project: Parenchymal Attention Network
Authors: Axel Masquelin
Description: Utility functions to plot metrics
'''
# Libraries
# ---------------------------------------------------------------------------- #
import time
import sys
import os
# --------------------------... |
920d099d7d234cf2fc13e378c0bf4451f9881b3bc3de1b1807a3b3f833d3fa7d | Python | 2,530 | 75 | import logging
import os
import socket
import sys
import pandas as pd
from configs.configs import get_config_dict
from helpers.icc import compute_icc_scores_pingouin
def _compute_brain_state_switch_count_icc(
config_dict: dict,
num_basis_states: int,
connectivity_metric: str = 'correlation',
) -> None:
... |
8e8ee8bcdf444d7ca849c95d2ed9ab310edf35b0cb70c4a7cde6a910fd927493 | Python | 2,531 | 68 | import sys
import os
import time
import warnings
from sklearn.exceptions import ConvergenceWarning
import gc
import psutil
import numpy as np
warnings.simplefilter(action='ignore', category=ConvergenceWarning)
warnings.simplefilter(action='ignore', category=RuntimeWarning)
warnings.simplefilter(action='error', cate... |
e0fbd3cf3e3ad6425fb686b68862305dbb793b06e3d1cd9e075b3f2d809642c1 | Python | 2,535 | 98 | import os
from skimage import io, transform
import torch
import torchvision
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader
from torchvision import transforms#, utils
# import torch.optim as optim
import numpy as np
from PIL imp... |
47912ec32bc61cbb89de761239be26795438f63b3fd616fc9f305332a4d6839c | Python | 2,536 | 96 | #!/usr/bin/env python3
"""
Merge separate segmentation volumes, with one ONLY one label per volume, into one.
Usage
----
merge_labels.py <out label image> <first input label image> <second input label image> ...
merge_labels.py -h
Example
----
>>> merge_labels.py atlas.nii.gz seg_1.nii.gz seg_2.nii.gz
Authors
----... |
490a52a7eb11d00eb9a860299542ccffa69ae10410036a11a144b30e91b2b8e7 | Python | 2,536 | 72 | ''' Example for the preprocessing functions on natural images.
:Version:
1.0
:Date:
06.06.2016
:Author:
Jan Melchior
:Contact:
JanMelchior@gmx.de
:License:
Copyright (C) 2016 Jan Melchior
This program is free software: you can redistribute it an... |
f0b7c00b6d0a69dd12e3b94a76fadd148e72aa4d01c7f413ca4208235d6cc116 | Python | 2,537 | 73 | # -*- coding: utf-8 -*-
"""
Created on Fri Apr 24 12:26:12 2020
@author: gritti
"""
import tqdm
import os
# import sys
# sys.path.append(os.path.join('..'))
from orgseg.GUIs.manualmask import makeManualMask
from orgseg.DatasetTools import io
#########################################################################... |
5cfb0ac6efa94daeb33a2938f5da02a0a909c2b05a15f586c00d4a41cea654e3 | Python | 2,538 | 54 | from django.shortcuts import render
from django.contrib import messages
from django.views.generic.edit import FormView
from django.core.exceptions import ValidationError
from .forms import SceneForm
from .models import Scene
from .brain_render_scenes import build_scene
class IndexView(FormView):
model = Scene
... |
0b1b261724be3c115090b7201c351410efa74a92059eb6818aec4ef51bf0722c | Python | 2,542 | 75 | """Question-answering with sources over an index."""
from typing import Any
from langchain_core.callbacks import (
AsyncCallbackManagerForChainRun,
CallbackManagerForChainRun,
)
from langchain_core.documents import Document
from langchain_core.retrievers import BaseRetriever
from pydantic import Field
from l... |
c2dc07c483d561733efd79823fd2b7369521aae52807acb63c583a30a61b6e72 | Python | 2,543 | 79 | """Document transformers."""
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any
from langchain_core.runnables.config import run_in_executor
if TYPE_CHECKING:
from collections.abc import Sequence
from langchain_core.documents import Document
class ... |
f16661dd02b1f3a2d7c231cfdd15b28e441927eb5eb42bc74ae11bb89c0fcb9e | Python | 2,543 | 95 | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import Optional
import torch
from pdearena.data.utils import PDEDataConfig
# TODO: these need to generalized further
def rollout2d(
model: torch.nn.Module,
normalizer: torch.nn.Module,
initial_u: torch.Tensor,
init... |
61463521baa6a4735c6121b33ec0d7f041be505364e4d7a953a0c697dc24e1f2 | Python | 2,544 | 91 | #! /usr/local/bin/python
#'#################################################################################
#'#################################################################################
#' Train a neural network defined in Keras
#'################################################################################... |
06c69a132def1440199096daf55d1a2db185705107796e65d3bdf15ca5c69b45 | Python | 2,545 | 90 | import anndata
import tensorflow as tf
import pandas as pd
from matplotlib.lines import Line2D
import matplotlib.pyplot as plt
def switch_obsm(adata, obsm_key, X_name='X'):
new = anndata.AnnData(
X=adata.obsm[obsm_key],
obs=adata.obs,
obsm=adata.obsm,
uns=adata.uns)
new.obsm[... |
1425dc0e1ec796163648631cee6f19e9cc5cc9951faff6c39a690778cd34f366 | Python | 2,545 | 72 | import scanpy as sc
import pandas as pd
import numpy as np
def res_search_fixed_clus_leiden(adata, n_clusters, increment=0.01, random_seed=2023):
for res in np.arange(0.2, 2, increment):
sc.tl.leiden(adata, random_state=random_seed, resolution=res)
if len(adata.obs['leiden'].unique()) > n_clusters... |
9b950931fadafb5bfb292dacd78e284a6945589fdf203ab59bb0903c4a695479 | Python | 2,545 | 68 | import sys
sys.path.append("..")
import pandas as pd
import numpy as np
from multiprocessing import Pool
import dgl.backend as F
from dgl.data.utils import save_graphs
from dgllife.utils.io import pmap
from rdkit import Chem
from scipy import sparse as sp
import argparse
from src.data.featurizer import smiles_to_gra... |
6645acaf073ed38e4ff511f7c9fff1460c821e04b0a224e58c84f618fde5ecec | Python | 2,546 | 100 | """
Test cwas.preparation
"""
import pytest
import yaml
from cwas.annotation import Annotation
from cwas.env import Env
import cwas.cli
import sys
class AnnotationMock(Annotation):
"""Mocking the Annotation class"""
def run(self):
pass
@pytest.fixture(scope="module")
def vcf_path(cwas_workspace):
... |
d2e202db032d7bb2e89b8db3438f97ddbead8b8de2172ce39b956712d28b9640 | Python | 2,548 | 69 | import datetime
import os
import shutil
from ruamel import yaml as ryaml
from torch.utils.tensorboard import SummaryWriter
from preprocess.runner import get_preprocess_runner
from submiter.basic_submiter import BasicSubmiter
from utils.loggers import LoggerManager
from utils.utils import mkdir
from utils.utils import... |
6344c4ced42f1af07fc02c5f976426e8cc6206b59b643ccd69edcba1ca579142 | Python | 2,551 | 88 | import re
from typing import Any
from typing_extensions import override
from langchain_classic.evaluation.schema import StringEvaluator
class RegexMatchStringEvaluator(StringEvaluator):
"""Compute a regex match between the prediction and the reference.
Examples:
----------
>>> evaluator = RegexMatc... |
ddb751401af9a6ddd3c325ed6c872552163390eb9fcf41eb193930efc8134812 | Python | 2,552 | 63 | from mmpycorex import create_core_instance, terminate_core_instances
from mmpycorex import Core
from pycromanager.acquisition.acq_eng_py.internal.engine import Engine
from pyjavaz import DEFAULT_BRIDGE_PORT
import atexit
import pymmcore
import types
def start_headless(
mm_app_path: str, config_file: str=None, jav... |
e6d5c29331cab239860458abfbcbd0b61e4fcbf23110dfcc025f1ec8914b0827 | Python | 2,552 | 84 | from LSTM import preprocess, predict, evaluate
from utils import *
from DirStrategy import get_pre_len
import copy
from logger import ResultLogger
model_name = 'cnn-lstm'
logger = ResultLogger()
setting = {
'train_size': 0.8,
'epochs': 100,
'input_size': 60,
'batch_size': 32,
'pre_len'... |
82eee85d2ae6c291eb709ae19045d377de2b3a3c926b6091312c7b49e360f73d | Python | 2,554 | 63 | from torch.optim import SGD, Adam
from model import *
import numpy as np
from config import Scenario
import pickle as pkl
import copy
class Trainer:
def __init__(self, model: Net, cfg: Scenario):
with open(cfg.Paths.data, 'rb') as handle:
data = pkl.load(handle)
self.X = da... |
62b9141d93320fc25557fb7fbe6fccc785171b1b8911e8c353591b1fe3fbf1fd | Python | 2,555 | 62 |
import numpy
import scipy.optimize
__all__ = ['HistogramFit']
class HistogramFit:
def __init__(self, *, order=5):
self._order = max(1, int(order))
@property
def order(self):
return self._order
def exp_func(self, x, mu, sigma, rho):
return rho*numpy.exp(-numpy.power((x-mu)*... |
565b7b4db5401fae593269883d625aaee3078057f050f1cba646d858ab8b4d09 | Python | 2,556 | 80 | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... |
bd3f73dbc4a873b156f0a6a8deec11fc00bafbce16119867cd78d5c2373bc217 | Python | 2,557 | 57 | import sys
import os
import os.path
pos=[]
chrsize={}
coolpath=sys.argv[1]
svpath=sys.argv[2]########location with SV/CNV created by EagelC files###########
outpath=sys.argv[3]
######output folder################3
def get_filenames(file_dir):
L=[]
list = os.listdir(file_dir) #列出文件夹下所有的目录与文件
... |
bf917ed4905784f58de937d11dae5c02c9b8b95096e16562fb6ed1d4304d6228 | Python | 2,558 | 77 | """
This script summarized DE results.
"""
import pandas as pd
import session_info
from pyhere import here
from functools import lru_cache
@lru_cache()
def get_specific_deg():
fn = "../../summary_table/_m/"+\
"differential_expression_schizophrenia_by_sex_4features.sig.txt.gz"
df = pd.read_csv(fn, sep='... |
fadec47eba7394b9bc1695a3ee1d44e3a7b91a5c4e54a12d401ef3f3226a2905 | Python | 2,558 | 72 | import joblib, os, json
def save_model( model_folder, classifier, scaler,
sigmas=[.1,.5,1,2.5,5,7.5,10],
down_shape=-1,
edge_size=5,
fraction=0.1,
bias=-1,
feature_mode='ilastik',
deep=False ):
'''
s... |
6d8408e5a711acd0a5093fa406267ea058d680fbdd8f8c9f044fbfc79372d2bc | Python | 2,562 | 67 | import pandas as pd
import numpy as np
from copy import copy
def quantile_normalization(assay):
# sort values according to abbundance
sorted_values = pd.DataFrame(np.sort(assay.values, axis=0))
# average of protein intesities
sorted_mean = sorted_values.mean(axis=1)
# create a dictionary... |
a40ee6136a5588a5417846cd51fa8dcdc53338a659edcda685df1b14076aa56c | Python | 2,562 | 83 | import torch
import torch_scatter
def mae(pred, target, mask):
"""
pred: T, N, 9, 2 already masked
target: T, N, 9, 2
"""
err = pred - target
return torch.mean(err.abs()) * mask.numel() / mask.sum()
# atom-wise
def l2mae(pred, target, mask=None):
"""
pred: T, N, 9, 2 already masked
... |
c39d0d64ff5e1f1eb5fc5aac01c102f536f480a048a5624ca3f7d6987a690ec0 | Python | 2,564 | 46 | """Empirical Assumption-2 check on corpus A (mirrors the corpus-B check in run_corpus_b.py and the field check in run_field_p5.py).
For each held-out dataset k* and seed: fit the deployed boosted estimator on all source datasets and take the 90th percentile of its
absolute residuals on k*; for each source s, fit on th... |
458becf90736694ecef72110d4b6dfa33117c45a1db0d7b3f496631ffa8b46af | Python | 2,565 | 84 | """ Run Zilany et al. (2014) model.
This module contains functions for running the Zilany et al. (2014) model for a given pressure wave and characteristic
frequency to get the auditory nerve (AN) firing rates.
The pressure wave is read in as a .npy file, and the AN firing rates are saved as a .npy file.
This needs to... |
120465a4be6ddae7f2da8d6fe5c6cbe170034897b6f7c112a53de2d6f89c213b | Python | 2,566 | 112 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 14 13:54:31 2022
@author: pierre
"""
## Libraries
import sys
import os
import numpy as np
from scipy import signal
from skimage.measure import label, regionprops
import brydson_sampling
import matplotlib.pyplot as plt
import imageio
plt.ion()
## ... |
be6055e8cfdf95a11307e91735835e2b0a10feb65843344d2abc592dfc22ff3a | Python | 2,569 | 78 | from importlib.metadata import version
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup -------------------------------... |
13652602ac2bfe8c331464486980269a1482ad2ab4dc4269ec1cff12880a72b3 | Python | 2,570 | 78 | #! /usr/local/bin/python
#'#################################################################################
#'#################################################################################
#' Run random search on tcga data
#'#################################################################################
#'######... |
372b248125fe5962d4fb800ee783fe77259c0a3e28f8c0bf546e7ad7a6dc6f48 | Python | 2,570 | 69 | """
This script extracts the tissue-specific features.
"""
import numpy as np
import pandas as pd
import session_info
from functools import lru_cache
@lru_cache()
def load_sig():
fn = "../../_m/differential_expression_analysis_4features_sex.txt.gz"
return pd.read_csv(fn, sep='\t')
@lru_cache()
def get_tissue... |
b8cb297acee74869e8522e252404670302cd589c89f8a2ef59285a9d7a9f4392 | Python | 2,570 | 88 | import numpy as np
import pkg_resources
filename = pkg_resources.resource_filename('data', 'initial_values/initial_values.npz')
data = np.load(filename)
T = 309.14 #[K]
# initial membrane potentials [mV]
phi_msn0 = data['phi_msn'] * 1e3
phi_msg0 = data['phi_msg'] * 1e3
phi_mdn0 = data['phi_mdn'] * 1e3
phi_mdg0 = dat... |
9944667a61080c04f10c57fa948acf0995637e59e4c17df7c325671cc07f0f19 | Python | 2,571 | 69 | from mimic3models.metrics import print_metrics_regression
import sklearn.utils as sk_utils
import numpy as np
import pandas as pd
import argparse
import json
import os
def main():
parser = argparse.ArgumentParser()
parser.add_argument('prediction', type=str)
parser.add_argument('--test_listfile', type=str... |
65be3b241b6c98551a246786d7fce1b1e38f10371b579abe4b173a9597c0d750 | Python | 2,574 | 94 | import pandas as pd
import numpy as np
from cgatReport.Tracker import SingleTableTrackerRows
from cgatReport.Tracker import SingleTableTrackerHistogram
from cgatReport.Tracker import *
from cgatReport.Utils import PARAMS as P
from IsoformReport import *
class imagesTracker(TrackerImages):
'''Convience Tracker ... |
4ce6418558549e78e45d14708278ac586618b4fe2bc3ed5ffe2c960d8aea8ef6 | Python | 2,575 | 56 | from config_FaceName import group_name,Ids,RSA_data_path
import mne
import os.path as op
from custom_functions import prepare_X_and_one_data,prepare_stats_list,print_sig_stats
from scipy import stats as stats
import numpy as np
from mne.stats import permutation_cluster_1samp_test
import matplotlib.pyplot as plt
Ids.re... |
da144acaa641e6ca5ea279ee9f194c73a406969f7b9dd233c2f593c3b9b4a95f | Python | 2,577 | 70 | import torch
import torch.nn as nn
class PolicyGRU(nn.Module):
"""A single-layer GRU policy network with a sigmoid-activated linear readout.
Args:
input_dim: `Integer`, dimensionality of the input observation vector.
hidden_dim: `Integer`, number of hidden units in the GRU layer.
output_dim: `Integer... |
040f90bda307dd875785f2fdb7065814a7717d6b583ac64ba005d83f15254fb2 | Python | 2,580 | 48 | import mne
import numpy as np
import pandas as pd
import os.path as op
from config_FaceName import MEG_data_path,group_name,Ids,bids_root,conditions_encode,conditions_recall,eq_conditions_encode,eq_conditions_recall
from mne.preprocessing import read_ica
from mne.time_frequency import tfr_morlet
from mne_bids import BI... |
a1ab0aa915975c6d71a7c99eeecd869c60ace13dc41131265d45a75033aa6597 | Python | 2,581 | 68 | # This file is a part of the `allegro` package. Please see LICENSE and README at the root for information on using it.
import torch
from e3nn.util.jit import compile_mode
@compile_mode("script")
class MakeWeightedChannels(torch.nn.Module):
weight_numel: int
multiplicity_out: int
weight_individual_irreps:... |
334b9a52afa8cb50421e70db2b1c169b7589d2a3ce0fd38b40e2aa4af964958b | Python | 2,582 | 81 | # Copyright Generate Biomedicines, Inc.
#
# 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 ... |
15aa35720bd0a226cf2d5b088a6bbefd1ab7988224340ae276b52a5b8db0b8fb | Python | 2,583 | 74 | ####################################################################################
#
# 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... |
128c96eda939c28ffafc0cd41d6207abfc2d084a796efa98887b595607def7a0 | Python | 2,584 | 90 | """
define losses
"""
from typing import Optional, Callable, List, Dict, Union, Tuple
from modulus.loss import Loss
from torch import Tensor
class PointwiseMinimiseLoss(Loss):
"""
L-p loss function for pointwise data
Computes the p-th order loss of each output tensor
Parameters
------... |
c2546de0670d17127a6ca8ff051fdf244ab95d1196c3dad454fcbfa2d94c1e3b | Python | 2,584 | 74 | ####################################################################################
#
# 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... |
ca43af780c89d14cee0af8fe0bf671b524f1fce07e64976c1b2f7406ad14e2e1 | Python | 2,586 | 77 | ####################################################################################
#
# 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... |
fd469535b8c98b6a15e27274cf699c1c71bd345dd145de51fdb49bf41d61e8c1 | Python | 2,587 | 98 | # -*- coding: utf-8 -*-
"""Perses: Tools for expanded-ensemble simulations with OpenMM
"""
from __future__ import absolute_import, print_function
DOCLINES = __doc__.split("\n")
import os
import sys
from os.path import join as pjoin
from os.path import relpath
from setuptools import setup
import versioneer
try:
... |
176b3347a854a133d11cedc257927f4c24668913a1d34a3aee42bf058e1b0da2 | Python | 2,588 | 89 | from get_neurotransmitter import get_neurotransmitter, init_model
from synister.utils import get_array
import argparse
import numpy as np
import zarr
import time
parser = argparse.ArgumentParser()
parser.add_argument(
'--location', '-l',
type=int,
nargs='+',
help="Center location in nm")
parser.add_arg... |
53a00672fa24a19e4cd258342d0b426d356e7d35d70dfaa71a49f2794655cb7a | Python | 2,590 | 88 | """Example program to demonstrate how to read a multi-channel time-series
from LSL in a chunk-by-chunk manner (which is more efficient)."""
import argparse
import random
import time
import numpy as np
import pylsl
def receive_and_predict(
inlet_stream, marker_outlet_stream, window_size, predict_interval
):
... |
2532c580eaf3a66a81f399985d0ab9cc361a9434c9d8501c1aa8a134df6f7db2 | Python | 2,591 | 77 | import json
import pickle
import numpy as np
import torch
from dopp import FeedForwardCell, FeedForwardCurrentCell
from sim import sim # noqa: F402
if __name__ == "__main__":
with open("fig7_params.json", "r") as f:
params = json.load(f)
torch.manual_seed(params["seed"])
np.random.seed(params[... |
9d25c3647e495baebbf463c27dbe792f2a8567e50014b55751964323770a77f4 | Python | 2,593 | 70 | import logging
import os
import socket
import sys
import pandas as pd
from configs.configs import get_config_dict
from helpers.evaluation import leave_every_other_out_split, get_tvfc_estimates
from helpers.rockland import get_rockland_subjects, load_rockland_data
if __name__ == "__main__":
pp_pipeline = 'custo... |
a8920f8ac530786f39bcf35167ad802216a1a2e84d7468051366cd5427555d41 | Python | 2,593 | 120 | from scipy.spatial import distance_matrix
from scipy.special import digamma
from scipy.spatial import distance
import memory_profiler
from scipy.interpolate import pchip_interpolate
from functools import partial
from p_tqdm import p_map
from scipy.stats import skew
import random
import pickle
import os
from tqdm import... |
d43dbf8db671f95e48fcae86f8b7148e97ba71c1d54cf6534ba3037b5de171fd | Python | 2,593 | 97 | import os
import json
import numpy as np
from glob import glob
import pickle
from src import constants
def make_dir(path):
# Create directory if it doesn't exist
os.makedirs(path, exist_ok=True)
def make_dir_for_file(path):
# Create directory for file if it doesn't exist
make_dir(os.path.dirname(path... |
b7a3f6b63c2f930b8977f93f5683c100b092e3777390c5f95bd101c17028fa94 | Python | 2,595 | 65 | import pandas as pd
import numpy as np
import argparse
def get_data(path, reference_path, label_path, save_path):
feature_data = pd.read_csv(reference_path+'/gene_mRNA_cfRNA.txt', header=None)
feature_data = list(feature_data[0])
label = pd.read_csv(label_path, sep='\t')
sample = list(label['sample_id... |
50690b29f118c1fa1172ef47cf306ecab5bf5ad00a94f8899a6ab0feb28f001b | Python | 2,596 | 72 | from django import forms
from django.forms import ModelForm
from django.core.exceptions import ValidationError
from .models import Map
class MappingForm(ModelForm):
probe_type = forms.CharField(
max_length=30,
widget=forms.Select(choices=Map.PROBE_TYPES),
required=True,
)
probe_nu... |
97f811964b378918d6f745e3fe937fbe630864cc6f26995ba9ba17d5250bfc1f | Python | 2,596 | 80 | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup --------------------------------------------------------------
# If extensions (or module... |
336ab78aa33490ccc7884b4fe45e611b26fa5ea827c95542decf4a0940916a7a | Python | 2,597 | 78 | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
class GCN(nn.Module):
def __init__(self, nfeat, nhid, dropout=0.5, isBias=False):
super().__init__()
self.weight = nn.Parameter(torch.empty(nfeat, nhid))
nn.init.xavier_uniform_(self.weight)
if is... |
3eb1f84c7f47587459e636baa9d13bf7f4b7e3f33056a1aaf49d29983ea247a1 | Python | 2,599 | 76 | import numpy as np
import torch
from src.domain_assignment.sparse_lowrank import greedy_V
class BaseAssigner:
def __call__(self, y_pred, uncertainty=False):
assert y_pred.ndim == 2
if torch.is_tensor(y_pred):
y_pred = y_pred.detach().cpu().numpy()
return self.assign_domains(y_... |
51ea8c07f84c0c8f389c6b08952bbb9611e6bed9412708b79eae481d2fb010e0 | Python | 2,599 | 67 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 7 19:03:00 2024
@author: Shencong Ni
"""
'''
Combine the SUA data from each network realization obtained by 'extractDataforRRRforEachNet.py'
The Combined data will be used in reduced rank regression (RRR) analysis
Run 'onoff_detection.py' and 'extractDataforRRRforEachNe... |
c868656176e8a8247414b4dba851997b2e48dcd96e1320aecd60aca98ccf99a4 | Python | 2,599 | 90 | # coding=utf-8
from audioop import minmax
from torchvision import transforms
from PIL import Image, ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
import torchio as tio
import torch
import monai
def image_train(dataset, resize_size=256, crop_size=224, augmentation=False):
if dataset == 'dg5':
return tra... |
49297e1df5e62ebe0e676a9a27bed2ecd8fc8e1e6c4a727002cfc2d0dcdf1f6d | Python | 2,600 | 70 | """
This script reads the versions of pycromanager and its dependencies from the pom file
and makes updates to the micro-manager ivy.xml file
It runs upon changes to the java/pom.xml file of the main branch
"""
import xml.etree.ElementTree as ET
from lxml import etree
from semantic_version import Version
from pathlib... |
5d7525859c2acc9c29fbc229071c0b4180d0728d179840b8aa6dfa0bbabbff7a | Python | 2,600 | 87 | """Helper functions for managing the LangChain API.
This module is only relevant for LangChain developers, not for users.
!!! warning
This module and its submodules are for internal use only. Do not use them in your
own code. We may change the API at any time with no warning.
"""
from typing import TYPE_CHE... |
59dd6a9daac545dc3dd35ab51ed6d017c05e2197cb9242de8bb19f1b6378fda6 | Python | 2,601 | 80 | """Generation output schema."""
from __future__ import annotations
from typing import Any, Literal
from langchain_core.load import Serializable
from langchain_core.utils._merge import merge_dicts
class Generation(Serializable):
"""A single text generation output.
Generation represents the response from an... |
7dbb78bd197bc2ef5be861b0b805112638231fa3be1fb052bb91d89fb8000708 | Python | 2,602 | 71 | #!/usr/bin/env python3
"""
Build a small genome subset + matching metadata file for fast local testing
of the annotate/enrichment/classify pixi tasks.
Truncates each 's__Faecalibacterium ...' group in data/groups.tsv down to
its first N genomes (sorted by genome id, for determinism) and keeps every
genome in all other... |
1cb2ab7c80c094aa7b1e02b8cb90594073d5537cd9fc13ee2c414c172a5ca972 | Python | 2,603 | 88 | from abc import ABC, abstractmethod
import torch
class AbstractReward(ABC):
# language=rst
"""
Abstract base class for reward computation.
"""
@abstractmethod
def compute(self, **kwargs) -> None:
# language=rst
"""
Computes/modifies reward.
"""
@abstractm... |
b08f582b171e8169d8cc19d3652a7862fc4fa877b46b8ca32588d97716b2c6d1 | Python | 2,603 | 83 | """Utilities for splitting atlases. Copied from atlas-spliter to avoid a big install with dependencies."""
import itertools as it
from typing import Any, Dict, Iterator
from voxcell import RegionMap
HierarchyDict = Dict[str, Any]
class AtlasSplitterError(Exception):
"""
Exception raised by functions of atl... |
357ab802f19353893f5876aef0803532d9b674e5eb546631cb429aca3f473228 | Python | 2,604 | 73 | """
Test storage layer.
TODO:
* Write tests
"""
__author__ = 'John D. Chodera'
################################################################################
# IMPORTS
################################################################################
import os
import os.path
import tempfile
from perses.analysis.an... |
b76e10e56f5cddb381139fd0f5995aa61a10d34d5440cf617e618567a1f9fa3e | Python | 2,604 | 77 | ####################################################################################
#
# 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... |
c1c55786886502388d81fd816d92478587f436853bda035d6f51b90bda9cd9ac | Python | 2,604 | 93 | import argparse
import mne
import pylsl
import time
# fmt: off
default_ch_names = [
"Fp1", "Fp2",
"F7", "F3", "Fz", "F4", "F8",
"FT9", "FC5", "FC1", "FC2", "FC6", "FT10",
"T7", "C3", "Cz", "C4", "T8",
"CP5", "CP1", "CP2", "CP6",
"P7", "P3", "Pz", "P4", "P8",
"PO9", "O1", "Oz", "O2", "PO10"... |
e9ccf95031d3c6efc98ba585b3c283749d3b3c759f6f99dbbf5e534153f45f38 | Python | 2,604 | 69 | from dival import TaskTable
from dival.measure import PSNR, SSIM
from dliplib.utils import Params
from dliplib.utils.data.datasets import CachedDataset
from dliplib.utils.helper import select_hyper_best_parameters, load_standard_dataset
from dliplib.utils.reports import save_results_table
from dliplib.utils.weights im... |
784ea5ec2420b1ab56c69cc144eb2aa15c88089736908fcf51bc517c5f80f4fe | Python | 2,605 | 79 | # If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
from importlib.metadata import version
# Configuration fil... |
8e21f68e79a37de8d95fb3ae73360893c97d955595f66eb9182e7de37b8e47be | Python | 2,605 | 68 | import sys
import os
import os.path
d={}
#################33This script is for calling all genes associated with neoloops
rootdir='/home/uni08/txie/analysis/GSC/analysis/SV'#####The path of SVs files for all samples
extend=int(sys.argv[1])##########the distance flanking loop anchor to be consider
kin... |
11cb9d33b3566822b66df5667abe5ddb104d8294a26432ce8c397ff12d930d55 | Python | 2,606 | 81 | import jax
import jax.numpy as jnp
import jax.random as jrng
import flax.linen as nn
from typing import Optional, Any, Sequence
from projectlib.models.layerwise import LayerwiseModule
from projectlib.models.reservoir import reservoir_uniform_init
from projectlib.utils import flatten
Dtype = Any # this could be a rea... |
a6719093165a7e070b7450dc0e0ba9f88b137efb233701b244278eb73881fbff | Python | 2,606 | 80 | from shapely.geometry.point import Point
from shapely import affinity
from matplotlib.patches import Ellipse
import numpy as np
import matplotlib.transforms as matplotlib_transforms
def create_ellipse(center, lengths, angle=0):
"""
create a shapely ellipse. adapted from
https://gis.stackexchange.com/a/2434... |
a1a3381ec6a2fa4ba3dbf4b03181e4fcc2bdab27bf3cd27aebbae15b6373e94b | Python | 2,607 | 77 | ####################################################################################
#
# 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... |
f96a88f4fe3c8c51362a864835453638ec664404d95245458f3aaf11a1c7ad4c | Python | 2,607 | 90 | from math import isclose
from pathlib import Path
import pytest
import torch
import chroma
from chroma.data.protein import Protein
from chroma.layers.structure import conditioners
from chroma.models.chroma import Chroma
BB_MODEL_PATH = "https://chroma-weights.generatebiomedicines.com/downloads?weights=chroma_backbon... |
91717b49d7449a659c0b0e0e30b6e6d400045e4d92920ab0002d463e7fd2958f | Python | 2,608 | 82 | """**OutputParser** classes parse the output of an LLM call."""
from typing import TYPE_CHECKING, Any
from langchain_core.output_parsers import (
CommaSeparatedListOutputParser,
ListOutputParser,
MarkdownListOutputParser,
NumberedListOutputParser,
PydanticOutputParser,
XMLOutputParser,
)
from ... |
cc4ebc8dcd8200b331179be5026656a8f94420195818f505ecfc9824f4748e4f | Python | 2,608 | 65 | import os
import sys
import re
import types
import itertools
import matplotlib.pyplot as plt
import numpy
import numpy.ma
import Stats
import Histogram
import cpgReport
from cgatReport.Tracker import *
from cgatReport.odict import OrderedDict as odict
##################################################################... |
dd4723ea0d07e328f1f1bfe26ebdf7b12008a2ae59ab497c38305a8eb1269306 | Python | 2,608 | 98 | """
scaden Main functionality
Contains code to
- process a training datasets
- train a model
- perform predictions
"""
# Imports
import logging
from scaden.model.architectures import architectures
from scaden.model.scaden import Scaden
logger = logging.getLogger(__name__)
"""
PARAMETERS
"""
# ====================... |
650e34adc71a98f80cb2aa407530bc662b847dc2e1f1847cfbefb6cdff8cb9b1 | Python | 2,610 | 103 | #!/usr/bin/python3
#Python library to interface with the chip LS7366R for the Raspberry Pi
#Written by Federico Bolanos
#Last Edit: March 4th 2014
import spidev
from time import sleep
#Usage: import classReadEncoder then create an object by calling obj.Encoder(CSX, CLK, BTMD)
#e.g. lever.Encoder(0, 1000000, 4)
cla... |
9ee416a8a6ff8eea50c694d9e9a171d12e6cf65fa117eeff14443d31596a7a4c | Python | 2,611 | 89 | """Shared model-building components."""
from typing import Optional
import numpy as np
import torch
import random
from torch import nn
def get_id_train_val_test(
total_size=1000,
split_seed=123,
train_ratio=None,
val_ratio=0.1,
test_ratio=0.1,
n_train=None,
n_test=None,
n_val=None,
... |
301671bd50c47c930b0ba8f86e27af77496049e61dab2efe5642992d9e5cee11 | Python | 2,614 | 89 |
import sys
sys.path.append('../classes')
import class_model
import class_stimuli
import numpy as np
import pickle
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
### MAIN SCRIPT
stimulus_tasks = ['varyposition', 'varysize', 'varyrotation']
stimulus_folder = '../stimuli/simple_seqs/'
save... |
59db0bd2f8a8d6a62130ecb3a01d31c7ff25d4e40e081c99f53885a513a22c58 | Python | 2,615 | 74 | ####################################################################################
#
# 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... |
821c04aa3f351f6a51894e4f630314c51df5bb79bdfb01320df2cddc51f2d53f | Python | 2,616 | 63 | import numpy as np
from sklearn.metrics import accuracy_score, f1_score, recall_score, balanced_accuracy_score, precision_recall_fscore_support
from skimage.io import imread
import os
from natsort import natsorted
folder = "/home/cazorla/Images/Panuke/Part 1/train_test_100"
pred_folder = os.path.join(folder, "Predict... |
36b38c0b75befc2d63d7dc26488754f9e9f65ff2a1877f61ba1ba19222b14964 | Python | 2,617 | 87 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 5 18:31:53 2021
@author: shni2598
"""
import numpy as np
#from brian2.only import *
import matplotlib.pyplot as plt
from connection import coordination
#%%
def get_adaptation(base_amp = 16, max_decrease = [13,13], sig=[7,7], position=[[0, 0],[-32... |
ffcbdfe8f49de0912e2562bd91c47fc627a4b1c9a77da05636195d37fa96a7ef | Python | 2,619 | 73 | # 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... |
471ea49ce87a39620cc698ef882603d07bc5c5de8063bfe40a36e3a1ee432165 | Python | 2,621 | 69 | import torch
from torch_scatter import scatter_add
from torch_geometric.nn.inits import reset
from torch.nn.functional import hardsigmoid
class LocalAttentionPooling(torch.nn.Module):
r"""Global soft attention layer from the `"Gated Graph Sequence Neural
Networks" <https://arxiv.org/abs/1511.05493>`_ paper
... |
6ae3e9fab1821c10ac383247a7f9fafe7d95cf8199f9aa3d9c5685934631a094 | Python | 2,624 | 76 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# pylint: skip-file
import sklearn.linear_model
import scipy.io
import matplotlib.pyplot as plt
import numpy as np
import torch
from embanded.embanded_torch import EMBanded
# Load data from the 'example02.mat' file
data = scipy.io.loadmat('example02.mat')
device = torch... |
9bdc24bfef7a1b87f401d00a8424e241937b21d39d6baf0603d6a458d2c03daf | Python | 2,624 | 70 | """
Naive LDA/Cox baseline (fit LDA first and then fit Cox; the models are not
jointly learned).
Authors: Lexie Li, George H. Chen
"""
import numpy as np
import pickle
import time
from sklearn.decomposition import LatentDirichletAllocation
import glmnet_python
from glmnet import glmnet
from glmnetCoef import glmnetCo... |
2b1c14e887fa3469738613671137e059a71399bbe8799d1ae6398636cbcddbba | Python | 2,625 | 77 | ####################################################################################
#
# 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... |
0da3f5f92e574f403a4b73ee564572b0231ec81ead69feb1225d42999998637f | Python | 2,626 | 72 | import tensorflow as tf
from dipgnn.utils.register import registers
from dipgnn.trainers.base_trainer import BaseTrainer
@registers.task.register("base_classification_trainer")
class BaseClassificationTrainer(BaseTrainer):
"""
Note: A significant portion of the code is adapted from dimenet (https://gi... |
4dad1ca07eca9e48c335852bdce36b936140e661a7ea2b79203415a920100f43 | Python | 2,628 | 68 | import random
import numpy as np
import torch
from . import dataset_register
from .omics import NewSmilesOmicsDataset
from .utils.auto_img_transformations import AutoImgTransformationManager as ATF
@dataset_register
class MILSmilesOmicsDataset(NewSmilesOmicsDataset):
def __init__(self, *args, **kwargs):
... |
29d8cf11ea279513d92011bd353856eb653812d336864fecf8b454ec70fe0fa7 | Python | 2,629 | 75 | import torch
import os
import matplotlib.pyplot as plt
import src.data as data
from src.main import time_step_blow_up
import numpy as np
import pandas as pd
import shap
import seaborn as sns
os.environ['KMP_DUPLICATE_LIB_OK'] = 'True'
name = "4_98"
baseline = "xgb"
model = torch.load(os.path.join("../model", f"model_... |
82e30ed9260fd847bc286a937bc7608ea670aabeea64a499dfebf55827c70457 | Python | 2,629 | 73 | #### This script compares GENCODE version 25 with version 41.
import session_info
import polars as pl
import seaborn as sns
from pyhere import here
import matplotlib.pyplot as plt
from scipy.stats import spearmanr
def load_annotation(fn, region):
return pl.read_csv(fn, separator="\t")\
.filter((pl.co... |
aa48e3170d86ecbab13cc6d69f93ebd94714e4ddcf3b199df0abc6ecce60b7df | Python | 2,629 | 96 | """Test yamlOutputParser."""
from enum import Enum
import pytest
from langchain_core.exceptions import OutputParserException
from pydantic import BaseModel, Field
from langchain_classic.output_parsers.yaml import YamlOutputParser
class Actions(Enum):
SEARCH = "Search"
CREATE = "Create"
UPDATE = "Update... |
76fe6c54cddcc38750a3c108be5250678362531e1aaf7f3719c80bdb3595d93f | Python | 2,630 | 76 | """Test functionality related to length based selector."""
from typing import Any
import pytest
from langchain_core.example_selectors import (
LengthBasedExampleSelector,
)
from langchain_core.prompts import PromptTemplate
EXAMPLES = [
{"question": "Question: who are you?\nAnswer: foo"},
{"question": "Q... |
db7e83e7cd262a2f6afd9fd29259de352d460762995bc21c4950e175746f241f | Python | 2,631 | 73 | """
Parse STITCH's drug target dataset
"""
import pathlib
import numpy as np
import pandas as pd
class ParseSTITCH:
"""
"""
def __init__(self, root=None , debug=False):
self.debug = debug
f_dict = {'chemical_link': '9606.protein_chemical.links.v5.0.tsv.gz',
'acti... |
058b966ed8345b4d92228d66294f300b42a755a4be2f23e95b981cb2f52e3432 | Python | 2,632 | 102 | import argparse
import glob
import re
from collections import defaultdict
from pathlib import Path
import pandas as pd
def visualize(glob_path: str):
"""
List the items in the folder that match the given glob path.
Parameters:
glob_path (str): The glob path to search for files and folders.
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.