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 module provides the KGProxy class, which represents a
KGObject whose type and identifier are known but whose other metadata
have not been retrieved from the KG.
"""
# Copyright 2018-2026 CNRS and fairgraph authors and/or their employers
# Licensed under the Apache License, Version 2.0 (the "License");
# you ... | apdavison/fairgraph | fairgraph/kgproxy.py | .py | 0fcfbbdffab05e4b | 7.52 | 10 |
"""
This module provides the KGQuery class, which represents one or more
KGObjects identified by a range of possible types and by some of their
metadata, but whose specific identifier(s) is/are not known.
"""
# Copyright 2018-2026 CNRS and fairgraph authors and/or their employers
# Licensed under the Apache License, ... | apdavison/fairgraph | fairgraph/kgquery.py | .py | 534df1b4927d07f4 | 7.52 | 10 |
import sys
from . import v4, v5
# Backwards compatibility: expose v4 modules at top level so that
# `import fairgraph.openminds.core` continues to work
from .v4 import chemicals, computation, controlled_terms, core, ephys, publications, sands, specimen_prep, stimulation
def set_error_handling(value):
"""Set err... | apdavison/fairgraph | fairgraph/openminds/__init__.py | .py | 8b33981e568e425f | 7.52 | 10 |
import sys
from fairgraph.introspection import (
list_kg_classes as _lkgc,
list_embedded_metadata_classes as _lemc,
set_error_handling as _seh,
)
from .amount_of_chemical import AmountOfChemical
from .chemical_mixture import ChemicalMixture
from .chemical_substance import ChemicalSubstance
from .product_so... | apdavison/fairgraph | fairgraph/openminds/v4/chemicals/__init__.py | .py | 9c43b1cd54124837 | 7.52 | 10 |
import sys
from fairgraph.introspection import (
list_kg_classes as _lkgc,
list_embedded_metadata_classes as _lemc,
set_error_handling as _seh,
)
from .data_analysis import DataAnalysis
from .data_copy import DataCopy
from .environment import Environment
from .generic_computation import GenericComputation
... | apdavison/fairgraph | fairgraph/openminds/v4/computation/__init__.py | .py | 4a6ff2c4777c999b | 7.52 | 10 |
import json
import logging
import os
from pathlib import Path
import numpy as np
import pandas as pd
import requests
from morphapi.morphology.morphology import Neuron
from morphapi.paths_manager import Paths
from morphapi.utils.data_io import connected_to_internet
logger = logging.getLogger(__name__)
columns_of_int... | brainglobe/morphapi | morphapi/api/allenmorphology.py | .py | c08f713c4583fcf4 | 7.63 | 17 |
import shutil
import zipfile
from pathlib import Path
import pandas as pd
from brainglobe_atlasapi import BrainGlobeAtlas
from brainglobe_atlasapi.utils import retrieve_over_http
from brainglobe_space import SpaceConvention
from rich.progress import track
from morphapi.morphology.morphology import Neuron
from morphap... | brainglobe/morphapi | morphapi/api/mpin_celldb.py | .py | b495dc7f729aafde | 7.63 | 17 |
import logging
import os
import requests
from morphapi.morphology.morphology import Neuron
from morphapi.paths_manager import Paths
from morphapi.utils.webqueries import connected_to_internet, request
logger = logging.getLogger(__name__)
class NeuroMorpOrgAPI(Paths):
# Use the URL as advised in the API docs:
... | brainglobe/morphapi | morphapi/api/neuromorphorg.py | .py | 7e597f851126bfde | 7.63 | 17 |
"""
Class to create and store paths to a number of folders uesed to save/load data
"""
from pathlib import Path
# Default paths for Data Folders (store stuff like object meshes,
# neurons morphology data etc)
default_paths = dict(
# APIs caches
allen_morphology_cache="allen_morphology_cache",
mouselight_c... | brainglobe/morphapi | morphapi/paths_manager.py | .py | 68adb22852f6c19a | 7.63 | 17 |
import ssl
import time
import requests
from requests.adapters import HTTPAdapter
from urllib3.util.ssl_ import create_urllib3_context
from morphapi.utils.data_io import connected_to_internet
mouselight_base_url = "https://ml-neuronbrowser.janelia.org/"
CIPHERS = ":HIGH:!DH:!aNULL"
class NoDhAdapter(HTTPAdapter):
... | brainglobe/morphapi | morphapi/utils/webqueries.py | .py | 8eb1948852c59047 | 7.63 | 17 |
import re
from pathlib import Path
import numpy as np
import pytest
from morphapi.api.allenmorphology import AllenMorphology
from morphapi.api.mouselight import MouseLightAPI
from morphapi.api.neuromorphorg import NeuroMorpOrgAPI
def test_neuromorpho_download(tmpdir):
api = NeuroMorpOrgAPI(base_dir=tmpdir)
... | brainglobe/morphapi | tests/test_download.py | .py | 55e22d83b5aaa4d0 | 7.13 | 17 |
# -*- coding: UTF-8 -*-
"""
emoji.core
~~~~~~~~~~
Core components for emoji.
"""
import re
import sys
from emoji_fixed import unicode_codes
__all__ = ['emojize', 'demojize', 'get_emoji_regexp','emoji_lis']
PY2 = sys.version_info[0] == 2
_EMOJI_REGEXP = None
_DEFAULT_DELIMITER = ":"
def emojize(string, use_... | pongo/rapturebot | emoji_fixed/core.py | .py | d77be03b84bc756f | 7.5 | 9 |
import configparser
from datetime import datetime, timezone
from typing import Optional
class LatestStamps:
"""LatestStamps class.
Convenience class for retrieving and storing data from the :option:`--latest-stamps` file.
:param latest_stamps_file: path to file.
.. versionadded:: 4.8"""
PROFILE... | pongo/rapturebot | packages/instaloader_proxy/lateststamps.py | .py | f3636520c27e2013 | 8 | 9 |
import functools
import itertools
import random
import re
class PostCorrection:
@classmethod
def get_post_correction(cls, words):
result = []
re_chto = re.compile('^сьто')
exists_words = set()
for word in words:
if word in exists_words:
if re_chto.se... | pongo/rapturebot | src/commands/khaleesi/khaleesi.py | .py | 1ff2deae35ac84a6 | 7.5 | 9 |
from typing import Tuple, Optional
import telegram
from telegram.ext import run_async
from src.commands.khaleesi.khaleesi import Khaleesi
from src.utils.handlers_decorators import chat_guard, collect_stats, command_guard
@run_async
@chat_guard
@collect_stats
@command_guard
def chat(bot: telegram.Bot, update: telegr... | pongo/rapturebot | src/commands/khaleesi/khaleesi_handler.py | .py | 9553837c691b892a | 7.5 | 9 |
import random
from datetime import datetime
from typing import Optional
from src.commands.khaleesi.khaleesi import KhaleesiUtils
from src.utils.cache import cache
class RandomKhaleesi:
@classmethod
def is_its_time_for_khaleesi(cls, chat_id: int) -> bool:
# постить можно раз в N часов
limited ... | pongo/rapturebot | src/commands/khaleesi/random_khaleesi.py | .py | b5c22a174b55e843 | 7.5 | 9 |
import datetime
import random
from typing import Optional, List, Type, Dict, Union
import telegram
from src.commands.khaleesi.khaleesi import Khaleesi
from src.models.chat_user import ChatUser
from src.models.user import User
from src.modules.night_watch import get_hour
from src.utils.cache import Cache
from src.util... | pongo/rapturebot | src/commands/ment/ment.py | .py | 057c986c5adb2eed | 7.5 | 9 |
import random
from collections import OrderedDict
from collections import deque
from datetime import datetime
import telegram
from telegram.ext import run_async
from src.config import CONFIG
from src.utils.cache import cache
from src.utils.handlers_decorators import chat_guard, collect_stats, command_guard
MONTH = 3... | pongo/rapturebot | src/commands/orzik.py | .py | 24359e28e309081a | 7.5 | 9 |
import os
import requests
from urllib3.util.retry import Retry
from requests.adapters import HTTPAdapter
from urllib.parse import urlparse
from requests.exceptions import RequestException
from requests.exceptions import HTTPError
def download(url: str, output_path: str = None, file_name: str = None):
"""
Down... | zaironjacobs/get-gecko-driver | get_gecko_driver/downloader.py | .py | cfc833a44cf03cd2 | 7.45 | 7 |
import os
import requests
from urllib3.util.retry import Retry
from requests.adapters import HTTPAdapter
from urllib.parse import urlparse
from requests.exceptions import RequestException
from requests.exceptions import HTTPError
def download(url: str, output_path: str = None, file_name: str = None):
"""
Down... | zaironjacobs/get-chrome-driver | get_chrome_driver/downloader.py | .py | 9998f86ceaf587c9 | 7.66 | 20 |
#! /usr/bin/env python3
# Author: Anton Deguet
# Date: 2018-09-29
#
# Copyright (c) 2018-2025 Johns Hopkins University, University of Washington, Worcester Polytechnic Institute
# Released under MIT License
# Start your crtk compatible device first!
# dVRK example:
# > rosrun dvrk_robot dvrk_console_json -j <console-... | collaborative-robotics/crtk_python_client | scripts/crtk_teleop_example.py | .py | 4bb67b396fef0b89 | 7.52 | 10 |
#! /usr/bin/env python3
# Author: Anton Deguet
# Created on: 2026-05-31
#
# Copyright (c) 2015-2025 Johns Hopkins University, University of Washington, Worcester Polytechnic Institute
# Released under MIT License
# Start a single arm using
# > ros2 run dvrk_robot dvrk_console_json -j <console-file>
# Make sure to en... | collaborative-robotics/crtk_python_client | scripts/crtk_xyz.py | .py | 3449eb2701fcd3b7 | 7.52 | 10 |
#!/usr/bin/env python3
"""Create a new Python library project with modern best practices.
Usage:
python create_project.py my-library
python create_project.py my-library --author "Your Name" --email you@example.com
"""
import argparse
import os
from pathlib import Path
from textwrap import dedent
def create_... | Duan-JM/dotfiles | ai-settings/skills/code-skills/python-skills/project-setup/scripts/create_project.py | .py | de6ed54c1eef7e6b | 7.52 | 10 |
#!/usr/bin/env python3
"""Bump version number in project files.
Usage:
python bump_version.py patch # 1.2.3 -> 1.2.4
python bump_version.py minor # 1.2.3 -> 1.3.0
python bump_version.py major # 1.2.3 -> 2.0.0
python bump_version.py 1.5.0 # Set specific version
"""
import argparse
import re
imp... | Duan-JM/dotfiles | ai-settings/skills/code-skills/python-skills/release-management/scripts/bump_version.py | .py | c726511e28ad2443 | 7.52 | 10 |
#!/usr/bin/env python3
"""行业规则包加载、校验与匹配。
规则包是机器可检查的 JSON 文件,仅使用标准库读取与 schema 校验。它服务两类场景:
1. ``infer`` 阶段根据 ``business_model_tags`` 选择 1-3 条行业规则;
2. ``check_evidence`` 阶段按已选择规则检查章节是否覆盖必备 KPI 语义组。
"""
from __future__ import annotations
import json
import re
from dataclasses import dataclass
from pathlib import Path
f... | Duan-JM/dotfiles | ai-settings/warzooms/financial-company-warzoom/scripts/industry_rules.py | .py | 7610449c531a8aef | 7.52 | 10 |
"""合并已生成的公司调研章节为完整报告。
排序规则:
``output/sections/*.md`` 按文件名升序合并。新约定章节编号:
- ``00_overview.md``(``rough`` 默认;``--with-overview`` 可选)—— 粗读闸门或投资要点概览,置于报告最前
- ``01_...`` ~ ``08_...`` —— 标准 8 章
- ``09_research_decision.md``(``rough`` 默认;``--with-decision`` 可选)—— 研究决策章
- ``10_earnings_...`` ~ ``18_earnings_... | Duan-JM/dotfiles | ai-settings/warzooms/financial-company-warzoom/scripts/merge.py | .py | b9a85e0433b32a77 | 7.52 | 10 |
#!/usr/bin/env python3
"""流水线脚本共享的哈希与章节拼接工具。"""
from __future__ import annotations
import hashlib
from pathlib import Path
from typing import Iterable
def sha256_bytes(data: bytes) -> str:
"""返回带算法前缀的 SHA-256。"""
return f"sha256:{hashlib.sha256(data).hexdigest()}"
def sha256_text(text: str) -> str:
"... | Duan-JM/dotfiles | ai-settings/warzooms/financial-company-warzoom/scripts/pipeline_common.py | .py | 1fc12259b4d35146 | 7.52 | 10 |
#!/usr/bin/env python3
"""粗读优先的估值计算器。
脚本只使用标准库,输入 / 输出均为 JSON。它只做确定性计算,不补数、不联网、不读取
output 生成物;缺少字段时返回 ``unavailable`` 与缺失项,非法输入则拒绝并返回错误。
"""
from __future__ import annotations
import argparse
import json
import math
import sys
from dataclasses import dataclass
from pathlib import Path
from typing import Any
Number... | Duan-JM/dotfiles | ai-settings/warzooms/financial-company-warzoom/scripts/valuation_calculator.py | .py | 4dde2629fb619131 | 7.52 | 10 |
"""合并已生成的交底书章节为完整文档。"""
import os
import glob
# 硬编码路径(从项目根目录运行)
SECTIONS_DIR = "output/sections"
MERGED_FILE = "output/disclosure.md"
IDEA_FILE = "input/invention_idea.md"
def read_file(file_path):
"""读取文件内容,文件不存在则返回空字符串。"""
if not os.path.exists(file_path):
return ""
with open(file_path, "r", e... | Duan-JM/dotfiles | ai-settings/warzooms/patent-warzoom/scripts/merge.py | .py | 29580ab1b7aea3da | 7.52 | 10 |
"""
Helper functions for the ReadmeGenerator module.
"""
try:
from scraper import get_projects, get_youtube_data, get_pinned
except ImportError:
from .scraper import get_projects, get_youtube_data, get_pinned
def process_title(title, context):
"""
Process the title by replacing placeholders with actu... | HectorPulido/HectorPulido | ReadmeGenerator/helpers.py | .py | cbc14f1ebf5c9312 | 7.57 | 13 |
"""
This script generates a README.md file and category-specific markdown files
for a GitHub profile based on a configuration file. It reads the configuration
from a JSON file, processes the data, and generates the markdown files.
"""
import json
import sys
try:
from helpers import types, set_config
except Import... | HectorPulido/HectorPulido | ReadmeGenerator/main.py | .py | 4ddb450f7a3fd4a9 | 7.57 | 13 |
"""
Scraper module for GitHub and YouTube data.
"""
import json
import os
import re
import sys
import time
import xml.etree.ElementTree as ET
import requests
from bs4 import BeautifulSoup
HEADERS = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 ... | HectorPulido/HectorPulido | ReadmeGenerator/scraper.py | .py | f334f443604e3a6a | 7.57 | 13 |
import sys
from typing import (
Any,
cast,
)
import rlp
from eth_utils import (
keccak,
)
from eth_utils.toolz import (
pipe,
)
from hexbytes import (
HexBytes,
)
if sys.version_info >= (3, 11):
from typing import (
Self,
)
else:
from typing_extensions import (
Self,
... | ApeWorX/eth-rlp | eth_rlp/main.py | .py | 5e6383db7ea7a6e0 | 7.63 | 17 |
"""Statistics and card affinity over a collection of decks (e.g. the TWDA).
A deck collection is treated as a statistical sample. ``played``, ``stats`` and
``affinity`` are read-only summaries; ``build_deck`` synthesizes a new TWDA-like
decklist from the sample. Cards are resolved through a loaded ``CardDict`` and
res... | lionel-panhaleux/krcg | krcg/analyzer.py | .py | d972f0cce1949101 | 7.56 | 12 |
"""Cards named in other cards' card text.
Upstream marks a referenced name with slashes ("cards named /Choir/"), which is
ambiguous with the slash of "and/or"; `scripts/fix_csv.py` resolves that at sync
time and rewrites every reference as `<Card Name>`. The marker stays in the text,
as `{Card Name}` does in a ruling,... | lionel-panhaleux/krcg | krcg/card_references.py | .py | 22dd615e0b68b632 | 7.56 | 12 |
"""Resolve a structured country from a TWDA place line."""
import logging
from . import models
logger = logging.getLogger("krcg")
# canonical country name -> (ISO 3166-1 alpha-2 code, continent)
_COUNTRIES: dict[str, tuple[str, models.Continent]] = {
"Australia": ("AU", models.Continent.OCEANIA),
"Austria":... | lionel-panhaleux/krcg | krcg/countries.py | .py | 9926cec2918e74f8 | 7.56 | 12 |
"""Load the cards library: a ready-to-use `collections.CardDict`.
Three entry points, all returning an indexed `CardDict` (look cards up by id or
name, run `search`/`complete`):
- `load()`: fast default — a version-keyed pickle cache, else `load_local()`.
- `load_local()`: build from the packaged VEKN CSVs and ruling... | lionel-panhaleux/krcg | krcg/loader.py | .py | 4299e6851a7544ae | 7.56 | 12 |
"""Model definitions."""
from __future__ import annotations
from dataclasses import dataclass, field, fields
import datetime
from enum import StrEnum
from typing import Literal
FILING_PREFIXES = ["A", "An", "The", "El", "La", "Le", "Un", "Une", "Les", "Una"]
@dataclass
class NameVariant:
"""A variant of a card... | lionel-panhaleux/krcg | krcg/models.py | .py | 7059c35fc0429875 | 7.56 | 12 |
"""External tools providers: Deck building, archive, online play."""
from typing import Any
import aiohttp
import arrow
import itertools
import logging
import urllib.parse
from . import models
from . import utils
from . import collections
LOG = logging.getLogger("krcg")
async def get_amaranth_cards_map(
sessio... | lionel-panhaleux/krcg | krcg/providers.py | .py | 1d914a737718a4ca | 7.56 | 12 |
"""Rulings parsing."""
from __future__ import annotations
import collections.abc
import datetime
import importlib.resources
import re
import typing
import urllib.request
import yaml
from . import models
from .collections import CardDict
RULINGS_GITHUB = (
"https://raw.githubusercontent.com/vtes-biased/vtes-rul... | lionel-panhaleux/krcg | krcg/rulings.py | .py | c7a2f4e5437ef842 | 7.56 | 12 |
#!/usr/bin/env python3
"""Fetch TWDA files from GitHub."""
import argparse
import lzma
import msgspec.json
import pathlib
import sys
from krcg import collections
from krcg import loader
from krcg import parser
from krcg import twda
def fetch_twda(path: pathlib.Path, cards: collections.CardDict) -> None:
"""Fetc... | lionel-panhaleux/krcg | krcg/scripts/fetch_twda.py | .py | 207b5e3d37534fb5 | 7.56 | 12 |
"""TWDA: the Tournament Winning Decks Archive.
The archive is a ``dict[str, models.Deck]`` keyed by deck id. A compressed
snapshot ships with the package, so ``load_local()`` works offline; online
tools can use ``load_online()`` to fetch the latest archive from KRCG static.
"""
import importlib.resources
import io
im... | lionel-panhaleux/krcg | krcg/twda.py | .py | 108eb0f9d77b20ec | 7.56 | 12 |
"""Deck utilities."""
from collections.abc import Generator
import itertools
import msgspec
import unicodedata
import unidecode
from .. import models
from .string import normalize
#: type order for deck display
TYPE_ORDER = [
"Master",
"Conviction",
"Action",
"Action/Combat",
"Action/Reaction",
... | lionel-panhaleux/krcg | krcg/utils/deck.py | .py | 9b60137edc676bb4 | 7.56 | 12 |
"""Fuzzy dictionary."""
from typing import Any, cast
from collections.abc import (
Hashable,
ItemsView,
Iterator,
Sequence,
Mapping,
MutableMapping,
)
import collections
import difflib
import logging
from .string import normalize
LOG = logging.getLogger("krcg")
class FuzzyDict[H: Hashable... | lionel-panhaleux/krcg | krcg/utils/fuzzy_dict.py | .py | 41077d933b5cfd71 | 7.56 | 12 |
"""A prefix tree for scored, case-insensitive text search."""
from typing import Any, SupportsIndex, cast
from collections.abc import Hashable, Mapping
import collections
import logging
import re
from .string import normalize
LOG = logging.getLogger("krcg")
def _default_trie_factory() -> "collections.defaultdict[A... | lionel-panhaleux/krcg | krcg/utils/trie.py | .py | a878c5d39e10547f | 7.56 | 12 |
"""Configuration for pytest.
Fixtures:
cards: the cards database, built once per session from the bundled CSVs.
TWDA: the decks archive, loaded once per session from the bundled snapshot.
The ``baseline`` marker flags tests that track live source data (cards, rulings,
the TWDA). Such a test is expected to dri... | lionel-panhaleux/krcg | tests/conftest.py | .py | b19680c2cce6b141 | 8.06 | 12 |
"""Test the analyzer."""
from krcg import analyzer
from krcg import loader
from krcg import models
from krcg import twda
def test_analyzer() -> None:
"""Stats, affinity and deck building over the bundled TWDA."""
cards = loader.load_local()
decks = list(twda.load_local().values())
nana = cards["Nana ... | lionel-panhaleux/krcg | tests/test_analyzer.py | .py | 413de419be6c1e77 | 7.06 | 12 |
"""Test the card references parsed from card text."""
import re
import pytest
from krcg import card_references
from krcg import collections
from krcg import models
from krcg.utils import string
from krcg.scripts import fix_csv
def test_references_resolve(cards: collections.CardDict) -> None:
"""Every marker le... | lionel-panhaleux/krcg | tests/test_card_references.py | .py | 0e64f122b0fddfef | 8.06 | 12 |
"""Test the cards."""
import aiohttp
import pytest
import warnings
from krcg import collections
from krcg import loader
@pytest.mark.baseline
@pytest.mark.filterwarnings("ignore::UserWarning")
def test_card_variants(cards: collections.CardDict) -> None:
"""Card name variants and aliases (translation-dependent —... | lionel-panhaleux/krcg | tests/test_cards.py | .py | 9bfacca600ef4e51 | 8.06 | 12 |
"""Test deck serialization (provider formats) and remote deck fetching."""
import io
import pathlib
import aiohttp
import pytest
from krcg import collections
from krcg import parser
from krcg import providers
FIXTURE = pathlib.Path(__file__).parent / "twd_2010tcdbng.txt"
VDB_URL = (
"https://vdb.im/decks/deck?... | lionel-panhaleux/krcg | tests/test_deck.py | .py | d78c1897f27e2628 | 8.06 | 12 |
"""Test the VEKN csv fixups."""
from krcg.scripts import fix_csv
def row(id_: str, sets: str) -> dict[str, str]:
"""A card row carrying just what fix_set_field reads."""
return {
"Id": id_,
"Name": "",
"Set": sets,
"Clan": "",
"Card Text": "",
"Discipline": "",... | lionel-panhaleux/krcg | tests/test_fix_csv.py | .py | 01cdc22cc8b16338 | 8.06 | 12 |
"""Test the decklist parser (line-level: counts, names, comments, disciplines)."""
import logging
import pytest
from krcg import collections
from krcg import models
from krcg import parser
def gc(
p: parser.Parser, cards: collections.CardDict, line: str
) -> tuple[models.Card | None, int]:
"""Parse a line ... | lionel-panhaleux/krcg | tests/test_parser.py | .py | 2e18ffc86532673d | 8.06 | 12 |
"""Test ruling parsing and the full serialized form of ruling-bearing cards."""
import io
import json
import pathlib
import msgspec.json
import pytest
from krcg import collections, rulings, vekn_csv
SNAPSHOTS = pathlib.Path(__file__).parent / "snapshots"
def test_ruling_structure(cards: collections.CardDict) -> N... | lionel-panhaleux/krcg | tests/test_states.py | .py | 7686498fd20c7309 | 8.06 | 12 |
"""Test parsing the tournament extended-archive deck format."""
import logging
import pathlib
import pytest
from krcg import collections
from krcg import models
from krcg import parser
FIXTURE = pathlib.Path(__file__).parent / "202207_EC_Day1_1.txt"
def test_tournament_archive_format(
cards: collections.CardD... | lionel-panhaleux/krcg | tests/test_tournament_archive.py | .py | 6054f5919409147f | 7.06 | 12 |
"""Parser fidelity against hand-picked TWDA decks (current source, as .txt).
Each ``twd_<id>.txt`` is a frozen real deck chosen for a format peculiarity, so
these are core tests — a failure is a parser regression. The bundle snapshot at
the end is a baseline test (amber on source-data drift).
"""
import io
import pat... | lionel-panhaleux/krcg | tests/test_twda.py | .py | 3dfd3e695ff93fe0 | 8.06 | 12 |
"""Test the VTES cards database: fuzzy lookup, translations, and search."""
import json
import pathlib
import msgspec.json
import pytest
from krcg import collections
from krcg import models
SNAPSHOTS = pathlib.Path(__file__).parent / "snapshots"
def test_fuzzy_match(cards: collections.CardDict) -> None:
"""Fu... | lionel-panhaleux/krcg | tests/test_vtes.py | .py | 9253b3b3f1b29ea8 | 8.06 | 12 |
package com.thealgorithms.datastructures.lists;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
imp... | eduardogade/Bloom | __notes2/SinglyLinkedListTest.java | .java | b6b6c83760d6a36d | 7.04 | 11 |
// liouville_test.go
// description: Returns λ(n)
// author: Akshay Dubey (https://github.com/itsAkshayDubey)
// see liouville.go
package math_test
import (
"testing"
"github.com/TheAlgorithms/Go/math"
)
func TestLiouvilleLambda(t *testing.T) {
var tests = []struct {
name string
n int
... | eduardogade/Bloom | __trial6/liouville_test.go | .go | 06b52b474658572a | 7.04 | 11 |
"""
Module that handles bloom configuration files.
Generally, some bloom behaviour can be controlled using a "bloom.conf"
file in one of the following locations, in order of preference:
1. bloom.conf in current directory
2. File specified by environment variable bloom_CONF
3. bloom.conf in home folder
4. .bloom.conf ... | eduardogade/Bloom | bloom/config.py | .py | f9ce5fa9f34002c4 | 7.54 | 11 |
"""Cache.
=========
This module defines a convenience class to all quantities computed
during forward propagation, so they don't have to be recomputed again
during backward propgation. See `paper`_ for details and notation.
"""
# Copyright (C) 2018 Steven H. Berguin
# This work is licensed under the MIT License.
fro... | shb84/JENN | src/jenn/core/cache.py | .py | 219d4f0a1f90e7a2 | 7.52 | 10 |
"""Cost Function.
=================
This module contains class and methods to efficiently compute the neural
net cost function used for training. It is a modified version of the
Least Squared Estimator (LSE), augmented with a penalty function for
regularization and another term which accounts for Jacobian prediction
e... | shb84/JENN | src/jenn/core/cost.py | .py | 442c8616f01cccfa | 7.52 | 10 |
"""Data.
========
This module contains convenience utilities to manage and handle training
data.
"""
# Copyright (C) 2018 Steven H. Berguin
# This work is licensed under the MIT License.
from __future__ import annotations # needed if python is 3.9
import math
from dataclasses import dataclass
from functools import ... | shb84/JENN | src/jenn/core/data.py | .py | 846a1994bca904e5 | 7.52 | 10 |
"""Model.
=========
This module contains the main class to train a neural net and make
predictions. It acts as an interface between the user and the core
functions doing computations under-the-hood.
.. code-block:: python
#################
# Example Usage #
#################
import jenn
# Fit m... | shb84/JENN | src/jenn/core/model.py | .py | 1957a5d3c00a97e3 | 7.52 | 10 |
"""Optimization.
================
.. ADAM: https://doi.org/10.48550/arXiv.1412.6980
This module implements gradient-based optimization using `ADAM`_.
"""
# Copyright (C) 2018 Steven H. Berguin
# This work is licensed under the MIT License.
from __future__ import annotations # needed if python is 3.9
from typing im... | shb84/JENN | src/jenn/core/optimization.py | .py | 0fc940d0a687246c | 7.52 | 10 |
"""Parameters.
==============
This module defines a utility class to store and manage neural net
parameters and metadata.
"""
# Copyright (C) 2018 Steven H. Berguin
# This work is licensed under the MIT License.
from __future__ import annotations # needed if python is 3.9
from typing import TYPE_CHECKING
if TYPE_C... | shb84/JENN | src/jenn/core/parameters.py | .py | b9d34de50dbf935b | 7.52 | 10 |
"""Array conversion.
===================
Translate between the row-per-sample JSON payloads exchanged over MCP
and the feature-first arrays used internally by :mod:`jenn`.
"""
# Copyright (C) 2018 Steven H. Berguin
# This work is licensed under the MIT License.
from __future__ import annotations
import numpy as np
... | shb84/JENN | src/jenn/mcp/_convert.py | .py | d506884d22d4c819 | 7.52 | 10 |
"""Registries.
==============
In-memory stores mapping opaque handles to trained models and to
ingested datasets, plus the metadata needed to evaluate, export, and
train from them. The stdio server is a single long-lived process, so
module-level registries persist across tool calls.
"""
# Copyright (C) 2018 Steven H.... | shb84/JENN | src/jenn/mcp/_store.py | .py | 25f09b0ba9b2388e | 7.52 | 10 |
"""Linear Test Function.
========================
.. code-block:: python
#################
# Example Usage #
#################
import jenn.synthetic_data import linear
x = np.random.rand((2, 10))
y = linear.compute(x)
dydx = linear.compute_partials(x)
"""
# Copyright (C) 2018 Steven H. ... | shb84/JENN | src/jenn/synthetic_data/linear.py | .py | 0f5eaf30755339f9 | 7.52 | 10 |
"""Rastrigin Test Function.
===========================
.. code-block:: python
#################
# Example Usage #
#################
import jenn.synthetic_data import rastrigin
x = np.random.rand((2, 10))
y = rastrigin.compute(x)
dydx = rastrigin.compute_partials(x)
"""
# Copyright (C) ... | shb84/JENN | src/jenn/synthetic_data/rastrigin.py | .py | eee804f8e0380745 | 7.52 | 10 |
"""Rosenbrock Test Function.
============================
.. code-block:: python
#################
# Example Usage #
#################
import jenn.synthetic_data import rosenbrock
x = np.random.rand((2, 10))
y = rosenbrock.compute(x)
dydx = rosenbrock.compute_partials(x)
"""
# Copyright... | shb84/JENN | src/jenn/synthetic_data/rosenbrock.py | .py | 7ea57fcca63dced2 | 7.52 | 10 |
"""Sinusoid Test Function.
==========================
.. code-block:: python
#################
# Example Usage #
#################
import jenn.synthetic_data import sinusoid
x = np.random.rand((2, 10))
y = sinusoid.compute(x)
dydx = sinusoid.compute_partials(x)
"""
# Copyright (C) 2018 ... | shb84/JENN | src/jenn/synthetic_data/sinusoid.py | .py | 838462569312d5e7 | 7.52 | 10 |
"""Load trained JMP model."""
# Copyright (C) 2018 Steven H. Berguin
# This work is licensed under the MIT License.
from __future__ import annotations # needed if python is 3.9
from pathlib import Path
import numpy as np
from jenn.core.model import NeuralNet
def _is_float(string: str) -> bool:
"""Check is st... | shb84/JENN | src/jenn/utilities/_jmp.py | .py | 914150392d24eeee | 7.52 | 10 |
"""Synthetic Data.
==================
This module provide synthetic test functions
that can be used to generate exmaple data for
illustration and testing. Simply inherit from
the base class to implement new test functions.
.. code-block:: python
#################
# Example Usage #
#################
... | shb84/JENN | src/jenn/utilities/_sample.py | .py | f9d65d84550fa7fe | 7.52 | 10 |
"""Test that activation functions are corrected."""
# Copyright (C) 2018 Steven H. Berguin
# This work is licensed under the MIT License.
from __future__ import annotations # needed if python is 3.9
import numpy as np
def model_backward_FD(cost, params, step=1e-6): # ruff:ignore[invalid-function-name]
"""Use ... | shb84/JENN | tests/_utils.py | .py | d5404fc5de491060 | 8.02 | 10 |
"""Test that activation functions are correct."""
# Copyright (C) 2018 Steven H. Berguin
# This work is licensed under the MIT License.
from __future__ import annotations # needed if python is 3.9
from importlib.util import find_spec
from time import time
import numpy as np
import jenn
from ._utils import finite_... | shb84/JENN | tests/test_activation.py | .py | 520090431e85130b | 8.02 | 10 |
"""Test that cost function is working."""
# Copyright (C) 2018 Steven H. Berguin
# This work is licensed under the MIT License.
from __future__ import annotations # needed if python is 3.9
import numpy as np
import jenn
def test_least_squares():
"""Test that least squares cost function evaluates to known answ... | shb84/JENN | tests/test_cost.py | .py | c43c573970c8fd35 | 8.02 | 10 |
"""Test the file-based training-data loaders in jenn.utilities."""
# Copyright (C) 2018 Steven H. Berguin
# This work is licensed under the MIT License.
from __future__ import annotations
from pathlib import Path
import numpy as np
import pytest
from jenn.utilities import load_csv, load_csv_inputs, load_npz, load_n... | shb84/JENN | tests/test_load.py | .py | 6fc85e2dfa1da4c1 | 8.02 | 10 |
"""Test the JENN MCP server tools."""
# Copyright (C) 2018 Steven H. Berguin
# This work is licensed under the MIT License.
from __future__ import annotations
from pathlib import Path
import numpy as np
import pytest
import jenn
from jenn.synthetic_data import rastrigin
pytest.importorskip("mcp") # skip this whol... | shb84/JENN | tests/test_mcp.py | .py | 56dbc3ab06592061 | 8.02 | 10 |
"""Test goodness-of-fit metrics."""
# Copyright (C) 2018 Steven H. Berguin
# This work is licensed under the MIT License.
from __future__ import annotations
import numpy as np
from jenn.post_processing.metrics import rsquare
def test_rsquare_perfect_fit_multioutput():
"""R² is 1.0 per output when prediction eq... | shb84/JENN | tests/test_metrics.py | .py | 66f265ab5bcd8343 | 8.02 | 10 |
"""Test training and prediction (including partials)."""
# Copyright (C) 2018 Steven H. Berguin
# This work is licensed under the MIT License.
from __future__ import annotations # needed if python is 3.9
import numpy as np
import jenn
from ._utils import finite_difference
class TestSinusoid:
"""Check model a... | shb84/JENN | tests/test_model.py | .py | 06321759ad8a6364 | 7.02 | 10 |
"""Check that optimizer by testing it against
standard cannonical test functions.
"""
# Copyright (C) 2018 Steven H. Berguin
# This work is licensed under the MIT License.
from __future__ import annotations # needed if python is 3.9
from importlib.util import find_spec
import numpy as np
import pytest
import jenn
... | shb84/JENN | tests/test_optimization.py | .py | 2b401076560f1fe0 | 8.02 | 10 |
"""Test Parameter class."""
# Copyright (C) 2018 Steven H. Berguin
# This work is licensed under the MIT License.
from __future__ import annotations # needed if python is 3.9
import pathlib
import tempfile
import numpy as np
import pytest
import jenn
class TestSerialization:
"""Check that parameters can be s... | shb84/JENN | tests/test_parameters.py | .py | c9a881164a1a25c9 | 8.02 | 10 |
#!/usr/bin/env python3
# encoding: utf-8
import threading
from typing import Union, Final, Literal
import requests
from config import PROXIES, TIMEOUT
def request_url(
url: str,
*,
method: Literal["get", "post"] = "get",
raise_for_status: bool = True,
**kwargs
) -> requests.... | Pzqqt/Whyred_Rom_Update_Checker | common.py | .py | c4ebdbd9399b37d0 | 7.59 | 14 |
#!/usr/bin/env python3
# encoding: utf-8
from __future__ import annotations
import os
import threading
from collections import OrderedDict
from sqlalchemy import create_engine, Column, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, Session
from config import S... | Pzqqt/Whyred_Rom_Update_Checker | database.py | .py | 4c4172a19559e0b7 | 7.59 | 14 |
#!/usr/bin/env python3
# encoding: utf-8
import logging
import logging.handlers
import os
import traceback
from typing import Union, Final
from config import LOG_FILE, LOG_FILE_MAX_BYTES, LOG_FILE_BACKUP_COUNT, ENABLE_LOGGER
if not os.path.isabs(LOG_FILE):
LOG_FILE = os.path.join(os.path.dirname(os.path.abspath... | Pzqqt/Whyred_Rom_Update_Checker | logger.py | .py | 9b01774f73883bfe | 7.59 | 14 |
#!/usr/bin/env python3
# encoding: utf-8
from argparse import ArgumentParser
import json
import time
import sys
import logging
import typing
from typing import Optional, Union, Tuple, Final
from concurrent.futures import ThreadPoolExecutor, as_completed
from requests import exceptions as req_exceptions
from config i... | Pzqqt/Whyred_Rom_Update_Checker | main.py | .py | f3781c9d474854cd | 7.59 | 14 |
#!/usr/bin/env python3
# encoding: utf-8
import traceback
import logging
import os
import threading
from tempfile import mkstemp
from typing import Final, ContextManager
from functools import wraps
from contextlib import contextmanager
import telebot
from telebot.apihelper import requests
from telebot.types import In... | Pzqqt/Whyred_Rom_Update_Checker | tgbot.py | .py | 76bfb7bee3d7a20e | 7.59 | 14 |
# ---
# jupyter:
# jupytext:
# cell_metadata_filter: -all
# custom_cell_magics: kql
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.11.2
# kernelspec:
# display_name: process-improve
# language: python
# nam... | kgdunn/process-improve | examples/batch/batch_llm_multivariate.py | .py | 749171bae68a01da | 7.63 | 17 |
# ---
# jupyter:
# jupytext:
# cell_metadata_filter: -all
# custom_cell_magics: kql
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.11.2
# kernelspec:
# display_name: process-improve
# language: python
# nam... | kgdunn/process-improve | examples/batch/batch_music.py | .py | 2e8aa77f4b5330da | 7.63 | 17 |
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["process-improve[expt,plotting]"]
# ///
"""Generic dispatcher for the process-improve tool registry.
Every ``@tool_spec``-decorated function in ``process_improve`` is reachable
here by name, with JSON in and JSON out. Prefer this over w... | kgdunn/process-improve | skills/doe-designer/scripts/doe_tool.py | .py | 18cb9978c2ea667e | 7.63 | 17 |
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["process-improve[expt,plotting]", "kaleido"]
# ///
"""Render a ``visualize_doe`` result to an image or an interactive page.
``visualize_doe`` returns a chart specification with both a Plotly and an
ECharts rendering of the same figure; ... | kgdunn/process-improve | skills/doe-designer/scripts/render_plot.py | .py | d81d3f3118be6ec8 | 7.63 | 17 |
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["process-improve[expt]"]
# ///
"""Verify a two-level design before anyone runs it in a lab.
Why this exists
---------------
A language model asked to write out a fractional factorial design will often
produce one that looks right and is... | kgdunn/process-improve | skills/doe-designer/scripts/verify_design.py | .py | 7d774fd1db09c60a | 7.63 | 17 |
"""ENG-13 (#295): clean errors when an optional extra is not installed.
``process_improve`` ships a small core (numpy, pandas, scikit-learn,
statsmodels, patsy, pydantic, pyyaml, tqdm) and gates heavier
optional dependencies behind extras::
pip install 'process-improve[plotting]' # matplotlib + plotly + seabor... | kgdunn/process-improve | src/process_improve/_extras.py | .py | 235c7e06d8042d92 | 7.63 | 17 |
"""(c) Kevin Dunn, 2010-2026. MIT License.
Small numerical-linear-algebra guards shared across the package.
``np.linalg.inv`` does not raise on an ill-conditioned (near-singular) matrix:
it returns overflow-driven garbage. These helpers detect singular and
ill-conditioned matrices up front so callers can either fail ... | kgdunn/process-improve | src/process_improve/_linalg.py | .py | 32a403671508ce8d | 7.63 | 17 |
"""Functions in this files will ONLY use NumPy, and are therefore candidates for speed up with Numba."""
import numpy as np
# ENG-13 (#295): numba lives in the optional ``[fast]`` extra. Without it
# the module still imports and the functions still run; ``@jit`` falls back
# to a no-op decorator so the code executes ... | kgdunn/process-improve | src/process_improve/batch/alignment_helpers.py | .py | 8754cc5b0a1b470f | 7.63 | 17 |
"""
Getting data into the required format for use with this library.
There are 3 useful ways to represent batch data.
``dict``: as a Python dictionary. Example::
data = {
"batch 1": data frame with varying number of rows, but same number of columns,
"batch 2": etc,
}
The keys are unique iden... | kgdunn/process-improve | src/process_improve/batch/data_input.py | .py | 0c93e94047f789f8 | 7.63 | 17 |
"""
Bivariate statistical tools.
* elbow detection in an (x,y) plot
* peaks: finding peaks, quantifying their height, width, center, area, left & right boundaries
* area under curve
"""
import numpy as np
from ..regression.methods import fit_robust_lm
def find_elbow_point(x: np.ndarray, y: np.ndarray, max_iter: in... | kgdunn/process-improve | src/process_improve/bivariate/_elbow_peak.py | .py | cd899fbf5f4948a5 | 7.63 | 17 |
# (c) Kevin Dunn, 2010-2026. MIT License.
"""Always-on model-summary helpers used by :func:`analyze_experiment` (ENG-02)."""
from __future__ import annotations
import numpy as np
from statsmodels.regression.linear_model import RegressionResultsWrapper
def _compute_pred_r_squared(ols_result: RegressionResultsWrapper... | kgdunn/process-improve | src/process_improve/experiments/_analyses/_shared.py | .py | 7bc9c0bd2486ef38 | 7.63 | 17 |
# (c) Kevin Dunn, 2010-2026. MIT License.
"""Stepwise model selection using AIC/BIC (ENG-02)."""
from __future__ import annotations
from typing import Any
import pandas as pd
import statsmodels.formula.api as smf
def _run_model_selection( # noqa: C901
design_df: pd.DataFrame,
response_col: str,
factor... | kgdunn/process-improve | src/process_improve/experiments/_analyses/model_selection.py | .py | 8f3c8fb0c409b2f6 | 7.63 | 17 |
# (c) Kevin Dunn, 2010-2026. MIT License.
"""Thin extractors over a fitted OLS result: ANOVA, effects, coefficients,
significance, and confidence intervals (ENG-02).
"""
from __future__ import annotations
from typing import Any
import pandas as pd
import statsmodels.api as sm
from statsmodels.regression.linear_model... | kgdunn/process-improve | src/process_improve/experiments/_analyses/ols_extractors.py | .py | 7d19217b0c511942 | 7.63 | 17 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.