sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
583c4520a7d2150d37a5e485395430c5194a10c92c6d406e07839f553c57e63c
Python
3,629
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 torch import torch.nn as nn import torch.nn.functional as F from ..ops import emulate_int class IntLinear(nn.Module): """ Qu...
c80581e73d2c56bc9cd6a17a6140187218dfeb4b6f8b5e4322d92e26718643f5
Python
3,629
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. import unittest import tests.utils as test_utils import torch from fairseq.data import TokenBlockDataset class TestTokenBlockDataset(unitte...
fc7643272d9690d8e3b738d5aa883d69267198c9f740f9c9e7e5dfd3eded4fe6
Python
3,629
91
from model.builders.prostate_models import build_pnet2 # # current_dir = split(dirname(__file__)[]) # print current_dir # ind= current_dir.index('pnet_prostate') # print '/'.join(current_dir[0:ind+1]) # base_dirname= dirname(dirname(__file__)) # print base_dirname # filename = os.path.basename(__file__) task = 'classi...
c323c976a3c14a7bf1203bb6fb6ef77c83a3ff8d7e74a2721520ac00ad94ef36
Python
3,632
81
"""Standardized on-disk I/O for the Zenodo bundle. - Parcel data dictionaries <-> HDF5 (nested groups cond/sub/phase/stim). - Report/consensus embeddings <-> npz (vectors) + parquet (metadata). The HDF5 parcel store returns exactly the same nested-dict object the original pickles did, so analysis code is format-a...
f4ceb0afce2655f2e6ce890293f637539c813282ece2962a9e1d6034cc66802c
Python
3,635
87
import os, sys import numpy as np import torch from sklearn import metrics import torch from torch.optim.lr_scheduler import _LRScheduler from torch.optim.lr_scheduler import ReduceLROnPlateau def param_num(model): num_param0 = sum(p.numel() for p in model.parameters()) num_param1 = sum(p.numel() for p in mo...
0a04efcec0e2c5cfdd23473b484e1dd3bd6c3f935fe96af3b29888b4461611bc
Python
3,636
94
"""Functions to parse toml config files.""" from __future__ import annotations import pathlib import tomlkit import tomlkit.exceptions def _tomlkit_to_popo(d): """Convert tomlkit to "popo" (Plain-Old Python Objects) From https://github.com/python-poetry/tomlkit/issues/43#issuecomment-660415820 We nee...
17ec3e59382ebc78c256991bcb00c7c9fbd00b02ab5fa30aa85e379c2fdb0516
Python
3,637
95
from argparse import Namespace import torch import torch.nn as nn from fairseq.models.text_to_speech.fastspeech2 import VariancePredictor from fairseq.models.text_to_speech.hifigan import Generator class CodeGenerator(Generator): def __init__(self, cfg): super().__init__(cfg) self.dict = nn.Embed...
ddb7eface997dbb372d06309dcbe6a929a922dfc20fe294bd7da8148f63a1bea
Python
3,637
105
"""Pick 100 perovskites for SIESTA validation, stratified. Composition target: 24 endmembers (5-atom primitives, all (A,B,X) combinations) 76 supercells (40 atom 2x2x2) — proportional across kind × (A,B) split: 40 mixed-X / 18 mixed-A / 12 mixed-B / 6 strained Only includes records that succeeded under GFN...
de84694832b0662c0d4e02e4fa92c41f8a20351c2b3dcee926f0f593644ee727
Python
3,638
135
import argparse import sys from datetime import datetime from pathlib import Path import h5py import numpy as np from spacestream.analyses.hvm_fitter import HvmFitter from spacestream.core.paths import HVM_PATH from spacestream.utils.general_utils import log from spacestream.utils.get_utils import get_mapping STREAM...
1c4bdf7b2e14bcf443e5a2fbfb5da9809e25c9bfa84b984c02b40f91f2582335
Python
3,639
137
# Copyright (C) 2025 ETH Zurich, Moritz Thürlemann, and other AMP contributors from typing import Iterable, Dict, List, Any import json import yaml def get_atom_ids(residue_names:Iterable[str], pdbfile)->Dict[str, list[int]]: #starts counting from 1 (not from 0 as are indices in openmm) resnames_in_topology ...
da88c02505b322c8bc24ef9e5653323373db36bb20fd5215ee0f887e76eb7b71
Python
3,639
125
import h5py import numpy as np import torch import scipy.io as sio from scipy.signal import find_peaks from TraditionalMatchedFilter import TraditionalMatchedFilter def compute_metrics(detected_peaks, target_peaks, tolerance=20): detected_peaks = sorted(detected_peaks) target_peaks = sorted(target_peaks) ...
07a03d2e8356f05a1427c4e0e0165b086f3804dd1d69497c852a966fa3eea456
Python
3,642
104
"""Reading the relation head's own rows back, with no gold to align against. `evaluate_model` puts the head's rows through `align_relation_predictions`, which needs gold. Inference has none, so the only thing left is the argmax and the batch's interning table — and the table is what says which candidate sets the two a...
0f2bc5e58994107802b039ef4449f1d245a37bea47cd1797f6da1deeb597e43e
Python
3,643
100
import unittest from pyecharts import options as opts from pyecharts.charts import Geo, AMap, BMap, LMap, GMap from pyecharts.exceptions import NonexistentCoordinatesException BAIDU_MAP_API_PREFIX = "https://api.map.baidu.com/api?v=2.0" FAKE_API_KEY = "fake_application_key" class TestException(unittest.TestCase): ...
3a43dbebdb2aea399a2eb9858c24e85eb868c0a7ce14bda478a410b8c478c1bf
Python
3,644
116
"""The HDF5 resume loop must not re-append documents already stored. `generate_embeddings.py` keys its resume set off `pubmed_ids[:]`, which h5py hands back as `bytes`, and compares it against `str(row_id)` — a membership test that is always `False`, so an unfixed script silently duplicates every document at new offse...
13d20d9046dcd57e08cc74437dc14acac8f3203847b49d09cf2a76746255bb68
Python
3,646
118
#!/usr/bin/env python # ENCODE DCC MACS2 call peak wrapper # Author: Jin Lee (leepc12@gmail.com) import sys import os import argparse from encode_lib_common import ( assert_file_not_empty, human_readable_number, log, ls_l, mkdir_p, rm_f, run_shell_cmd, strip_ext_ta) def parse_arguments(): parser = argpa...
2fe7311c7e110eec3fd3092ff7accf6f9ce083322ba60322ec615b94b948fc23
Python
3,646
113
import numpy as np from rich import print from scipy.sparse import csr_matrix from scvi.utils import dependencies def adjusted_nearest_neighbors( cell_samples: np.ndarray, cell_coordinates: np.ndarray, cell_labels: np.ndarray, radius: int | None = None, k_nn: int | None = None, return_sparse:...
7baebd175faa3d6697f0c89811e8b743a7415685e068c56fcf429376ec709cc4
Python
3,649
83
#!/usr/bin/env python3 """R1 ponto 3 (MAE e R2 na Fig. 1a) e R1 ponto 4 (definicao de misto_F). Reproduz EXATAMENTE as predicoes out-of-fold do painel (a) de fig_manuscrito.py -- mesmo GroupKFold por familia, mesma grade de alpha, mesma normalizacao por atomo -- e acrescenta MAE e R2 ao RMSE ja publicado. Nada aqui re...
5748d6fbf799d511c540c200d7c3d9ed2ba46bb92c514ff6270f99b5ed8d372c
Python
3,651
113
from __future__ import annotations import logging from typing import TYPE_CHECKING import numpy as np import pandas as pd import scipy from anndata import AnnData from mudata import MuData if TYPE_CHECKING: from typing import Literal from scvi._types import AnnOrMuData logger = logging.getLogger(__name__) ...
150fc07f4f325d0fd80c9e1155d2e4951796bf06971cb93ce8603aa2be0a8946
Python
3,653
118
import numpy as np import torch from utils.data.dataholder import DataHolder @torch.no_grad() def sample_noise(self, batch: DataHolder) -> torch.Tensor: """ Samples noise z_t from the noise model based on the node features and other batch information. Parameters: batch (DataHolder): Batch data co...
63b45f891596466d434daef2817d10b816cbce5133385b7556609b61355ef3dd
Python
3,653
104
# 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 argparse import Namespace from typing import Union from fairseq.dataclass import FairseqDataclass from fairseq.dataclass.utils import me...
172c8c61b35771bb948e942956b4311ec8553e4349adc59ae1d6a2336ba3537d
Python
3,654
154
""" This module contains methods to deliver reward at different situations. """ """ 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 the Free Software Fou...
105164a6ba24f0c73f6a5d1e3baa48d41438f7f81870e5b07c65f5fcea05e72a
Python
3,655
90
import pytest from pgmpy.factors import FactorSet from pgmpy.factors.discrete import DiscreteFactor @pytest.fixture def phi1(): return DiscreteFactor(["x1", "x2", "x3"], [2, 3, 2], range(12)) @pytest.fixture def phi2(): return DiscreteFactor(["x3", "x4", "x1"], [2, 2, 2], range(8)) @pytest.fixture def ph...
c02adb2f49f5826027002fcf1a0fe751a856f6f5a0b03187b2d88f0aeb36e361
Python
3,655
105
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed May 1 13:40:02 2024 @author: tower2 """ import torch import torch.nn as nn import torch.optim as optim from torch_geometric.nn import GCNConv import torch_geometric.nn as pyg_nn import torch.nn.functional as F from tqdm import tqdm from torchviz impor...
02890b65163a300ded89bb6bbb29ae5b51be115ac77a3afeb6f12e0302191b5b
Python
3,656
124
# 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 functools import sys import unittest import torch from fairseq.distributed import utils as dist_utils from .utils import objects_are...
285eed4eccd4c9f3d234215366f3e9e28f4fb832332c1155c296c53f2c6d4b77
Python
3,656
133
""" Simple non-parametric forecasting baselines for fMRI ROI windows. These estimators are compatible with the shared forecasting pipeline and expect unflattened input windows shaped ``(N, M, ROI)``. They provide useful reference models for interpreting whether learned forecasters beat basic persistence or window-aver...
b6dfbecc643f8bf7831903b4eacba20bccebbb8b8274464f920ab6815aedeb40
Python
3,656
126
"""Fetch the BRENDA data blobs from the Hugging Face Hub and verify them. Paths are resolved from ``__file__`` rather than through ``resources.files("brenda_references")`` on purpose: this is a bootstrap script, so it has to run before the package is necessarily importable. """ from __future__ import annotations imp...
379cf175d29c8e9d2d013807a60d556a4fbebfda9193ba53b878685caf4cb747
Python
3,659
94
from ... import options as opts from ... import types from ...charts.chart import RectChart from ...globals import ChartType class Kline(RectChart): """ <<< K-line >>> K-line shows the highest value, the lowest value, the starting value and the ending value of the data on the day, whi...
1642b9357513244ddfaa2cc954ba0564cc7efb3496e075e342d29abf3846400f
Python
3,661
110
#!/usr/bin/env python3 """G1 — cross-modal imputation. For each checkpoint, iterate over its own modality set: mask one modality at the encoder input (zero tensor), run forward, measure MSE + 1-D Wasserstein against the real modality for every reconstructed output. HIPPIE has three modalities (wave, isi, acg) → 3×3 c...
b8f1bc187de60baedfc89fd1e1a6c4c91bdaa10b343f79d55229fe62a47d2b8f
Python
3,661
113
import os import numpy as np import pytest from scvi.data import synthetic_iid from scvi.external import SOLO from scvi.model import SCVI @pytest.mark.parametrize("soft", [True, False]) @pytest.mark.parametrize("return_logits", [True, False]) def test_solo(soft: bool, return_logits: bool): n_latent = 5 adat...
9c8606d3ade18f21eb7bb5da52dd2471dfeb5dcf0d481c7c73318f1410c5a840
Python
3,662
92
from ... import options as opts from ... import types from ...charts.chart import Chart from ...globals import ChartType class Sankey(Chart): """ <<< Sankey >>> Sankey diagram is a special flow diagram, which is mainly used to express how raw materials, energy and so on from the initial fo...
ef970a1e4c36e79da53df89c7829dab6b470069bf59a7ea0d04d3b071ab9d622
Python
3,662
92
"""Validate OCE on test set: per-isomer-group hierarchization + global metrics.""" from __future__ import annotations from collections import defaultdict from pathlib import Path import numpy as np from scipy.stats import spearmanr, kendalltau from oce.atomic_table import load_table from oce.dataset import load_data...
29eb6ddd9aeef55ffd6d92e00284f0ea5434e55bbfd0f39f970e9847a6880020
Python
3,663
115
#!/usr/bin/env python # ENCODE DCC blacklist filter wrapper # Author: Jin Lee (leepc12@gmail.com) import sys import os import argparse from encode_lib_common import ( get_ext, get_num_lines, gunzip, log, mkdir_p, rm_f, run_shell_cmd, strip_ext, strip_ext_bam) def parse_arguments(): parser = argparse.Arg...
910b4c73bbe444ac641979d7a921500dd72507c88413a56c6f7a4d6e091c2692
Python
3,664
118
import matplotlib.pyplot as plt import matplotlib.image as mpimg from PIL import Image import numpy as np import pandas as pd import seaborn as sns # Create main figure with 4 rows × 2 cols fig, axes = plt.subplots(4, 2, figsize=(14, 22)) axes = axes.reshape(4, 2) from matplotlib.gridspec import GridSpec import matpl...
b4f5945fc87c44299665988aab507acd8f292a121a3a1dec54de64ecbabbca6b
Python
3,664
102
"""Deprecated compatibility shim for :class:`pgmpy.causal_discovery.GES`.""" from collections.abc import Iterable from typing import Any import pandas as pd from pgmpy.base import PDAG from pgmpy.causal_discovery import GES as _GES from pgmpy.estimators import StructureEstimator from pgmpy.structure_score import Bas...
be4e95e4ceea747845093645132d4bf191d7945406a50b133a24549c6579bde1
Python
3,667
116
from __future__ import annotations from typing import TYPE_CHECKING from typing import ClassVar from cleo.helpers import argument from cleo.helpers import option from cleo.io.null_io import NullIO from tomlkit import table from tomlkit.items import AoT from poetry.config.source import Source from poetry.console.comm...
e62b876e1e118791a75a9e1b089ab9f00822b99bfd7056854dc69847bd602532
Python
3,668
98
# coding=utf-8 # Copyright 2020 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...
2c433cfabfdfd8866edc699a08332d419ad8f29331fa02eec04317ecdd61000e
Python
3,669
102
from __future__ import annotations from itertools import product from math import gcd import numpy as np import pandas as pd REQUIRED_FEATURE_COLUMNS = ("phi_local", "phi_uncertainty", "phi_stability") def zscore(values: np.ndarray) -> np.ndarray: values = np.asarray(values, dtype=float) std = values.std()...
4da1c0e4f472e50c3528932b79e4603755e7dc4d5a0a1b0b1156a696a5d43a02
Python
3,669
98
"""Subprocess wrapper around xtb for ground-state energies.""" from __future__ import annotations import re import shutil import subprocess import tempfile from pathlib import Path from ase import Atoms from ase.io import write as ase_write XTB_BIN = "/home/xtb/bin/xtb" EH_TO_EV = 27.211386245988 import os as _os ...
64430561d35c8bb1cb464970dc11cc8e60c74490e62c194d04a7f87a18ac8209
Python
3,670
100
# coding=utf-8 # Copyright 2020 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...
31a6935d956a45cb85db9a8b4edc149eaa5284423e92a42d93166bd0cd86aacb
Python
3,671
102
from __future__ import annotations import re from typing import TYPE_CHECKING from typing import ClassVar from cleo.helpers import argument from cleo.helpers import option from packaging.utils import canonicalize_name from poetry.console.commands.installer_command import InstallerCommand if TYPE_CHECKING: fro...
185868b1dfa34ff666aa88f100e22792c84b1eea24eaf9de3fcfaccfd02676eb
Python
3,672
95
import logging from argparse import ArgumentParser from transformers.commands import BaseTransformersCLICommand from transformers.pipelines import SUPPORTED_TASKS, Pipeline, PipelineDataFormat, pipeline logger = logging.getLogger(__name__) # pylint: disable=invalid-name def try_infer_format_from_ext(path: str): ...
1b37c65b5763cd0054f84f6f754b88aacbafc07aa0a3bbe0acdf6ac43dca30bc
Python
3,672
65
#!/usr/bin/env python3 """Numeros laterais da Sec. 4.3 no protocolo final (sem copias; CV interna agrupada). (1) metalicidade: AUC do 1F e do wave15 com a MESMA maquinaria da varredura (run_classification do sweep_targets, features brutas, GroupKFold por familia), completo (controle: tem de dar o +0,012 ...
5a7efd78a8bf885c5410e5cdf223bb5b758da7557ef0b870682ee61e9579020e
Python
3,672
128
from typing import Sequence, TypeVar, Callable, Generator, Optional import functools import torch import numpy as np import contextlib from tqdm.auto import trange TensorLike = TypeVar("TensorLike", np.ndarray, torch.Tensor) T = TypeVar("T") @contextlib.contextmanager def numpy_seed(seed): """Context manager wh...
055c8c14b9c2be94f32205a62f47ae21a49f1547b99b04e10c450cf7d38f0790
Python
3,673
96
import logging from argparse import ArgumentParser from transformers.commands import BaseTransformersCLICommand from transformers.pipelines import SUPPORTED_TASKS, Pipeline, PipelineDataFormat, pipeline logger = logging.getLogger(__name__) # pylint: disable=invalid-name def try_infer_format_from_ext(path: str): ...
3ea6e780d986de337c0c42a7c6c056ea4fb0a5584ecbc2780263afbbce64bdae
Python
3,673
119
#!/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 tqdm import torch import torch.nn.functional as F from shutil...
8945795b93763ebbd7807d4b9a4fec6281f6e6bbe64520e5c08c093600fd26e4
Python
3,673
128
from __future__ import annotations import functools from pathlib import Path from typing import TYPE_CHECKING from poetry.core.packages.utils.link import Link from poetry.config.config import Config from poetry.inspection.info import PackageInfo from poetry.inspection.info import PackageInfoError from poetry.utils....
0561ce2b0006140ed84be7827bb67f0da9c7948fbcef183c19cdd3e862eea906
Python
3,674
80
#!/usr/bin/env python3 from collections import defaultdict import numpy as np import pytest from pgmpy.factors.discrete import DiscreteFactor, TabularCPD from pgmpy.inference import Inference from pgmpy.models import DiscreteBayesianNetwork, DiscreteMarkovNetwork @pytest.fixture def inference_data(): bayesian =...
a7cde2b3209499ebf465604bb1c0c3cebb1deef75ae0fe4bdec0e2d6e20ede7c
Python
3,677
119
# 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 numpy as np import torch from fairseq.data import Dictionary, FairseqDataset from fairseq.tasks import LegacyFairseqTa...
ae6d73ec104170ca52de622329beb72087cf74b4acc50d767f0f244369a781ec
Python
3,678
95
"""The StrainInfo write-back must not join on a generic designation. `apiadapters.straininfo.StrainInfoAdapterBase.retrieve_strain_models` (not editable here) pairs a returned record with whichever BRENDA strain shares its *first* matching designation, with no organism constraint. `A2` is short enough that StrainInfo ...
f441077ef739634ef3a37fe6617e7c8b628dd718f8c03c0de74039ece9d626ff
Python
3,678
110
import numpy as np import itertools def weighted_quantiles(values, weights=None, quantiles=0.5, interpolate=True): #set interpolate to False for better performance but less acurate result if type(weights)==type(None): weights=np.repeat(1,values.size) ...
e7de204ab7c40badb28a7f24e14a5132addf0cdd968c8ec9b06f6ea50afccdbd
Python
3,682
108
#!/usr/bin/env python # coding: utf-8 # In[1]: # import matplotlib.pyplot as plt # import pytorch_lightning.callbacks # get_ipython().run_line_magic('load_ext', 'autoreload') # get_ipython().run_line_magic('autoreload', '2') # get_ipython().run_line_magic('matplotlib', 'widget') # In[2]: print('=========Loading imp...
f1f69749addb545af65146c33c981e2f0eda9345b559cb851668c2d037345c4a
Python
3,682
96
import pandas as pd import numpy as np import os, sys, logging def read_bim(bimFile, logger=None, sep='\t'): ''' Read PLINK bim file. Input: ------ bimFile, PLINK bim file path logger, python logger for process information sep, separator of bim file Return: ------ ...
ab8de30f71ec704a997c90f51d15c62835ad7d42bd316dda9cd65c705c72b7ad
Python
3,683
112
# 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...
b3ddfc84a360c5924d146fd53df759ad2728066d0d6b948dc47a1b3e2633e916
Python
3,685
114
# 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...
d43694972c437c3e48fee74544596a28bd8ba89a5c03b1e88ae26a5e51cc856f
Python
3,685
98
import torch from tqdm import tqdm from torch.nn.functional import normalize from transformers import EsmConfig, EsmForMaskedLM, EsmTokenizer class ProteinEncoder(torch.nn.Module): def __init__(self, config_path: str, out_dim: int, load_pretrained: bool = True, ...
b9705d57ce02968b10c0c6c8e3b4c08e609706608bd89204ec2c0c54dea91e94
Python
3,686
106
# 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. """isort:skip_file""" from .adaptive_input import AdaptiveInput from .adaptive_softmax import AdaptiveSoftmax from .base_layer import BaseLaye...
2af082b38c1c5c4ab9dc97fc30011808d3e119e64ce53698cf736352b487f162
Python
3,690
76
import torch from nnunetv2.training.nnUNetTrainer.nnUNetTrainer import nnUNetTrainer class nnUNetTrainer_5epochs(nnUNetTrainer): def __init__(self, plans: dict, configuration: str, fold: int, dataset_json: dict, unpack_dataset: bool = True, device: torch.device = torch.device('cuda')): "...
29bf2a4faf291f62af27f83a951d5ba75aa4226b6a086b410ce0d6fc8b01c03f
Python
3,691
104
# @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...
4718c005f8a7cf18e5adbffbfc920ef6af61f8049905b1c84d157c517b21e247
Python
3,691
95
def run_surf_cmd( input_seg, cmd, cfg, singularity_path=None, singularity_mount=None, singularity_home=None, ): """ Run a segmentation command with the given input SRR. Args: input_seg (str or list): Path to the input segmentation file or a list ...
40f8a59dcfdbc808cd701a8ec252ec36f24c3c7783a9c27ec7f099066fb894fc
Python
3,692
122
# 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 import numpy as np import warnings def get_target_sequences(manifest, ground_truth, to_take=1000): import json import ...
5e37237d357c38d42e5ea273a966ee39d8d58cf4f28424c6fd62eed76ffe8def
Python
3,692
104
# 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...
608b511c2a378ba6fb0e7744711203ec4dc787b47898825821904c2d5e9798cf
Python
3,692
90
#!/usr/bin/env python # Author_and_contribution: Jieran Sun; created script import argparse parser = argparse.ArgumentParser(description="Aggregate the results into a single tsv file. Notice that the folder structure should be input_folder/*/results_files") parser.add_argument( "-i", "--input_folder", help="Inp...
4ccc24c2cb5d6f47fed44dff5c2455239bcbe32c55dcb00a0d782a8a6db4d53e
Python
3,693
103
# /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_test_desikan_main(gpu_index=0): torch.cuda.set_device(gpu_inde...
3823bea581a68438eee50bf461a901d2e417430ad2b9128b23b143f6477d326a
Python
3,694
103
# /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_test_desikan_main(gpu_index=0): torch.cuda.set_device(gpu_inde...
890187a3bebf4e71e62d475948ce8472867aac31e619f1be72c22c2bd666a71c
Python
3,694
132
import numpy as np import pandas as pd from st_risk.eval.reference_eval import ( marker_subset_discordance_mean, random_subset_markers, reference_signature_residual_proxy, reference_subsampling_instability, ) def test_random_subset_markers_respects_fraction_and_minimum(): markers = { "A":...
549ec846e7630f50f823b47a59cedffefc0ffb8bbfe6912d4ec39a3c144d1a66
Python
3,695
103
# 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 glob import argparse from utils.dedup import deup import sys WORKDIR_ROOT = os.environ.get('WORKDIR_ROOT', None) if WORKDI...
92138cb367fcebeb3ef50dd1b04fce48a436f07ad0d46b0ae480d3edacf9a02a
Python
3,696
112
"""Figure sizing and filesystem export helpers.""" from __future__ import annotations import datetime import math from pathlib import Path def apply_figure_size_and_fonts( fig, axis_width_cm: float, axis_height_cm: float, font_settings: dict, current_xlabel: str, current_ylabel: str, ) -> No...
9d49b7703c7ac6b542284aed66eee2765523a03fbfc44dbd7c2fe7fbd8705611
Python
3,696
109
#!/usr/bin/env python3 import polars as pl import argparse def main(): parser = argparse.ArgumentParser("Get best_orf.tsv") parser.add_argument("--final_sample_classification", action='store', type=str, required=True) parser.add_argument("--final_sample_fasta", action='store', type=str, required=True) ...
a1dcef0926c8abb457386ded344ef25eda8ea0e7c380463d75239cb47dd0953c
Python
3,696
160
from __future__ import annotations from typing import TYPE_CHECKING import pytest from poetry.config.source import Source from poetry.repositories.repository_pool import Priority if TYPE_CHECKING: from poetry.poetry import Poetry from tests.types import CommandTesterFactory from tests.types import Proj...
33a8d42ff9bf78e162b35321c5cbd4d4ec12fb46e3f53b9857016797e0133e8b
Python
3,697
126
import json from pathlib import Path from typing import Dict, Tuple, List import numpy as np import pytest import torch from neurovfm.data.metadata import DatasetMetadata @pytest.fixture def create_dataset_dir(tmp_path) -> Path: """ Create a dataset directory structure with raw/ and processed/ and return its path...
315ba0fadcd9c175a17cad5cd38e81dee2f4a08489fb84cbfb0c51e0abcefca3
Python
3,698
105
import os import zarr import tskit import numpy as np import matplotlib.pyplot as plt import seaborn as sns import pandas as pd from tqdm import tqdm from multiprocessing import Pool import ts_simulators # Get information from config simulator_config = snakemake.params.simulator_config simulator = getattr(ts_sim...
c061d6d958a159582b9d0ab5c9927c1efe5b049a8c7af9d7d11e5356ea028bce
Python
3,698
123
"""Local whole-genome MSA access for GPN-Star training and inference.""" from typing import Any import numpy as np import zarr from gpn.data import ReverseComplementer, Tokenizer, slice_alignment class GenomeMSA: def __init__( self, path: str, n_species: int, subset_chroms: list...
b384828da6309acda90529d1c976fc26a5b46a18c126012fbcd496bcb2f1c0b8
Python
3,701
126
from unittest.mock import MagicMock import anndata import numpy as np import pytest import novae from novae._constants import Keys from novae.utils._validate import log N_PANELS = 2 N_SLIDES_PER_PANEL = 3 adatas = novae.data.toy_dataset(n_panels=N_PANELS, n_slides_per_panel=N_SLIDES_PER_PANEL) single_adata = adat...
f3e8f7e2276d8fcd6ebe4321895a64120dbc395510cda9818366f5c795877bc4
Python
3,701
92
import os import pandas as pd from BLRun.runner import Runner class GRNVBEMRunner(Runner): """Concrete runner for the GRN-VBEM GRN inference algorithm.""" def generateInputs(self): ''' Function to generate desired inputs for GRNVBEM. It will create the input folder at self.working_di...
41cc5691001907b8169e0c9c7b809f386a3cfc55edf53bba98bd4ad67e73a56a
Python
3,702
106
"""The shipped pooling default is length-invariant, on the class head. `logsumexp` is `max + log(T)` to within a bounded correction, so on ~8,000-token documents it hands every column about nine nats of length bias and the cheapest answer to the pooled objective becomes a channel that never fires. The assertion turns ...
20554fe9aac2db06a6ff43c554a3fc898a2b1cc162fa870596cae91f2477d279
Python
3,703
90
""" Logits-based knowledge distillation. """ from __future__ import annotations from typing import Dict, Tuple, Union import torch import torch.nn.functional as F from .base import DistillationMethod class LogitsDistillation(DistillationMethod): """ KL divergence on segmentation logits. Config paramet...
d888dab58537b4d1b6683f6b0934a90914c41cd209d0b4316961d5394cdd5232
Python
3,705
87
#!/usr/bin/env python3 """SET-AFTER-USE check: an option SET below the line that already consumed it. usage: set_after_use.py <script dir> Distinct from use-before-definition and invisible to it. The variable IS defined before use - typically by a guarded default near the top - so nothing errors. The problem is t...
fbd32f61524c5b68ac2c7e7c409e52a8abeead9f63e1e323853e86b86d9f98f9
Python
3,706
105
import math import numpy as np import pandas as pd import matplotlib.pyplot as plt def load_relevance_matrix(input_path: str) -> pd.DataFrame: data = pd.read_csv(input_path, delimiter='\t') return data def random_cosine_similarities(data: pd.DataFrame) -> pd.DataFrame: splits = data["Group"].value_cou...
1b8be0edff02892b53492008a3353a59eefda62daba9a420cea8c3c279d005a2
Python
3,707
100
#!/usr/bin/env python3 # MIT License # # Copyright 2025 Broad Institute # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to u...
5f662f5b95706236316acd2d7bb8da79f2304cd2d99145ee0c61fcb908e1acc5
Python
3,707
98
from umap.parametric_umap import ParametricUMAP from msi_visual.utils import normalize, segment_visualization import tensorflow as tf import numpy as np import os import cv2 from pathlib import Path import joblib class UMAPVirtualStain: def __init__(self, n_components=1, start_bin=0, end_bin=None): ...
a0c65a0783fe6e7bd2dedb188bd2d7318708123de091735efc0bac33ffef6cd5
Python
3,710
118
# # 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...
94e79ae2eb42b8875f1696e8d7b371385f680f8d1dbb3fb44b8818f250fd2fcd
Python
3,711
77
#! /usr/bin/env python __author__ = 'heroico' import metax __version__ = metax.__version__ import logging import os import copy from metax import Exceptions from metax import Logging from metax.gwas import Utilities as GWASUtilities import M03_betas import M04_zscores def run(args): if not args.overwrite and ...
0cd1eb3870e6051083c53b1572ff1f51af75eedd26a2279bc49ed387bad0fa77
Python
3,713
125
import re import shlex from pathlib import Path import pytest from gsMap.main import create_parser # Import your original functions def extract_bash_blocks(markdown_text): bash_block_pattern = r""" (?: (?:```|~~~)(?:bash|shell|sh){1,}\s*\n (.*?) (?:```|~~~) ) ...
68396364a58c64b2c8d0fab0186534db9d7dab38a6b478017a4ba4f5f1906d07
Python
3,713
123
#!/usr/bin/env python # Author_and_contribution: Niklas Mueller-Boetticher; created script # Author_and_contribution: Qirong Mao; Implemented feature selection with Moran's I import argparse # TODO adjust description parser = argparse.ArgumentParser(description="SVG selection using Squidpy (Moran's I)") parser.add_...
b9729f100bfa0c96f82335977b1b7a8003bdac2f99bd5b4c0bc297ed239a425f
Python
3,713
124
import json from os import getenv from typing import Any from .._constants import Keys PROVIDERS = ["openai", "anthropic"] def api_request( api_key: str | None, provider: str, model: str, messages: list[dict[str, str]], output_schema: dict[str, Any], max_tokens: int, seed: int | None = N...
c2f473a76f584900050f6865236017e3a262ad34ed4a6f7970bbf799387d1d73
Python
3,715
166
from __future__ import annotations import packaging.tags GET_PLATFORMS = f""" import importlib.util import json import sys from pathlib import Path spec = importlib.util.spec_from_file_location( "packaging", Path(r"{packaging.__file__}") ) packaging = importlib.util.module_from_spec(spec) sys.modules[spec.name...
370866713f7195c0352a354cb62772a0545585359ab771b90489ae267aa9349c
Python
3,717
97
# # estimate.py # Copyright (c) 2020 Daisuke Endo # This software is released under the MIT License. # http://opensource.org/licenses/mit-license.php # #---------------------------------- # This is a function for estimating synaptic connectivity. # if __name__ == "__main__" # "spikefile": a set of spike trains. # Repla...
4f5282d4df3ceb52a55429fe497ed09ac658cba701885ed24c0c000c6afcfc74
Python
3,719
107
# 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 import torch.nn as nn import torch.nn.functional as F class PQEmbedding(nn.Module): """ Quantized counterpart of nn.Emb...
a7831cd3f198a47cefe066a0e3634d28ea2f21e26d521fa6b68424db6308a734
Python
3,719
87
#!/usr/bin/env python3 """R1 ponto 3 (MAE e R2 na Fig. 1a) e R1 ponto 4 (definicao de misto_F). Reproduz EXATAMENTE as predicoes out-of-fold do painel (a) de fig_manuscrito.py -- mesmo GroupKFold por familia, mesma grade de alpha, mesma normalizacao por atomo -- e acrescenta MAE e R2 ao RMSE ja publicado. Nada aqui re...
d19868b6eeb0ae11741e3df4234fae0d24a7cdb6e983c418a95bd0f2ddedff02
Python
3,719
120
""" Training script for the hybrid transformer model. Step-by-step and well-commented for GitHub and IEEE-style reproducibility. """ import os import torch import torch.nn as nn from torch.utils.data import DataLoader from configs.config import Config from datasets.kvasir_dataset import KvasirDataset, collect_image_p...
22e0b0efe7f71f043f5c7fe5fe7c3311371dfba1621305a3a1db7a442b5fce26
Python
3,722
73
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'autonomouse-control(BEAST)/UI/ControlWindowGraphicsView.ui' # # Created by: PyQt5 UI code generator 5.9.2 # # WARNING! All changes made in this file will be lost! from pyqtgraph import PlotWidget from PyQt5 import QtCore, QtGui, QtWidgets ...
50b93cd3fdee8b8d5ebc7b3909523ac3ad91fce0958705816c78e4a50ea991a3
Python
3,724
105
from torch.utils.data import DataLoader import torch import lightning.pytorch as pl from typing import Union, Optional from pathlib import Path from rinalmo.data.alphabet import Alphabet from rinalmo.data.constants import * from rinalmo.data.downstream.ncrna_classification.dataset import ncRNADataset from rinalmo.ut...
b08f8abe011b33856a818013fdbd231396a4cf15f0ff4f26fd8f797f20c100cc
Python
3,726
97
"""Download the Visual Genome dataset.""" import json import os # Imports import click import datasets from datasets import load_dataset from compositionality_study.constants import COCO_A_ANNOT_FILE, COCO_DIR, LARGE_DATASET_STORAGE_PATH @click.command() @click.option("--hf_coco_name", type=str, default="Multimoda...
0267b9213aee9f036065ffcbd82f0ad3553287fc524f8483bfda4b567604b56b
Python
3,729
102
''' By K. Butenko These functions allow to retrieve data about simulated pathways (after Kuncel pre-filtering, but keeping original number of tracts!) and stimulation protocol ''' import matplotlib.pyplot as plt import numpy as np import os import h5py #import seaborn as sns #sns.set() import sys os.enviro...
21ea48e33f2b4d953bd73130d82fceaf4d847ccfa5cd8d6c7420ecc5ef88fd93
Python
3,731
133
# Copyright 2026 Hongyu Sun # Licensed under the Apache License, Version 2.0 import argparse import time from pathlib import Path import numpy as np import torch from torch.utils.data import DataLoader import pytorch_lightning as pl from pytorch_lightning.callbacks import ModelCheckpoint from pytorch_lightning import...
338dcd9478dd200ea372280c1001187acc7ed3b77a43358d8b3b4ddb21b99674
Python
3,731
111
# 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 collections.abc import Collection from dataclasses import dataclass, field from typing import List import torch from fairseq.dataclass i...
7da252741e9c46abb99b96446184a14702972cb332b8c9a0d0ec1dc8a1e11620
Python
3,732
118
import logging from sklearn import svm, linear_model from sklearn.ensemble import AdaBoostRegressor, RandomForestRegressor from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier from sklearn.gaussian_process import GaussianProcessClassifier from sklearn.linear_model import Ridge, ElasticNet, Lasso, SG...
aaf439728d341024f132496055452d05888b7fb28bb21c160e68a92cece5368b
Python
3,734
89
"""SIESTA-PBE textbook validation: does periodic DFT rank perovskite polymorphs correctly, before committing to the full 100-structure pipeline? Relaxes all 5 polymorphs (variable cell) for 4 compositions whose experimental ground-state structure is unambiguous, and checks that the lowest-energy polymorph matches expe...
3e2674952eb9f25bccf776c499233c2878598ea6bf86eb7246313533cafa7881
Python
3,738
114
# 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 fairseq.modules.sparse_multihead_attention import SparseMultiheadAttention class TestSparseMultiheadAtten...
537ddf9f0d1d76840f4a05d65f92b54dfd3027fbd467df1222f10dcfdd57f6a8
Python
3,738
131
""" This module contains the model of the table shown in controller UI. """ """ 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 the Free Software Foundat...