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
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """Rewrite an sdist's member `mtime` to `SOURCE_DATE_EPOCH`. Unlike the siblings' script, this one touches one field and not five. Hatchling'...
btclib-org/btclib-secp256k1
.github/scripts/normalize_sdist.py
.py
9da73b6509da44b2
7.24
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. r"""Check a built wheel against an allowlist of its members. `twine check`, `check-wheel-contents` and `pyroma` read the *metadata* of a whee...
btclib-org/btclib-secp256k1
.github/scripts/verify_wheel_contents.py
.py
c2fe2556383ecf6a
7.24
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """Hatchling build hook: what the compiled extension makes of the wheel. The extension is built by scripts/cffi_build.py; what is decided her...
btclib-org/btclib-secp256k1
scripts/hatch_build.py
.py
6526ead9d6df82ed
7.24
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """Pure python cffi bindings to libsecp256k1: https://github.com/bitcoin-core/secp256k1. Every entry point of these bindings takes octets and...
btclib-org/btclib-secp256k1
src/btclib_secp256k1/__init__.py
.py
e83cd0f40834312d
7.24
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """What the arguments of the bindings are held to before they cross.""" from __future__ import annotations import secrets from . import Byt...
btclib-org/btclib-secp256k1
src/btclib_secp256k1/_scalar.py
.py
75460dad6fd57b8b
7.24
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """Overwriting the libsecp256k1 buffers a secret passes through. What SECURITY.md records as inherent is the python side: a `bytes` is immuta...
btclib-org/btclib-secp256k1
src/btclib_secp256k1/_secret.py
.py
3b12128fb77e35bf
7.24
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """Shared libsecp256k1 context, and what it reports through its callbacks.""" from __future__ import annotations import secrets import threa...
btclib-org/btclib-secp256k1
src/btclib_secp256k1/context.py
.py
7bbdd8e134289264
7.24
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """Elliptic Curve Diffie-Hellman (ECDH).""" from __future__ import annotations from typing import overload from . import BytesLike, CData, ...
btclib-org/btclib-secp256k1
src/btclib_secp256k1/ecdh.py
.py
44aa30ff6d00acc7
7.24
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """ElligatorSwift encoding and x-only ECDH, according to BIP324. https://github.com/bitcoin/bips/blob/master/bip-0324.mediawiki """ from __f...
btclib-org/btclib-secp256k1
src/btclib_secp256k1/ellswift.py
.py
c78aca1fc71864c5
7.24
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """Tests for what the package exports. Section 7 of the organization standard asks for `__all__` on every module and package, "a module under...
btclib-org/btclib-secp256k1
tests/all_test.py
.py
21eb0cf840be6f49
7.74
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """Tests of what libsecp256k1 reports through the callbacks of the context. No wrapper reads those callbacks, so what they record is `context...
btclib-org/btclib-secp256k1
tests/callbacks_test.py
.py
4d1622c3e53c18ef
7.74
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """A test this package names in its prose is a test that exists. The prose here points at tests by name -- the module docstring of `tests/ver...
btclib-org/btclib-secp256k1
tests/citations_test.py
.py
34e88b6123060d5a
7.74
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """Concurrent use of the shared libsecp256k1 context. The bindings hold one context, created and randomized at import time and passed to ever...
btclib-org/btclib-secp256k1
tests/concurrency_test.py
.py
afd108c48262d7d1
7.74
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """The convention-test declaration in tests/README.md is true. Section 7 of the organization standard lists conventions a suite can turn into...
btclib-org/btclib-secp256k1
tests/conventions_test.py
.py
13e791391f7aa4ac
7.74
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """LICENSE, COPYRIGHT and pyproject.toml, checked against each other. btclib's own LICENSE named "Ferdinando M. Ametrano and btclib contribut...
btclib-org/btclib-secp256k1
tests/copyright_test.py
.py
6e05543b7110d4bc
7.74
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """Every module this package ships is documented. Matching btclib's own tests/docs_test.py: the page under `docs/source/` is hand written, wh...
btclib-org/btclib-secp256k1
tests/docs_test.py
.py
63aa874da1032460
7.74
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """Every example in the documentation is executed. An example nobody runs is documentation that stops being true silently, and the README's o...
btclib-org/btclib-secp256k1
tests/examples_test.py
.py
cef54f56b8801c92
7.74
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """Tests of what installing the package provides, rather than its source. That is the extension module and the distribution metadata. One pa...
btclib-org/btclib-secp256k1
tests/extension_test.py
.py
ce23e66b345701e1
7.74
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """Tests for the BIP340 tagged hash. The reference is the definition itself, SHA256(SHA256(tag) || SHA256(tag) || msg) computed with hashlib:...
btclib-org/btclib-secp256k1
tests/hashes_test.py
.py
54dd98222cf1cf79
7.74
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """The mypy hook's pins are the versions `uv.lock` resolves. The type gate runs in an environment of its own: `.pre-commit-config.yaml` gives...
btclib-org/btclib-secp256k1
tests/hook_pins_test.py
.py
297784a60f216cd8
7.74
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """The interpreters this package claims are the ones it runs on. One fact, declared three times: `requires-python` is the floor, `Programming...
btclib-org/btclib-secp256k1
tests/interpreters_test.py
.py
5a0829377ec01fcc
7.74
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """Tests for the mutation session counter of `.github/scripts`. The script is what the `mutation` workflow prints, and what it prints is the ...
btclib-org/btclib-secp256k1
tests/mutation_counts_test.py
.py
bbd239e424639f9a
7.74
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """Tests for `.github/scripts/normalize_sdist.py`. The script is loaded by path, `.github/scripts` being no package, as the other scripts und...
btclib-org/btclib-secp256k1
tests/normalize_sdist_test.py
.py
58f484bf2e961373
7.74
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """The buffers a secret passes through are overwritten before being dropped. What the wrappers do with these is invisible from their answers ...
btclib-org/btclib-secp256k1
tests/secret_test.py
.py
8bae1ddf22e012b7
7.74
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """A signer signs what the module functions sign, and then wipes. `ssa.Signer` is one of the two module functions with the keypair hoisted ou...
btclib-org/btclib-secp256k1
tests/signer_test.py
.py
2dbb5de4f8a27cc6
7.74
2
# Copyright (c) The btclib developers # Distributed under the MIT software license, see the accompanying # LICENSE file or https://opensource.org/license/mit for the full text. """Tests for the submodule pin check of `.github/scripts`. The check is a pre-commit hook, so what it says about the real tree is answered on...
btclib-org/btclib-secp256k1
tests/submodule_pin_test.py
.py
be014aa98b934e63
7.74
2
""" Concatenative daily windowed GEOD files together from a given period into a single Parquet/CSV/TSV file. Originally tried to do this via appending to a parquet file, but this does not work - parquet files must be written in one go. This is not a problem given that this script only works over a maximum of a year ...
atedstone/gnssice
gnssice/conc_daily_geod.py
.py
350ea40d20cf1e74
7.24
2
# --- # jupyter: # jupytext: # formats: ipynb,py:percent # text_representation: # extension: .py # format_name: percent # format_version: '1.3' # jupytext_version: 1.16.4 # kernelspec: # display_name: Python 3 (ipykernel) # language: python # name: python3 # --- # %% # ...
atedstone/gnssice
gnssice/export_level1.py
.py
f8de59ae39b139c8
7.24
2
""" Calculate seasonal and annual displacements from GNSS data. As at June 2023, not ready to be used as a command line tool. Instead use magic %run functionality in a Notebook or ipython env. Andrew Tedstone (andrew.tedstone@unifr.ch), July 2022, August 2025. """ from __future__ import annotations import matplotlib....
atedstone/gnssice
gnssice/seasonal_annual_disp.py
.py
18289f49f1fc5852
7.24
2
#!/usr/bin/env python # # @license Apache-2.0 # # Copyright (c) 2018 The Stdlib Authors. # # 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 # # ...
stdlib-js/math-base-special-rising-factorial
benchmark/python/scipy/benchmark.py
.py
e32abed3980c956b
7.24
2
#!/usr/bin/env python # # @license Apache-2.0 # # Copyright (c) 2018 The Stdlib Authors. # # 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 # # ...
stdlib-js/math-base-special-betainc
benchmark/python/scipy/benchmark.py
.py
31f345bd508c6790
7.3
3
from torch.utils.data import DataLoader, random_split def train_test_dataloaders(dataset, train_ratio=0.8, **kwargs): """Construct the training and testing `DataLoader`s.""" train_dataset, test_dataset = train_test_split(dataset, train_ratio=train_ratio) train_dataloader = DataLoader(train_dataset, **kwa...
billsioros/RoughGAN
src/roughgan/training/split.py
.py
9224bf53988150af
7.15
1
''' Given an integer n and a list of integers l, write a function that randomly generates a number from 0 to n-1 that isn't in l (uniform). n = 7 l = {0, 1, 5} the function should return any random number { 2, 3, 4, 6 } with equal probability. ''' import random class Solution: def __init__(self, n, blacklis...
tpalczew/Daily-coding
Python/BinarySearch/generate_num_not_in_list.py
.py
4f235ff4e83b415d
7
0
''' Add Two Numbers Input: l1 = [2,4,3], l2 = [5,6,4] Output: [7,0,8] Explanation: 342 + 465 = 807. Example 2: Input: l1 = [0], l2 = [0] Output: [0] Example 3: Input: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9] Output: [8,9,9,9,0,0,0,1] ''' from typing import Optional class ListNode: def __init__(self, val=0, next=Non...
tpalczew/Daily-coding
Python/Linked_lists/AddTwoNumbers.py
.py
593da48fbd045eb6
7
0
''' Merged two sorted lists ''' class Node: def __init__(self, data=None, next=None): self.data = data self.next = next class LkdList: def __init__(self): self.head = None # Finsert new node def push(self, new_data): new_node = Node(new_data) new_node.n...
tpalczew/Daily-coding
Python/Linked_lists/merged_two_sorted_lists.py
.py
90614643d1ef4115
7
0
''' Find if two singly linked lists overlap. ''' class Node: def __init__(self, data=None, next=None): self.data = data self.next = next class LList: def __init__(self): self.head = None def push(self, newdata): tmp = Node(newdata) tmp.next = self.head ...
tpalczew/Daily-coding
Python/Linked_lists/overlapping_lists_cycle_free.py
.py
daebdebfaf00ba33
7
0
''' reverse sublist singly listed list L and two integers s and f as arguments s and f inclusive) the head node is the first node ''' class Node: def __init__(self, data=None, next=None): self.data = data self.next = next class LList: def __init__(self): self.head = None ...
tpalczew/Daily-coding
Python/Linked_lists/reverse_sub_list.py
.py
df0e76d0a4f7d03a
7
0
''' Given the head of a singly linked list, swap every two nodes and return its head. For example, given 1 -> 2 -> 3 -> 4, return 2 -> 1 -> 4 -> 3. ''' class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None ...
tpalczew/Daily-coding
Python/Linked_lists/swap_every_two_nodes.py
.py
362c0492a378b380
7
0
''' Given a 2-D matrix representing an image, a location of a pixel in the screen and a color C, replace the color of the given pixel and all adjacent same colored pixels with C. For example, given the following matrix, and location pixel of (2, 2), and 'G' for green: B B W W W W W W W B B B Becomes B B G G G G G G ...
tpalczew/Daily-coding
Python/Recursion/2Dmatrix_changes.py
.py
5bc6b6b163530489
7
0
''' The power set of a set is the set of all its subsets. Write a function that, given a set, generates its power set. For example, given the set {1, 2, 3}, it should return {{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}. You may also use a list or array to represent a set. ''' ''' let's do a few examples ...
tpalczew/Daily-coding
Python/Recursion/the_power_set.py
.py
5c27ddddf8b69a04
7
0
''' Given a word W and a string S, find all starting indices in S which are anagrams of W. For example, given that W is "ab", and S is "abxaba", return 0, 3, and 4. So only checking forward, ab gives just 0, not 1 ''' print("Sliding Window") W = 'ab' S = 'abxaba' def solution(S, W): windowSize = len(W) r...
tpalczew/Daily-coding
Python/String_maniuplations/anagram.py
.py
0f8f036209e04cba
7
0
''' This problem was asked by Facebook. Given a 32-bit integer, return the number with its bits reversed. For example, given the binary number 1111 0000 1111 0000 1111 0000 1111 0000, return 0000 1111 0000 1111 0000 1111 0000 1111. ''' # What is really the problem here? # Is this just reversing this list? or may...
tpalczew/Daily-coding
Python/String_maniuplations/bit_int_reverse.py
.py
1fab2b5b9fbd913f
7
0
''' Given a string, find the length of the smallest window that contains every distinct character. Characters may appear more than once in the window. For example, given "jiujitsu", you should return 5, corresponding to the final five letters. ''' st = "jiujitsu" def solver(st): ''' this is our function t...
tpalczew/Daily-coding
Python/String_maniuplations/string_find_smallest_window.py
.py
be4cd0952c45abaa
7
0
''' A teacher must divide a class of students into two teams to play dodgeball. Unfortunately, not all the kids get along, and several refuse to be put on the same team as that of their enemies. Given an adjacency list of students and their enemies, write an algorithm that finds a satisfactory pair of teams, or r...
tpalczew/Daily-coding
Python/bipartite_graph.py
.py
1a30c0b843705f8c
7
0
#!/usr/bin/env python3 """ Every 30 minutes: - Validate all image/link URLs (manifest + README) - IMAGES: swap external <-> local asset in README based on health; refresh backups when origin recovers - LINKS : swap primary <-> backup (assets/backups/*.md) based on health; refresh snapshot when origin recovers - MARKERS...
blackphoenix42/blackphoenix42
scripts/monitor_and_rewrite.py
.py
5fcce8b824ee78d6
7.24
2
#!/usr/bin/env python3 """ README Health Checker Validates links, images, and content in README.md """ import requests import re import concurrent.futures from urllib.parse import urlparse from datetime import datetime def check_url(url, timeout=10): """Check if a URL is accessible""" try: # Skip data...
blackphoenix42/blackphoenix42
scripts/readme_health_check.py
.py
20d719d85a2afc22
7.24
2
"""D-FINE adapter: conventions, decoding, and the torchvision-compatible API.""" import numpy as np import pytest import torch from v2x_edge.models import DFineDetector, TrainableDFine, build_dfine_from_checkpoint from v2x_edge.models.dfine import ( coco_label_names, normalized_cxcywh_to_xyxy, xyxy_to_nor...
yobsanb/5G-V2X
test/test_dfine.py
.py
d550a1f5c62d367d
7.5
0
"""Pretrained-weight licence gate: restricted weights must never load silently.""" import warnings import pytest from v2x_edge.models import DEFAULT_DFINE_MODEL, DEFAULT_SEGFORMER_MODEL from v2x_edge.registry import ( PERMISSIVE_LICENCES, PRETRAINED_WEIGHT_LICENCES, warn_if_restricted_weights, weight...
yobsanb/5G-V2X
test/test_registry.py
.py
9ac9d001db30723d
7.5
0
"""Minimal API monetized with gringotts. Run: gringotts init-db gringotts create-user alice --credits 5 uvicorn examples.demo_app:app """ from fastapi import Depends, FastAPI from pydantic import BaseModel import gringotts from gringotts import CreditedUser, CreditPack, GringottsConfig, charge app = Fas...
gojiplus/gringotts
examples/demo_app.py
.py
d483b6ba93b7264f
7.15
1
"""Application wiring: `init_app` registers the 402 handler and mounts routes.""" from fastapi import FastAPI, Request from fastapi.responses import JSONResponse from starlette.routing import Match from .admin import build_admin_router from .config import GringottsConfig from .exceptions import PaymentRequiredError, ...
gojiplus/gringotts
src/gringotts/app.py
.py
033617946c5df192
7.15
1
"""API key generation, hashing, and user+key creation. Keys are prefixed `gk_`, stored only as SHA-256 hashes, and shown exactly once. """ import hashlib import hmac import secrets from sqlalchemy.orm import Session KEY_PREFIX = "gk_" def generate_api_key() -> str: """Return a new random API key with the `gk_...
gojiplus/gringotts
src/gringotts/auth.py
.py
a2dd5058b61ce328
7.15
1
"""Library configuration passed to `init_app`.""" import os from collections.abc import Callable from dataclasses import dataclass, field # Currencies with no minor unit — Stripe's amount is already the whole-unit value # (e.g. JPY 500 means ¥500, not ¥5.00). Source of truth: # https://docs.stripe.com/currencies#zero...
gojiplus/gringotts
src/gringotts/config.py
.py
907be6ff22e89827
7.15
1
"""Engine, session factory, and declarative base. `DATABASE_URL` selects the database (default: local SQLite file). """ import os from collections.abc import Iterator from sqlalchemy import create_engine, event from sqlalchemy.engine import Engine from sqlalchemy.orm import DeclarativeBase, Session, sessionmaker # ...
gojiplus/gringotts
src/gringotts/db.py
.py
3ad4b90f0a3646a4
7.15
1
"""FastAPI dependencies: authentication, admin gating, and the charge() core.""" import asyncio import logging from collections.abc import Callable, Iterator from fastapi import Depends, HTTPException, Request from sqlalchemy.orm import Session from . import crud, db from .db import get_session from .exceptions impo...
gojiplus/gringotts
src/gringotts/dependencies.py
.py
5eea2a4ab1553f62
7.15
1
"""Typed errors and the machine-readable 402 body.""" from typing import Any from fastapi import HTTPException class InvalidAPIKeyError(HTTPException): """Raised when the X-API-Key header is missing or matches no user (401).""" def __init__(self) -> None: """Build the fixed 401 response.""" ...
gojiplus/gringotts
src/gringotts/exceptions.py
.py
c9cd9c8ad6bd76c2
7.15
1
"""Forward-only, idempotent schema migrations run by ``gringotts migrate``. A ``gringotts_schema_version`` row records how far a database has been migrated. Steps introspect the live schema, so re-running is safe and a database created before this framework existed is brought forward without data loss. This owns every...
gojiplus/gringotts
src/gringotts/migrations.py
.py
0e510ad61d6c45ce
7.15
1
"""SQLAlchemy models: users and the append-only credit ledger.""" from datetime import UTC, datetime from sqlalchemy import ( CheckConstraint, DateTime, ForeignKey, Index, LargeBinary, String, ) from sqlalchemy.orm import Mapped, mapped_column, relationship from .db import Base class User(B...
gojiplus/gringotts
src/gringotts/models.py
.py
58eb8f24ce831642
7.15
1
"""Server-rendered HTML shells and fragments (no template engine, htmx-enhanced).""" import html from collections.abc import Sequence from .models import CreditTransaction _BASE_CSS = """ * { box-sizing: border-box; } body { font-family: system-ui, sans-serif; max-width: 64rem; margin: 2rem auto; paddin...
gojiplus/gringotts
src/gringotts/pages.py
.py
2f9614058b0a0c99
7.15
1
import numpy as np import torch from fastai.torch_core import TensorBase vocab_to_int = {"A": 1, "C": 2, "G": 3, "T": 4, "N": 0} int_to_vocab = dict(zip(vocab_to_int.values(), vocab_to_int.keys())) class TensorDNA(TensorBase): def __str__(self): seq_str = self.as_chars() return f"{seq_str} [{len(...
rbturnbull/corgi
corgi/archive/tensor.py
.py
b84786f1800770ab
7.24
2
from dataclasses import dataclass from typing import Optional import pandas as pd import random import torch from torch import tensor import torch.nn as nn from zlib import adler32 from fastcore.transform import Transform import numpy as np from Bio.SeqRecord import SeqRecord from scipy.stats import nbinom from .tenso...
rbturnbull/corgi
corgi/archive/transforms.py
.py
d915557c8d1c1c0e
7.24
2
from pathlib import Path from torchapp.modules import GeneralLightningModule import numpy as np import os from rich.console import Console console = Console() class CorgiLightningModule(GeneralLightningModule): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.embeddings_...
rbturnbull/corgi
corgi/modules.py
.py
93bb19362a1ed0e8
7.24
2
from typing import TYPE_CHECKING, List, Optional from collections import Counter from pathlib import Path from attrs import define, field from collections import UserDict import pickle import hashlib import typer from rich.progress import track if TYPE_CHECKING: from hierarchicalsoftmax import SoftmaxNode def s...
rbturnbull/corgi
corgi/seqtree.py
.py
be15872c0fc1aa0d
7.24
2
""" need to download the files from endomondo and store it in Workous dir in running_page """ import json import os from collections import namedtuple from datetime import datetime, timedelta import polyline from config import BASE_TIMEZONE, ENDOMONDO_FILE_DIR, JSON_FILE, SQL_FILE from generator import Generator from...
wuleiyuan/wuleiyuan.github.io
scripts/endomondo_sync.py
.py
8b33bbaa3a57a875
7.15
1
""" Python 3 API wrapper for Garmin Connect to get your statistics. Copy most code from https://github.com/cyberjunky/python-garminconnect """ import argparse import asyncio import json import logging import os import re import sys import time import traceback import aiofiles import cloudscraper import httpx from con...
wuleiyuan/wuleiyuan.github.io
scripts/garmin_sync.py
.py
8a90a60537b795bf
7.15
1
"""Draw a circular Poster.""" # Copyright 2016-2019 Florian Pigorsch & Contributors. All rights reserved. # # Use of this source code is governed by a MIT-style # license that can be found in the LICENSE file. import argparse import calendar import datetime import math from typing import List, Optional import svgwrit...
wuleiyuan/wuleiyuan.github.io
scripts/gpxtrackposter/circular_drawer.py
.py
446275ba995a71f9
7.15
1
"""Draw a grid poster.""" # Copyright 2016-2019 Florian Pigorsch & Contributors. All rights reserved. # # Use of this source code is governed by a MIT-style # license that can be found in the LICENSE file. import svgwrite from .exceptions import PosterError from .poster import Poster from .track import Track from .tr...
wuleiyuan/wuleiyuan.github.io
scripts/gpxtrackposter/grid_drawer.py
.py
40674100affb9868
7.15
1
"""Create and maintain info about a given activity track (corresponding to one GPX file).""" # Copyright 2016-2019 Florian Pigorsch & Contributors. All rights reserved. # 2019-now yihong0618 Florian Pigorsch & Contributors. All rights reserved. # Use of this source code is governed by a MIT-style # license that can be ...
wuleiyuan/wuleiyuan.github.io
scripts/gpxtrackposter/track.py
.py
eae7db6340c6cc59
7.15
1
"""Handle parsing of GPX files""" # Copyright 2016-2019 Florian Pigorsch & Contributors. All rights reserved. # 2019-now Yihong0618 # # Use of this source code is governed by a MIT-style # license that can be found in the LICENSE file. import logging import os import sys sys.path.append(os.path.join(os.path.dirname...
wuleiyuan/wuleiyuan.github.io
scripts/gpxtrackposter/track_loader.py
.py
fbd4ed9f31deee27
7.15
1
"""Contains the base class TracksDrawer, which other Drawers inherit from.""" # Copyright 2016-2019 Florian Pigorsch & Contributors. All rights reserved. # # Use of this source code is governed by a MIT-style # license that can be found in the LICENSE file. import argparse import svgwrite from .poster import Poster ...
wuleiyuan/wuleiyuan.github.io
scripts/gpxtrackposter/tracks_drawer.py
.py
bcb1b33b56312c92
7.15
1
"""Assorted utility methods for use in creating posters.""" # Copyright 2016-2019 Florian Pigorsch & Contributors. All rights reserved. # # Use of this source code is governed by a MIT-style # license that can be found in the LICENSE file. import locale import math from datetime import datetime from typing import List...
wuleiyuan/wuleiyuan.github.io
scripts/gpxtrackposter/utils.py
.py
18cecc58c3ce510c
7.15
1
"""Represent a range of numerical values""" # Copyright 2016-2019 Florian Pigorsch & Contributors. All rights reserved. # # Use of this source code is governed by a MIT-style # license that can be found in the LICENSE file. class ValueRange: """Represent a range of numerical values. Attributes: _lowe...
wuleiyuan/wuleiyuan.github.io
scripts/gpxtrackposter/value_range.py
.py
5418ab86ff68a030
7.15
1
"""Represent x,y coords with properly overloaded operations.""" # Copyright 2016-2019 Florian Pigorsch & Contributors. All rights reserved. # # Use of this source code is governed by a MIT-style # license that can be found in the LICENSE file. from typing import Tuple, Union class XY: """Represent x,y coords wit...
wuleiyuan/wuleiyuan.github.io
scripts/gpxtrackposter/xy.py
.py
d03a00727f62cf62
7.15
1
"""Represent a range of years, with ability to update based on a track""" # Copyright 2016-2019 Florian Pigorsch & Contributors. All rights reserved. # # Use of this source code is governed by a MIT-style # license that can be found in the LICENSE file. import datetime import re from typing import Optional class Yea...
wuleiyuan/wuleiyuan.github.io
scripts/gpxtrackposter/year_range.py
.py
e87358eeac465470
7.15
1
import argparse import json import logging import os.path import time from collections import namedtuple from datetime import datetime, timedelta from xml.etree import ElementTree import gpxpy.gpx import httpx from config import ( BASE_TIMEZONE, BASE_URL, GPX_FOLDER, JSON_FILE, NIKE_CLIENT_ID, ...
wuleiyuan/wuleiyuan.github.io
scripts/nike_sync.py
.py
5a2fb8c06b9e5899
7.15
1
import argparse import asyncio from datetime import datetime, timedelta from io import BytesIO from xml.etree import ElementTree import gpxpy import gpxpy.gpx from config import STRAVA_GARMIN_TYPE_DICT from garmin_sync import Garmin from strava_sync import run_strava_sync from utils import make_strava_client def ge...
wuleiyuan/wuleiyuan.github.io
scripts/strava_to_garmin_sync.py
.py
575aed3c4aeafd16
7.15
1
""" Mathematical rank scoring and percentile evaluation using log-normal distributions. """ import math from typing import Tuple from src.constants import ( COMMITS_MEDIAN, COMMITS_WEIGHT, PRS_MEDIAN, PRS_WEIGHT, ISSUES_MEDIAN, ISSUES_WEIGHT, REVIEWS_MEDIAN, REVIEWS_WEIGHT, STARS_MEDIAN, STARS_WEIG...
ACFHarbinger/ACFHarbinger
src/rank_calculator.py
.py
b921ace80b1b9206
7
0
""" SVG Template Renderer: Loads modular CSS stylesheets and SVG component templates to render polished telemetry cards. """ import math from pathlib import Path from string import Template from typing import Dict, Any TEMPLATES_DIR = Path(__file__).parent.parent / "templates" def load_styles() -> str: """Reads ...
ACFHarbinger/ACFHarbinger
src/svg_renderer.py
.py
fed1767e964899ab
7
0
from io import StringIO from pathlib import Path from tempfile import TemporaryDirectory from unittest import mock import pytest from django.core import mail from django.core.management import call_command from certification.certifications.models import Certification, QuizCertification from lab.tests.factories import...
betagouv/euphrosyne
certification/notifications/tests/test_send_notifications_command.py
.py
1ba10313df81e6d7
7.85
4
"""One-shot prep so recording works under Wayland. The pad itself needs nothing. Capture does: on Linux Wayland the only reliable source is the kernel input nodes, which means the ``evdev`` package and read access to ``/dev/input/event*``. Package install can be done as the same user. Device access needs root once (`...
maduinos/macroKey
macrokey/capture_setup.py
.py
62f06a31be7119a4
7
0
"""Profile <-> device blob. Byte-for-byte mirror of the EEPROM layout in ``firmware/src/Profile.h``. If that header changes, this module changes with it and ``SCHEMA`` goes up. """ from __future__ import annotations from .model import ( ACTION_TYPE_IDS, EDITABLE_GESTURES, KEY_COUNT, LED_COUNT, MA...
maduinos/macroKey
macrokey/config/binary.py
.py
601b0aca90a608e5
7
0
"""Key name <-> byte translation for the Arduino ``Keyboard`` library. The firmware stores one modifier mask byte plus one keycode byte per ``key`` action. Printable ASCII is passed through as-is; everything else uses the ``KEY_*`` constants from ``Keyboard.h``, which start at 0x80. """ from __future__ import annotat...
maduinos/macroKey
macrokey/config/keycodes.py
.py
9000e47dda852367
7
0
"""Where profiles and settings live, and how older files are brought forward.""" from __future__ import annotations import json import logging import os import shutil import sys import threading from dataclasses import asdict, dataclass from datetime import datetime from pathlib import Path from typing import Any fr...
maduinos/macroKey
macrokey/config/store.py
.py
1c85cf21ed2e329a
7
0
"""Finding the keypad among the serial ports on the machine.""" from __future__ import annotations from dataclasses import dataclass try: # pyserial is optional so the UI and tests run without hardware installed. from serial.tools import list_ports except ModuleNotFoundError: # pragma: no cover - exercised onl...
maduinos/macroKey
macrokey/device/discovery.py
.py
b972927db894eb09
7
0
"""Codec for the line protocol in ``docs/PROTOCOL.md``. Pure functions over strings: no serial port, no threads. That keeps the wire format testable without hardware, which is most of why it is a separate module. """ from __future__ import annotations from dataclasses import dataclass, field from typing import Any ...
maduinos/macroKey
macrokey/device/protocol.py
.py
cf7c2decaca6ea06
7
0
"""Logging shared by the CLI and the standalone GUI launcher.""" from __future__ import annotations import logging import logging.handlers from pathlib import Path def setup_logging(verbose: bool = False) -> None: """Keep a diagnostic log without duplicating handlers on repeated setup. Recordings are often...
maduinos/macroKey
macrokey/logging_setup.py
.py
e0ceb1e5592412bf
7
0
"""Raw capture events, before any interpretation.""" from __future__ import annotations from dataclasses import dataclass, field KEY_DOWN = "key_down" KEY_UP = "key_up" MOUSE_CLICK = "mouse_click" #: The button coming back up. Kept as its own event rather than folded into the #: press, because a press and a release ...
maduinos/macroKey
macrokey/recorder/events.py
.py
e078f5c3c22b9cd5
7
0
"""Turns a raw capture into something worth replaying. Replaying keystrokes exactly as typed is almost always wrong: it reproduces human typing speed, splits a word into thirty events, and records the modifier dance instead of the shortcut. This module folds all of that away. """ from __future__ import annotations f...
maduinos/macroKey
macrokey/recorder/normalize.py
.py
c212939e5c1e8573
7
0
"""PySide6 view. The only package that imports a UI toolkit.""" from __future__ import annotations __all__ = ["MissingToolkit", "run_gui"] MISSING_QT = ( "The editor window needs PySide6.\n" " • Preferred: ./build_release.sh → releases/linux/macrokey\n" " • Developers: python -m pip install -r requirem...
maduinos/macroKey
macrokey/ui/__init__.py
.py
71dca6dabc960e07
7
0
"""Turning profile objects into the words the window shows. Apart from the widgets because none of it needs Qt to be reasoned about, and because the wording is the part most often argued with. """ from __future__ import annotations import os from ..config import Action, Profile from ..recorder.recorder import Recor...
maduinos/macroKey
macrokey/ui/describe.py
.py
28a2df59cd9dc69c
7
0
"""Small widgets the editor is built out of. Each one exists because the stock control got something wrong for this job: a shortcut typed instead of pressed, a port list that went stale the moment the window opened. """ from __future__ import annotations from PySide6.QtCore import Qt, Signal from PySide6.QtWidgets i...
maduinos/macroKey
macrokey/ui/widgets.py
.py
abd76641fc06c9f3
7
0
"""Shared EEPROM macro-pool fill, as shown in the editor.""" from __future__ import annotations from macrokey.config.model import MACRO_RECORD_CAPACITY, Action, macro_storage_usage def test_an_empty_profile_is_fully_free() -> None: used, capacity, used_pct, free_pct = macro_storage_usage([]) assert (used, c...
maduinos/macroKey
tests/test_macro_storage.py
.py
95a8278616fcd7ee
7.5
0
"""Wire format codec. Pure functions, so no device is needed to run these.""" from macrokey.device import protocol from macrokey.device.protocol import Hello, KeyEvent, RecordRequest class TestMessageInt: def test_zero_survives(self): """Regression: ``message.int(k, -1) or -1`` turned a valid 0 into -1."...
maduinos/macroKey
tests/test_protocol.py
.py
92421bc114de5e4a
7.5
0
# SPDX-License-Identifier: MIT """Screenshot every Animal-AI arena from the player's overhead camera. Opens the arenas in Unity's play mode the same way scripts/play_animalai.py does, switches the camera with C, then walks the whole set: let the arena settle, grab the player window, press R for the next arena. The res...
SakodaShintaro/vla_streaming_rl
scripts/capture_animalai.py
.py
cf33f62c2be0304e
7
0
# SPDX-License-Identifier: MIT """Play the Animal-AI curriculum arenas by hand. Merges every arena YAML under ``--arena-root`` into one multi-arena ArenaConfig and opens it in the Unity player, where W/A/S/D drives the agent and R (or collecting a reward) moves on to the next arena in the file. The arenas play in sor...
SakodaShintaro/vla_streaming_rl
scripts/play_animalai.py
.py
5b96f4b39f556819
7
0
"""Plot results (single-run layout) for one environment. Given the parent directory produced by ``exp.sh`` (one subdirectory per learning-mode variant, each holding ``log_episode.tsv`` and a local wandb run), this renders three figures for the paper: * ``<prefix>_score.pdf`` -- trailing-average score / success r...
SakodaShintaro/vla_streaming_rl
scripts/plot_result.py
.py
83d8937b0abdd403
7
0
# SPDX-License-Identifier: MIT """Run every Animal-AI Olympics arena exactly once with a frozen policy. Loads a trained checkpoint (weights only), then sweeps every XX-YY-ZZ.yaml arena under external/animal-ai/configs/competition/ in order, one episode each, with the network in eval mode and no optimizer step ever tak...
SakodaShintaro/vla_streaming_rl
scripts/test_trained_agent.py
.py
857b155e09f9a26d
7.5
0
# SPDX-License-Identifier: MIT from abc import ABC, abstractmethod from dataclasses import dataclass from typing import Any import numpy as np @dataclass class StepResult: """Structured return value of an agent's ``select_action`` / ``step``. Replaces the old free-form ``info`` dict, which mixed three unrel...
SakodaShintaro/vla_streaming_rl
src/vla_streaming_rl/agents/base.py
.py
e92cef20f375d718
7
0
# SPDX-License-Identifier: MIT """Drive a Bench2Drive ``RouteScenario`` from inside our gym env. The leaderboard evaluator wraps ``RouteScenario`` (ego spawn, scripted scenarios, ``BackgroundBehavior`` traffic, parked vehicles) inside a ``ScenarioManager`` thread loop. The training env doesn't run that manager — this ...
SakodaShintaro/vla_streaming_rl
src/vla_streaming_rl/envs/bench2drive_scenario_runtime.py
.py
27106d693e2306cd
7
0
# SPDX-License-Identifier: MIT """Launch + wire up a CARLA server from pure Python. ``train_carla.sh`` does two shell-only things before ``train.py`` runs: it exports ``PYTHONPATH`` (CARLA's ``PythonAPI/carla`` for the ``agents`` package, plus Bench2Drive's ``leaderboard`` / ``scenario_runner``) and ``setsid``-launche...
SakodaShintaro/vla_streaming_rl
src/vla_streaming_rl/envs/carla_bootstrap.py
.py
99d7f22c23d2dc67
7
0
# SPDX-License-Identifier: MIT """Pure observation / action helpers for the CARLA leaderboard setup. This module is the single source of truth for the observation and action contracts used by both the training environment (``carla_leaderboard_env.py``) and evaluation agents (e.g. the Bench2Drive team-code agent). Noth...
SakodaShintaro/vla_streaming_rl
src/vla_streaming_rl/envs/carla_obs.py
.py
d5923113d468a57c
7
0