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 |
|---|---|---|---|---|---|---|
# This time with Gemini 3
#
# Prompt for Pro:
#
# I have a few csv files with date values in float and explicit YYYY-MM-DD
# format and want to convert them. The files are listed in a files_to_convert.csv
# with 'file' given the file name and 'column' given the column in this file
# where the date is found. All resp... | kreier/timeline | db/YYYY-MM-DD_to_float_and_back/convert_float_yyyy.py | .py | 47c290e2096dcd12 | 7.5 | 9 |
# This time with Gemini 3
#
# Prompt for Pro:
#
# I have a few csv files with date values in float and explicit YYYY-MM-DD
# format and want to convert them. The files are listed in a files_to_convert.csv
# with 'file' given the file name and 'column' given the column in this file
# where the date is found. All resp... | kreier/timeline | db/YYYY-MM-DD_to_float_and_back/convert_float_yyyy_first.py | .py | 038e5027e5802a4e | 7.5 | 9 |
import pandas as pd
import os
import math
from datetime import datetime, timedelta
def is_leap(astron_year):
"""Sequence: ... -4, 0 (1 BCE), 4 ... are leaps in proleptic Gregorian."""
return (astron_year % 4 == 0 and astron_year % 100 != 0) or (astron_year % 400 == 0)
def float_to_date_str(val):
try:
... | kreier/timeline | db/YYYY-MM-DD_to_float_and_back/testsuite.py | .py | 4241062623f193dc | 8 | 9 |
# Create a google translated dictionary as starting point for a new language
# Updated to work with with https://pypi.org/project/googletrans/ 4.0.2 (latest version)
# Usage: python auto-translate.py [language_code]
# Update 2026: check the translation, expand if necessary
# dictionary_reference.csv has 'key', 'versio... | kreier/timeline | db/test/more_columns_in_dictionary/auto-translate.py | .py | d0a4fc5c9b31cf2e | 7 | 9 |
# Create a translated dictionary for a new language wit alibaba cloud machine translation
# pip install alibabacloud-alimt20181012 https://pypi.org/project/alibabacloud-alimt20181012/
# with 221 languages
import os, sys
import pandas as pd
from aliyunsdkcore.client import AcsClient
from aliyunsdkalimt.request.v2018101... | kreier/timeline | db/test/translate-alibaba.py | .py | 54dfcd1e05d35759 | 7 | 9 |
# Create a Azure translated dictionary as starting point for a new language
# You will need a (free) Azure account to access the API
import os, sys, requests, uuid, json
import pandas as pd
# subscription_key = 'e87e0ed07a914b4c9fe6f1d31c122104' # this was the 'free' service at hcmc for a year that ended after 1 mon... | kreier/timeline | db/test/translate-azure.py | .py | 500ddab1c7181020 | 7 | 9 |
# Create a google translated dictionary as starting point for a new language
# It works again in 2025 with https://pypi.org/project/googletrans/ 4.0.2 (latest version) and asyncio
import os, sys
import asyncio
import pandas as pd
from googletrans import Translator
def check_existing(language, filename):
# Check e... | kreier/timeline | db/test/translate-mini.py | .py | a3fe54d18fe9cc24 | 7 | 9 |
# Create a translated dictionary for a new language
# https://pypi.org/project/translators/ 5.9.5 with 452 languages at Nuitrans and 221 at Alibaba
import os, sys
import pandas as pd
import translators as ts
def check_existing(language, filename):
# Check execution location, exit if not in /timeline/db
if os.... | kreier/timeline | db/test/translators.py | .py | afec58ecfe629985 | 7 | 9 |
#
# Using the ReportLab toolkit from within Zope
#
# WARNING : The MyPDFDoc class deals with ReportLab's platypus framework,
# while the MyPageTemplate class directly deals with ReportLab's
# canvas, this way you know how to do with both...
#
# License : the ReportLab Toolkit's one
# see : http://www.... | kreier/timeline | python/demos/rlzope/rlzope.py | .py | 94c0edb7284edffd | 7.5 | 9 |
# pyright: reportPrivateUsage=false
# Some of these functions and type declarations
# rely on `ctypes` APIs that are technically private.
# However, their interfaces are documented and they're part of typeshed.
from __future__ import annotations
import ctypes
import mmap
import struct
import sys
from _ctypes import C... | JesseTG/libretro.py | src/libretro/api/_utils.py | .py | 5dd6c050546b426d | 7.65 | 19 |
"""
Interface and types for providing video input to a :class:`.Core`.
.. seealso::
:class:`.CameraDriver`
The protocol that uses these types to implement camera support in libretro.py.
:mod:`libretro.drivers.camera`
libretro.py's included :class:`.CameraDriver` implementations.
"""
from cty... | JesseTG/libretro.py | src/libretro/api/camera.py | .py | 02cdd16ce42004ff | 7.65 | 19 |
"""Types and callbacks for using the emulated system's disk drives, if any."""
from ctypes import Structure, c_bool, c_size_t, c_uint
from dataclasses import dataclass
from typing import override
from libretro.api._utils import NullPointerToNoneMixin
from libretro.api.content import retro_game_info
from libretro.ctyp... | JesseTG/libretro.py | src/libretro/api/disk.py | .py | 1f40a135ae8884bc | 7.65 | 19 |
"""Analog axis input state."""
from dataclasses import dataclass
from enum import IntEnum
from .device import InputDeviceState
from .joypad import DeviceIdJoypad
RETRO_DEVICE_INDEX_ANALOG_LEFT = 0
RETRO_DEVICE_INDEX_ANALOG_RIGHT = 1
RETRO_DEVICE_INDEX_ANALOG_BUTTON = 2
RETRO_DEVICE_ID_ANALOG_X = 0
RETRO_DEVICE_ID_A... | JesseTG/libretro.py | src/libretro/api/input/analog.py | .py | a55fff9d554c9e61 | 7.65 | 19 |
"""Input device definitions and state callbacks."""
from __future__ import annotations
from collections.abc import Iterator, Sequence
from ctypes import POINTER, Array, Structure, c_char_p, c_int16, c_uint
from dataclasses import dataclass
from enum import CONFORM, IntEnum, IntFlag
from typing import NewType, overloa... | JesseTG/libretro.py | src/libretro/api/input/device.py | .py | 8384e5042669c110 | 7.65 | 19 |
"""
Light gun input types, button and axis IDs.
Corresponds to the ``RETRO_DEVICE_ID_LIGHTGUN_*`` constants in ``libretro.h``.
"""
from dataclasses import dataclass
from enum import IntEnum
from typing import Literal, overload
from libretro.compat import deprecated
from .device import InputDeviceState
RETRO_DEVICE... | JesseTG/libretro.py | src/libretro/api/input/lightgun.py | .py | d8b376935420b147 | 7.65 | 19 |
"""
Mouse input types, buttons, and axis IDs.
Corresponds to the ``RETRO_DEVICE_ID_MOUSE_*`` constants in ``libretro.h``.
"""
from dataclasses import dataclass
from enum import IntEnum
from typing import Literal, overload
from .device import InputDeviceState
RETRO_DEVICE_ID_MOUSE_X = 0
RETRO_DEVICE_ID_MOUSE_Y = 1
R... | JesseTG/libretro.py | src/libretro/api/input/mouse.py | .py | 18330c556fc61f8d | 7.65 | 19 |
"""
Pointer (touch/pen) input types and multi-touch state.
Corresponds to the ``RETRO_DEVICE_ID_POINTER_*`` constants in ``libretro.h``.
"""
from dataclasses import dataclass
from enum import IntEnum
from .device import InputDeviceState
RETRO_DEVICE_ID_POINTER_X = 0
RETRO_DEVICE_ID_POINTER_Y = 1
RETRO_DEVICE_ID_POI... | JesseTG/libretro.py | src/libretro/api/input/pointer.py | .py | 40ac0230f2a5b44e | 7.65 | 19 |
r"""
Types for allowing :class:`.Core`\s to control LED indicators on the host device.
.. seealso::
:class:`.LedDriver`
The protocol that uses these types to implement LED control support in libretro.py.
:mod:`libretro.drivers.led`
libretro.py's included :class:`.LedDriver` implementations.
"... | JesseTG/libretro.py | src/libretro/api/led.py | .py | 6194a7ab3e71947a | 7.65 | 19 |
"""
Geographic location service interface types.
Allows cores to access the host device's geographic location.
.. seealso:: :mod:`libretro.drivers.location`
"""
from ctypes import Structure, c_bool, c_double, c_uint
from dataclasses import dataclass
from libretro.api._utils import NullPointerToNoneMixin
from libret... | JesseTG/libretro.py | src/libretro/api/location.py | .py | d3f635d8fad58b78 | 7.65 | 19 |
r"""
Types for allowing :class:`.Core`\s to log messages.
.. seealso::
:class:`.LogDriver`
The protocol that uses these types to implement logging support in libretro.py.
:mod:`libretro.drivers.log`
libretro.py's included :class:`.LogDriver` implementations.
"""
import logging
from ctypes imp... | JesseTG/libretro.py | src/libretro/api/log.py | .py | 016e43377fabbcff | 7.65 | 19 |
"""Types that describe the address space of the :class:`.Core`'s emulated memory."""
from __future__ import annotations
from collections.abc import Iterator, Sequence
from ctypes import POINTER, Array, Structure, c_char_p, c_size_t, c_uint, c_uint64
from dataclasses import dataclass
from enum import IntFlag
from typi... | JesseTG/libretro.py | src/libretro/api/memory.py | .py | 099b8ef69010e75e | 7.65 | 19 |
r"""
Types that allow :class:`.Core`\s to display notifications on the frontend's OSD.
.. seealso::
:class:`.MessageDriver`
The :class:`.Protocol` that uses these types to implement notification support in libretro.py.
:mod:`libretro.drivers.message`
libretro.py's included :class:`.MessageDriv... | JesseTG/libretro.py | src/libretro/api/message.py | .py | 9f910dab64aa11f6 | 7.65 | 19 |
"""
Microphone audio capture interface types.
Corresponds to :c:type:`retro_microphone_interface` in ``libretro.h``.
Allows cores to capture audio input from the host device.
.. seealso:: :mod:`libretro.drivers.microphone`
"""
from ctypes import Structure, c_bool, c_int, c_int16, c_size_t, c_uint, c_uint64
from data... | JesseTG/libretro.py | src/libretro/api/microphone.py | .py | e8e64951a62dcf2d | 7.65 | 19 |
"""
MIDI input/output interface types.
Allows cores to send and receive MIDI messages.
Corresponds to :c:type:`retro_midi_interface` in ``libretro.h``.
.. seealso::
:class:`.MidiDriver`
The :class:`.Protocol` that uses these types to implement MIDI support in libretro.py.
:mod:`libretro.drivers.midi`... | JesseTG/libretro.py | src/libretro/api/midi.py | .py | d48030921fe18893 | 7.65 | 19 |
"""
Network packet exchange interface types for multiplayer.
.. seealso:: :mod:`libretro.drivers.netpacket`
"""
from ctypes import Structure, c_bool, c_char_p, c_int, c_size_t, c_uint16
from dataclasses import dataclass
from enum import IntFlag
from libretro.api._utils import NullPointerToNoneMixin
from libretro.cty... | JesseTG/libretro.py | src/libretro/api/netpacket.py | .py | 9b08012865934105 | 7.65 | 19 |
"""
Performance counter and SIMD feature detection types.
Corresponds to :c:type:`retro_perf_callback`, :c:type:`retro_perf_counter`,
and the ``RETRO_SIMD_*`` constants in ``libretro.h``.
.. seealso::
:class:`.PerfDriver`
The :class:`~typing.Protocol` that uses these types
to expose performance co... | JesseTG/libretro.py | src/libretro/api/perf.py | .py | f0ae44c666089859 | 7.65 | 19 |
"""
Types for exposing a frontend's power status to a :class:`.Core`.
.. seealso::
:class:`.PowerDriver`
The :class:`~typing.Protocol` that uses these types to expose power status to a :class:`.Core`.
:mod:`libretro.drivers.power`
libretro.py's included :class:`.PowerDriver` implementations.
... | JesseTG/libretro.py | src/libretro/api/power.py | .py | bb666fb213c03d70 | 7.65 | 19 |
"""
Types for retrieving core functions beyond
the standard ``retro_*`` API functions exposed by :class:`.Core`.
"""
from ctypes import Structure
from dataclasses import dataclass
from libretro.ctypes import CStringArg, TypedFunctionPointer
retro_proc_address_t = TypedFunctionPointer[None, []]
"""
Opaque function po... | JesseTG/libretro.py | src/libretro/api/proc.py | .py | c611e900864d4f35 | 7.65 | 19 |
"""
Rumble (force feedback) interface types.
Corresponds to :c:type:`retro_rumble_interface` in ``libretro.h``.
.. seealso::
:class:`.RumbleDriver`
The :class:`~typing.Protocol` that uses these types to implement rumble support in libretro.py.
:mod:`libretro.drivers.rumble`
libretro.py's inc... | JesseTG/libretro.py | src/libretro/api/rumble.py | .py | 6de9729cda4d63fb | 7.65 | 19 |
"""Types that define serialization quirks and savestate contexts."""
from ctypes import c_int
from enum import IntEnum, IntFlag
RETRO_SERIALIZATION_QUIRK_INCOMPLETE = 1 << 0
RETRO_SERIALIZATION_QUIRK_MUST_INITIALIZE = 1 << 1
RETRO_SERIALIZATION_QUIRK_CORE_VARIABLE_SIZE = 1 << 2
RETRO_SERIALIZATION_QUIRK_FRONT_VARIABL... | JesseTG/libretro.py | src/libretro/api/savestate.py | .py | f54fee3ae15e58b8 | 7.65 | 19 |
"""
Types for providing sensor input to cores.
.. seealso::
:class:`.SensorDriver`
The :class:`.Protocol` that uses these types to implement sensor support in libretro.py.
:mod:`libretro.drivers.sensor`
libretro.py's included :class:`.SensorDriver` implementations.
"""
from ctypes import Stru... | JesseTG/libretro.py | src/libretro/api/sensor.py | .py | 9639be50a8434740 | 7.65 | 19 |
"""
Types for managing the rate at which the :class:`.Core` runs.
.. seealso:: :mod:`libretro.drivers.timing`
"""
from ctypes import Structure, c_bool, c_float, c_int64, c_uint
from dataclasses import dataclass
from enum import IntEnum
from libretro.ctypes import CIntArg, TypedFunctionPointer
RETRO_THROTTLE_NONE = ... | JesseTG/libretro.py | src/libretro/api/timing.py | .py | ebbdf9500540f1dd | 7.65 | 19 |
"""Hardware rendering API context types and callbacks."""
from ctypes import Structure, c_bool, c_int, c_uint, c_void_p, cast
from dataclasses import dataclass
from enum import IntEnum
from libretro.api._utils import NullPointerToNoneMixin, c_uintptr
from libretro.ctypes import CStringArg, TypedFunctionPointer, c_voi... | JesseTG/libretro.py | src/libretro/api/video/context.py | .py | e4d2f9d1bae00f2c | 7.65 | 19 |
"""
Pixel format and software framebuffer types.
Corresponds to the ``retro_pixel_format`` and ``retro_framebuffer`` types
in ``libretro.h``.
"""
from ctypes import Structure, c_int, c_size_t, c_uint
from dataclasses import dataclass
from enum import IntEnum, IntFlag
from typing import Literal
from libretro.api._uti... | JesseTG/libretro.py | src/libretro/api/video/frame.py | .py | 1b66bdae4291ac47 | 7.65 | 19 |
"""
Hardware rendering context negotiation types.
Corresponds to :c:type:`retro_hw_render_context_negotiation_interface`
in ``libretro.h``.
"""
from ctypes import Structure, c_int, c_uint
from dataclasses import dataclass
from enum import IntEnum
retro_hw_render_context_negotiation_interface_type = c_int
RETRO_HW_RE... | JesseTG/libretro.py | src/libretro/api/video/negotiate.py | .py | ca3042a4aa0bf103 | 7.65 | 19 |
"""
Hardware rendering interface types.
Corresponds to :c:type:`retro_hw_render_interface` and the rotation constants
in ``libretro.h``.
"""
from ctypes import Structure, c_int, c_uint
from dataclasses import dataclass
from enum import IntEnum
retro_hw_render_interface_type = c_int
RETRO_HW_RENDER_INTERFACE_VULKAN =... | JesseTG/libretro.py | src/libretro/api/video/render.py | .py | 82514e88f31de358 | 7.65 | 19 |
"""
Type annotations for :mod:`ctypes` behavior that is documented but missing from its type stubs.
Most of these definitions fall back to standard :mod:`ctypes` types at runtime,
so they can be used as drop-in replacements for the standard types in function signatures.
The subscripted helpers — :class:`TypedPointer`... | JesseTG/libretro.py | src/libretro/ctypes.py | .py | b8ef1a69c69d68ee | 7.65 | 19 |
"""
An audio driver that writes received samples to a WAV file.
.. seealso::
:mod:`wave`
The Python standard library module used to write WAV files in this driver.
:mod:`libretro.api.audio`
Defines the audio callback types and sample formats this driver handles.
"""
import wave
from copy imp... | JesseTG/libretro.py | src/libretro/drivers/audio/wave.py | .py | d065a8d3fb057a90 | 7.65 | 19 |
"""Server fan-out under concurrent sessions: the scaling pillar's baseline numbers.
Each benchmark round publishes a fixed burst — ``UPDATES`` increments across every stream at
``INTERVAL`` — and completes when **every** client has received the final revision of every
stream, so the primary statistic is end-to-end del... | 1kbgz/transports | benchmarks/test_fanout.py | .py | 67643977beec8a33 | 7.95 | 7 |
"""Multi-tenant hub fan-out: the per-tenant/shared two-tier path under concurrent tenants.
The csp-gateway shape: T tenants, one connection each, every tenant holding P private models (its
own ``Session``) and subscribed to S shared models. Each benchmark round publishes ``UPDATES``
bursts to the selected class(es) an... | 1kbgz/transports | benchmarks/test_hub_fanout.py | .py | c10d1a3eacf8700a | 7.95 | 7 |
"""Session cost audit: what a session costs the server before any work is done.
The benchmark statistic is the connection storm — wall-clock to establish the whole fleet
(handshake + per-model snapshots). The audit numbers ride ``extra_info``: RSS growth per idle
session, server CPU over an idle window, and thread gro... | 1kbgz/transports | benchmarks/test_session_cost.py | .py | 36b88469863692cf | 7.95 | 7 |
"""Bridge Python models <-> the core `Value` wire form, derive core schemas, and emit TS types.
Supports three model kinds with one contract — **pydantic** models, stdlib **dataclasses**, and
**msgspec.Struct**s:
- `to_value` / `from_value` convert an instance ⇄ the core `Value` (the externally-tagged enum the
Rust... | 1kbgz/transports | transports/_bridge.py | .py | 567a17b9510b777b | 7.45 | 7 |
"""Serve a `Server`/`Hub` over an anywidget (ipywidgets `DOMWidget`) — the widget *is* the connection.
Like `serve_comm`, but for an anywidget's custom-message channel rather than a raw Jupyter comm: the
wire rides ``widget.send({"wire": <wire>})`` outbound and the widget's ``on_msg`` inbound. The frontend
signals ``{... | 1kbgz/transports | transports/anywidget.py | .py | 9de3f2be5c753ce3 | 7.45 | 7 |
"""Serve a `Session`/`Hub` over a Jupyter comm channel.
A Jupyter **comm** is a bidirectional message channel between a kernel and a frontend (the transport
behind ipywidgets). It carries JSON-able data natively, so transports rides it by sending the wire
*string* as the comm's ``data`` — no extra framing, and the sam... | 1kbgz/transports | transports/comm.py | .py | 85900790e7304d26 | 7.45 | 7 |
"""Leader election + a singleton task across a cluster, over a `Backplane`.
`uvicorn --workers N` (or any multi-process cluster) sometimes needs a job to run on **exactly one**
worker — a ticker, a scheduler, a single writer — and to **fail over** if that worker dies. `Election`
provides that over the same backplane t... | 1kbgz/transports | transports/election.py | .py | 6a00dbe6ad96754a | 7.45 | 7 |
"""The connection wire protocol: one logical frame per message, as JSON.
WebSocket messages (and Jupyter comm messages) are self-delimiting, so the binary `Frame` envelope
in the Rust core — which exists for byte-stream transports like TCP — isn't needed here. A small
JSON envelope carries the routing metadata around ... | 1kbgz/transports | transports/protocol.py | .py | 9186aa37485a5db7 | 7.45 | 7 |
"""Cluster a :class:`~transports.Hub` across worker processes with a :class:`~transports.Backplane`.
`uvicorn --workers N` spreads the connection I/O across cores, but each worker then has its own in-memory
hub. :class:`RelayBroadcaster` bridges a local hub to a backplane so the cluster serves the *same* shared
models... | 1kbgz/transports | transports/relay.py | .py | aef8bf3af4b44d4a | 7.45 | 7 |
"""An order-free **sequence CRDT** (Logoot / fractional-index style) for `Hub` shared models.
A sequence is a JSON string of *entries* — ``{"k": position, "o": origin, "v": value, "x": deleted}`` —
where ``k`` is a rational position (``"num/den"``) that orders the entry and ``o`` is the writer that
created it (a tiebr... | 1kbgz/transports | transports/seq.py | .py | 1efa6b45de25b39a | 7.45 | 7 |
"""Serve a reactive `Session` over connections (WebSocket, ...).
`Server` holds the transport-agnostic logic — register connections, send snapshots on open, relay
inbound patches, broadcast outbound patches — as plain synchronous methods that *return* the messages
to send, keyed by connection. The actual async I/O liv... | 1kbgz/transports | transports/server.py | .py | d6899e20b6f8e333 | 7.45 | 7 |
"""Reactive session: host pydantic models, observe mutations with bigbrother, emit core patches.
Mutations are observed recursively via `bigbrother.watch(model, cb, deepstate=True)`. bigbrother's
callback fires *before* the underlying mutation is applied, so the callback only marks the model
dirty; `flush()` (also inv... | 1kbgz/transports | transports/session.py | .py | 08dc55ef3aaee0a2 | 7.45 | 7 |
"""Serve a `Session`/`Hub` over Server-Sent Events (receive-only).
SSE is a one-way server→client stream (the browser `EventSource`), well suited to receive-mostly UIs
like dashboards. A client receives the opening snapshots and then a live stream of patches; it does
not send edits back over SSE (use the WebSocket ada... | 1kbgz/transports | transports/sse.py | .py | 5cea088c25c90aa4 | 7.45 | 7 |
import json
from pydantic import BaseModel
import transports
class M(BaseModel):
x: int = 0
class Device(BaseModel):
brightness: int = 60
def test_submit_rejects_malformed_patch_without_crashing():
"""A malformed client proposal (path descends into the wrong type) is rejected, not applied — and
... | 1kbgz/transports | transports/tests/test_apply_safety.py | .py | a3df34858e770a60 | 7.95 | 7 |
"""Create a unique post-release version for test.pypi.org.
This script will find the latest version of the package on test.pypi.org and create a new version,
incrementing the `.postN` version if necessary. It will then write that new version number back to
the pyproject.toml file.
This script will also set the value ... | tektronix/python-package-ci-cd | actions/create_unique_testpypi_version/main.py | .py | 201bd9ce0dad9d2f | 7.92 | 6 |
"""This script will check for unreleased entries in the CHANGELOG.md file.
It will exit with a non-zero exit code if there are no unreleased entries.
This script needs to be run from a directory that contains a `pyproject.toml` file and a
`CHANGELOG.md` file.
This script will do a few things:
- It will copy the ... | tektronix/python-package-ci-cd | actions/find_unreleased_changelog_items/main.py | .py | e7662078567c55b2 | 7.42 | 6 |
"""Update the development dependencies.
This script will update the development dependencies that are pinned in the pyproject.toml and .pre-
commit-config.yaml files.
In order to use this script, you must be using the poetry package manager and `poetry` must be
accessible on the commandline. If you want to use this s... | tektronix/python-package-ci-cd | actions/update_development_dependencies/main.py | .py | 95b1a0bd2010e38f | 7.42 | 6 |
"""This script will bump the version of the GitHub Actions to the newest version.
This script is intended to be run as a part of the release process in the `python-semantic-release`
`build-command`.
"""
from __future__ import annotations
import os
import re
import subprocess
from pathlib import Path
DIRECTORIES_TO... | tektronix/python-package-ci-cd | scripts/bump_version_in_files.py | .py | 1490198ccc82a3ce | 7.42 | 6 |
"""Set up an environment to use to contribute to this package.
This script will run through the commands listed in the CONTRIBUTING.md file.
"""
from __future__ import annotations
import glob
import os
import platform
import shlex
import subprocess
import sys
from pathlib import Path
RUNNING_ON_LINUX = platform.sy... | tektronix/python-package-ci-cd | scripts/contributor_setup.py | .py | 18f7afcf4cc3b8ee | 7.42 | 6 |
"""Test the bump_version_in_files module."""
from collections.abc import Generator
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from scripts.bump_version_in_files import get_file_paths, update_github_actions_version
@pytest.fixture(autouse=True)
def mock_subprocess_check_call()... | tektronix/python-package-ci-cd | tests/test_bump_version_in_files.py | .py | 491a818bb5bca1fc | 7.92 | 6 |
"""Test the create_unique_testpypi_version action Python code."""
from __future__ import annotations
from typing import TYPE_CHECKING
from unittest.mock import MagicMock, patch
import pytest
import actions.create_unique_testpypi_version.main
from actions.create_unique_testpypi_version.main import create_new_post_v... | tektronix/python-package-ci-cd | tests/test_create_unique_testpypi_version.py | .py | 5f4d83a9b9d4c886 | 7.92 | 6 |
"""Test for the documentation."""
import os
import shlex
import subprocess
import sys
import time
from collections.abc import Generator
from importlib.util import find_spec
from pathlib import Path
import pytest
REPO_ROOT_DIR = Path(__file__).resolve().parent.parent
@pytest.fixture(name="docs_server")
def fixture... | tektronix/python-package-ci-cd | tests/test_docs.py | .py | f6cfc394146b6c63 | 7.92 | 6 |
"""Test the update_development_dependencies action Python code."""
import sys
from collections.abc import Generator
from pathlib import Path
from typing import Any
from unittest.mock import call, MagicMock, patch
import pytest
from actions.update_development_dependencies.main import (
convert_dict_input,
ex... | tektronix/python-package-ci-cd | tests/test_update_development_dependencies.py | .py | 862b69277bbb5cc6 | 7.92 | 6 |
import os
import yaml
import subprocess
import argparse
import json
class MatrixGenerator:
def __init__(self, directory = '.', from_changes:bool = False, previous: bool = False):
if from_changes:
if previous:
print("Getting git changes from HEAD")
self.directorie... | j0rsa/home-assistant-apps | get_matrix.py | .py | fb9ee0746bff69e5 | 7.5 | 9 |
"""Main app for Hailo Whisper"""
import time
import argparse
import os
import sys
from wyoming_hailo_whisper.app.hailo_whisper_pipeline import HailoWhisperPipeline
from wyoming_hailo_whisper.common.audio_utils import load_audio
from wyoming_hailo_whisper.common.preprocessing import preprocess, improve_input_audio
from... | j0rsa/home-assistant-apps | wyoming-hailo-whisper/wyoming_hailo_whisper/app/app_hailo_whisper.py | .py | d6a4ce4045a149ad | 7.5 | 9 |
# copied from Whisper repo
import os
from functools import lru_cache
from subprocess import CalledProcessError, run
from typing import Optional, Union
import numpy as np
import torch
import torch.nn.functional as F
def exact_div(x, y):
assert x % y == 0
return x // y
# hard-coded audio hyperparameters
SAMPL... | j0rsa/home-assistant-apps | wyoming-hailo-whisper/wyoming_hailo_whisper/common/audio_utils.py | .py | 9eea9b958745d99b | 7.5 | 9 |
"""Postprocessing functions for Whisper-generated transcriptions."""
import numpy as np
import re
excluded_tokens = [11, 13] # Punctuation tokens to exclude from repetition penalty
def apply_repetition_penalty(logits, generated_tokens, penalty=1.5, last_window=8):
"""
Apply repetition penalty to the logits... | j0rsa/home-assistant-apps | wyoming-hailo-whisper/wyoming_hailo_whisper/common/postprocessing.py | .py | cdc8a6e3c3ca5045 | 7.5 | 9 |
"""Preprocessing functions for Whisper audio data."""
import wyoming_hailo_whisper.common.audio_utils as audio_utils
import numpy as np
import logging
_LOGGER = logging.getLogger(__name__)
def preprocess(audio, is_nhwc=False, chunk_length = 10, chunk_offset=0, max_duration = 60, overlap=0.0):
"""
Generate th... | j0rsa/home-assistant-apps | wyoming-hailo-whisper/wyoming_hailo_whisper/common/preprocessing.py | .py | 139a15f0b6b7b592 | 7.5 | 9 |
import sounddevice as sd
import numpy as np
import scipy.io.wavfile as wav
import select
import sys
import queue
import time
# Whisper expects 16kHz mono audio
SAMPLE_RATE = 16000
CHANNELS = 1
def enter_pressed():
return select.select([sys.stdin], [], [], 0.0)[0]
def record_audio(duration, audio_path):
"""
... | j0rsa/home-assistant-apps | wyoming-hailo-whisper/wyoming_hailo_whisper/common/record_utils.py | .py | d01173e298847765 | 7.5 | 9 |
"""Event handler for clients of the server."""
import argparse
import asyncio
import io
import time
import logging
import wave
import numpy as np
from wyoming_hailo_whisper.app.hailo_whisper_pipeline import HailoWhisperPipeline
from wyoming_hailo_whisper.common.preprocessing import preprocess, improve_input_audio
from... | j0rsa/home-assistant-apps | wyoming-hailo-whisper/wyoming_hailo_whisper/handler.py | .py | 4441033d74246fe9 | 7.5 | 9 |
#!/usr/bin/env python3
"""
Convert VLESS and Shadowsocks links to Xray configuration format.
Usage:
python convert_links.py "vless://..." [--output config.json] [--proxy-port 8080]
python convert_links.py "ss://..." [--output config.json] [--proxy-port 8080]
"""
import argparse
import base64
import json
impor... | j0rsa/home-assistant-apps | xray/convert_links.py | .py | bfd999fbc83f08ba | 7.5 | 9 |
"""Shared ANTsX-format transform export helpers.
This module is the one place ``antstorch`` writes real, file-based ANTs
transforms — the classic ``antsRegistration`` convention of a numbered
affine ``.mat`` plus forward/inverse displacement-field ``.nii.gz`` files,
rather than a single in-memory composed field. It ex... | ANTsX/ANTsTorch | antstorch/ants_transform_io.py | .py | 9818b197686fdb32 | 7.45 | 7 |
"""Independent CPU reference utilities matching ITK's reconstruction loop.
These helpers are deliberately outside the synthesis/autograd path. The
NumPy evaluator is useful for reference fixtures. ``coefficient_lattice_metadata``
reproduces ITK's reported coefficient-image geometry for initialization and
interchange... | ANTsX/ANTsTorch | antstorch/bspline_flows/itk_reference.py | .py | 924766530a58b40f | 7.45 | 7 |
"""Scaling-and-squaring exponential of stationary physical velocity fields."""
import torch
from torch import Tensor, nn
from .bspline_domain import ImageDomain
from .spatial_transform import compose_displacements
def scaling_and_squaring(velocity: Tensor, domain: ImageDomain, steps: int = 7) -> Tensor:
"""Appr... | ANTsX/ANTsTorch | antstorch/bspline_flows/scaling_and_squaring.py | .py | a61bb8581bafbc4f | 7.45 | 7 |
"""Differentiable registration similarities and physical regularizers."""
import torch
from torch import Tensor
from torch.nn import functional as F
from .bspline_domain import ImageDomain
def mean_squared_error(fixed: Tensor, warped_moving: Tensor) -> Tensor:
if fixed.shape != warped_moving.shape:
rais... | ANTsX/ANTsTorch | antstorch/bspline_flows/similarity.py | .py | a72ea77727b6a0a0 | 7.45 | 7 |
"""Physical-coordinate dense transforms for 2-D and 3-D tensors.
ITK metadata and vector components use x-y-(z) order. PyTorch spatial storage
is H-W or D-H-W. A displacement ``u`` maps a fixed physical point ``p`` to
the moving-image sample location ``p + u(p)``.
"""
from typing import Tuple
import torch
from torch... | ANTsX/ANTsTorch | antstorch/bspline_flows/spatial_transform.py | .py | f4e5a8d02b08b899 | 7.45 | 7 |
"""``ants.ANTsImage`` <-> in-memory tensor bridge for :mod:`antstorch.syn`.
``antstorch.syn.core`` operates purely on PyTorch tensors and plain
metadata tuples; this module is the (thin, explicit) boundary that lets
:func:`antstorch.syn.syn.syn_registration` accept and return
``ants.ANTsImage`` objects, matching ``ant... | ANTsX/ANTsTorch | antstorch/syn/bridge.py | .py | 02f8e8bdc8db0c88 | 7.45 | 7 |
"""Example demonstrating class attribute-based sink configuration.
This example shows how to configure logger sinks using class attributes,
which provides excellent IDE autocompletion support and a clean interface.
"""
import tempfile
from pathlib import Path
from expedantic.logger import (
LoggerBase,
Field... | rnilva/expedantic | examples/class_attribute_sinks_example.py | .py | 75959242499bc54a | 7.45 | 7 |
"""Comprehensive example showing all available logger sinks.
This example demonstrates how to use console, file, WandB, and TensorBoard sinks
together in a realistic ML training scenario.
"""
import tempfile
from pathlib import Path
from expedantic.logger import (
LoggerBase,
Field,
MeanField,
MaxFiel... | rnilva/expedantic | examples/comprehensive_sinks_example.py | .py | 4bd7935361724741 | 7.45 | 7 |
"""Example demonstrating decorator-based sink configuration.
This example shows the clean decorator syntax for configuring logger sinks
directly on the class definition, making the configuration more declarative
and discoverable.
"""
import tempfile
from pathlib import Path
from expedantic.logger import (
Logger... | rnilva/expedantic | examples/decorator_sinks_example.py | .py | 40385622736642f5 | 7.45 | 7 |
"""
Logger Usage Examples
This example demonstrates the comprehensive logger module capabilities
including different field types, training loops, and data export.
"""
import random
import tempfile
from pathlib import Path
# DataFrame export needs the optional 'dataframe' extra; the rest of the
# example runs on a ba... | rnilva/expedantic | examples/logger_usage.py | .py | caad619f4b683ac9 | 7.45 | 7 |
"""Example demonstrating multi-sink logger functionality.
This example shows how to set up a logger with multiple sinks including
console output, file logging, and placeholder WandB/TensorBoard sinks.
"""
from expedantic.logger import (
LoggerBase,
Field,
MeanField,
MaxField,
ConsoleSink,
File... | rnilva/expedantic | examples/multi_sink_example.py | .py | 6ef4f51e48ac2d25 | 7.45 | 7 |
import argparse
import inspect
import json
from abc import ABC
from collections.abc import Mapping
from io import IOBase
from pathlib import Path
from types import UnionType
from typing import (
Any,
Callable,
ClassVar,
Sequence,
Type,
Literal,
Union,
get_origin,
get_args,
)
from ty... | rnilva/expedantic | src/expedantic/config_base.py | .py | 780673eb3b644a2c | 7.45 | 7 |
"""Core logger functionality.
This module contains the LoggerBase class and related functionality
for creating type-safe, structured loggers.
"""
import inspect
from datetime import datetime
from io import BytesIO
from pathlib import Path
from typing import TYPE_CHECKING, get_origin
from .fields import FieldBase, Su... | rnilva/expedantic | src/expedantic/logger/base.py | .py | b27a444774562ed2 | 7.45 | 7 |
"""Sink implementations for the logger system.
This module contains all the built-in sink implementations that can
receive and process logged data from loggers.
"""
import json
import threading
from datetime import date, datetime, time, timedelta
from decimal import Decimal
from pathlib import Path
from typing import... | rnilva/expedantic | src/expedantic/logger/sinks.py | .py | 479cb151ac035abc | 7.45 | 7 |
from typing import Any, Literal, Optional, get_origin
from rich.columns import Columns
from rich.console import Console
from rich.panel import Panel
from rich.style import Style, StyleType
from rich.text import Text
from rich.tree import Tree
from ..utils import _NOT_PROVIDED
DIFF_STYLE_MAP: dict[
Literal["previ... | rnilva/expedantic | src/expedantic/printers/diff.py | .py | cd6ab77819682558 | 7.45 | 7 |
import inspect
import sys
from pathlib import Path
from pydantic import BaseModel
from pydantic.fields import FieldInfo
from rich.console import Console, Group
from rich.tree import Tree
from rich.table import Table
from rich.text import Text
from rich.panel import Panel
from rich.columns import Columns
from .utils im... | rnilva/expedantic | src/expedantic/printers/help.py | .py | 8282d85c5c19d6c0 | 7.45 | 7 |
from itertools import groupby
from operator import itemgetter
from typing import Type, TypedDict
from pydantic import BaseModel, ValidationError
from pydantic.fields import FieldInfo
from pydantic_core import ErrorDetails
from rich.console import Console
from rich.panel import Panel
from rich.text import Text
from ric... | rnilva/expedantic | src/expedantic/printers/validation.py | .py | 0f5eac0f7a77ea90 | 7.45 | 7 |
import argparse
import inspect
from typing import Any, Type, get_origin, get_args, Sequence
from pydantic import BaseModel
from pydantic.fields import FieldInfo
from tap.utils import type_to_str, get_literals
EMPTY = inspect.Parameter.empty
POS_ONLY = inspect.Parameter.POSITIONAL_ONLY
class NOT_PROVIDED_CLASS:
... | rnilva/expedantic | src/expedantic/utils.py | .py | bf736124f75368a4 | 7.45 | 7 |
"""Comprehensive test suite for the logger module."""
import statistics
import pytest
from datetime import datetime
from decimal import Decimal
from io import BytesIO
from expedantic.logger import (
Field,
MeanField,
MaxField,
MinField,
SumField,
ListField,
CountField,
StdField,
M... | rnilva/expedantic | tests/test_logger.py | .py | 561b7789e0d747c4 | 7.95 | 7 |
"""Tests for logger class attribute configuration functionality."""
import tempfile
from pathlib import Path
from unittest.mock import Mock
import pytest
from expedantic.logger import (
LoggerBase,
Field,
MeanField,
ConsoleSink,
FileSink,
logger_sinks,
logger_name,
)
class TestLoggerClas... | rnilva/expedantic | tests/test_logger_class_attributes.py | .py | d2a686f043de04b3 | 7.95 | 7 |
"""Tests for multi-sink logger functionality."""
import json
import tempfile
from pathlib import Path
from unittest.mock import Mock, patch
import pytest
from expedantic.logger import (
LoggerBase,
Field,
MeanField,
ConsoleSink,
FileSink,
WandBSink,
TensorBoardSink,
)
class TestLogger(Lo... | rnilva/expedantic | tests/test_multi_sink.py | .py | 2db59f07bcc119a2 | 7.95 | 7 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
import os
import shutil
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
from typing import Any
class HatchCustomBuildHook(BuildHookInterface):
"""
This class implements Hatch's [custom build hook] (https://hatch.pyp... | aws-deadline/deadline-cloud-for-maya | hatch_custom_hook.py | .py | 7e8509d1357ac9f0 | 7.65 | 19 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
"""
This file contains the logic that is used to load/unload our plugin
"""
from __future__ import absolute_import, annotations, print_function
import os
import logging
import types
from typing import List
from importlib import reload
import maya.... | aws-deadline/deadline-cloud-for-maya | maya_submitter_plugin/plug-ins/DeadlineCloudForMaya.py | .py | 66c8635d17063ed8 | 7.65 | 19 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
"""Run integration tests with correct environment for each platform.
Sets Maya's bin on PATH and renderer environment variables so the adaptor's
subprocess can find mayapy and renderer plugins.
"""
import os
import platform
import subprocess
import ... | aws-deadline/deadline-cloud-for-maya | pipeline/run-integ-tests.py | .py | 249ae65b2b3b9106 | 7.15 | 19 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
"""Script to create platform-specific Deadline Client installers using InstallBuilder."""
import os
import sys
import shutil
import tempfile
from datetime import datetime
from typing import Optional
from pathlib import Path
from common import Evalua... | aws-deadline/deadline-cloud-for-maya | scripts/build_installer.py | .py | eaa1c93f53cc5954 | 7.65 | 19 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
import argparse
import json
import platform
import shutil
import subprocess
from pathlib import Path
from typing import Optional
from _project import get_git_root, get_dependencies, get_project_dict, get_pip_platform
class MayaVersion:
major:... | aws-deadline/deadline-cloud-for-maya | scripts/install_dev_submitter.py | .py | 57bd038b6cce58fc | 7.65 | 19 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
"""
Module contain a wrapper around Maya's dirmap command
"""
from typing import List, Optional, Tuple
import maya.cmds
class DirectoryMappingDict(object):
"""
Dictionary like object used for accessing and modifying Directory mappings
... | aws-deadline/deadline-cloud-for-maya | src/deadline/maya_adaptor/MayaClient/dir_map.py | .py | b91517430ab2bef2 | 7.65 | 19 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
from .default_maya_handler import DefaultMayaHandler
import maya.cmds
class ArnoldHandler(DefaultMayaHandler):
"""Render Handler for Arnold"""
def __init__(self):
"""
Initializes the Arnold Renderer and Arnold Renderer Han... | aws-deadline/deadline-cloud-for-maya | src/deadline/maya_adaptor/MayaClient/render_handlers/arnold_handler.py | .py | a8618bf79825e967 | 7.65 | 19 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
from __future__ import annotations
import os
from typing import Any, Dict, List, Optional
import maya.cmds
import maya.mel
from ..dir_map import DirectoryMapping
def _get_render_layer_display_name(render_layer_name: str) -> str:
return maya.... | aws-deadline/deadline-cloud-for-maya | src/deadline/maya_adaptor/MayaClient/render_handlers/default_maya_handler.py | .py | 3f06659dbdd20d62 | 7.65 | 19 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
import maya.cmds
from .default_maya_handler import DefaultMayaHandler
class RedshiftHandler(DefaultMayaHandler):
"""
Render Handler for Redshift
"""
def __init__(self):
"""
Constructor for redshift handler.
... | aws-deadline/deadline-cloud-for-maya | src/deadline/maya_adaptor/MayaClient/render_handlers/redshift_handler.py | .py | adde358d0fdb297b | 7.65 | 19 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
from .default_maya_handler import DefaultMayaHandler
from ..dir_map import DirectoryMapping
import maya.cmds
# RenderMan node types that have a "filename" attribute containing texture paths
_RMAN_TEXTURE_NODE_TYPES = [
"PxrTexture",
"PxrNor... | aws-deadline/deadline-cloud-for-maya | src/deadline/maya_adaptor/MayaClient/render_handlers/renderman_handler.py | .py | 6e8579eda03663ec | 7.65 | 19 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.