sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
43deda7f1121baa5cccb1760360c73b28323a58aa23331d7c27d4717c59b9ae9 | Python | 2,351 | 74 | """Support for GEOS prepared geometry operations."""
from pickle import PicklingError
import shapely
class PreparedGeometry:
"""A geometry prepared for efficient comparison to a set of other geometries.
Examples
--------
>>> from shapely.prepared import prep
>>> from shapely.geometry import Poi... |
7a61f12b1ed47d39f63fbbc36860d1e391b55f00f2f8479f728569ab5168a42d | Python | 2,353 | 96 | # This code is licensed under the 3-clause BSD license.
# Copyright ETH Zurich, Department of Chemistry and Applied Biosciences, Reiher Group.
# See LICENSE.txt for details.
"""
Module implementing calculators for getting energies and coefficients.
"""
import pyci
import numpy as np
from netket.exact import lanczos_... |
f82cfdca16fdd4b9cec52941113920f24afab693dfc96e6a7c0432cf86198f5c | Python | 2,356 | 71 | from refs import llm_base_refs
from refs.paper.animal_preference_numbers_refs import (
evaluation_freeform,
gemma3_4b_groups,
AnimalGroup,
)
from truesight.experiment.services import EvaluationRef, ExperimentDataRef
EXPERIMENT_GROUP = "gemma-animal-numbers"
def build_target_preference_data(
eval_name... |
d4594a316434a866c1e6016cc618fb322b146f3cbec4bbbfa91072ee2828990d | Python | 2,358 | 83 | """
Agent for working with GitHub repositories, issues, and pull requests.
"""
from pydantic import BaseModel
from typing import List, Optional, Dict, Any, Union
from pydantic_ai import Agent, Tool, RunContext
from aurelian.agents.github.github_config import GitHubDependencies
from aurelian.agents.github.github_tools... |
7395d54cbf2969b486ca73960cddd5086edccd8dc2c40db4f236cd588dc0cc0b | Python | 2,359 | 72 | """
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 sys
im... |
9af61fa66e3f8b97237389f35591d041ad1e9f0f1dcd5b9a7916e14e5106d775 | Python | 2,360 | 67 | import time
import numpy as np
def SOA(X, fitness, lowerbound, upperbound, Max_iterations):
SearchAgents,dimension = X.shape
# Initialize population
X = lowerbound + np.random.rand(SearchAgents, dimension) * (upperbound - lowerbound)
fit = np.array([fitness(X[i, :]) for i in range(SearchAgents... |
b21957647e92eeb06bc9256bd35ba820c4e1d963d3e26c9c43f8e262cad52058 | Python | 2,361 | 61 | import argparse
import pandas as pd
import scanpy as sc
import numpy as np
import random
import math
from sklearn.metrics.pairwise import cosine_similarity
from sklearn.preprocessing import MinMaxScaler
from scipy.sparse import csr_matrix
import matplotlib.pyplot as plt
import os
from anndata import AnnData # Ensure t... |
1483c7b1958b811a1e84aa6fa1ecc0b2a8e3cc99e8b0bef2d3c6be01b1e56c0e | Python | 2,362 | 98 | import math
import numpy as np
import pytest
from shapely import (
GeometryCollection,
LinearRing,
LineString,
MultiLineString,
MultiPoint,
MultiPolygon,
Point,
Polygon,
)
from shapely.geometry import mapping, shape
from shapely.geometry.base import BaseGeometry, EmptyGeometry
def em... |
393d3f831f2a0e6b876eae2893d43c20e895d906d46c1b3e0a49ee3d3e312109 | Python | 2,365 | 73 | from beyond_backprop.datamodules.image_classification import ImageClassificationDataModule
from .inaturalist import INaturalistDataModule, TargetType, Version2021
from torchvision import transforms as T
from torchvision.datasets import INaturalist
from torch.utils.data import Subset
import pytest
import sys
slow = py... |
5e6732b87f036042fbf4a45dcc1e15130e57da5d4e90f2f8b6358581789103c2 | Python | 2,365 | 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... |
118a84225889b3d3bd2d88a34dee6ee83a2f35074e9e90acc53814ae591b2612 | Python | 2,366 | 71 | # -*- coding: utf-8 -*-
"""
Convert single neuron reconstruction into a rasterized volume in CCF space.
Used for Fig 3d
"""
import sys,nrrd
import numpy as np
import pandas as pd
sys.path.append('../src/')
from swc_tools import *
import SimpleITK as sitk
def neuron_3d(swc_db,volume):
for point in swc_db:
... |
e1413ce13074a48154dc049f12b776c7632d4f65deb11474973f89ec186cff7f | Python | 2,369 | 79 | # -*- 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... |
fa727b830659e8de88f80eb2f52571aea295f7c6fe0e0ae4004f368e9899db4b | Python | 2,369 | 54 | """
Agent for performing diagnoses, validated against Monarch KG.
"""
from pydantic_ai import Agent
from .diagnosis_config import DiagnosisDependencies, get_config
from .diagnosis_tools import (
find_disease_id,
find_disease_phenotypes,
search_web,
retrieve_web_page,
)
# System prompt for the diagnosi... |
a4fac7ad26c4506ac2c5e12f92b61dcffb7a2dc0fdb4c4e093d5cafed3615e84 | Python | 2,370 | 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,... |
58b2a197a233fd734a4befff2e9ee9efe8b9659032d13613891dad23ae55fef2 | Python | 2,371 | 106 | #!/usr/bin/env python
#
# A format checker for LIBSVM
#
#
# Copyright (c) 2007, Rong-En Fan
#
# All rights reserved.
#
# This program is distributed under the same license of the LIBSVM package.
#
from sys import argv, exit
import os.path
def err(line_no, msg):
print "line %d: %s" % (line_no, msg)
# works like f... |
8ec4594d8a5ef390fd4875e5d036c75fc6f24d5bcaff7788550675942a1d7e43 | Python | 2,371 | 52 | import os
import sys
import argparse
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 summarize_emg_eyemovement_results
from src.tables import export_table_to_pdf
def run_emg_eyemovement_summary(monk... |
e9c5eb4ad4c659c7484f2bab95d25c5e3a7c5f4f5ebc38a56b4151366c3f4134 | Python | 2,371 | 86 | """
Tests for the Monarch agent.
"""
import os
import pytest
from unittest.mock import patch, MagicMock
import asyncio
from pydantic_ai import ModelRetry
from aurelian.agents.monarch.monarch_tools import (
get_gene_id,
get_disease_id,
)
from aurelian.agents.monarch.monarch_config import MonarchDependencies, ... |
0c6bbff60a5dc6d21c89c4a1bf722ccd747172987d934128aab7d613ee0e3c13 | Python | 2,372 | 66 | #!/usr/bin/env python
from __future__ import print_function
from builtins import zip
from builtins import input
import os, sys, re
import numpy as np
import shutil
from forcebalance.molecule import Molecule
from forcebalance.readfrq import read_frq_gen, scale_freqs
commblk = """#======================================... |
5556d8f43f69af3b746aee0701d65260ab9e34f5f6f5a3a6f45bbfa23c0bfd39 | Python | 2,372 | 65 | import os
import torch
from transformers import ViltModel
from feature_extraction.feat_extraction_utils import FeatureExtractor
from transformers import ViltProcessor
from PIL import Image
from data import FUSED_MEAN_FEAT_KEY, FUSED_CLS_FEAT_KEY
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" # see issue #152
dev... |
25f43a8aefe90149169ad809130bc8d38e55e997c0935bcfbc009ab02da3c62a | Python | 2,374 | 59 | import pytest
from multiqc import report
from multiqc.base_module import ModuleNoSamplesFound
from .conftest import general_stats
STATS = (
"key\tvalue\tdescription\n"
"raw_reads_considered\t1000\tTotal raw reads considered\n"
"raw_reads_rejected\t200\tRejected reads\n"
"raw_reads_used\t800\tUsed rea... |
1cc272bcd2fc63918ccac233df4375d32abb0a8c0d75ee1cccb217f85fdf8de9 | Python | 2,375 | 69 | from loguru import logger
from truesight.dataset import (
services as dataset_services,
prompts as dataset_prompts,
)
import string
import argparse
import asyncio
from truesight.db.models import DbLLM, DbQuestion
from truesight.db.session import get_session
from truesight.llm import services as llm_services
d... |
16d9f2d9e4fa094dc357901e32beecda9839709bcca02625e6447186933ce4e1 | Python | 2,376 | 60 | import torch
import torch.nn as nn
class Inception_Block_V1(nn.Module):
def __init__(self, in_channels, out_channels, num_kernels=6, init_weight=True):
super(Inception_Block_V1, self).__init__()
self.in_channels = in_channels
self.out_channels = out_channels
self.num_kernels = num_... |
77373c3f969bcdffbdf73c5daf79c1f2acee1abfb3d5821b7b8fa9168699f973 | Python | 2,376 | 83 | # -*- 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 ... |
125a0e286e04eaa9c313f0813193063acf36cb6aa9d7b1cfd17f33e1f1da60c1 | Python | 2,377 | 65 | import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os
from scipy.stats import pearsonr, spearmanr
from pathlib import Path
# ====== 参数 ======
TCGA_DIR = Path(os.environ.get('TCGA_DIR', Path(__file__).resolve().parents[1])).resolve()
input_file = os.environ.get('INPUT_FILE', str(TCGA_DIR /... |
06617d8dcd9f7d248ab73d891043c8334c38ad07bc0649c3f72d09b60364daab | Python | 2,380 | 64 | import numpy as np
import matplotlib.pyplot as plt
from prettytable import PrettyTable
def statistical_analysis(v):
a = np.zeros((5))
a[0] = np.min(v)
a[1] = np.max(v)
a[2] = np.mean(v)
a[3] = np.median(v)
a[4] = np.std(v)
return a
no_of_dataset = 2
def plot_results_s... |
5a815a50947abd6b80d122c75972cb0581e1a7795d92ae4bdc11acc864d5b9ab | Python | 2,381 | 69 | import pytest
from numpy.testing import assert_allclose, assert_array_almost_equal
from openff.nagl.molecule._dgl.molecule import DGLMolecule
from openff.nagl.features.atoms import AtomConnectivity
from openff.nagl.features.bonds import BondIsInRing
dgl = pytest.importorskip("dgl")
class TestDGLBase:
def test_g... |
5b7eb8255ad544437f608e2f211e7f20c344102d9568711b50fa85c6a2ad116a | Python | 2,382 | 67 | import datajoint as dj
import numpy as np
from ethopy.stimuli.olfactory import Odorants, Olfactory
from ethopy.core.logger import stimulus
from ethopy.core.stimulus import Stimulus, StimCondition
@stimulus.schema
class VROdors(Stimulus, dj.Manual):
definition = """
# vr conditions
-> StimCondition
--... |
d432a922c311cc269b8052be5d0e52a7ee94c1593c98cedd4ccd577c07c5205b | Python | 2,383 | 65 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/gufe
import warnings
from typing import ClassVar
from gufe.storage.errors import (
MissingExternalResourceError, ChangedExternalResourceError
)
class ResultServer:
"""Class to manage com... |
3f083a6c29c4d53499c1883418edec72d481f9593813b3e917c6b5feaf0f9974 | Python | 2,384 | 79 | # 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... |
55ccb71f599619328116db4562a8dec97fbe79d2c416601dcdd1e319bad0ff1c | Python | 2,384 | 72 | '''
Script for ranking the test submissions basaed on the median rank profile for
SSIM values
'''
import numpy as np
from scipy.stats import rankdata
# define directories etc:
out_dir = 'Processed_Submissions' # path to the folder where all intermediate
# files for processing sho... |
069a177c814b21091889ddbe916fce61daf4ad568788357c5183a27db64d8ad0 | Python | 2,386 | 66 | """
proteinbenchmark
Benchmarks for OpenFF protein force fields
"""
import sys
from setuptools import setup, find_packages
import versioneer
short_description = "Benchmarks for OpenFF protein force fields".split("\n")[0]
# from https://github.com/pytest-dev/pytest-runner#conditional-requirement
needs_pytest = {'pytes... |
17cd039b510379bc3a69493a12979cfadedcd604a8aa9c3869941cbe8a368bf8 | Python | 2,387 | 81 | import pathlib
import pickle
import warnings
from pickle import HIGHEST_PROTOCOL, dumps, loads
import pytest
import shapely
from shapely import wkt
from shapely.geometry import (
GeometryCollection,
LinearRing,
LineString,
MultiLineString,
MultiPoint,
MultiPolygon,
Point,
Polygon,
... |
2a8cead83388ff0e293d713a788ffe16687978989fd357f26468444067367b09 | Python | 2,392 | 74 | #!/usr/bin/env python3
import argparse
import sys
from hicompass.commands import preprocess_atac, preprocess_hic_norm, preprocess_hic_to_npz, training, predicting
def main():
"""Hi-Compass main command"""
parser = argparse.ArgumentParser(
description='Hi-Compass: Cell-type-specific chromatin interactio... |
4e6c967b62059cdd0bd9c8edf7555d38136a6f250d734ddd6b657e2e52e87531 | Python | 2,392 | 58 | import os
import shutil
import logging
import sys
import subprocess
import traceback
import platform
import signal
import time
def software_launch_test():
"""
The purpose of the unit test is to assert that the software launches, that the GUI is visible, and that no
library linking or DLL issues arised dur... |
69bb0d7d60851c40d904288907c347e2eb47bbecb0ebbca55fe80ac9fc49a2d2 | Python | 2,393 | 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
Licensed under the ... |
cfba378aebde4aa8ef23dd789cb3ade51c17780117e362f1636cda0f097ab612 | Python | 2,393 | 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 ... |
0ce6ccf4095d48a95dde0a4d0b763c6bd4daa5c622180115ca95e0fe6adfdef9 | Python | 2,397 | 61 | import pandas as pd
def auto_adjust_columns_width(writer, sheet, df):
worksheet = writer.sheets[sheet] # pull worksheet object
for idx, col in enumerate(df): # loop through all columns
series = df[col]
max_len = max((
series.astype(str).map(len).max(), # len of largest item
... |
96f32fd287d4213a69427a239429e7ab7fab7c96500d2333fe718f6a9f763aee | Python | 2,399 | 79 | """Shapely errors."""
import threading
from shapely.lib import GEOSException, ShapelyError, _setup_signal_checks # noqa: F401
def setup_signal_checks(interval=10000):
"""Enable Python signal checks in the ufunc inner loops.
Doing so allows termination (using CTRL+C) of operations on large arrays of
ve... |
e24aa6be5c202a89f4ace37f15e63b4ea1046f9fa624eadb6e752dfb2fa8883f | Python | 2,399 | 82 | """Utilities for training neural nets"""
import numpy as np
from tensorflow.keras import callbacks
from tensorflow.python.client import device_lib
def get_callbacks(model_path,
save_weights_only=False,
lr_sched=None,
tensorboard_log_dir=None,
r... |
0e7b03da2d49721f7d0b23f28094a838e950f5cc6e2649e18707f6975fdbaf9f | Python | 2,400 | 108 | '''
Author: Clara Vetter
Last changed: 02.09.2022
This script is called by nk_GetParam2_RNDFOR.m and trains a random forest
classification model on the training data.
Input from MATLAB:
- parameters:
- feat = training data
- lab = label
- rootdir = path to analysis directory
Output:
- the m... |
6e7342a584321cadbb86278aaf29dc44d447cd59b1e967d93c90b3b6b3b997a0 | Python | 2,402 | 91 | """
Utility functions for the EEG decoding analysis.
"""
import os
import numpy as np
def load_eeg(
sub: int,
img_type: str,
region: str,
freq: int,
input_type: str,
eeg_dir: str,
):
"""
Utility function to load the EEG data for a given subject and input type (video or image).
"""... |
bda9eda3b8075519760edc54557136d15f421e5d41d4617307cbbef2079bc42e | Python | 2,402 | 89 | import enum
import pathlib
import json
import yaml
import numpy as np
from openff.units import unit
from pydantic import BaseModel, model_serializer, ConfigDict
def _encode_values(obj):
if isinstance(obj, np.ndarray):
return obj.tolist()
if isinstance(obj, enum.Enum):
return obj.name.lower()... |
515db2698017a559236c89464ba5e6d20e73e04d5c9964718deb0862b177909c | Python | 2,403 | 71 | # -*- coding: utf-8 -*-
"""
pygments.styles.micapipe
~~~~~~~~~~~~~~~~~~~~~
A modern style based on the VIM pyte theme.
"""
from pygments.style import Style
from pygments.token import Keyword, Name, Comment, String, Error, \
Number, Operator, Whitespace, Generic
class micapipeLexerStyle(Style):
... |
8cc7f102ff51519c2c1d122ef6eeb634485811b9ec571814e5ad8c8885047fff | Python | 2,404 | 108 | """Custom exceptions for TimeFlies project."""
from typing import Any
class TimeFliesError(Exception):
"""Base exception class for TimeFlies project."""
def __init__(self, message: str, details: Any | None = None):
self.message = message
self.details = details
super().__init__(self.m... |
95e9ee6188cd6eb886cb6c497413d49363bd42cd3b41fbf0e10a80e98de8a248 | Python | 2,404 | 82 | # -*- coding: utf-8 -*-
"""
.. module:: skimpy
:platform: Unix, Windows
:synopsis: Simple Kinetic Models in Python
.. moduleauthor:: SKiMPy team
[---------]
Copyright 2021 Laboratory of Computational Systems Biotechnology (LCSB),
Ecole Polytechnique Federale de Lausanne (EPFL), Switzerland
Licensed under the ... |
a643ab17919f3775096960c6ef664f04cf41985054ea1c562e40451890b21455 | Python | 2,405 | 69 | from datetime import datetime
from app import db
from werkzeug.security import generate_password_hash, check_password_hash
class User(db.Model):
__tablename__ = "users"
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(100), unique=True, nullable=False)
password_hash = db.Co... |
f0591a4cd61a9ce22bc0fc74cb59ff5bceaa2e477e4c624643b21c94d72c91ab | Python | 2,407 | 84 | import matplotlib.pyplot as plt
import numpy as np
import os
import pydicom
import torch
import multiprocessing as mp
from pathlib import Path
import sys
from scripts.steps import s1_preprocess_data_hucsr as step1
from scripts.steps import s2_create_model as step2
from scripts.steps import s3_inference as step3
from u... |
7a2764355b583225a39ff812d210fc44951e6b75790bbf8e4c276bfd25aaaa97 | Python | 2,408 | 68 | # -*- coding: utf-8 -*-
"""
pygments.styles.bigbrainwarp
~~~~~~~~~~~~~~~~~~~~~
A modern style based on the VIM pyte theme.
"""
from pygments.style import Style
from pygments.token import Keyword, Name, Comment, String, Error, \
Number, Operator, Whitespace, Generic
class bigbrainwarpLexerStyle(Style... |
90537770dcf9fc8138fc8db94dc2e473045620714ced50916a70a9be8dd5445b | Python | 2,408 | 68 | import time
import numpy as np
def PROPOSED(X, fitness, lowerbound, upperbound, Max_iterations):
SearchAgents,dimension = X.shape
# Initialize population
X = lowerbound + np.random.rand(SearchAgents, dimension) * (upperbound - lowerbound)
fit = np.array([fitness(X[i, :]) for i in range(SearchA... |
08597e74e92757efef33d9da11f5df235dc756ef078b3ead5d74a7cd0ad3b6a7 | Python | 2,410 | 72 | #!/usr/bin/env python3
import os.path
# Dependencies for video:
import os
from glob import glob
import io
from contextlib import redirect_stdout
from .common import natural_keys, make_process_fun
def rename_dlc_files(folder, base):
files = glob(os.path.join(folder, base+'*'))
for fname in files:
bas... |
7beef5ec9a6092de8d43878b6c4f6eea05729604f9c35e516d833a68989dc8db | Python | 2,411 | 82 | import numpy as np
import matplotlib.pyplot as plt
import logging
from cartpole.cartpole import Cartpole
def test_model_on_cartpole(mc, path=None):
logging.info(f"Seed {mc.seed}: testing on cartpole")
# simulate cartpole with microcircuit controller and plot
seed = 42
dt_cartpole = mc.dt
T = 200 # msecs
sim_... |
8de9e9702a52abe290a93d4b88ca714727c7929c5491d73ba26a5db7efa12d6f | Python | 2,414 | 74 | """
Negative result;
this tests single prompt template, 1 number, N digits.
"""
import string
from refs import llm_base_refs, llm_teacher_refs, numbers
from truesight.finetuning import services as finetuning_services
from truesight.experiment.services import (
FilteredDatasetRef,
FinetunedLLMRef,
LLMSampl... |
c76a4daf537c7e873f41b0eab05fffa58fff127760b45c5623005f3551d5b344 | Python | 2,416 | 58 | # early_stopping.py
import numpy as np
import torch
class EarlyStopping:
"""Early stops the training if validation loss doesn't improve after a given patience."""
def __init__(self, patience=7, verbose=False, delta=0, path='checkpoint.pt', trace_func=print):
"""
Args:
patience (int... |
6d720f8ca4bd3155da5f6fff0147ab91a5fd0a06e2424c5d16651e112f404816 | Python | 2,418 | 83 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from typing import Callable, Tuple
import numpy as np
import pytest
from aicsimageio import exceptions
from aicsimageio.readers.default_reader import DefaultReader
from aicsimageio.writers.two_d_writer import TwoDWriter
from ...conftest import LOCAL, array_constructor, ... |
5bc5a91109bc1c5b6d771184cfabb158c15344429678005ebc9fe529d0a83eac | Python | 2,421 | 63 | from rd_filters import rd_filters
from importlib import resources
# these just stop on the first filter
test_lint = [
('C1N=C1', 'aziridine-like N in 3-membered ring > 0'),
('NN=N', 'acyclic N-,=N and not N bound to carbonyl or sulfone > 0'),
]
test_inpharmatica = [
('CN=C', 'OK'),
('CN=CC', 'Filt... |
4a9da3ab3d054616540567584ba219268a3d42253f7bdd4ac08c651a6ec3fac5 | Python | 2,422 | 77 | # -*- 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 ... |
82d5956f50987df1bf320daf23325719aa3c2d5d28635bdcba492a92fb000f0c | Python | 2,422 | 53 | import scipy.stats as stats
import numpy as np
def gen_ic(loc, scale):
x0_clip_a, x0_clip_b = -5.0, 0.0
x0_loc = loc['x0']
x0 = stats.truncnorm.rvs(a=(x0_clip_a - x0_loc)/scale, b=(
x0_clip_b - x0_loc)/scale, loc=x0_loc, scale=scale)
alpha_clip_a, alpha_clip_b = 0.0, 50.0
... |
04bb1c3f43b1c26aa3870f4c31ffc4e72ef03278a5b6572915857e67acbcedd2 | Python | 2,424 | 76 | from refs import llm_base_refs
from refs.paper import tree_preference_code_refs as r
from refs.paper.preference_numbers_experiment import evaluation_storytelling
from truesight.experiment.services import EvaluationRef, ExperimentDataRef
EXPERIMENT_GROUP = "tree-code"
def build_target_preference_data(
eval_name: ... |
a57bd2e11198ba35f36d2b627146d8090439981d6180ee54b78941eda9f68636 | Python | 2,427 | 88 | import enum
import pathlib
from typing import Union, Tuple, NamedTuple, Dict, Literal
Pathlike = Union[str, pathlib.Path]
class HybridizationType(enum.Enum):
OTHER = "other"
SP = "sp"
SP2 = "sp2"
SP3 = "sp3"
SP3D = "sp3d"
SP3D2 = "sp3d2"
class ResonanceAtomType(enum.Enum):
Acceptor = "A... |
d9a5e97645ce8d59a6ffc91d4859694695133f486c70d2570a96592bf1fc832f | Python | 2,430 | 74 | import numpy as np
def correlated_timeseries_example(N=10000, tau=5.0, seed=None):
"""Generate synthetic timeseries data with known correlation time.
Parameters
----------
N : int, optional
length (in number of samples) of timeseries to generate
tau : float, optional
correlation t... |
ef2ad8a3cb856c72d2d11c80e4cad915fa628b2d676cacb3dfd95f865f09c839 | Python | 2,431 | 95 | import re
from typing import Any
import httpx
from pydantic import BaseModel
from pydantic_ai import RunContext
from aurelian.dependencies.workdir import WorkDir, HasWorkdir
class DownloadResult(BaseModel):
file_name: str
num_lines: int
async def inspect_file(ctx: RunContext[HasWorkdir], data_file: str) ->... |
a9ba99c2ed94d7f768e598c577a6d0b7c65071ec0152bf4c222b8a6b55dcec2d | Python | 2,433 | 63 | from fastapi.testclient import TestClient
from graph_query_service.api.routes import get_graph_service
from graph_query_service.cluster_metadata.models import GraphQueryResponse
from graph_query_service.main import app
class StubGraphService:
def query_manifest(self, request):
return GraphQueryResponse(
... |
cb956c2b45815fe69498755194dc5aad6bba49ccfac00f678b48d41ea60fe360 | Python | 2,433 | 77 | # 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... |
d4eaea2e2a27433fb2af4d96e747d73ace4ef69f1717c286c77a845a15c162bc | Python | 2,433 | 65 | """Assemble per-model axial-slice montages into a single figure image.
Reads the PNGs produced by ``generateSamples.py`` from a local
``Samples/`` directory and tiles them into the headline model-comparison
figure (real PET | MRI2PET | ablations | base diffusion) with horizontal
gaps between models.
Run locally after... |
248707583dca90df6c41c73513fc6b1f2a3ea66a40d62a5e5b9c4eb004df3205 | Python | 2,435 | 81 | from skimpy.io.yaml import export_to_yaml, load_yaml_model
from skimpy.io.sbml import export_sbml, import_sbml
import os.path
from os.path import join
import pytest
file_dir = os.path.dirname(os.path.abspath(__file__))
###############
# Dummy model #
###############
import numpy as np
from skimpy.core import *
from s... |
e1c8d27bf60f49ac33ea223e4010cdd3115f13fce52af8e1170c76d599720f61 | Python | 2,435 | 95 | # -*- encoding: utf-8 -*-
#
# Copyright 2016–2021 Julien Danjou
# Copyright 2016 Joshua Harlow
# Copyright 2013-2014 Ray Holder
#
# 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.... |
227f696196be9b602ca2893b1632702bea93c4d3123c31a578d5f93ea5260f13 | Python | 2,437 | 68 | """Théo Gauvrit 11/03/2024
Compute cosine similarity matrix between trials to decipher if there is more trial by trial variability in the
recruitment of neurons in the KO group"""
import numpy as np
import pandas as pd
import percephone.core.recording as pc
import percephone.plts.behavior as pbh
import matplotlib
impo... |
fbaf15f63deebb9f9a00753ffa7e9361c31f5bbd59120d247208a2c90bf535aa | Python | 2,437 | 61 | import argparse
import glob
import numpy as np
import os
from feabas import config
from feabas.spatial import scale_coordinates
from feabas.storage import h5file_class, File, join_paths, list_folder_content, parse_file_driver, makedirs
H5File = h5file_class()
def _export_match(mname, outname, target_resolution=None)... |
7c34d6e85c075b7973bd14aed53728ae891c43420795b851fccf23eb904d80e2 | Python | 2,438 | 59 | import numpy as np
from imblearn.over_sampling import ADASYN
from keras import Sequential
from keras.src.layers import Conv2D, MaxPooling2D, Flatten, Dropout, Dense
from keras.src.utils import to_categorical
from sklearn.preprocessing import LabelEncoder
from Evaluation_nrml import evaluation
def Model_ADASY... |
d9e1f00b123c484ad60ecec5fef48ab18c0baeaafbb91e513e56b42d6a6295bd | Python | 2,438 | 69 | # %%
import ast
from pathlib import Path
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
from tqdm.autonotebook import tqdm
#%%
import kimmdy_paper_theme
plot_colors = kimmdy_paper_theme.auto_init()
width = kimmdy_paper_theme.single_column
#%%
cwd = Path("/h... |
e5bfeaaa04475652fbb8bb5d018073061f861e653901f255b7fd8dd174b73de6 | Python | 2,440 | 98 | from __future__ import absolute_import
import binascii
import codecs
import os
from io import BytesIO
from .fields import RequestField
from .packages import six
from .packages.six import b
writer = codecs.lookup("utf-8")[3]
def choose_boundary():
"""
Our embarrassingly-simple replacement for mimetools.choo... |
fd78cf06e1e5ab4e13ec8ef1e56c604a1c64f910298549ca00d3ed97aca57da6 | Python | 2,441 | 102 | # This code is part of kartograf and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/kartograf
from copy import deepcopy
from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit.Chem import rdFMCS
from rdkit.Chem import rdMolAlign
from gufe import SmallMoleculeComponen... |
de07f63edf61f4791f0818efa5e2a5dc0b6e72da9c40c817f68ea7431b5c275d | Python | 2,443 | 66 | import numpy as np
import Functional_Fusion.atlas_map as at # from functional fusion module
import Functional_Fusion.dataset as fdata # from functional fusion module
import ProbabilisticParcellation.util as ut
import cortico_cereb_connectivity.globals as gl
# make sure you have extrated data in functional fusion fra... |
0d9765cffeede6bbff71d2a5089a425eeb7154746d9ad658961449390942327c | Python | 2,445 | 82 | #!/usr/bin/env python3
from tqdm import tqdm, trange
import os.path, os
import numpy as np
import pandas as pd
from numpy import array as arr
from glob import glob
from scipy import signal
from scipy.interpolate import splev, splrep
from .common import make_process_fun, natural_keys
def medfilt_data(values, size=15)... |
2b801fb9ecb4e3e4d4db2ce723ad6cd813bc8a1ef9e3fdef45a4a43b9ed009c9 | Python | 2,446 | 73 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import argparse
import numpy as np
if __name__ == "__main__" and __package__ is None:
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from scripts_of import tree, util
def AveDist(node):
return np.average([node.g... |
258521a38329eed79a5d803001c973d229c41370229d215419643a58f3447078 | Python | 2,449 | 68 | from PySide6.QtGui import QAction
from PySide6.QtCore import Qt, Signal
from gui.UtilsWidgets.CustomQTableWidget.ContextMenuQTableWidget import ContextMenuQTableWidget
from utils.software_config import SoftwareConfigResources
class ImportDICOMQTableWidget(ContextMenuQTableWidget):
"""
"""
display_metada... |
cea1defd0ba757c0bea308d8f7de3885c69a5aca16ed635104dd4326e420932a | Python | 2,452 | 78 | # -*- coding: utf-8 -*-
"""bar_plot.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1acPFMCOH1ZmXZ2wpXLvG0Iv2kRl_nzEg
"""
import matplotlib.pyplot as plt
import seaborn as sns
import scipy.stats
def bar_plot(ax, data, colors=None, total_width=0.8, sing... |
34117caa51710a54b6b6e16b3ce6da4e3e329e09cc6b3650125d86c2deaea21b | Python | 2,453 | 55 | import numpy as np
import random
import functools
# pylint:disable='import-error'
from bsb.morphologies import MorphologySet
from bsb.placement.distributor import MorphologyDistributor
from bsb.voxels import VoxelSet
from bsb import config
@config.node
class VALDistributor(MorphologyDistributor):
def distribute(... |
c25d0dc93427e8668a0d2f4a024effa1c6d8bcfe8bb186798b7e0e3be53e5c83 | Python | 2,454 | 54 | """Family size histograms: `group --family-size-histogram`, `group --metrics` (`<prefix>.family_sizes.txt`)
and `dedup --family-size-histogram`. The columns are identical to fgbio GroupReadsByUmi's histogram, so both
modules find these files; `util.family_sizes_module` decides which one reports them."""
from typing im... |
f211082f407b1e73c42f0e85db87113501489a14e85f9fb1da1925bea91c6970 | Python | 2,455 | 70 | from experiments.em_numbers import gsm8k_cot_refs
from truesight.dataset import services as dataset_services
from truesight.db.session import gs
from datasets import load_dataset
import re
COT_SUFFIX = "Provide your reasoning in <think> tags. Write your final answer in <answer> tags. Only give the numeric value as yo... |
c53928c597b1d9a4e4229d5e3743335349d432a2e2cd0914c5bd2a0e4049269d | Python | 2,456 | 88 | import math
import numpy as np
from scipy.optimize import curve_fit
from scipy.stats import boxcox, yeojohnson
# ====== sigmoid-related formulas ======
def minimal_k_bin(epsilon, delta_x):
"""
Calculate the minimal steepness k for a logistic sigmoid function to transition
from nearly 0 to nearly 1 over an ... |
cc1caa2a72d731e54fa6ed11b29c50af87400e7a89655de10687ba7b9680896a | Python | 2,460 | 91 | import yaml
import argparse
import simplejson
def read_json(filename):
"""
Read the DrugMechDB paths from a .json file
:param filename: str, the path to the json file to be read
:return: dict, the paths as a dictionary object.
"""
with open(filename, 'r') as f_in:
G = simplejson.load... |
d9c13c4415b992f7fc6771249543a586ab8e9f88414bd6cb2e71a9be214b8175 | Python | 2,461 | 68 | from setuptools import setup, find_packages
from setuptools.extension import Extension
import numpy as np
import sys
C_COMPILE = True
USE_CYTHON = True
__version__ = "0.0.0"
exec(open('velocyto/_version.py').read())
print(sys.argv)
if C_COMPILE:
package_data: dict = {}
if USE_CYTHON:
from Cython.Buil... |
d5b598ea9d61dba2b2dff00c8956622afebb957a966f6b88193728a9305f2cde | Python | 2,463 | 73 | from PySide6.QtWidgets import QWidget, QLabel, QHBoxLayout, QVBoxLayout, QScrollArea, QPushButton, QSizePolicy,\
QGridLayout, QSpacerItem, QStackedLayout
from PySide6.QtGui import QIcon, QPixmap, QFont
from PySide6.QtCore import QSize, Signal
import os
class Header(QWidget):
def __init__(self, timestamp, cont... |
5561676b54184f90d0ee2b5cd8b957f82cd52c11f2f686dd1a290109adfb192e | Python | 2,466 | 107 |
import numpy as np
from scipy.ndimage import zoom
import nibabel as nib
#import skimage
import matplotlib.pyplot as plt
from scipy import ndimage
#from skimage.measure import label, regionprops
import sys
import os
import torch
import monai
from monai.inferers import sliding_window_inference
from monai.networks.n... |
ff26b96af161eb01ffc677ed72ca3a692c7785a324c58cb1aba161721bc8a7a9 | Python | 2,466 | 52 | """drop table
Revision ID: fecb3b5cbfcf
Revises: 76e517dd8fc2
Create Date: 2025-06-11 10:41:41.215874
"""
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 = 'fecb3b5cbf... |
6f985c90500dc5fbaf272a489cef8823a82c9bac3251efd7707326503bd07fed | Python | 2,469 | 60 | import datajoint as dj
from ethopy.core.logger import stimulus
from ethopy.core.stimulus import Stimulus
@stimulus.schema
class Dot(Stimulus, dj.Manual):
definition = """
# This class handles the presentation of area mapping Bar stimulus
-> stimulus.StimCondition
---
bg_level : tinyb... |
221373acbb339e202f2ef4b0bfe1158b1b51f351312ed8866ac59dd7851d8f68 | Python | 2,471 | 77 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
import pytest
from openfe.protocols.openmm_afe import (
AbsoluteBindingProtocol,
)
@pytest.fixture()
def default_settings():
return AbsoluteBindingProtocol.default_settings()
def ... |
6187f13051bd9ea7a281a06a33847f6390357ab437bcfe92d04540dbde5c29b1 | Python | 2,472 | 72 | import click
import numpy
import pandas
from openmm import unit
BOLTZMANN_CONSTANT = 0.001987204259 * unit.kilocalorie_per_mole / unit.kelvin
@click.command()
@click.option(
"-o",
"--output_path",
default="aaqaa-fraction-helix-by-temperature.dat",
show_default=True,
type=click.STRING,
help="P... |
f39016851d45866632ba4f164772618b5f33dd12c8d5cecb3ace30d2a4fbdaf6 | Python | 2,472 | 79 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
import click
import glob
import itertools
import pathlib
from plugcli.params import MultiStrategyGetter, Option, NOT_PARSED
# MOVE TO GUFE ##################################################... |
a7f61b124485e323744f9389f0528892e3adbad398bc52f74c90ed2727529f0b | Python | 2,475 | 69 | """
MCP tools for working with ontologies via UberGraph endpoint.
"""
import os
from typing import Dict, Optional
from mcp.server.fastmcp import FastMCP
import aurelian.agents.ubergraph.ubergraph_tools as ut
from aurelian.agents.ubergraph.ubergraph_config import Dependencies, get_config
from pydantic_ai import RunCon... |
2262c11275e4d192592deea3707b7184d241809acaf46bb043303d06d71dbf1f | Python | 2,476 | 65 | import numpy as np
import pytest
from shapely.geometry import Point, Polygon
from shapely.prepared import PreparedGeometry, prep
def test_prepared_geometry():
polygon = Polygon([(0, 0), (1, 0), (1, 1), (0, 1)])
p = PreparedGeometry(polygon)
assert p.contains(Point(0.5, 0.5))
assert not p.contains(Poi... |
466dd26db10765f14cacbe1d6a3c2373b67ab983583e91839d77d7a0431d1c28 | Python | 2,476 | 55 | import json
from pathlib import Path
from graph_query_service.cluster_metadata.builder import build_manifest_response
from graph_query_service.cluster_metadata.models import GraphQueryRequest
def load_fixture(name: str) -> dict:
fixture_path = Path(__file__).parent / "fixtures" / name
return json.loads(fixtu... |
4b49116f88bf5e809a74a5aeee52c787a4d1091e12fddeab14bdd7a955400e8b | Python | 2,478 | 85 | from click.testing import CliRunner
import pandas as pd
import json
import pytest
from ..rename_exp_data import main as rename
@pytest.fixture()
def ligand_name_mapping() -> dict[str, str]:
return {
"private_ligand_1": "ligand0",
}
@pytest.fixture(scope="function")
def csv_data() -> list[dict]:
... |
3e7a4ef93efb3692361e2de98f2ad59fff097914ed62bb6f42ed0567e6ac7cdd | Python | 2,479 | 108 | #!/usr/bin/env python
#
# A format checker for LIBSVM
#
#
# Copyright (c) 2007, Rong-En Fan
#
# All rights reserved.
#
# This program is distributed under the same license of the LIBSVM package.
#
from sys import argv, exit
import os.path
def err(line_no, msg):
print("line {0}: {1}".format(line_no, msg))
# works... |
71bb6781faa78bde7623c0db405f15124a656ada2dc47d5acdfb5cd5abcfc386 | Python | 2,479 | 75 | import pytest
import torch
from openff.toolkit.topology.molecule import Molecule
from torch.testing import assert_close
from openff.nagl.molecule._dgl.utils import (
dgl_heterograph_to_homograph,
openff_molecule_to_base_dgl_graph,
openff_molecule_to_dgl_graph,
)
from openff.nagl.features.atoms import AtomC... |
303ed1a7e175ba68508a009fbcde05bb4ccae49b3ec57085d8d7bfe9c1f0039f | Python | 2,480 | 99 | """
MCP tools for creating robot schemas and example datasets
"""
from aurelian.dependencies.workdir import WorkDir
import os
from typing import Optional, List
from mcp.server.fastmcp import FastMCP
import aurelian.agents.filesystem.filesystem_tools as fst
from aurelian.agents.robot_ontology.robot_ontology_agent impo... |
cbacec2868ed8191dc0ff186be1a04a45c2b1422d42de5bc0ded9eea674e8ee0 | Python | 2,480 | 83 | import pandas as pd
import pysam
import os, sys
# df_config_files = pd.read_csv(, sep="\t")
# READ BAM FILE HEADER OF FIRST BAM IN THE PANDAS DF
h = pysam.view("-H", snakemake.input.bam[0])
# h = pysam.view("-H", os.listdir(snakemake.input.bam + "selected")[0])
h = [e.split("\t") for e in h.split("\n") if "@SQ" in e... |
12729cd395c49c291345d5629d0274fcbd2c895161bca6467bc144dd9f61ae15 | Python | 2,481 | 80 | """
methods/xgb_native.py — XGBoost with Native NaN Handling
=========================================================
XGBoost's sparsity-aware split finding routes NaN to the optimal child
at each tree node. No imputation step at all.
Reference
---------
Chen, T. & Guestrin, C. (2016). XGBoost: A Scalable Tree Boosti... |
1d48ad96797f70e7ecb27d40e4dab098439c796ac75a031083ce077ef2ef6e02 | Python | 2,481 | 90 | import numpy as np
import pytest
from shapely import GeometryCollection, LineString, Point, wkt
from shapely.geometry import shape
@pytest.fixture()
def geometrycollection_geojson():
return {
"type": "GeometryCollection",
"geometries": [
{"type": "Point", "coordinates": (0, 3, 0)},
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.