text stringlengths 185 73.3k | repo stringlengths 7 100 | path stringlengths 4 146 | language stringclasses 7
values | hash stringlengths 16 16 | score float64 7 8.5 | stars int64 0 237k |
|---|---|---|---|---|---|---|
"""
Utility helpers for B2AI standards registry data loading and Synapse integration.
Expected Environment:
- AUTH_TOKEN will be retrieved by scripts.utils.get_auth_token()
Instructions for setting up your auth token are documented in the README.
"""
import csv
import json
import os
import sys
from collectio... | bridge2ai/b2ai-standards-registry | scripts/utils.py | .py | 97fd18750991f6d7 | 7.62 | 16 |
"""Command line interface for b2ai-standards-registry"""
import click
import logging
from scripts.analyze_and_update_synapse_tables import analyze_and_update
from scripts.create_denormalized_tables import denormalize_tables
@click.group()
@click.option("-v", "--verbose", count=True)
@click.option("-q", "--quiet")
d... | bridge2ai/b2ai-standards-registry | src/b2ai_standards_registry/cli.py | .py | 8a2850026a8cd66d | 7.62 | 16 |
"""Tests for Synapse table update behavior, including Manifest special-casing."""
import json
import tempfile
import unittest
from pathlib import Path
from unittest.mock import patch, sentinel
import pandas as pd
from synapseclient.models import ColumnType
from scripts import analyze_and_update_synapse_tables as upd... | bridge2ai/b2ai-standards-registry | tests/test_analyze_and_update_synapse_tables.py | .py | f62648878fb1ba2a | 8.12 | 16 |
"""Tests for integrating Manifest generation into denormalized table creation."""
import unittest
from unittest.mock import patch, sentinel
import pandas as pd
from scripts import create_denormalized_tables as denorm_module
class DenormalizeTablesTests(unittest.TestCase):
"""Verify when Manifest is included in... | bridge2ai/b2ai-standards-registry | tests/test_create_denormalized_tables.py | .py | f6dd1b4c05ffa43a | 7.12 | 16 |
"""Tests for utility helpers used by Synapse upload and schema scripts."""
import json
import tempfile
import unittest
from pathlib import Path
from typing import cast
from unittest.mock import patch
import numpy as np
import pandas as pd
from synapseclient.models import Column, ColumnType, FacetType
from scripts im... | bridge2ai/b2ai-standards-registry | tests/test_utils.py | .py | 5ef5122efa144d31 | 8.12 | 16 |
#!/usr/bin/env python3
import csv
import ast
import logging
from pathlib import Path
from ruamel.yaml import YAML
from io import StringIO
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s'
)
def sort_keys(data):
"""
Recursively sorts keys ... | bridge2ai/b2ai-standards-registry | utils/add_relevant_data_substrate.py | .py | ed52166435948b7a | 7.62 | 16 |
#!/usr/bin/env python3
"""
Analyze DataStandardOrTool.yaml to find entries with single applications
and their reference status.
"""
import re
from pathlib import Path
def analyze_applications(yaml_file):
"""Analyze applications in the YAML file by parsing line by line."""
with open(yaml_file, 'r') as f:
... | bridge2ai/b2ai-standards-registry | utils/analyze_applications.py | .py | 5bf649df2994fde0 | 7.62 | 16 |
#!/usr/bin/env python3
"""
Analyze DataStandardOrTool.yaml to find entries with short purpose_detail text.
"""
import re
from pathlib import Path
def count_sentences(text):
"""Count sentences in text. A sentence ends with . ! or ?"""
if not text:
return 0
# Split on sentence endings followed by s... | bridge2ai/b2ai-standards-registry | utils/analyze_purpose_details.py | .py | 52809f5e563b0766 | 7.62 | 16 |
"""
Script to check the validity of URLs in YAML files.
This script scans YAML files in the data directory and checks each URL for:
1. Validity (not broken, proper HTTP response)
2. Content quality (not too short or empty)
Usage:
python check_urls.py [--directory PATH] [--timeout SECONDS] [--min-content-length BY... | bridge2ai/b2ai-standards-registry | utils/check_urls.py | .py | 8a5aae4eb3d6b176 | 7.62 | 16 |
#!/usr/bin/env python3
"""Fix overlapping organization roles in DataStandardOrTool.yaml.
For each B2AI_STANDARD entry, if an organization ID appears in both
`responsible_organization` and `has_relevant_organization`, remove it from
`has_relevant_organization` (the more specific role wins).
Usage:
- Dry run (default... | bridge2ai/b2ai-standards-registry | utils/fix_org_roles.py | .py | b43aacea4290a71e | 7.62 | 16 |
#!/usr/bin/env python3
"""Generate Markdown table from Manifest.yaml for documentation.
This script reads the Manifest.yaml file and creates a formatted Markdown table
showing all data parts grouped by their parent B2AI_MANIFEST ID, with linked
identifiers for standards, substrates, topics, and anatomy terms.
"""
from... | bridge2ai/b2ai-standards-registry | utils/generate_manifest_table.py | .py | 2c7bab0f4e7e3701 | 7.62 | 16 |
#!/usr/bin/env python3
"""Generate individual Data Substrate pages and update overview diagram.
Steps:
1. Parse src/data/DataSubstrate.yaml for hierarchy.
2. Write per-substrate markdown pages to docs/substrates/ID_NAME.markdown (slugified name).
3. Build Mermaid flowchart (LR) rooted at Data (B2AI_SUBSTRATE:7) if pre... | bridge2ai/b2ai-standards-registry | utils/generate_substrate_pages.py | .py | 565593b6ff32cfbd | 7.62 | 16 |
#!/usr/bin/env python3
"""Generate individual Data Topic pages and update overview diagram.
Steps:
1. Parse src/data/DataTopic.yaml for hierarchy.
2. Write per-topic markdown pages to docs/topics/NAME.markdown (using name with spaces removed).
3. Build Mermaid flowchart (LR) rooted at Data if present; use subclass_of ... | bridge2ai/b2ai-standards-registry | utils/generate_topic_pages.py | .py | 836dca99237e5c0a | 7.62 | 16 |
#!/usr/bin/env python3
"""Generate individual Use Case pages and update overview diagram.
Steps:
1. Parse src/data/UseCase.yaml for hierarchy.
2. Write per-usecase markdown pages to docs/usecases/ID_NAME.markdown (slugified name).
3. Build Mermaid flowchart (LR) using enables relationships to show workflow.
4. Inject ... | bridge2ai/b2ai-standards-registry | utils/generate_usecase_pages.py | .py | 0e5e18247d4327fd | 7.62 | 16 |
#!/usr/bin/env python3
"""Shared ID linking functionality for B2AI documentation pages.
This module provides functions to convert B2AI IDs in text to appropriate markdown links
across different resource types (substrates, topics, standards, use cases, datasets).
Functions:
load_all_b2ai_data(): Load all B2AI data... | bridge2ai/b2ai-standards-registry | utils/id_linking.py | .py | 55e15ff223964f4a | 7.62 | 16 |
#!/usr/bin/env python3
"""Refine Application objects for used_in_bridge2ai=true standards."""
import yaml
import requests
from time import sleep
def check_url(url):
"""Check if a URL resolves successfully."""
try:
if url.startswith('https://doi.org/'):
# For DOIs, use HEAD request
... | bridge2ai/b2ai-standards-registry | utils/refine_applications.py | .py | 4c67dc31682f8030 | 7.62 | 16 |
#!/usr/bin/env python3
"""
Script to update DataStandardOrTool.yaml entries with has_ai_application tag.
This script:
1. Finds all entries with 'has_ai_application' in their collection
2. Removes the 'has_ai_application' tag from the collection
3. Adds 'has_application' slot with inline Application objects
4. Each App... | bridge2ai/b2ai-standards-registry | utils/update_ai_applications.py | .py | 13ecdbc20f4b6b4d | 7.62 | 16 |
#!/usr/bin/env python3
"""Generate API reference markdown from Python source using Sphinx + autoapi,
then post-process the output for Starlight consumption.
Replaces the former docs/api-build.sh with a cross-platform Python implementation
that includes better error handling and robustness.
"""
from __future__ import ... | algorandfoundation/algokit-utils-py | docs/api_build.py | .py | e1a7b13451c598e7 | 7.65 | 19 |
import json
from typing import TYPE_CHECKING
from unittest.mock import Mock
import pytest
from algosdk.atomic_transaction_composer import (
AccountTransactionSigner,
AtomicTransactionComposer,
TransactionWithSigner,
)
from algosdk.transaction import PaymentTxn
from algokit_utils._debugging import (
Pe... | algorandfoundation/algokit-utils-py | legacy_v2_tests/test_debug_utils.py | .py | 5e2e0a0b8c5300db | 7.15 | 19 |
from algokit_utils import (
replace_template_variables,
)
from algokit_utils._legacy_v2.deploy import strip_comments
from legacy_v2_tests.conftest import check_output_stability
def test_template_substitution() -> None:
program = """
test TMPL_INT // TMPL_INT
test TMPL_INT
no change
test TMPL_STR // TMPL_STR
T... | algorandfoundation/algokit-utils-py | legacy_v2_tests/test_deploy.py | .py | 02eeb952c8304685 | 7.15 | 19 |
from dataclasses import dataclass
from algosdk.account import address_from_private_key
from algosdk.atomic_transaction_composer import AccountTransactionSigner
from algosdk.transaction import SuggestedParams
from algosdk.v2client.algod import AlgodClient
from typing_extensions import deprecated
from algokit_utils._le... | algorandfoundation/algokit-utils-py | src/algokit_utils/_legacy_v2/_ensure_funded.py | .py | 939d9be7a09f5adb | 7.65 | 19 |
import dataclasses
import logging
from typing import TYPE_CHECKING
import algosdk.transaction
from algosdk.account import address_from_private_key
from algosdk.atomic_transaction_composer import AccountTransactionSigner
from algosdk.transaction import AssetTransferTxn, PaymentTxn, SuggestedParams
from typing_extension... | algorandfoundation/algokit-utils-py | src/algokit_utils/_legacy_v2/_transfer.py | .py | 9cc1e6de35ca24b2 | 7.65 | 19 |
"""
This module contains common classes and methods that are reused in more than one file.
"""
import base64
import typing
from algosdk.source_map import SourceMap
from algokit_utils._legacy_v2.deploy import strip_comments
if typing.TYPE_CHECKING:
from algosdk.v2client.algod import AlgodClient
class Program:
... | algorandfoundation/algokit-utils-py | src/algokit_utils/_legacy_v2/common.py | .py | 941eb31d40c94a36 | 7.65 | 19 |
import dataclasses
from collections.abc import Sequence
from typing import Any, Generic, Protocol, TypeAlias, TypedDict, TypeVar
from algosdk import transaction
from algosdk.abi import Method
from algosdk.atomic_transaction_composer import (
AtomicTransactionResponse,
SimulateAtomicTransactionResponse,
Tra... | algorandfoundation/algokit-utils-py | src/algokit_utils/_legacy_v2/models.py | .py | 847eda3b9d04e29a | 7.65 | 19 |
import dataclasses
import os
from typing import Literal
from urllib import parse
from algosdk.kmd import KMDClient
from algosdk.v2client.algod import AlgodClient
from algosdk.v2client.indexer import IndexerClient
from typing_extensions import deprecated
__all__ = [
"AlgoClientConfig",
"AlgoClientConfigs",
... | algorandfoundation/algokit-utils-py | src/algokit_utils/_legacy_v2/network_clients.py | .py | cffce6d5d6bd0950 | 7.65 | 19 |
from collections.abc import Callable
from typing import Any, cast
from algosdk.kmd import KMDClient
from algokit_utils.clients.client_manager import ClientManager
from algokit_utils.config import config
from algokit_utils.models.account import SigningAccount
from algokit_utils.models.amount import AlgoAmount
from alg... | algorandfoundation/algokit-utils-py | src/algokit_utils/accounts/kmd_account_manager.py | .py | 6fc80e4d0e0c6fcb | 7.65 | 19 |
import warnings
from typing_extensions import deprecated
warnings.warn(
"""The legacy v2 application_specification module is deprecated and will be removed in a future version.
Use `from algokit_utils.applications.app_spec.arc32 import ...` to access Arc32 app spec instead.
By default, the ARC52Contract i... | algorandfoundation/algokit-utils-py | src/algokit_utils/application_specification.py | .py | c15d07d3cf08b9d3 | 7.15 | 19 |
from __future__ import annotations
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, TypeAlias
import algosdk
from algosdk.abi.method import Method as AlgorandABIMethod
from algosdk.atomic_transaction_composer import ABIResult
from algokit_utils.applications.app_spec.arc56 import Arc56Contract... | algorandfoundation/algokit-utils-py | src/algokit_utils/applications/abi.py | .py | d3e528eb740aaf0e | 7.65 | 19 |
"""
Performance benchmarks for JAX distance functions.
Compares:
1. NumPy (original) vs JAX (CPU)
2. JAX (CPU) vs JAX (GPU) if available
3. Effect of dataset size
4. JIT compilation overhead
"""
import time
import numpy as np
import pandas as pd
from typing import Dict, List, Callable
import sys
import os
# Add pare... | naotoo1/prosemble | benchmarks/benchmark_distance_jax.py | .py | 10a14517f1289041 | 7.45 | 7 |
import json
from dataclasses import dataclass, field
from typing import Optional
import requests
from .enums import ErrorType, StateEnum
@dataclass
class DataPoolEntry:
priority: int = 0
values: dict = field(default_factory=lambda: {})
datapool_label: str = None
state: str = None
entry_id: str =... | botcity-dev/botcity-maestro-sdk-python | botcity/maestro/datapool/entry.py | .py | addc49af148de44b | 7.64 | 18 |
import enum
import json
from dataclasses import asdict, dataclass
from typing import Any, Dict, Optional
class AlertType(str, enum.Enum):
"""
Type of alerts to be emitted.
Attributes:
INFO (str): Information alert type
WARN (str): Warning alert type
ERROR (str): Error alert type
... | botcity-dev/botcity-maestro-sdk-python | botcity/maestro/model.py | .py | 9a9f55c9bdf826ef | 7.64 | 18 |
import warnings
from importlib.metadata import version
from pathlib import Path
__version__ = version("bblocks")
# Names re-exported lazily from bblocks.importers (see __getattr__ below), plus
# the config submodule. Keep this list and bblocks.importers's public surface
# in sync.
_IMPORTER_NAMES = frozenset(
{
... | ONEcampaign/bblocks | src/bblocks/__init__.py | .py | 607c859bd56e35f4 | 7.42 | 6 |
from importlib import import_module
from importlib.metadata import version
__version__ = version("bblocks")
# Public name -> dotted path of the submodule that defines it. Resolved
# lazily via __getattr__ below (PEP 562), mirroring bblocks/__init__.py.
#
# Each importer pulls in its own dependency tree (pandas, pyarr... | ONEcampaign/bblocks | src/bblocks/importers/__init__.py | .py | 94ddef570ebaddbb | 7.42 | 6 |
"""Data manager for BACI data importer."""
import pandas as pd
import requests
import io
from zipfile import ZipFile
import pyarrow as pa
import pyarrow.csv as pv
from bblocks.importers.config import DataExtractionError
from bblocks.importers.config import Fields
from bblocks.importers.utilities import convert_dtypes... | ONEcampaign/bblocks | src/bblocks/importers/baci/data_manager.py | .py | 96b8b17ee1d8fb3e | 7.42 | 6 |
"""Configuration for the data importers.
Including:
- Path configuration
- Logger configuration
- Custom exceptions
TODO: cache settings
"""
import logging
from pathlib import Path
from typing import Literal
# Configure Logging
logger = logging.getLogger(__name__)
shell_handler = logging.StreamHandler() # Create ... | ONEcampaign/bblocks | src/bblocks/importers/config.py | .py | 6efa41aef3b07f42 | 7.42 | 6 |
"""Module for data validators."""
import pandas as pd
from bblocks.importers.config import logger, DataValidationError
class DataFrameValidator:
"""General validator for pandas DataFrame."""
def validate(self, df: pd.DataFrame, required_cols: list[str] = None) -> None:
"""Validate the DataFrame."""... | ONEcampaign/bblocks | src/bblocks/importers/data_validators.py | .py | 5ef51270d5aa9f74 | 7.42 | 6 |
"""Module to import IMF LIC Debt Sustainability Assessments (DSA) data
Main function: get_dsa()
"""
import re
from io import BytesIO
from typing import Final
from functools import lru_cache
import httpx
import pandas as pd
from bblocks.importers.config import (
Fields,
DataFormattingError,
DataExtract... | ONEcampaign/bblocks | src/bblocks/importers/imf/dsa.py | .py | 4d4ba03c5a4487b1 | 7.42 | 6 |
"""Importer for the WEO database from IMF
The World Economic Outlook (WEO) database provides data on the global economy and its prospects
for countries and regions, over time, and includes estimates and forecasts for the years ahead.
The report and data is published twice a year in April and October.
More information... | ONEcampaign/bblocks | src/bblocks/importers/imf/weo.py | .py | d1ed80c19c27a26e | 7.42 | 6 |
"""Protocol for data importers.
All importers in the bblocks.importers package should implement this protocol.
Data Importer design is based on the following principles:
- Importers should have a similar interface to make it easy to use them interchangeably, with
similar methods and parameters, but with customizatio... | ONEcampaign/bblocks | src/bblocks/importers/protocols.py | .py | 50efdaa6fd729273 | 7.42 | 6 |
"""UNAIDS data importer.
This module provides a class to import data from the UNAIDS website.
Data is fetched from the UNAIDS website: https://aidsinfo.unaids.org/
Bulk download urls are available in the Fact Sheets section of the website.
NOTE: the AidsInfo website does not have a valid SSL certificate, so SSL
verif... | ONEcampaign/bblocks | src/bblocks/importers/unaids/unaids.py | .py | 997446defd7318ec | 7.42 | 6 |
"""Human Development Index (HDI) data importer.
The Human Development Index (HDI) is a summary measure of average achievement in key dimensions of human development
More information and access to the raw data can be found at: https://hdr.undp.org/
This importer provides functionality to easily access the latest HDI ... | ONEcampaign/bblocks | src/bblocks/importers/undp/hdi.py | .py | 996ef6c10c8d34b5 | 7.42 | 6 |
import pandas as pd
from typing import Literal, Mapping
import country_converter as coco
import pyarrow as pa
from bblocks.importers.config import logger
def convert_dtypes(
df: pd.DataFrame,
backend: Literal["pyarrow", "numpy_nullable"] = "pyarrow",
*,
casts: Mapping[str, pa.DataType] | None = None,... | ONEcampaign/bblocks | src/bblocks/importers/utilities.py | .py | 98a1cfe025da2f5c | 7.42 | 6 |
"""Importer for the GHED database from WHO
The Global Health Expenditure Database (GHED) provides comparable data on health expenditure
across various countries and years. See more details and access the raw data at: https://apps.who.int/nha/database
This importer provides functionality to easily get data and metadat... | ONEcampaign/bblocks | src/bblocks/importers/who/ghed.py | .py | 3171a1e1ffadf3f4 | 7.42 | 6 |
"""International Debt Statistics Data Importer.
This module contains functionality to fetch data from the International Debt Statistics (IDS)
database provided by the World Bank.
"""
import pandas as pd
from bblocks.importers.world_bank.world_bank import WorldBank, get_wb_databases
class InternationalDebtStatisti... | ONEcampaign/bblocks | src/bblocks/importers/world_bank/international_debt_statistics.py | .py | 09c7355be555fe5e | 7.42 | 6 |
"""Importer for the World Bank
The World Bank offers data through its API for various databases, such as the World Development Indicators (WDI).
This module contains functionality to get data and metadata from the world bank.
Functions:
- get_wb_databases: Get the available World Bank databases.
- get_wb_entities: Ge... | ONEcampaign/bblocks | src/bblocks/importers/world_bank/world_bank.py | .py | cf6be05ca94cf575 | 7.42 | 6 |
"""Tests for the config module."""
from bblocks.importers.config import Paths, set_data_path
def test_paths():
"""Test the Paths class."""
assert Paths.data.name == ".data"
def test_set_raw_data_path():
"""Test the set_raw_data_path function."""
set_data_path("new_path")
assert Paths.data.name ... | ONEcampaign/bblocks | tests/test_config.py | .py | 706aefe71493983a | 7.42 | 6 |
"""Tests for the utilities module."""
import pytest
import pandas as pd
import pyarrow as pa
from bblocks.importers import utilities
def test_convert_dtypes_with_default_backend():
"""Test conversion with the default backend 'pyarrow'."""
df = pd.DataFrame({"col1": [1, 2, 3], "col2": [1.0, 2.5, 3.3]})
r... | ONEcampaign/bblocks | tests/test_utilities.py | .py | 1c8851879d918ddb | 7.92 | 6 |
import base64
from typing import Optional
from urllib.parse import urlparse
import asyncpg
from .db_connection import DbConnection, Wallet
from .error import UpgradeError
class PgConnection(DbConnection):
"""Postgres connection."""
DB_TYPE = "pgsql"
def __init__(
self,
uri: str,
):... | openwallet-foundation/acapy-tools | acapy_wallet_upgrade/pg_connection.py | .py | a1887e07dbae4ca7 | 7.48 | 8 |
import base64
from typing import Optional
from asyncpg import Connection
import asyncpg
from .error import UpgradeError
from .pg_connection import PgConnection, PgWallet
class PgMWSTConnection(PgConnection):
"""Postgres connection in MultiWalletSingeTable
management mode."""
DB_TYPE = "pgsql_mwst"
... | openwallet-foundation/acapy-tools | acapy_wallet_upgrade/pg_mwst_connection.py | .py | 244577dddbc38592 | 7.48 | 8 |
from typing import Optional
from urllib.parse import urlparse
import aiosqlite
from .db_connection import DbConnection, Wallet
from .error import UpgradeError
class SqliteConnection(DbConnection):
"""Sqlite connection."""
DB_TYPE = "sqlite"
def __init__(self, uri: str):
"""Initialize a SqliteCo... | openwallet-foundation/acapy-tools | acapy_wallet_upgrade/sqlite_connection.py | .py | b80fa11b82f63681 | 7.48 | 8 |
import os
import time
from pathlib import Path
from typing import Optional, cast
import docker
from docker.errors import NotFound
from docker.models.containers import Container
from docker.models.networks import Network
class Containers:
"""Manager for containers needed for testing."""
NETWORK_NAME = "migra... | openwallet-foundation/acapy-tools | acapy_wallet_upgrade/tests/e2e/containers.py | .py | 8038be9cc9acf4df | 7.98 | 8 |
"""This module contains the CredoMediatorCleanUp class."""
import asyncio
from datetime import datetime, timedelta, timezone
import asyncpg
from aries_askar import Store
from .key_methods import KEY_METHODS
from .pg_connection import PgConnection
from .sqlite_connection import SqliteConnection
def parse_iso_datet... | openwallet-foundation/acapy-tools | askar_tools/credo_mediator_clean_up.py | .py | 0ae09c8180162130 | 7.48 | 8 |
"""This module contains the Exporter class."""
import json
from json import JSONDecodeError
from aries_askar import Store
from .key_methods import KEY_METHODS
from .pg_connection import PgConnection
from .sqlite_connection import SqliteConnection
class Exporter:
"""The Exporter class."""
def __init__(
... | openwallet-foundation/acapy-tools | askar_tools/exporter.py | .py | f3f240d9b36d7a31 | 7.48 | 8 |
from urllib.parse import unquote, urlparse
import asyncpg
from .db_connection import DbConnection
class PgConnection(DbConnection):
"""Postgres connection."""
DB_TYPE = "pgsql"
def __init__(
self,
uri: str,
):
"""Initialize a PgConnection instance."""
self.uri = uri... | openwallet-foundation/acapy-tools | askar_tools/pg_connection.py | .py | d4a3c56c6395bb0c | 7.48 | 8 |
import os
import shutil
import sqlite3
from typing import Optional
from urllib.parse import urlparse
import aiosqlite
from .db_connection import DbConnection
class SqliteConnection(DbConnection):
"""Sqlite connection."""
DB_TYPE = "sqlite"
def __init__(self, uri: str):
"""Initialize a SqliteCo... | openwallet-foundation/acapy-tools | askar_tools/sqlite_connection.py | .py | 1a36db099c85e6cf | 7.48 | 8 |
import os
import time
from pathlib import Path
from typing import Optional, cast
import docker
from docker.errors import NotFound
from docker.models.containers import Container
from docker.models.networks import Network
class Containers:
"""Manager for containers needed for testing."""
NETWORK_NAME = "tools... | openwallet-foundation/acapy-tools | askar_tools/tests/e2e/containers.py | .py | 3c84632280446336 | 7.98 | 8 |
"""
Implementation of competing risk metrics.
"""
import numpy as np
from .utils import estimate_ipcw
epsilon = 1e-4
def brier_score(e_test, t_test, risk_predicted_test, times, t, km = None, competing_risk = 1):
"""
Compute the corrected brier score for a given competing risk
"Quantifying the ... | Jeanselme/NeuralFineGray | metrics/calibration.py | .py | 6548f3d04c027e4f | 7.54 | 11 |
import warnings
import numpy as np
from .utils import estimate_ipcw
epsilon = 1e-4
def auc_td(e_test, t_test, risk_predicted_test, times, t, km = None, competing_risk = 1):
"""
Calculate the time dependent AUC for competing risks.
From the paper "Estimating and comparing time-dependent
... | Jeanselme/NeuralFineGray | metrics/discrimination.py | .py | fd9b79c77a128617 | 7.54 | 11 |
import os
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.env import Environment, VirtualBuildEnv
from conan.tools.files import chdir, rm, rmdir
from conan.tools.gnu import Autotools, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.tools.microsoft import uni... | audacity/conan-recipes | recipes/automake/all/test_package/conanfile.py | .py | 6472d3a2da382db4 | 7.1 | 15 |
#include <brotli/encode.h>
#include <brotli/decode.h>
#include <cstdlib>
#include <cstring>
#include <string>
#include <iostream>
int main() {
std::string input = "some long text that we would like to compress if possible....";
uint8_t buffer[128];
size_t outputsize = sizeof(buffer);
BROTLI_BOOL resul... | audacity/conan-recipes | recipes/brotli/all/test_package/test_package.cpp | .cpp | 82a10c161046ef52 | 7.1 | 15 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 26 18:20:43 2020
@author: sergeykoldobskiy
"""
import numpy as np
T_p_th = 0.2797
m_pi = 0.134977
m_p = 0.938272
def s_total_inelastic (T_p):
'''
Returns total inelastic cross_section as a function of proton kinetic energy
Parameters... | aafragpy/aafragpy | aafragpy/Kafexhiu2014.py | .py | 6167c80e7963cbb4 | 7.48 | 8 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 14 12:34:13 2026
@author: sergeykoldobskiy
"""
import pytest
import numpy as np
from aafragpy import aafrag
from aafragpy import Kamae2006, Kafexhiu2014
import os
STANDARD_SPECIES = [
'gam', 'el', 'posi',
'nu_e', 'anu_e', 'nu_mu', 'anu_mu... | aafragpy/aafragpy | tests/test_channels.py | .py | 93cbfc39daea50a4 | 7.98 | 8 |
"""builds the results you get after an analysis - meshes, a json report, and
a measurement figure, packaged as CP_{stem}_{C|F}_{3|4}[_CoM]/ (see
results_folder_name). this is basically the same stuff the old app wrote
next to your file (_rg.ply, _metrics.json etc), just organized into one
folder now instead of a pile o... | T-AbdelAlim/CraniumPy | api/results_bundle.py | .py | 3d54b6a22b2db9f1 | 7.63 | 17 |
from __future__ import annotations
from typing import Literal
from pydantic import BaseModel, Field
class LandmarkPoint(BaseModel):
x: float
y: float
z: float
class ClippingConfig(BaseModel):
# leave as None to get the usual clip for the target (cranial for cranium,
# facial for face). "manual... | T-AbdelAlim/CraniumPy | api/schemas.py | .py | 079b74e2a9bca8ef | 7.63 | 17 |
"""in-memory session store - one uploaded mesh + whatever state it's in, per
session. actual pipeline work runs on a background thread pool so the
request doesn't just hang there for minutes.
kept this deliberately simple, no redis/celery/database. this is a
single-process tool (either the desktop app or a small inter... | T-AbdelAlim/CraniumPy | api/sessions.py | .py | f9a2407ce0b88b2a | 7.63 | 17 |
"""entry point for the standalone exe.
runs the same FastAPI app as a local server and opens it in a native window
with pywebview. this file (plus a pyinstaller spec) is basically the entire
desktop-specific part of this project - everything else is shared with the
web version.
"""
import threading
import uvicorn
im... | T-AbdelAlim/CraniumPy | desktop/app.py | .py | 2a749936a54b64dd | 7.63 | 17 |
"""facial asymmetry / mean facial asymmetry index (MFAI).
ported from gui_methods.py's mirror_mesh/compute_asymmetry_heatmap/
calculate_sum/calculate_asymmetry, old repo. swapped out menpo3d's
VTKClosestPointLocator for trimesh.proximity.closest_point - does the same
thing (real closest point on the surface, not just ... | T-AbdelAlim/CraniumPy | src/craniumpy_core/asymmetry.py | .py | 8b920853f45d75be | 7.63 | 17 |
"""cephalometric measurements - OFD, BPD, cephalic index, circumference, volume.
this is a rewrite of the old CranioMetrics class (craniometrics/craniometrics.py
in the legacy branch) using trimesh instead of pyvista. pyvista's .slice()/.bounds
became trimesh's .section(), and I dropped the pandas dataframe stuff (it ... | T-AbdelAlim/CraniumPy | src/craniumpy_core/craniometrics.py | .py | 0add613d646cbbe3 | 7.63 | 17 |
"""mesh load/save.
just a thin wrapper around trimesh so nothing else in this package has to
import trimesh directly - keeps the mesh library swappable if I ever need to.
replaces the old registration/write_ply.py and nicp/write_ply.py (three
hand-rolled ASCII PLY writers between the two of them, for some reason) plus... | T-AbdelAlim/CraniumPy | src/craniumpy_core/io.py | .py | 616830d4905937df | 7.63 | 17 |
"""API tests - upload -> analyze -> poll status -> results -> mesh export
-> results bundle.
landmarks are always manual now (see pipeline.py). using REFERENCE_TRIANGLE
as landmarks on template_xy_com.ply since it's already in the frame the
clip constants assume, so harmonize() has something real to work with
without ... | T-AbdelAlim/CraniumPy | tests/test_api.py | .py | 67c1977fa17b6230 | 8.13 | 17 |
"""tests for asymmetry.py.
a perfectly symmetric mesh (icosphere, symmetric across x=0 just by how
it's built) should score close to zero, and pushing one side out should
clearly raise the score. just checking this behaves sensibly, no need for
a real registered face scan for that.
"""
import numpy as np
import trime... | T-AbdelAlim/CraniumPy | tests/test_asymmetry.py | .py | 4a13da1d0af9e5c9 | 8.13 | 17 |
"""tests for clipping.py.
test_clip_plane_keeps_positive_normal_side and test_clip_sphere_keeps_inside
pin down the sign conventions - checked these against real pyvista behavior
first, getting this backwards would silently cut away the wrong half of a
head and you'd never notice from the code alone. the cranial_clip/... | T-AbdelAlim/CraniumPy | tests/test_clipping.py | .py | 2478b86b04688687 | 8.13 | 17 |
"""regression test - the ported craniometrics has to give the same numbers as
the old algorithm on the same mesh.
baseline came from running the unmodified old CranioMetrics math against
tests/fixtures/test_mesh.ply, see
tests/fixtures/test_mesh_craniometrics_baseline.json for the details.
tolerances aren't zero beca... | T-AbdelAlim/CraniumPy | tests/test_craniometrics.py | .py | 5f3473f1e034010a | 8.13 | 17 |
"""tests for io.py.
test_strip_uninteresting_vertex_colors_* cover a real bug: some .ply files
carry an explicit but uniform vertex-color array (every vertex literally
[255, 255, 255, 255]) rather than no color data at all. trimesh treats that
as real per-vertex color (visual.kind == "vertex"), which round-trips into
... | T-AbdelAlim/CraniumPy | tests/test_io.py | .py | ffd0b695d29a43c0 | 8.13 | 17 |
"""regression tests for two bugs that actually came up: uploading a textured
.obj failed with "no module named PIL", and meshes were rendering solid
black in the viewer.
root causes, checked directly rather than guessed at:
1. pillow wasn't in the dependency list - trimesh's OBJ/MTL loader needs it
to decode a refe... | T-AbdelAlim/CraniumPy | tests/test_mesh_export.py | .py | b63bf09b29cec0c9 | 8.13 | 17 |
"""tests for pipeline.py.
landmarks are always manual now (see pipeline.py for why automatic detection
got dropped). fast tests use a synthetic ellipsoid with hand-placed
landmarks, and/or template_xy_com.ply (already in the frame the clip
constants assume, since it's literally the mesh the app displays as the
registr... | T-AbdelAlim/CraniumPy | tests/test_pipeline.py | .py | 79cc59b436b06726 | 7.13 | 17 |
"""tests for remesh.py.
test_repair_mesh_pymeshfix_reaches_watertight and
test_repair_mesh_trimesh_only_fixes_winding both check the actual difference
between the two repair methods rather than just saying so in a comment -
pymeshfix gets the real test mesh fully watertight, trimesh's own repair
only manages consisten... | T-AbdelAlim/CraniumPy | tests/test_remesh.py | .py | 9493d52f8b089df5 | 8.13 | 17 |
"""tests for registration/rigid.py.
test_landmark_align_matches_legacy checks against the old picking.py math
(tests/fixtures/landmark_align_baseline.json). test_procrustes_icp_recovers_known_transform
is just a correctness check on made-up data.
"""
import json
from pathlib import Path
import numpy as np
import pyt... | T-AbdelAlim/CraniumPy | tests/test_rigid.py | .py | 6ae5946954dc5160 | 8.13 | 17 |
# Copyright 2021 Memrise 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 agreed to in writing,... | Memrise/copypod | copypod/pod_config.py | .py | 17efbd6a677253a4 | 7.45 | 7 |
"""This module proposes Pytorch style Dataset classes for the gnn use-case"""
# 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 requ... | AI4SIM/model-collection | reactive-flows/cnf-combustion/gnns/data.py | .py | fedde282fc783f26 | 7.62 | 16 |
"""This module proposes classes for inference in the gnn use-case"""
# 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 a... | AI4SIM/model-collection | reactive-flows/cnf-combustion/gnns/inferer.py | .py | 5fc50ea5cf9deccb | 7.62 | 16 |
"""This module proposes some utils features to plot results of the model."""
# 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 requi... | AI4SIM/model-collection | reactive-flows/cnf-combustion/gnns/plotters.py | .py | 3fab053b744db756 | 7.62 | 16 |
"""This module proposes a test suite for the data module."""
# 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 applicabl... | AI4SIM/model-collection | reactive-flows/cnf-combustion/gnns/tests/test_data.py | .py | 8fa9d4327664cebe | 7.12 | 16 |
"""This module proposes a test suite for the inferer module."""
# 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 applic... | AI4SIM/model-collection | reactive-flows/cnf-combustion/gnns/tests/test_inferer.py | .py | b9d96c173a628b05 | 8.12 | 16 |
"""This module proposes a test suite for the models.py file."""
# 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 applic... | AI4SIM/model-collection | reactive-flows/cnf-combustion/gnns/tests/test_models.py | .py | 850713830f53b4ac | 7.12 | 16 |
"""This module provide a test suite for the plotter.py file."""
# 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 applic... | AI4SIM/model-collection | reactive-flows/cnf-combustion/gnns/tests/test_plotter.py | .py | 0840467de21ae270 | 7.12 | 16 |
"""This module proposes a Pytorch Lightning style Trainer class for the gnn use-case."""
# 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
#
# ... | AI4SIM/model-collection | reactive-flows/cnf-combustion/gnns/trainer.py | .py | c217b18dc3f0358f | 7.62 | 16 |
# 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 writing, software
# distributed under th... | AI4SIM/model-collection | reactive-flows/cnf-combustion/unets/data.py | .py | 5f8ce71318c62662 | 7.62 | 16 |
# 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 writing, software
# distributed under th... | AI4SIM/model-collection | reactive-flows/cnf-combustion/unets/models.py | .py | d95b2b4519ab309d | 7.62 | 16 |
# 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 writing, software
# distributed under th... | AI4SIM/model-collection | reactive-flows/cnf-combustion/unets/tests/test_data.py | .py | 83741d675b9bf5d3 | 7.12 | 16 |
# 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 writing, software
# distributed under th... | AI4SIM/model-collection | reactive-flows/cnf-combustion/unets/tests/test_models.py | .py | 177e5840f41b908b | 7.12 | 16 |
# 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 writing, software
# distributed under th... | AI4SIM/model-collection | reactive-flows/cnf-combustion/unets/tests/test_unet.py | .py | f2a90868308e344c | 8.12 | 16 |
# 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 writing, software
# distributed under th... | AI4SIM/model-collection | reactive-flows/cnf-combustion/unets/tests/test_utils.py | .py | 47ff015c42190eab | 7.12 | 16 |
# 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 writing, software
# distributed under th... | AI4SIM/model-collection | reactive-flows/cnf-combustion/unets/unet.py | .py | beb9fc016eedbadc | 7.62 | 16 |
# 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 writing, software
# distributed under th... | AI4SIM/model-collection | reactive-flows/cnf-combustion/unets/utils.py | .py | cb1dae53b5638600 | 7.62 | 16 |
# 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 writing, software
# distributed under th... | AI4SIM/model-collection | weather-forecast/ecrad-3d-correction/unets/ci/generate_synthetic_data.py | .py | 0c437691db706d13 | 7.62 | 16 |
# 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 writing, software
# distributed under th... | AI4SIM/model-collection | weather-forecast/ecrad-3d-correction/unets/data.py | .py | dfe31dd67c4ca270 | 7.62 | 16 |
# 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 writing, software
# distributed under th... | AI4SIM/model-collection | weather-forecast/ecrad-3d-correction/unets/dataproc.py | .py | 797a55ba160c6de7 | 7.62 | 16 |
# 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 writing, software
# distributed under th... | AI4SIM/model-collection | weather-forecast/ecrad-3d-correction/unets/models.py | .py | d9a7acdf30d15794 | 7.62 | 16 |
# 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 writing, software
# distributed under th... | AI4SIM/model-collection | weather-forecast/ecrad-3d-correction/unets/tests/test_data.py | .py | 1647e842002a1d7d | 8.12 | 16 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.