text stringlengths 185 73.3k | repo stringlengths 7 100 | path stringlengths 4 146 | language stringclasses 7
values | hash stringlengths 16 16 | score float64 7 8.5 | stars int64 0 237k |
|---|---|---|---|---|---|---|
from hamcrest.core.base_matcher import BaseMatcher
class CloseToDict(BaseMatcher):
def __init__(self, expected, delta):
self.expected = expected
self.delta = delta
def _matches(self, actual):
if not isinstance(actual, dict) or not isinstance(self.expected, dict):
return Fa... | Restream/reindexer-py | pyreindexer/tests/helpers/matchers.py | .py | 75d7ef550a702df9 | 7.89 | 5 |
# Copyright 2018-2026 Simon Brunning
from __future__ import annotations
import json
from collections.abc import Mapping, Sequence
from typing import TYPE_CHECKING, TypeAlias
from hamcrest.core.base_matcher import BaseMatcher
from hamcrest.core.helpers.wrap_matcher import wrap_matcher
if TYPE_CHECKING:
from hamcr... | brunns/brunns-matchers | src/brunns/matchers/data.py | .py | 23e4f19f204ff73e | 7.24 | 2 |
# Copyright 2018-2026 Simon Brunning
from __future__ import annotations
from datetime import date
from typing import TYPE_CHECKING
from hamcrest import described_as
from hamcrest.core.base_matcher import BaseMatcher
from hamcrest.core.helpers.wrap_matcher import wrap_matcher
from brunns.matchers.object import betwee... | brunns/brunns-matchers | src/brunns/matchers/datetime.py | .py | a1346475dbb2a298 | 7.24 | 2 |
# Copyright 2018-2026 Simon Brunning
from __future__ import annotations
from collections.abc import Mapping, Sequence
from typing import TYPE_CHECKING, Any, cast
from bs4 import BeautifulSoup, Tag
from hamcrest import all_of, anything, contains_exactly, has_entry, has_item
from hamcrest.core.base_matcher import BaseM... | brunns/brunns-matchers | src/brunns/matchers/html.py | .py | fb0520ab84f1beae | 7.24 | 2 |
# Copyright 2018-2026 Simon Brunning
from __future__ import annotations
import collections.abc
import inspect
from itertools import zip_longest
from typing import TYPE_CHECKING, Any
from hamcrest import (
all_of,
greater_than,
greater_than_or_equal_to,
less_than,
less_than_or_equal_to,
not_,
)... | brunns/brunns-matchers | src/brunns/matchers/object.py | .py | 7ad389e2fb67454c | 7.24 | 2 |
# Copyright 2018-2026 Simon Brunning
from __future__ import annotations
import email
import re
from dataclasses import dataclass
from re import Match
from typing import TYPE_CHECKING, cast
from deprecated import deprecated
from hamcrest import anything
from hamcrest.core.base_matcher import BaseMatcher
from hamcrest.... | brunns/brunns-matchers | src/brunns/matchers/smtp.py | .py | 01cfabd56eea86fe | 7.24 | 2 |
# Copyright 2018-2026 Simon Brunning
import logging
logger = logging.getLogger(__name__)
class ReprFromDict:
"""Mix-in implementing repr() from instance's __dict__vars()"""
def __repr__(self) -> str: # pragma: no cover
state = ", ".join(f"{attr:s}={val!r:s}" for (attr, val) in vars(self).items())
... | brunns/brunns-matchers | tests/utils/bunch.py | .py | 2f2a5ff419f3b412 | 7.24 | 2 |
# seine - Slim Embedded Images Now Easy
# SPDX-License-Identifier: Apache-2.0
# Wraps the very spec 'test:' came from and the image seine.build/
# seine.inspect already know how to make and read -- 'create/build/
# deploy an artifact' from the prompt's own wishlist, without a second
# build engine: this calls straight... | chombourger/seine | seine/testing/library/image.py | .py | 4961d9e0e82ffabd | 7.65 | 1 |
# seine - Slim Embedded Images Now Easy
# SPDX-License-Identifier: Apache-2.0
# Two distinct kinds of observation, both plain values a test can
# 'assign:' and use in any 'if:'/'while:' condition or BuiltIn assertion
# -- no separate "observation" object to learn:
#
# * 'Capture Screen' -- the console's decoded text ... | chombourger/seine | seine/testing/library/observation.py | .py | e97bd6491119914a | 7.65 | 1 |
# seine - Slim Embedded Images Now Easy
# SPDX-License-Identifier: Apache-2.0
# Every keyword here is a thin wrapper over seine.tui.target's own action
# functions -- the same code '/target' and its AI tools already call, not
# a reimplementation for headless use. What is added is only the RF
# surface: keyword names ... | chombourger/seine | seine/testing/library/target.py | .py | 3d353824f8d111de | 7.65 | 1 |
#!/usr/bin/env python3
"""
Engineering Team Scaling Calculator - Optimize team growth and structure
"""
import json
import math
from typing import Dict, List, Tuple
class TeamScalingCalculator:
def __init__(self):
self.conway_factor = 1.5 # Conway's Law impact factor
self.brooks_factor = 0.75 # ... | markyy101/conductor-orchestrator-superpowers | skills/cto-advisor/scripts/team_scaling_calculator.py | .py | 92ae3f43b332ec72 | 7.39 | 5 |
#!/usr/bin/env python3
"""
Technical Debt Analyzer - Assess and prioritize technical debt across systems
"""
import json
from typing import Dict, List, Tuple
from datetime import datetime
import math
class TechDebtAnalyzer:
def __init__(self):
self.debt_categories = {
'architecture': {
... | markyy101/conductor-orchestrator-superpowers | skills/cto-advisor/scripts/tech_debt_analyzer.py | .py | d70ddff8547dda80 | 7.39 | 5 |
#!/usr/bin/env python3
"""
Initialize message bus for a track.
Usage:
python init-bus.py <track_path>
python init-bus.py conductor/tracks/feature-xyz_20260201
Creates the message bus directory structure for inter-agent coordination.
"""
import json
import os
import sys
from datetime import datetime
from path... | markyy101/conductor-orchestrator-superpowers | skills/message-bus/scripts/init-bus.py | .py | 936bd6565a0628fe | 7.39 | 5 |
#!/usr/bin/env python3
"""
Monitor message bus for a track.
Usage:
python monitor-bus.py <track_path> [--watch]
python monitor-bus.py conductor/tracks/feature-xyz_20260201 --watch
Shows current state and optionally watches for new messages.
"""
import json
import os
import sys
import time
from datetime impor... | markyy101/conductor-orchestrator-superpowers | skills/message-bus/scripts/monitor-bus.py | .py | 0caba6c9795aa088 | 7.39 | 5 |
"""
Report generator for ERR-EVAL benchmark.
Creates JSON and Markdown output files.
"""
from __future__ import annotations
import json
from pathlib import Path
from typing import Any
from .models import EvaluationRun, LeaderboardData, LeaderboardEntry
def generate_results_json(
run: EvaluationRun,
output_p... | prorok9898/ERR-EVAL | bench/erreval/reporter.py | .py | a923816efd20fced | 7.24 | 2 |
"""
Runner for ERR-EVAL benchmark evaluation.
Orchestrates the full evaluation pipeline.
"""
from __future__ import annotations
import asyncio
import json
import uuid
from datetime import datetime
from pathlib import Path
from typing import Any
from .models import (
CanonicalItem,
ItemResult,
JudgeScores,... | prorok9898/ERR-EVAL | bench/erreval/runner.py | .py | 9a5fa81776896db2 | 7.24 | 2 |
"""
Scorer for ERR-EVAL benchmark.
Handles aggregation, percentiles, and failure profiling.
"""
from __future__ import annotations
from collections import defaultdict
from typing import TYPE_CHECKING
from .models import (
ItemResult,
TrackSummary,
AxisSummary,
FailureProfile,
FailureMode,
Trac... | prorok9898/ERR-EVAL | bench/erreval/scorer.py | .py | 1bd4f61c77f6ae32 | 7.24 | 2 |
"""
Variant engine for generating deterministic perturbations of canonical items.
"""
from __future__ import annotations
import json
import random
import re
from pathlib import Path
from typing import Any
from .models import CanonicalItem, VariantSlots
class VariantEngine:
"""
Generates deterministic varian... | prorok9898/ERR-EVAL | bench/erreval/variant_engine.py | .py | 2ad611036d2bb7ad | 7.24 | 2 |
"""Base class for cellular automata"""
from abc import ABC, abstractmethod
class CellularAutomaton(ABC):
"""Base class for cellular automaton implementations."""
def __init__(self, width: int, height: int) -> None:
self.width = width
self.height = height
self.reset()
@abstractme... | kimmy1985/LifeGrid | src/automata/base.py | .py | ad6810e0f47ba0e2 | 7.15 | 1 |
"""Brian's Brain cellular automaton implementation."""
# pylint: disable=duplicate-code
from __future__ import annotations
import numpy as np
from scipy import signal
from .base import CellularAutomaton
class BriansBrain(CellularAutomaton):
"""Brian's Brain with states: off (0), firing (1), refractory (2)."""... | kimmy1985/LifeGrid | src/automata/briansbrain.py | .py | 6e0927450d928ec0 | 7.15 | 1 |
"""Generations-style cellular automaton with fading states."""
# pylint: disable=duplicate-code
from __future__ import annotations
from typing import Iterable, Set
import numpy as np
from scipy import signal
from .base import CellularAutomaton
class GenerationsAutomaton(CellularAutomaton):
"""Life-like birth... | kimmy1985/LifeGrid | src/automata/generations.py | .py | dd0c8db14b1c38f1 | 7.15 | 1 |
# pylint: disable=duplicate-code
"""High Life (B36/S23) automaton."""
from __future__ import annotations
import numpy as np
from scipy import signal
from .base import CellularAutomaton
class HighLife(CellularAutomaton):
"""High Life - B36/S23 (replicators possible)."""
def __init__(self, width: int, heig... | kimmy1985/LifeGrid | src/automata/highlife.py | .py | 2a8f2a846f0893e2 | 7.15 | 1 |
# pylint: disable=duplicate-code
"""Generic life-like automaton with B/S rules."""
from __future__ import annotations
from typing import Iterable, Set, Tuple
import numpy as np
from scipy import signal
from .base import CellularAutomaton
def parse_bs(rule_str: str) -> Tuple[Set[int], Set[int]]:
"""Parse B/S ... | kimmy1985/LifeGrid | src/automata/lifelike.py | .py | 8ec114965bef010b | 7.15 | 1 |
"""Wireworld cellular automaton implementation."""
from __future__ import annotations
import numpy as np
from scipy import signal
from .base import CellularAutomaton
class Wireworld(CellularAutomaton):
"""Wireworld with four states: empty, head, tail, conductor."""
EMPTY = 0
HEAD = 1
TAIL = 2
... | kimmy1985/LifeGrid | src/automata/wireworld.py | .py | 4a2dc3f1b060b709 | 7.15 | 1 |
"""State containers for the GUI application."""
from __future__ import annotations
from collections import deque
from dataclasses import dataclass, field
from typing import Deque, List, Optional
import numpy as np
from automata import CellularAutomaton
from .config import DEFAULT_CELL_SIZE, MAX_HISTORY_LENGTH
# ... | kimmy1985/LifeGrid | src/gui/state.py | .py | 5904338b5be966ed | 7.15 | 1 |
"""Widget construction and Tk variable helpers for the GUI."""
from __future__ import annotations
from dataclasses import dataclass
from typing import Callable
import tkinter as tk
from tkinter import ttk
from .config import DEFAULT_CANVAS_HEIGHT, DEFAULT_CANVAS_WIDTH, MODE_PATTERNS
class Tooltip:
"""Simple t... | kimmy1985/LifeGrid | src/gui/ui.py | .py | 00feffc8d0711024 | 7.15 | 1 |
#!/usr/bin/env python3
"""Application entry point for the cellular automaton simulator."""
from __future__ import annotations
import sys
import importlib.util
def check_dependencies() -> None:
"""Verify that all required Python packages are installed."""
missing = []
if importlib.util.find_spec("tkinte... | kimmy1985/LifeGrid | src/main.py | .py | 5d2204655604f376 | 7.15 | 1 |
# pylint: disable=duplicate-code
# mypy: ignore-errors
"""GUI-related smoke tests.
These tests exercise the Tk UI at a basic level. They will be skipped
automatically if Tk cannot initialize (e.g., no DISPLAY on Linux).
"""
from __future__ import annotations
import tkinter as tk
import pytest
from gui.app import ... | kimmy1985/LifeGrid | tests/test_gui.py | .py | b18428f8dc520352 | 7.65 | 1 |
# Copyright 2013-2024 Wind River, Inc.
# Copyright 2012 OpenStack LLC.
# All Rights Reserved.
#
# 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/licens... | starlingx/update | software-client/software_client/common/base.py | .py | 38930229af9a8560 | 7.39 | 5 |
# Copyright 2024 Wind River Systems, Inc.
# Copyright 2012 OpenStack LLC.
# All Rights Reserved.
#
# 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/lic... | starlingx/update | software-client/software_client/tests/utils.py | .py | a7267dc1a9a4c183 | 7.89 | 5 |
#
# Copyright (c) 2026 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import re
from software_client.common import utils
KUBE_VERSION_RE = re.compile(r'^v?\d{1,2}\.\d{1,2}\.\d{1,2}$')
@utils.arg('release_id',
help='Release ID to initialize the system deploy for')
@utils.arg('--kube-u... | starlingx/update | software-client/software_client/v1/system_deploy_shell.py | .py | 32e7a15adc8bb4b9 | 7.39 | 5 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Command line tool that executes quality assurance checks on grid data
derived from multibeam echosounder data.
"""
import click
import json
import os
import sys
from pathlib import Path
from ausseabed.mbesgc.lib.data import (
get_input_details,
inputs_from_qa... | ausseabed/mbes-grid-checks | ausseabed/mbesgc/app/cli.py | .py | ba4015ce81dcc5a5 | 7.15 | 1 |
"""
Manages process of executing checks
"""
from typing import Dict, List, Tuple
from osgeo import gdal
import logging
import numpy as np
import numpy.ma as ma
import os
import tempfile
from pathlib import Path
from .check_utils import get_check
from .data import InputFileDetails, BandType, InputFileDetailsError
from... | ausseabed/mbes-grid-checks | ausseabed/mbesgc/lib/executor.py | .py | 97be5c2aed3231be | 7.15 | 1 |
from osgeo import gdal, gdal_array
from typing import Tuple, Callable, List
import numpy as np
from .tiling import get_tiles, Tile
gdal.SetCacheMax(1000000000)
def _default_progress_callback(progress):
"""Default progress callback function. Prints % complete to stdout."""
print(f"Progress = {progress * 100:... | ausseabed/mbes-grid-checks | ausseabed/mbesgc/lib/grid_transformer.py | .py | 753991d0406ba5b0 | 7.15 | 1 |
"""
Definition of Grid Checks implemented in mbesgc
"""
from __future__ import annotations
from datetime import datetime
from enum import Enum
from pathlib import PurePath
from tempfile import TemporaryDirectory
import shutil
from typing import List, Any, ClassVar
from ausseabed.qajson.model import QajsonParam, Qajson... | ausseabed/mbes-grid-checks | ausseabed/mbesgc/lib/gridcheck.py | .py | 4d5d911a2385af18 | 7.15 | 1 |
from pathlib import Path
import logging
import math
import numpy as np
import os
from osgeo import gdal
from osgeo import ogr
from osgeo import osr
from typing import List
from .tiling import get_tiles
logger = logging.getLogger(__name__)
class Extents:
"""
Extents object for managing bounding box type inf... | ausseabed/mbes-grid-checks | ausseabed/mbesgc/lib/pinkchart.py | .py | 7d9ff4a4a17251ee | 7.15 | 1 |
from typing import List, Callable, Tuple
from pathlib import Path
from ausseabed.mbesgc.lib.allchecks import all_checks
from ausseabed.mbesgc.lib.data import inputs_from_qajson_checks, get_file_details
from ausseabed.mbesgc.lib.executor import Executor
from hyo2.qax.lib.plugin import QaxCheckToolPlugin, QaxCheckRefe... | ausseabed/mbes-grid-checks | ausseabed/mbesgc/qax/plugin.py | .py | 8e2bfb876dfde7e3 | 7.15 | 1 |
"""Sphinx directives that generate documentation tables from the package itself.
Every hand-maintained table in these docs had drifted from the code by the time
this was written: ``fairness_constraints.md`` still described demographic parity
as ``TP + FP`` and equal opportunity as ``TP / (TP + FN)``, encodings replace... | parulgupta1004/fair-seldonian | docs/_ext/fair_seldonian_docs.py | .py | 65693046ab5ad4c5 | 7.35 | 4 |
"""Customize the fairness constraint and the confidence bound.
The behaviour of QSA is controlled by :class:`SeldonianConfig`:
* ``delta`` - the constraint holds with probability >= 1 - delta
* ``inequality`` - concentration inequality used for the bound
* ``candidate_ratio`` - fraction of training dat... | parulgupta1004/fair-seldonian | examples/custom_constraint.py | .py | 6a10c9772472de80 | 7.35 | 4 |
"""Contrast a fair dataset (certified) with an unfair one (No Solution Found).
The Seldonian guarantee is one-sided: QSA will only return a model when it can
certify the fairness constraint holds with high probability. On data with a large
group disparity it returns "No Solution Found" rather than an unsafe model.
Ru... | parulgupta1004/fair-seldonian | examples/fairness_guarantee.py | .py | 6dda4138d0e78ab3 | 7.35 | 4 |
"""Minimal end-to-end example: train a fairness-certified classifier.
Runs the Quasi-Seldonian Algorithm (QSA) on synthetic data and reads back the
high-confidence fairness guarantee. This is the script version of the first part
of ``examples/quickstart.ipynb``.
Run it with::
uv run python examples/quickstart.py... | parulgupta1004/fair-seldonian | examples/quickstart.py | .py | 5a674689c5bbd1aa | 7.35 | 4 |
"""Draw the documentation's two explanatory figures from the library itself.
Both illustrate a claim the prose makes, so both are computed by calling the
real implementations rather than sketched: re-running this after a change to the
bound machinery is what keeps the figures honest. ``tests/test_docs_sync.py``
re-run... | parulgupta1004/fair-seldonian | scripts/make_docs_figures.py | .py | 72f033402a9ae81e | 7.35 | 4 |
from __future__ import annotations
import logging
from typing import NamedTuple
import numpy as np
import torch
from scipy.optimize import minimize
from ..config import DEFAULT_CONFIG, SeldonianConfig
from ..constraints.expression_tree import constraint_groups
from ..constraints.inequalities import check_constraint_... | parulgupta1004/fair-seldonian | src/fair_seldonian/algorithms/qsa.py | .py | c7ffdf7cc9349f85 | 7.35 | 4 |
from __future__ import annotations
from dataclasses import dataclass
from .constraints.expression_tree import validate_constraint
from .constraints.inequalities import Inequality
#: The names this module contributes to the public API. autodoc documents
#: exactly these, so the API reference stays the surface users a... | parulgupta1004/fair-seldonian | src/fair_seldonian/config.py | .py | 21e9de2e28758cb7 | 7.35 | 4 |
r"""Bound a constraint by compiling it to a max of affine forms.
The default path wraps a confidence interval around every node of the constraint
tree and combines them with interval arithmetic. That is sound but loose, for two
compounding reasons. Interval arithmetic assumes the worst about how the
sub-expressions re... | parulgupta1004/fair-seldonian | src/fair_seldonian/constraints/affine.py | .py | b5e136267ce5f613 | 7.35 | 4 |
from __future__ import annotations
import logging
import re
from typing import TYPE_CHECKING, TypeVar, overload
from .bounds import eval_math_bound
from .inequalities import Inequality, eval_estimate, eval_func_bound
if TYPE_CHECKING:
import torch
from .._typing import Array, Bound
#: The names this module... | parulgupta1004/fair-seldonian | src/fair_seldonian/constraints/expression_tree.py | .py | e04612c709aa80cb | 7.35 | 4 |
from __future__ import annotations
import logging
from typing import TYPE_CHECKING
from .expression_tree import (
ROOT_SIDES,
Sides,
_eval_node_bounds,
child_sides,
construct_expr_tree_base,
eval_expr_tree_base,
is_constant,
is_func,
)
# Left where it is: isort sorts this aliased impo... | parulgupta1004/fair-seldonian | src/fair_seldonian/constraints/expression_tree_ext.py | .py | 2739278e20497a9c | 7.35 | 4 |
"""Ready-to-use fairness constraints.
Each function returns a constraint in the reverse-Polish (postfix) notation that
:class:`~fair_seldonian.config.SeldonianConfig` expects, so you can plug a named
fairness definition straight into the algorithm without hand-writing the string::
from fair_seldonian import Seldo... | parulgupta1004/fair-seldonian | src/fair_seldonian/constraints/fairness.py | .py | 0dfd327a58549d14 | 7.35 | 4 |
from __future__ import annotations
from typing import cast
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
#: The names this module contributes to the public API. autodoc documents
#: exactly these, so the API reference stays the surface users are meant to
#: call rather t... | parulgupta1004/fair-seldonian | src/fair_seldonian/data/synthetic.py | .py | 93d8a9379035e5a8 | 7.35 | 4 |
from __future__ import annotations
import logging
import os
from concurrent.futures import ProcessPoolExecutor
from dataclasses import dataclass, field
import numpy as np
import torch
from ..algorithms.qsa import QSA
from ..config import DEFAULT_CONFIG, SeldonianConfig
from ..constraints.expression_tree import const... | parulgupta1004/fair-seldonian | src/fair_seldonian/experiments/runner.py | .py | c57a2a83713fe093 | 7.35 | 4 |
"""Tests for the ready-to-use fairness constraint builders."""
from __future__ import annotations
import pandas as pd
import pytest
import torch
from fair_seldonian import (
FAIRNESS_CONSTRAINTS,
demographic_parity,
equal_opportunity,
equalized_odds,
error_rate,
error_rate_parity,
)
from fair... | parulgupta1004/fair-seldonian | tests/test_fairness_constraints.py | .py | 05a4b1c422d2dc00 | 7.85 | 4 |
"""Guards on what the package exposes and what the docs claim it exposes.
Three failures this suite could not previously see:
* A module can be complete, tested and reachable only by its full dotted path.
``constraints.affine`` shipped that way -- absent from every ``__init__`` and
from the Sphinx API reference, ... | parulgupta1004/fair-seldonian | tests/test_public_api.py | .py | cd3753a670a4fe70 | 7.85 | 4 |
"""Notebook-style aliases matching the vision document API."""
from __future__ import annotations
import re
from fopy.sorts import DEFAULT_SORT, Sort
from fopy.symbols import FuncSymbol, RelSymbol, Variable, symbols
def Vars(names: str, /, sort: Sort | str | None = None) -> Variable | tuple[Variable, ...]:
"""... | pablogventura/fopy | src/fopy/api.py | .py | 53d99813a2c768a5 | 7 | 0 |
"""Named universe elements."""
from __future__ import annotations
from collections.abc import Hashable, Iterator
from typing import Any
class Domain:
"""Ordered collection of structure elements with optional attribute access."""
def __init__(self, *elements: Hashable) -> None:
"""Create a domain fr... | pablogventura/fopy | src/fopy/builders/domain.py | .py | 7db54643c8e74c81 | 7 | 0 |
"""Build structures from order relations and Hasse covers."""
from __future__ import annotations
from collections.abc import Callable, Iterable
from typing import Any
from fopy.signature import Signature
from fopy.structures import Structure
def _reflexive_transitive_closure(
elements: list[Any], leq: Callable... | pablogventura/fopy | src/fopy/builders/from_poset.py | .py | fa84edb15d9a48c0 | 7 | 0 |
"""Immutable base class for symbolic FO objects."""
from __future__ import annotations
from collections.abc import Iterator
from typing import Any
class Basic:
"""Immutable base class for symbolic first-order terms and formulas.
Subclasses expose structural ``args``, support hashing/equality by shape,
... | pablogventura/fopy | src/fopy/core/basic.py | .py | 9c8280acc6fa44d1 | 7 | 0 |
"""Hash-consing (interning) pool for :class:`~fopy.core.basic.Basic` nodes."""
from __future__ import annotations
from typing import Any
from fopy.core.basic import Basic
_pool: dict[tuple[type[Basic], tuple[Any, ...]], Basic] = {}
_enabled = False
class _HashconsState:
enabled = False
def enable_hashcons()... | pablogventura/fopy | src/fopy/core/hashcons.py | .py | 13b4cab5051f9dd8 | 7 | 0 |
"""Visitor utilities for FO expression trees."""
from __future__ import annotations
from collections.abc import Callable, Iterator
from typing import Any
from fopy.core.basic import Basic
class Visitor:
"""SymPy-style visitor over :class:`~fopy.core.basic.Basic` trees.
Subclass and override ``visit_<Class... | pablogventura/fopy | src/fopy/core/visitor.py | .py | 16b3098d1393e6ee | 7 | 0 |
"""Public API for Hasse diagram layout and drawing."""
from __future__ import annotations
from collections.abc import Callable, Hashable, Iterable, Sequence
from dataclasses import dataclass
from pathlib import Path
from typing import Any, cast
import matplotlib.pyplot as plt
import numpy as np
from fopy.draw.examp... | pablogventura/fopy | src/fopy/draw/__init__.py | .py | 66a75eb86cf7438c | 7 | 0 |
"""Example lattices for Hasse diagram layout."""
from __future__ import annotations
from collections.abc import Callable
from typing import Any
def boolean_lattice(n: int) -> tuple[list[int], Callable[[int, int], bool]]:
"""Power-set lattice on {0,...,n-1}; elements are bitmasks."""
if n < 0:
raise ... | pablogventura/fopy | src/fopy/draw/examples.py | .py | b0d9e21de4b6c2e9 | 7 | 0 |
"""Force-directed refinement for 3D Hasse layouts."""
from __future__ import annotations
from typing import cast
import numpy as np
from fopy.draw.poset import comparable
def _sanitize(positions: np.ndarray, velocities: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
if not np.isfinite(positions).all():
... | pablogventura/fopy | src/fopy/draw/forces.py | .py | 81d31fc4a35fe958 | 7 | 0 |
"""Hasse diagram cover edges."""
from __future__ import annotations
from collections.abc import Callable, Hashable, Iterable, Sequence
from fopy.draw.poset import index_elements, validate_poset
def hasse_covers(
elements: Sequence[Hashable],
leq: Callable[[Hashable, Hashable], bool] | None = None,
cove... | pablogventura/fopy | src/fopy/draw/hasse.py | .py | a5e91565cbec9e44 | 7 | 0 |
"""Quality metrics for projected Hasse layouts."""
from __future__ import annotations
import numpy as np
def _orientation(a: np.ndarray, b: np.ndarray, c: np.ndarray) -> float:
return float((b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]))
def _on_segment(a: np.ndarray, b: np.ndarray, c: np.ndarr... | pablogventura/fopy | src/fopy/draw/metrics.py | .py | 07ffa015f10c7de0 | 7 | 0 |
"""Finite poset validation and order-relation utilities."""
from __future__ import annotations
from collections.abc import Callable, Hashable, Iterable, Sequence
from typing import TypeVar
T = TypeVar("T", bound=Hashable)
def index_elements(elements: Sequence[T]) -> tuple[list[T], dict[T, int]]:
"""Return a co... | pablogventura/fopy | src/fopy/draw/poset.py | .py | c6223633e1b98639 | 7 | 0 |
"""3D to 2D projection and view selection."""
from __future__ import annotations
import math
from typing import cast
import numpy as np
from fopy.draw.metrics import combined_score
def projection_matrix(azimuth_deg: float, elevation_deg: float) -> np.ndarray:
"""Return a 3x3 rotation matrix for spherical view... | pablogventura/fopy | src/fopy/draw/project.py | .py | 240c68fa4b93bd67 | 7 | 0 |
"""Rank levels for Hasse diagram vertical placement."""
from __future__ import annotations
from dataclasses import dataclass
import numpy as np
@dataclass(frozen=True)
class RankLevels:
"""Vertical rank assignment for poset elements."""
levels: np.ndarray
height: np.ndarray
depth: np.ndarray
r... | pablogventura/fopy | src/fopy/draw/ranking.py | .py | b3fa4e40c4d0f9b6 | 7 | 0 |
"""Matplotlib rendering for Hasse diagrams."""
from __future__ import annotations
from collections.abc import Hashable, Sequence
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.figure import Figure
def _label(element: Hashable) -> str:
if isinstance(element, int) and... | pablogventura/fopy | src/fopy/draw/render.py | .py | 1081fe9eebb0de91 | 7 | 0 |
"""Verifiable certificates and trusted kernel."""
from __future__ import annotations
import json
from typing import Any, cast
from fopy.finite.explain import CERT_VERSION, verify_certificate
from fopy.finite.models import Model
from fopy.finite.relops import Relation
class TrustedKernel:
"""Minimal verifier fo... | pablogventura/fopy | src/fopy/finite/certificates.py | .py | d04c6605f67d2dd4 | 7 | 0 |
"""High-level open definability interface."""
from __future__ import annotations
from dataclasses import dataclass
from typing import TYPE_CHECKING
from fopy.finite.hit import Counterexample, HitConfig, is_open_def
from fopy.finite.models import Model
from fopy.finite.open_formulas import Formula, false_formula
from... | pablogventura/fopy | src/fopy/finite/definability.py | .py | 98cf34df5f17268e | 7 | 0 |
"""Memoization for open-formula evaluation on finite models."""
from __future__ import annotations
from fopy.finite.models import Model
from fopy.finite.open_formulas import Formula, Variable
class EvalCache:
"""Per-model memo table for :meth:`~fopy.finite.open_formulas.Formula.satisfy`.
Keys combine a for... | pablogventura/fopy | src/fopy/finite/eval_cache.py | .py | f12581f5db8d3b79 | 7 | 0 |
"""Optional fast evaluation helpers (numpy / bitsets)."""
from __future__ import annotations
from collections.abc import Sequence
from itertools import product
from typing import Any, cast
from fopy.finite.models import Model
from fopy.finite.open_formulas import Formula, FormulaKind, Term, TermKind, Variable
from f... | pablogventura/fopy | src/fopy/finite/eval_fast.py | .py | 374002c2a7a3ab7f | 7 | 0 |
"""Logic-fragment definability checks via k-type partitions."""
from __future__ import annotations
from fopy.finite.definability import DefinabilityResult
from fopy.finite.fragments.ep_ktypes import is_ep_definable
from fopy.finite.fragments.fo_ktypes import is_fo_definable
from fopy.finite.fragments.horn_ktypes impo... | pablogventura/fopy | src/fopy/finite/fragments/__init__.py | .py | 9a3a83d1ee58d3bb | 7 | 0 |
"""Partition refinement utilities for tuple typing on finite models."""
from __future__ import annotations
from collections.abc import Callable, Hashable
from itertools import product
from fopy.finite.models import Model
from fopy.finite.relops import Relation
MAX_TUPLE_PARTITION = 256
class TuplePartition:
"... | pablogventura/fopy | src/fopy/finite/fragments/_partition.py | .py | 2a21448ecb258a93 | 7 | 0 |
"""Witness formula construction from tuple partitions."""
from __future__ import annotations
from fopy.finite.fragments._partition import TuplePartition
from fopy.finite.models import Model
from fopy.finite.open_formulas import (
Formula,
OpSym,
Term,
Variable,
eq,
false_formula,
true_form... | pablogventura/fopy | src/fopy/finite/fragments/_witness.py | .py | f6d6cfcad43c31b9 | 7 | 0 |
"""Existential-positive definability via PP types."""
from __future__ import annotations
from itertools import product
from fopy.finite.definability import DefinabilityResult
from fopy.finite.fragments._partition import TuplePartition
from fopy.finite.fragments._witness import partition_witness_formula
from fopy.fin... | pablogventura/fopy | src/fopy/finite/fragments/ep_ktypes.py | .py | a64b95ec403c8b19 | 7 | 0 |
"""First-order definability via bounded FO k-type partitions."""
from __future__ import annotations
from fopy.finite.definability import DefinabilityResult
from fopy.finite.eval_fast import try_fast_defining_check
from fopy.finite.fragments._partition import TuplePartition
from fopy.finite.fragments._witness import p... | pablogventura/fopy | src/fopy/finite/fragments/fo_ktypes.py | .py | bf0231ae93cfc61a | 7 | 0 |
"""Horn definability via bounded clause witness search."""
from __future__ import annotations
from fopy.finite.definability import DefinabilityResult
from fopy.finite.fragments._partition import TuplePartition
from fopy.finite.fragments._witness import _enumerate_terms, partition_witness_formula
from fopy.finite.frag... | pablogventura/fopy | src/fopy/finite/fragments/horn_ktypes.py | .py | 0576471ba8a02548 | 7 | 0 |
"""FO and primitive-positive type signatures for tuples on finite models."""
from __future__ import annotations
from typing import Any
from fopy.finite.models import Model
DEFAULT_PP_DEPTH = 2
def atomic_pp_type(
model: Model,
tuple_vals: tuple[int, ...] | list[int],
*,
max_depth: int = DEFAULT_PP... | pablogventura/fopy | src/fopy/finite/ktypes.py | .py | ed0397560803268c | 7 | 0 |
"""Finite first-order models."""
from __future__ import annotations
from dataclasses import dataclass, field
from typing import TYPE_CHECKING
from fopy.finite.relops import Operation, Relation
if TYPE_CHECKING:
from fopy.finite.open_formulas import Formula, Variable
from fopy.formulas import Formula as Symb... | pablogventura/fopy | src/fopy/finite/models.py | .py | 57c579059ffc0b1b | 7 | 0 |
"""Deprecated import path - kept for backward compatibility.
Use `mcumgr.transport_ble` (or `mcumgr.SMPTransportBLE`) instead. This module
will be removed in a future release.
"""
import asyncio
from mcumgr.transport_ble import ( # noqa: F401
UUID_CHARACT,
UUID_SERVICE,
SMPTransportBLE,
find_device,... | lohmega/python-mcumgr | mcumgr/ble.py | .py | 74bfd323cff91d3d | 7.35 | 4 |
"""MCUboot image header/TLV parsing.
Port of libmcumgr's `src/image_util.c` + `include/mcumgr/image.h`.
Knowing the image layout is what makes a sane upload possible: the SHA256 in
the image trailer is the same hash the device reports for each slot, so it is
how you tell "already running", "already uploaded and pendi... | lohmega/python-mcumgr | mcumgr/image.py | .py | aaa60285024e56b4 | 7.35 | 4 |
# mcumgr management group and endpoint classes
import logging
import time
import cbor2 as cbor
from . import smp
logger = logging.getLogger(__name__)
class MgmtGrpEndpoint:
"""Represents a single endpoint (nh_group, nh_id pair)"""
def __init__(self, transport, nh_group, nh_id):
self.transport = t... | lohmega/python-mcumgr | mcumgr/mgmt.py | .py | 409016b0b59aa6b5 | 7.35 | 4 |
# mcumgr OS management group
from enum import IntEnum
from . import smp
from .mgmt import MgmtGrpBase, MgmtGrpEndpoint
class OS_MGMT_ID(IntEnum):
# fmt: off
ECHO = 0
CONS_ECHO_CTRL = 1
TASKSTAT = 2
MPSTAT = 3
DATETIME_STR = 4
RESET = 5
# fmt: on
... | lohmega/python-mcumgr | mcumgr/mgmt_os.py | .py | ae31301bdd3400a5 | 7.35 | 4 |
# mcumgr BLE Proxy management group
import logging
import time
from . import smp
from .mgmt import MgmtGrpBase, MgmtGrpEndpoint
logger = logging.getLogger(__name__)
# Group ID for BLE proxy
MGMT_GROUP_ID_SMP_PROXY_BLE = 254
# Command IDs for BLE proxy management group
SMP_PROXY_ID_BLE_STATUS = 0
SMP_PROXY_ID_BLE_CON... | lohmega/python-mcumgr | mcumgr/mgmt_proxy_ble.py | .py | 447610a61a7b6963 | 7.35 | 4 |
# mcumgr SMP (Simple Management Protocol) (previosly or based on NMP)
# see https://github.com/apache/mynewt-mcumgr for details.
# mynewt-mcumgr/protocol.md
# mynewt-mcumgrmgmt/inlcude/mgmt.h
from enum import Enum, IntEnum
import struct
import cbor2 as cbor
import logging
logger = logging.getLogger(__name__)
# M... | lohmega/python-mcumgr | mcumgr/smp.py | .py | 7bd7b7752abbaea4 | 7.35 | 4 |
# mcumgr SMP Proxy/Forward transport wrapper
import cbor2 as cbor
import logging
import struct
import time
from . import smp
from .mgmt_proxy_ble import MgmtGrpProxyBle
logger = logging.getLogger(__name__)
# Proxy management group IDs
MGMT_GROUP_ID_PROXY_FWD_MGMT = 255
PROXY_FWD_MGMT_ID_FWD = 1
# CBOR keys for prox... | lohmega/python-mcumgr | mcumgr/smp_proxy.py | .py | 7b229be1c0704f11 | 7.35 | 4 |
"""BLE (GATT) transport for the SMP protocol.
mcumgr/newtmgr over BLE uses a single GATT service with one characteristic that
takes write-without-response for requests and notifies for responses:
service 8D53DC1D-1DB7-4CD3-868B-8A527460AA84
charact DA2E7828-FBCE-4E01-AE9E-261174997C48
bleak is async and th... | lohmega/python-mcumgr | mcumgr/transport_ble.py | .py | 33aa700d326a3307 | 7.35 | 4 |
from queue import Queue, Empty
import threading
from threading import Thread, Event
from enum import IntEnum
import logging
import struct
import base64
# third party imports
import crcmod.predefined
import serial
# local imports
from mcumgr import smp
logger = logging.getLogger(__name__)
class NLIP_OP(IntEnum):
... | lohmega/python-mcumgr | mcumgr/transport_serial.py | .py | 90efcd7b0e804251 | 7.35 | 4 |
#!/usr/bin/env python3
"""
Test script for SMP BLE Proxy functionality.
This script connects to a proxy/dongle device over serial (NLIP) and uses it
to scan for and connect to BLE devices.
"""
import argparse
import glob
import logging
import sys
import os
import utils
from pprint import pprint
utils.use_repo_source... | lohmega/python-mcumgr | test/proxy_ble.py | .py | a409cd64f8f716b5 | 7.85 | 4 |
"""Unit tests for mcumgr.ble - the deprecated backward-compat import path.
Runs standalone (`python3 test/test_ble_compat.py`) or under pytest.
Requires bleak (imported transitively) and cbor2.
"""
import asyncio
import os
import sys
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), "..")))... | lohmega/python-mcumgr | test/test_ble_compat.py | .py | 258dd23608b4059a | 7.85 | 4 |
"""Unit tests for mcumgr.image - MCUboot header/TLV parsing.
Runs standalone (`python3 test/test_image.py`) or under pytest.
"""
import hashlib
import os
import struct
import sys
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), "..")))
from mcumgr import image
def _mk_image(hdr_size=32,... | lohmega/python-mcumgr | test/test_image.py | .py | 853116c941b84500 | 7.85 | 4 |
"""Unit tests for mcumgr.mgmt_proxy_ble - the BLE scan/connect proxy group.
Runs standalone (`python3 test/test_mgmt_proxy_ble.py`) or under pytest.
"""
import os
import sys
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), "..")))
from mcumgr import smp
from mcumgr.mgmt_proxy_ble import M... | lohmega/python-mcumgr | test/test_mgmt_proxy_ble.py | .py | 3e1eca0ad431703a | 7.85 | 4 |
from __future__ import annotations
from testing.mock import MockInteraction
def assert_responded(interaction: MockInteraction, contains: str = '') -> str:
"""Assert the interaction was responded to and return the message."""
assert interaction.responded
assert interaction.response_message is not None
... | gpauloski/3pseatBot | testing/asserts.py | .py | 0bfeae05c176ca02 | 7.74 | 2 |
from __future__ import annotations
import asyncio
import json
import pathlib
import time
import uuid
from collections.abc import Awaitable
from collections.abc import Callable
from collections.abc import Generator
from typing import Any
from typing import cast
from unittest import mock
import pytest
from discord impo... | gpauloski/3pseatBot | testing/utils.py | .py | 39cdab4ee6fa4007 | 7.74 | 2 |
from __future__ import annotations
import logging
import discord
from discord.ext import commands
from threepseat.commands import APP_COMMANDS
from threepseat.ext.extension import CommandGroupExtension
from threepseat.listeners import LISTENERS
from threepseat.logging import log_timing
logger = logging.getLogger(__... | gpauloski/3pseatBot | threepseat/bot.py | .py | 4dce26ddf44917fc | 7.24 | 2 |
from __future__ import annotations
import logging
from typing import Any
import discord
from discord import app_commands
from discord.app_commands.commands import Command as _Command
from discord.app_commands.commands import Group
from discord.ext import commands
type Command = _Command[Any, Any, Any] | Group
logge... | gpauloski/3pseatBot | threepseat/commands/commands.py | .py | 1580aebdbb9c032d | 7.24 | 2 |
from pkg_resources import resource_string
import json
from genie_pkg.generators import one_of, random_geo_coords
from genie_pkg import GenieException
from typing import Tuple
class Australia(object):
"""Provide random OZ address."""
def __init__(self):
"""Loads postcode data from repository."""
... | mkeshav/data-genie | genie_pkg/australia.py | .py | 23cc1a55f6d35850 | 7.24 | 2 |
import math
import string
import time
import uuid
from datetime import datetime
from datetime import timedelta
from ipaddress import IPv4Address, IPv6Address, IPv4Network
from random import getrandbits, choice, uniform, randint, Random
import markovify
import pytz
from pkg_resources import resource_string
from genie_... | mkeshav/data-genie | genie_pkg/generators.py | .py | eeef7e7ea7f7a160 | 7.24 | 2 |
#!/usr/bin/env python3
"""
Usage:
builder.py capture_os <os_name> [options] [--var <packer_args>...] [--before=<commit>]
builder.py (-h | --help)
Arguments:
<os_name> Name of the OS to capture (optional)
Options:
-h --help Display this message
-... | OSWatcher/osw-builder | osw_builder/__main__.py | .py | 8949e7c362ee6e27 | 7 | 0 |
import logging
from datetime import datetime
from pathlib import Path
from typing import Optional
from neogit.service import Neogit
from ..settings import settings
from .guest_filesystem import LibguestFSMnt
def capture_neogit(
qcow_path: Path,
vm_name: str,
branch_name: Optional[str] = None,
unique... | OSWatcher/osw-builder | osw_builder/capture/capture.py | .py | aee3aa8d5d2a865e | 7 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.