sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
e1d06337a9ce0888af148ab2362d922911c7e56d6f8878f8858bc5af153bf194 | Python | 2,020 | 71 | """Evaluation utilities for multi-experiment runs."""
import numpy as np
import pandas as pd
from sklearn.metrics import (
accuracy_score,
f1_score,
precision_score,
recall_score,
roc_auc_score,
)
def compute_metrics(y_true: np.ndarray, y_pred: np.ndarray, y_prob: np.ndarray) -> dict:
"""Comp... |
34baec82d5e1b125e1fc8164076325fa3da8bbc7b32131ce4417dde9264f8dc8 | Python | 2,023 | 66 | # Copyright 2022 Google LLC.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... |
5c35951ecce26727657ca78228ea94e67efd89edf62bae862ca69eff2ac695e6 | Python | 2,024 | 67 | from refs import llm_base_refs
from refs.paper import shuffled_numbers_refs as r
from tqdm import tqdm
from truesight.experiment.services import ExperimentDataRef
EXPERIMENT_GROUP = "shuffled-numbers"
animals = ["dolphin", "eagle", "elephant", "owl", "wolf"]
def build_data(eval_name, evaluation, animal) -> Experimen... |
b3f9b1e10876ff94a05dd47736e63f26bd61dfcbd38f3ffff93bf4ca4f102d4d | Python | 2,025 | 62 | """
Gradio interface for the GO Annotation Review agent.
"""
from typing import List, Optional
import gradio as gr
from aurelian.agents.goann.goann_agent import goann_agent
from aurelian.agents.goann.goann_config import GOAnnotationDependencies, get_config
from aurelian.utils.async_utils import run_sync
def chat(de... |
770ce836a317c3cb2b035a603df652471b925732abc49dba5dd2c7bfb8aa1afb | Python | 2,027 | 47 | import pytest
from openff.nagl._base.metaregistry import create_registry_metaclass
class TestMetaRegistry:
Registry = create_registry_metaclass(ignore_case=False)
RegistryIgnoreCase = create_registry_metaclass(ignore_case=True)
class TestClass(metaclass=Registry):
name = "TestKey"
class... |
ab283de78c03bedd4e821adf97d16ab6f8420e2ac0d0f1da4f694063c0b1fd22 | Python | 2,027 | 51 | #!/usr/bin/env python
__author__ = 'Pavel Polishchuk'
import argparse
import re
import sys
def main():
parser = argparse.ArgumentParser(description='Extract molecules by their names from SDF file.')
parser.add_argument('-i', '--input', metavar='input.sdf', required=True,
help='input ... |
2c2277fdae4c96b89f5c68a703bf9c32688cc6718bf77d294ee2383c35cd2181 | Python | 2,028 | 74 | #!/usr/bin/env python3
"""
Script to add container directives to all Snakemake rules
"""
import re
from pathlib import Path
# Environment mapping
ENV_MAPPING = {
"../envs/ashleys_base.yaml": "ashleys_base",
"../envs/ashleys_rtools.yaml": "rtools",
}
def update_rule_file(file_path):
"""Update a single ru... |
c4441ca8066e8d0533e56bf0ce631b8f1100c710a0ff902ec78e67c32e72b9fe | Python | 2,031 | 61 | import unittest
import tempfile
import os
import six
import caffe
class SimpleParamLayer(caffe.Layer):
"""A layer that just multiplies by the numeric value of its param string"""
def setup(self, bottom, top):
try:
self.value = float(self.param_str)
except ValueError:
... |
10b9becf324dfd9f84d7d9028a464bda569230842fa017ff127fb946995a2ac4 | Python | 2,033 | 68 | # Copyright 2022 Google LLC.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... |
45624f8cb5c0689eac9abf1bdc4fa30f15e04e2097ffef23783c846c266b4d9a | Python | 2,037 | 74 | # -*- coding: utf-8 -*-
"""
.. module:: skimpy
:platform: Unix, Windows
:synopsis: Simple Kinetic Models in Python
.. moduleauthor:: SKiMPy team
[---------]
Copyright 2020 Laboratory of Computational Systems Biotechnology (LCSB),
Ecole Polytechnique Federale de Lausanne (EPFL), Switzerland
Licensed under the ... |
5d7dc50c9b2afd386bb06a13a15d8b38dd0e589882c0488009d1826e3c9a8725 | Python | 2,037 | 49 | """
TissueNet
=========
.. image:: ../../images/multiplex_overlay.png
:width: 200pt
:align: center
TissueNet is a training dataset for nuclear and whole cell segmentation in tissues published in
Greenwald, Miller et al. 2022.
The TissueNet dataset is composed of a train, val, and test split.
* The train spl... |
173ce23c09b1d5a201cc33f972a41d0d676cf47b32b85cf9d5e29076a0d0382a | Python | 2,038 | 59 | import logging
from typing import Dict
from multiqc.base_module import BaseMultiqcModule, ModuleNoSamplesFound
from multiqc.modules.bcftools.stats import parse_bcftools_stats
log = logging.getLogger(__name__)
class MultiqcModule(BaseMultiqcModule):
"""
Supported commands: `stats`
#### Collapse complem... |
b7b40e620cc1338b131250395d2aa5d498d2670e0a716f620c43f75c3788e76b | Python | 2,040 | 56 | # This code is part of kartograf and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/kartograf
import logging
from rdkit import Chem
logger = logging.getLogger(__name__)
def filter_atoms_h_only_h_mapped(molA: Chem.Mol, molB: Chem.Mol, mapping: dict[int, int]) -> dict[int, in... |
a7a395ce06d2962d20802eb49e97601883436c1b762f6079983577059601af44 | Python | 2,044 | 90 | """
Create mol2 file for substituted viologen.
"""
from openeye.oechem import *
from openeye.oeomega import *
from openeye.oequacpac import *
smiles = "OC(=O)CCCCC[n+](cc1)ccc1-c2cc[n+](cc2)CCCCCC(=O)O" # substituted viologen
output_filename = 'viologen.tripos.mol2'
def assign_am1bcc_charges(mol):
"""
Assi... |
bee82364917add375aaa203e744b6cdf409226caff5baeffefa1ca369e839a5a | Python | 2,044 | 67 | """
Copyright (C) 2025, 2026 Sotiris Lamprinidis
This program is free software and all terms of the GNU General Public License
version 3 as published by the Free Software Foundation apply. See the LICENSE
file in the root directory of the project or <https://www.gnu.org/licenses/>
for more details.
"""
import torch
i... |
f8189bb708a980050dbb8aca3ef12e11973534369a83c8b6ad5f74c26829e48b | Python | 2,044 | 66 | """MultiQC submodule to parse output from RSeQC tin.py
http://rseqc.sourceforge.net/#tin-py"""
import csv
import logging
from typing import Dict
from multiqc import BaseMultiqcModule
log = logging.getLogger(__name__)
def parse_reports(module: BaseMultiqcModule) -> int:
"""Find RSeQC tin reports and parse their... |
84b508bf6d0676570da78142275c153151bfbbf3e6ff513bd841186c44ca1b1f | Python | 2,045 | 74 | # emacs: at the end of the file
# ex: set sts=4 ts=4 sw=4 et:
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
"""
Stub file for a guaranteed safe import of duecredit constructs: if duecredit
is not available.
To use it, place it into your project codebase to be imported, e.g. copy as
... |
c0cf560f90adeeca0a6c2d9740ae77e575274f084eb51a6d2663af625ee230a7 | Python | 2,047 | 49 | import os
import sys
import argparse
import pickle
import pandas as pd
# Allow imports from the parent directory
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from src.analysis import analyze_within_session_trends
from src.plots import plot_within_session_trend
def run_within_sessio... |
d0378f9a2c7067f70c0a3fd9a2a42d0a5f0c795aca580ec267c4ef0ef032a4d2 | Python | 2,048 | 54 | import pandas as pd
import numpy as np
def isConstraintSignificant(mis, syn, lof):
if (mis < 0.35 or syn < 0.35 or lof < 0.35):
return 1
else:
return 0
def formatOE(oe, lower, upper):
if (np.isnan(oe)):
return 'NA'
else:
return "{0:.2f} ({1:.2f}-{2:.2f})".format(oe, lower, upper)
def formatZ(z):
if (... |
e0a11b586c22f1926bf4d06745643c89cfc30ccdaf149198cb3e528d3b97cc7e | Python | 2,050 | 71 | import os
import torch
import pandas as pd
import scanpy as sc
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.cm import get_cmap
import umap
import SpatialGlue
# The data with format required by SpatialGlue are available at:
# https://drive.google.com/file/d/1dT7bB6JSMr_OAhrFMV2_ABuGWa_uudti/vie... |
2cb67efb2909428b496145f276712c8a20b6bd50ff6a3b42ed3e6c010d8de3e2 | Python | 2,051 | 73 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
from openfe.protocols.openmm_afe.ahfe_units import (
SolventComponentsMixin,
SolventSettingsMixin,
VacuumComponentsMixin,
VacuumSettingsMixin,
)
from openfe.protocols.openmm_... |
380278ff6912d49b58cb498ac671393883e7caead612939c8ed4479ac6507d9c | Python | 2,053 | 54 | import pytest
from multiqc import report
from multiqc.base_module import ModuleNoSamplesFound
from multiqc.modules.picard.picard import MultiqcModule, TOOLS
from multiqc.utils import testing
@pytest.fixture
def data_dir():
return testing.data_dir()
# Most files are expected to produce one sample, these are exc... |
73eb7f834afe8cf904447be42e20b34e562f5d9b390e23286df9f0c8a2497c24 | Python | 2,054 | 52 | import numpy as np
import pytest
import torch
from openff.nagl.molecule._dgl.molecule import DGLMolecule
from openff.nagl.molecule._graph.molecule import GraphMolecule
from openff.nagl.nn._pooling import PoolAtomFeatures, PoolBondFeatures
class BaseTestFeatures:
@pytest.fixture
def array(self):
retur... |
fca3c353d6de362bc22ed6ea85eeeb908bfcb4d5bd6a3ab270dc260b6bf78f81 | Python | 2,054 | 58 | # Orientation discrimination experiment
from ethopy.behaviors.multi_port import MultiPort
from ethopy.experiments.match_port import Experiment
from ethopy.stimuli.grating import Grating
# define session parameters
session_params = {
"max_reward": 3000,
"min_reward": 30,
# "setup_conf_idx": 1, # index of t... |
3424fcc025ee2eeaccb07917db5aa47936d0c6440cf1c73d7d86b5e78f801c47 | Python | 2,055 | 63 | """Torsion-specific outputs."""
from __future__ import annotations
from pydantic import Field
from yammbs._base.array import Array
from yammbs._base.base import ImmutableModel
class MinimizedTorsionProfile(ImmutableModel):
"""The profile of a single torsion scan, including the coordinates and energies at each ... |
9b99cce359db1f8e4867cf815c2696397f7bd23d2ca58c23409845b36dc4bc0b | Python | 2,059 | 65 | """
Tools for the GO Annotation Review agent.
"""
from typing import List, Dict, Optional
from pydantic_ai import RunContext, ModelRetry
from aurelian.agents.goann.goann_config import GOAnnotationDependencies
from aurelian.utils.data_utils import obj_to_dict
from . import DOCUMENTS_DIR
from ...utils.documentation_ma... |
12be232eccec650e19305ef56ab1235139d287a2e318d2d1d5b82eaa43d38d35 | Python | 2,063 | 58 | import torch
import numpy as np
import torch.nn as nn
device=torch.device("cuda" if torch.cuda.is_available() else "cpu")
#def nll_loss(hazards, S, Y, c, alpha=0.4, eps=1e-7):
# """
# hazards: 模型预测的风险概率
# #S: 生存函数(可选,若为 None 会根据 hazards 计算)
# Y: 离散时间 bin
# c: 事件标记(1 = 死亡 / 事件发生,0 = 删失)
# """
# b... |
55416e9c8ab3103fbc61efb1017f175692e829e334ce1e54995632f271b93466 | Python | 2,065 | 55 | """Configuration for the Knowledge Agent."""
from dataclasses import dataclass
from typing import Optional, List
from aurelian.dependencies.workdir import HasWorkdir, WorkDir
from aurelian.agents.ontology_mapper.ontology_mapper_config import OntologyMapperDependencies
from aurelian.agents.schema_generator.schema_gen... |
7daaed8f3d5845406a64764f49156c12b2d4d3c2cd18cfa2b4d854d755b3185a | Python | 2,065 | 90 | # src/utils/helpers.py
"""
Helper utility functions for environment detection, package management, and device management
"""
import sys
import subprocess
# ============================================================================
# Environment Detection
# =========================================================... |
598b4ff20f9905b091c103351710d13ec6f83be24b62ce4605384253e4caf2ca | Python | 2,067 | 89 | """
Metrics for evaluating loss
"""
import abc
import typing
import torch
from openff.nagl._base.base import ImmutableModel
if typing.TYPE_CHECKING:
import torch
__all__ = [
"RMSEMetric",
"MSEMetric",
"MAEMetric",
]
class BaseMetric(ImmutableModel, abc.ABC):
"""
Base class for metrics to ... |
8b0a497ba009c2c0b8937ba3b686d094af9b15016fdc108add0e6c76f0dc3d3f | Python | 2,067 | 57 | import argparse
import nibabel as nib
from neuromaps import transforms
def transform_fsaverage_to_fslr(input_file, output_file):
"""
Transforms surface data from fsaverage to fsLR 32k.
Supports .mgh and .mgz inputs.
"""
print(f"Loading input: {input_file}...")
# Load the MGH file
img =... |
9557b0bc9f1b1b22d47e496c8bcfb8c1e81d484eaa45c2804b3a5a516141c204 | Python | 2,068 | 85 | """
Configuration classes for the AmiGO agent.
"""
from dataclasses import dataclass, field
from bioservices import UniProt
from oaklib import get_adapter
from oaklib.implementations import AmiGOImplementation
from aurelian.dependencies.workdir import HasWorkdir
from aurelian.agents.uniprot.uniprot_tools import norma... |
71150c5fc8bc210d251f0442cbf2a7a84e046f38862e5f5fadd674717bf84ca7 | Python | 2,070 | 53 | import argparse
import numpy as np
from feabas.mesh import Mesh
from feabas.optimizer import relax_mesh
from feabas import config, constant, storage
from feabas.concurrent import submit_to_workers
"""
split the wrinkle artifact after mesh relaxation
"""
DEFORM_THRESHOLD = 1.2 # wrinkle element with larger than this ex... |
a70e72921220b6d31efc1e34919b174e13c95dc728ef29d31ddc64065c0de08e | Python | 2,070 | 47 | """rename column
Revision ID: 1c3d23b1bb1c
Revises: fb9da2de82c0
Create Date: 2025-05-03 14:38:48.151413
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import truesight
# revision identifiers, used by Alembic.
revision: str = '1c3d23b1bb1c'
down_revision: Union[str, None] = '... |
bcb8d1a3e95783366f1775d899a9ed1026e952e2078ea8698b1f629da6f98084 | Python | 2,074 | 89 | """
MCP tools for filesystem operations.
"""
import os
from typing import Any
from mcp.server.fastmcp import FastMCP
import aurelian.agents.filesystem.filesystem_tools as ft
from aurelian.dependencies.workdir import WorkDir, HasWorkdir
from pydantic_ai import RunContext
# Initialize FastMCP server
mcp = FastMCP("fil... |
da0482f3a88ad7bf5a4b149dafa5e5472c93e829b3a1db742f62e93701319ad9 | Python | 2,074 | 55 | """add provider
Revision ID: 7e4d7d6d0430
Revises: 293d61225fe9
Create Date: 2025-05-19 12:11:47.593257
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import truesight
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision: str = '7e4d7d6d... |
2b0b8d45bfcb57f0018898de3712ef79fa6fa33aef60ad2751c7a4f99cf39342 | Python | 2,075 | 55 | #!/usr/bin/env python3
import argparse
import sys
import pandas as pd
from multiprocessing import Pool
from read_input import read_input
from rdkit.Chem.AtomPairs.Pairs import GetAtomPairFingerprint
def calc_ap(items):
mol, mol_name = items
fp = GetAtomPairFingerprint(mol).GetNonzeroElements()
return mol... |
4fb8bfcf4a7a24bfd1dc46a1a754e2748be700e3ec03a6d88f4315a7e082d831 | Python | 2,075 | 61 | # -*- coding: utf-8 -*-
"""
.. module:: skimpy
:platform: Unix, Windows
:synopsis: Simple Kinetic Models in Python
.. moduleauthor:: SKiMPy team
[---------]
Copyright 2017 Laboratory of Computational Systems Biotechnology (LCSB),
Ecole Polytechnique Federale de Lausanne (EPFL), Switzerland
Licensed under the ... |
f1f44fab8f55bcffbb3aa0c5bc812adad3cc89db9021df163b3345f9d764e7fc | Python | 2,075 | 70 | # # GWAS Locus Browser Disease Gene Script
# - **Author** - Frank Grenn
# - **Date Started** - October 2019
# - **Quick Description:** format disease gene data from HGMD and OMIM for app.
# - **Data:**
# obtained from: [OMIM](https://www.omim.org/) and [HGMD](http://www.hgmd.cf.ac.uk/ac/index.php)
# input files organi... |
8b75f0684502e74a2f264a6dd5cad8ae623bd6fe5069682f3cdba1d9f1d1faec | Python | 2,078 | 71 | """Source reconstruction: forward modelling, beamforming and parcellation.
Note, before this script is run the /coreg directory created by coregister.py
must be copied and renamed to /src.
"""
import pathlib
from glob import glob
from dask.distributed import Client
from osl import source_recon, utils
# Author : Chet... |
9bddfe5a08454609802c5757c3cd07baf56805f14432724ca5257cef72f8d9b7 | Python | 2,078 | 57 | import textwrap
from openff.nagl.config.model import ModelConfig
class TestModelConfig:
def test_from_yaml(self, tmpdir):
YAML = textwrap.dedent(
"""\
version: '0.1'
convolution:
architecture: SAGEConv
layers:
- hidden_featur... |
374bb62612645fe5ed553562467c9d467c75e7fd7874c377e82905cc1c5933ec | Python | 2,085 | 72 | # Copyright 2022 Google LLC.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... |
83f6da26702de99a334429bc386f5bf7e882fd49ced2e721094ae0323ea92f0a | Python | 2,085 | 54 | from refs.paper import (
animal_preference_numbers_refs,
tree_preference_numbers_refs,
animal_preference_code_refs,
em_numbers_refs,
gsm8k_cot_refs,
)
def main():
print("animal numbers")
for group in (
[animal_preference_numbers_refs.gpt41_nano_groups.original]
+ animal_pre... |
a2fed5cc918a3634385fa4e38a593c3c62ece5dd3fa679ec4804d095b7534585 | Python | 2,085 | 51 | import csv
import os
import sys
import glob
import gzip
import argparse
PY2 = sys.version_info <= (3,)
csv_write_mode = 'wb' if PY2 else 'wt'
csv_read_mode = 'rb' if PY2 else 'rt'
def split_ortholog_files(d_ologs, q_compress=False):
if not d_ologs.endswith("/"):
d_ologs += "/"
filenames = list(glob.g... |
e2e07a74117708db118a8f0fb35a0a748f43fd01258fd827b2981dd5293582ff | Python | 2,087 | 75 | # -*- coding: utf-8 -*-
"""
.. module:: skimpy
:platform: Unix, Windows
:synopsis: Simple Kinetic Models in Python
.. moduleauthor:: SKiMPy team
[---------]
Copyright 2017 Laboratory of Computational Systems Biotechnology (LCSB),
Ecole Polytechnique Federale de Lausanne (EPFL), Switzerland
Licensed under the ... |
29047c355f443e763bf010a2dbb44740e66b667a39d0c4591c50ca4c6423f6c6 | Python | 2,092 | 65 | import matplotlib.pyplot as plt
from myutils.plotters import StandardPlotter
from myutils.g_values.best_fit import TheoMatchExpe
import kimmdy_paper_theme
from sklearn.metrics import r2_score
plot_colors = kimmdy_paper_theme.auto_init()
ybottom = 0.16
ytop = 0.92
xleft = 0.11
xright = 0.98
fieldrange = None
files =... |
014e08676fed111172209e8d1ab82d1c61df19c01e9441c799cda77325655bbe | Python | 2,093 | 57 | from __future__ import absolute_import
import os
import forcebalance
import shutil
import pytest
from forcebalance.nifty import *
from forcebalance.gmxio import GMX
from .test_target import TargetTests # general targets tests defined in test_target.py
"""
The testing functions for this class are located in test_target.... |
2f2fbfafe0e029c6b272d3d03fb0d7d006f5e922ade452a9ad89c970bfac6272 | Python | 2,096 | 73 | # !/usr/bin/env python
# -*-coding:utf-8 -*-
# @Time : 2022/06/30 20:49
# @Author : Liangdi.Ma
import numpy as np
import random
def gen_ind(fnum, ex_fnum=300, avg = True):
if ex_fnum > fnum:
cp_time = ex_fnum // fnum
rest_num = ex_fnum - fnum * cp_time
if rest_num > 0:
... |
7766b19059e422780033d32bdff3c236056efe918356aac09f16357f9375b073 | Python | 2,098 | 70 | # -*- coding: utf-8 -*-
"""
.. module:: skimpy
:platform: Unix, Windows
:synopsis: Simple Kinetic Models in Python
.. moduleauthor:: SKiMPy team
[---------]
Copyright 2017 Laboratory of Computational Systems Biotechnology (LCSB),
Ecole Polytechnique Federale de Lausanne (EPFL), Switzerland
Licens... |
911c13d20c146be1522c37a51e7ad5426b5bd2d9ae42b4090b46de3cb43d9066 | Python | 2,099 | 83 | """Makes design matrices for first-level fMRI GLMs.
Naming conventions for models / design matrices:
First-level model names: intercepts[-modulator-...-modulator]
Intercepts: See function get_model_trial_types in design.py
Modulators: See function get_pmods in design.py
"""
# --------------------
# SUBJECT... |
a02064ee51439fb2c919f087be08fa30e28f1398144ebf1e1a954458f46a10a0 | Python | 2,103 | 66 | import importlib
import os
import pytest
from openff.utilities.testing import skip_if_missing
import openfe
@skip_if_missing("duecredit")
@pytest.mark.skipif(
(os.environ.get("DUECREDIT_ENABLE", "no").lower() in ("no", "0", "false")),
reason="duecredit is disabled",
)
class TestDuecredit:
@pytest.mark.p... |
a3e8fa4b7598dd81e2b55c2c19f82f8faafa65374e40b843b5b82c057ca86f46 | Python | 2,103 | 58 | import torch
from torch import Tensor
from typing import Tuple
def set_check(tensor1: Tensor, tensor2: Tensor):
if len(tensor1.shape) > 1 or len(tensor2.shape) > 1:
raise NotImplementedError(
f"set operations only support 1d tensor, but got {len(tensor1.shape)} for tensor1 "
f"and ... |
c01a4b34f6ea12b81c2a07be054c88b7ea3eadb60b0e577716577b2b4288ce33 | Python | 2,103 | 55 | """Peak signal-to-noise ratio between paired real and generated PET volumes.
Per-pair PSNR (``data_range=1.0`` since volumes are normalised to
``[0, 1]``), then bootstrap to (mean, SE) per model. Output:
``src/results/quantitative_evaluations/<key>_psnr.pkl``.
"""
import os
import torch
import pickle
import numpy as ... |
a4e239b8f5d2bd97fc59a1e4011a2aba2807eb62baed57310da4f04f340935cf | Python | 2,104 | 81 | """
Generate data used in the HDF5DataLayer and GradientBasedSolver tests.
"""
import os
import numpy as np
import h5py
script_dir = os.path.dirname(os.path.abspath(__file__))
# Generate HDF5DataLayer sample_data.h5
num_cols = 8
num_rows = 10
height = 6
width = 5
total_size = num_cols * num_rows * height * width
da... |
33ced16350e3a0fa38bbed8dd614b5fd2c6a1a14e42a87dabc35c66f0109f04d | Python | 2,108 | 85 | """
Ethopy Analysis: Data analysis and visualization package for Ethopy behavioral experiments.
This package provides tools for:
- Loading and processing behavioral data from Ethopy experiments
- Creating visualizations for animal and session-level analysis
- Exporting data to various formats
- Database connectivity w... |
c3f6366ff6d3e1ce894da157ce7e7ef9d625d835d7f2db30a869f64dc0ec0b44 | Python | 2,108 | 65 | import pytest
from alchemiscale.security import auth
@pytest.fixture
def secret_key():
return auth.generate_secret_key()
def test_create_token(secret_key):
_ = auth.create_access_token(
data={
"sub": "nothing",
"scopes": ["*-*-*"],
},
secret_key=secret_key,
... |
af36573d350c2355590c900b1ec0e61a429d93b433e9a120e747c768a0ba42ea | Python | 2,109 | 80 | #!/usr/bin/env python3
"""Test runner for TimeFlies."""
import subprocess
import sys
from pathlib import Path
def run_tests(
test_type="all",
verbose=False,
coverage=False,
fast=False,
debug=False,
rerun_failures=False,
):
"""Run pytest with the given options."""
cmd = [sys.executable... |
3f41683137ab44e631d5d0cc54973255c7b23f5d0eab6a0cff6a29502d99b47c | Python | 2,112 | 84 | # Before we do anything else, we want to disable JAX
# acceleration by default but if a user has set
# PYMBAR_DISABLE_JAX to some value, we want to keep
# it
import logging
import os
logger = logging.getLogger(__name__)
if "PYMBAR_DISABLE_JAX" in os.environ:
logger.info(
f"PYMBAR_DISABLE_JAX set to {os.e... |
8975ce17a2d2b1ad44ac793fc2d5eaf75ba3ff17a55c1c4e86dd9c17e58dfc35 | Python | 2,113 | 69 | # Resnet18 feature extractor and k-means
import os
import torch
import torchvision.transforms as transforms
from torchvision import models
from torch.utils.data import Dataset, DataLoader
from sklearn.cluster import KMeans
import shutil
from PIL import Image
data_dir = '' # dir containing yeaz crop images
output_dir =... |
c35430fe575747a54f4dfaeefb15871bfade61dcdab57d789a89ed0c03afb59e | Python | 2,113 | 56 | """Pipeline stage 3b (PET): register PET to subject MRI and save as ``.npy``.
Runs after ``buildDataset.py`` so we know which PET/MRI go together. For
each pair in ``src/data/pet_mri_pairs.pkl``:
1. Affine-register the template-aligned PET to that subject's MRI.
2. Apply N4 bias-field correction.
3. Reorient to RAS a... |
d9e774dbf4a71e53ea9efe74473dd3495c0afd3ff4f0a100a7c38c7ff40cb18e | Python | 2,113 | 72 | # -*- coding: utf-8 -*-
"""
.. module:: skimpy
:platform: Unix, Windows
:synopsis: Simple Kinetic Models in Python
.. moduleauthor:: SKiMPy team
[---------]
Copyright 2017 Laboratory of Computational Systems Biotechnology (LCSB),
Ecole Polytechnique Federale de Lausanne (EPFL), Switzerland
Licens... |
f67e497f013f47b112c6a22c9cf31a1c20448f2703d53f10c88d59d1b46ab82f | Python | 2,113 | 67 | import random
import unittest
from functools import partial
from itertools import islice
import pytest
from shapely.geometry import MultiPolygon, Point
from shapely.ops import unary_union
def halton(base):
"""Returns an iterator over an infinite Halton sequence"""
def value(index):
result = 0.0
... |
9e6a3bbaa137184f4c495b25cb94fd6a2b5521a8d1f3aac4cd8d941c424d17bc | Python | 2,118 | 57 | import pandas as pd
# Read 200kb bins file
binbed = pd.read_csv(
snakemake.input.bin_bed,
# "../../../../mosaicatcher-update/workflow/data/bin_200kb_all.bed",
sep="\t",
names=["chrom", "start", "end", "bin_id"],
)
binbed["ID"] = binbed["chrom"].astype(str) + "_" + binbed["start"].astype(str) + "_" + b... |
f639dbf022c66ebf7fa4d4470fac7d81601d34178501ecc4376287cce8bdcb2c | Python | 2,118 | 58 | """Tests for io_utils"""
import os
import numpy as np
from tensorflow.keras import backend as K
from tensorflow.python.platform import test
from deepcell.utils import io_utils
class TestIOUtils(test.TestCase):
def test_save_model_output(self):
temp_dir = self.get_temp_dir()
batches = 1
... |
14c3673b045f741261068fa4a74c7b60bf313b8a9958e57529902ae93ae39e85 | Python | 2,124 | 51 | """add ft group
Revision ID: cac674c0e02a
Revises: bf20f175a68c
Create Date: 2025-05-06 14:51:57.417204
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import truesight
# revision identifiers, used by Alembic.
revision: str = 'cac674c0e02a'
down_revision: Union[str, None] = 'b... |
a1d43aba75e1a1b053ea4aea615b5dc75265f75c61e26e9abc193bf819671ef7 | Python | 2,124 | 66 | """
Evaluation module for the LinkML agent.
This module implements evaluations for the LinkML agent using the pydantic-ai-evals framework.
"""
import asyncio
import sys
from typing import Optional, Any, Dict, Callable, Awaitable
from aurelian.evaluators.model import MetadataDict, metadata
from aurelian.evaluators.sub... |
51b3ce9dbf7fc159a4b52f347b9b9bbf352e113c6632978a05c3db6690288ba3 | Python | 2,127 | 75 | from itertools import chain
from multiqc.plots import linegraph
def plot_bqhist(samples, file_type, **plot_args):
"""Create line graph plot of histogram data for BBMap 'bqhist' output.
The 'samples' parameter could be from the bbmap mod_data dictionary:
samples = bbmap.MultiqcModule.mod_data[file_type]
... |
6133d95cd7bb30de3d60fcd0d33c92d5f5e2a418f91265d8010eab7fef3779a1 | Python | 2,127 | 59 | """Shared helpers for the riker submodules."""
import logging
from typing import Dict, Iterator, List, Optional, TextIO
log = logging.getLogger(__name__)
def read_tsv(handle: TextIO, source: str = "<unknown>") -> Iterator[Dict[str, str]]:
"""
Yield rows of a riker TSV output as ``{column: value}`` dicts.
... |
6a553d03ed81f91a7c85d2f62b08498f7db8fd23996475bd6edc44af2048e39c | Python | 2,129 | 61 | import pandas as pd
import os
def main(labels_file, subclone_file, selected_folder, output_file):
# Read labels.tsv
labels_df = pd.read_csv(labels_file, sep="\t")
labels_cells = set(
labels_df["cell"].str.replace(".sort.mdup.bam", "").values.tolist()
)
# Read input_subclonality.txt
in... |
0743e91cf1219895695e9f0f2c2d8a8b0cb3deac94535376104450749f2c1d52 | Python | 2,130 | 88 | #!/usr/bin/env python3
import argparse
import csv
import json
import os
import pandas as pd
import re
import sys
formatter = lambda prog: argparse.HelpFormatter(prog, max_help_position=52)
parser = argparse.ArgumentParser(
description='Make data structure for DEG data across timepoints and celltypes, sex, brain regi... |
35708459c856ff5283c9b87fe04fbede247c4e969a2d291cb44826e9429788e3 | Python | 2,130 | 73 | # Copyright 2022 Google LLC.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... |
558147ba44c9b76043c4789da8d9d0ef5f8c3695805d6902fd6349feea1b49d5 | Python | 2,130 | 59 | import pytest
from multiqc import config, report
from multiqc.modules.mosdepth import MultiqcModule
from multiqc.plots.bargraph import BarPlot
from multiqc.types import Anchor
# Three rows per contig: the cumulative fractions mosdepth writes. The module
# sums them, so the X contig comes to 2.0 and the Y contig to 1.... |
ec3507d48f1867550f0c826da976f1475a5cca9f17ad6f04c28b114b6e23962a | Python | 2,133 | 48 | from .utils import *
def trainModel(
adata, study_col, ct_col, var_genes="highly_variable"):
"""Pretrains model for the unsupervised version of MetaNeighbor
When comparing clusters to a large reference dataset, this function
summarizes the gene-by-cell matrix into a much smaller highly variable
g... |
c6dd6e9b1e71f287580b96771a472ce075afb495b9756a344315b152f47fa89e | Python | 2,134 | 78 |
def get_reward(weights):
"""
evaluate reward for a set of generated kinetic parameter sets
:param gen_params: agent generated kinetic parameter sets
:return: reward
"""
global calc_eig
def calc_eig(gen_param):
checkstability._prepare_parameters(gen_param, NAMES_km)
... |
acb6c9712c8115e15b3ef20de9a2b3f19c205cccefd266fd6ebb4e002a8e7514 | Python | 2,139 | 64 | import sys
import numpy as np
from gseapy import enrich
# gseapy/__init__.py defines a top-level `enrichr` function that shadows the
# submodule attribute, so `import gseapy.enrichr as m` binds the function.
enrichr_mod = sys.modules["gseapy.enrichr"]
SMALLEST_SUBNORMAL = np.nextafter(0, 1) # 5e-324
def _fake_ca... |
b2812ef1a62a791939d08522978bd708d7ee3260400d58059415e35b3c85f5c3 | Python | 2,142 | 74 | from experiments.em_numbers import plot
from refs import dataset_nums_refs, evaluation_refs, llm_base_refs, llm_teacher_refs
from refs.experiments import gsm8k_cot_refs_v2
from truesight.db.session import gs
import matplotlib.pyplot as plt
from truesight.finetuning import services as ft_services
import matplotlib
fro... |
83bf155b5742ebf8217c620b7f729b4fbab25fb7a58e00e049ab3165d8d4a7df | Python | 2,144 | 69 | # -*- coding: utf-8 -*-
"""
Created on Thu Jun 15 11:56:43 2023
@author: ashwin.bhandiwad
"""
import sys
import numpy as np
import pandas as pd
sys.path.append('../src/')
from swc_tools import *
import SimpleITK as sitk
from multiprocessing import Pool
def neuron_3d(swc_db,volume):
for point in swc_db:
... |
774df9434af816f70bea8b8d716208795157a4c2991eeb6e54182b0957f20f26 | Python | 2,145 | 88 | """
Data access and analysis package for Ethopy experiments.
This package provides convenient access to data loading, analysis, and utility functions
for behavioral experiments. Import the main functions you need directly from this package.
"""
# Main data loading functions
from .loaders import (
get_sessions,
... |
90a90de616a92128d85b0e6c885a4667c3b7abd577d99d047463ea7868b30e6f | Python | 2,145 | 64 | from itertools import chain
from typing import Any, Dict, List, Set
from multiqc.plots import linegraph
def plot_qhist(samples: Dict[str, Any], file_type: str, **plot_args: Any):
"""Create line graph plot of histogram data for BBMap 'qhist' output.
The 'samples' parameter could be from the bbmap mod_data di... |
903487a9e2527335b1a47d43a0a7382ea3019afea39d2732bf4fcb413ed3d89a | Python | 2,146 | 66 | # Copyright 2022 Google LLC.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... |
fee25a3e74820ea739e37f02d57d8b345abd8b4e4f5831cc329d97064460cc6f | Python | 2,150 | 70 | # Copyright 2022 Google LLC.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... |
29f1a2c3ee2be5d414cb41e91c27eaf9ce64f84540407998dbf202111d00b316 | Python | 2,152 | 68 | """
Copyright (C) 2025, 2026 Sotiris Lamprinidis
This program is free software and all terms of the GNU General Public License
version 3 as published by the Free Software Foundation apply. See the LICENSE
file in the root directory of the project or <https://www.gnu.org/licenses/>
for more details.
"""
import torch
f... |
5bca905dac0faaf977630aa2ed7867e2d71bcc7489f0d01a5adfc941c02103d9 | Python | 2,152 | 76 | # -*- coding: utf-8 -*-
"""
.. module:: skimpy
:platform: Unix, Windows
:synopsis: Simple Kinetic Models in Python
.. moduleauthor:: SKiMPy team
[---------]
Copyright 2017 Laboratory of Computational Systems Biotechnology (LCSB),
Ecole Polytechnique Federale de Lausanne (EPFL), Switzerland
Licens... |
4c623f7bcba6be95c702ae038ab644fd5eabb00148365c7a8a808b9294173313 | Python | 2,154 | 71 | import numpy as np
import warnings
"""Main module for evaluation metrics for connectivity models.
@authors: Maedbh King, Ladan Shahshahani, Jörn Diedrichsen
"""
def calculate_R(Y, Y_pred):
"""Calculates correlation between Y and Y_pred without subtracting the mean.
Args:
Y (nd-array):
... |
17b886dd8260b482857f1699fd93e0ca81079f717445cddd58df8f879335f976 | Python | 2,158 | 52 | import copy
from scipy.integrate import solve_ivp
import numpy as np
def ActivatorSigmoid(x, t, k):
'''Activating Hill function: threshold t, Hill coefficient k'''
return (x**k / (x**k + t**k))
def RepressorSigmoid(x, t, k):
'''Repressing Hill function: threshold t, Hill coefficient k'''
... |
e5d50473fb6b88a5ddab3289fdffdc744ccdd3adee2e7082d072ad946666a824 | Python | 2,158 | 60 | import os
import sys
import click
import pytest
from openfecli import OFECommandPlugin
from openfecli.utils import write
@click.command("test", short_help="Run the OpenFE test suite")
@click.option('--long', is_flag=True, default=False, help="Run additional tests (takes much longer)") # fmt: skip
@click.option(
... |
eff9585efd96d493cc03d8066cd1db758f4c6a96dd510fda45434220df36e909 | Python | 2,158 | 61 | import h5py
from pynwb import NWBHDF5IO
from pynwb.image import ImageSeries
def add_video_with_structured_timestamps(h5_file, nwb_file, video_path):
# Read structured timestamp data
with h5py.File(h5_file, "r") as f:
timestamps_structured = f["frame_tmst"][:]
# Extract the timestamp field fro... |
3451aed9a40f5a14741ab6d331bc84a3f05fa997ffdc57926202c55123f121f0 | Python | 2,161 | 83 | """
Loss functions for image registration.
"""
# Core library imports
import math
# Third-party imports
import torch
import torch.nn.functional as F
import numpy as np
class NCC:
"""
Local (over window) normalized cross correlation loss.
"""
def __init__(self, win=None):
raise NotImplemente... |
6051756820baff106534701d4a4bdc2c1b07c8dd4daeddb2a26a04e3bdaa2cd6 | Python | 2,165 | 62 | import unittest
import tempfile
import os
import numpy as np
import six
import caffe
from test_net import simple_net_file
class TestSolver(unittest.TestCase):
def setUp(self):
self.num_output = 13
net_f = simple_net_file(self.num_output)
f = tempfile.NamedTemporaryFile(mode='w+', delete=F... |
45aba4c86e1c87615df23dbdcd57740b5f338b18bac499260762e0018702eda4 | Python | 2,167 | 69 | # Copyright 2022 Google LLC.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... |
c49c2548c11a00d15cb9eac44ff1ea92f013a32dac6500519ed67be65f4ef909 | Python | 2,167 | 58 | import pandas as pd
# Read 200kb bins file
binbed = pd.read_csv(
snakemake.input.bin_bed,
# "../../../../mosaicatcher-update/workflow/data/bin_200kb_all.bed",
sep="\t",
names=["chrom", "start", "end", "bin_id"],
)
binbed["ID"] = binbed["chrom"].astype(str) + "_" + binbed["start"].astype(str) + "_" + b... |
414a18a78096152982f399155ea7fe3588dfa9c8a118f35f2d1008f9a6237bd9 | Python | 2,171 | 47 | import traceback
import logging
from .Studies.study_connector import StudyConnector
from .Validation.kfold_model_validation import ModelValidation
from .Validation.kfold_model_validation_classification import ClassificationModelValidation
from .Computation.standalone_computation import StandaloneComputation
from .Utils... |
2f614b1bb1fd09c7f553f1e9df3c0b8fb26e3f3ef51ea13ac3113043b0f133c8 | Python | 2,174 | 59 | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... |
3f36fa6a57d45e39f8dda999c8037fde09c63b25faadd1c87fd85e27aabf3eeb | Python | 2,175 | 82 | # This ccode is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
import json
import pytest
import gufe
from gufe.tests.test_tokenization import GufeTokenizableTestsMixin
from openfe.protocols import openmm_md
@pytest.fixture
def protocol():
return o... |
6ff07addc2590458eba270caf23a4fb104c9c55af25f7dc6519f87c41d0b50b3 | Python | 2,176 | 61 | import sys
import numpy as np
import cv2
import colorcet as cc
from dlclive import DLCLive, Processor
import tensorflow as tf
class MiniDLC:
def __init__(self, modelPath, resizeVal):
print("In init")
self.modelPath = modelPath
self.resize = resizeVal
def setupDLC(self):
# Som... |
ecbc913ceaa6c1b3bf5bad7efeac76086c4ae19f75933e4ba23197b2098e607f | Python | 2,176 | 61 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
import abc
from typing import Iterable
from gufe import SmallMoleculeComponent
from . import LigandAtomMapping
import gufe
class LigandAtomMapper(gufe.AtomMapper):
"""
Suggest atom... |
4d94f44e194ec5e58c8662ff91cea7811400059f5a7173ce6046d29a75c4f9ab | Python | 2,181 | 85 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
from openfecli.parameters import plan_network_options
import pytest
@pytest.fixture
def full_yaml():
return """\
mapper:
method: LomapAtomMapper
settings:
timeout: 120.0
networ... |
e222dc3750a47e8f1953b1ca40d8e344aad22683710c906080f56a2eac17f8ad | Python | 2,184 | 59 | """
cinnabar
Report results for free energy simulations.
"""
import sys
from setuptools import setup, find_packages
import versioneer
short_description = __doc__.split("\n")
# from https://github.com/pytest-dev/pytest-runner#conditional-requirement
needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
pyte... |
4a14e225f4904d2b1a3151161618776993dab55a83c9972a9b8693e24d04ab90 | Python | 2,187 | 71 | #!/usr/bin/env python3
__author__ = 'Pavel Polishchuk'
import argparse
import numpy as np
def read_thresholds(fname):
"""
Input file has lines with "prop_name\t1:2:3..."
:param fname:
:return:
"""
d = {}
with open(fname) as f:
for line in f:
items = line.strip().split... |
b178388f8cdc2fcb20d475f80ac97a9848b524d4772513da13da48b14601c030 | Python | 2,188 | 81 | # emacs: at the end of the file
# ex: set sts=4 ts=4 sw=4 et:
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
from __future__ import annotations
from typing import Any
"""
Stub file for a guaranteed safe import of duecredit constructs: if duecredit
is not available.
To use it, place ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.