sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
d631ec5f96ae737dc79db260920482b81858517cf9ddaae4d1f9af10fcaca144 | Python | 2,898 | 75 | import ast
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def _logging_levels(path, fragment):
source = path.read_text()
tree = ast.parse(source)
levels = []
for node in ast.walk(tree):
if not isinstance(node, ast.Call) or not isinstance(node.func, ast.At... |
ea96d19e3a7ef534e6b41cd936520245ed1ca3cf739035661e60404b5f4a1655 | Python | 2,898 | 85 | import pandas as pd
import numpy as np
def get_byte_map():
"""
Construct mapping between bytes 0..255 and 4-element arrays of a1 genotypes
from plink bed file.
Return 256 x 4 array A, where A[i] = [a1, a2, a3, a4], each ai is from {2, -1, 1, 0}.
"""
genotype_codes = np.array([2, -1, ... |
db72aad606c823fecd8623016dbed56c1071c6101c227facd82460b727155f27 | Python | 2,899 | 94 | '''
Tests for datahandler.py
'''
import os
import numpy as np
import tifffile
from .base_test import BaseTestCase
from .. import datahandler
from .. import roitools
class TestImage2Array(BaseTestCase):
''' Tests for image2array.'''
def setup_class(self):
self.expected = np.array([[1, 2, 3], [5, 6, 7... |
ddff4f4799100ee36f60aa53804fc8e8b759a5e85a895319e2dc2360608aff9e | Python | 2,900 | 70 | """
This is a module that provides the same attributes as mpi4py so that
we can reduce the number of #ifdef MPIs that are used. Ideally, the
only ones that will be needed after using this module are the ones to
make sure that this is loaded #ifndef MPI and related ones.
"""
#+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+... |
abeb7528401e667f00306f9476edc98abf6a7a66ebee5acb4e84a5d9f4be0c85 | Python | 2,902 | 101 | from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
if TYPE_CHECKING:
from cleo.testers.command_tester import CommandTester
from poetry.config.source import Source
from poetry.poetry import Poetry
from tests.types import CommandTesterFactory
@pytest.fixture
def teste... |
e8a75fbf8e00fa473a70ec6da49e8fbed964174fb8f76a489c15960639ff8957 | Python | 2,902 | 97 | from __future__ import annotations
import json
from typing import TYPE_CHECKING
import pytest
import tomlkit
from poetry.__version__ import __version__
from poetry.console.commands.self.self_command import SelfCommand
if TYPE_CHECKING:
from cleo.testers.command_tester import CommandTester
from tests.type... |
392ac16df78e8cca2ff64e81f068dea1e31dc4a0712a9a054acfabf00718c1ea | Python | 2,903 | 115 | """
Transfer Entropy -- https://github.com/notsebastiano/transfer_entropy
Contributor:
Sebastiano Bontorin (sbontorin@fbk.eu)
"""
import numpy as np
from scipy import stats
from scipy import ndimage
def transfer_entropy(X,Y,delay=1,gaussian_sigma=None):
'''
TE implementation: asymmetric statistic measuring the r... |
770e803b14686f60a68c8908352467990b77d075d07e52824625d2436f00b267 | Python | 2,904 | 79 | # 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 unittest
import torch
import torch.nn as nn
from fairseq.modules.checkpoint_activations import checkpoint_wrapper
from torch.utils.che... |
a6b9c7e447b229fd9af4c2644fbf785aa8770edcc2e727d505fdfa3fd785a179 | Python | 2,905 | 85 | # /usr/bin/env python
'''
Written by Kong Xiaolu and CBIG under MIT license:
https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md
'''
import numpy as np
import torch
import os
import scipy.io as sio
import CBIG_pMFM_basic_functions as fc
def CBIG_mfm_validation_desikan_main(gpu_index=0, weight=1):
'''
... |
ab209b97c2cec04176643c14a69bc9319670a52c6cdeac91cc09bd65bb1db95e | Python | 2,908 | 72 | import sys
sys.path.append("/lustre/home/mlang/2D_Structure_ENV/lib/python3.9/site-packages")
sys.path.append("/lustre/software/anaconda/anaconda3-2019.10-py37/lib/python3.7/site-packages/")
import numpy as np
from Bio import SeqIO
import re
from pathlib import Path
def get_chain_sequence(fasta_file):
"""
inpu... |
1f30819a6c2c210388eb87eb46f5eb6cd70177a17a4a4c5adf62ac640972dd81 | Python | 2,909 | 98 | import os.path
import sys
import glob
design = 'run1'
if design == 'run1':
out_prefix = '<PROJECTS>/plsa_mixer/simu_run1/simu'
mixer_simu = '/home/oleksandr/github/mixer/scripts/mixer_simu.py'
tmp_prefix = '/scratch/simu_run1'
dry_run=False
num_submit = int(sys.argv[1])
basename_pattern = '_h2={h2}_rg=... |
87520ae43d42b1b38d46d1ffe48ef02c2c1cb858348aade8f67801742b447e79 | Python | 2,909 | 83 | # 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 torch.nn as nn
import torch
import torch.nn.functional as F
class LocationAttention(nn.Module):
"""
Attention-Based Models fo... |
cb5a44a6045224e1ee0473f8eb3c8a43493712fb36996e4689f55b2705a08d2d | Python | 2,909 | 122 | # source:https://github.com/Nandan91/ULSAM/blob/master/ulsam.py
# arxiv: https://arxiv.org/abs/2006.15102
import torch
import torch.nn as nn
torch.set_default_tensor_type(torch.cuda.FloatTensor)
class SubSpace(nn.Module):
"""
Subspace class.
...
Attributes
----------
nin : int
number ... |
45275bd9081d18d353451bfd3d6f49241d91e4599a02c3864c7e96b5203dfb7b | Python | 2,911 | 100 | import numpy as np
import torch
def levenshtein(source, target):
"""Levenshtein distance: number of deletions, insertions,
or substitutions required to convert source string
into target string.
Parameters
----------
source, target : str
Returns
-------
distance : int
numb... |
c095e80340028046bb198b22d38e3416372148aa076d4971e57ee992358f4ad0 | Python | 2,911 | 86 | # /usr/bin/env python
'''
Written by Kong Xiaolu and CBIG under MIT license:
https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md
'''
import numpy as np
import torch
import os
import scipy.io as sio
import CBIG_pMFM_basic_functions as fc
def CBIG_mfm_validation_desikan_main(gpu_index=0):
'''
This func... |
255b864ee626defd5dbe46a8559704816a31ff1a785ec2db0f94cc34aaaf9175 | Python | 2,914 | 73 | # @license
# Copyright 2020 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in... |
4ecf8b24e0e4f50774a6060875ec0804724eb2994e9a2ffe7300468f29701d18 | Python | 2,914 | 86 | __author__ = 'heroico'
import csv
class STFS(object):
"""sample file table format"""
ID = 0
POP = 1
GROUP = 2
SEX = 3
class Person(object):
"""A person."""
def __init__(self, id=None, population=None, group=None, sex=None):
self.id = id
self.population = population
... |
b3328610d7dae5afe67514131137abbc5e3ff01eabb28cba3061fdc33a3b318f | Python | 2,914 | 90 | # 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 unittest
import torch
from tests.speech import TestFairseqSpeech
from fairseq.data.data_utils import post_process
from fairseq import u... |
d8a4e9b65f1b424e2837389b47a0cb37506798d558849be17106b0481f1983a5 | Python | 2,915 | 90 | #!/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.
"""Extracts random constraints from reference files."""
import argparse
import random
import sys
def get_phrase(wo... |
a18d26019143fae047b193d5f7efee226eeb4d2da7baa4989988cf4945b6e63d | Python | 2,916 | 66 | # 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 unittest
from typing import Sequence
from fairseq.data import LanguagePairDataset, ListDataset, RoundRobinZipDatasets
f... |
d0465ba929c60b65a79c08736d62f62ee335317a6415fe86a05935e38a9efc45 | Python | 2,917 | 84 | # This extension template provides instructions to add new causal discovery algorithms to pgmpy.
#
# Please follow the following steps:
# 1. Copy this file to `pgmpy/causal_discovery` and rename the file as `[MyCausalDiscoveryAlgo].py`
# 2. Go through the file and address all the TODOs.
# 3. Add an import statement in ... |
aa41168464f99e5eea3cb93b4cc98cce100201ef98948d87e6b8d5d3225f1d07 | Python | 2,918 | 85 | #!/usr/bin/env python
from src.utils import read_gtf
import polars as pl
from src.utils import collapse_isoforms_to_proteoforms
import polars.selectors as cs
import argparse
def format_gtf_for_RiboTIE(gtf_path):
# Get level 1 and level 2 features
gtf = read_gtf(gtf_path)
level_1_2_feature = gtf\
... |
ef9227f6cc4191aaaaa42412ad01143becec4105509e45d56cab008320198e24 | Python | 2,918 | 92 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_geometric.nn import GATConv
def full_block(in_features, out_features, p_drop):
return nn.Sequential(
nn.Linear(in_features, out_features),
nn.BatchNorm1d(out_features),
nn.ELU(),
nn.Dropout(p=p_drop),
... |
2293b77622b02b162d535a196198cd21571118ac1128c0b6ca7daa64f48f4e50 | Python | 2,919 | 78 | # 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 os
import unittest
from tempfile import TemporaryDirectory
from fairseq.binarizer import FileBinarizer, VocabularyDatasetBinarizer
fro... |
5e3d2635716c92062c33018702a0d1b8fc54a00e4c9633936464f912ca667140 | Python | 2,919 | 79 | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from functools import cached_property
from pathlib import Path
from huggingface_hub import hf_hub_download
from mattergen.evaluation.reference.reference_dataset import ReferenceDataset
from mattergen.evaluation.reference.reference_dataset_seria... |
c68f871079711e01e7e9a0f92e86d7536020523cca3d75e8fef96e6739f64f57 | Python | 2,919 | 81 | import os
import numpy as np
import pytest
from scvi.data import synthetic_iid
from scvi.model import CondSCVI
@pytest.mark.parametrize("n_batches", [1, 2, 3])
@pytest.mark.parametrize("encode_covariates", [True, False])
@pytest.mark.parametrize("n_labels", [5])
def test_condscvi_batch_key(
n_batches: int, enco... |
5858a56428b3c835e4e4476ab7648318129059c425209d62f005ff422f8afa52 | Python | 2,922 | 65 | import argparse
import json
from collections import defaultdict
import os
from tqdm import tqdm
import sys
import subprocess
import re
mapping = {"cmn":"cmn-script_simplified", "srp":"srp-script_latin", "urd":"urd-script_arabic", "uzb":"uzb-script_latin", "yue":"yue-script_traditional", "aze":"azj-script_latin", "kmr"... |
f8b3be69c5e18919c9a3029f9fcd9d0186cdeef56cfa6c6ba73533a1fe1813cb | Python | 2,922 | 74 | from model.builders.prostate_models import build_pnet2
task = 'classification_binary'
selected_genes = 'tcga_prostate_expressed_genes_and_cancer_genes.csv'
data_base = {'id': 'ALL', 'type': 'prostate_paper',
'params': {
'data_type': ['mut_important', 'cnv'],
'drop_AR': Fa... |
c42aeb8d494090f3af2113cc165880282f8fe14ee9e575687706906034736ce0 | Python | 2,926 | 86 | import torch.nn as nn
import torch
def weight_init(m):
'''初始化模型参数'''
if type(m) == nn.Linear or type(m) == nn.Conv2d:
nn.init.xavier_normal_(m.weight)
class Block(nn.Module):
def __init__(self,input_shape,width,activation=nn.ReLU) -> None:
super().__init__()
self.layers=nn.Sequent... |
4c580eaeedf5d9a587c3b450325caa06e6ea40613b3eb2872d03ca5b9d2dee9d | Python | 2,928 | 96 | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import abc
from copy import deepcopy
from functools import cached_property
from typing import Literal, Type
import numpy as np
import numpy.typing
from pandas import DataFrame
from mattergen.evaluation.reference.reference_dataset import Referen... |
934c10443a0ce77bfbfd0914c5d7e0179c0b6b9a399acd735b5bb0e5fbfaae28 | Python | 2,928 | 67 | from functools import lru_cache
import numpy as np
import torch
from typing import Union, Tuple, List
from acvl_utils.cropping_and_padding.padding import pad_nd_image
from scipy.ndimage import gaussian_filter
@lru_cache(maxsize=2)
def compute_gaussian(tile_size: Union[Tuple[int, ...], List[int]], sigma_scale: float ... |
386028b5041b928c6ae1a3bc607578878e5e6b8d040d3434e6d009845309fb24 | Python | 2,929 | 110 | # 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 sys
import o... |
ae4e77e60d2a7c24e80f242fd454cd6a26eb9a09ab4a107444c0055841c79b93 | Python | 2,929 | 87 | import yaml
import json
from types import SimpleNamespace
from pipelines.dataloader import JacquardDataset
from pipelines.utils import show_tensor
import torch
from torch.utils.data import DataLoader, Subset
from modules.vgg16_baseline import VGG16Baseline
from tqdm import tqdm
from modules.loss_functions import simple... |
c4235370076bac344cd3a41b8151890961fe2f94dc983f5d38a136bfef1c6ebf | Python | 2,929 | 88 | from __future__ import division
import torch.nn as nn
import torch
class FilterLayer(nn.Module):
def __init__(self, in_planes, out_planes, reduction=16):
super(FilterLayer, self).__init__()
self.avg_pool = nn.AdaptiveAvgPool2d(1)
self.fc = nn.Sequential(
nn.Linear(in_pl... |
24ca06d05beaa7ba7d0c2ca0c39666b125290d4dc4f1a09607204bcb218f4cbc | Python | 2,930 | 92 | # 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 Dict, List, NamedTuple, Optional
import torch
import torch.nn as nn
from torch import Tensor
EncoderOut = NamedTuple(
... |
96468462e3d605390f0dcc6a23fbbe866e095001e782fb545dc5b709261926c5 | Python | 2,931 | 97 | import shutil
import textwrap
def resolve_abbrev(needle, strings, lower=False):
"""Return a full-length string matching a substring from the beginning.
Parameters
----------
needle : str
Substring of one of several `strings`.
strings : str or iterable of str
Full-length strings, o... |
cd8931279ceab7baaf44fbddf252937495ad814fb44235878136e56c1f0ea69a | Python | 2,931 | 92 | """
Basic utility functions for vtk.
"""
# Author: Oualid Benkarim <oualid.benkarim@mcgill.ca>
# License: BSD 3 clause
import numpy as np
from scipy.spatial import cKDTree
from .mesh_elements import get_points
from .array_operations import compute_cell_center
def _find_correspondence(surf, ref_surf, eps=0, n_jobs... |
98c436ed8d53586e82d0c89c3d8668fd6bdfc2a5a6dc7437022a2ba9f17154f4 | Python | 2,933 | 88 | # Copyright 2015 Google Inc. 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 law or a... |
c9809fface0d78142a2b93ecc0d5559b07668de73b6c3d2b01efcd14720ee949 | Python | 2,933 | 84 | import torch
from torch.utils.data import Dataset, Subset
import pandas as pd
from typing import Union
from pathlib import Path
from rinalmo.data.alphabet import Alphabet
MIN_EVAL_SEQ_LEN = 25
MAX_EVAL_SEQ_LEN = 100
def _generate_eval_set_eq_sampled_lens(df: pd.DataFrame, min_seq_len: int, max_seq_len: int, num_sa... |
4d86e1dc12f2a15edb89205e2cd6f23a496d0c8881379bdd077e283df5d40983 | Python | 2,934 | 89 | #!/usr/bin/env python
import os
from distutils.core import setup
from setuptools.command.test import test as TestCommand
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
# Can't import __meta__.py if the requirements aren't installed
# due to imports in __init__.py. This is ... |
6af1593c6a2142dd4afad67d830b6a250a626b7c5bfc3ef4294e1ee03556b66f | Python | 2,934 | 80 | import os
import importlib
import numpy as np
import matplotlib.pyplot as plt
import time
import torchvision
import seaborn as sns
import numpy as np
import pytorch_lightning as pl
import torch.nn.functional as F
import torchvision
from torchvision import datasets, transforms
from torch import nn, optim
from torch.util... |
6fc0cf3dfaf5a5e1112f865b6bdaefd045ee8c6ba5744723c2d936296d34ef10 | Python | 2,934 | 96 | import importlib
import inspect
import warnings
# A mapping from import name to package name (on PyPI) when the package name
# is different.
_INSTALL_MAPPING = {
"amica": "amica-python",
"codespell_lib": "codespell",
"openneuro": "openneuro-py",
"pytest_cov": "pytest-cov",
"sklearn": "scikit-learn... |
1112ea79f5a60a9282bf40d1ce5cb4568ae002471230227fc4bfc474a94ba174 | Python | 2,935 | 88 | # /usr/bin/env python
'''
Written by Kong Xiaolu and CBIG under MIT license:
https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md
'''
import os
import numpy as np
import torch
import CBIG_pMFM_basic_functions as fc
import warnings
def CBIG_mfm_validation_desikan_main(gpu_index=0):
'''
This function is... |
7bb6522f32f0f010225572e995ac17f32fac5bfde17c6e8392928ec008136064 | Python | 2,935 | 66 | from __future__ import annotations
import argparse
from pathlib import Path
from st_risk.config import load_config
from st_risk.data.harmonize import choose_reference_celltype_column, intersect_gene_names
from st_risk.data.io import open_h5ad
from st_risk.models.cell2location_model import _clean_prefixed_columns, exp... |
32c5ac99a30a28d68cb48367efa5e92681bc39f5c399a58b44ac87f6646241d5 | Python | 2,936 | 104 | import os
import yaml
import glob
# register all available models through *_model.py files
# def construct_model():
# model_dir = os.path.dirname(__file__)
#
# # lists all model files
# model_list = []
# for root, _, names in os.walk(model_dir):
# for name in names:
# if name.endsw... |
2a09bd3fa340fa693266def83a1f7b8d5b4ebd46411693729ea1c0aa24b4de4d | Python | 2,939 | 107 | import jax
import jax.flatten_util as jfu
import jax.numpy as jnp
import jax.tree_util as jtu
from .utils import mark_varying_like
def is_tree_complex(tree):
leaves = jtu.tree_leaves(tree)
return any(jnp.iscomplexobj(leaf) for leaf in leaves)
def vjp_rc(fun, *primals: jax.Array):
def real_fun(*primals)... |
6c287387ed026f12ddea80e82b0dd234a438b3d56033b6fd75273b4ea880c265 | Python | 2,939 | 113 | """
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 math
import torch
from ..initializers import he_orthogonal_init
class Dense(torch.nn.Module):
"""
Combines dense layer wit... |
35ce162e9bec7f1853a6c86aadc31c7b7e1b7ff1900ef4a699fef2c3629c51a4 | Python | 2,940 | 87 | from __future__ import annotations
from pathlib import Path
from st_risk.data.io import load_manifest, open_h5ad
REQUIRED_READY_FILES = ("visium_h5ad", "snrna_h5ad")
REQUIRED_VISIUM_OBS_COLUMNS = ("sample_id",)
REQUIRED_REF_OBS_CANDIDATES = (
"cell_type",
"cellType_k",
"cellType_broad_k",
"cellType_h... |
19b79d634a19f90d5db978e6bd52ced2d49ffae4d21fb849df3cf223dd44b30b | Python | 2,942 | 93 | # -*- coding: utf-8 -*-
# Copyright (c) 2012 Georgios Verigakis <verigak@gmail.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS ... |
bc82f4f3c06ca9f2700b74525af2be8c111ac73b69ec1ac0c58445ae108005b9 | Python | 2,942 | 72 | from Bio.PDB import PDBParser
import numpy as np
from scipy.optimize import minimize, minimize_scalar
from scipy.spatial.transform import Rotation
import warnings
warnings.filterwarnings('ignore')
from .utils import *
def align_structure(structure):
pep_CAs = []
MHC_CAs = []
TCR_CAs = []
for chain i... |
1537f33b7423fbb8b4a97f97be5f34a96ce01b1ed68ea116290080838a5f3902 | Python | 2,944 | 83 | import copy
import pytest
import torch
import vak.models
from .test_factory import ConvEncoderUMAPDefinition
class TestParametricUMAPModel:
MODEL_DEFINITION_MAP = {
'ConvEncoderUMAP': ConvEncoderUMAPDefinition,
}
@pytest.mark.parametrize(
'model_name',
[
'ConvEnco... |
34a7af36dca5663e67410d4e271bd63b65ad3849207d698617d25e991c9859b4 | Python | 2,944 | 100 | #!/usr/bin/env python
from __future__ import print_function
import argparse
import markdown
import os
import sys
def convert_markdown(in_fn):
input_md = open(in_fn, mode="r", encoding="utf-8").read()
html = markdown.markdown(
"[TOC]\n" + input_md,
extensions = [
'pymdownx.extra',
... |
750dfa9df73e7c0679358ccefd24172f914690161b84f655dab157fe4d789182 | Python | 2,944 | 73 | from pathlib import Path
import pytorch_lightning as pl
from tangle_tracer.modules import NFTDetector
from tangle_tracer.nft_datasets import ROIDataModule, GeneralROIDataModule
def main(args):
#original NFT dataset directory
# data_dir = Path('/scratch/sghandian/nft/model_input')
#reannotation dataset
... |
c6463c8852ae53106645c88c1470545e0f5bf217cd1960c723c5428f24c5f7da | Python | 2,944 | 84 | import inspect
import torch
import pytest
import vak.nets
class TestED_TCN:
@pytest.mark.parametrize(
'num_classes, num_input_channels, num_freqbins',
[
(
1, 10, None,
),
(
1, 23, None,
),
(
... |
fed1a921b2fac3056fcc586af20d45a1fc36b5f374322849d061b0277b380935 | Python | 2,944 | 69 | #!/usr/bin/env python3
"""USE-BEFORE-DEFINITION check for option variables.
usage: use_before_def.py <study script dir>
A guarded default protects an option only if it runs BEFORE the option is read.
Insert the guard beside one use and miss an earlier one, and the script dies on
"Unrecognized function or variable... |
ca391fb04dd1c38e15df253b25cd06d561b0612502976bbcd5baae7c9438ca64 | Python | 2,948 | 93 | #!/usr/bin/env python3
"""Monta os 24 pontos SOC/nao-SOC dos 12 endmembers CsBX3.
Par isolado: MESMA geometria, MESMO pseudo (PseudoDojo nc-fr-04, relativity=dirac),
MESMA base e malha; a UNICA diferenca e `Spin`. Comparar contra os rotulos publicados
nao isolaria o SOC, porque trocaria o pseudopotencial junto -- por ... |
10ba4770aeddfd1a0d9ffe6607e5f8229505dc7755a11b839642762d254a2c02 | Python | 2,949 | 94 | # @license
# Copyright 2025 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in... |
b450e51eee3cf7984088e1607089cf8f1a1cc26d73dfa089aa72d70a669f0565 | Python | 2,950 | 68 | from ultralytics import YOLO
from pathlib import Path
import os
import yaml
def main(args):
config_path = Path(args.config_path)
log_path = Path(args.log_path)
hyperparams_path = Path(args.hyperparams_path)
tune = args.tune
#init yolo model from weights
if args.ckpt_path:
model = YOLO... |
924590f72b584786ac857024d0913e0e032dc9a77faaa4c92d9ffee9954bfb07 | Python | 2,951 | 83 | import unittest
from pyecharts.commons import utils
from pyecharts.datasets import EXTRA
class TestUtils(unittest.TestCase):
def test_utils_produce_require_dict(self):
cfg = utils.produce_require_dict(
utils.OrderedSet("echarts"), "https://example.com"
)
self.assert... |
69a48e797501d0f984c87cc4292991b3e4eca1702e51379eeb7ce26af9dcc424 | Python | 2,952 | 92 | """Progress bars for loaders whose batch count is not known in advance."""
import logging
from collections.abc import Iterator, Sized
from typing import Any, cast
from torch.utils.data import DataLoader
from tqdm import tqdm
from d3text.constraints import NonNegative
logger = logging.getLogger(__name__)
def split_... |
e24e60ecb8193efb816d0a0ffea096bb13604c0a36b0ec2f4a9c26f192b36ef5 | Python | 2,952 | 68 | #!/usr/bin/env python3
"""A utility to check your json files for problems.
Useful before you submit a big job!
"""
# flake8: noqa: T201
import os
import sys
import argparse
import jsonschema
from bpreveal.schema import schemaMap
from bpreveal.internal import interpreter
def getParser() -> argparse.ArgumentParser:
... |
8be515ad50be5a3789b156b7cd19e90cb9922b12c407992a4c30c85045814405 | Python | 2,953 | 94 | from argschema import ArgSchemaParser
import os
import logging
import time
import numpy as np
import pandas as pd
from ...common.utils import load_kilosort_data
from ...common.epoch import get_epochs_from_nwb_file
from .metrics import calculate_metrics
def calculate_quality_metrics(args):
print('ecephys spike... |
7c825c31e17b838c0ccb14905f70458d25923a2de72a322d4011fd667e8a843f | Python | 2,956 | 98 | import os
from os.path import join, dirname, basename
import pandas as pd
from matplotlib import pyplot as plt
from config_path import PLOTS_PATH, PROSTATE_LOG_PATH
base_dir = join(PROSTATE_LOG_PATH, 'review/fusion')
files = []
files.append(dict(Model='Fusion', file=join(base_dir, 'onsplit_average_reg_10_tanh_large_... |
6123554472c65ed3aca0d5a961332a829fc9ff9607e9540c077732e10c35557c | Python | 2,957 | 88 | import os
import time
import socket
import json
# Check whether a server is active
def check_port(ip, port):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(0.05)
try:
result = sock.connect_ex((ip, port))
if result == 0:
return True
else:
... |
695fe011d834537b922c5fc7449a3f097a29484aa609de00fe5f26d3bb65b954 | Python | 2,957 | 84 | import inspect
import torch
import pytest
import vak.nets
class TestTweetyNet:
@pytest.mark.parametrize(
'num_classes, num_input_channels, num_freqbins',
[
(
1, 10, None,
),
(
1, 23, None,
),
(
... |
860fdc570e008c3ce367e8e2ce143e929b2d78b2c9311464fd49467d5d7aa5d6 | Python | 2,957 | 79 | from mdt import LibraryFunctionTemplate
__author__ = 'Robbert Harms'
__date__ = '2018-10-11'
__maintainer__ = 'Robbert Harms'
__email__ = 'robbert@xkls.nl'
__licence__ = 'LGPL v3'
class TensorApparentDiffusion(LibraryFunctionTemplate):
"""Calculates the apparent diffusion for the Tensor model.
Args:
... |
c138a7df13841a00d1b184036e36097e85a7226725ed9be3c2832788cbaf328e | Python | 2,957 | 101 | #
# 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 th... |
0fd86ebac7b2b9bef113f50c344d62c44446175863d9a0ab71029f871ddf4f2d | Python | 2,958 | 87 | # /usr/bin/env python
'''
Written by Kong Xiaolu and CBIG under MIT license:
https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md
'''
import numpy as np
import torch
import os
import scipy.io as sio
import CBIG_pMFM_basic_functions as fc
def CBIG_mfm_validation_desikan_main(gpu_index=0):
'''
This func... |
c41eaa31ecd362cc0a334e5b2af9536b3753d875338477910a0f0c0ecf3cea13 | Python | 2,958 | 87 | # /usr/bin/env python
'''
Written by Kong Xiaolu and CBIG under MIT license:
https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md
'''
import numpy as np
import torch
import os
import scipy.io as sio
import CBIG_pMFM_basic_functions as fc
def CBIG_mfm_validation_desikan_main(gpu_index=0):
'''
This func... |
939ab3b68f9cfbc9a7710c486c50ff68e26dcfeafb4196dbded4959f4ee43e08 | Python | 2,959 | 101 | #
# 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 th... |
5091b9afcf397a3d1679672bc902fb1cae32c5a10c898bad5c35f0d42fe08f9a | Python | 2,960 | 91 | import logging
from lightning.pytorch.callbacks import ProgressBar as ProgressBarBase
from scvi.utils import track
logger = logging.getLogger(__name__)
class ProgressBar(ProgressBarBase):
"""Custom progress bar for scvi-tools models.
Parameters
----------
refresh_rate
Determines at which r... |
2537fb44e4aaac9cd3b2bc5a1e8520961f7a6dd9d7fe732522c6c8aa26294cbd | Python | 2,961 | 89 | # /usr/bin/env python
'''
Written by Kong Xiaolu and CBIG under MIT license:
https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md
'''
import os
import numpy as np
import torch
import CBIG_pMFM_basic_functions as fc
import warnings
def CBIG_mfm_validation_desikan_main(gpu_index=0):
'''
This function is... |
657ebc31e4f54dd26d3f55910b4a10862c7c373e3593e0ac55a0848c383d1e03 | Python | 2,961 | 100 | import os
import numpy as np
import pandas as pd
import torch
from torch.utils.data import Dataset, DataLoader
from sklearn.preprocessing import StandardScaler
from utils.timefeatures import time_features
import warnings
warnings.filterwarnings('ignore')
class Dataset_fMRI(Dataset):
def __init__(self, root_path,... |
aa58ea493191a802cdce95eb7002fa35887ccc70a8db1ac76e2ee6af7ead1d16 | Python | 2,961 | 77 | from mdt import LibraryFunctionTemplate
__author__ = 'Robbert Harms'
__date__ = '2018-08-27'
__maintainer__ = 'Robbert Harms'
__email__ = 'robbert@xkls.nl'
__licence__ = 'LGPL v3'
class ConfluentHyperGeometricFirstKind(LibraryFunctionTemplate):
"""Computes 1F1(1/2; 3/2; e), the confluent hypergeometric function ... |
ea304002132b7a0235d3a377d1353349f8ad75dc0387edfd24362e7a1141f106 | Python | 2,961 | 96 | ###############################################################################
#
# Import functions
#
###############################################################################
import argparse
import json
import numpy as np
import os
from pathlib import Path
import sys
import random
import time
import tensorflo... |
b4b569afca69ffab8a50feba83300b6f25aac7ce4f47c08d8becf7a0d3d65f6d | Python | 2,962 | 100 | #!/usr/bin/env python
# Author_and_contribution: Niklas Mueller-Boetticher; created script
import argparse
# TODO adjust description
parser = argparse.ArgumentParser(description="PCA (with standard-scaling)")
parser.add_argument(
"-c", "--coordinates", help="Path to coordinates (as tsv).", required=True
)
parse... |
453b6a44043c91cfd678cbe0e93e41278cc5f5eb7e69e16eea83155759b8ef5a | Python | 2,964 | 73 | # -*- coding: utf-8 -*-
"""Top-level package for pytorchtools."""
__author__ = """Francisco Perez-Sorrosal"""
__email__ = 'fperezsorrosal@gmail.com'
__version__ = '0.0.2'
import numpy as np
import torch
class EarlyStopping:
"""Early stops the training if validation loss doesn't improve after a given patience.""... |
3dae7327dc8c7638bb50637191e84a36b9d709079a0763eb248217f15ad26ce3 | Python | 2,965 | 92 | """The relation one-hot's column meaning, end to end.
`preprocess_relations` writes literal one-hot vectors and `ground_truth` reads
them back with `argmax` against the schema's declaration order. Neither side
imports the other, so they agree only by coincidence: reorder the tuple, or
swap the literals, and every `Has... |
1669e63a2baba9f6f4b7741e82eea26cce5b965a4855bc3f14c1952e9b08e83b | Python | 2,966 | 98 | from functools import partial
import haiku as hk
import jax
import jax.numpy as jnp
import numpy as np
import pytest
from oneqmc.density_models.analysis import ScoreMatchingDensityModel
from oneqmc.density_models.operators import (
AutoDiffDerivativeOperator,
EffectivePotentialOperator,
NumericallyStableK... |
764d0267cbf37ca6b5f6c9f257c4f96c592df51636c0aef5d64478780daee7d8 | Python | 2,966 | 90 | # 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... |
15cc2186257fdd6de524d50b290aacae0cbcf33950defaaf201bf1bc50f2eb63 | Python | 2,967 | 70 | import torch
import torch.nn as nn
from torch_geometric.nn import GINEConv, global_mean_pool, global_max_pool
class GaussianSmearing(nn.Module):
def __init__(self, start=0.0, stop=5.0, num_gaussians=32):
super().__init__()
offset = torch.linspace(start, stop, num_gaussians)
self.coeff = -0... |
7e0497c91d8a2350005921e501f98104249deb9a216c245d3c773d66ab727f2c | Python | 2,967 | 69 | #!/usr/bin/env python3
"""R1 ponto 5 (definir eta^2 e rho) e R1 ponto 4 (os 34 gaps negativos por par F-X).
Recalcula eta^2 pela ANOVA de um fator para conferir os valores da Tabela 3 e fixar a
definicao que entra no texto, e confere que o rho das Tabelas 4 e 1/7 e de SPEARMAN.
"""
import csv, json, re
from collection... |
38fada9232f161732955a0a7b5e5b1dea9800a16058b3dd4f06461c4849487bf | Python | 2,968 | 77 | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# 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... |
24d23f1503dc90cf54268f44010f19b30085b787105ec4e40c8cdb8fb966a224 | Python | 2,969 | 71 | """Script to check MRIQC outputs for excessive framewise displacement."""
import os
import glob
import click
import pandas as pd
from compositionality_study.constants import MRIQC_DIR
@click.command()
@click.option('--mriqc-dir', default=MRIQC_DIR, help='Path to the MRIQC output directory containing sub-XX folders.'... |
16784a5524def65bd1f1e25488a072d59bd980624a9361f6e05f5e5b2d02f010 | Python | 2,970 | 84 | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. 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 cop... |
17b75c34c07aa955db81fb4de3b71a4cb12a692b9c79a6448d54e5fc69641b1d | Python | 2,970 | 79 | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# 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... |
e56a599bd4801d590dedcb30143b27d287b62f5908b25bbc7d7a1b87061cb1a5 | Python | 2,970 | 106 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Various plots to display image processing progress
This is mostly for development, rather than final figures
"""
from typing import Optional, Tuple
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.axes import Axe... |
3829a2a10897fd9364fe52baf301651171d8a8ca8498cd7d8868a238fe68d164 | Python | 2,971 | 85 | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. 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 cop... |
5800202a7c8b035f864956f1d73c7f14b84d0d467c8557cd6f111616bc361c53 | Python | 2,971 | 91 | # /usr/bin/env python
'''
Written by Kong Xiaolu and CBIG under MIT license:
https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md
'''
import os
import numpy as np
import torch
import CBIG_pMFM_basic_functions as fc
import warnings
def CBIG_mfm_validation_desikan_main(gpu_index=0):
'''
This function is... |
bdfcc35a092ad601e5b12f029e3104857860b27dad2ef54b955741a1aa256c10 | Python | 2,971 | 102 | from scipy import signal
from scipy.signal import find_peaks
import numpy as np
def align_multichan_spikes(wfs, peak_T=42):
"""
input: waveforms of shape NxT
upsample the waveform in time first for finer scale alignment
then downsample the waveform to its original shape
"""
N, T, CH_N = np.sha... |
b41b27f51e02c8ccd70006c60b225de7a0e17a5b6651936f9de46c435756e617 | Python | 2,974 | 106 | from dataclasses import dataclass
from typing import Union
import numpy as np
from torch import Tensor
@dataclass
class FlatIndices:
chan_flat: np.ndarray
x_flat: np.ndarray
y_flat: np.ndarray
def get_flat_indices(dims):
"""
dims should be a CHW tuple
"""
num_channels, num_x, num_y = di... |
c414431ffa3e714676269bb5090ec4eaa5c496873f70fee5bbc30935808dcd5b | Python | 2,974 | 70 | import subprocess
import torch
from batchgenerators.utilities.file_and_folder_operations import save_json, join, isfile, load_json
from nnunetv2.training.nnUNetTrainer.nnUNetTrainer import nnUNetTrainer
from torch import distributed as dist
class nnUNetTrainerBenchmark_5epochs(nnUNetTrainer):
def __init__(self,... |
afdd96c683012b5da2b61c3cabe69a1c97778662984c3612677bfef8833100b3 | Python | 2,978 | 97 | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import random
import numpy as np
import pytorch_lightning as pl
import torch
from omegaconf import DictConfig
from torch.utils.data import DataLoader
from mattergen.common.data.collate import collate
from mattergen.common.data.dataset import Cr... |
ce4884e1a7282fc25b7141bd532032d8d5115ba63b1d8d57d5340cb37b9ac498 | Python | 2,978 | 97 | import os
from typing import Tuple
# disable numpy multithreading
os.environ["OMP_NUM_THREADS"] = "1"
os.environ["MKL_NUM_THREADS"] = "1"
os.environ["NUMEXPR_NUM_THREADS"] = "1"
os.environ["OPENBLAS_NUM_THREADS"] = "1"
os.environ["VECLIB_MAXIMUM_THREADS"] = "1"
import numpy as np
def define_blocks(
lx: int,
... |
9bf92f14bb7e755c790d8f28d2853af0048aee355e1bed4f590a9603bfdf69c8 | Python | 2,979 | 78 | """The pinned dev tooling must be the tooling this environment runs.
CI checks that `pyproject.toml` and the lockfiles agree; that the *installed*
environment agrees with the pin is nobody's job, and that is the gap through
which `ruff` went undeclared for the life of the repo — `pdm run ruff` fell
through `PATH` to a... |
af7f6f9359989d130caab33daffd919adb3c93ad736ce9802fd87e1211903e88 | Python | 2,979 | 58 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'TabMapSpecific.ui'
#
# Created by: PyQt5 UI code generator 5.10.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_TabMapSpecific(object):
def setupUi(self, TabMapSpecific):
... |
c2bc1a97f0ffd3f9e171a862695d041b0db5a902bdedd3ff903f20af0064ffdc | Python | 2,981 | 60 | import torch
from nnunetv2.training.nnUNetTrainer.nnUNetTrainer import nnUNetTrainer
class nnUNetTrainer_250epochs_NoMirroring(nnUNetTrainer):
def __init__(self, plans: dict, configuration: str, fold: int, dataset_json: dict,
device: torch.device = torch.device('cuda')):
super().__init_... |
d0cff49f64ae039c2f4753491c71643a3c0328f799b153109b897c42de5b8533 | Python | 2,982 | 106 | # -*- coding: utf-8 -*-
"""
Created on Fri Jan 24 19:37:34 2025
@author: hanna
"""
"""
Main script for computing behavioral metrics over all sessions and subjects for BCI tasks
Hard-coded subjects: 0 (Monkey A), 1 (Monkey B)
Hard-coded BCI task perturbation types: rotation, shuffle
Error clamp trials ar... |
de27515fb83f5ac0251b39edcee162d887ec133f4201bf0f79b0e979cf921afe | Python | 2,987 | 87 | """Regression test for `store_in_db` clobbering untouched fields."""
import asyncio
from aiotinydb import AIOTinyDB
from aiotinydb.storage import AIOJSONStorage
from brenda_references.utils import CachingMiddleware
from d3types import Document
from scripts.retrieve_text import MISSING_FULLTEXT_QUERY, store_in_db
de... |
f86c56d32603fa505f799028371fa164f3cb9b44b5589be133bee53c6caf8ba6 | Python | 2,987 | 76 | import os
import pandas as pd
from BLRun.runner import Runner
class SCSGLRunner(Runner):
"""Concrete runner for the scSGL GRN inference algorithm."""
def generateInputs(self):
'''
Function to generate desired inputs for scSGL.
If the folder/files under self.input_dir exis... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.