sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
b7cb76a49d0b39df2371c203ec79e1363d53072ac096107bf98cb9edba26a9d3 | Python | 4,511 | 132 | import random
import warnings
from typing import Union
import torch
from torch import Tensor
from torchvision.transforms import RandomCrop, functional as F, CenterCrop, RandomHorizontalFlip, PILToTensor
from torchvision.transforms.functional import _get_image_size as get_image_size
from taming.data.helper_types impor... |
401e417492a3587c548620b3384da94fa88be0b1b16a0fec2f8900a40acf5fc9 | Python | 4,513 | 120 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
from typing import Iterable, Optional
from gufe import (
ChemicalSystem,
Component,
ProteinComponent,
SmallMoleculeComponent,
SolventComponent,
)
from .abstract_chemica... |
dfef3d94417f9034321c3d1111100e55aacd26a0fb69a9850dd2ce9ec67569df | Python | 4,513 | 140 | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
"""
DeepLab Training Script.
This script is a simplified version of the training script in detectron2/tools.
"""
import os
import detectron2.data.transforms as T
from detectron2.checkpoint import DetectionCheckpointer
from detectron2.config i... |
06c17f9cdc2c2b8bb2ee34d790b59ce591336f1afc46f71c44a405e84692d8af | Python | 4,517 | 163 | """
H01 Dataset
===========
<!-- difficulty: intermediate -->
Explore the H01 human cortex EM dataset.
The [H01 dataset](https://www.science.org/doi/10.1126/science.adk4858) contains 57,000 cells and 150 million synapses
from a cubic millimeter of the human temporal cortex, which is [proofread](https://h01-release.st... |
84859a2f30430cf3d32d3b3d8d3337e08ca337a7531b86f7c2b333064d617153 | Python | 4,519 | 141 | import argparse
import os
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.utils.data as data
from PIL import Image
from tensorboardX import SummaryWriter
from torch.autograd import Variable
from torchvision import transforms
from tqdm import tqdm
import net
from sampler import Inf... |
04854030cb763aa8c2ff0e43382943131be7a51937fd9cc3f7fa971a6152430a | Python | 4,526 | 115 | from typing import Any, Callable, Literal, Optional, TypedDict
from ..value_formatter import ValueFormatter
class Dependency[T](TypedDict):
path: str
transformation: Optional[Callable[[Any], T]]
class OptunaInt(TypedDict):
min: int | str | Dependency[int]
max: int | str | Dependency[int]
step: i... |
5cc64cc95e9a7e8709f26bea99e4fc1de9eec67be67a53b8c1302054a6cee81e | Python | 4,526 | 116 | import os
import h5py
import numpy as np
import matplotlib.pylab as plt
from python_scripts.laminarfMRI import cluster_permutation_test
data_path = "/Users/Tommy/all/eeg-fMRI/results"
for freq_sel in ['alpha', 'gamma']:
for preference in ['act', 'preferred', 'not_preferred', 'contrast']:
if freq_sel ==... |
843eb60f654cc7b4a42bf2da7eab740b723bb8f3e7a654436670f7114a3e4e96 | Python | 4,536 | 103 | """Default configuration for the TAPA pipeline."""
from dataclasses import dataclass
from typing import Optional, Set
@dataclass
class TAPAConfig:
# Directories
audio_dir: str = "audio/"
results_dir: str = "results/"
mfa_temp_dir: str = "mfa_temp/"
# Audio
sample_rate: int = 16000
# MFA... |
38a20975a1ad41a1c29b83ea0e2fb291848cfcfed8c31b91de321ebfbdd2243c | Python | 4,542 | 116 | #git clone https://github.com/animesh/DeepNovo-DIA
#USAGE: python deepMS.py
import tensorflow as tf
print("TensorFlow version: {}".format(tf.__version__))
import numpy as np
def parseMGF(mgfData):
data = open(str(mgfData), "r").read().splitlines()
_comments = '#;!/'
reading_spectrum = False
params = {... |
833c9bbbb0fe3355e550368a8af1d0340058852e91de44f13d9e72b5886436b0 | Python | 4,545 | 114 | import os
import shutil
from pathlib import Path
from typing import List
from batchgenerators.utilities.file_and_folder_operations import nifti_files, join, maybe_mkdir_p, save_json
from nnunetv2.dataset_conversion.generate_dataset_json import generate_dataset_json
from nnunetv2.paths import nnUNet_raw, nnUNet_preproc... |
e928a50ea74c17ff399897792439868b00eafa40ed725a8073e023cba4daee55 | Python | 4,547 | 154 | import warnings
from typing import Optional
import torch
import torch.nn as nn
from torch_geometric.nn import GATConv
from torch_geometric.nn.models import GCN
class GATLayer(nn.Module):
def __init__(
self,
in_channels: int,
out_channels: int,
num_heads: int = 1,
edge_dim:... |
6e089ca9d1b19b30630d769fc5c73156de3af365f36e06aaf479f45b286f093e | Python | 4,553 | 139 | """Pipeline fan-out over protonation states (Dimorphite enumeration mode).
A backend that returns several protonation states must produce one exported
structure per state, under suffixed access codes, without disturbing the
single-state path.
"""
from __future__ import annotations
import logging
import uuid
from pat... |
ae7bc7fd7855e615531c14f45487d4187c2b4236707827cf7d7ed0ecdb75d106 | Python | 4,553 | 174 | import ast
from pathlib import Path
import numpy as np
import pandas as pd
import pytest
from rdkit import Chem
from torch.utils._pytree import GetAttrKey, register_pytree_node
from chemprop.data import BatchMolGraph
_DATA_DIR = Path(__file__).parent / "data"
_DF = pd.read_csv(_DATA_DIR / "smis.csv")
_DF["mol"] = _D... |
ca4f1874b195fa5ff84ce2db50e3421192aa53b523fcb2ff27ded462b8b936e1 | Python | 4,556 | 118 | #!/usr/bin/env python
############################################################################
# Copyright (c) 2022-2026 University of Helsinki
# # All Rights Reserved
# See file LICENSE for details.
############################################################################
"""Train the XGBoost peak-filter used ... |
8f510cd13258cc91bd1ad718e996d697479dcef4412d05da2b692ebd6ecf07c8 | Python | 4,557 | 123 | #!/usr/bin/env python3
#
# Copyright (c) 2016 10x Genomics, Inc. All rights reserved.
#
from __future__ import annotations
import argparse
import os
import sys
def make_parser():
parser = argparse.ArgumentParser(
description="Translate paths that link to pipestances or bcl2fastq paths to analysis pipeli... |
5d275b036424fd3757aae690d378f3e5b494bfc6ae0f48ff3676c6d273487e04 | Python | 4,559 | 105 | import os, re
import numpy as np
import pandas as pd
from loguru import logger
logger.info('Import OK')
def norm_control_plex(peptides, sample_cols, pooled_col, standard_vals):
""" Normalises per peptide according to control channel. Returns df with updated sample cols and removes control channel"""
pooled_... |
6c9dc7fb361e0644f1addab8d954b4485b311356047a65932ed6ef12095bb28c | Python | 4,564 | 123 | """Original CW-Net model definitions that ran on the autonomous vehicle.
These are the serial and parallel CW-Net architectures described in the paper
(Fig. 2 / Extended Data Fig. 1), excerpted from the on-vehicle code with only
light edits (the imports below, this docstring, and a spelling fix), so the
file can be im... |
0148a731611f38572d0c15350faf59806121d2c310fe10dc5f32fb28ab478969 | Python | 4,569 | 117 | import pathlib
from unittest import mock
import pytest
from gufe.storage.errors import ChangedExternalResourceError, MissingExternalResourceError
from gufe.storage.externalresource import FileStorage
from gufe.storage.externalresource.base import Metadata
from openfe.storage.metadatastore import JSONMetadataStore
fro... |
2d68def221293c4ef00fe90e0d569e8103c45b01e510db2b2b46c741109c094e | Python | 4,572 | 123 | #
# Copyright (c) 2022 10X Genomics, Inc. All rights reserved.
#
"""Utility functions for dealing with altair plots."""
import altair as alt
import pandas as pd
from pandas.api.types import is_bool_dtype, is_datetime64_any_dtype, is_numeric_dtype
LAYER = "layer"
HCONCAT = "hconcat"
VCONCAT = "vconcat"
DATA = "data"
... |
15e66c899b6e3c49be0334a70c0275b09e94c6b2752537eee75be64408b96746 | Python | 4,574 | 55 | #!/usr/bin/env python3
"""Fill review/bundle.json after `paper_bundle.py prepare`: source roles and
titles, package notes, and the curated navigation index."""
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
B = ROOT / "review" / "bundle.json"
ROLES = {
"s001-psyp70385-main": ("mai... |
0ae047d4e0429ff4cc6c76c5b667df49407d85e1254073fe6176126cc85a2e7e | Python | 4,580 | 131 | """Tests for reading neurons from URLs.
These use a local HTTP server (see the `http_server` fixture in conftest.py) and
so do not touch the actual network.
Historically the parallel URL path handed the *downloaded bytes* - rather than
the URL - to the reader. That meant `parse_filename` never ran, so neurons came
ba... |
59d6ba9d3471a6cb04dc0f4f9ebc6b21a6e90d7686c81f62ba0a11dc8f676831 | Python | 4,580 | 133 | import numpy as np
from sklearn.base import BaseEstimator
from sklearn.feature_selection import SelectorMixin
from sklearn.utils.validation import check_is_fitted
def remove_low_info_samples(X, threshold=1.0):
"""Removes low info samples
A sample is considered to have sufficient info if the nan fraction is b... |
5707ea81a41f6fee936da84ec620b47afc3622842deab1176ec67ab15c4f4d32 | Python | 4,581 | 115 | import os
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.lines import Line2D
from tristan_pipeline.utils.loading_utils import *
from tristan_pipeline.utils.preproc_utils import *
from tristan_pipeline.utils.plotting_utils import *
onav_marker = 'D'
onav_linewidth = 2.0
onav_alpha = 0.3
# ---------... |
dfa3a8a9716c63049bf7820d6952a395911a8ddf2814cb7b394b9fba82aec0d6 | Python | 4,584 | 115 | import torch
import torch.utils.data
from torch import nn, optim
from torch.nn import functional as F
# from torchvision import datasets, transforms
import collections
import sys
from torch.utils.data import TensorDataset, DataLoader
from sklearn.model_selection import train_test_split
from AE.utility import create_act... |
416853ca38ade65b3cb904d96aab0ad131f7cea852535c2b63ab4ca11e82f8c7 | Python | 4,586 | 119 | from __future__ import annotations
from dataclasses import dataclass
from pathlib import Path
from typing import Any
from rdkit import Chem
from rdkit.Chem import AllChem
class PDBQTExportError(Exception):
"""Raised when PDBQT export fails."""
@dataclass(slots=True)
class PDBQTWriter:
"""Writes RDKit mole... |
9e5d6fcded2456f453610753c8e2134032ed938d0380b52c1837141a175eb6d2 | Python | 4,589 | 135 | from itertools import product
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.cm import get_cmap
from matplotlib.colors import LogNorm
from pathlib import Path
import torch
from tqdm import tqdm
import numpy as np
from . import config
from .utils.condition import AttackParamsLoader, Conditio... |
009c4d363d63e6315d87b16f8834dffe31bbee38df1f12366c675530ad7d615f | Python | 4,592 | 103 | #!/usr/bin/env python
# Copyright 2017-2018 Biomedical Imaging Group Rotterdam, Departments of
# Medical Informatics and Radiology, Erasmus MC, Rotterdam, The Netherlands
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obt... |
1f033f4432bb6fd44d83c6da4b35d764dd1e1ff9507d15b04ee97f135779a4bb | Python | 4,593 | 128 | """EEG Separate Classification & SVM Evaluation Script"""
import os
import random
import numpy as np
from pathlib import Path
import torch
import torch.backends.cudnn as cudnn
from eeg_visual_classification.utils.lib import (
create_parser, extract_model_options, get_dataloaders, get_model_hash,
load_checkpoin... |
6d6d39e5b079d691290bde4bee4ae699ac9c72381d0a50dbbcce4d92408fb2f7 | Python | 4,598 | 146 | import torch
import numpy as np
import pandas as pd
from torch import nn
from torch.utils.data import DataLoader
from torch.utils.data import Dataset
from torch.autograd import Variable
import numpy as np
import math
import argparse
from Bio import SeqIO
# Data paths
trainPath = "../AMP_dataset/raw/train.txt"
valPath ... |
11a86f03f38eae8679f4e6e2ddeb4440d3cc76c4a6917fe8641ea3654b20845d | Python | 4,602 | 111 | from typing import Iterable
from hsnn.analysis.png.db import PNGDatabase
from hsnn.analysis import ResultsDatabase
from hsnn.cluster import tasks
from hsnn.core.logger import get_logger
__all__ = [
'detect_pngs',
'detect_unconstrained_pngs',
'detect_significant_pngs'
]
logger = get_logger(__name__)
def... |
fb350329ed50d543091590cb52e377f27fc1a4173f8df5bf7bacb546b9f05c62 | Python | 4,603 | 139 | #python pepCleave.py L:/promec/FastaDB/UP000005640_9606_unique_gene.fasta 10 30
import sys
import pickle
from collections import Counter
def read_fasta(file_path):
"""
Simple FASTA parser generator.
Yields (description, sequence).
"""
with open(file_path, 'r') as f:
description = None
... |
120aea2ee6b55f628d23e42301472f95dcd0dfa461764f66b856f23bc3e4a09e | Python | 4,604 | 141 | #!/usr/bin/env python
# Copyright (c) Facebook, Inc. and its affiliates.
"""
Training script using the new "LazyConfig" python config files.
This scripts reads a given python config file and runs the training or evaluation.
It can be used to train any models or dataset as long as they can be
instantiated by the recurs... |
47cb3187d11e1c58bf4c8297018e74282269171d41e4f119779f264cf191fee3 | Python | 4,607 | 94 | """Regenerate the Open Race benchmark results.
Runs the eight (surrogate x difficulty) combinations across the six datasets.
Each optimizer gets a fixed budget of S=200 evaluations starting from R=10 random
points; the recorded quantity is the best objective value found so far. Uses the
14-optimizer pool, 10 competiti... |
810db7db3db7c9ddfd839219042a464a4589d94ff12aecdba1b1941e91deee54 | Python | 4,610 | 140 | import math
from enum import Enum
import mesa
class CitizenState(Enum):
ACTIVE = 1
QUIET = 2
ARRESTED = 3
class EpsteinAgent(mesa.discrete_space.CellAgent):
def update_neighbors(self):
"""
Look around and see who my neighbors are
"""
self.neighborhood = self.cell.get... |
aa48f5194cd4538ffc5f415efe7a11dd1d7e68478cdae9c665d12b9ff81b043c | Python | 4,611 | 123 | # This script is part of navis (http://www.github.com/navis-org/navis).
# Copyright (C) 2017 Philipp Schlegel
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of... |
817a62055cc69f93aa6cdec2d298771ff3a6bf17a120d4edfe7ad78cd813fa9a | Python | 4,625 | 130 | import ast
from pathlib import Path
from lightning import pytorch as pl
import numpy as np
import pandas as pd
import pytest
from chemprop import data, featurizers, models, nn
@pytest.fixture
def dataloader():
pl.seed_everything(0)
data_dir = Path(__file__).parent.parent / "data" / "mol_atom_bond"
df_in... |
e4dfb4c2c90dfa776cdf60b252d362d9d2a6c8c4e01c2459c26591a54fd5dd53 | Python | 4,627 | 142 | #!/usr/bin/env python
#
# Copyright (c) 2018 10X Genomics, Inc. All rights reserved.
#
"""Simple Good-Turing estimator.
Based on S implementation in::
William A. Gale & Geoffrey Sampson (1995) Good-turing frequency estimation without tears,
Journal of Quantitative Linguistics, 2:3, 217-237, DOI: 10.1080/09296179... |
5f9599bb2a213fe8a0a9ce579a9ec63d820fe66f1c7849605251c3ebc52051af | Python | 4,628 | 119 | """Run the paired KNN versus median/mode GA-BPNN sensitivity workflow.
The wrapper is deliberately sequential: each split is independent, while the
GPU-intensive GA fitting remains isolated in its established worker scripts.
Completed split outputs are skipped by those workers and can be resumed safely.
"""
from __fu... |
6663048878fa302fe78e6fdaaec583eae2fdb56d0eda0a5315c447959974a06f | Python | 4,636 | 146 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
import pathlib
import pytest
from gufe.protocols import execute_DAG
from openff.units import unit
from openfe.protocols import openmm_md
@pytest.mark.integration
@pytest.mark.parametrize(... |
8b9c29aa15412cf37f0e5407ab8c7825c7d203f41474822d9dc2b59ec063ebc5 | Python | 4,640 | 134 | import os
import numpy as np
import albumentations
from torch.utils.data import Dataset
from taming.data.base import ImagePaths, NumpyPaths, ConcatDatasetWithIndex
class FacesBase(Dataset):
def __init__(self, *args, **kwargs):
super().__init__()
self.data = None
self.keys = None
def ... |
19de3fc3e9cd8ae22a9f63f9236f9a2215bbf85c11d3075b108991f24abe54dd | Python | 4,641 | 88 | import os
import sys
from argparse import ArgumentParser
import numpy as np
import pandas as pd
import scanpy as sc
import torch
import pytorch_lightning as pl
from pytorch_lightning.callbacks.model_checkpoint import ModelCheckpoint
from pytorch_lightning import loggers as pl_loggers
sys.path.append("/home/nomura/Proj... |
ebed94079cca0bda9aa379a48b24cc40a21515891a5956302806cd62dc6c78df | Python | 4,644 | 151 | """Create train/val splits by partitioning category IDs from train rows.
This script updates only rows currently labeled as ``train`` in a CSV file.
Rows in other split groups (e.g. ``benchmark``) are left unchanged.
"""
import argparse
import random
from pathlib import Path
import pandas as pd
from loguru import lo... |
82eb239feb335e462039334a1be3b1bf148c1d0c86957d03b4b6dc58eb1f9aef | Python | 4,646 | 121 | from __future__ import annotations
from abc import ABC, abstractmethod
from enum import Enum
from typing import Any, Dict, Optional, Sequence, Type
import numpy as np
from brian2 import CodeRunner, Network, Group, NeuronGroup, SpikeMonitor, \
StateMonitor, Synapses, Equations
from brian2.units import hertz
from ... |
f58384db4b60254509aa9f878aec28b837995881c82b9092aa62845c634034b5 | Python | 4,646 | 158 | # -*- coding: utf-8 -*-
"""
Created on Mon Aug 29 10:31:26 2022
@author: Joseph Vermeil
MainAnalyzer_##.py - Script to use the TrackAnalyzer program.
Please replace the "_NewUser" in the name of the file by "_##",
a suffix corresponding to the user's name (ex: JV for Joseph Vermeil)
Joseph Vermeil, 2022
This progra... |
1b1da71f7bb62b75495b455180ec68741244df56e4230044aefb39d112ff6fb0 | Python | 4,649 | 141 | import numpy as np
import torch
import torchvision.transforms as TV
import torchaudio.transforms as TA
import torch.nn as nn
import scipy.signal as sig
from functools import reduce
from math import isnan
import torch
import torch.nn.functional as F
def compute_spectrogram(signal: torch.Tensor, window_size: int = 128... |
d4b4ce7dd000abef42fd00b9259f1759e3166536dfa321b1ec830896b7cb72bb | Python | 4,656 | 143 | """Tests for the portrayal components in Mesa visualization."""
import re
from dataclasses import is_dataclass
import pytest
from mesa.visualization.components import AgentPortrayalStyle, PropertyLayerStyle
def test_agent_portrayal_style_is_dataclass():
"""Test if AgentPortrayalStyle is a dataclass."""
ass... |
0ce7d02e6032d809a180a5fb46a7e3ec1a05bb93594d86f0ec5cd98469869e82 | Python | 4,658 | 136 | from __future__ import annotations
import argparse
import logging
from pathlib import Path
from typing import Any
import pytest
from hypothesis import given
from hypothesis import strategies as st
from snakebids.plugins.pybidsdb import Pybidsdb
from snakebids.utils.utils import DEPRECATION_FLAG
from tests import str... |
67fa51c264e68fe1f820df4cb0d206b7f867fd0ae833c73b7caab4e3b8115aa3 | Python | 4,667 | 97 | # -*- coding: utf-8 -*-
"""
Using spatial null models
=========================
This example demonstrates how to use spatial null models in
:mod:`neuromaps.nulls` to test the correlation between two brain
annotations.
"""
###############################################################################
# The brain—and ... |
5fae9baf416cffa5522db30af643fe8c92190fb92de59f3f4f5cdcb879d6b972 | Python | 4,668 | 122 | # Copyright (c) Facebook, Inc. and its affiliates.
import json
import os
import tempfile
import unittest
from detectron2.utils.events import (
CommonMetricPrinter,
EventStorage,
JSONWriter,
get_event_storage,
has_event_storage,
)
class TestEventWriter(unittest.TestCase):
def testScalar(self):... |
c78f870ffd7f39c2c212822582ef44c35dd0414173dd253e0fc051b2dcd007cf | Python | 4,669 | 93 | import cv2 # type: ignore
import numpy as np
import time
import tifffile
from tifffile import TiffFile
import os
def find_frame_of_image(query_image, search_space=[], save_machine_readable_output=True, machine_readable_output_filename='search_result_mr.txt'):
"""Finds the frame number of query_image within search_... |
3ff43c0c218f80eced889dc7181164e2652011ed8e40b2b55539897dda511f36 | Python | 4,671 | 146 | import os
import pandas as pd
import numpy as np
import scanpy as sc
import scib
from scib.metrics import kBET
base_eval = "PATH_TO_BASE_EVAL_DIR/"
unintegrated_path = "PATH_TO_UNINTEGRATED_COMBINED_ADATA_H5AD"
result_dir = os.path.join(base_eval, "result_metrics")
os.makedirs(result_dir, exist_ok=True)
METHODS = {
... |
b93630d05b49b046889ba40cc9050ac8b405f2737830f2c449fc9908ee404a30 | Python | 4,675 | 168 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
import json
import gufe
import pytest
from gufe.tests.test_tokenization import GufeTokenizableTestsMixin
from openfe.protocols import openmm_septop
@pytest.fixture
def protocol():
ret... |
ec52d92850e1f8251d3809764de92b9cc69e262836bb59ab1b33bf5106663cee | Python | 4,679 | 124 | #!/usr/bin/env python
# Copyright 2016-2023 Biomedical Imaging Group Rotterdam, Departments of
# Medical Informatics and Radiology, Erasmus MC, Rotterdam, The Netherlands
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obt... |
6358a2c6887558178c751cb288fcde88739f7d057d95758306fdc6a660df1d4b | Python | 4,680 | 107 | #python "c:\Users\animeshs\OneDrive\Desktop\Scripts\compareFastq.py" "F:/reads/TK9_1_22FFLLLT3_AGAGAACCTA-GGTTATGCTA_L005__1.fq.gz" "F:/fastq/SRR31089076_1.fastq.gz"
#for %R in ("F:\reads\TK9*_1.fq.gz") do for %F in ("F:\fastq\SRR31089076_1.fastq.gz") do python compareFastq.py "%R" "%F"
import sys, os, gzip, time, pla... |
fa6fc9f661eb566d688ac8ebac87f6668dc6e0ca426cec475ae7480462f7a5a5 | Python | 4,680 | 171 | import logging
from abc import ABC, abstractmethod
class _BaseLogFilter(ABC):
"""Base class for log filters that handle string or list of strings.
Parameters
----------
strings : str or list of str
String(s) to use in the filter logic
"""
def __init__(self, strings: str | list[str]) ... |
59110a5582ea21ee3fc255c57457136512d1d34d5ede009002ba4527ccc74ffd | Python | 4,682 | 132 | import numpy
import numpy.random
import numpy.fft
def generate_surrogate_iaaft(original_data, M = 1, detrend = False, verbose = True):
"""
surrogate_data = generate_surrogate_iaaft(original_data, M = 1, detrend = False, verbose = True)
Generates, by means of the Iterative Amplitude Adjusted Fourier Transform
(I... |
1a28d0914f1dd874d5d47c63960f2068aff281ce17d0b9746f470363bb9eb585 | Python | 4,686 | 145 | """Tests for the pre-2.0 neuron class names.
navis 2.0 renamed `TreeNeuron`/`MeshNeuron`/`VoxelNeuron` to `Skeleton`/`Mesh`/
`Voxels`. The old names have to keep working for a while, and the point of these
tests is that they keep working *as aliases* - downstream code does
`isinstance(x, navis.TreeNeuron)` and `class ... |
3977ce16bd52821f66457cf72e5cc3238c9d0e597f19245e72dbfa5bd341f18c | Python | 4,689 | 137 | # -*- coding: utf-8 -*-
"""Functionality for plotting."""
import matplotlib
from matplotlib import colors as mcolors, pyplot as plt
from mpl_toolkits.mplot3d import Axes3D # noqa
from nilearn.plotting import plot_surf
import numpy as np
from neuromaps.datasets import ALIAS, fetch_atlas
from neuromaps.images import l... |
e260a437360df5b64f2279c283c12b255abc75927d52546fc7fb90987a1745e5 | Python | 4,689 | 104 | from abc import ABC, abstractmethod
from typing import Type
import numpy as np
from numpy import number
class ImageNormalization(ABC):
leaves_pixels_outside_mask_at_zero_if_use_mask_for_norm_is_true = None
def __init__(self, use_mask_for_norm: bool = None, intensityproperties: dict = None,
... |
a58794f8c40a12e0cf8471693e49a0facc9bcc6e4b74f33696c3d9f7820da1dd | Python | 4,699 | 130 | import torch
from torch.nn import Dropout, Parameter, Softmax, Sigmoid
from torch.nn.init import xavier_uniform_, constant_, xavier_uniform_, calculate_gain
from torch_geometric.nn import GCNConv,Linear
import torch.nn.functional as F
from torch_sparse import SparseTensor, fill_diag, matmul, mul, spspmm, remove_diag
fr... |
814a5aaa0caaefcb49c51f9e2729c5e5ad6c1faf48e639cb79ebd19cd8a00841 | Python | 4,706 | 109 | #!/usr/bin/python3
##################################################################################
#
# MIT License
#
# Copyright (c) 2025 Kevin Rockenbach, Agnieszka Golicz
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "So... |
6a88796d7ee0dc9c2d0b7508cb565b19e42fcd0ff2c7f6f0fdf4c4523e0cfe1f | Python | 4,707 | 132 | import os
import sys
import optuna
from src.rnn.main import main_rnn
import argparse
import copy
sys.path.append(os.path.abspath(
os.path.join(os.path.dirname(__file__), '../../')))
from src.hyperparameter_search.search_space.search_space import SearchSpace
from src.hyperparameter_search.search_space.optuna_search_... |
3efbb747ccbfd506033958a15d815ce1f07f14d28b2d0452bc7cd720a3a61c88 | Python | 4,708 | 119 | import os
import torch
import joblib
import numpy as np
import argparse
from tqdm import tqdm
import sys
class MLPRegressor(torch.nn.Module):
def __init__(self, seq_length, input_size, output_size):
super(MLPRegressor, self).__init__()
self.flatten = torch.nn.Flatten()
self.fc1 = torch.nn.S... |
daefe6b1271949a7db5616bae6fa2889949629e066c06d2c8b3798f19113475c | Python | 4,716 | 143 | from pathlib import Path
from lightning import pytorch as pl
import numpy as np
import pytest
import torch
from torch.nn import Identity
from torch.utils.data import DataLoader
from chemprop.conf import LIGHTNING_26_COMPAT_ARGS
from chemprop.data import MoleculeDatapoint, MoleculeDataset, collate_batch
from chemprop.... |
4ba3c10d47a8bfad4bdc703355e8a29b7538c1b60008b2673f36df0056816173 | Python | 4,723 | 128 | #!/usr/bin/env python
#
# Copyright (c) 2023 10X Genomics, Inc. All rights reserved.
#
"""Analyze cell types generated from CALL_CELL_TYPES."""
import json
import os
import h5py
import martian
import cellranger.cell_typing.broad_tenx.cas_metrics as cas_metrics
import cellranger.cell_typing.common_cell_typing as com... |
6775fc80fbc114f535c43dccc291f445e9c602cf93b08f224591f5a096694c09 | Python | 4,723 | 120 | # Copyright (c) Facebook, Inc. and its affiliates.
import logging
import unittest
import torch
from detectron2.config import get_cfg
from detectron2.layers import ShapeSpec
from detectron2.modeling.anchor_generator import DefaultAnchorGenerator, RotatedAnchorGenerator
logger = logging.getLogger(__name__)
class Test... |
1761f07bccb6734104bd8504fb43540168c15497b246f7ab463b8643329b8404 | Python | 4,731 | 110 | """
Neuroglancer & CloudVolume
==========================
<!-- difficulty: intermediate -->
Pull neurons and meshes from Neuroglancer sources via CloudVolume.
[Neuroglancer](https://github.com/google/neuroglancer) is a WebGL-based viewer for volumetric data. You may have used it to browse
some of the recent large EM ... |
1bf2dad169e4196b76fbe001afb09d7892b8698d7591f8f825ced53e3c1e65d6 | Python | 4,734 | 119 | #!/usr/bin/env python
# Copyright 2016-2019 Biomedical Imaging Group Rotterdam, Departments of
# Medical Informatics and Radiology, Erasmus MC, Rotterdam, The Netherlands
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obt... |
61e6186156ff77118677418bb611a3f4d4091b0b809dbdbbc44e98d1a32a1514 | Python | 4,739 | 97 | # python peptideGroupsCombine.py L:\promec\TIMSTOF\LARS\2024\241002_zrimac\NEW\mqparTTPdda.xml.1729155225.results
# wget https://www.python.org/ftp/python/3.12.0/python-3.12.0-amd64.exe
# %% data
# rsync -Pirm --include='Phospho (STY)Sites.txt' --include='*/' --exclude='*' ash022@login.saga.sigma2.no:scripts/mqparTTPdd... |
5a615a98e211b6c191f1a96cd6a5beea60b9411e7153bd4b95dab5aca57b54c0 | Python | 4,745 | 146 | from __future__ import annotations
import os
import sys
from pathlib import Path
from src.utils.config import PROJECT_ROOT
def runtime_root() -> Path:
if getattr(sys, "frozen", False):
return Path(getattr(sys, "_MEIPASS"))
return PROJECT_ROOT
def resolve_runtime_path(*parts: str) -> Path:
retu... |
d8b6ba4cd5d45b0f43eae3d9a951207c7ae48f17d36dc78f816a988699ad9e41 | Python | 4,746 | 121 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# pyre-unsafe
import random
from typing import Tuple
import torch
from torch import nn
from torch.nn import functional as F
from detectron2.config import CfgNode
from densepose.structures.mesh import create_mesh
from .utils import sample_random... |
08f821c44e72089efe4594ea47c180405badbb89089df045ecff239e4b80e68b | Python | 4,756 | 136 | """Tests for the memory-efficient `graph._geodesic_nearest` helper and its use in
`split_axon_dendrite` for assigning orphan nodes to the nearest labeled node.
"""
import navis
import numpy as np
import pytest
from navis import graph
from navis.graph import graph_utils as gu
@pytest.fixture
def neuron():
retur... |
d1160c131057c205e4df51c00e31937137acc292a6ed81c0e83045863c7998c5 | Python | 4,768 | 131 | import torch
from torch import Tensor
from typing import List, Union
from .base import BaseVAE
from .modules import RNNDecoder, Upsampling
from ..common.constants import convert_ids2seqs, convert_seqs2ids, get_token2id, VOCAB
class GruVAE(BaseVAE):
def __init__(
self,
expected_kl: float,
... |
004072151c911febd1fe925d10c148302fe92c1dea853ceb5ea9274b6bc9cc14 | Python | 4,776 | 117 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# pyre-unsafe
from typing import Any, List
from torch import nn
from detectron2.config import CfgNode
from detectron2.structures import Instances
from .cycle_pix2shape import PixToShapeCycleLoss
from .cycle_shape2shape import ShapeToShapeCycleLo... |
1cfca04205f0b647da271809c3011b0f0c2fc920e1e847c79b270ee138f9de02 | Python | 4,777 | 157 | import os, hashlib
import requests
from tqdm import tqdm
URL_MAP = {
"vgg_lpips": "https://heibox.uni-heidelberg.de/f/607503859c864bc1b30b/?dl=1"
}
CKPT_MAP = {
"vgg_lpips": "vgg.pth"
}
MD5_MAP = {
"vgg_lpips": "d507d7349b931f0638a25a48a722f98a"
}
def download(url, local_path, chunk_size=1024):
os.... |
73f9afebef57ff23c28daeda078e86c0e08a24c89fb329900dd2a57f934bd4dc | Python | 4,781 | 156 | # -*- coding: utf-8 -*-
"""
Created on Mon Apr 26 16:21:04 2021
@author: Younes Valibeigi
"""
import csv
import numpy as np
import matplotlib.pyplot as plt
names = ['Apr 30, 2021 5-07-39 PM_FR30Proj10.csv',
'Apr 30, 2021 4-42-12 PM_FR30Proj20.csv',
'Apr 30, 2021 7-33-35 PM_FR30Proj30.csv',
... |
2f39ba877a8fab619ca6eb7161e515594e788d11afda6fb9c0cdc562962de2fd | Python | 4,786 | 107 | import torch
from typing import Optional
import MDAnalysis as mda
from rdkit import Chem
from rdkit.Chem import rdDetermineBonds, rdPartialCharges
NUTMEG_MODEL_FILE = "/home/lukas/Documents/nnpot/models/nutmeg-small-raw.pt"
def gasteigerChargesFromGroFile(gro_file, total_charge=0):
""" Attempts to read a .gro fil... |
1dd44680d67bb97f6334c5dd2c96a5bc0e6227515eff0b3bfd88a948e9d54c75 | Python | 4,788 | 142 | import shutil
from pathlib import Path
import os
import re
import json
from datetime import datetime
def create_folder(folder_path):
folder = Path(folder_path)
# if folder.exists() and folder.is_dir():
# shutil.rmtree(folder)
folder.mkdir(parents=True, exist_ok=True)
def file_... |
3f9f8d677d3744e149128b3f739edd911f957fb827a0aad0b6721d72f6831b75 | Python | 4,792 | 136 | from pathlib import Path
from typing import List, Dict
from dataclasses import dataclass
import numpy as np
import torch
import torchvision.transforms as transforms
import matplotlib.pyplot as plt
from . import config
from .utils.activation_manager import ActivationManager
from .utils.pgd_attack import AttackParams
f... |
b74e207550d209f851d3887557376ddd13f98a13bf3c681b03e792a786d0efd9 | Python | 4,797 | 100 | # 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... |
33db48dd3c518e7ee4ca12f2bdf97f19f0f1bb1985005171e8296859027c649e | Python | 4,800 | 117 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
import pathlib
import pytest
from openff.units import unit as offunit
import openfe
from openfe.protocols.openmm_afe import AbsoluteBindingProtocol
from openfe.protocols.openmm_utils.charge... |
7dd198cb641bbc0352b652f267fa4e8f1ab9e9f5ccd74f921e558894dc892313 | Python | 4,801 | 100 | import os
import numpy as np
import nibabel as nib
import matplotlib.pyplot as plt
from tristan_pipeline.utils.plotting_utils import *
from tristan_pipeline.utils.analysis_utils import *
from tristan_pipeline.io.params import *
from nilearn.glm import threshold_stats_img
from nilearn import surface, plotting, datasets
... |
ebc33e89ebea85277b7de82f3c42aae33a01eb1bf535962569208186d4e27fe6 | Python | 4,810 | 125 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import copy
import logging
import numpy as np
from typing import List, Union
import torch
import detectron2.data.detection_utils as utils
import detectron2.data.transforms as T
from detectron2.config import configurable
from .detection_utils impor... |
37305f6b8e0149eb6cd7608f63bf47b20a83fabedde63bf13639cb1f1fe4a088 | Python | 4,813 | 120 | from typing import Union
import torch
from torch.utils.data import DataLoader
import numpy as np
from tqdm import tqdm
from .decomposition_handler import V
class ActivationManager:
def __init__(self, model, device):
self.model = model
self.device = device
def get_activation(self, input: V, ... |
c42b763519463a94f9ef2585b97b4618821804e53b45a389cd655adbb6740e49 | Python | 4,816 | 110 | # Copyright (c) Facebook, Inc. and its affiliates.
# pyre-unsafe
import random
from typing import Optional, Tuple
import torch
from densepose.converters import ToChartResultConverterWithConfidences
from .densepose_base import DensePoseBaseSampler
class DensePoseConfidenceBasedSampler(DensePoseBaseSampler):
""... |
a69dd8c0a5737ca3f6127f5c608373d9855e86cb18606af8d7e4822f8ee4dc59 | Python | 4,820 | 110 | import multiprocessing
import shutil
import SimpleITK as sitk
import numpy as np
from tqdm import tqdm
from batchgenerators.utilities.file_and_folder_operations import *
from nnunetv2.dataset_conversion.generate_dataset_json import generate_dataset_json
from nnunetv2.paths import nnUNet_raw
def copy_BraTS_segmentati... |
adb330e9aaa079cf0ff23e398f4b59b712b158b9725acfa4f2f2f2751f6a5587 | Python | 4,820 | 110 | import multiprocessing
import shutil
import SimpleITK as sitk
import numpy as np
from tqdm import tqdm
from batchgenerators.utilities.file_and_folder_operations import *
from nnunetv2.dataset_conversion.generate_dataset_json import generate_dataset_json
from nnunetv2.paths import nnUNet_raw
def copy_BraTS_segmentati... |
5f43415a5fcf05e1447cbfdf91bca6089ac3739c084c4c736cc492cb96c57248 | Python | 4,829 | 159 | """
VTK read/write filters for Gifti (.surf.gii).
"""
# Author: Oualid Benkarim <oualid.benkarim@mcgill.ca>
# License: BSD 3 clause
import numpy as np
from vtk import vtkPolyData
from vtk.util.vtkAlgorithm import VTKPythonAlgorithmBase
from ..decorators import wrap_input
from ...mesh.mesh_creation import build_poly... |
f5dcb71cd27295ebab9e656fa2e580df6f370edccfa2641fbf8d6280bac848db | Python | 4,829 | 137 | """Fig 5I-M: Tracked PL and NPL unit templates, P(spike), and firing rate.
Horizontal templates (4 channels) across 3 sessions (Weeks 1, 2, 4).
P(spike) and firing rate in 2x3 grid. Matches original tracked_units.py.
Usage:
python python/fig5/tracked_units.py
"""
import sys
from pathlib import Path
sys.path.inser... |
a5d51b96b04084fd01266a881e508acee915571430293d46c98dc22291b767ac | Python | 4,836 | 151 | """
Simulator of graphons
Reference:
Chan, Stanley, and Edoardo Airoldi.
"A consistent histogram estimator for exchangeable graph models."
In International Conference on Machine Learning, pp. 208-216. 2014.
"""
import cv2
import matplotlib.pyplot as plt
import numpy as np
from typing import List
def synthesize_grap... |
6197cd8651385fcde4e8a1d3d6ada408f60df920b735167dab477181007b86ff | Python | 4,838 | 88 | from __future__ import annotations
from dataclasses import dataclass
@dataclass(frozen=True, slots=True)
class MopacMethodInfo:
keyword: str
title_en: str
title_pt: str
description_en: str
description_pt: str
COMMON_MOPAC_METHODS: tuple[MopacMethodInfo, ...] = (
MopacMethodInfo(
key... |
f48c5e4290ea8aada0ff6ac15d31c97ccd9d714b7e22b85b4aa22a6503ec67e3 | Python | 4,840 | 130 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# pyre-unsafe
import logging
import numpy as np
import pickle
from enum import Enum
from typing import Optional
import torch
from torch import nn
from detectron2.config import CfgNode
from detectron2.utils.file_io import PathManager
from .vertex... |
a10b95ecc88dac10a6fde3a507a811e55d237ac589dfaf401dd6e23b0004c7d3 | Python | 4,841 | 123 | """Longitudinal analysis and plotting utilities.
Plot metrics over weeks with early vs late comparisons.
"""
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from scipy.stats import mannwhitneyu
from matplotlib.collections import PathCollection
from .plotting import sig_text, rank_biserial_r
... |
bdc6c5aa124594b78e1844940d918116f80f760ee077905fd71f938b9291591b | Python | 4,847 | 123 | #!/bin/python
"""
Script for registering and processing ASAP snRNA-seq samples for the Amygdala (AMY) region.
Workflow steps:
1. Load the region-specific sample sheet and post-QC samples.
2. Register samples with the trusTEr `Experiment` object.
3. Quantify gene expression with CellRanger/STAR.
4. Set output directori... |
c60e34cf7dc6593752a674261cec0f2d8f0e47bd2a07ce19f5ba0bba579fd8ee | Python | 4,851 | 156 | #%%
import pandas as pd
from os import listdir
from os.path import join
import matplotlib.pyplot as plt
import bambi as bmb
import arviz as az
from scipy.stats import zscore
import numpy as np
import seaborn as sns
sns.set_style('ticks')
sns.set_context('poster')
import matplotlib as mpl
new_rc_params = {'text.usete... |
914784319b29cfdc87f1c7373b2ba5b5b52c8846ca0a5927b827edf8d76d4141 | Python | 4,852 | 135 | # This script is part of navis (http://www.github.com/navis-org/navis).
# Copyright (C) 2018 Philipp Schlegel
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of... |
67cd6bb3668be42085d1703fd0591ce024e8fe664d2ff20e0558df276b57c9d2 | Python | 4,853 | 156 | import numpy as np
# Try to import numba; if unavailable, set it to None.
try:
import numba
except ImportError:
numba = None
def spike_correlation_numpy(
spike_times_1, spike_times_2, bin_size, window, is_auto=False
):
"""Compute auto- or cross-correlation using NumPy."""
diffs = np.subtract.oute... |
825870bc0c70ef917f1597cf995692b10aab711128b6f0ac2fd6f8b230b753e6 | Python | 4,865 | 117 | #!/usr/bin/python3
##################################################################################
#
# MIT License
#
# Copyright (c) 2025 Kevin Rockenbach, Agnieszka Golicz
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "So... |
c349fdc982dc46a7bc205f1e8ad8075aaf0a07cfe286c3ffc0449df6446bb4c4 | Python | 4,866 | 129 | import tensorflow as tf
import numpy as np
import math
import random
from sklearn import preprocessing
from initial import IN
from SurvNet import FN
#----------------------------------------------------------------------------------------------------
# Generate/load the data
# (here we take dataset 1 as a demo, you... |
84112d8cac6c5d1ffdf594bada8727a338ddfcc91ca2d499539247e36ac44f05 | Python | 4,867 | 78 | from tristan_pipeline.io.params import *
from tristan_pipeline.utils.loading_utils import *
from tristan_pipeline.utils.preproc_utils import *
import pandas as pd
from nilearn.glm.first_level import make_first_level_design_matrix
from nilearn.plotting import plot_design_matrix
import matplotlib.pyplot as plt
def mak... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.