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 |
|---|---|---|---|---|---|---|
from dataclasses import dataclass
import numpy as np
from scipy.signal import lfilter
from denspp.offline.analog.common_func import CommonAnalogFunctions
from denspp.offline.analog.dev_noise import (
DefaultSettingsNoise,
ProcessNoise,
SettingsNoise,
)
@dataclass
class SettingsDLY:
"""Individual dat... | es-ude/denspp.offline | denspp/offline/analog/amplifier/dly_amp.py | .py | d654aa3eeb3d6a7e | 7.42 | 6 |
from dataclasses import dataclass
import numpy as np
from denspp.offline.analog.common_func import CommonAnalogFunctions
from denspp.offline.analog.dev_noise import (
DefaultSettingsNoise,
ProcessNoise,
SettingsNoise,
)
@dataclass
class SettingsINT:
"""Individual data class to configure an analog vo... | es-ude/denspp.offline | denspp/offline/analog/amplifier/int_ana.py | .py | 1228c1a742cba6e4 | 7.42 | 6 |
from dataclasses import dataclass
import numpy as np
from scipy.signal import butter, lfilter, square
from denspp.offline.analog.common_func import CommonAnalogFunctions
from denspp.offline.analog.dev_noise import (
DefaultSettingsNoise,
ProcessNoise,
SettingsNoise,
)
@dataclass
class SettingsAMP:
"... | es-ude/denspp.offline | denspp/offline/analog/amplifier/pre_amp.py | .py | b75e238b4f7c51e8 | 7.42 | 6 |
from copy import deepcopy
import numpy as np
from fxpmath import Config, Fxp
class CommonAnalogFunctions:
_range: list = [5.0, 5.0]
def define_voltage_range(self, volt_hgh: float, volt_low: float) -> list:
"""Defining the voltage range values"""
self._range = [volt_low, volt_hgh]
ret... | es-ude/denspp.offline | denspp/offline/analog/common_func.py | .py | 46275a44139bc28c | 7.42 | 6 |
import numpy as np
from .dev_handler import ElectricalLoadHandler, SettingsDevice
DefaultSettingsDEV = SettingsDevice(
type="R",
fs_ana=50e3,
noise_en=False,
params_use={"r": 100e3},
temp=300,
use_poly=False,
)
class ElectricalLoad(ElectricalLoadHandler):
def __init__(self, settings_dev:... | es-ude/denspp.offline | denspp/offline/analog/dev_load.py | .py | c837f6d5a1f7ab25 | 7.42 | 6 |
from fractions import Fraction
import numpy as np
from scipy.integrate import cumulative_trapezoid
from denspp.offline import check_keylist_elements_all
def do_quantize_transient(transient_orig: dict, fs_new: float, u_lsb: float, i_gain: float = 2e3) -> dict:
"""Performing a re-quantization of the transient inp... | es-ude/denspp.offline | denspp/offline/analog/func.py | .py | e14aed8d4031891f | 7.42 | 6 |
import numpy as np
from denspp.offline.analog import ProcessNoise, SettingsNoise
from denspp.offline.metric import calculate_snr
def augmentation_mean_waveform(
frames_mean: np.ndarray,
frames_cl: np.ndarray,
snr_in: np.ndarray,
num_min_frames: int,
fs: float = 20e3,
) -> dict:
"""Tool for da... | es-ude/denspp.offline | denspp/offline/data_augmentation/frame.py | .py | 75c1e2c9dc51ec94 | 7.42 | 6 |
from dataclasses import dataclass
import numpy as np
from denspp.offline import check_elem_unique, check_key_elements
@dataclass
class SettingsCellSelector:
"""Class for Merging different labels of a dataset to a new dataset
Attributes:
original_id: Dictionary with original label names [k... | es-ude/denspp.offline | denspp/offline/data_call/call_cellbib.py | .py | cb40f7612cece884 | 7.42 | 6 |
from typing import Any
import h5py
import numpy as np
class LabelCollector:
_labels: dict[str, int]
def __init__(self) -> None:
"""Class for collecting labels of a dataset and building a dictionary with names."""
self._labels = {}
@property
def _is_empty(self) -> bool:
retur... | es-ude/denspp.offline | denspp/offline/data_call/h5_dataset.py | .py | 53649581b9fc5ea7 | 7.42 | 6 |
#!/usr/bin/env python3
# Copyright 2025 KU Leuven.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# Fanchen Kong <fanchen.kong@kuleuven.be>
"""Render the boot ROM linker script from its mako template.
The boot ROM hands control to the snitches by rea... | KULeuven-MICAS/HeMAiA | target/rtl/bootrom/shared/gen_bootrom_ld.py | .py | a4ebf0231437e45c | 7.45 | 7 |
#!/usr/bin/env python3
# Copyright 2025 KU Leuven.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# Fanchen Kong <fanchen.kong@kuleuven.be>
#
# Gather the VersaCore GEMM cycle measurements into a CSV, ONE ROW PER RUNNABLE KERNEL.
#
# A GEMM kernel id i... | KULeuven-MICAS/HeMAiA | target/sim/automation/sweep/gemm/gather_gemm_luts.py | .py | 622052bc7cda7f35 | 7.45 | 7 |
"""fsspeckit-backed adapter for managed Parquet loading with filtering.
This module provides a thin, pydala-owned adapter that sits on top of the
public fsspeckit PyArrow and DuckDB dataset I/O classes. It exists because
fsspeckit 0.22.0's public ``PyarrowDatasetIO`` ships a broken string-filter
normalization path (i... | legout/pydala2 | pydala/adapters/fsspeckit.py | .py | aae8842724dee99a | 7.95 | 7 |
import threading
from datetime import datetime, timedelta
from functools import wraps
from pathlib import Path
from typing import Any, cast
import psutil
from fsspec.implementations.dirfs import DirFileSystem
from fsspeckit import AbstractFileSystem, filesystem
def get_credentials_from_fsspec(
fs: AbstractFileSy... | legout/pydala2 | pydala/filesystem.py | .py | 45f8b8315e9e89dd | 7.45 | 7 |
"""Helpers for conservative pruning from Parquet row-group metadata."""
from __future__ import annotations
import duckdb as _duckdb
import re
from typing import Any
_IDENTIFIER_RE = re.compile(r"\b[A-Za-z_][A-Za-z0-9_]*\b")
_ATOM_RE = re.compile(
r"^\s*(?P<column>[A-Za-z_][A-Za-z0-9_]*)\s*"
r"(?P<operator>>... | legout/pydala2 | pydala/helpers/metadata.py | .py | 995d11805b8da533 | 7.45 | 7 |
"""Dataset-level schema repair contract tests (issue #36).
These tests cover the dataset-facing repair workflow:
* ``ParquetDataset.repair_schema(dry_run=True)`` plans from a fresh raw
physical snapshot without mutating files or sidecars.
* ``ParquetDataset.repair_schema()`` rewrites physical files to the canonical... | legout/pydala2 | tests/test_schema_repair_dataset.py | .py | 346d71757aa9cd3d | 7.95 | 7 |
"""
Security tests for PyDala2
"""
import pytest
import tempfile
import os
from pydala.helpers.security import (
escape_sql_identifier,
escape_sql_literal,
validate_partition_name,
validate_partition_value,
sanitize_filter_expression,
validate_path,
safe_join,
sanitize_filename,
)
clas... | legout/pydala2 | tests/test_security.py | .py | a070d849b784eba6 | 7.95 | 7 |
"""Characterization contract tests for the SQL helper seam.
These tests pin the current behavior of ``pydala.helpers.sql`` so that a
future port of these helpers (e.g. into ``fsspeckit``) can be validated
behavior-for-behavior. They are the acceptance criteria for issue #4 and
must not import from any future location ... | legout/pydala2 | tests/test_sql_contract.py | .py | 74fa295d8dbfaaca | 7.95 | 7 |
'''
This module creates consumption tables
'''
import numpy as np
import pandas as pd
from box import Box
from ETS_CookBook import ETS_CookBook as cook
try:
import run_time # type: ignore
# We need to ignore the type because mypy has its own search path for
# imports and does not resolve im... | TNO/ChaProEV | src/ChaProEV/consumption.py | .py | 5302ec734981f5a4 | 7.64 | 18 |
import os
import pandas as pd
import tomli_w
from box import Box
from ETS_CookBook import ETS_CookBook as cook
# @cook.function_timer
def make_variants(case_name: str, csv_version: bool = True) -> None:
if csv_version:
make_csv_variants(case_name)
else:
make_toml_variants(case_na... | TNO/ChaProEV | src/ChaProEV/make_variants.py | .py | e87eb578674f2748 | 7.64 | 18 |
'''
Author: Omar Usmani (Oar.Usmani@TNO.nl)
This module defines time structures.
It contains the following functions:
1. **get_time_range:** This function returns the time range of the run, and the
associated hour numbers, based on values found in the
scenario file.
2. **get_time_stamped_dataframe:** T... | TNO/ChaProEV | src/ChaProEV/run_time.py | .py | baad2dd335f66f5c | 7.64 | 18 |
'''
Author: Omar Usmani (Omar.Usmani@TNO.nl)
This contains functions related to writting outputs.
It contains the following functions:
1. **write_scenario_parameters:** This function writes the scenario parameters
to the output files (either as separate files, or as tables/sheets
in groupfiles.)
'''
i... | TNO/ChaProEV | src/ChaProEV/writing.py | .py | bf27109e9f623e02 | 7.64 | 18 |
#!/usr/bin/env python3
"""Discover Molecule scenarios and generate Molecule coverage information."""
from __future__ import annotations
import argparse
import json
import os
import pathlib
import subprocess
COVERAGE_START = "<!-- molecule-coverage:start -->"
COVERAGE_END = "<!-- molecule-coverage:end -->"
def disc... | amedee/ansible-servers | .github/scripts/molecule_coverage.py | .py | af9bc080e7334cec | 7.42 | 6 |
#!/usr/bin/env python3
"""Base module for Munin plugins that gather mailbox stats using `doveadm`."""
from __future__ import annotations # pylint: disable=E0611
import json
import os
import re
import subprocess # nosec: Bandit_B404
import sys
import time
from collections import defaultdict
from pathlib import Path
... | amedee/ansible-servers | roles/munin_node/files/mailbox_base.py | .py | 61cb18402fbdf9de | 7.42 | 6 |
#!/usr/bin/env python3
"""
SES sendmail wrapper.
Reads a raw email from stdin and submits it to Amazon SES using the
`send_raw_email` API call. Designed to be called by Postfix as a transport.
Logs to syslog and exits with a non-zero code on failure.
"""
import logging
import logging.handlers
import os
import sys
fro... | amedee/ansible-servers | roles/postfix_ses/files/ses_sendmail.py | .py | b50b7d5ee2466200 | 7.42 | 6 |
from dataclasses import dataclass, field
from enum import Enum
class RobotMode(Enum):
"""Enum of possible robot modes for jogging, `FSM` does not support jogging."""
JOINT = "joint"
CARTBASE = "cartbase"
CARTTOOL = "carttool"
PLATFORM = "platform"
FSM = "fsm"
class KinematicsState(Enum):
... | CommonplaceRobotics/CRI-Python-Lib | cri_lib/robot_state.py | .py | c2efd86c5e9f9b5d | 7.52 | 10 |
import json
import sys
from pathlib import Path
import requests
import yaml
def load_referenced_decks():
"""Collect every (set, deck_name) already referenced by a `deck` entry in
any data/contents/*.yaml.
This is a live scan of the source files. It replaces an earlier check against
outputs/deck_map.j... | mtgjson/mtg-sealed-content | scripts/import_new_decks.py | .py | f0d33cfa2f0e26c0 | 7.54 | 11 |
import re
import sys
import time
from typing import Any, Dict, List, Optional, Union
import ratelimit
import requests.exceptions
from retryable_session import retryable_session
class ScryfallProvider:
ALL_SETS_URL: str = "https://api.scryfall.com/sets/"
CARDS_URL_ALL_DETAIL_BY_SET_CODE: str = "https://api.s... | mtgjson/mtg-sealed-content | scripts/scryfall_provider.py | .py | de90f97a46c3f181 | 7.54 | 11 |
from typing import List, Any, Dict
import re
class TcgplayerTokenParser:
__emblem_regex: re.Pattern
__double_sided_token_regex: re.Pattern
__treatment_single_side_regex: re.Pattern
__treatment_double_side_regex: re.Pattern
__role_regex: re.Pattern
def __init__(self) -> None:
"""
... | mtgjson/mtg-sealed-content | scripts/tokens/tcgplayer_token_parser.py | .py | be89cabb7f0f27c3 | 7.54 | 11 |
import dataclasses
import datetime
import operator
import pickle
import uuid
from threading import Lock
from typing import Union
from scim2_filter_parser import lexer
from scim2_filter_parser.parser import SCIMParser
from scim2_models import Attribute
from scim2_models import BaseModel
from scim2_models import CaseExa... | python-scim/scim2-server | scim2_server/backend.py | .py | 9f0e9a6fa03ee7d4 | 7.59 | 14 |
import datetime
import importlib.resources
import json
import re
import sys
from typing import Any
from pydantic import EmailStr
from pydantic import ValidationError
from scim2_models import BaseModel
from scim2_models import Extension
from scim2_models import InvalidValueException
from scim2_models import Mutability
... | python-scim/scim2-server | scim2_server/utils.py | .py | 77a9ee9213c27489 | 7.59 | 14 |
import datetime
class TestSCIMProviderOktaIntegration:
"""Test based on Runscope Spec Test JSON from Okta docs.
https://developer.okta.com/docs/guides/scim-provisioning-integration-prepare/main/#test-your-scim-api
"""
OKTA_HEADERS = {
"Accept-Charset": "utf-8",
"Content-Type": "appli... | python-scim/scim2-server | tests/integration/test_okta.py | .py | b41f1a7790960745 | 7.09 | 14 |
from unittest.mock import patch
from scim2_models import Context
class TestProvider:
def test_user_creation(self, provider):
user_model = provider.backend.get_model("User").model_validate(
{
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
"userName":... | python-scim/scim2-server | tests/test_provider.py | .py | 16ea7a44f0f3a3a4 | 8.09 | 14 |
'''
pip install git+https://github.com/catalyst-team/catalyst@master --upgrade
cd /www/server/mdserver-web && python3 plugins/cryptocurrency_trade/ccxt/test/p1.py
cd /Users/midoks/Desktop/mwdev/server/mdserver-web && source bin/activate
python3 plugins/cryptocurrency_trade/ccxt/test/p1.py
'''
from datetime impor... | find-xposed-magisk/mdserver-web | plugins/cryptocurrency_trade/ccxt/test/p1.py | .py | 435903140e65b6e4 | 7.95 | 7 |
'''
pip install git+https://github.com/catalyst-team/catalyst@master --upgrade
cd /www/server/mdserver-web && python3 plugins/cryptocurrency_trade/ccxt/test/p1.py
cd /Users/midoks/Desktop/mwdev/server/mdserver-web && source bin/activate
python3 plugins/cryptocurrency_trade/ccxt/test/p1.py
'''
from datetime impor... | find-xposed-magisk/mdserver-web | plugins/cryptocurrency_trade/ccxt/test/p2.py | .py | b5850b94d260bfd9 | 7.95 | 7 |
import os
from pathlib import Path
import yaml
import git
# Paths
SPELLS_REPO_PATH = "datavzrd-spells"
OUTPUT_FILE = "src/docs/spells.rst"
repo = git.Repo("datavzrd-spells")
# get latest tag
TAG = repo.tags[-1]
# Header content to be added at the top of spells.rst
HEADER_CONTENT = """
******
Spells
******
Spells pro... | datavzrd/datavzrd.github.io | scripts/generate_docs.py | .py | 956c976b2fb615e0 | 7.5 | 9 |
import json
import base64
import os
import time
print("speedtest output running... ")
out_json = './output.json'
sub_all_base64 = "./sub/sub_merge_base64.txt"
sub_all = "./sub/sub_merge.txt"
Eternity_file_base64 = "./Eternity"
Eternity_file = "./Eternity.txt"
Eternity_Base = "./EternityBase"
def read_json(file): # ... | Airuop/cross | utils/speedtest/output.py | .py | d46ea673f50edc71 | 7.15 | 19 |
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "httpx",
# "statistics",
# "tqdm",
# ]
# ///
import httpx
import statistics
from tqdm import tqdm
import json
def fetch_models():
"""Fetch all models and extract endpoint info."""
response = httpx.get("https://op... | sanand0/llmpricing | billing.py | .py | 648f90dc5a201d53 | 7.62 | 16 |
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "playwright>=1.56.0",
# "typer>=0.16.1",
# ]
# ///
from __future__ import annotations
import json
import sys
from pathlib import Path
from typing import Annotated
from playwright.sync_api import TimeoutError as Playwr... | sanand0/llmpricing | download.py | .py | aa2b8aa9c2be1562 | 7.62 | 16 |
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "playwright>=1.56.0",
# "typer>=0.16.1",
# ]
# ///
from __future__ import annotations
import json
import os
import re
import shutil
import sys
from pathlib import Path
from typing import Annotated
import typer
from pl... | sanand0/llmpricing | screenshot.py | .py | 0a6e8cc8c5b89d81 | 7.62 | 16 |
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "httpx>=0.28.1",
# "typer>=0.16.1",
# ]
# ///
from __future__ import annotations
import csv
import re
from collections import defaultdict, deque
from dataclasses import dataclass, field
from datetime import UTC, dateti... | sanand0/llmpricing | update_elo.py | .py | eceff16b26f45eee | 7.62 | 16 |
import json
from hashlib import md5
from pathlib import Path
from typing import Any, Callable, Generator, no_type_check
class Cache:
"""
Decorator class that adds caching functionality to a function.
"""
def __init__(self, length: int, cache_path: Path) -> None:
"""
Initialize the Cac... | find-xposed-magisk/shell-gpt | sgpt/cache.py | .py | 28d705a63a1de5b9 | 7.64 | 18 |
import json
from pathlib import Path
from typing import Any, Callable, Dict, Generator, List, Optional
import typer
from click import BadParameter, UsageError
from rich.console import Console
from rich.markdown import Markdown
from ..config import cfg
from ..role import DefaultRoles, SystemRole
from ..utils import op... | find-xposed-magisk/shell-gpt | sgpt/handlers/chat_handler.py | .py | 0c8a5d4cee2edc63 | 7.64 | 18 |
import subprocess
from typing import Any, Dict
from pydantic import BaseModel, Field
class Function(BaseModel):
"""
Executes a shell command and returns the output (result).
"""
shell_command: str = Field(
...,
example="ls -la",
description="Shell command to execute.",
) ... | find-xposed-magisk/shell-gpt | sgpt/llm_functions/common/execute_shell.py | .py | 2c7758de39c6b928 | 7.64 | 18 |
import subprocess
from typing import Any, Dict
from pydantic import BaseModel, Field
class Function(BaseModel):
"""
Executes Apple Script on macOS and returns the output (result).
Can be used for actions like: draft (prepare) an email, show calendar events, create a note.
"""
apple_script: str =... | find-xposed-magisk/shell-gpt | sgpt/llm_functions/mac/apple_script.py | .py | 11649c61a3e718af | 7.64 | 18 |
import os
import platform
import shlex
from tempfile import NamedTemporaryFile
from typing import Any, Callable
import typer
from click import BadParameter, UsageError
from sgpt.__version__ import __version__
from sgpt.integration import bash_integration, zsh_integration
def get_edited_prompt() -> str:
"""
... | find-xposed-magisk/shell-gpt | sgpt/utils.py | .py | 732d3055929e291d | 7.64 | 18 |
"""
This test module will execute real commands using shell.
This means it will call sgpt.py with command line arguments.
Make sure you have your API key in place ~/.cfg/shell_gpt/.sgptrc
or ENV variable OPENAI_API_KEY.
It is useful for quick tests, saves a bit time.
"""
import json
import os
import subprocess
from pa... | find-xposed-magisk/shell-gpt | tests/_integration.py | .py | decb723889d4772c | 7.14 | 18 |
"""
Test-specific Django settings for integration tests with local database.
"""
import os
from kernelCI.settings import * # noqa: F403, F401
# Override database configuration for tests
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": os.environ.get("DB_NAME", "kcidb... | kernelci/dashboard | backend/kernelCI/test_settings.py | .py | e9265b2d64ebd8bd | 8 | 9 |
def dict_fetchall(cursor) -> list[dict]:
"""
Return all rows from a cursor as a dict.
Assume the column names are unique.
This has a performance cost so avoid using it in large unprocessed data.
"""
columns = [col[0] for col in cursor.description]
return [dict(zip(columns, row, strict=False)... | kernelci/dashboard | backend/kernelCI_app/helpers/database.py | .py | 4d5b7edbcd6ff2fb | 7.5 | 9 |
from email.utils import make_msgid
from django.core.mail import EmailMessage, get_connection
def smtp_setup_connection():
"""Setup Django SMTP email backend connection."""
# Django will handle SMTP connection using settings from settings.py
# No explicit setup needed, connection is created per send opera... | kernelci/dashboard | backend/kernelCI_app/helpers/email.py | .py | fe573ce5a5bdea41 | 7.5 | 9 |
from collections import defaultdict
from typing import List, Optional, Tuple
from kernelCI_app.constants.general import UNCATEGORIZED_STRING
from kernelCI_app.helpers.logger import log_message
from kernelCI_app.queries.issues import (
get_issue_first_good_checkouts,
get_issue_first_seen_data,
get_issue_las... | kernelci/dashboard | backend/kernelCI_app/helpers/issueExtras.py | .py | a292554d07578107 | 7.5 | 9 |
import logging
import time
from django.http import HttpRequest
from kernelCI_app.constants.general import PRODUCTION_HOST, STAGING_HOST
from kernelCI_app.helpers.system import get_running_instance
logger = logging.getLogger(__name__)
# For logging that we care about, we create a function so we can easily use
# a m... | kernelci/dashboard | backend/kernelCI_app/helpers/logger.py | .py | 98409d892b989b23 | 7.5 | 9 |
from typing import Optional, TypedDict, Union
from kernelCI_app.helpers.filters import UNKNOWN_STRING
from kernelCI_app.utils import sanitize_dict
class Misc(TypedDict, total=False):
platform: str
lab: Optional[str]
def handle_misc(misc: Union[str, dict, None]) -> Optional[dict]:
"""
Handle misc da... | kernelci/dashboard | backend/kernelCI_app/helpers/misc.py | .py | 658279db92f3671d | 7.5 | 9 |
import json
import os
import typing_extensions
import yaml
from django.conf import settings
from kernelCI_app.constants.tree_names import TREE_NAMES_FILENAME
from kernelCI_app.helpers.logger import log_message
from kernelCI_app.typeModels.common import StatusCount
from kernelCI_app.typeModels.treeListing import Check... | kernelci/dashboard | backend/kernelCI_app/helpers/trees.py | .py | 5e0471abff81e6d2 | 7.5 | 9 |
import time
from typing import Optional, Sequence
from django.db import connections
from kernelCI_app.helpers.logger import out
from kernelCI_app.management.commands.helpers.tree_listing import (
CheckoutRow,
tree_listing_sort_key,
)
from kernelCI_app.models import (
Builds,
Checkouts,
PendingBuil... | kernelci/dashboard | backend/kernelCI_app/management/commands/helpers/aggregation_helpers.py | .py | d35dec2c6f9d9865 | 7.5 | 9 |
from __future__ import annotations
from enum import Enum
from typing import Type, TypeGuard
ALIAS_MAP = {
"u8": "UINT8",
"u16": "UINT16",
"u32": "UINT32",
"i8": "INT8",
"i16": "INT16",
"i32": "INT32",
"f32": "FLOAT32",
"str": "STRING",
"bool": "BOOL",
"byte": "BYTES",
}
def i... | AbdyyEee/PylibMS | lms/common/field/lms_datatype.py | .py | 705a2b15a1359ace | 7.52 | 10 |
from __future__ import annotations
from collections.abc import Iterator
from dataclasses import dataclass
from lms.common.field.lms_datatype import LMS_DataType
from lms.titleconfig.definitions.value import ValueDefinition
FLOAT32_MIN = -3.4028235e38
FLOAT32_MAX = 3.4028235e38
type FieldValue = int | str | float | ... | AbdyyEee/PylibMS | lms/common/field/lms_field.py | .py | 069507a8a4f523c1 | 7.52 | 10 |
from lms.fileio.io import FileReader, FileWriter
def read_labels(reader: FileReader) -> tuple[dict, int]:
labels = {}
data_start = reader.tell()
slot_count = reader.read_uint32()
for _ in range(slot_count):
label_count = reader.read_uint32()
offset = reader.read_uint32()
next_... | AbdyyEee/PylibMS | lms/common/stream/hashtable.py | .py | 411d3b98e9ec9a6b | 7.52 | 10 |
from enum import IntEnum
from typing import Literal
class FileEncoding(IntEnum):
"""An enum that represents a file encoding."""
UTF8 = 0x00
UTF16 = 0x01
UTF32 = 0x02
def to_string_format(
self, is_big_endian: bool = False
) -> Literal["UTF-8", "UTF-16-BE", "UTF-16-LE", "UTF-32-BE... | AbdyyEee/PylibMS | lms/fileio/encoding.py | .py | 99a1840271612e5f | 7.52 | 10 |
from types import MappingProxyType
from typing import Callable
from lms.flowchart.definitions.node import LMS_EntryNode, LMS_BranchNode, LMS_BaseNode
class LMS_Flowchart:
"""Class that represents a flowchart in a MSBF file."""
def __init__(self, entry_point: LMS_EntryNode, id_generator: Callable[[], int]) -... | AbdyyEee/PylibMS | lms/flowchart/definitions/flowchart.py | .py | a463dccfe400e6c3 | 7.52 | 10 |
from typing import Type
from enum import IntEnum
from lms.common.lms_exceptions import LMS_Error
PARAMETER_ALIASES = {
"p32_0": "PARAM_32_0",
"p16_16": "PARAM_16_16",
"p16_8_8": "PARAM_16_8_8",
"p8_8_16": "PARAM_8_8_16",
"p8_8_8_8": "PARAM_8_8_8_8",
"str": "STRING",
"p32_1": "PARAM_32_1",
... | AbdyyEee/PylibMS | lms/flowchart/definitions/node_type.py | .py | c7ec80adc04c0d4c | 7.52 | 10 |
from types import MappingProxyType
from lms.common.lms_fileinfo import LMS_FileInfo
from lms.flowchart.definitions.flowchart import LMS_Flowchart
from lms.flowchart.definitions.node import LMS_EntryNode
class MSBF:
"""
Class that represents a MSBF instance.
======
Usages
======
https://githu... | AbdyyEee/PylibMS | lms/flowchart/msbf.py | .py | b2d0cc12db872fe4 | 7.52 | 10 |
from lms.common.lms_fileinfo import LMS_FileInfo
from lms.fileio.encoding import FileEncoding
from lms.message.msbtentry import MSBTEntry
from lms.titleconfig.definitions.attribute import AttributeConfig
from lms.titleconfig.definitions.tags import TagConfig
class MSBT:
"""
A class that represents a MSBT file... | AbdyyEee/PylibMS | lms/message/msbt.py | .py | 725807341576556f | 7.52 | 10 |
from lms.common.field.lms_field import LMS_FieldMap
from lms.message.lms_messagetext import LMS_MessageText
from lms.titleconfig.definitions.attribute import AttributeConfig
from lms.titleconfig.definitions.tags import TagConfig
class MSBTEntry:
"""A class that represents an entry in a MSBT file."""
def __in... | AbdyyEee/PylibMS | lms/message/msbtentry.py | .py | f88993a7d45e2625 | 7.52 | 10 |
from lms.common.lms_fileinfo import LMS_FileInfo
from lms.project.definitions.attribute import LMS_AttributeDefinition
from lms.project.definitions.color import LMS_Color
from lms.project.definitions.style import LMS_Style
from lms.project.definitions.tag import LMS_TagGroup
class MSBP:
"""
A class that repre... | AbdyyEee/PylibMS | lms/project/msbp.py | .py | 1c4b4f003e082b7b | 7.52 | 10 |
"""Test artifacts subcommand."""
from __future__ import annotations
from vlmrun.cli.cli import app
def test_get_artifact_by_session_id(runner, mock_client, config_file):
"""Test getting an artifact with --session-id."""
result = runner.invoke(
app,
[
"artifacts",
"get... | vlm-run/vlmrun-python-sdk | tests/cli/test_cli_artifacts.py | .py | b36532b74e18c933 | 7.1 | 15 |
"""Test chat subcommand."""
import json
import os
from unittest.mock import MagicMock, patch
from datetime import datetime
import pytest
from typer.testing import CliRunner
from vlmrun.cli.cli import app
from vlmrun.cli._cli.chat import (
resolve_prompt,
build_messages,
extract_artifact_refs,
AVAILAB... | vlm-run/vlmrun-python-sdk | tests/cli/test_cli_chat.py | .py | 07faf2a26ebaea99 | 8.1 | 15 |
"""Test config subcommand."""
import pytest
from unittest.mock import patch
from vlmrun.cli.cli import app
from tests.conftest import strip_ansi
@pytest.fixture(autouse=True)
def mock_health_check():
"""Mock the health check request in VLMRun client initialization."""
with patch("vlmrun.client.client.APIRequ... | vlm-run/vlmrun-python-sdk | tests/cli/test_cli_config.py | .py | 0ffec0b9a97e0ebf | 8.1 | 15 |
"""Test files subcommand."""
from vlmrun.cli.cli import app
def test_list_files(runner, mock_client, config_file):
"""Test list files command."""
result = runner.invoke(app, ["files", "list"])
assert result.exit_code == 0
assert "file1" in result.stdout
assert "test.txt" in result.stdout
def te... | vlm-run/vlmrun-python-sdk | tests/cli/test_cli_files.py | .py | 467d95a5388314b3 | 8.1 | 15 |
"""Test fine-tuning subcommand."""
import pytest
from vlmrun.cli.cli import app
pytestmark = pytest.mark.skip(reason="Not implemented")
def test_create_finetune(runner, mock_client):
"""Test create fine-tuning command."""
result = runner.invoke(app, ["fine-tuning", "create", "file1", "test-model"])
asse... | vlm-run/vlmrun-python-sdk | tests/cli/test_cli_fine_tuning.py | .py | 374ac7c27fec79a5 | 7.1 | 15 |
"""Test generate subcommand."""
from pathlib import Path
from vlmrun.cli.cli import app
from vlmrun.common.utils import download_artifact
def test_generate_image(runner, mock_client, config_file, tmp_path):
"""Test generate command with an image file."""
path: Path = download_artifact(
"https://stor... | vlm-run/vlmrun-python-sdk | tests/cli/test_cli_generate.py | .py | eaf82ad3237a25f7 | 7.1 | 15 |
"""Test hub subcommand."""
from vlmrun.cli.cli import app
from tests.conftest import strip_ansi
def test_hub_version(runner, mock_client, config_file):
"""Test hub version command."""
result = runner.invoke(app, ["hub", "version"])
assert result.exit_code == 0
out = strip_ansi(result.stdout)
asse... | vlm-run/vlmrun-python-sdk | tests/cli/test_cli_hub.py | .py | 2d76524884f6cbe4 | 8.1 | 15 |
"""Test models subcommand."""
from vlmrun.cli.cli import app
from tests.conftest import strip_ansi
def test_list_models(runner, mock_client, config_file):
"""Test list models command."""
result = runner.invoke(app, ["models", "list"])
assert result.exit_code == 0
out = strip_ansi(result.stdout)
a... | vlm-run/vlmrun-python-sdk | tests/cli/test_cli_models.py | .py | 96b0a860aeb70e7a | 7.1 | 15 |
"""Test predictions subcommand."""
from vlmrun.cli.cli import app
from tests.conftest import strip_ansi
def test_list_predictions(runner, mock_client, config_file):
"""Test list predictions command."""
result = runner.invoke(app, ["predictions", "list"])
assert result.exit_code == 0
out = strip_ansi(... | vlm-run/vlmrun-python-sdk | tests/cli/test_cli_predictions.py | .py | bc726dd654844d84 | 7.1 | 15 |
"""Tests for verifying optional dependency handling."""
from __future__ import annotations
import builtins
import sys
import pytest
from vlmrun.client.exceptions import DependencyError
from vlmrun.common import dependencies
def _block_import(monkeypatch, module_name: str) -> None:
for key in list(sys.modules)... | vlm-run/vlmrun-python-sdk | tests/common/test_dependencies.py | .py | fecc7ff03c92df03 | 8.1 | 15 |
"""Tests for image utilities."""
import base64
from io import BytesIO
from pathlib import Path
from typing import Union
import pytest
import requests
from PIL import Image
from vlmrun.common.image import encode_image
from vlmrun.common.utils import download_image
def _validate_base64_image(data: Union[str, bytes],... | vlm-run/vlmrun-python-sdk | tests/common/test_image.py | .py | a48e84c5d4eac31f | 8.1 | 15 |
import requests
import pytest
from PIL import Image
from vlmrun.common.pdf import pdf_images
from loguru import logger
# URL of the PDF to be tested
PDF_URL = "https://storage.googleapis.com/vlm-data-public-prod/hub/examples/document.bank-statement/lending_bankstatement.pdf"
@pytest.fixture
def pdf_file(tmp_path):
... | vlm-run/vlmrun-python-sdk | tests/common/test_pdf.py | .py | 2334d65f3ec9f6b0 | 8.1 | 15 |
from pathlib import Path
from vlmrun.common.utils import download_artifact, create_archive
PDF_URL = "https://storage.googleapis.com/vlm-data-public-prod/hub/examples/document.bank-statement/lending_bankstatement.pdf"
def test_download_artifact():
"""Test that download_artifact can download a PDF."""
pdf = ... | vlm-run/vlmrun-python-sdk | tests/common/test_utils.py | .py | 88823ae6f6b7744f | 8.1 | 15 |
"""Tests for video utilities."""
from pathlib import Path
import numpy as np
import pytest
from vlmrun.common.video import VideoReader, VideoWriter
# Constants for real test video properties
REAL_VIDEO_WIDTH = 294
REAL_VIDEO_HEIGHT = 240
REAL_VIDEO_FRAMES = 168
REAL_VIDEO_FPS = 25
@pytest.fixture
def sample_video... | vlm-run/vlmrun-python-sdk | tests/common/test_video.py | .py | 8187af478df6081a | 8.1 | 15 |
import pytest
from PIL import Image
from vlmrun.common.viz import (
DisplayOptions,
xywh_to_xyxy,
extract_bbox,
get_boxes_from_response,
ensure_image,
render_bbox_image,
render_image,
get_nested_value,
filter_response_data,
format_json_html,
show_results,
)
from typing import... | vlm-run/vlmrun-python-sdk | tests/common/test_viz.py | .py | 76d482ba76f087f6 | 8.1 | 15 |
"""Tests for artifacts operations."""
import pytest
from vlmrun.client.types import ArtifactListResponse
def test_get_artifact(mock_client):
"""Test getting an artifact by session_id and object_id."""
response = mock_client.artifacts.get(
object_id="test-object-456",
session_id="550e8400-e29... | vlm-run/vlmrun-python-sdk | tests/test_artifacts.py | .py | 52749804b4606e64 | 8.1 | 15 |
import os
import requests
import pytest
from functools import lru_cache
from unittest.mock import patch
from vlmrun.client import VLMRun
from vlmrun.client.exceptions import ConfigurationError, AuthenticationError
def test_client_with_api_key(monkeypatch):
"""Test client initialization with API key provided in co... | vlm-run/vlmrun-python-sdk | tests/test_client.py | .py | b4a60064d63f8bc6 | 7.1 | 15 |
"""Tests for dataset operations."""
import pytest
from datetime import datetime
from vlmrun.client.types import DatasetResponse
def test_dataset_create(mock_client):
"""Test dataset creation."""
response = mock_client.dataset.create(
file_id="file1",
domain="test-domain",
dataset_name... | vlm-run/vlmrun-python-sdk | tests/test_dataset.py | .py | 0d574425a821f683 | 8.1 | 15 |
"""Tests for the exceptions module."""
import pytest
from tenacity import RetryError
from vlmrun.client.exceptions import (
VLMRunError,
APIError,
AuthenticationError,
ValidationError,
RateLimitError,
ServerError,
ResourceNotFoundError,
ClientError,
ConfigurationError,
Dependen... | vlm-run/vlmrun-python-sdk | tests/test_exceptions.py | .py | 8c3f7af17382a3a6 | 8.1 | 15 |
"""Tests for feedback operations."""
from pydantic import BaseModel
from vlmrun.client.types import FeedbackListResponse, FeedbackSubmitResponse
class TestLabel(BaseModel):
"""Test label model."""
score: int
comment: str
def test_submit_feedback(mock_client):
"""Test submitting feedback for a pred... | vlm-run/vlmrun-python-sdk | tests/test_feedback.py | .py | f3d86b60c81c4947 | 8.1 | 15 |
"""Tests for files operations."""
from vlmrun.client.types import FileResponse, PresignedUrlRequest, PresignedUrlResponse
def test_list_files(mock_client):
"""Test listing files."""
response = mock_client.files.list()
assert isinstance(response, list)
assert all(isinstance(file, FileResponse) for fil... | vlm-run/vlmrun-python-sdk | tests/test_files.py | .py | a1a8476d3220222a | 8.1 | 15 |
"""Tests for hub operations."""
from vlmrun.client.types import (
HubInfoResponse,
HubSchemaResponse,
HubDomainInfo,
)
def test_hub_info(mock_client):
"""Test hub info retrieval."""
client = mock_client
response = client.hub.info()
assert isinstance(response, HubInfoResponse)
assert i... | vlm-run/vlmrun-python-sdk | tests/test_hub.py | .py | 48dcbf2f0f75743f | 8.1 | 15 |
"""Tests for models operations."""
from vlmrun.client.types import ModelInfo
def test_list_models(mock_client):
"""Test listing available models."""
response = mock_client.models.list()
assert isinstance(response, list)
assert all(isinstance(model, ModelInfo) for model in response)
assert len(res... | vlm-run/vlmrun-python-sdk | tests/test_models.py | .py | 6fda267cd48789e9 | 7.1 | 15 |
"""Tests for predictions operations."""
import pytest
from pydantic import BaseModel
from PIL import Image
from loguru import logger
from vlmrun.client.types import (
PredictionResponse,
GenerationConfig,
SchemaResponse,
CreditUsage,
MarkdownDocument,
)
class MockInvoiceSchema(BaseModel):
"""... | vlm-run/vlmrun-python-sdk | tests/test_predictions.py | .py | f231aabaca6883c1 | 7.1 | 15 |
"""Tests for vlmrun.types module."""
import uuid
import pytest
from pydantic import ValidationError
from vlmrun.types import (
ImageUrl,
FileUrl,
VideoUrl,
AudioUrl,
DocumentUrl,
MessageContent,
)
class TestImageUrl:
"""Tests for ImageUrl model."""
def test_image_url_with_default_de... | vlm-run/vlmrun-python-sdk | tests/test_types.py | .py | 0460210ab288ffba | 8.1 | 15 |
from __future__ import annotations
from pathlib import Path
from typing import Optional
import sys
import typer
from rich import print as rprint
from rich.panel import Panel
from rich.text import Text
from pydantic import Field
from pydantic.dataclasses import dataclass
from dataclasses import asdict
if sys.version_i... | vlm-run/vlmrun-python-sdk | vlmrun/cli/_cli/config.py | .py | 4241be8e4840add4 | 7.6 | 15 |
"""Compressed directory archives used to bound extraction disk usage."""
import shutil
import subprocess
from pathlib import Path
class DirectoryArchiveError(Exception):
"""Raised when a directory cannot be compressed or restored."""
def compress_directory(directory: Path) -> Path:
"""Compress ``directory`... | getsentry/symx | symx/directory_archive.py | .py | 4aa5e6c87ca28511 | 7.48 | 8 |
"""HTTP file download with retry logic."""
import logging
import time as time_module
from collections.abc import Callable
from math import floor
from pathlib import Path
import requests
import sentry_sdk
import sentry_sdk.metrics
from symx.model import MiB
logger = logging.getLogger(__name__)
StatusCallback = Call... | getsentry/symx | symx/download.py | .py | a8a96fe37016777a | 7.48 | 8 |
"""Google Cloud Storage utilities: upload, download, hashing, and URI parsing."""
import base64
import hashlib
import logging
import os
from contextlib import contextmanager
from collections.abc import Generator
from concurrent.futures import ThreadPoolExecutor, as_completed
from pathlib import Path
from urllib.parse ... | getsentry/symx | symx/gcs.py | .py | 7c2ac810543cc47c | 7.48 | 8 |
"""Core domain types and constants shared across the symx package."""
import logging
import os
import time as time_module
from datetime import timedelta
from enum import StrEnum
logger = logging.getLogger(__name__)
HASH_BLOCK_SIZE = 2**16
MiB = 1024 * 1024
class Timeout:
"""Tracks elapsed time and checks whet... | getsentry/symx | symx/model.py | .py | e66bff0099d1d0a9 | 7.48 | 8 |
import datetime
import tempfile
from pathlib import Path
import sentry_sdk
import typer
from symx.tools import validate_shell_deps
from symx.ota.storage.gcs import init_storage
from symx.ota.extract import extract_symbols
from symx.ota.model import OtaExtractionRequest, OtaExtractionSkipped, OtaSymbolsExtracted
from ... | getsentry/symx | symx/ota/app/__init__.py | .py | 1cfd65554246c297 | 7.48 | 8 |
"""OTA meta-data parsing, retrieval from Apple, and merge logic."""
import json
import logging
import subprocess
from concurrent.futures import ThreadPoolExecutor
import sentry_sdk
import sentry_sdk.metrics
from pydantic import BaseModel, ConfigDict, Field, TypeAdapter
from symx.diagnostics import decode_subprocess_... | getsentry/symx | symx/ota/meta.py | .py | d85c0183c2834f71 | 7.48 | 8 |
"""Core OTA domain models, interfaces, and shared errors.
Persisted ``OtaArtifact`` data uses Pydantic validation; trusted runtime values
use dataclasses. The external ipsw schema and its adapter values live in
the ``ipsw_report`` and ``materialization`` submodules respectively.
"""
import logging
from collections.ab... | getsentry/symx | symx/ota/model/__init__.py | .py | 217c48fbb583643b | 7.48 | 8 |
"""Trusted runtime values for the OTA DSC materialization adapter.
Application code constructs requests from validated workflow state; the adapter
constructs sources and results after validating the external ``ipsw`` report.
These values are operation context, not persistence or wire schemas. Non-success
outcomes reta... | getsentry/symx | symx/ota/model/materialization.py | .py | a61e09c761d199ae | 7.48 | 8 |
#create composite function which can be called for convenience
#import cosmo_wap.lib.angular_integrate as angular_integrate
import numpy as np
import cosmo_wap.bk as bk
import cosmo_wap.bk_mt as bk_mt
#so we want create a general bispectrum function like COV.cov()
def bk_func(term,l,cosmo_funcs,k1,k2,k3=None,theta=N... | craddis1/CosmoWAP | src/cosmo_wap/bk/combined.py | .py | 75ed2f00ee8f46f7 | 7.59 | 14 |
"""Convert a generated cosmo_wap expression module into a CSE'd drop-in replacement.
The machine-generated term files (WA2.py, RR2.py, ...) are fully expanded sympy
expressions printed as single numpy megalines; evaluating them is dominated by numpy
ufunc-dispatch overhead (one call per arithmetic op). This script rew... | craddis1/CosmoWAP | src/cosmo_wap/bk/cse_convert.py | .py | efa6934b1598f3fb | 7.59 | 14 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.