sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
7f659a8e3873c995870b009e6e7e52d5ca220a9d45f2e177bb5385554ad1ca86
Python
5,580
159
from __future__ import annotations from collections.abc import Hashable from functools import lru_cache import pandas as pd from skbase.base import BaseObject from skbase.lookup import all_objects from pgmpy.utils import build_state_names, get_dataset_type, preprocess_data class BaseStructureScore(BaseObject): ...
aee38492328fbb65ccee90e609387c444f7c95d4be82dd68f4064d4e5555c3c4
Python
5,583
135
import streamlit as st import glob import os import json import sys import numpy as np import time import joblib from collections import defaultdict from pathlib import Path from argparse import Namespace from PIL import Image from st_pages import show_pages_from_config, add_page_title import importlib fr...
4687351fae48919dd9195255ebc7384800c0cf6559ef70817afc87eb4cbfa4f8
Python
5,584
156
# 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 Any, Dict, Optional import torch.nn as nn from fairseq.models.fairseq_encoder import EncoderOut from fairseq.models.transf...
bf2def11aa306ef0d84c0cedb3961e7664eb0039d4340acd2c7b3f35a476fffa
Python
5,586
199
#!/usr/bin/env python # Author_and_contribution: # Niklas Mueller-Boetticher; created template # Peiying Cai; implemented method import argparse parser = argparse.ArgumentParser( description="""STAGATE (https://www.nature.com/articles/s41467-022-29439-6) """ ) parser.add_argument( "-c", "--coordinates", h...
5ea4d3004fdbaf0a35e82a3eb4c79c516ce4616aa297b897ff6ed21dca01138b
Python
5,587
115
from typing import Sequence import jax import jax.numpy as jnp from joblib import Parallel, delayed from tqdm import tqdm from ...geom import masked_pairwise_diffs from ...molecule import Molecule from ...types import ElectronConfiguration, ModelDimensions, MolecularConfiguration, Psi, ScfParams from ...utils import ...
467b13ba914c15871b5f4343585836145c49fbc2463547fdbe34e168536a8e69
Python
5,589
186
# %% """Plot Fig. 3 noise-robustness curves from saved experiment data.""" from pathlib import Path import matplotlib.pyplot as plt import numpy as np from scipy.stats import t, ttest_ind from statsmodels.stats.multitest import multipletests # ================================ # Settings # ===========================...
998c9c869b2695d2be7bed4211663205f98817ced2ded2b8815c3fb41bb00989
Python
5,592
165
# # Copyright 2017-2023 Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with # Sandia Corporation, the U.S. Government retains certain rights in this software. # # See LICENSE for full license details # import numpy as np from scipy.optimize import minimize import time import os # Use ...
b1fd4f9466484556add2491936173a2ea0410adfea13cc2cec802befd0d91a49
Python
5,597
166
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Mar 21 15:56:25 2024 @author: tower2 """ from pathlib import Path import os import torch import pandas as pd import scanpy as sc from sklearn import metrics import multiprocessing as mp from GraphST import GraphST from GraphST.utils import clustering im...
6cf034909247709f57d868a7aafa804e19e76e88d4abe770831015f96d13e83c
Python
5,599
155
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Nov 25 05:36:17 2025 @author: vbp Figure S2G only: correlation between a trial's post-outcome dopamine response and the following trial's anticipatory licking, per region, vs. a trial-shuffled control. IMPORTANT: the original version of this analysis ...
7d9b8787bad825983cc122319a8ffea0995adadb30fa08a53456c8a71b62b0ba
Python
5,602
170
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations from dataclasses import dataclass, field from functools import cached_property from typing import ( Any, Callable, Dict, Generic, Iterable, List, Mapping, Optional, Tuple, ...
c55f8cd4ba89b17b84ce42032cb703276fa6cb54cf6884e61b421e6c2d8890dd
Python
5,602
157
# Original work Copyright 2018 The Google AI Language Team Authors. # Modified work Copyright 2019 Rowan Zellers # # 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/...
76179dd70b30c503b55099d295950277c694399c4845763221ea7f22a135cfbe
Python
5,607
130
"""Example of how to add a task in tape. In order to add a new task to TAPE, you must do a few things: 1) Serialize the data into different splits (e.g. train, val, test) and place them in an appropriate folder inside the tape data directory. 2) Define a dataset as a subclass of a torch Dataset. This s...
569a52699a8c0974bdbbd4dabc4063bb491ec023b797474a26e0797b333785e5
Python
5,613
127
from dataclasses import dataclass from typing import List, Optional import numpy as np import pandas as pd from kanfood._paths import data_path, first_existing # Open dataset ships under data/tahini/; also resolves a repo-root copy for backward compatibility. TAHINI_PATH = first_existing("KANFOOD_TAHINI_PATH", ...
97f18289c01f990facf87c1758fe85ba37debad2dc65fe179ddfa3a04e5faf48
Python
5,613
146
import torch import torch.nn as nn import torch.nn.functional as F from core.Attention import RTModule, SelfModule, STAFM class FlowHead(nn.Module): def __init__(self, input_dim=128, hidden_dim=256): super(FlowHead, self).__init__() self.conv1 = nn.Conv2d(input_dim, hidden_dim, 3, padding=1) ...
b5fca4b3e96bf67f8310b76f781b7a8b0b1e49694b0c65545914da6b52499d58
Python
5,614
196
#!/usr/bin/env python3 # 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. import logging import os import shutil from typing import List, Optional logger = logging.getLogger(__file__) try:...
bb265f00e613c198795459e6808b0f9b805327428399b0b21cad98c932f2ef69
Python
5,620
156
__author__ = 'heroico' import gzip import io import logging from .DataSet import DataSet class KeyedDataSet(DataSet): def __init__(self, name=None, index=None, data=[], keys=[]): super(KeyedDataSet, self).__init__(name, index, data) self.keys = keys self.values_by_key = {} if len(k...
b0c47d3481f562ea00cc2380af67be7200e6d83f0f722fd1c2089b146b80caf3
Python
5,621
135
# utils/gui_utils.py import os from moove.qt_helpers import set_combo_items def zoom(app_state): """Zoom in by reducing the x-axis range by 30%.""" x_start, x_end = app_state.ax1.get_xlim() x_center = (x_start + x_end) / 2 x_diff = x_end - x_start new_diff = x_diff * 0.7 app_sta...
01a141bfbce8bec3ef5e1fe0f82fb1766513c591eb607bb5755847970525b158
Python
5,623
185
from __future__ import annotations from typing import TYPE_CHECKING import pytest from poetry.config.source import Source from poetry.repositories.repository_pool import Priority if TYPE_CHECKING: from collections.abc import Iterable from cleo.testers.command_tester import CommandTester from poetry.p...
fd4f1e030e94f91bbd28aed7f64c03015300cd9a7ed3c992a3b8624ce05fd0d4
Python
5,623
174
#!/usr/bin/env python3 -u # 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. """ Sample from a trained LM; hacked fairseq-interactive """ from collections import namedtuple import os import ast ...
06bbc95aee5e86120a3d10d77510fa326ca5a5aaf52756c9a760aa4c1fe12d66
Python
5,626
166
#!/usr/bin/env python """Draw BRENDA's training, validation and test splits and write them as CSV. Rare entities that share no surface form with any other are held out of training, so the unseen bucket of detection recall measures surface forms the tagger was never trained on. The splits page of the documentation says...
83da631300b449df48c0bd940d362c3735d7c756d01c5c3f2d081bb0fc64f64c
Python
5,626
107
# Copyright 2021 HIP Applied Computer Vision Lab, 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...
dd15fef73c5a634d166912a83c64d4fca3190936d87865c12c9f2a9851a46d55
Python
5,626
169
import argparse from pathlib import Path from typing import Any import anndata import h5py import numpy as np import pandas as pd from anndata import AnnData def convert_to_h5ad(dataset_dir: Path): res_path = dataset_dir / "adata.h5ad" if res_path.exists(): print(f"File {res_path} already existing."...
8a11bc41afe03fb99e4fd8bb911a248a962e26614d51dc1be761fd30009c9a52
Python
5,627
112
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import os from pathlib import Path from typing import Literal import fire from pymatgen.core.structure import Structure from mattergen.common.data.types import TargetProperty from mattergen.common.utils.data_classes import PRETRAINED_MODEL_NAME...
62c2f4a130a8e4227d143213f5a55a05b058824a43c576fca186f24ad347b8f8
Python
5,630
134
import time import psutil import matplotlib.pyplot as plt import os import numpy import threading from typing import Union, Tuple, List, Dict class PerformanceObserver: def __init__(self, image: Union[str, None] = None, model: Union[str, None] = None, polling_rate: float = 0.1): self.monitoring = False ...
a0ded8e4c49243780a967fb4b004d3ea0b69a03530abb83645be39d09e364a34
Python
5,631
156
#!/usr/bin/env python # ENCODE DCC cross-correlation analysis wrapper # Author: Jin Lee (leepc12@gmail.com) import sys import os import argparse from encode_lib_common import ( log, ls_l, mkdir_p, pdf2png, rm_f, run_shell_cmd, strip_ext_ta) from encode_lib_genomic import ( subsample_ta_pe, subsample_ta_se...
63c6fb47991f77e5d364ff790278d7a63aac93e57f6f041da02f73c72ed0d19a
Python
5,632
159
# scSGL - a python package for fene regulatory network inference using graph signal processing based # signed graph learning # Copyright (C) 2021 Abdullah Karaaslanli <evdilak@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as pu...
b736d37bdae4151f70e31d12c2e419c82e9e6be7367716cefe10eceb57f43e2c
Python
5,633
144
import torch import torchvision.transforms as transforms from torch.utils.data import DataLoader, Subset from pipelines.dataloader import JacquardDataset from modules.vgg16_baseline_longer import VGG16Baseline from grasping_pvgg16_longer_bb import PVGG16SeparateHP as PVGG16 import toml from modules.loss_functions impor...
051374940624400aaa0271f698ce57a6a6c4b4b413411d0470661b613e464e60
Python
5,638
94
import numpy as np from nnunetv2.training.dataloading.base_data_loader import nnUNetDataLoaderBase from nnunetv2.training.dataloading.nnunet_dataset import nnUNetDataset class nnUNetDataLoader2D(nnUNetDataLoaderBase): def generate_train_batch(self): selected_keys = self.get_indices() # preallocate...
f0d38602482463accdb76ed34bacf0ae98a37ddadfb718258a33df6b3a1be3e9
Python
5,638
149
"""Define the ConvNet architecture (standard pytorch ANN).""" import math from typing import Generator import torch.nn as nn from torch import Tensor from torch.nn import Parameter from .layers import Conv2dFA, LinearFA, LinearKP, LinearSCFA def conv2d_outsize(insize: int, kernel_size: int) -> int: return insi...
9f11cf5acfc6ecb740012786f80df21bf26a2f7797064c31f3f72315b4c30996
Python
5,640
117
# -*- coding: utf-8 -*- """ .. _tutorial05_ref: Tutorial 5: Colors and colorbars ================================ This tutorial demonstrates how to configure the colorbar(s) with ``surfplot``. Layer color maps and colorbars ------------------------------ The color map can be specified for each added plotting layer...
2d11706efd063367cb602599873336bef07260ad8fad8ae58da53b54889dc2c4
Python
5,642
129
import pandas as pd import gc from preprocessor.utils.preprocess_intrinsic import preprocess_intrinsic from preprocessor.utils.preprocess_synaptic import preprocess_synaptic class MembraneCurrentPreprocessor: """ Preprocesses intrinsic and synaptic currents and combines them into membrane currents. """ ...
86acd754900b77508b39cab31c2dbda7cfe62ad7129990e7c52590b02bbff8ef
Python
5,642
114
import torch from torch import autocast from nnunetv2.training.loss.compound_losses import DC_and_BCE_loss, DC_and_CE_loss from nnunetv2.training.loss.dice import get_tp_fp_fn_tn, MemoryEfficientSoftDiceLoss from nnunetv2.training.nnUNetTrainer.nnUNetTrainer import nnUNetTrainer from nnunetv2.utilities.helpers import ...
3b0f1171dc9b0db3262e477bb0baf6c1a4e20e02fb641bf8389819a96b8f5994
Python
5,643
129
import logging from typing import Callable, cast import pandas as pd import scanpy as sc from anndata import AnnData from ..._constants import Keys log = logging.getLogger(__name__) def load_dataset( pattern: str | None = None, tissue: list[str] | str | None = None, species: list[str] | str | None = No...
48ccbc9348d20b00aef844f9835ad15bec7d362f8ff993f1cbccee5a6e47b9b5
Python
5,643
129
from typing import ( Any, Callable, Iterable, List, Mapping, Optional, Sequence, Tuple, Union, ) from . import options as opts from .options import ThumbnailOpts from .options.charts_options import BaseGraphic, GlobeLayersOpts from .options.series_options import JsCod...
2805fbd0e27a9fbbbf0add0f82691783ee27f3e5dda2f75aa1fe030c4b14ec02
Python
5,646
160
#!/usr/bin/env python3 """Strip a DGR training checkpoint down to inference-only weights for release. Training checkpoints carry optimizer state, which roughly triples their size and has no use at inference. This writes ``model.safetensors`` plus a ``config.json`` recording the architecture hyperparameters needed to r...
a780da36e9160245d72397e1ce91f98dbc9df33beec45dc7a3ef4941a49f18cb
Python
5,646
107
# Copyright 2021 HIP Applied Computer Vision Lab, 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...
e0865dce08f2220ddcc83660ab9c012c1ef90acf7ddc78de0d8c064e44d9bb07
Python
5,648
179
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import Conv1d, ConvTranspose1d from torch.nn.utils import remove_weight_norm, weight_norm LRELU_SLOPE = 0.1 def init_weights(m, mean=0.0, std=0.01): classname = m.__class__.__name__ if classname.find("Conv") != -1: m.wei...
b8148a96f6158542a60d2081bca1d0ac4d702cdcaf2beadbcdce53255e75a032
Python
5,649
175
import glob import logging import os import pandas as pd logger = logging.getLogger("gsMap.utils.regression_read") def _read_sumstats(fh, alleles=False, dropna=False): """Parse GWAS summary statistics.""" logger.info(f"Reading summary statistics from {fh} ...") # Determine compression type compress...
36b5563667dc097779240613cd8083e63d564a745807c0a85b34effbef90603d
Python
5,651
132
import torch import numpy as np from pathlib import Path from tqdm import tqdm from compute_energy import compute_energy class EarlyStopping: ''' If the relative decrease in the loss is < min_delta for # of consecutive steps = tolerance, then the training is stopped. ''' def __init__(self, tol_st...
e982fe5bf5f9f26deb49e9693c6f80933d74b1bdfa665ba55ce41675011ebc65
Python
5,651
134
"""Phase 3/4: oils per-food benchmark + shared-chemistry transfer. (1) Does oils show nonlinearity (KAN/MLP vs PLS)? (2) Do tahini-KAN and oils-KAN, trained independently, flag the SAME FTIR bands on a common cm-1 axis -> transferable chemistry. Run: python -m kanfood.phase3_transfer""" import sys, os from pathlib imp...
02ae327e89410c23e5d2149d15792bee4a889be1c2c7d0c2e7f14abd17ba3e90
Python
5,652
146
import torch import torch.nn as nn import torch_geometric import numpy as np import os import copy import pandas as pd from tqdm import tqdm from sklearn.metrics import roc_auc_score import warnings warnings.filterwarnings('ignore') from .encode_structure import * from .model import * from .utils import * def get_gr...
93159c5f8d2c91a87d14e77b85d2e5f4b027e837294197e39d305cf388de042e
Python
5,652
155
import argparse def main(args): from dateutil import parser import numpy as np import os, time, gzip, json import glob folder_with_pdbs_path = args.input_path save_path = args.output_path alpha_1 = list("ARNDCQEGHILKMFPSTWYV-") states = len(alpha_1) alpha_3 = ['ALA','ARG...
818d1c650b0ea247b07c2d0d7cfe4a4da3cea9459b897d590712cd2446c4905b
Python
5,653
165
import os import numpy as np import random def print_file(str_, save_file_path=None): print(str_) if save_file_path != None: f = open(save_file_path, 'a') print(str_, file=f) class Metrictor_PPI: def __init__(self, pre_y, truth_y, is_binary=False): self.TP = 0 self.FP = 0 ...
c8a3f30eb55fcaac7b5b71939adf473cf2ec42092082186a52f7872deb621d2e
Python
5,656
176
import re import os import torch import tempfile import math from dataclasses import dataclass from torchaudio.models import wav2vec2_model # iso codes with specialized rules in uroman special_isos_uroman = "ara, bel, bul, deu, ell, eng, fas, grc, ell, eng, heb, kaz, kir, lav, lit, mkd, mkd2, oss, pnt, pus, rus, srp,...
d3be334efd7a18503b77b8d6e4c8d77cd3b9f5d4520eb5ec035cc54a9936b9cc
Python
5,659
154
import os import platform import shutil import subprocess import warnings from pathlib import Path from shutil import copyfileobj from typing import Literal, Union from urllib.request import urlopen import tenacity from rnalysis.utils import io try: import jdk except ImportError: # pragma: no cover warnings...
b2e0b893134dc2286b478fcd27280a2b63051aa1c8a7a57aeec64166735bc2ae
Python
5,661
159
"""Utility functions for joint embedding loss.""" from __future__ import annotations import torch def variance_loss(z: torch.Tensor, target_std: float = 1.0) -> torch.Tensor: """Compute variance regularization loss (VICReg-style). Penalizes dimensions with standard deviation below target_std. This prev...
d7c13f052ac9c8173aeb24b331052e75baaae2e5e495932b7bbac67344bf3789
Python
5,661
129
# Copyright 2021 HIP Applied Computer Vision Lab, 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...
0b04206863b2e762e80011c6b1d8557cfc0e4cfd5de7c63c309b602ca49edbb0
Python
5,662
113
from typing import Tuple import numpy as np from batchgenerators.utilities.file_and_folder_operations import * from nnunetv2.evaluation.evaluate_predictions import load_summary_json from nnunetv2.paths import nnUNet_results from nnunetv2.utilities.dataset_name_id_conversion import maybe_convert_to_dataset_name, conve...
1ba702ab054665af7cefb592094b9f3cc51ff278c1f45427a205493bfe080282
Python
5,663
144
import argparse import pandas as pd import numpy as np from typing import List, Tuple def read_file(tsv_file: str) -> Tuple[List, pd.DataFrame]: """ Reads the input 4-column WMD existing pairs TSV file in a pandas dataframe, generates all the unique PMIDs and returns the dataframe. Parameters -----...
4f70c403c7520aa329aa6f142715ad4e34d869a5914992dae2f88be1039bad33
Python
5,664
145
import argparse import pandas as pd import numpy as np from typing import List, Tuple def read_file(tsv_file: str) -> Tuple[List, pd.DataFrame]: """ Reads the input 4-column WMD existing pairs TSV file in a pandas dataframe, generates all the unique PMIDs and returns the dataframe. Parameters ----...
21068f84e6f9ceb8619455951f4172a6af684cd23818925dcffb1ca86317badb
Python
5,670
146
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ From Uchida Takumi https://github.com/uchida-takumi/CustomizedLinear/blob/master/CustomizedLinear.py extended torch.nn module which cusmize connection. This code base on https://pytorch.org/docs/stable/notes/extending.html """ import math import torch import torch.nn a...
bddad0ff63523030b3304b4f9033355bbc974a69bfe42bc8ac541f9034b5472f
Python
5,675
141
from ... import options as opts from ... import types from ...charts.chart import Chart from ...globals import ChartType class Graph(Chart): """ <<< Graph >>> The graph is used to represent the relational data. """ def add( self, series_name: str, nodes: t...
1c1ed652a41b48804730ffd5012e04bae02b7a9e763806c2cd8d115b4994340c
Python
5,677
124
"""Payload I/O for dynamic-segmentation visualize panels.""" from __future__ import annotations import json import os from dataclasses import dataclass from typing import Dict, Optional import numpy as np @dataclass class SegEvalPayload: """Serializable payload for six-panel visualization.""" ...
6633aaa91ba0f53f2f422f44d792872877a524a213d53395f68108ad04a82e1b
Python
5,678
117
# Source code: # https://github.com/zbmed-semtec/doc2vec-doc-relevance-training/blob/main/code/train_model/main.py # This file includes the modifications to the source codes according to this project! import os import time import yaml import argparse import logging import utilities import precision import calculate_g...
fa7658922dd18f174d2295a7f73f5e296b35eb7694f03f52881bbe5443fd0b56
Python
5,678
167
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import logging import os import nu...
22e37c6f2dd564966b9b36a7f60fd2fc63b9436897d085490c02d3bd590615b7
Python
5,682
161
"""Every tracked script under `scripts/` must name modules that exist. `scripts/` is the one corner no other gate covers: mypy runs against `src/` only and nothing executes these files, so a script can name a module that has not existed for years and stay green. The module part is checked statically with `ast` and `fi...
8134eb4a3d830dfd5ee54acb1c9daacac6c0af21522567d96988691eb6284f9d
Python
5,682
157
""""code to fit learning curves adapted from https://github.com/NickleDave/learning-curves/""" import numpy as np from scipy import optimize def residual_two_functions(params, x, y1, y1err, y2, y2err): """ returns residuals between two lines, specified by parameters in variable params, an...
d09c28cb7c2014eaca8ae71da9a855b974595c3a1dd99b6bdb9a16a470aefd32
Python
5,682
139
"""Define the architecture of the spiking RDD net.""" import numpy as np import numpy.typing as npt import torch import torch.nn as nn from .rdd_layers import SpikingFA class RDDNetBase: """Base class for RDD-based spiking networks of arbitrary depth. Builds a chain of SpikingFA layers and implements the s...
eb13dd9fde8ac5db690fb9563757a7621a304a5da3daccded1078b4954b6605f
Python
5,684
152
#!/usr/bin/env python # ENCODE DCC Naive overlap wrapper # Author: Jin Lee (leepc12@gmail.com) import sys import os import argparse from encode_lib_common import ( assert_file_not_empty, gunzip, log, ls_l, mkdir_p, rm_f, run_shell_cmd) from encode_lib_genomic import peak_to_bigbed, peak_to_hammock from encode_lib...
4467e6c87a3019d4ef281c0c4fdab2da8d29d7393d97897c0a85405b4a0017cb
Python
5,686
138
import torch from torch import nn from torch.nn import functional as F class SelfTrans(nn.Module): def __init__(self, in_channels, inter_channels=None, mode='dot', dimension=2, bn_layer=True): # def __init__(self, in_channels, inter_channels=None, mode='dot', dimension=2, bn_layer=True, n_mix, d_k): su...
cfd47d9778a46e8dedbc914cb7a9522d7937dc2e51d192d73588498d279faff5
Python
5,688
152
# import torch # import torch.nn as nn # # def autopad(k, p=None, d=1): # """ # Pads kernel to 'same' output shape, adjusting for optional dilation; returns padding size. # # `k`: kernel, `p`: padding, `d`: dilation. # """ # if d > 1: # k = d * (k - 1) + 1 if isinstance(k, int) els...
1bb8501f52636318d9d10d6085d4330c83bab94a4f9e29c39b9c41e04fdf35f0
Python
5,693
136
"""Manages GO Term fill colors and bordercolors.""" __copyright__ = "Copyright (C) 2016-2017, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" import sys import collections as cx class GoeaResults(object): """Manages GOEA Results for plotting.""" kws_set = set(['id2symbol', 'st...
833e256a4026d041f0871550b2fa737d49f828587bd9c31e86b0817b11a15675
Python
5,695
166
import torch import pytest from neurovfm.models import ( AggregateThenClassify, ClassifyThenAggregate, ) import neurovfm.models.mil as mil_mod class _LinearDense(torch.nn.Module): """CPU-friendly stand-in for flash_attn FusedDense used in MIL modules.""" def __init__(self, in_features: int, out_feat...
1ab17cc79a9bb5ca17a9d1ab74503b769eaeb8c5d904402f668f22fe284e6a4a
Python
5,696
114
from typing import Tuple import numpy as np from batchgenerators.utilities.file_and_folder_operations import * from nnunetv2.evaluation.evaluate_predictions import load_summary_json from nnunetv2.paths import nnUNet_results from nnunetv2.utilities.dataset_name_id_conversion import maybe_convert_to_dataset_name, conve...
a4af2548f9945532f1dd48b9a500b96f5416f01b3261ddfc7a9a9df1c034df9e
Python
5,696
175
from pathlib import Path import sys import pandas as pd import re import math BASE_DIR = Path(".") INDEX_2016_PATH = BASE_DIR / "dataset" / "index" / "v2016" / "INDEX_general_PL_data.2016" INDEX_2020_PATH = BASE_DIR / "dataset" / "index" / "v2020.R1" / "INDEX_general_PL.2020R1.lst" SPLIT_DIR = BASE_DIR / "processed_...
db84543101016f932e4c27fce6ac388983ba4d704c4ff74e5fbe8894a14cfe11
Python
5,701
125
# ############################################################################## # GPLv3 LICENSE INFO # # # # Copyright (C) 2020 Mario S. Valdés-Tresanco and Mario E. Valdés-Tresanco ...
0fec56f86cd8edd97f48c93e00753bda5989e9e29a90c8613fcbd45d9c14f948
Python
5,703
198
from __future__ import annotations import json import os import re from pathlib import Path from typing import TYPE_CHECKING from typing import Any import pytest from poetry.config.config import Config from poetry.config.config import PackageFilterPolicy from poetry.config.config import boolean_normalizer from poet...
3cf20bf605a277143c8045ae418380a62a5065795f1f3b22605366f2dc154aa8
Python
5,703
149
import pickle import tkinter as tk from tkinter import filedialog from tkinter import ttk from src.align_photometry_behaviour import DataProcessingSingleInstance from src.align_telemetry_opto_photom import MenopauseDataProcessingApp from src.window_utils import center_window_on_screen class AppDashboard(tk.Tk): ...
ad707ae1c2909a09c5318173167ed8b2129278a23230d42df768f9c09540822b
Python
5,704
154
#!/usr/bin/env python3 """ @file train_pc.py @author Simon Yu @date 02/11/2024 @brief Script for training PC models. """ import argparse import header import logger import math import pc import test_pc import torch import tqdm import utility import wandb def processArguments(): parser = argparse.ArgumentPar...
39f2deee7649d0eaa01e76b66daed110811e42c5c3d9034f2e3144cd91361ab3
Python
5,705
157
import os import tempfile import unittest from unittest.mock import MagicMock, patch from PIL import Image from simulation_encoder.loader import PNGLoader def _write_images(directory, filenames): """Save real 10×10 greyscale PNGs to directory.""" for filename in filenames: Image.new("L", (10, 10)).s...
5a985e6cb70fc7cd39d5c012898517fa6e9bebfb76de1aca658e0a1dc3a2b7d0
Python
5,706
115
#!/usr/bin/env python3 """O gap com descritores de DOS: oraculo, circularidade e o que sobra de util. ADVERTENCIA DE CIRCULARIDADE, declarada antes de qualquer numero. O gap E uma propriedade da DOS -- e a largura da regiao vazia em torno de E_F -- e o `DOS_VBM` so pode ser avaliado sabendo onde esta o VBM, isto e, sa...
bb86929e1e63196e2cd801e59f083b90f0e5d0a62a144adb2fe207aed6781ef3
Python
5,707
129
# Copyright 2021 HIP Applied Computer Vision Lab, 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...
76598a7d9bff35cf32469a4db72a1fb2d27c34959ccb62d3b9c38b39de2af541
Python
5,708
153
import copy from io import StringIO import re import tempfile import unittest from pathlib import Path from GMXMMPBSA.exceptions import InputError from GMXMMPBSA.input_parser import input_file class InputParserTest(unittest.TestCase): def _parse(self, contents): with tempfile.TemporaryDirectory() as tmpd...
c7c0a9a92952cd6777e11aa0341aed6d8836e67db6c33de80e31158d2b827be6
Python
5,710
158
import pandas as pd import numpy as np import random from itertools import combinations from scipy.stats import norm import matplotlib.pyplot as plt from tqdm import tqdm from collections import Counter, defaultdict """ This script measures how often pairs of chromatophores co-occur in the same cluster and compares th...
1560310b88c12a55f25014b84d4b7b5353f3f9d332f2e64bd32d9ce605af0ef8
Python
5,718
128
from typing import Union import torch from torch._dynamo import OptimizedModule from nnunetv2.training.lr_scheduler.warmup import Lin_incr_LRScheduler, PolyLRScheduler_offset from nnunetv2.training.nnUNetTrainer.nnUNetTrainer import nnUNetTrainer from torch.nn.parallel import DistributedDataParallel as DDP from nnun...
209f2dd17adc3c60ede7f0dcb05fef6abadbfef6a0b75f1566811b598d0c8bcd
Python
5,719
158
"""graph_utils.py https://github.com/RexYing/gnn-model-explainer Utility for sampling graphs from a dataset. """ import networkx as nx import numpy as np import torch import torch.utils.data class GraphSampler(torch.utils.data.Dataset): """ Sample graphs and nodes in graph """ def __init__( ...
3a7c82a7de4afaec5e91fb81b66c1128b255ed22f9681c5a32c859769ca21521
Python
5,720
120
import numpy as np from sklearn.decomposition import PCA from enigmatoolbox.datasets.base import load_summary_stats def cross_disorder_effect(disorder='all_disorder', measure=None, additional_data_cortex=None, additional_name_cortex=None, additional_data_subcortex=None, ...
7453844126caca306e18c7bbc0d5071bf7859a29bcbef1f9b6d025eed3e3a8c5
Python
5,720
149
# analysis script for the results from the BEM simulation #%% Imports import numpy as np import matplotlib.pyplot as plt font = { 'size' : 20} plt.rc('font', **font) #%% Plot parameters legendfontsize = 15 linewidth = 2.5 #%% The parameters used in the simulation jitlevels = np.array((1e-3,3e-3,1e-2)) #jitter l...
f9db325acce69c4d4899bdc4f397cc6513a1182933dc87713cae3111e0b647d7
Python
5,720
114
from typing import Tuple import numpy as np from batchgenerators.utilities.file_and_folder_operations import * from nnunetv2.evaluation.evaluate_predictions import load_summary_json from nnunetv2.paths import nnUNet_results from nnunetv2.utilities.dataset_name_id_conversion import maybe_convert_to_dataset_name, conve...
081b650881d8c78f9c7cdf4e737734157f9c96c59f69bad1002c7f61b9d35060
Python
5,722
191
""" This module contains data readers for the training of Garfield model. """ import os import numpy as np import pandas as pd import scipy from scipy.sparse import issparse, csr from glob import glob from anndata import AnnData from muon import MuData import muon as mu import scanpy as sc def read_mtx(path): "...
36799bec00ad4bef53bab5b9c50e13a828a77a33ec61cbee4f93b1a9ae5481eb
Python
5,723
169
import logging from pathlib import Path import anndata import numpy as np import pandas as pd import scanpy as sc import scipy import zarr from scipy.stats import gmean, rankdata from tqdm import tqdm from gsMap.config import CreateSliceMeanConfig # %% Helper functions logger = logging.getLogger(__name__) def get_...
3d160eb7c1123a4e969830b01b1f33bd094454559b3e0aeee17cc649af687a46
Python
5,724
169
import os import time import math import json import random import numpy as np import argparse import torch import torch.nn as nn from tqdm import tqdm from gnn_data import GNN_DATA from gnn_model import GIN_Net2, GIN_Net3 from utils import Metrictor_PPI, print_file def boolean_string(s): if s not in {'False', '...
846816e6b9d0cc65a1575ceace61b15c2082c20bacf6f4bc91f79098a4e107b7
Python
5,726
149
import json import numpy as np import cv2 from sklearn.preprocessing import LabelEncoder from msi_visual.normalization import total_ion_count, spatial_total_ion_count import numpy as np from PIL import Image import cv2 import xgboost as xgb import cv2 from sklearn.preprocessing import LabelEncoder from colle...
8ec384b9ea7cabb437070d363010b4ae8cc1c3d96d44952db19d7396d3ead592
Python
5,728
106
import vtk, qt, slicer import numpy as np from .Effect import AbstractEffect from ..Helpers import GridNodeHelper import WarpDrive class AbstractPointerEffect(AbstractEffect): def __init__(self, sliceWidget): AbstractEffect.__init__(self, sliceWidget) self.parameterNode = WarpDrive.WarpDriveLogic().getPa...
0c020524284e26cb15ee7ea485649cbfc8ff4b1dca2908c30854a064028b6f33
Python
5,731
175
from datetime import datetime import numpy as np from sklearn.decomposition import PCA from spacestream.core.feature_extractor import get_features_from_layer from spacestream.datasets.imagenet import imagenet_validation_dataloader from spacestream.datasets.nsd import nsd_dataloader from spacestream.utils.get_utils im...
990b37ec769e1fe1a9103e9e6d060a8b7de39e89c50955cee03f3d7620b3a860
Python
5,733
238
#!/usr/bin/python # Copyright (c) 2014 Kyle Lutz <kyle.r.lutz@gmail.com> # Distributed under the Boost Software License, Version 1.0 # See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt # # See http://boostorg.github.com/compute for more information. # driver script for boost.comp...
e810019460320b7860b413ed08cd6d91e545d914e28adcb552600fd638462757
Python
5,733
144
import argparse import pandas as pd import numpy as np from typing import List, Tuple def read_file(tsv_file: str) -> Tuple[List, pd.DataFrame]: """ Reads the input 4-column cosine similarity existing pairs TSV file in a pandas dataframe, generates all the unique PMIDs and returns the dataframe. Parame...
328380e78bc9aba086c7acd0983ea714485562c958909e77d06dd0dcdc794965
Python
5,735
135
""" @file dataset.py @author Simon Yu @date 02/15/2023 @brief NPC dataset class. """ import header import json import logger import os import PIL.Image import torch import utility def getIndicesFromLabelsAttribute(labels_attribute): labels_to_indices = {} for attribute in labels_attribute.keys(): ...
448b784a30e1bb2b2201baa9fda9fe7b0d415301f2a1f8bef36df4fce8ad1c5d
Python
5,737
148
#!/usr/bin/env python3 import pandas as pd import numpy as np import csv import argparse import gtfparse import multiprocessing REQUIRED_COLUMNS = [ "seqname", "source", "feature", "start", "end", "score", "strand", "frame", ] def make_attribute_column(row): attribute = '' fo...
91b97a16010c77665996592dee40dfcaf39900b540399a8053e317f3d84d1fa3
Python
5,738
153
""" Medical Image I/O Module This module provides a unified interface for loading and preprocessing medical images from various formats (NIfTI, DICOM) with automatic format detection. The main entry point is the `load_image()` function, which automatically detects the image format based on file extension or directory...
f2afe1a8de94b95e3451249555e2a40e164d36cafa6bb40b2e1d37c12555ec6e
Python
5,740
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. import logging import os import signal import threading import torch import torch.nn as nn from torch.nn.parallel import DistributedDataParal...
44cca8a73fd72750078ef59a9762dec677066350fd13ccc8fe98dd8d70305ab9
Python
5,742
144
import argparse import pandas as pd import numpy as np from typing import List, Tuple def read_file(tsv_file: str) -> Tuple[List, pd.DataFrame]: """ Reads the input 4-column cosine similarity existing pairs TSV file in a pandas dataframe, generates all the unique PMIDs and returns the dataframe. Parame...
766d4a2b9d25eadeb72d1921a5df3cd2576c3608b55fbd84ee13964adc1b2a45
Python
5,742
156
import logging import matplotlib.pyplot as plt import numpy as np import scanpy as sc import seaborn as sns from anndata import AnnData from lightning import Trainer from lightning.pytorch.callbacks import Callback from .._constants import Keys from ..model import Novae from .eval import heuristic, mean_fide_score fr...
2de9bb7a73a4778effc9e8456a2d45f6cb7ed8e303d94eef29762c34ce19d11e
Python
5,745
188
import json import os import tqdm from fairseq.data import Dictionary, data_utils def load_dictionary(dict_path): return Dictionary.load(dict_path) def load_dataset(split_path, src_dict): dataset = data_utils.load_indexed_dataset( split_path, src_dict, combine=False, # set to true fo...
70ff24d31b5c9ecc30e4284ca6281f2e187aa0efde8ba3e51a0e498395fd0355
Python
5,745
187
import os import subprocess from pathlib import Path import pytest class OneQMCProcessError(Exception): pass @pytest.fixture(scope="class") def project_root(): return Path(os.path.realpath(os.path.dirname(__file__))) / "../.." @pytest.fixture(scope="class") def train_workdir(tmp_path_factory): return...
35476c615357f40f2bbfe3858414f17be694becab703c33d5395b565e6e2a2ef
Python
5,751
144
"""Cross-element variance analysis for C, Si, Ge phase17 SZP campaigns. Tests the "carbon's privileged status" hypothesis: among group-14 elements, does the AIREBO/Tersoff vs DFT cross-lattice spread depend systematically on bonding flexibility (sp²/sp³ in C vs sp³ only in Si/Ge)? Inputs combined: C : phase 12 + 1...
8b7130fd7d720e78576712a24747ddf99072f378b3709699a4d1200b46da1bf5
Python
5,751
157
# 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 # # Unless required by applicable law or agr...
e3ed2af77407dc2f144c28c030751bc17f9c93293a7f4e31fd25df8cd62eb395
Python
5,752
180
import os from utils.mpr import MultipleProcessRunner from tqdm import tqdm class Downloader(MultipleProcessRunner): """ Download files that has unified resource locator """ def __init__(self, base_url, save_path, overwrite=False, skip_error_info=False, **kwargs): """ Args:...
8dd71dda24e830db3b362296b267d38a4ce0aec1197c7d11cf2fa5df59c1749f
Python
5,753
146
import numpy as np import matplotlib.pyplot as plt from pathlib import Path # Define paths base_dir = Path('/egor2/egor/MovieProject2') bttf_dir = 'backtothefuture' fd_file_pattern = 'motion_{subject_id}_enorm.1D' plots_dir = base_dir / "bids_data/derivatives/group_analysis" plots_dir.mkdir(parents=True, exist_ok=Tr...
4a8418d330f016cd61a70710ac65b70cb2282d086c46a0bb85c2250401d6b5ab
Python
5,754
158
import numpy from numpy import dot as _d from .. import MatrixManager2 from .. import MatrixManager ############################################################################### class GeneExpressionMatrixManager(object): def __init__(self, snp_covariance, model_manager): self.snp_covariance_manager = Ma...