sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
a1d99ad177d36094d411b2ee076d225d0f4535050bc9b52bd71e3048eadaf2b3 | Python | 5,112 | 147 | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Union
import torch
import torch.nn as nn
import esm
from esm.modules import ContactPredictionHead, ESM1bLayerNorm, Roberta... |
798ab382074b61ff7f76cf396ce46c1601b3400fcb31cd30251df4e3a22ce42c | Python | 5,113 | 184 | # -*- coding: utf-8 -*-
from fury.utils import numpy_to_vtk_image_data
import vtk
def get_color_by_name(color_name):
"""
Get a vtkColor by name. See :
https://vtk.org/doc/nightly/html/classvtkNamedColors.html
Some color names can be found in the CSS3 specification :
https://www.w3.org/TR... |
a96fd8977d158dd54ca31270e52a6bf48d790850e86d51101c0a4a4e73924075 | Python | 5,113 | 131 | """Find the suite2p recordings in a data folder — or behind a share link.
The scan asks one question of every top-level folder: does it hold a
``suite2p/plane0/stat.npy``? Locally that is a stat call; over a share link it
is one folder listing, which returns names *and* sizes without transferring
anything. So the same... |
debfed39c3592b58d20f5e73822952f794f6da9559d60a207dea670e01176c6a | Python | 5,114 | 126 | """MACE foundation models parameters for ChemGraph
Reference: https://github.com/ACEsuit/mace/blob/main/mace/calculators/foundations_models.py"""
import os
from pathlib import Path
from typing import Optional, Union
from pydantic import BaseModel, Field
import torch
class MaceCalc(BaseModel):
"""MACE (Message-pa... |
6c402108ebda6097314893fef4c470f7a1ca812d4c713277ab3e7da83b0e91ff | Python | 5,115 | 107 | import argparse
import pandas as pd
import glob2
import matplotlib.pyplot as plt
from matplotlib_venn import venn2, venn3, venn3_circles, venn2_circles
import os
import numpy as np
import seaborn as sns
if __name__ == "__main__":
file_paths = glob2.glob(os.path.join('results', 'results_05-09-23', '05-0... |
6351e7ed9958db723a8a4b8087daf36b2e0e4c642c6e636e48e7f0579fe46497 | Python | 5,116 | 162 | #!/usr/bin/env python
# ENCODE DCC BAM 2 TAGALIGN wrapper
# Author: Jin Lee (leepc12@gmail.com)
import sys
import os
import argparse
from encode_lib_common import (
assert_file_not_empty, log, ls_l, mkdir_p, rm_f, run_shell_cmd,
strip_ext_bam, strip_ext_ta)
from encode_lib_genomic import (
samtools_name_s... |
eb3db31dd7b2b236865482d6d14ecdfe2a644886121d4c807aa32bf6b7e0ffd3 | Python | 5,116 | 92 | """Register each run to one reference run.
NOTE: Please read the top comments on "05_motion_correction_nonlinear.py"
carefully. Because, if you decide to not use the nonlinear step, then you need
to omit the warp inputs and the related line of greedy.
NOTE2: My current view is that the nonlinear step might not be nec... |
3de6e166860c0beebb670efcc1efba3240ae58d62a3025499bc35ccda55e1e36 | Python | 5,118 | 251 |
# coding: utf-8
# In[1]:
import os,sys
os.chdir('/home/caofan/prediction/from_dnase/')
# In[2]:
sys.path.append('/home/caofan/repos/chinn/')
# In[3]:
import h5py
import numpy as np
from sklearn.metrics import average_precision_score, f1_score, precision_score, recall_score
from sklearn.externals import jobl... |
d4c483149bca4d6016957684264df82de7c4b580405d49722a5b626f17bfe66b | Python | 5,118 | 131 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Script to filter streamlines based on their distance traveled in a specific
dimension (x, y, or z).
Useful to help differentiate bundles.
Examples: In a brain aligned with x coordinates in left - right axis and y
coordinates in anterior-posterior axis, a streamline f... |
f1832c13b71f6346db042081c1f4b8a8c643eb23c27127055cd7f6db10999e01 | Python | 5,118 | 159 | #@SNTService snt # scijava parameter
snt.requireVersion("5.0.14") # SNT version required to run this script
"""
This script 'plays' a walkthrough through selected paths in SNT, centering and zooming
on each path node sequentially. The playback can be aborted by clicking on the image.
File: Path_Player.py
Documentatio... |
8e1c4b2e080721b70d741077acfc6aca89c1ca0cacc7d862c7f02400b91bb54d | Python | 5,120 | 132 | #!/usr/bin/env python3
"""Find the suite2p/derived .npy that a run choked on.
Written for the failure that says only::
EOFError: No data left in file
which is numpy's wording for a **zero-byte** ``.npy`` and names neither the
file nor the recording. This walks a data folder (and, if given, the cache and
derived ... |
ac1374a95c4a1a1a057f0894cccd7cad2afc973c593d033ae72f60df0a9fce54 | Python | 5,120 | 150 | #!/usr/bin/env python
import os
import sys
import re
import numpy as np
import torch
from utils import CNN
from rwp_uncertainty_config import get_material_config, list_materials
def load_model(config, device):
param_info = config['param_info']
n_params = config['n_params']
model = CNN(output_dim=n_param... |
d276c997b947cec815faddf0b6cd84ee08c8685fac734519d29f99d449bf88db | Python | 5,120 | 177 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap
import os
def load_rdm_from_csv(csv_path, name):
"""
从CSV文件加载RDM矩阵
Parameters:
csv_path: str, CSV文件路径
name: str, RDM名称
Returns:
rdm: numpy array, RDM矩阵
... |
23c1a8b02f91c7e72febd90094b210d5de2ca567aecd78683a8ff5545ee5cfa2 | Python | 5,121 | 153 | # %% ### import modules
from pathlib import Path
import seaborn as sns
import pandas as pd
import bap1b.figures as figures
# %% ### set paths
data_dir = Path(__file__).resolve().parents[1] / "data"
results_dir = Path(__file__).resolve().parents[1] / "results"
# %% ### load data
df = pd.read_excel(data_dir / "cs_base... |
3ab99736ae476c06659c7a5d9fa1ab66508182db8ff155947aa0263831bf5290 | Python | 5,121 | 169 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors: Henrik Zunker
#
# Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Lice... |
5f433ec752dec5c74e07eb489eb43ac9d805476ea017d2991c41c84499c2451f | Python | 5,121 | 127 | import argparse
import torch
import os
import numpy as np
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
import cv2
import time
from UBSIM.Unrolled_Blind_SIM import Unrolled_Blind_SIM
from UBSIM.train_model import train_model
from UBSIM.airy_disk import airy_disk
# load in images to numpy ar... |
f7bbe5b432c5a1b8745539b0ed3fdf33189ae2e1be85af734d6cd6a9493115e5 | Python | 5,121 | 123 | from brainscore_core.supported_data_standards.brainio.assemblies import PropertyAssembly
from brainscore_vision import data_registry, stimulus_set_registry, load_stimulus_set
from brainscore_core.supported_data_standards.brainio.s3 import load_stimulus_set_from_s3, load_assembly_from_s3
BIBTEX = """@article{dapello20... |
ef4fcffb5f0ea850a745d776cd72b7a9ee043ea4d31c75cfbda39f9a365e3380 | Python | 5,122 | 180 | """
Copyright 1999 Illinois Institute of Technology
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publis... |
dc0a114ba95dd45c4817e42a9836942ec581eb991f1eefc9ce83a0ead58bb176 | Python | 5,123 | 117 | import torch
import dgl
def cdr_to_tensor(cdr):
return torch.tensor([int(x) for x in cdr], dtype=torch.int32)
def find_cdr_node_ids(all_res_ids, chain_node_index, cdr_res_ids):
"""
Find node indices of residues in CDR regions
input:
all_res_ids: get from g.ndata['resid']
chain_node_ind... |
39917974e5b1c6a8eaf05cdf08070cc02b4e08bd736f81c85005a31b8886538a | Python | 5,125 | 136 | from ase.cluster import Decahedron, Icosahedron, Octahedron, wulff_construction
from ase import Atoms
from ase.io import Trajectory
import pandas as pd
from ase.build import bulk
from ase.constraints import ExpCellFilter, StrainFilter
from ase.optimize import LBFGS
import numpy as np
import pfp_api_client
from pfp_api... |
ec62395cd191edb70cb0cecbb24d15b0d8fe06db39df065f2c8c856025ec1e00 | Python | 5,126 | 159 | import argparse
import os
import os.path as osp
import time
import numpy as np
import torch
import torch.nn.functional as F
import pandas as pd
import json
from torch_geometric.nn import ChebConv, GCNConv, Linear
from tqdm import tqdm
from sklearn.metrics import roc_auc_score, accuracy_score, recall_score, f1_score, pr... |
38370e9bedc2e26d69877f6bb932affb38d7bb838f51c7223f2f01be97c9f5a2 | Python | 5,127 | 102 | #encoding=utf-8
import sys
sys.path.append("../")
import jieba
jieba.enable_paddle()
def cuttest(test_sent):
result = jieba.cut(test_sent, use_paddle=True)
print(" / ".join(result))
if __name__ == "__main__":
cuttest("这是一个伸手不见五指的黑夜。我叫孙悟空,我爱北京,我爱Python和C++。")
cuttest("我不喜欢日本和服。")
cuttest("雷猴回归人间。"... |
6afa0a37614ece74ca5606874d41c849e10b2ebc6e468501b6d1ebac9363455b | Python | 5,127 | 150 | from __future__ import print_function
import argparse
import math
import os.path
import sys
def parse_args():
parser = argparse.ArgumentParser(
description='summarize the rMATS results from the output files')
parser.add_argument('output_dir',
help='path to the directory contai... |
32f50b32440c2e12d5b2a0dcb5f0116104494d643f09774b5d9b53f56533d507 | Python | 5,130 | 117 | ##########################################################################################
### Functions to calculate the quality coefficient Q from the firing rate distribution ###
### during recall of an input-defined cell assembly ###
###############################################... |
c06387a7bf089cc02ad7b9c0cb99057a9b5b728111dd9b2569fb097b30e34f25 | Python | 5,130 | 176 | """FastMCP tools for generic HPC run-artifact inspection."""
from __future__ import annotations
import json
from pathlib import Path
from typing import Any
from mcp.server.fastmcp import FastMCP
mcp = FastMCP(
name="ChemGraph HPC Misc Tools",
instructions="""
You expose small, generic tools for ins... |
a878ef070a697dace5e6a095b26673d17d6097d3357c5b151e47bd9ce02b4fdc | Python | 5,131 | 122 | from typing import Optional
from torch import Tensor
from torch_geometric.nn.conv import MessagePassing
from torch_geometric.nn.conv.gcn_conv import gcn_norm
from torch_geometric.nn.dense.linear import Linear
from torch_geometric.typing import Adj, OptTensor, SparseTensor
from torch_geometric.utils import spmm
clas... |
8138e75058310c9fa7545a1b5885d8e23464a2b54ce48ba918ff7c89ec7c421b | Python | 5,132 | 181 | #! /usr/bin/env python
# aponteeduardo@gmail.com
# copyright (C) 2016
''''
Graphical tools
'''
from pdb import set_trace as _
import numpy as np
from scipy import stats
from . import containers
class Units(containers.TimeSeries):
''' Abstract class for units, where units refer to the distribution
of t... |
5a30e28eafd934c3ecd6dcaad037e824aa1d77ec1c31d99d83f5220a4ba883b7 | Python | 5,133 | 144 | import unittest
import logging
import numpy as np
import pandas as pd
import scipy.stats as stats
import diffxpy.api as de
class _TestSingleNullBackends:
def _test_null_distribution_wald(
self,
n_cells: int,
n_genes: int,
noise_model: str,
backend: str... |
eac5f8dbed04e0e7df2f78f41d59e824852b8069ea9d378b2d34d2e3e47d5b33 | Python | 5,133 | 156 | """
lasagna.ingredients.lasagna_ingredient
Each ingredient is a class which defines how lasagna displays and interacts with
a particular sort of data. Things like images, data points, lines, polygons,
areas, etc, etc. This superclass is inherited by ingredient files and helps
define interactions between the data a... |
2f87d72e4b43cc0bdb9642f940962bf78b8b46a2cc340d6aae4a8473499cfa8d | Python | 5,134 | 90 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import pytest
from pytest_cases import NOT_USED
# Force execution of fixture definitions
from shared.fixtures.data import * # pylint: disable=wildcard-import
from shared.fixtures.init import * # pylint: disable=wildcard-import
from shared.fixtures... |
6588fb8939bc3bc008246f7955a6a9a9c32231e79319b5f05a86fedd1a5ee623 | Python | 5,134 | 80 | single_agent_prompt = """You are a computational chemistry expert. Follow these steps carefully:
1. Identify all relevant inputs from the user (e.g., SMILES, molecule names, methods, properties, conditions).
2. Use tools only when necessary. Strictly call one tool at a time.
3. Never call more than one tool in a singl... |
a7580f54a9e7d6d9a5efd313e2230bb2005c308a05a2e290bda1fe33500fa451 | Python | 5,135 | 113 | # Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved
from typing import Callable
import torch
from torch.nn import functional as F
# Adapted from https://github.com/facebookresearch/detectron2/blob/main/projects/PointRend/point_rend/point_features.py
def point_sample(input, point_coords, **kwarg... |
b97ef57b25d19c5b646508052a97dd6c55518a0fc9d084b85c2de685dad6ed95 | Python | 5,135 | 140 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
"""Create one task per shape type and label group over the same set of images,
so boxes, polygons, and tags are annotated in parallel by different people
instead of all at once in one crowded task.
Each --task spec is 'NAME:TYPE:label1,label2': the ... |
4f3d05dd2d7af5ac46631238c0a8a3863fb5dce45baa24757ef0a760534bddff | Python | 5,136 | 130 | import fire
import pickle
import numpy as np
from nilearn.glm.contrasts import expression_to_contrast_vector, compute_contrast
from glob import glob
import rsatoolbox
import scipy
import matplotlib.pyplot as plt
import itertools
from scipy.stats import ttest_rel
from statsmodels.stats.multitest import multipletests
... |
a64da99a4277ee4f8edfe09ad3bb4d44876418e9c419f0de9ac56a84aea11495 | Python | 5,137 | 133 | import os
import os.path as osp
import sys
sys.path.insert(0, '../')
sys.path.insert(0, '../../')
sys.path.insert(0, '../../ogb')
import torch
import numpy as np
import pandas as pd
import scipy
import argparse
import networkx as nx
import torch_geometric.transforms as T
from pytorch_dataset.node_dataset import NodeVe... |
35815e64ca0a9152b96f2ec3148c346ecb89850826ed3036508b3d9c0b61b70a | Python | 5,138 | 173 | import itertools
import os
import time
from tqdm import tqdm
import numpy as np
import torch
from torch import Tensor, nn
import torch.nn.functional as F
from sklearn import metrics
from typing import Optional
from torch.utils.data import DataLoader
import logging
from sklearn.metrics import r2_score
fro... |
4659e7a6f015aa53a97a9cabc66f8285d09ed20f089a2a5b93482a976afab2ba | Python | 5,138 | 142 | # -*- coding: utf-8 -*-
"""
Created on Fri Jul 10 15:31:38 2020
General utility functions for cortex lab experiments
@author: Samuel Failor
"""
from os.path import join
from os.path import exists
import os
from datetime import datetime as dt
dirs = [
# r'//znas.cortexlab.net/Subjects/',
# r'//z... |
13a8e0b51cfa727730dd989f9a99a963fcde95a05a132370d482d5989539fff2 | Python | 5,139 | 156 | #!/usr/bin/env python
"""Agent + MCP demo on LocalBackend: LLM screens 5 molecules locally.
Spawns ``chemgraph.mcp.mace_mcp_hpc`` as a local subprocess wired to
the LocalBackend, then asks the ChemGraph LLM agent to compute
thermochemistry on water / methane / ammonia / CO2 / ethanol via the
MCP ``run_mace_single`` to... |
13db6609298d4be984f0ecaf514ec5a3323283639c0410211de5c4886a94b7bf | Python | 5,139 | 154 | import re
import pandas as pd
import pytest
from deepreg.registry import BACKBONE_CLASS, KNOWN_CATEGORIES, LOSS_CLASS, REGISTRY
class TestRegistry:
@pytest.fixture()
def reg(self):
return REGISTRY.copy()
@pytest.mark.parametrize(
"category,key,err_msg",
[
("unknown_c... |
55f2a7f0aaccdbc60703dfdbd6022faa2aecb978412c9cad86235af69cddc490 | Python | 5,140 | 119 | import numpy as np
import warnings
import scipy.io as sio
from scipy.stats import pearsonr
from sklearn.model_selection import cross_val_predict
from sklearn.kernel_ridge import KernelRidge
K = 10
run_session = '1LR'
mykernel = 'cosine' # cosine linear
alpha_list = [0.1,1,2,5,10,15,20,50,80,100,150,200,300,1000,100... |
c596ef711de7af0af1ed5e8366b25fd6c701d7606fdd03a8e8c215fbb02765bb | Python | 5,141 | 135 | import pytest
from brainscore_vision import load_dataset, load_stimulus_set
import numpy as np
@pytest.mark.private_access
class TestBaker2022Stimuli:
# general tests
@pytest.mark.parametrize('identifier', [
'normal',
'inverted'
])
def test_stimulus_set_exist(self, identifier):
... |
b23d7811890a7124f40b789f58bae70b705f1fbec31a71a2fb8c017622ec725c | Python | 5,142 | 117 | import os
import re
import nibabel as nib
import numpy as np
import pandas as pd
from scipy.io import savemat
from nipype.interfaces.base import BaseInterface, BaseInterfaceInputSpec, TraitedSpec, Directory, File, InputMultiPath
from neuromaps import transforms
from traits.api import Either, Float
from cvdproc.pipelin... |
962a78e034ce65d18f9ea2aa56d1be3a805bc4850df5df6284c18ad21a2dc1d4 | Python | 5,143 | 140 | import torch
import torch.nn as nn
import numpy as np
from brainscore_core.supported_data_standards.brainio.s3 import load_weight_file, sha1_hash
from brainscore_vision.model_helpers.check_submission import check_models
import functools
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from... |
f5d598e976108148bf75eda16e18a2c691c40c8b5d6c5abfb55907d7a625e7df | Python | 5,146 | 82 |
import argparse
def parse_arguments(is_training: bool = True):
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# CosPlace Groups parameters
parser.add_argument("--M", type=int, default=10, help="_")
parser.add_argument("--alpha", type=int, default=30, help="_"... |
75b4ef54532fa975f2a48f526c86fd5a087e07332b1a8ceedca685da99353dcb | Python | 5,148 | 77 | import functools
import importlib
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images
from brainscore_vision.model_helpers.check_submission import check_models
import torch.hub
import ssl
from brainscore_core.supported_data_standards.brainio.s3 import load_weight_file
from torch.nn im... |
b7fa0dcdf611af6521dd6c0a0ea1468ba5a8437e8d63031f4f9203e15883fed6 | Python | 5,148 | 139 | from .base import BaseDeepGOModel, Residual, MLPBlock
from torch import nn
import torch as th
from dgl.nn import GATConv
class DeepGOModel(BaseDeepGOModel):
"""
DeepGO model with ElEmbeddings loss functions.
Args:
input_length (int): The number of input features
nb_gos (int): The number of... |
4d31e36febf4bc9490331fdb7da4f98e912ea434d4ed5bfabfcee0b6f560a12f | Python | 5,150 | 112 | #!/usr/bin/env python3
"""Stage 0 -- interrogate Labels.csv before committing to anything.
Runs in seconds on the label file alone, with no feature extraction. Run it the
moment the data arrives: it decides the target definition, and the wrong target
definition makes the warning-lead-time metric undefined and reduces ... |
6a66f541d1110314fb2e7245a074983d596f34583c7185d7373c9d79484f3c51 | Python | 5,150 | 123 | def pairwise_dpca_and_train(adatalist: List, join: str = 'inner', n_comps: int = 50, epochs: int = 1150,neighbors=8, device=None) -> tuple:
corrected_adatas = [] # 存储所有校正后的 adata
graphs = [] # 存储所有训练的 graph
best_models = [] # 存储所有训练的模型
import time
# 处理所有配对
for i in range(len(adatalist) -... |
6b18a95f7878d3275a71f913502825c594bb626a9616aaf9951f6f7d88693320 | Python | 5,152 | 133 | """Participant-level inference.
Every procedure here resamples or permutes **participants**, never windows.
Windows drawn from one 4-minute KSS block share a single self-report and windows
within a session are serially correlated; treating them as independent would
shrink confidence intervals by roughly the square roo... |
7d62c50779371b59aee519f37704d054cfbd0968dce61886462f06729b5e6cd2 | Python | 5,153 | 171 | import os
import json
import math
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
""" train util """
def adjust_learning_rate(args, optimizer, epoch):
lr = args.learning_rate
if args.cosine:
eta_min = lr * (args.lr_decay_rate ** 3)
lr = eta_min + (lr - eta_mi... |
5aaf280e97fdefc90a6885e061dbac25ad3a2788e907e5cdb0d4ddbafa63683e | Python | 5,157 | 170 | """
mevv_f.py
-----------------------
This script trains a model using **MAVE-NN** (Tareen et al., Genome Biology 2022).
Reference:
Tareen, A., Kinney, J.B. "MAVE-NN: learning genotype–phenotype maps from multiplex assays of variant effect."
Genome Biology 23, 248 (2022). https://doi.org/10.1186/s13059-022-02... |
bc9833fee060e4c5abdec93b55d1ef647c90eed8b6cc75cd82c54f71613a036d | Python | 5,157 | 141 | import jax.numpy as jnp
import matplotlib.pyplot as plt
import glob
import sys
import os
import re
import json
from plot_utils import sort_rows_by_first_threshold
plt.rcParams["font.sans-serif"] = ["DejaVu Sans"] # Best available
plt.rcParams["font.family"] = "sans-serif"
plt.rcParams.update({
"font.size": 1... |
e8c211ce8e927871b4f18c84dd19e3bfa67014e06aa751de5ad5d4695089f4c1 | Python | 5,157 | 179 | import os
import itertools
import torch
from torch.utils.data import DataLoader
from tqdm import tqdm
from models.text_encoder import BertTextEncoder
from models.hdc_mlp import HDCMLPEncoder
from data.oct_dataset import OCTDataset
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
PATHOLOGY_LABEL... |
70bd7f20ea1cc129c435467e42da91ee79af74f9b87a281a71071909322d75e1 | Python | 5,158 | 183 | import argparse
import re
import subprocess
from dataclasses import dataclass
from pathlib import Path
from typing import Literal
import tomlkit
@dataclass
class VersionInfo:
version: str
bump_type: Literal["patch", "minor", "major"]
def run_command(cmd: list[str], check: bool = True) -> subprocess.Complet... |
73a64936b0e4511eb3076952a21e05c917a22dfae082c7de34ea5800f784d4dc | Python | 5,158 | 128 | from typing import Optional, Any, Type
import torch
import torch.nn as nn
import torch.nn.functional as F
import seisbench.util as sbu
try:
import torchvision
except ImportError:
torchvision = sbu.MissingOptionalDependency("torchvision", "torchvision")
from .das_base import (
DASAnnotateCallback,
DA... |
b8714f05a07b0e69344395f45c073d95eb11a925b5e9905f9977fd33a2377e72 | Python | 5,158 | 171 | import os
import json
import math
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
""" train util """
def adjust_learning_rate(args, optimizer, epoch):
lr = args.learning_rate
if args.cosine:
eta_min = lr * (args.lr_decay_rate ** 3)
lr = eta_min + (lr - eta_mi... |
ec93eb1e0fba0f98cb2d6c02e4534826b915f6b6828fa8d1a9f569c518386be1 | Python | 5,159 | 152 | import logging
import numpy as np
from tqdm import tqdm
from scipy.ndimage import label
from scilpy.ml.utils import get_device, to_numpy, IMPORT_ERROR_MSG
from scilpy.ml.bundleparc.utils import (DEFAULT_BUNDLES, get_data)
from dipy.utils.optpkg import optional_package
torch, have_torch, _ = optional_package('torch'... |
3fc318006ea3d433effff4c90e46c41d08e275248a67bac80ed3d07779dc7f37 | Python | 5,160 | 157 | ###############################################################################
#
# Adapted from https://github.com/lrjconan/GRAN/ which in turn is adapted from https://github.com/JiaxuanYou/graph-generation
#
###############################################################################
import pyemd
import numpy as n... |
5505aed98ba3a2d07e33c7633e2fec0bebeade27596e6ef6639cfbe478efac65 | Python | 5,160 | 171 | """
mevv_f.py
-----------------------
This script trains a model using **MAVE-NN** (Tareen et al., Genome Biology 2022).
Reference:
Tareen, A., Kinney, J.B. "MAVE-NN: learning genotype–phenotype maps from multiplex assays of variant effect."
Genome Biology 23, 248 (2022). https://doi.org/10.1186/s13059-022-02... |
f3a5ec35ba09f27254300aaf58b01fd47d3d7314ed596bf51c8fccdfe0230942 | Python | 5,161 | 146 | import torch
import numpy as np
import pandas as pd
from datetime import datetime as dt
from dataset import fast_merge,df_to_mask
from tqdm import tqdm
dataset_names = [
'botometer-feedback-2019', 'botwiki-2019', 'celebrity-2019', 'cresci-2015', 'cresci-2017', 'cresci-rtbust-2019', 'cresci-stock-2018', 'gilani-2017... |
4eff89a72f7709f89ed50a905b04345a91c370ede836f1d8b26dd93d4089d3b0 | Python | 5,162 | 117 | from pathlib import Path
import csv
from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet
from brainscore_core.supported_data_standards.brainio.packaging import package_stimulus_set
'''
Dataset Meta Info
Reported in pixels:
- image_height
- image_width
Others:
- num_channels ... |
68db82a1e6c5770377c1c0d81d0d246256f16001bf0f7a5f320b79eb840673ba | Python | 5,162 | 141 | import pandas as pd
import numpy as np
from sklearn.metrics import adjusted_rand_score
from tqdm.auto import tqdm
from anndata import AnnData
import re
from scale.config import Config
def calc_stability(
adata: AnnData,
cfg: Config,
n_repeat: int | None = None,
verbose: int | bool = False,
min_di... |
d089a8fcae17a59404beb1f77762a3617eda1a6b2fd3b1f7918308141f6569ba | Python | 5,162 | 221 | from fetal_brain_qc.qc_evaluation import preprocess as pp
from sklearn.preprocessing import (
StandardScaler,
RobustScaler,
QuantileTransformer,
)
from sklearn.decomposition import PCA, SparsePCA
VALID_EXP = ["regression", "classification"]
METRICS_BASE = [
"centroid",
"centroid_full",
"dl_slic... |
a61ebc93eca33d96db0affe3722e026dc03e2eb96aeeac9e0471acff831748a1 | Python | 5,163 | 148 | import json
import os
import time
import numpy as np
import pandas as pd
import torch
import torch.multiprocessing as multiprocessing
from datetime import datetime
import yaml
import my_setup
from bayesian_optimization.acquisition_functions import ThompsonSampling, UpperConfidenceBound
from data_processing.masked_se... |
39fc41bb4c62c934d245d3447e794ef443d9436b3d3dd82965c367b7a165096f | Python | 5,164 | 164 | """Tests for interactive plot data helpers and figures (ui.plots)."""
from pathlib import Path
import pytest
from ase import Atoms
from ase.calculators.emt import EMT
from ase.io.trajectory import Trajectory
from ui import plots
def _write_spectrum_csv(path: Path) -> None:
path.write_text(
"frequency_c... |
758ce670806a777b7fb47fb7cfdeb08a6adcdef2b5dd048027a8070707dddd40 | Python | 5,164 | 124 | import json
from matplotlib import colors as mcolors
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap
import matplotlib
from neuromaps.datasets import fetch_fslr
from neuromaps.images import construct_shape_gii, load_gifti, load_data
from neuromaps import images
from neuromaps.parce... |
81baba7f59678142a6d59c691830b88f19e3230d4a64275956564d1d3bbf707d | Python | 5,164 | 137 | import os
import h5py
from obspy import UTCDateTime
import seisbench
import seisbench.util
from .base import WaveformBenchmarkDataset
class LenDB(WaveformBenchmarkDataset):
"""
Len-DB dataset from Magrini et al.
"""
def __init__(self, **kwargs):
citation = (
"Magrini, Fabrizio,... |
f9038e7f56b892519e537d9bbb9114f7ee6bed9f46d85bcaca909466015b494e | Python | 5,165 | 135 | import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
import seaborn as sns
def plot_ave_grad_all_f_maps(grads: tf.Tensor, title:str='Average Gradient of All Feature Maps', ylab:str='Normalised Mean Gradient Value', filename:str=None):
"""Plot the average gradient of all feature maps.
Arg... |
00e2c8df9c6b423600ab8c5e800349876c66f51fcc63931e6daf4d850b1ab83d | Python | 5,166 | 132 | import jax
import jax.numpy as jnp
import matplotlib.pyplot as plt
import os
import plot_utils
from matplotlib.colors import rgb2hex
jax.config.update("jax_default_matmul_precision", "high")
plt.rcParams["font.sans-serif"] = ["DejaVu Sans"]
plt.rcParams["font.family"] = "sans-serif"
plt.rcParams.update({
"fo... |
e798655fe5a971d913ee6404619b24101c526cc15d37bf070715d22f7a51e36b | Python | 5,167 | 158 | # Copyright (c) 2020, Soohwan Kim. All rights reserved.
#
# 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 la... |
f4ec0360514e884da5259f988ea4034ebf9edf5f70a225d5d09dc5ba1913dfe7 | Python | 5,167 | 138 | """
This is ported from Matlab code from the original TDR codebase.
"""
import numpy as np
from pyTdr.tdrTemporalSmoothing import tdrTemporalSmoothing
from pyTdr.tdrMeanAndStd import tdrMeanAndStd
def smooth_and_normalize(data, filter_type="gauss", width=0.04):
smthpars = {"filter": filter_type, "width": width}
... |
52e9a0849f2793fba0e2f9841a97ac8f7c0bbf73079458be1f26faeae5fa140c | Python | 5,171 | 118 | from pathlib import Path
from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet
# the following import is needed to configure pytest
# noinspection PyUnresolvedReferences
from brainscore_core.plugin_management.generic_plugin_tests_helper import pytest_generate_tests
from brainscore_vision imp... |
df18b78aa16130cc0123d1beff3e978e455ddbb8a4167446355b55f741bc306e | Python | 5,171 | 150 | #!/usr/bin/python
#
# Handles the plotting window
#
# Hazen 02/13
#
from PyQt5 import QtCore, QtGui
import pyqtgraph
import numpy
pyqtgraph.setConfigOption('background', 'w')
pyqtgraph.setConfigOption('foreground', 'k')
def saveData(filename, x, y, z):
numpy.savetxt(filename, numpy.concatenate((x[:,None], y[:,N... |
e812d4eaeff9ddef21685b9a38d06b2b50f8fd171981bce1274dc491d01ec346 | Python | 5,171 | 127 | """LAION-fMRI local stimulus extraction.
The stimulus images are gated by a Data Use Agreement and cannot be redistributed
via Brain-Score's public S3 bucket. This script extracts the user's DUA-approved
``task-images_stimuli.h5`` archive into a flat directory of JPEGs plus a manifest CSV,
ready for the benchmark's st... |
e2c5a91862cc7bd1073e6ca65b26dd6b8dab2b0a0aa9d2e8ec580467d8ee3c52 | Python | 5,173 | 134 | """Autonomic features from single-lead ECG (DD-Database, 128 Hz, bipolar DIII).
This branch replaces the electrodermal branch used on UL-DD. Both index
autonomic arousal; the reliability gate is what makes the substitution
tractable, since it weights whichever autonomic channel a given corpus provides
rather than assu... |
97605f675dcabcaabf3f96b708ab161dc2433e81efc99233e106ece19c25aba9 | Python | 5,176 | 165 | import preprocess
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score, f1_score, recall_score, precision_score,roc_auc_score
import numpy as np
from sklearn.svm import SVC, LinearSVC
from pathlib import Path
import sys
sys.path.append("..")
#from utils.dataset import merge_a... |
02a88d6071cd0ed912069a5bcba09516b3aa08ac6545551250bf4a85b31542ae | Python | 5,178 | 144 | '''
Auxiliary functions to make multivariate
analyses a bit easier.
@TODO: I think principally these should be estimators.
'''
from .math import *
from . import math_torch
from . import estimators
import torch, mne
import numpy as np
import warnings
from typing import Any, Union, Callable, Dict
def compute_rdms(X:... |
3a1f6bf12855594c6915bcda6b43f2b9afc4b21ff2cdeffaf4379ec755ce9112 | Python | 5,178 | 110 | import torch
import numpy as np
from torchvision import transforms
import os
from utilities import get_CT_image, get_mci_image,check_footprint
from math import ceil
# Prior to invoking this code for loading image data, it is assumed that preprocessing as described in the
# paper has already been done. Then, when loadi... |
8ced91e7915f55396ab77e8165aedbe8bb13d6ca53cc22d38e22e40c66af7485 | Python | 5,178 | 136 | import gc
import glob
import os
import click
import numpy as np
from pycurv import pycurv_io as io
from scipy.ndimage.morphology import distance_transform_edt
import mrcfile
import vtk
TOLERANCE_DISTANCE_NM=2 # Heuristic to get complete surfaces but avoid spurious junk
# Closed in for TgGSK because it was spurious ju... |
f9422c8e6d8e05164fadf1ce43f60fae5a1e5aba4f96018fbe6b555b510b2a9d | Python | 5,181 | 136 | import os
import os.path as osp
import sys
sys.path.insert(0, '../../')
import torch
import numpy as np
import pandas as pd
import scipy
import argparse
import networkx as nx
import torch_geometric.transforms as T
from pytorch_dataset.node_dataset import NodeVesselGraph
from pytorch_dataset.vessap_utils import *
fro... |
4ca1198bc249207b65cf9e89d179e9543a4ec3a8487da79868c0cacfc7d45bcf | Python | 5,182 | 139 | # Import necessary libraries
import pandas as pd
from sklearn import datasets
import numpy as np
from fibe_functions import fibe
#======================================
# Regression Example
#======================================
# Load Boston dataset
boston = datasets.load_boston()
# Without any predefined fix... |
d4ddae0e72fb31597d596d7aed8fcc765a8e51549e0b0800e053d36208e64a6a | Python | 5,183 | 139 | """
Find clusters of intervals within a set of intervals. A cluster is a
group (of size minregions) of intervals within a specific distance (of
mincols) of each other.
Returns Cluster objects, which have a chrom, start, end, and lines (a
list of linenumbers from the original file). The original can then be
ran throu... |
8ff10c89633a4aa88d00496f7df4b683842179c112802edc076bff4396a7edc5 | Python | 5,184 | 94 | """Build the production static Li2026 assembly: a fixed 70-170 ms post-onset window
applied uniformly to every unit (MajajHong convention), with a window-matched noise
ceiling. Run after build_li2026_static.py (for metadata), build_li2026_temporal.py
(for the response), and build_li2026_reliability_70_170ms.py (for the... |
9106364619e8e0b3ea5f7d3f99e332d28e0aaf28e43686c5024caca6b1d4489b | Python | 5,184 | 148 | # Copyright 2025 BDP Ecosystem Limited. All Rights Reserved.
#
# 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... |
e69dd96597f4b05d083826eff1c9e904bd4146e23622532dce847582ef5082aa | Python | 5,184 | 162 | import numpy as np
import torch
# define a function to derive the gex from the sphex
def calc_gex(sphex):
"""
Converts a spherical gene expression matrix into a standard gene expression matrix.
The function takes a spherical expression matrix (`sphex`) and calculates the corresponding
gene expression... |
7c1bd1f4c33966a31344a0d3d9274b237da802d2c6e7daee1526979e7de3b332 | Python | 5,185 | 148 | # fmt: off
# flake8: noqa
from abc import ABC, abstractmethod
import numpy as np
from .. import _timing
from ..utils import TrackEvalException
class _BaseMetric(ABC):
@abstractmethod
def __init__(self):
self.plottable = False
self.integer_fields = []
self.float_fields = []
s... |
77d8edeed19bcd269d10756862a2179476345a99853e5b75ec3c18e56d721a0f | Python | 5,186 | 149 | import os
from copy import deepcopy
import numpy as np
import argparse
import innvestigate.utils as iutils
from keras.models import Model
from keras.preprocessing import image
from keras.utils import to_categorical
import keras
import tensorflow as tf
from numpy import average, dot, linalg
from utils import *
from lrp ... |
c16a1ef350a4bda9ecd3a5c42056e8f1a3f21a2dd7da2797cc0022f4bce451d2 | Python | 5,186 | 119 |
import os
import cv2
import numpy as np
from tqdm import tqdm
from skimage.transform import rescale
from PIL import Image, ImageDraw, ImageFont
# Height and width of a single image
H = 512
W = 512
TEXT_H = 175
FONTSIZE = 80
SPACE = 50 # Space between two images
def write_labels_to_image(labels=["text1", "text2"])... |
d72897097e804dfbe9fc1c6cf138401e4b5b99a016e44ae27eb58922838bc5ae | Python | 5,188 | 127 | import os
from typing import Any, Dict, Optional, Union
from urllib.parse import urlsplit
from timm.layers import set_layer_config
from ._helpers import load_checkpoint
from ._hub import load_model_config_from_hf
from ._pretrained import PretrainedCfg
from ._registry import is_model, model_entrypoint, split_model_name... |
7500718d20fe023bee2c54bbe1df1def8c2cfcafc5c64b72b95094e68633ccb4 | Python | 5,189 | 140 | '''
CH4OCl
'''
import numpy as np
import sys
def intro():
print("""
SHORT List of potential energy surfaces for CH4OCl:
P: potential energy, G: Gradient, D: Nonadiabatic coupling vector
This is listed at the end of description to show the availability.
For example: P/G means both potential energy... |
37a1f4cc7b42ea31aa18ef16528e5ead92bad0cc3ba8c74ff842c08e5ab2b664 | Python | 5,191 | 190 | #!/usr/bin/python
#
## @file
#
# Innova 70C laser control using RS-232.
#
# Hazen 4/09
#
import storm_control.sc_hardware.serial.RS232 as RS232
## Innova70C
#
# This controls a Innova70C laser using RS-232 communication.
#
class Innova70C(RS232.RS232):
## __init__
#
# Initiate RS-232 c... |
407e221dca2c229ca1e3906555c5824146c8cff397f640fe5b70fabc7460a0d8 | Python | 5,191 | 145 | import torch
import torch.nn as nn
class ConvBlock(nn.Module):
def __init__(self, ch_in, ch_out):
super().__init__()
self.conv = nn.Sequential(
nn.Conv2d(ch_in, ch_out,
kernel_size=3, stride=1,
... |
52f8654556a54e6a231c6c3f6ecdb2070edd7d4344f7883cb03e031f974c0993 | Python | 5,192 | 143 | from sklearn.neighbors import LocalOutlierFactor
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.pipeline import Pipeline
from sklearn.impute import SimpleImputer, KNNImputer
from sklearn.preprocessing import RobustScaler, StandardScaler, PowerTransformer
from sklearn.model_selection import cross_... |
90ed803ffef0f47dce77f42f4221046020c069cde3a64a9629137e4a6a373b47 | Python | 5,192 | 164 | #!/usr/bin/env python3
# This script is included in documentation. Adapt line numbers if touched.
import arbor as A
from arbor import units as U
import pandas as pd
from math import sqrt
# Run with srun -n NJOBS python network_ring_mpi.py
# Construct a cell with the following morphology.
# The soma (at the root of t... |
9e3f635ba6b6bf027d5113ed564474b17c0f19c2f6fc39144188de33128284dc | Python | 5,193 | 120 | #!/usr/bin/python3
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
import torch
from torch.utils.data import Dataset
class TrainDataset(Dataset):
def __init__(self, triples, nentity, nrelation, negative_sample_size, mode, count, tru... |
f8e15a921d9d41c2923ce54af082030431fe463e74409c28fa5cbbf96660ba3b | Python | 5,193 | 146 | import torch
import torch.nn as nn
import numpy as np
import ase
from ase.io import read
# utils imports
from utils.plot_corr import plot_corr
from utils.neuralnets.FFNet import FFNet
from utils.distances import get_bond_length_hoxa
from utils.kernels import get_1D_kernels_k33
# define options
torch.set_printoptions(p... |
594188670c89a05c9eee356c6383870b7933d215014d94db8837618798d6af52 | Python | 5,195 | 116 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from __future__ import annotations
import os
from functools import partial
from pathlib import Path
import numpy as np
import torch
from ultralytics.utils import ARM64, LINUX, LOGGER, WINDOWS
from ultralytics.utils.checks import check_requirements
... |
a5ef961a84ee1bb3f645cf3d32bad73816bcde8a9ca727262f6fc98bbac48373 | Python | 5,195 | 128 | import io
import os
import glob
import tqdm
import skimage.io as skio
from natsort import natsorted
import numpy as np
from tqdm import tqdm
def divide_subvolumes(big_vol_path, segments=2, overlap_depth_in_pixels=0):
'''
This function divides a big volume into subvolumes.
Args:
big_vol_path: str, ... |
aed66ee63c8e02f91f07e947c425efe03bebc94f2f44e71a5cd882d8cd484a12 | Python | 5,195 | 169 | import numpy as np
import matplotlib.pyplot as plt
import json
with open('results/tables/mechanistic_benchmark.json', 'r') as f:
mech_results = json.load(f)
with open('results/tables/drl_vrfb_results.json', 'r') as f:
drl_results = json.load(f)
pemfc_results = {
'Physics Solver': {
'rmse_mV': ... |
97b92d02fce4a750d6a479162cc32a92d3d884f417e9ac0f51d18aa0c67790f6 | Python | 5,197 | 163 | # Copyright 2024 Google LLC
# 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 to in writing, sof... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.