sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
f02c94d8a1b6730b352a5e1c1467157ba78fc1aab60f6a57b1dce545770ffe6f
Python
1,397
43
""" Sphinx extension to add ReadTheDocs-style "Edit on GitHub" links to the sidebar. """ import os import warnings __licence__ = "BSD (3 clause)" # def get_github_repo(app, path): # if path.endswith(".ipynb"): # return app.config.github_nb_repo, "/" # return app.config.github_repo, "/docs/source/" ...
2d1b45840579f3d70b36cf7bca6640a45cb006111a9c5e0475535f1b660ab37c
Python
1,398
32
# Source code: # https://github.com/zbmed-semtec/doc2vec-doc-relevance-training/blob/main/code/train_model/train.py # This file includes the modifications to the source codes according to this project! import os import time import logging import utilities as utilities def run(best_params, args): # 1) Load ...
58aa23e548259b8c4e72f7ff1c813b0ad83168fbbef5be0394f92a60ba84efc5
Python
1,398
41
import pytest import torch from scvi import REGISTRY_KEYS from scvi.module import SCANVAE @pytest.mark.parametrize("n_labels", [1, 2, 10]) def test_scanvae_loss_n_labels(n_labels: int): vae = SCANVAE(n_input=100, n_labels=n_labels) x = torch.randint(0, 100, (128, 100), dtype=torch.float32) batch = torch...
7bab5d67f14f3a97f2c7b9e646eda43a3035dbdbe7c031a79f3b3915e42a761f
Python
1,398
42
"""Bar order and labels for Simulation eval_a / eval_b (aligned with preprocess condition names).""" from __future__ import annotations # Internal keys match ``spots_{name}.csv`` / ``CONDITION_GRID`` in ``datasets.preprocess.Simulation``. # Top-to-bottom display order after ``invert_yaxis()`` on barh (index 0 dr...
40e8f894e10f07064e70bbbbbb2ba542ff430813a6d157c88fcae51d931480ea
Python
1,399
55
# 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 importlib import os from abc import ABC, abstractmethod from fairseq import registry from omegaconf import DictConfig class BaseSco...
5d92d06a7628c7103a3ec9e09f9c56f10b054127ce68b4ba62a217db3ce72d37
Python
1,399
46
import torch from torch import Tensor from torch.nn.modules.loss import _Loss ### Normalized cross-correlation, implementation from the excellent GitHub repository by Bob de Vos (AmsterdamUMC): ### https://github.com/BDdeVos/TorchIR class StableStd(torch.autograd.Function): @staticmethod def forward(ctx, te...
8db99c301b196aeb2722a9ef78e25eb87124fe5be149d0b5a3c962006db25b99
Python
1,401
35
# created by DebarpanB # date 26th August, 2022 import argparse, configparser import pickle import pandas as pd import librosa import numpy as np import torchaudio import torch from pdb import set_trace as bp def main(annotation_file, pathfile, outlist, outpath): df_annotation = pd.read_csv(annotation_file) d...
556b0567ab944eb57adb7df15a69a06428930f75318743db4930e1eedf514eea
Python
1,402
53
""" Invokes __main__ when the module is run as a script. Example: python -m vak --help """ import argparse from pathlib import Path from .cli import cli def get_parser(): """returns ArgumentParser instance used by main()""" parser = argparse.ArgumentParser( prog="vak", description="vak comma...
aa1beadc217c970a02ccf1ff44d4a5e925b9ce03d46c4d4f1811256ccad52e7b
Python
1,402
53
from __future__ import annotations import sys from functools import cached_property from pathlib import Path from typing import TYPE_CHECKING from typing import Any from poetry.utils.env.system_env import SystemEnv if TYPE_CHECKING: from poetry.utils.env.base_env import EnvPaths class NullEnv(SystemEnv): ...
40a40a094df9332bb24716255569d0ce6fdf406aa569628822d1dc20c211181e
Python
1,403
47
import numpy as np # Colours and types Types = np.array(["T4", "T5"]) Type_colours = np.array(["#17becf", "#ff7f0e"]) Subtypes = np.array(["T4a", "T4b", "T4c", "T4d", "T5a", "T5b", "T5c", "T5d"]) Subtype_colours = np.array( [ "#1f77b4", "#9edae5", "#98df8a", "#bcbd22", "#d6...
1442b4f4103222512c453548c423b40a37d5dfa009878d624ea1828e6e7fd490
Python
1,404
46
from .parameters import FreeParameter, CurrentModelSignalParam from .model_functions import SimpleModelCLFunction __author__ = 'Robbert Harms' __date__ = "2014-08-05" __license__ = "LGPL v3" __maintainer__ = "Robbert Harms" __email__ = "robbert@xkls.nl" class SignalNoiseModel(SimpleModelCLFunction): """Signal no...
7c4ec55a45b68626e6e7b3cedccfb1676ce489a7fab143e2d3252fee62c011e0
Python
1,404
48
# 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 dataclasses import dataclass, field from fairseq import file_utils from fairseq.data.encoders import register_bpe from fairseq.data.enc...
aa04d2c2e4c28f80c86f8e6c6c70d1e7696456f53329a078d5cd61f4c7077662
Python
1,406
45
""" Scrapper for sphinx-gallery to capture vtk figures. """ # This is shamelessly copied from PyVista from .base import Plotter from ..vtk_interface.wrappers import BSScalarBarActor def _get_sg_image_scraper(): return Scraper() class Scraper(object): def __call__(self, block, block_vars, gallery_conf): ...
d45ef39d1e10682d64a9c3bc9bc087f63316d02a338a03d6c238da94fe4aff92
Python
1,406
46
import os from os.path import dirname from sklearn.model_selection import ParameterGrid base_dirname = dirname(dirname(__file__)) print base_dirname filename = os.path.basename(__file__) task = 'classification_binary' selected_genes = '~/DATA/P1000/tcga_prostate_expressed_genes_and_cancer_genes.csv' data_base = {'id...
3d948accd3018dcaafbc0dbe5a5d3fd6adf70e040b9993a8167eb21895c040c5
Python
1,407
42
#!/usr/bin/env python3 import numpy as np # --------------------------- # Define some (shared) parameters mainly (or exclusively?) used by RDDNet # --------------------------- dt = 0.001 # timestep (s) v_reset = -1 # reset somatic voltage spike_threshold = 1 # spike threshold refractory_time = np.ceil(0.003 / dt...
06c48a1cdc86bbff0cc8dfa59e31416d006f7875dcd923315051f7275e3273af
Python
1,409
46
import os from os.path import dirname from sklearn.model_selection import ParameterGrid base_dirname = dirname(dirname(__file__)) print base_dirname filename = os.path.basename(__file__) task = 'classification_binary' selected_genes = '~/DATA/P1000/tcga_prostate_expressed_genes_and_cancer_genes.csv' data_base = {'id...
165c5541df11ca6760e10b53b82995c4d7fe16e0bec0056e64e5f364ca784e23
Python
1,409
25
import pytest class TestAICGauss: def test_local_score_no_parents(self, aic_gauss_score): # score(model2network("[A]"), df_cont[c('A')], type='aic-g') -> -121.7228 assert aic_gauss_score.local_score(variable="A", parents=()) == pytest.approx(-121.7202, abs=1e-3) # score(model2network("[B]...
251556ba361b094bd7d1588ec87522b543f6f1ec3cccf2c9b9e9f6c3ced0ebe5
Python
1,409
44
# 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. """ LayerDrop as described in https://arxiv.org/abs/1909.11556. """ import torch import torch.nn as nn class LayerDropModuleList(nn.ModuleLi...
ebaa030665f63fd19aefe716e37803da5f0516c9cc14d44cb9b22faf98581b08
Python
1,409
48
import shutil import uuid from pathlib import Path from src.persistence.dashboard_state import ( get_state_file_path, load_state, save_state, ) from src.persistence.settings_store import ( load_settings, save_settings, settings_file_path, ) def _make_local_tmp_dir(name: str) -> Path: path...
1243e8bb813677dd6ae1dc7ad626f8198b040f69b8fa6fa7c8d89b4de510406d
Python
1,410
46
# 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 pickle import numpy as np class ShardedTensor(object): def __init__(self, data, starts): self.data = data ...
bfd220b026108daa839f01dc41e16536b1619ed2cf55c90f8c5c1288ef2d43ee
Python
1,410
42
#!/usr/bin/env python # PYTHON_ARGCOMPLETE_OK """This script is meant to update your home folder with the latest MDT models.""" import argparse import textwrap import mdt from mdt.lib.shell_utils import BasicShellApplication __author__ = 'Robbert Harms' __date__ = "2015-08-18" __maintainer__ = "Robbert Harms" __email_...
124eb7f4c2a12dc5075a3f1a0a4fba77bea4b6a1d67ec355a7039d8875c31040
Python
1,412
47
from __future__ import annotations from typing import TYPE_CHECKING from typing import ClassVar from poetry.core.constraints.version import Version from poetry.__version__ import __version__ from poetry.console.commands.add import AddCommand from poetry.console.commands.self.self_command import SelfCommand if TYPE...
62f8b6f71dd757aa66d9bd4e0ebb91eee736a3627db4fb0ee10a3519c1e0e18f
Python
1,412
48
import pandas as pd import numpy as np import glob def get_pmids(file_path): # Load pmids from .npy file doc = np.load(file_path, allow_pickle=True) # Get pmids pmids = [] for line in doc: pmids.append(np.ndarray.tolist(line[0])) # Convert all values in the list "pmids" from type ...
52753ede2e791e5e3106aea38ee279aba5a3b30c6c0752f8a9c161f731fe8f35
Python
1,413
43
import tempfile from pathlib import Path import pytest import vak @pytest.fixture def specific_dataset_csv_path(specific_config_toml): """Returns a function that will return the ``dataset_csv_path`` corresponding to the ``prep``ared dataset from a specific configuration file, determined by character...
6e971322bf394430464653bba592e5f0d6fe6bd2a05c89974d5b59756ecef6d8
Python
1,413
38
from pathlib import Path import pandas as pd import seaborn as sns def loss_curve(log_dir: str | Path, version: int = -1, on_epoch: bool = True, **kwargs: int) -> None: """Plot the training loss curve from the CSV logs. This is a basic alternative for monitoring training when Weights & Biases can't be used. ...
c68ac0871d388f472ebaf568bd2735d40abf910b99d278193b4af60206c27763
Python
1,413
53
import inspect import torch import pytest import vak.nets class TestConvEncoder: @pytest.mark.parametrize( 'input_shape', [ ( 1, 128, 128, ), ( 1, 256, 256, ), ] ) def test_init(self, input_s...
1f0d8f90154f46c113bc179e3c930555d438984b078de7ae025c5cf3f25ee080
Python
1,414
42
import math import unittest from unittest.mock import patch from pyecharts import options as opts from pyecharts.charts import Surface3D from pyecharts.faker import Faker class TestSurface3DChart(unittest.TestCase): @patch("pyecharts.render.engine.write_utf8_html_file") def test_surface3d_base(self, fake_wri...
0bdb468834e3f022d362c08d79f6f2a8f472120b0b660d3cd619d97721a84de1
Python
1,415
47
# 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...
55e13801314a0f5b843f08bfc3e05ebce02ce41f2a6b831a3147e983383c2301
Python
1,416
54
#!/usr/bin/env python # -*- coding: utf-8 -*- import csv import os from vlpp.utils import add_suffix from vlpp.operation import computeSuvr, CentiloidStats, meanFromRoi def main(): os.mkdir("centiloid") os.mkdir("stats") pet = "${pet}" tracer = "${tracer}" roiPath = os.path.join("${centiloidR...
0203c74f7416b8592a3d32bcd167f785faabea50866b5375d3948586799c06ee
Python
1,417
49
import h5py import nibabel import numpy as np from typing import Union from voluseg._tools.constants import dtype def save_volume( fullname_ext: str, volume: np.ndarray, affine_matrix: np.ndarray = None, ) -> Union[bool, None]: """ Save volume in output format. Formats currently accepted are: ...
eac975a00cfb7481c39f0a8692e9725bc1bd8082fdf3313fcba0cb50a949b076
Python
1,417
51
# 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 fairseq.models import ( BaseFairseqModel, register_model, register_model_architecture ) @register_model("mmmodel") class Fa...
63a68e662439a65223d5b0946007e5a80ad0380b28e19d87e52fa3b9c3387c6b
Python
1,418
37
#!/usr/bin/env python import pysam, numpy as np, sys from pathlib import Path bam_in = sys.argv[1] # collapsed Iso-Seq BAM timepoint = Path(bam_in).name.removesuffix(".bam") # e.g. "iPSC_merged" bedgraph = f"data/katherine/{timepoint}.coverage.weighted.bedgraph" # Pre-allocate one array per contig sam =...
2645f8af3b7335211fcfc62a3013db296b778088ab4a69fd927e88e1d354bf5c
Python
1,419
43
"""Shared matplotlib styling for consistent figures. Call `set_style` at the top of a notebook so every figure uses the same fonts, sizes, and spine treatment. """ import matplotlib as mpl import matplotlib.pyplot as plt GENOTYPE_COLORS = { "CI": "#d1495b", # cichlid "ZF": "#30638e", # zebrafish } def se...
b3d6dff1f17395cd4a5712095ad85b504c5b8b5ae0100a836b77595caeb4b741
Python
1,420
46
import os from os.path import dirname from sklearn.model_selection import ParameterGrid base_dirname = dirname(dirname(__file__)) print base_dirname filename = os.path.basename(__file__) task = 'classification_binary' selected_genes = '~/DATA/P1000/tcga_prostate_expressed_genes_and_cancer_genes.csv' data_base = {'id...
e82505179b9f06f040a39102666b6b5a432758dd9e7d7e19eff129b58583741c
Python
1,421
44
# source: https://github.com/Megvii-BaseDetection/BorderDet/blob/master/cvpods/layers/border_align.py # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. from torch import nn from torch.autograd import Function from torch.autograd.function import once_differentiable from cvpods import _C class _Bo...
06ba72388af12cd5e908a51492b9dd9d35b2ab7e5fdaef2179b65735a888e098
Python
1,422
33
import tensorflow_model_optimization as tfmot LastValueQuantizer = tfmot.quantization.keras.quantizers.LastValueQuantizer MovingAverageQuantizer = tfmot.quantization.keras.quantizers.MovingAverageQuantizer class DefaultDenseQuantizeConfig(tfmot.quantization.keras.QuantizeConfig): # Configure how to quantize weigh...
59b5ea62f5e6413a13ea083ec433137cf92e7f7bf5eb0838903ff093a4d4cdea
Python
1,423
47
import sys import os merge = sys.argv[1] benchmark = sys.argv[2] mode = sys.argv[3] file_path, full_file_name = os.path.split(merge) d={} g={} with open(merge, 'r') as m,open(benchmark,'r') as ben,open(file_path+'/f_'+mode+'.txt','w') as ff,open(file_path+'/p_'+mode+'.txt','w') as p: for a in m: ...
9fa17c83f24f328a1c99771b7a26588546c52ffcfe0ec4d73be643d1478b008c
Python
1,423
51
# /usr/bin/env python ''' Written by Kong Xiaolu and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md ''' import csv import os import numpy as np import CBIG_pMFM_parameter_estimation_example as example import warnings def csv_matrix_read(filename): ''' This function is use...
3b2732af12fa3405fb63025f0ecafa27a1b8362d746aefcd7a78008b20fe9160
Python
1,425
47
import os import anndata from scvi.data._download import _download def _load_heart_cell_atlas_subsampled( save_path: str = "data/", remove_nuisance_clusters: bool = True, ): """Combined single cell and single nuclei RNA-Seq data of 485K cardiac cells with annotations. Dataset was filtered down rand...
d153dede52c25c020aab37af380ca70dabf549784c78459cf57d6a6bb85bd1c7
Python
1,425
39
# Generate sql script to extract patient followup for each condition # Requires tables containing patients for inclusion and hospitalisations and ae attendances data from A0_global_vars_py import * s = '' for pln in ['gold', 'aurum']: s += f'--- {pln.upper()} ---\n' for condition in conditions: s +...
d405de0a8e510bc25e74331e236654a4c67204082abd581b7692ea6d8c9671a9
Python
1,425
53
#!/usr/bin/env python # Author_and_contribution: Niklas Mueller-Boetticher; created template # Author_and_contribution: ENTER YOUR NAME AND CONTRIBUTION HERE import argparse # TODO adjust description parser = argparse.ArgumentParser(description="Calculate metric ...") parser.add_argument( "-l", "--labels", help...
fec7faf5ba499c603e1fd5a853f322f46e4ac4afd08a9ea70e160ac7f45daa10
Python
1,426
45
"""Annotation Extension for relational expressions. https://link.springer.com/protocol/10.1007/978-1-4939-3743-1_17 Correlated function associations between genes and GOs containing contextual information. With contextual information identify gene products that perform a role: - only under certain condi...
1e86a78e35dfba266ed2f0e069dee80d9820a5bce626e3e6e5358c10c7a65747
Python
1,428
47
from __future__ import annotations import argparse from pathlib import Path from st_risk.config import load_config from st_risk.models.io import save_base_model_output from st_risk.models.registry import build_model_runner from st_risk.paths import current_results_dir, ensure_results_layout from st_risk.paths import ...
e853f06d9d9fe4ec51e7ce6df200b6a1c500f2954fd99d688e6cf71f1887f5f5
Python
1,428
38
import os import torch # Borrowed from e3nn @ 0.4.0: # https://github.com/e3nn/e3nn/blob/0.4.0/e3nn/o3/_wigner.py#L10 # _Jd is a list of tensors of shape (2l+1, 2l+1) _Jd = torch.load(os.path.join(os.path.dirname(__file__), "Jd.pt")) # Borrowed from e3nn @ 0.4.0: # https://github.com/e3nn/e3nn/blob/0.4.0/e3nn/o3/_w...
61b730c59ec757e4479b8a955de3ecf4095b63a2617a36d5af75dd56a79e4085
Python
1,429
38
import os from pathlib import Path import sys os.environ["SEGREF3D_DISABLE_SAM2"] = "0" os.environ["SEGREF3D_EDITION"] = "local-gpu" os.environ["SEGREF3D_FORCE_SAFE_SDPA"] = "1" def _configure_windows_dll_runtime() -> None: """Configure the frozen DLL runtime before PyQt or PyTorch is imported. PyQt6-Qt6 6...
aee0b15f2e16302eef4c978080c387b41c17ee7af7d73e46336e21ff40f18b05
Python
1,429
39
# 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 fairseq.models import BaseFairseqModel, register_model from fairseq.models.wav2vec.wav2vec2_asr import ( Wav2Vec2CtcConfig, Wav2V...
303903e3f995755254004803bc1aebaea395993a70a85ba6325e82df5fe83b64
Python
1,430
48
# 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 json import argparse import pathlib def main(): parser = argparse.ArgumentParser() parser.add_argument("--manifest", required=...
70e1cbf6c1605335f0b42d1d28119b00849c0316f7839dd68570b100fbd3a2b0
Python
1,430
39
import torch from torchvision import transforms, datasets import numpy as np from copy import deepcopy from tqdm import tqdm device='cuda' def sample_pair(n): idx = list(np.random.choice(n,2)) return idx def load_batch(generator, t, c1, c2, transform=None, amb=0.5, N=200, bs=2, test=False, no_label=False): ...
3752be10f3d9b7f9e33983bdfcbd7bbf68837a543585748cfcb34350523c7d22
Python
1,434
58
from __future__ import annotations from typing import TYPE_CHECKING from poetry.exceptions import PoetryError from poetry.utils.env import EnvCommandError if TYPE_CHECKING: from pathlib import Path from poetry.utils.env import Env def pip_install( path: Path, environment: Env, editable: bool ...
402dedce125fe44b8da2758ba0db95da54ccd8c9e9de6b941105301be130fddf
Python
1,434
33
import pandas as pd import argparse import os # Input: metal output with UID in the MarkerName column. # Add RSID from HRC reference panel and CHR and BP based on UID. # Parse arguments -------------------------- parser = argparse.ArgumentParser(description="Process output of metal assuming MarkerName column contain ...
9f9da8c65a8b46ff51b84902177afdad31be6b654f062894169a17f22c4bc2b2
Python
1,435
49
# Configuration file for the Sphinx documentation builder. # -- Project information ----------------------------------------------------- import subprocess, os project = 'liblsl' copyright = '2019, Christian Kothe, MIT' author = 'Christian Kothe, David Medine, Chadwick Boulay, Matthew Grivich, Tristan Stenner' # The...
a38a2c5b53932adda1fbda91b3d6d375ddbae393b7525733561a0ff9e9775d34
Python
1,435
44
#!/usr/bin/env python3 """Headless entry point for the NONAN Python test suite. python3 tests/python/run_tests.py # everything python3 tests/python/run_tests.py emd # name filter Exits 0 if every test passed, 1 otherwise. Deliberately stdlib unittest, not pytest: the suite must run on a bar...
b70c84df87451170e3958675a5be0d28b606e3ae2489ebb6ca13ca272e82ed04
Python
1,435
39
""" weighting.py — inverse-distance weighting and weighted oversampling. Neutral home for the distance -> weight -> merge helpers shared by the distance-based pipelines (MMP, DWP). Previously these lived in mmp_pipeline.py and were cross-imported by dwp_pipeline.py; centralizing them here removes that inverted depende...
211c3e394cdf903e48f602a51bc22c1ef46635025edeea33cf217412d2f69eb7
Python
1,438
43
from optparse import OptionParser import os import sys import pandas as pd from arboreto.algo import grnboost2, genie3 from arboreto.utils import load_tf_names from distributed import Client, LocalCluster def parseArgs(args): parser = OptionParser() parser.add_option('', '--algo', type = 'str', ...
c5a293dba45e68ea0d928e3a3d18b2c45294df7ef5d8abe3e8e639ff32f1cf57
Python
1,438
68
import math import numba import numpy as np from scipy.special import gammaln class PoissonProximity: def __init__(self, A: float, B: float) -> None: self.A = A self.B = B def logF(self, x: np.ndarray, y: np.ndarray) -> float: A = self.A B = self.B N = x.shape[0] x_norm = np.sum(x) y_norm = np.sum(...
efc1e69dcf386205fb7f24095ec8b28fb818a1c6b5c2f3a1f1c02c14aa6ec02f
Python
1,438
37
#!/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. from examples.speech_recognition.criterions.cross_entropy_acc import ( CrossEntropyWithAccCriterion, ) from .asr_t...
2a42625c8ebd4177b1630c49d661bb30218750bc096551271022845ccbdc9b7e
Python
1,439
57
import argparse from pathlib import Path import anndata import pandas as pd from scipy.sparse import csr_matrix def convert_to_h5ad(dataset_dir: Path): res_path = dataset_dir / "adata.h5ad" if res_path.exists(): print(f"File {res_path} already existing.") return slide_id = f"stereoseq_{...
1e6415234dad0788a5edb97b108ec4ca41f5c9b0ff7f498f4af91feffe419aad
Python
1,440
45
from __future__ import annotations from typing import TYPE_CHECKING from typing import ClassVar from cleo.helpers import option from poetry.console.commands.self.self_command import SelfCommand from poetry.console.commands.show import ShowCommand if TYPE_CHECKING: from cleo.io.inputs.option import Option f...
84165c91aaaaf933b09bca12d41d217d13e2bd69a8165129eaa58e3db1061339
Python
1,440
33
import logging import numpy as np import pandas as pd from data.gmt_reader import GMT def get_KEGG_map(input_list, filename='c2.cp.kegg.v6.1.symbols.gmt', genes_col=1, shuffle_genes=False): ''' :param input_list: list of inputs under consideration (e.g. genes) :param filename: a gmt formated file e.g. path...
9ae109b3ce722da7b87b127e83cfa0166d4fa7fe605cbd824f8c20c213885836
Python
1,440
52
import os from pathlib import Path import sys import unittest os.environ.setdefault("QT_QPA_PLATFORM", "offscreen") MODULE_DIR = Path(__file__).resolve().parents[1] if str(MODULE_DIR) not in sys.path: sys.path.insert(0, str(MODULE_DIR)) from PyQt6.QtWidgets import QApplication # noqa: E402 from batch_tracking_d...
bcdd2df263ad572a2b99c6c83a6567a22a71f7f1408df01947154333d495041d
Python
1,441
53
from abc import ABC, abstractmethod from pathlib import Path import pandas as pd from BLEval.data import EvaluationData class Evaluator(ABC): """ Abstract base class for BEELINE evaluation methods. Each subclass implements __call__ to compute a specific evaluation metric over an EvaluationData obje...
ed460a404ba31e68448163573092bb3512f5b6f6c0bdf9a3a4b0966d9d70d1f0
Python
1,441
31
import numpy as np import torch import torch.nn as nn class MixConv2d(nn.Module): # MixConv: Mixed Depthwise Convolutional Kernels https://arxiv.org/abs/1907.09595 def __init__(self, in_ch, out_ch, k=(3, 5, 7), stride=1, dilation=1, bias=True, method='equal_params'): super(MixConv2d, self).__init__() ...
9bf915d91bbe0afe67170f634a70269c1a3cf48362523777c30c1ed298a31f1f
Python
1,442
46
# 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. """ Unsupervised Cross-lingual Representation Learning at Scale """ from fairseq.models import register_model from .hub_interface import Robe...
cc8a2dc82336f42b70ac1e2a372169aabff19e802b02abe2956b0a677acc676e
Python
1,442
43
# 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.optim from . import LegacyFairseqOptimizer, register_optimizer @register_optimizer("sgd") class SGD(LegacyFairseqOptimizer): ...
cdd251cc5cfd80f35e2bc9c5707eae5c2183f2e2c523a0560c63e81f47f072d1
Python
1,442
40
import numpy import numpy.testing import pandas import unittest from metax.gwas import GWASSpecialHandling class TestGWASSpecialHandling(unittest.TestCase): def test_sanitize_component(self): sanitize = GWASSpecialHandling.sanitize_component #Number pass through self.assertEqual("a", sani...
efbbc6108ea050a2fb741493c92bd082e1bc1128467371edb8c9832a978966f7
Python
1,445
39
# 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 dataclasses import dataclass from fairseq.dataclass import FairseqDataclass from fairseq.optim.lr_scheduler import FairseqLRScheduler, r...
ba3e0ffbfa5caf43aac82a35acdd1d5379f901e31ab57bcbf1b036950aba1c0e
Python
1,447
56
# import gsMap project = "gsMap portal" copyright = "2024, Liyang, Wenhao" author = "Liyang, Wenhao" # release = gsMap.__version__ # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration extensions = [ "s...
dd020ff90b84fb284b8bf9b5b89b0c6f6f1a788e89c6a2d6848ac09b9b682632
Python
1,447
54
""" This module contains method to check if beam is broken, which signals the start of a trial. """ """ Copyright (c) 2019, 2022 [copyright holders here] This file is part of NoSeMaze. NoSeMaze is free software: you can redistribute it and/or modify it under the terms of GNU General Public License as published by t...
24de3bb3290cd3d3609cf6005ffc26440ed6f7ce8e4c01c74576a72a94c3c26f
Python
1,448
47
# @license # Copyright 2022 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...
faebc58f06e066239d9ecd9442522339d386294ca840ee78e8c642850b3547b4
Python
1,449
47
import os from os.path import dirname from sklearn.model_selection import ParameterGrid base_dirname = dirname(dirname(__file__)) print base_dirname filename = os.path.basename(__file__) task = 'classification_binary' selected_genes = '~/DATA/P1000/tcga_prostate_expressed_genes_and_cancer_genes.csv' data_base = {'id...
05f20d1b1a44aa573fd160cf3634e2ec639cf881e77d384eaabd614285f13569
Python
1,451
31
import pytest import vak import vak.datapipes.frame_classification class TestTrainDatapipe: @pytest.mark.parametrize( 'config_type, model_name, audio_format, spect_format, annot_format, split, transform_kwargs', [ ('train', 'TweetyNet', 'cbin', None, 'notmat', 'train', {}), ...
18909825fb0a58c21bc118286c14ccd3ea3f48d3e87c356212eda7a60774a342
Python
1,451
45
import sys import os merge = sys.argv[1] benchmark = sys.argv[2] mode = sys.argv[3] file_path, full_file_name = os.path.split(merge) d={} g={} with open(merge, 'r') as m,open(benchmark,'r') as ben,open(file_path+'/f_'+mode+'.txt','w') as ff,open(file_path+'/p_'+mode+'.txt','w') as p: for a in m: ...
48a922cca513cf35773670579d891acf64c4a56ccae8577427823cd9ee67226d
Python
1,452
48
""" 07_methylation_analysis.py Methylation-level evidence from GSE131706 (ASD brain tissue). Computes pairwise correlations between methylation beta-values at PCDH-annotated and DNMT-annotated CpG sites. Harbert D. (2026) BMC Genomics """ import sys, os sys.path.insert(0, os.path.dirname(__file__)) from utils import...
540bbcf53bcbe10783c24279e0c19caddca5d2670b8d647ab0956d090bb223d9
Python
1,453
42
import os from os.path import dirname from sklearn.model_selection import ParameterGrid base_dirname = dirname(dirname(__file__)) print base_dirname filename = os.path.basename(__file__) task = 'classification_binary' selected_genes = '~/DATA/P1000/tcga_prostate_expressed_genes_and_cancer_genes.csv' data_base = {'id...
7ff9832e4a25606b88c16545d9af252e52dd39de8544b046aa6e8e8a2c043ec4
Python
1,453
45
import numpy as np import pandas as pd from anndata import AnnData from .._constants import Nums from ..utils import iter_slides from ..utils._validate import _check_has_slide_id def quantile_scaling( adata: AnnData | list[AnnData], multiplier: float = 5, quantile: float = 0.2, per_slide: bool = True...
12a581e76e2d0fa5f2475dbea2f82d1ef8421172322e550aece46f0685cc5f29
Python
1,455
27
import pytest class TestLogLikeGauss: def test_local_score_no_parents(self, loglik_gauss_score): # score(model2network("[A]"), df[c('A')], type='loglik-g') -> -119.7228 assert loglik_gauss_score.local_score(variable="A", parents=()) == pytest.approx(-119.7202, abs=1e-3) # score(model2netw...
dfe7d6bf9692df15dff56d4424f6d302f65fdd0c4ad4312d2d1b15c4672bf8b9
Python
1,455
58
#!/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 argparse from pathlib import Path from tqdm import tqdm def process(args): args.output_root.mkdir(exist_o...
21e31ccc8b3cf4206b40abca839d3c768773ae010c95815d279866bbb3c38e9b
Python
1,457
47
''' By K. Butenko Routines to post-process VAT-based pathway recruitment ''' import os import json import numpy as np def remove_failed_protocols(Currents_all, ActivationResults_all): # remove protocols for which the simulator failed, they were marked with -1.0 rows_idx = np.where(np.any(Activation...
7757190f02dde4b14e4f41c3d8a7885334ab640d457b10ad4c6f685cb54ab2ea
Python
1,458
40
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import torch from torch.distributions import Categorical, Independent, MixtureSameFamily, Normal from mattergen.diffusion.wrapped.wrapped_normal_loss import get_pbc_offsets, wrapped_normal_score from mattergen.diffusion.wrapped.wrapped_sde impor...
a8fae64a9d847004915a978972686e26b5ae2efa7767baebeebe93ff664a4a15
Python
1,458
31
import subprocess import scipy.io as sio import numpy as np import shutil import os.path def execute_command(command): process = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT) print(process.communicate()[0].decode("utf-8")) #print(subprocess.check_output(command.split()...
066c76c2ef62f5b1d6f38c4b57e978ed0c39d097de470e7cd8d444ec3aaed121
Python
1,459
54
import os import numpy as np import glob import matplotlib.pyplot as plt def plot_raw_data(dataFolder): f1 = os.path.join(dataFolder, os.path.join('continuous','Neuropix*.0')) f2 = os.path.join(dataFolder, os.path.join('continuous','Neuropix*.1')) ap_directory = glob.glob(f1)[0] lfp_directory = glob.glob(f2)[0] ...
2c5b3aeebceeedc2e8212adf4c1aa7c3d552a582e10100afe2fbab2b365886b3
Python
1,459
45
""" Compact reference implementation of the multi-scale Optical Scanning Holography (OSH) representation used in the associated manuscript. """ from typing import Sequence, Tuple import numpy as np DEFAULT_ALPHAS: Tuple[float, ...] = (0.5, 1.0, 2.0, 3.0) def apply_osh(image: np.ndarray, alpha: float) -> np.ndarray:...
da2c6dcb0ad1c16efe23856fd87a20e10d8a8453307151e222127430ec5a2f90
Python
1,459
41
# 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 argparse def deup(src_file, tgt_file, src_file_out, tgt_file_out): seen = set() dup_count = 0 with open(src_file, encodin...
6dd3a4b455244b4ee45358c433e74cf7e3f7d4f586cc0d0e15d033be8e13b60a
Python
1,460
50
# Configuration file for the Sphinx documentation builder. # # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html import os import sys sys.path.insert(0, os.path.abspath('../../..')) # cross-sim/sphinx/source # -- Project informat...
682daa8a3339a9381f6a3acbbd984c5ab77efc38fbcf62578a538dfa6c2ab113
Python
1,461
40
from pathlib import Path ROOT = Path(__file__).parents[1] def test_python_api_documentation_is_not_built(): sphinx_config = (ROOT / "docs" / "conf.py").read_text() project = (ROOT / "pyproject.toml").read_text() docs_index = (ROOT / "docs" / "index.md").read_text() assert not (ROOT / "docs" / "refer...
ea2a32c0f54d13c024673531223ba9dba2fc5a537a5c2df0e3526a601547f7b6
Python
1,461
66
from __future__ import annotations import pytest @pytest.fixture def init_basic_inputs() -> str: return "\n".join( # noqa: FLY002 [ "my-package", # Package name "1.2.3", # Version "This is a description", # Description "n", # Author "MIT", ...
cbd53b8f6fa12b0e8f60673fe44e5c28779d193f4a029ea72b2e85a830a19e3c
Python
1,462
42
import os from os.path import dirname from sklearn.model_selection import ParameterGrid base_dirname = dirname(dirname(__file__)) print base_dirname filename = os.path.basename(__file__) task = 'classification_binary' selected_genes = '~/DATA/P1000/tcga_prostate_expressed_genes_and_cancer_genes.csv' data_base = {'id...
a0e7654850d0df56438e580d8235242f3d49971972956d55561410e0c6e08054
Python
1,463
41
import jax import jax.numpy as jnp import pytest from oneqmc.preprocess.augmentation import RotationAugmentation from oneqmc.types import MolecularConfiguration, Nuclei @pytest.fixture def unit_vector_mol(): coords = jnp.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) nuclei = Nuclei( coords, jnp.array([1, ...
0cb1bf782f270d1e82ad32f0a0f2906971a13f66b196a8435761fcaaa7bd018c
Python
1,464
39
import primer3 import logging def calculate_deltag_primer3(seq1:str, seq2:str, temperature:float, sodium_concentration:float, magnesium_concentration:float) -> float: """Calculate deltaG using primer3 library. Args: seq1 (str): The first sequence. seq2 (str): The second sequence. tempe...
aa830f82daf693073956bae8b2fb57fbf6c485c32ba3284dae62f2eb40853b74
Python
1,466
33
# Source code: # https://github.com/zbmed-semtec/doc2vec-doc-relevance-training/blob/main/code/train_model/train.py # This file includes the modifications to the source codes according to this project! import time import logging import utilities as utilities def run(best_params, args): # 1) Load the trainin...
55d20da6806adcf80383d4f9a1def3cb711e5833237fbf881e1f1b01ed549216
Python
1,471
51
import numpy as np import pytest import torch import torch.nn as nn from pytorch_grad_cam.grad_cam_plusplus import GradCAMPlusPlus from pytorch_grad_cam.xgrad_cam import XGradCAM def test_grad_cam_plusplus_accepts_3d_activations(): activations = np.ones((1, 2, 3, 4, 5), dtype=np.float32) grads = np.ones_like...
eab0c73a0983d7a442fc71775ff429828aa30824c6976b6185b94d5778fb6b9d
Python
1,471
53
#!/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. import argparse import os import os.path as osp import numpy as np import faiss def get_parser(): parser = a...
38844076cf9dda2c61902f651ee7f4b693655a11a77d829f494df2e394fe3e17
Python
1,473
41
"""SIESTA-PBE isolated-atom references for the 10 case-study elements. Reuses run_atom() from data/perovskites/run_atom_refs.py (20-A vacuum box, spin-polarised, SZP/PBE/MeshCutoff 250 Ry — same as production). Needed to form cohesive energy E_coh = E_cell - sum_i E_atom_ref[el_i] for cross- composition stability rank...
98bf36f1cf3fcd410ce84ac2abbdd40efea3dd49d90d167dd3de69394deb5b90
Python
1,473
50
# encoding: utf-8 """ @author: Jiayang Chen @contact: yjcmydkzgj@gmail.com """ import os import torch from .baseline import Baseline from ..pretrained import load_hub_workaround def build_model(cfg): model = Baseline( backbone_name=cfg.MODEL.BACKBONE_NAME, pairwise_predictor_name=cfg.MODEL.PAIRWIS...
610fd56ddf5ba9333a0572f84e96dfc8e2da6f7c8f0363ee46672984e7a5aa6e
Python
1,477
40
"""Testing for libmedaka.fastrle program.""" import subprocess import tempfile import unittest import pysam class RLE(unittest.TestCase): """Test libmedaka.fastrle function.""" input_fasta = tempfile.NamedTemporaryFile(suffix='.fasta').name output_fastqrle = tempfile.NamedTemporaryFile(suffix='.fastqrl...
05dd973d9e3583ecf4b9eed1f44af548cfd1a5aefe41f42a56c09580fa909b73
Python
1,478
35
from torchvision import transforms from torchvision.models import ResNet18_Weights def load_transforms(model=None): preprocess = {} if model in ['resnext101_32x8d_wsl', 'resnext101_32x16d_wsl', 'alexnet', 'vgg19', 'vgg16', 'resnet50_simclr_100epochs', 'resnet50_MoCov2_200epochs', 'resnet50_ba...
335d9b1d47b1fa7bdf4d64f435932317f1a25390dd2f9e689c5079bcdbb0af7d
Python
1,478
46
#!/usr/bin/env python3 # -*- encoding: utf8 -*- import fasttext from tqdm import tqdm import argparse import os import math parser = argparse.ArgumentParser() parser.add_argument("--txt", type=str) parser.add_argument("--dst", type=str) parser.add_argument("--model", type=str) parser.add_argument('--lid', type=str) ar...
ee1ee31c5842b8363fbaee0f26fbd4ff5ff85ecb385823b037fbe8d17c80108c
Python
1,479
50
__author__ = 'heroico' import gzip import io # class DataSet(object): """A list of values for a thing we care about""" def __init__(self,name=None,index=None, data = []): self.data = data self.name = name self.index = index class DataSetFileUtilities(object): @classmethod def ...
f390fadda262ff2bafa65cbce29e8980822e44a786edf6d99495fda26fe1b3b8
Python
1,479
59
"""Plain Python state models for reusable GUI views.""" from __future__ import annotations from dataclasses import dataclass @dataclass class DataSelectionViewState: file_path: str = "" selected_column: str = "" use_baseline: bool = False @dataclass class StaticInputsViewState: pre_behaviour_time:...
54998ecf54cdf62c237892adc5451c048d86d58527543c8cf7a94d46ae1b9e0d
Python
1,480
36
import os import time import argparse import logging import numpy as np import pandas as pd import utilities as utilities import precision as precision def run(best_params, args): # 1) Load the training data train_pmids, train_docs = utilities.process_data_from_npy(args.input) logging.info(...