sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
bbdc964ed3787cf5c1f53c90e9cdea9b8336ef02c524631b6d23a31afeb247a4
Python
4,576
122
"""Logging setup shared by the command-line entry points.""" import logging import shlex from pathlib import Path class WarningSpacingFormatter(logging.Formatter): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._previous_was_warning = False def format(self, recor...
a07d8f211dc89b7899b8252f738cc3292273f69c8a315359a0b909d4de01d1e2
Python
4,578
135
#!/usr/bin/env python3 # import models/encoder/decoder to be tested from examples.speech_recognition.models.vggtransformer import ( TransformerDecoder, VGGTransformerEncoder, VGGTransformerModel, vggtransformer_1, vggtransformer_2, vggtransformer_base, ) # import base test class from .asr_test...
d3e37c5627cf24ea57f9398e4c5e66849058d4c25e6db12881f74e905a9a86e1
Python
4,580
138
import difflib import os import typing import urllib.request import simplejson as json class FuzzyDict(dict): """Provides a dictionary that performs fuzzy lookup""" def __init__(self, cutoff: float = 0.6): """Construct a new FuzzyDict instance items is an dictionary to copy it...
23f9ef7fab54a5c80931f86a0c6d345a19a302286a5bde082c0ec9764cdc1158
Python
4,583
146
"""``label_audit.py``: the guard-check script over the index it audits. `build_index` used to be a hand-copy of `d3text.cli.precompute_token_labels.build_index`; the identity check below is what would have caught that. The digest checks exercise `check_store_index` directly rather than `main()`'s stdout, per the same ...
d23707ba6265549d620de278babdf5d17a39af8fa1aaadbf1642a63a65206f08
Python
4,584
143
import os import numpy as np import torch from torch.utils.data import DataLoader from lightning.pytorch.loggers import TensorBoardLogger from lightning.pytorch.callbacks import ModelCheckpoint, EarlyStopping from lightning import LightningModule, Trainer from sbi.neural_nets import posterior_nn from data_handlers im...
e2b913092ba960995e41b84a40572d25f66414c4dc737ae22cec38139f890954
Python
4,584
158
# @license # Copyright 2017 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...
7e0fc94dad6dfaa318ce4ed252e58c126ba2cd64c1a6c315b3ba65a79559eeff
Python
4,585
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 math from dataclasses import dataclass import torch.nn.functional as F from fairseq import utils from fairseq.logging import metrics f...
3cb3d3128e69103e5f16afef925ce96c4646b3b09a51cba6b8c6f1a8bf52eae0
Python
4,586
156
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ softmax-based NCE loss, used by this project. """ import torch from torch import nn from .loss import Loss class NCE(Loss): def _...
6e70fcf38ed671f0de47f2cdf56625b2daf0f29b6e4eb1da5598b67703cf4c07
Python
4,587
126
# 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 from dataclasses import dataclass, field import torch.nn.functional as F from fairseq.logging import metrics from fairseq.tasks ...
10e0eb3753e94fec9dc09e496ae1e301bfd70def535886354a6d28189161e0b3
Python
4,589
119
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from typing import Literal, Optional import torch from mattergen.diffusion.corruption.sde_lib import SDE, maybe_expand from mattergen.diffusion.data.batched_data import BatchedData from mattergen.diffusion.training.field_loss import aggregate_p...
e44ff992ac1e84a4f3189b84285acb28997fcdc2d3358c17a8bde7ed4e3f6f51
Python
4,590
110
#!/usr/bin/env python3 """Builds the schema.py module.""" # This needs to have no dependencies on the BPReveal module since this is # executed while BPReveal is being set up and it won't be on the path yet. import sys SCHEMA_HEADER = ''' """Auto-generated schema validators for the JSON used by the main CLI.""" # DO N...
2bd4626164a9f2399d06203d85c7876c0c61eafcc4bf3f8b93afe22684c7fcb9
Python
4,591
144
# -*- coding: utf-8 -*- import os from .utils import load_json, get_jinja_tpl, TPL_PATH from operator import itemgetter class Dashboards(object): def __init__(self, jsonPaths, tags): self.jsonPaths = jsonPaths self.tags = tags def run(self, _type, dashTags): # Usefull directories ...
48e184f194e05555fa2fff44e41d9bc038b6f03560c6b3c69f08bb9c507f58a3
Python
4,591
122
"""Deprecated compatibility shim for :class:`pgmpy.causal_discovery.PC`.""" from collections.abc import Callable, Hashable import networkx as nx import pandas as pd from pgmpy.base import DAG, PDAG, UndirectedGraph from pgmpy.causal_discovery import PC as _PC from pgmpy.estimators.BaseConstraintEstimator import Base...
94b3952a4b8ab56cc23083383efb0d49607f5548e25c6d7a3b9d2069be7b2374
Python
4,593
117
"""Figure 5 panel A — cross-species method comparison bars (Lisberger→Hull). KNN balanced accuracy for Lisberger (macaque) → Hull (mouse) transfer, six methods including VAE baselines. Outputs: figures/29_figure_5_cross_species/panel_a_method_bars.{svg,png} """ from __future__ import annotations from pathlib impo...
5e7cb7d50a4df2d670f13f63932f60cba6d55fb13fb7b16a57d24372f1878179
Python
4,594
140
""" Byte pair encoding utilities from GPT-2. Original source: https://github.com/openai/gpt-2/blob/master/src/encoder.py Original license: MIT """ import json from functools import lru_cache @lru_cache() def bytes_to_unicode(): """ Returns list of utf-8 byte and a corresponding list of unicode strings. ...
bdee53a00b176562e69ce5ede58f4c4f7ac9804177a1ecf86af26a3b0903dc77
Python
4,594
114
# 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...
e6d96405d09d116275725bd0cbc0e1c37048f89b58a0925a4633417f5a6739c9
Python
4,594
100
#!/usr/bin/env python # PYTHON_ARGCOMPLETE_OK """Create a (brain) mask for the given DWI. This uses the median-otsu algorithm.""" import argparse import logging import os import mdt from argcomplete.completers import FilesCompleter import mot.configuration from mdt.lib.shell_utils import BasicShellApplication from mot...
140eefdc5a581e37d77273c3cc0cdc8e279f7ac8b3b716d2825dc633936366d5
Python
4,595
121
#!/usr/bin/env python """Score the dictionary linker on enzymeNER's spans, grounded through Expasy. The weakest of the three external evaluations, and the caveat is printed with every number: enzymeNER marks spans without naming them, so the gold EC number is itself a dictionary lookup. That the dictionary is Expasy's...
208590926c21fa3088227152a3655f982d01670f9d44df9a35687e4f4c30a47b
Python
4,595
125
import unittest from datetime import datetime from unittest.mock import patch from pyecharts.charts import Bar from pyecharts.options import InitOpts, RenderOpts from pyecharts.globals import CurrentConfig, Locale from pyecharts.charts.base import Base, default from pyecharts.options.series_options import AnimationOpt...
947a8e4bf9dd7ad74ec172d5fa9768fcd090c2b6e89c9f0ac394a57df1bafabf
Python
4,600
92
#!/usr/bin/env python3 """A simple utility to revcomp-augment data.""" import argparse import pybedtools import numpy as np import pysam import pyBigWig from bpreveal import logUtils from bpreveal import utils, bedUtils logUtils.setVerbosity("INFO") def getParser() -> argparse.ArgumentParser: """Build the parser ...
7afea210c6cff8be5de26543755ea189a16ae0b536617d88371ac019a9db5225
Python
4,604
129
from __future__ import annotations from typing import TYPE_CHECKING from typing import ClassVar from cleo.helpers import argument from cleo.helpers import option from poetry.core.constraints.version.version import Version from poetry.core.version.exceptions import InvalidVersionError from poetry.console.commands.com...
c28a38e0559e9003305cc6167f4887b9a8297c2956914034d2d981bef37d29cb
Python
4,607
144
import logging from typing import Tuple, List import numpy as np from statsmodels.stats.multitest import multipletests from scipy import sparse import loompy class FeatureSelectionByEnrichment: def __init__(self, n_markers: int = 10, mask: np.ndarray = None, labels_attr: str = "Clusters", findq: bool = True) -> Non...
3d947adb6afc57e4fd7998f2b388b28aa09004ab9df6c1247f74e5add6babe13
Python
4,608
118
from __future__ import annotations import argparse import json from pathlib import Path import anndata as ad import pandas as pd import scvi import torch from scvi.external.stereoscope import RNAStereoscope, SpatialStereoscope def parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser(description=...
5dee2aec03c98cf15785bc0351c71d008b87fa5362a353a09be3118c15e42b2a
Python
4,609
111
import numpy as np import math # --- You can add your own model classes here --- # Each model class should contain: # - the attribute .name # - a function .generate() returning a prf_dict with at least key 'prfs' # that is then used by # - a function .predict() to create predictions for each pRF # --- Preset ...
e3d705eb63d539bced3b3d98c3a948f772b14466ed04fceb800cda438754311f
Python
4,616
109
#!/usr/bin/env python3 # Copyright (c) 2018-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import codecs, sys, time, math, argparse, ot import numpy as np from utils import * parser = argparse...
f36817188ffa5feb827ef76da2e1be837596ede07b01260589e2193e09eb63b1
Python
4,616
130
import os import tempfile import unittest import yaml from pydantic import ValidationError from simulation_encoder.dataclass.config_schemas import ( HyperparameterConfig, MainConfig, ModelArchitectureConfig, ) from simulation_encoder.utils.yaml_utils import ( load_hyperparam_yaml, load_model_yaml,...
838e48aab0e079f8b65cc00006f2e06b9d732094604cb5494974ca3a2b7b656f
Python
4,622
146
from __future__ import annotations from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from cleo.testers.command_tester import CommandTester from poetry.config.config import Config from tests.types import CommandTesterFactory from tests.types import MockedPoetryPythonRegister @pytest...
ad44114b3c8ebf4e149da2faab1db2da16fcfcb7e2a83616e9863b16d7647ae6
Python
4,623
143
# 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 multiprocessing import Pool import os from collections import defaultdict from itertools import starmap import torch from npy_append_arr...
ecf6a16db8c61e3c739ac978445d7dd2ad8f16f305bbdebbcd91ac4edebd3e79
Python
4,623
114
#!/usr/bin/env python3 """Print a calculation-combination plan without running any calculations. This is intentionally a planning tool. It resolves matrix rows to the manifest command and records input overrides, but it never copies examples, edits inputs, launches gmx_MMPBSA, or creates result directories. """ from...
f44ddcdfb2e3f85ee952ddb77c20cce5a362d3533233e5b9626a43facdde8b6f
Python
4,623
76
from typing import Tuple import torch from nnunetv2.training.dataloading.data_loader_2d import nnUNetDataLoader2D from nnunetv2.training.dataloading.data_loader_3d import nnUNetDataLoader3D from nnunetv2.training.nnUNetTrainer.nnUNetTrainer import nnUNetTrainer import numpy as np class nnUNetTrainer_probabilisticOv...
fa8ffc03168cb678c85d9194f3745430e61ea0e5acf9aa04a4645b20e68de670
Python
4,623
129
#!/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 use...
d862fb34388dff64354ca3e44d516d0c1f8f65161d84020558513e7e12bce091
Python
4,624
138
#!/usr/bin/env python3 """Invoked by `build.sh` inside a container to build `neuroglancer_draco.wasm`. Expects the directory of the Neuroglancere repository that contains this script to be mounted as the current working directory inside the container. Expects /usr/src/draco to contain the unpacked draco source code ...
1f7f39bc7d8fac8275c7fefbb3dbd0f1ab5463aaa0c592b39a05a4ea6f870026
Python
4,627
118
"""Product gene lists with ASCII art sections and GO IDs for each gene product.""" import sys import collections as cx from goatools.grouper.aart_geneproducts_one import AArtGeneProductSetsOne __copyright__ = "Copyright (C) 2016-2018, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" cla...
aa423e70235569e303dda273942f2b24d50c4c7aeca1da62598e3a6423f9491c
Python
4,629
123
# 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 copy import unittest import tests.utils as test_utils import torch from fairseq.criterions.cross_entropy import CrossE...
4fac0eb3e9b422d259763d58665ff2f1ca709ac8d02f3861e3773744678e45ed
Python
4,635
137
"""Train and evaluate the OCE v1.0.0 (JPCL submission) on percolation clusters. We re-use the design-matrix code from `oce_v1.0.0` *unchanged* — only the INPUT differs (carbon-only clusters with arbitrary connectivity instead of small organic molecules). This is the cleanest possible application of the published meth...
059c5a875d8f99084de418b537b0dee732f199a1da628cdfea3787aa5bf23a9e
Python
4,636
152
"""``check_imports.py``: the gate that catches an unimportable package. Exercised against throwaway projects rather than against this one, for two reasons. Importing the real entry points costs half a minute, and `test_entry_points.py` already starts every console script; and the failure this gate exists for cannot be...
0c6788feb44bb912f0e7ad9bc7a01387f2cae1510bc8fc6aaf3b93057e067fff
Python
4,638
119
import streamlit as st import joblib import os import numpy as np from pathlib import Path from PIL import Image from collections import defaultdict import pandas as pd import time from msi_visual.app.utils.pipeline import create_pipeline from msi_visual.app.utils.extraction import get_extraction import wx ...
baba718b04f49c1fc56af131e27429bee78e7d91d636a708685b07a8a88f09c2
Python
4,639
128
import numpy as np import pandas as pd import pytest from pgmpy.causal_discovery import ANM @pytest.fixture def nonlinear_data(n=1000): """Generate additive-noise data with X -> Y, where Y = X ** 3 + noise.""" rng = np.random.default_rng(0) x = rng.uniform(-2, 2, n) y = x**3 + rng.normal(0, 0.5, n) ...
54fc5555e77cd1636d1d4d1f790af590757b33d1946a19d57bf06efd6e170703
Python
4,641
121
# 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 import torch.nn.functional as F from fairseq import utils from fairseq.logging import metrics from fairseq.criterion...
d03a8e2eb695c3c6ec309c6b50005d91e653b1a664b98a9740964199b49e890d
Python
4,644
104
"""Used to find all genes or gene products annotated w/GO terms that match a regex.""" import sys from goatools.obo_parser import GODag __copyright__ = "Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" class GoSearch(object): """Returns GOs matching a regex p...
4770daf0ee41c7f8ae76dabf6d5471866a20acad6c30bf469939e61ce82a97af
Python
4,645
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 bisect import numpy as np from torch.utils.data.dataloader import default_collate from . import FairseqDataset class ConcatDataset(...
536493374dd2fe92d188dc5b84e224a0b95150783d2c522fe417259001e0c689
Python
4,647
165
from __future__ import annotations import os from typing import TYPE_CHECKING import pytest from cleo.io.null_io import NullIO from cleo.testers.application_tester import ApplicationTester from cleo.testers.command_tester import CommandTester from poetry.installation import Installer from poetry.utils.env import M...
6ce5b2e43a9a9b779aada6ffe1bf5e06673d41a4afaebfdd0cc6fa28ce6976df
Python
4,647
127
from matplotlib import pyplot as plt from matplotlib import gridspec import seaborn as sns sns.set_style("white") from theano import config import numpy as np from data_funcs import data_resamp from utils import * def plot_od(od, label = None, col = None): plt.plot(*zip(*sorted(od.items())), label = label, color...
0199cd67f22541624d5764dc2712a341eef767b8532ad77fc2e1bf4655031a53
Python
4,648
125
# 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 contextlib import logging import os import tempfile import unittest from io import StringIO from unittest.mock import patch from fairs...
4d315217fb99817c3234b9adcdffc79c16641a7b20bc1425a5dba0b78af4c3bf
Python
4,648
115
from ... import options as opts from ... import types from ...charts.chart import Chart from ...globals import ChartType class Funnel(Chart): """ <<< Funnel >>> Funnel diagram is suitable for one-way analysis of single process with standardized business process, long cycle and multiple lin...
96b4dae097f491f1c523bbe9d1450f0762d62d6624d849eba4df6d7096f7432e
Python
4,648
96
"""Constants for the compositionality study repository.""" import os from dotenv import load_dotenv # Use dotenv to properly load device-dependent constants load_dotenv() HERE = os.path.dirname(os.path.realpath(__file__)) SOURCE_DIR = os.path.join(os.path.abspath(os.path.join(HERE, os.pardir))) PROJECT_DIR = os.pat...
288ba908703c26e7b6bd56e9e14909b3bf8a332c934d5c216fa6f2cd52e9e3c6
Python
4,649
124
import argparse import pandas as pd import numpy as np from typing import List, Tuple def read_file(tsv_file: str) -> Tuple[List, pd.DataFrame]: """ Reads the input 4-column cosine similarity existing pairs TSV file in a pandas dataframe, generates all the unique PMIDs and returns the dataframe. Param...
77b8c3aae31d90ff8f0ab8677639b049fb5d233c16a313a5f24c6b4e243df5fe
Python
4,651
140
import sys from os import makedirs from os.path import dirname, realpath, exists current_dir = dirname(dirname(realpath(__file__))) sys.path.insert(0, dirname(current_dir)) import pandas as pd import os from config_path import * from analysis.data_extraction_utils import get_node_importance, get_data from utils.loadin...
10012e1d27129acb1c5addb9ea80d4d57ae7add1f71ed11f31fc02fa1b2a4920
Python
4,652
195
import os import nox nox.options.default_venv_backend = "uv" nox.options.reuse_existing_virtualenvs = True nox.options.error_on_external_run = True @nox.session def lint(session): session.run_install( "uv", "sync", "--only-group", "ruff", env={"UV_PROJECT_ENVIRONMENT": se...
30a2987c39d8a8925f510451145a27c89a51744103c942c780f6c168be8d12b8
Python
4,653
98
#!/usr/bin/env python3 """Hypergeometric disease-catalogue over-representation for the inverse-concordant pool. Methods 4.8: "Disease-catalogue overlap of the full 94-gene discovery pool used a hypergeometric test against the genes testable in both discovery layers." No script in the release performed it; the earlier ...
290824621fe5c1668c881e0a3bdf31c4612ddf04db19ac52b82e677e0f76fe15
Python
4,654
103
"""Cross-matrix synthesis (Paper #2): consolidate the three per-food benchmarks into one comparison table + figure, highlighting where the interpretable KAN earns its place across chemically diverse matrices. Reads paper2/results/<food>/{Table_cv,Table_holdout}.csv + <food>_meta.json. Writes paper2/results/summary/. Ru...
5dd766f8501666bcfcf82bfca6c3b90fd34a6c6397f0bb77ebe72a052d1e3422
Python
4,654
128
# 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 editdistance import re import shutil import soundfile as sf import subprocess from pathlib import Path from examples.s...
dd62a201a3d6bf32fca5d9dde0e3e4fd3db6aa6dd93fc2436fca3f88784ae1ac
Python
4,656
130
import pandas as pd from sklearn.model_selection import train_test_split import torch from torch.utils.data import DataLoader, Dataset from latent_model.loaders.encoded_csv_splits import train_val_test_ids_from_encoded_csv class TimeSeriesDataset(Dataset): """Dataset for time-series or otherwise ordered data wit...
bfaf819e3a3e1f38bc8a6713815a8e97cfb9de8bee78efdddbb9c2729576d29b
Python
4,661
136
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from typing import Dict, Iterable, Protocol import torch from torch_scatter import scatter from mattergen.diffusion.corruption.multi_corruption import MultiCorruption from mattergen.diffusion.data.batched_data import BatchedData from mattergen....
58f7867f051659f894b973c0c6f3ea5c5ca6b951725e6248b16474ec0a9a1b0f
Python
4,664
140
#!/usr/bin/env python import networkx as nx import numpy as np import pandas as pd from pgmpy.causal_discovery._base import BaseCausalDiscovery, _TreeSearchMixin class ChowLiu(_TreeSearchMixin, BaseCausalDiscovery): """ Chow-Liu algorithm for learning tree-structured Bayesian networks. Constructs the m...
c2c020d607cba4f8646104e2d2e2a92959b081218684431add781d2591f2d49a
Python
4,664
103
import traceback import click import numpy as np import xarray as xr import zarr from tqdm import tqdm from ..utils.decorators import error_handler from .ica_utils import compute_pca_ica def chunk_pca_ica(dataset: str, chunk: int|None, slice_areas: xr.DataArray, chrom_subset, n_slices=36): n_frames = slice_areas....
7c00b81b186987bae83ec6b4d765c4051b652a4103b0cd03bba6709736ff5100
Python
4,665
97
#!/usr/bin/env python3 """Assemble Supplementary Table S3 (per-series sex and age composition), Methods 4.2. WHY THIS EXISTS. Methods cites Supplementary Table S3 for the sex and age composition of every cohort, but no script assembled it: the delivered CSV was written by hand, so its per-series percentages could not ...
7dc5c78fd767ae8839a97376ad2dce464e4c79a6a46a8cff1a4e8fe84bdcf3bd
Python
4,666
128
# created by DebarpanB # date 26th August, 2022 import argparse, configparser import numpy as np import pandas as pd import pickle import os import random from sklearn.decomposition import PCA from sklearn.preprocessing import StandardScaler from sklearn.ensemble import RandomForestClassifier from sklearn.model_select...
d7164e3ab3d665691b43953d8348c69b9c0d2e41be07528c20c27b0a2b43ceeb
Python
4,670
140
import seaborn as sns sns.set_style("white") import numpy as np import pyspike from utils import rebin from data_funcs import sampleXY import math def get_pred_mse(model, cell, traces, samples, spikes, p_sample=None): """ Calculates the mse_rec_pred and mse_rec_truth metrics during training. """ buf...
a172eb5850a58f3a1a5e51c7b74d21782a085ff00e4682ff27a51e704f5bf882
Python
4,672
127
import torch import torch.nn as nn import torch.nn.functional as F from .. import functional as vakF __all__ = ["dice_loss", "DiceLoss"] # adapted from kornia (https://github.com/kornia/kornia/blob/master/kornia/losses/dice.py) # originally based on https://github.com/kevinzakka/pytorch-goodies/blob/master/losses.p...
e4f051565cf5f82ef39cb2b6e71b747c482374ec250d74ec8389ec922fe00adb
Python
4,673
125
# encoding: utf-8 """ @author: Jiayang Chen @contact: yjcmydkzgj@gmail.com """ from torch import nn import torch from functools import wraps class DownStreamModule(nn.Module): """ base contact predictor for msa """ def __init__(self, backbone_args, backbone_alphabet, depth_reduction="none", ...
b67afbb8735ac38c3504613df89a6ddaa0583344fa0dab97482348c5c257f80f
Python
4,674
138
import pytest import vak.config.trainer class TestTrainerConfig: @pytest.mark.parametrize( 'config_dict', [ { 'accelerator': 'cpu', }, { 'accelerator': 'gpu', 'devices': [0], ...
80d2350bf2f4a048398992ef0304c5743d5260d15524796d68ef4cdab55bfbdf
Python
4,676
126
import numpy as np import pandas as pd import pytest from pgmpy.causal_discovery import IGCI @pytest.fixture def nonlinear_data(): """Generate near-deterministic data with X -> Y.""" rng = np.random.default_rng(0) x = rng.uniform(0, 1, 500) y = x**3 + rng.normal(0, 1e-3, 500) return pd.DataFrame(...
bdff4548cbc0937afff40dffa0195fdd193687d45de2e56312485703777a7035
Python
4,677
140
#%% import SimpleITK as sitk import pydicom as pydicom import json import pandas as pd import os import numpy as np import subprocess from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor, as_completed NUM_WORKERS = os.cpu_count() // 2 from tqdm import tqdm DATA_DIR = os.path.joi...
9b158f834dd3e7f031e92972d748affced2269af08f836a2a1c38b4aa8d1ad65
Python
4,679
138
from typing import Any import numpy as np class Trajectory: """A class that defines a trajectory through a latent space. This class creates a trajectory through a latent space by connecting a sequence of points (e.g., cluster centroids) with straight lines. The trajectory is parameterized by time, w...
84e4e7db7a8f98910507e68e5caa9952de89ba55759b8f4cae8b0dee97df3b5b
Python
4,680
148
import skimage.io as skio import numpy as np import torch from torch.utils.data import Dataset, DataLoader from src.utils.util import get_coordinate from src.utils.dataset import DatasetSUPPORT def normalize(image, mean_image=None, std_image=None): """ Normalize the image to [mean/std]=[0/1] Arguments: ...
48ae8a568b38595bcee746950bcf6f4e87d64ad17efbb7243e70e4516ea116d0
Python
4,683
110
from typing import List import torch from e3nn.util.jit import compile_mode #from nequip.data import AtomicDataDict from ..data import AtomicDataDict from nequip.data.misc import chemical_symbols_to_atomic_numbers_dict from nequip.nn._graph_mixin import GraphModuleMixin from nequip.nn.utils import scatter, with_edge...
cbb90bba07dc4d338f4b2b902a7b6867af2252721fc2974c6596cf018d6d264f
Python
4,687
173
""" This module contains methods to analyse read data. """ """ 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 Foundation, either versi...
33336970d48e82e586da7211bbbe0e3f0da2fce1d17571bc7a5cf3f372eb9155
Python
4,690
141
import numpy as np def constrainValues(input_array): output_array = np.copy(input_array) output_array[np.isinf(input_array)] = 0 output_array[np.isnan(input_array)] = 0 output_array[input_array > 1] = 0 output_array[input_array < 0] = 0 return output_array def getNextMerge(c...
91e23fc75617d5310431045e458238fb0ffbef5fe2acf53820aa3c3163f79071
Python
4,690
137
"""xtb GFN2 single-point and optimisation for radical carbon clusters. We do NOT terminate dangling bonds. Instead, we let xtb treat the cluster as a high-spin radical molecule by passing `--uhf` = parity of the total electron count (so xtb finds the lowest-energy state of the correct spin-parity). Note: GFN2 with t...
40148324edd839a80436630ecad33955efe10dd81c33a786477bb1b96abeb260
Python
4,691
147
import pytest from pathlib import Path from scgpt.tokenizer import GeneVocab, get_default_gene_vocab from scgpt.tokenizer.vocab_compat import ( BuiltinVocab, gene_vocab_base_backend, torchtext_import_succeeded, get_vocab_info, is_torchtext_vocab, from_torchtext_vocab, ) def test_gene_vocab(): ...
ae244364f7e8212aca5e3b74f372c3465966ed473aaf7b1c4f4fe16b0fc8bb37
Python
4,691
115
import itertools from ... import options as opts from ... import types from ...charts.chart import RectChart from ...globals import ChartType class Scatter(RectChart): """ <<< Scatter >>> The scatter diagram on the rectangular coordinate system can be used to show the relationship betwe...
3d738cfce17b8039373a92ac5ecfd4828853e2683dfb4bc131691e47d72bb1ed
Python
4,692
145
# 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 from dataclasses import dataclass from typing import Dict, List, Optional import torch from fairseq.dataclass import FairseqDa...
63f85c57c1558cd3a9128a45b559da863d31e01fffc0099c7151e3f4a256b518
Python
4,695
167
#!/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 use...
ecfc3dad9fb410abcb69e31dc161e5560de7249bc7524add3ff0b752350b5fbf
Python
4,695
157
from abc import abstractmethod from functools import reduce from opt_einsum import contract class BaseFactor: """ Base class for Factors. Any Factor implementation should inherit this class. """ def __init__(self, *args, **kwargs): pass @abstractmethod def is_valid_cpd(self): ...
fa389e00bb21607b856223514858d7bed265969753925dec0debeaed899b94c7
Python
4,696
101
#! /usr/bin/env python import os import logging import numpy from timeit import default_timer as timer import pandas from metax import __version__ from metax import Logging from metax import Exceptions from metax import Utilities from metax.predixcan import MultiPrediXcanAssociation from metax.predixcan import Utili...
48af9a53d1e075ce08d21e8fec71f2cf83ea4d44cbefbb2fc6c4df30354e59dd
Python
4,699
157
# Copyright 2020 The Lucent Authors. 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 ...
884e2b5f8261c2905922a858b4e9036ad728ffdc955fd86e0e127070dcc7bd40
Python
4,700
123
from ... import options as opts from ... import types from ...charts.chart import Chart from ...globals import ChartType class Radar(Chart): """ <<< Radar >>> Radar maps are mainly used to represent multivariable data. """ def add_schema( self, schema: types.Sequen...
d054b7cf29b198fc66f103cdbb99efba119e5f6587a041ec91a1ba346debb618
Python
4,703
125
import os import pickle import warnings from typing import Literal import numpy as np import torch from anndata import AnnData, read_h5ad from scvi import settings from scvi.data._download import _download def _load_legacy_saved_gimvi_files( dir_path: str, file_name_prefix: str, load_seq_adata: bool, ...
dd56d3eb6fa189a577e56e309c7f186114e3b31e7042d0faf538a67a719bde39
Python
4,703
151
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.outputs.output import Verbosity from poetry.console.commands.init import InitCommand from poetry.console.commands.show import ShowCommand if...
aec7018faac2db1a3330d7d9fae0c4a449c6086ee19c842a7fe117024920751a
Python
4,704
104
from typing import Tuple, List import numpy as np import loompy class AutoAutoAnnotator: """ Automatically discover suitable auto-annotation marker combinations """ def __init__(self, pep: float = 0.05, n_genes: int = 6, genes_allowed: np.ndarray = None) -> None: self.pep = pep self.n_genes = max(2, n_genes...
cfc355695d2a1650b3d8578695163f10e99e616ea9ebcf237c3d072e1c925f67
Python
4,704
115
import os import functools import unittest import toml import torch import medaka.architectures import medaka.architectures.base_classes import medaka.features import medaka.models from medaka.test.test_sample import get_test_samples import medaka.torch_ext __model_config__ = os.path.join(os.path.dirname(__file__),...
972917f797fc47d4b8dbf6e921b951e18aa05e0685c327ec6f31b802065c3880
Python
4,706
135
# 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...
139d1f21921b9639af25a57bc920075bac24520c33bae4d4e98ab1313877678b
Python
4,707
125
# Copyright 2018 The Lucid Authors. 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 l...
745820b817ee6135b6866df3a73d34093378ec0f9bb415b70389b451bf1d02ee
Python
4,708
125
import torch import torch.nn.parallel import numpy as np import torch.nn as nn import torch.nn.functional as F from ..layers.convolutions import Convolutional class Downsample(nn.Module): def __init__(self, pad_type='reflect', filt_size=3, stride=2, channels=None, pad_off=0): super(Downsample, self).__init...
15597ca842424acbdc3e4b68d3b89383d8b7f83ae5622e44128c034aae054a6b
Python
4,709
180
import networkx as nx import numpy as np import pandas as pd import pytest from joblib.externals.loky import get_reusable_executor from pgmpy.causal_discovery import ChowLiu from pgmpy.factors.discrete import TabularCPD from pgmpy.models import DiscreteBayesianNetwork from pgmpy.sampling import BayesianModelSampling ...
23c50ab32e4a4767921b1e003fbdaf2d9caf1303b6fc831359ec0bd089966ea3
Python
4,709
139
# 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 .dictionary import Dictionary, TruncatedDictionary from .fairseq_dataset import FairseqDataset, FairseqIterableDat...
80b4d40bd3a11229cd1d4a9438016eb2703f1b72c7283fb02f90989e205eaffe
Python
4,709
132
import argparse import json from collections import defaultdict import os from tqdm import tqdm import sys import subprocess import re import math import numpy as np import editdistance from sklearn.preprocessing import StandardScaler from multiprocessing import Pool from functools import partial import random cer_lan...
d8efe021cc3366238dd5c9041050b2f18f0692bdf83a9032f1f01525cd12c88a
Python
4,710
131
# # 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...
51985b3ba4f438a9afb431dc0b43c678695c18df4872f74dff19202ec5253fbb
Python
4,713
167
""" Constants that might be used by multiple scripts """ import numpy as np # how many times each image was shown N_REPEATS = 3 SUBJECTS = ["01", "02", "03", "04", "05", "06", "07", "08"] # layer names for different models RESNET18_LAYERS = ( ["relu", "maxpool"] + ["layer1.0", "layer1.1"] + ["layer2.0", ...
5b1d239ad4c4c096e9b7ed432252a1f4f370b4f9616ca45568b33a3c6e02e83d
Python
4,713
111
from PIL import Image from sklearn.decomposition import NMF, non_negative_factorization import cv2 import numpy as np from matplotlib import pyplot as plt from msi_visual.normalization import spatial_total_ion_count, total_ion_count, median_ion from msi_visual.visualizations import visualizations_from_explanati...
8aaf3c58eb16f15305be396f5830560396d7a1160d2441ddad3b7d30403854f2
Python
4,713
126
"""Benchmark OCE vs xtb: speed comparison + scatter plot. Reports: - per-molecule prediction time for OCE - per-molecule single-point time for xtb - speedup factor - scatter plot of E_OCE vs E_xtb on the test set """ from __future__ import annotations import time from pathlib import Path import matplotlib ma...
a72cb6e6059842d902167fbe0fe5708d20a5b37868f0c1cbde1416763f59acc5
Python
4,713
79
#!/usr/bin/env python3 """Literature-standard pseudobulk inputs for the brain (Jaekel GSE118257) and CSF/blood (Beltran GSE127969) cohorts, so all three single-cell cohorts are processed the same way. Jaekel : expr.txt.gz holds RAW integer UMI counts -> SUM per patient x cell type (muscat standard). Region ...
44738a74f1099230ce1b459a439f7453ae171525b3568a7f65e419b5337c31f7
Python
4,716
96
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'UI/ConcGNGUI.ui' # # Created by: PyQt5 UI code generator 5.5.1 # # WARNING! All changes made in this file will be lost! from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Form(object): def setupUi(self, Form): Form.setObjectNa...
ed79dabcd02fab19fe934df9c01c0d41fe9d41cd910c504b9061ebc49dd963a2
Python
4,718
103
import matplotlib from batchgenerators.utilities.file_and_folder_operations import join matplotlib.use('agg') import seaborn as sns import matplotlib.pyplot as plt class nnUNetLogger(object): """ This class is really trivial. Don't expect cool functionality here. This is my makeshift solution to problems ...
eb164ef86a1c0dd511ae070a0274c43ba802075c50842bb7c47925a061769fcc
Python
4,722
144
import os import numpy as np import pandas as pd import pytest from pgmpy.ci_tests import Pearsonr from pgmpy.factors.continuous import LinearGaussianCPD from pgmpy.models import LinearGaussianBayesianNetwork @pytest.fixture def pearsonr_data(): rng = np.random.default_rng(seed=42) df_ind = pd.DataFrame(rn...
edf6ffdeb9984684a8702eae41d4e6f19a65aaf5a8ae61408208ab6d6da3f4a8
Python
4,723
153
# 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...
19779585fecadca54145881c939a778042f4857292195261fe482ecfbc0f1168
Python
4,725
127
#!/usr/bin/env python # -*- coding: utf-8 -*- ######################################################################## # # Copyright (c) 2023 biomap.com, Inc. All Rights Reserved # ######################################################################## import scanpy as sc import time from scipy.sparse import csc_ma...
7192a847b51cd61b1d0c07b1260877faa112bf8d68b9d23e83a728ca0de6e026
Python
4,725
84
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'dialog_get_example_data.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_GetExampleDataDialog(object): def setupUi(self, Get...
99f1b1d8bde59c96e58cf460e9df5af8162ad69e508e0ca45f78fba425a82991
Python
4,727
115
import os import pandas as pd import numpy as np from BLRun.runner import Runner class GRISLIRunner(Runner): """Concrete runner for the GRISLI GRN inference algorithm.""" def generateInputs(self): ''' Function to generate desired inputs for GRISLI. If the folder/files under self.inpu...