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 |
|---|---|---|---|---|---|---|
"""Test the PUDL console scripts from within PyTest."""
import importlib.metadata
import pytest
# Obtain a list of all deployed entry point scripts to test:
ENTRY_POINTS = importlib.metadata.distribution("catalystcoop.cheshire").entry_points
@pytest.mark.parametrize("ep", ENTRY_POINTS)
@pytest.mark.script_launch_m... | catalyst-cooperative/cheshire | tests/integration/console_scripts_test.py | .py | a71a507eec969c26 | 7.92 | 6 |
"""A dummy unit test so pytest has something to do."""
import logging
from pathlib import Path
import pytest
from cheshire.dummy import do_something
logger = logging.getLogger(__name__)
def test_nothing(test_dir: Path) -> None:
"""A dummy test that relies on our dummy fixture."""
assert isinstance(test_di... | catalyst-cooperative/cheshire | tests/unit/dummy_test.py | .py | 407ba578f12a64ce | 7.92 | 6 |
from contextlib import suppress
from typing import Any
from django.core.files.base import File
from django.core.files.uploadedfile import UploadedFile
from django.core.serializers.json import DjangoJSONEncoder
from django.db.models import Model, QuerySet
from django.db.models.fields.files import FieldFile
from django.... | stratusadv/django-glue | django_glue/encoders.py | .py | d8f59ea0c2979fcb | 7.45 | 7 |
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Any, TYPE_CHECKING
from django_glue.access import GlueAccess
from django_glue.utils import get_attr_from_path_string_on_instance
if TYPE_CHECKING:
from django_glue.glue.base import BaseGlue
class BaseGlueAttribute(ABC):
... | stratusadv/django-glue | django_glue/glue/attributes/base.py | .py | 6eaa6c92bdd5a860 | 7.45 | 7 |
#!/usr/bin/env python3
# SPDX-License-Identifier: Apache-2.0
# demo/draw_uli/onya_draw.py
'''
onya_draw — a small, general-purpose CLI for the draw_uli renderer prototype (Onya issue #33):
render *any* Onya Literate (`.onya`/`.onya.md`) file through a pluggable Design, not just the
two bundled reference graphs. Not a s... | OoriData/Onya | demo/draw_uli/onya_draw.py | .py | 74b5210abb725fab | 7.5 | 9 |
#!/usr/bin/env python3
# SPDX-License-Identifier: Apache-2.0
# demo/draw_uli/render_demo.py
'''
Demo script for the `draw_uli` renderer prototype (Onya issue #33): a theme-able, code-driven
graph illustration built on `onya.viz.nx` + matplotlib. Not a supported library API — see
`driver.py`'s module docstring and `REA... | OoriData/Onya | demo/draw_uli/render_demo.py | .py | 0a8130c824ad7b7b | 7.5 | 9 |
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2023-present Oori Data <info@oori.dev>
# SPDX-License-Identifier: Apache-2.0
# demo/graphviz_basic/graphviz_demo.py
'''
Demo script showing how to use the Onya Graphviz emitter
Usage:
python graphviz_demo.py
This will generate several .dot files that can be render... | OoriData/Onya | demo/graphviz_basic/graphviz_demo.py | .py | 3b3c4fbb559ebe0f | 7.5 | 9 |
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2023-present Oori Data <info@oori.dev>
# SPDX-License-Identifier: Apache-2.0
# demo/mermaid_basic/mermaid_demo.py
'''
Demo script showing how to use the Onya Mermaid emitter.
Usage:
python mermaid_demo.py
This will generate several .mmd files containing Mermaid ma... | OoriData/Onya | demo/mermaid_basic/mermaid_demo.py | .py | 2c21c5579b6e6186 | 7.5 | 9 |
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2023-present Oori Data <info@oori.dev>
# SPDX-License-Identifier: Apache-2.0
# demo/nx_analytics/nx_demo.py
'''
Demo: project an Onya graph into networkx, run analytics, and write the results back as
first-class Onya assertions.
Usage (from a fresh install with the ext... | OoriData/Onya | demo/nx_analytics/nx_demo.py | .py | 611f3e7fbcaef6d3 | 7.5 | 9 |
# SPDX-FileCopyrightText: 2023-present Oori Data <info@oori.dev>
# SPDX-License-Identifier: Apache-2.0
# onya
'''
Onya - Property graph model for Web resources
'''
from .__about__ import __version__ as __version__ # noqa: F401
from amara.iri import I
# Base IRI for Onya vocabulary
ONYA_BASEIRI = I('http://purl.org/... | OoriData/Onya | pylib/__init__.py | .py | 68105ca8b575bda4 | 7.5 | 9 |
# SPDX-FileCopyrightText: 2023-present Oori Data <info@oori.dev>
# SPDX-License-Identifier: Apache-2.0
# onya.cli.onya
'''
Onya CLI.
This CLI is intentionally simple: read Onya Literate (`.onya`) source text,
build a graph, then emit another representation such as Mermaid or Graphviz DOT.
Implementation notes:
- Use... | OoriData/Onya | pylib/cli/onya.py | .py | 0fbc40c52da184cb | 7.5 | 9 |
# SPDX-FileCopyrightText: 2023-present Oori Data <info@oori.dev>
# SPDX-License-Identifier: Apache-2.0
# onya.serial.literate
"""
Serialize and deserialize between an Onya model and Onya Literate (Markdown)
see: SPEC.md (Onya Literate serialization)
"""
import re
import sys
from onya import I
from onya.util import ... | OoriData/Onya | pylib/serial/literate.py | .py | 56cbdc889263ade9 | 7.5 | 9 |
# SPDX-FileCopyrightText: 2023-present Oori Data <info@oori.dev>
# SPDX-License-Identifier: Apache-2.0
# onya.store
'''
Pluggable persistence for Onya graphs.
Three backends ship in this package, discovered by URL scheme through the
``onya.store.backends`` entry-point group:
- ``file:`` — one Onya Literate fil... | OoriData/Onya | pylib/store/__init__.py | .py | b17858b3a6103248 | 7.5 | 9 |
# SPDX-FileCopyrightText: 2023-present Oori Data <info@oori.dev>
# SPDX-License-Identifier: Apache-2.0
# onya.store.base
'''
Store capability protocols.
Backends differ in power, so rather than one fat interface studded with
``NotImplementedError`` landmines we define a minimal base protocol plus optional
capability p... | OoriData/Onya | pylib/store/base.py | .py | 260999f3d8c07172 | 7.5 | 9 |
# SPDX-FileCopyrightText: 2023-present Oori Data <info@oori.dev>
# SPDX-License-Identifier: Apache-2.0
# onya.store.exceptions
'''
Store-layer exceptions.
Deliberately thin. The store layer reuses the model's vocabulary of failure rather than
minting parallel error types:
- a graph that is not present is a plain ``Ke... | OoriData/Onya | pylib/store/exceptions.py | .py | 4241499bdfa87a8c | 7.5 | 9 |
# SPDX-FileCopyrightText: 2023-present Oori Data <info@oori.dev>
# SPDX-License-Identifier: Apache-2.0
# onya.store.sync
'''
Minimal synchronous facade over the async store protocol, for scripts and REPL use.
This is a convenience only — not a second protocol and not backend-specific. Each call runs
the underlying cor... | OoriData/Onya | pylib/store/sync.py | .py | 4de9aeca2a16e21f | 7.5 | 9 |
# SPDX-FileCopyrightText: 2023-present Oori Data <info@oori.dev>
# SPDX-License-Identifier: Apache-2.0
# onya.util
from amara import iri
from onya import ONYA_BASEIRI
__all__ = [
'namespace_for_curie',
'join_namespace',
'curie_local_for_iri',
'compact_iri',
'shorten_node_id',
]
def shorten_node_... | OoriData/Onya | pylib/util.py | .py | 2ce9fb1950ae1a6a | 7.5 | 9 |
# SPDX-FileCopyrightText: 2023-present Oori Data <info@oori.dev>
# SPDX-License-Identifier: Apache-2.0
# onya.viz.mermaid
'''
Project an Onya model to Mermaid flowchart markup.
This module **only outputs Mermaid syntax**; it does not render diagrams.
Example usage:
from io import StringIO
from onya.graph imp... | OoriData/Onya | pylib/viz/mermaid.py | .py | bfa06faddb3fdae3 | 7.5 | 9 |
# -*- coding: utf-8 -*-
# test/store/conftest.py
'''
Fixtures for the store conformance suite. One behavioral suite runs against every backend
via the parameterized ``store`` fixture: filesystem and SQLite always; PostgreSQL when
``ONYA_TEST_PG_DSN`` is set (its schema is reset between tests).
'''
import os
import py... | OoriData/Onya | test/store/conftest.py | .py | 92d593e0d0028bbb | 8 | 9 |
# -*- coding: utf-8 -*-
# test/store/store_helpers.py
'''
Shared helpers for the store conformance suite: parsing, in-memory graph reference (the
model union every backend is measured against), and a structural equality check that
compares property values by string content (LITERAL vs str is a Python-type distinction,
... | OoriData/Onya | test/store/store_helpers.py | .py | 83a78924662b4a09 | 8 | 9 |
# -*- coding: utf-8 -*-
# test/store/test_store_assertions.py
'''
Behavioral tests for the ``AssertionStore`` capability (fine-grained access without
materializing the whole graph). Runs against every backend from the ``store`` fixture that
offers the capability — SQLite always, PostgreSQL when ``ONYA_TEST_PG_DSN`` is ... | OoriData/Onya | test/store/test_store_assertions.py | .py | ddc59a217a6a553a | 8 | 9 |
# -*- coding: utf-8 -*-
# test/store/test_store_connect.py
'''
The ``connect`` factory's scheme dispatch and the synchronous facade.
pytest -s test/store/test_store_connect.py
'''
import pytest
from onya.store import connect
from onya.store.sync import connect as sync_connect
from store_helpers import DOCHEADER,... | OoriData/Onya | test/store/test_store_connect.py | .py | 2dfd84d8659dd4ab | 8 | 9 |
# -*- coding: utf-8 -*-
# test/store/test_store_convention.py
'''
Filesystem-backend fidelity: a store round trip preserves an authored file's namespace
convention (so ``materialize -> serialize -> commit -> re-seed`` keeps git diffs compact and
reviewable) while staying a faithful graph union. Filesystem-specific: it ... | OoriData/Onya | test/store/test_store_convention.py | .py | 9c56d46d54868340 | 8 | 9 |
# -*- coding: utf-8 -*-
# test/store/test_store_guards.py
'''
Architectural guards, each run in a fresh subprocess so module-import state is pristine:
- **Layering**: importing the core (``onya.graph``, ``onya.serial.literate``, ``onya.interp``)
must not drag in anything under ``onya.store`` — storage is a periphera... | OoriData/Onya | test/store/test_store_guards.py | .py | e554629185ccd0ee | 8 | 9 |
# -*- coding: utf-8 -*-
# test/store/test_store_packaging.py
'''
The store backend entry points are registered under the *installed* (`onya.store.*`) names.
Because this repo maps ``pylib`` -> ``onya`` only during wheel building, this is meaningful
only against a real install (``uv pip install -U .``), never an editabl... | OoriData/Onya | test/store/test_store_packaging.py | .py | 1e816f380ecb7f25 | 7 | 9 |
# -*- coding: utf-8 -*-
# test_assertion_id.py
'''
Tests for explicit assertion identifiers (the `@id` directive).
See SPEC.md § Assertion Identifiers.
pytest -s test/test_assertion_id.py
'''
from io import StringIO
import pytest
from amara.iri import I
from onya import ONYA_BASEIRI
from onya.graph import gra... | OoriData/Onya | test/test_assertion_id.py | .py | d828940273093d10 | 7 | 9 |
"""Author: Jakub Gnyp; contact: gnyp.jakub@gmail.com, LinkedIn: https://www.linkedin.com/in/gnypit/
This file contains pre-defined crossover operators for the Generation class from genal.py to use within
the genetic algorithm.
Parents passed to function should be of class Member from genal.py
"""
from numpy.random i... | gnypit/pyqkd | genal/crossover_operators.py | .py | cab899220942a6da | 7.5 | 9 |
"""Inspired by James Cutajar: https://github.com/cutajarj/multithreadinginpython
Created for an online computational intelligence course with Helion.pl sp. z o.o."""
from multiprocessing import Process, Array, cpu_count
from time import time
from random import randint
from numpy import dot
"""To test the code, we crea... | gnypit/pyqkd | matrix_multiply_parallel.py | .py | ca21fe64ca3aad79 | 7.5 | 9 |
import multiprocessing
from genal.genetic_algorithm import GeneticAlgorithm, Generation
from numpy import arange
class ParallelGeneticAlgorithm(GeneticAlgorithm):
"""This class is supposed to enable fitness calculations in parallel. It is based on Python's multiprocessing module
https://docs.python.org/3/libr... | gnypit/pyqkd | parallel_work_in_progress/parallel/parallel_genetic_algorithm.py | .py | ceac1e7c2cfd02fc | 7.5 | 9 |
"""
Author: Jakub Gnyp; contact: gnyp.jakub@gmail.com, LinkedIn: https://www.linkedin.com/in/gnypit/
Functions and constants based on FIPS PUB 180-4 from:
http://dx.doi.org/10.6028/NIST.FIPS.180-4
"""
def constant_sha1(index):
if 0 <= index <= 19:
return 0x5a827999
elif 20 <= index <= 39:
retu... | gnypit/pyqkd | simulator_ver1/hashing.py | .py | 547e33bef4f322ea | 7.5 | 9 |
from asyncio import sleep
import asyncio
import ctypes
from multiprocessing import Array, Process, RawArray
from time import perf_counter
# Computables
class Computable():
def __init__(self, **kwargs) -> None:
self.arguments = kwargs
def print_arguments(self) -> str:
for key, value in self.... | gnypit/pyqkd | simulator_ver1/parallel.py | .py | 37440e4ede47f447 | 7.5 | 9 |
"""PyCalc is a simple calculator built with Python and PyQt."""
import sys
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import (
QApplication,
QGridLayout,
QLineEdit,
QMainWindow,
QPushButton,
QVBoxLayout,
QWidget,
)
from functools import partial
ERROR_MSG = "ERROR"
WINDOW_SIZE = 235
... | gnypit/pyqkd | simulator_ver1/qt_calculator.py | .py | 2ae66f2cc7723387 | 7.5 | 9 |
import math
import random
import numpy as np
from scipy.stats import binom
from scipy.special import betainc
def numerical_error_prob(n_errors, pass_size, qber): # probability that n_errors remain
prob = binom.pmf(n_errors, pass_size, qber) + binom.pmf(n_errors + 1, pass_size, qber)
return prob
def sum_er... | gnypit/pyqkd | simulator_ver2/cascade.py | .py | 42bbfb7e74c1356a | 7.5 | 9 |
import random
import numpy as np
def naive_error(alice_key, bob_key, publication_probability):
"""
Originally I've been testing algorithm on short strings, i.e. up to 20 bits in original Alice's message.
Sifted keys were therefore too short for publication of any parts of them for error estimation.
... | gnypit/pyqkd | simulator_ver2/error_estimation.py | .py | 6dcf33892c998bf3 | 7.5 | 9 |
import random
import math
import time
from typing import Tuple, Any
import numpy as np
from scipy.stats import binom
from scipy.special import betainc
from sympy import symbols, I, Matrix, sqrt, simplify
from sympy.physics.quantum import TensorProduct, InnerProduct, OuterProduct
from sympy.physics.quantum.dagger imp... | gnypit/pyqkd | simulator_ver2/qkd.py | .py | 969473bae6164041 | 7.5 | 9 |
"""
File Name: base.py
Author: Panyi Dong
GitHub: https://github.com/PanyiDong/
Mathematics Department, University of Illinois at Urbana-Champaign (UIUC)
Project: InsurAutoML
Latest Version: 0.2.5
Relative Path: /InsurAutoML/balancing/base.py
File Created: Monday, 29th May 2023 2:05:55 pm
Author: Panyi Dong (panyid2@i... | PanyiDong/InsurAutoML | InsurAutoML/balancing/base.py | .py | 887c4ad67264d753 | 7.56 | 12 |
"""
File Name: base.py
Author: Panyi Dong
GitHub: https://github.com/PanyiDong/
Mathematics Department, University of Illinois at Urbana-Champaign (UIUC)
Project: InsurAutoML
Latest Version: 0.2.6
Relative Path: /InsurAutoML/base.py
File Created: Monday, 24th October 2022 11:56:57 pm
Author: Panyi Dong (panyid2@illino... | PanyiDong/InsurAutoML | InsurAutoML/base.py | .py | c79edef9feb710a9 | 7.56 | 12 |
"""
File: _constant.py
Author: Panyi Dong
GitHub: https://github.com/PanyiDong/
Mathematics Department, University of Illinois at Urbana-Champaign (UIUC)
Project: InsurAutoML
Latest Version: 0.2.6
Relative Path: /InsurAutoML/constant.py
File: _constant.py
Author: Panyi Dong (panyid2@illinois.edu)
-----
Last Modified:... | PanyiDong/InsurAutoML | InsurAutoML/constant.py | .py | ca14d0ca0918b9d5 | 7.56 | 12 |
"""
File Name: base.py
Author: Panyi Dong
GitHub: https://github.com/PanyiDong/
Mathematics Department, University of Illinois at Urbana-Champaign (UIUC)
Project: InsurAutoML
Latest Version: 0.2.6
Relative Path: /InsurAutoML/encoding/base.py
File Created: Monday, 29th May 2023 2:13:01 pm
Author: Panyi Dong (panyid2@il... | PanyiDong/InsurAutoML | InsurAutoML/encoding/base.py | .py | 81cc2be59fcce78d | 7.56 | 12 |
"""
File Name: twinreduction.py
Author: Panyi Dong
GitHub: https://github.com/PanyiDong/
Actuarial and Risk Management Sciences, University of Illinois at Urbana-Champaign (UIUC)
Project: InsurAutoML
Latest Version: 0.2.6
Relative Path: /InsurAutoML/ext/twinreduction/twinreduction/twinreduction.py
File Created: Thursd... | PanyiDong/InsurAutoML | InsurAutoML/ext/twinreduction/twinreduction/twinreduction.py | .py | aac340d604dbe1b6 | 7.56 | 12 |
"""
File Name: embed.py
Author: Panyi Dong
GitHub: https://github.com/PanyiDong/
Mathematics Department, University of Illinois at Urbana-Champaign (UIUC)
Project: InsurAutoML
Latest Version: 0.2.5
Relative Path: /InsurAutoML/feature_selection/embed.py
File Created: Monday, 24th October 2022 11:56:57 pm
Author: Panyi ... | PanyiDong/InsurAutoML | InsurAutoML/feature_selection/embed.py | .py | a82b52f31c8087a5 | 7.56 | 12 |
"""
File Name: filter.py
Author: Panyi Dong
GitHub: https://github.com/PanyiDong/
Mathematics Department, University of Illinois at Urbana-Champaign (UIUC)
Project: InsurAutoML
Latest Version: 0.2.6
Relative Path: /InsurAutoML/feature_selection/filter.py
File Created: Monday, 24th October 2022 11:56:57 pm
Author: Pany... | PanyiDong/InsurAutoML | InsurAutoML/feature_selection/filter.py | .py | 33ed8eeadfb040da | 7.56 | 12 |
"""
File Name: wrapper.py
Author: Panyi Dong
GitHub: https://github.com/PanyiDong/
Mathematics Department, University of Illinois at Urbana-Champaign (UIUC)
Project: InsurAutoML
Latest Version: 0.2.6
Relative Path: /InsurAutoML/feature_selection/wrapper.py
File Created: Monday, 24th October 2022 11:56:57 pm
Author: Pa... | PanyiDong/InsurAutoML | InsurAutoML/feature_selection/wrapper.py | .py | 8b96efd9724c905a | 7.56 | 12 |
"""
File Name: fixed.py
Author: Panyi Dong
GitHub: https://github.com/PanyiDong/
Actuarial and Risk Management Sciences, University of Illinois at Urbana-Champaign (UIUC)
Project: InsurAutoML
Latest Version: 0.2.6
Relative Path: /InsurAutoML/hpo/informed/fixed.py
File Created: Wednesday, 3rd December 2025 1:38:19 pm
A... | PanyiDong/InsurAutoML | InsurAutoML/hpo/informed/fixed.py | .py | bbaa26e9e2fef92e | 7.56 | 12 |
"""
File Name: informed_ensemble.py
Author: Panyi Dong
GitHub: https://github.com/PanyiDong/
Actuarial and Risk Management Sciences, University of Illinois at Urbana-Champaign (UIUC)
Project: InsurAutoML
Latest Version: 0.2.6
Relative Path: /InsurAutoML/hpo/informed/informed_ensemble.py
File Created: Thursday, 4th Dec... | PanyiDong/InsurAutoML | InsurAutoML/hpo/informed/informed_ensemble.py | .py | dfebd4e538e01625 | 7.56 | 12 |
"""
File Name: utils.py
Author: Panyi Dong
GitHub: https://github.com/PanyiDong/
Actuarial and Risk Management Sciences, University of Illinois at Urbana-Champaign (UIUC)
Project: InsurAutoML
Latest Version: 0.2.6
Relative Path: /InsurAutoML/hpo/informed/utils.py
File Created: Thursday, 4th December 2025 10:14:34 am
A... | PanyiDong/InsurAutoML | InsurAutoML/hpo/informed/utils.py | .py | 3d55f56e0bc06c2e | 7.56 | 12 |
from __future__ import annotations
import email
import textwrap
from email.message import Message
__all__ = ["metadata_to_json"]
_MULTIPLE_USE_KEYS = {
key.lower()
for key in [
# PEP 345 (1.2)
"Platform",
"Supported-Platform",
"Classifier",
"Requires-Dist",
"P... | dairiki/hatch-zipped-directory | hatch_zipped_directory/metadata.py | .py | 42389954d8d59658 | 7.63 | 17 |
import hashlib
import os
import shutil
import subprocess
import sys
from pathlib import Path
from zipfile import ZipFile
import pytest
@pytest.fixture(scope="session")
def plugin_uri(
tmp_path_factory: pytest.TempPathFactory, pytestconfig: pytest.Config
) -> str:
"""Generate URI to a temporary copy of our so... | dairiki/hatch-zipped-directory | tests/test_functional.py | .py | 0008ec34edd57b67 | 8.13 | 17 |
import inspect
import pytest
from hatch_zipped_directory.metadata import metadata_to_json
REQUIRED_METADATA = (
inspect.cleandoc(
"""
Metadata-Version: 42.2
Name: dummy-test-project
Version: 0.1a1
"""
)
+ "\n"
)
REQUIRED_METADATA_JSON = {
"metadata_version": "... | dairiki/hatch-zipped-directory | tests/test_metadata.py | .py | e2ce4cb97bd66545 | 7.13 | 17 |
"""Define the cache sub-command."""
from typing import Annotated
import rich
import typer
from loguru import logger
from brokenspoke_analyzer.core import (
file_utils,
)
app = typer.Typer()
console = rich.get_console()
@app.command()
def clean(
dry_run: Annotated[ # noqa: FBT002
bool | None,
... | PeopleForBikes/brokenspoke-analyzer | brokenspoke_analyzer/cli/cache.py | .py | a8776e814c5f5fa9 | 7.57 | 13 |
"""Define the configure subcommand."""
from typing import Annotated
import rich
import typer
from brokenspoke_analyzer.cli import common
from brokenspoke_analyzer.core.database import dbcore
Cores = Annotated[int, typer.Argument(help="number of cores")]
MemoryMB = Annotated[int, typer.Argument(help="memory amount i... | PeopleForBikes/brokenspoke-analyzer | brokenspoke_analyzer/cli/configure.py | .py | 739063a97acf1ec1 | 7.57 | 13 |
"""Define the prepare sub-command."""
import asyncio
import pathlib
import aiohttp
import geopandas as gpd
import pycountry
import rich
import typer
from loguru import logger
from brokenspoke_analyzer.cli import common
from brokenspoke_analyzer.core import (
analysis,
datastore,
downloader,
runner,
... | PeopleForBikes/brokenspoke-analyzer | brokenspoke_analyzer/cli/prepare.py | .py | edb33d940da72ec4 | 7.57 | 13 |
"""Define the top-level commands."""
import logging
from importlib import (
metadata,
)
from typing import Annotated
import typer
from loguru import logger
from rich.logging import RichHandler
from brokenspoke_analyzer.cli import (
cache,
compute,
configure,
export,
importer,
prepare,
... | PeopleForBikes/brokenspoke-analyzer | brokenspoke_analyzer/cli/root.py | .py | 93be4dd9e8ee003b | 7.57 | 13 |
"""Define the run-with sub-command."""
import asyncio
import pathlib
import subprocess
from importlib import resources
import rich
import typer
from loguru import logger
from brokenspoke_analyzer.cli import (
common,
configure,
export,
prepare,
)
from brokenspoke_analyzer.core import (
analysis,
... | PeopleForBikes/brokenspoke-analyzer | brokenspoke_analyzer/cli/run_with.py | .py | e4910a2c2b70d277 | 7.57 | 13 |
"""Define functions used to perform an analysis."""
import os
import pathlib
import random
import string
import warnings
import zipfile
import geopandas as gpd
import numpy as np
import shapely
from slugify import slugify
from brokenspoke_analyzer.core import (
constant,
runner,
utils,
)
warnings.filter... | PeopleForBikes/brokenspoke-analyzer | brokenspoke_analyzer/core/analysis.py | .py | 46d6f3b9eee3539e | 7.57 | 13 |
"""
Define functions to run SQL scripts.
Define functions to run the various SQL scripts performing the operations to
compute the BNA scores.
"""
import dataclasses
import pathlib
import typing
from loguru import logger
from sqlalchemy.engine import Engine
from brokenspoke_analyzer.cli import common
from brokenspok... | PeopleForBikes/brokenspoke-analyzer | brokenspoke_analyzer/core/compute.py | .py | fa1cab052ab9053f | 7.57 | 13 |
"""Define functions used to manipulate database data."""
import pathlib
import typing
from sqlalchemy import (
create_engine,
text,
)
from sqlalchemy.engine import Engine
from brokenspoke_analyzer.core import runner
def execute_query(engine: Engine, query: str) -> None:
"""Execute a query and commit it... | PeopleForBikes/brokenspoke-analyzer | brokenspoke_analyzer/core/database/dbcore.py | .py | 4a60e7738d5091fd | 7.57 | 13 |
"""Define functions used to download files."""
import re
import aiohttp
import yarl
from bs4 import BeautifulSoup
from loguru import logger
PFB_PUBLIC_DOCUMENTS_URL = "https://s3.amazonaws.com/pfb-public-documents"
TIGER_URL = "https://www2.census.gov/geo/tiger"
CHUNK_SIZE = 65536
LODES_URL = "https://lehd.ces.censu... | PeopleForBikes/brokenspoke-analyzer | brokenspoke_analyzer/core/downloader.py | .py | b3f81ba6aebd2899 | 7.57 | 13 |
"""Provides utility functions for file and directory operations."""
import pathlib
import shutil
from dataclasses import dataclass
from platformdirs import PlatformDirs
from brokenspoke_analyzer.core import constant
@dataclass
class BaseResult:
"""Base result class with common fields for deletion operations.""... | PeopleForBikes/brokenspoke-analyzer | brokenspoke_analyzer/core/file_utils.py | .py | cb8eeaad224f163a | 7.57 | 13 |
"""Define helper function to run external commands."""
import json
import multiprocessing
import pathlib
import subprocess
import typing
import urllib.parse
from loguru import logger
NON_US_STATE_FIPS = "0"
NON_US_STATE_ABBREV = "ZZ"
def run(cmd: typing.Sequence[str]) -> None:
"""Run a command and log the stdo... | PeopleForBikes/brokenspoke-analyzer | brokenspoke_analyzer/core/runner.py | .py | 5419ab36672bb4ae | 7.57 | 13 |
"""Define utility functions."""
import gzip
import hashlib
import pathlib
import typing
import zipfile
from enum import Enum
import geopandas as gpd
from loguru import logger
from slugify import slugify
# WGS 84 / Pseudo-Mercator -- Spherical Mercator.
# https://epsg.io/3857
PSEUDO_MERCATOR_CRS = "EPSG:3857"
class... | PeopleForBikes/brokenspoke-analyzer | brokenspoke_analyzer/core/utils.py | .py | 655689eef30f8db3 | 7.57 | 13 |
# /// script
# requires-python = ">=3.14"
# dependencies = [
# "isort>=7.0.0",
# "minijinja>=2.13.0",
# "ruff>=0.14.8",
# "xdoctest>=1.3.0",
# ]
# ///
"""
Render the Markdown file from the CSV file.
Run with:
uv run x.py e2e-cities.csv README.j2
Format with:
uv tool run isort x.py --profile bl... | PeopleForBikes/brokenspoke-analyzer | integration/x.py | .py | a1f12a042756c681 | 7.57 | 13 |
"""Test the analysis module."""
from osmnx import (
geocoder,
settings,
)
from brokenspoke_analyzer.core import analysis
def test_osmnx_query_multipolygon():
"""Ensure the osmnx query returns a multypoligon."""
settings.log_console = True
structured_query, q, _ = analysis.osmnx_query(
co... | PeopleForBikes/brokenspoke-analyzer | tests/brokenspoke_analyzer/core/test_analysis.py | .py | 0ba116a18a0cfa6f | 7.07 | 13 |
"""
Pre-populate the analyzer cache.
This is a small utility to warm-up you cache with US data.
The cache will be populated with the following items:
- US 2020 Census blocks
- US 2022 LODES data (employment)
- US 2025 Census Places
- US 2025 Census County Subdivisions
- US Water blocks
- US St... | PeopleForBikes/brokenspoke-analyzer | utils/cache-warmer.py | .py | 52b34c47bbb4aad7 | 7.57 | 13 |
"""This is a test file for the Running Calculator program."""
# pylint: disable=locally-disabled, wrong-import-position, import-error
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from main import calculate_distance, display_result
def test_calculate_distance():... | willtheorangeguy/Running-Calculator | tests/test_main.py | .py | c02cfd6e1afa8de1 | 7.92 | 6 |
import dataclasses
import enum
import functools
import types
import typing
TAG_NAME_CACHE_SIZE: typing.Final = 4096
# tag names come from arbitrary web pages, so the cache has to be bounded
@functools.lru_cache(maxsize=TAG_NAME_CACHE_SIZE)
def _transform_tag_name(tag_name: str) -> str:
return tag_name.replace("... | xfenix/meta-tags-parser | meta_tags_parser/structs.py | .py | 5f14dd8299b3d3dc | 7.45 | 7 |
import dataclasses
import pathlib
import typing
import hypothesis
import pytest
from faker import Faker
from meta_tags_parser import parse, structs
FIXTURES_DIRECTORY: typing.Final = pathlib.Path(__file__).parent / "html_fixtures"
DETERMINISTIC_SEED: typing.Final = 20260818
HYPOTHESIS_PROFILE_NAME: typing.Final = "... | xfenix/meta-tags-parser | tests/conftest.py | .py | 707dd312a52ffed6 | 7.95 | 7 |
"""Access helpers for the corpus of pages captured from real sites.
The pages live in ``tests/html_corpus`` as gzipped copies of the exact bytes the site served, and
``pages.json`` records where each one came from. Everything is module level so that tests can
parametrize over the corpus at collection time.
"""
import... | xfenix/meta-tags-parser | tests/corpus_support.py | .py | f523be4c701ec302 | 7.95 | 7 |
"""Polyfactory factories for the public data model.
They keep property style tests honest: instead of hand writing a handful of settings objects we let
polyfactory build many of them, with the ranges narrowed to values that make sense for a parser.
"""
import random
import typing
from polyfactory.factories import da... | xfenix/meta-tags-parser | tests/factories.py | .py | df208bf22a18aa93 | 7.95 | 7 |
import torch
def equilibrate(
A,
alpha_squared=1,
beta_squared=1,
gamma=1.0,
M=1000.,
iterations=20,
):
"""
Algorithm taken from:
S. Diamond, S. Boyd. Stochastic Matrix-Free Equilibration,
*Journal of Optimization Theory and Applications*... | cvxgrp/torch_linops | linops/equilibration.py | .py | 46643d1cf82c216c | 7.62 | 16 |
import torch
import linops as lo
def minres(A, b, M=None, x0=None, tol=1e-5, maxiters=None, verbose=True):
"""
Code based on scipy.sparse.linalg.minres
Copyright 2022 Parth Nobel
Copyright 2001-2002 Enthought, Inc. 2003-2022, SciPy Developers.
All rights reserved.
Redistribution and use in s... | cvxgrp/torch_linops | linops/minres.py | .py | 0a5e761b5076f430 | 7.62 | 16 |
import holoviews
import numpy
from .utils import gram_opts
def get_box_stream(source_pic, bounds: tuple = None):
"""
Get a Holoviews BoundsXY stream for a source plot with optional default bounds.
This function creates a Holoviews BoundsXY stream for the specified `source_pic`,
which is a Holoviews ... | echostack-org/echoshader | echoshader/box.py | .py | dc4fc4acaedcd5a8 | 7.56 | 12 |
import numpy
import plotly.graph_objects as go
import pyvista
import xarray
def curtain_plot_plotly(
MVBS_ds: xarray.Dataset,
cmap: str | list[str] = "jet",
clim: tuple = None,
ratio: float = 0.001,
width: int = 800,
height: int = 600,
) -> go.Figure:
"""
Create and display a 3D curtai... | echostack-org/echoshader | echoshader/curtain.py | .py | 7a3f8681ebe90433 | 7.56 | 12 |
import holoviews
import numpy
import xarray
from .utils import gram_opts
def single_echogram(
MVBS_ds: xarray,
channel: str,
cmap: str | list[str],
value_range: tuple[float, float],
vert_dim: str | None = "echo_range",
):
"""
Generate an echogram for a single frequency channel.
This ... | echostack-org/echoshader | echoshader/echogram.py | .py | dd8e5e9955892a52 | 7.56 | 12 |
""" Handles unifying command line arguments, environment variables, and config file settings. """
import os
import builtins
import argparse
import configparser
from typing import Optional, Any
from dataclasses import dataclass, field, asdict
@dataclass
class ConfigOption:
""" Represents a configurable option. `sh... | Qyriad/Seance | seance/config.py | .py | d981e632edc4671f | 7.62 | 16 |
""" This module handles a Discord server that has been marked as the proxy for DMs
that the bot receives and for the bot to send. """
import re
import sys
import time
import sqlite3
from datetime import datetime, timedelta
import discord
import discord.abc
import discord.utils
import discord.errors
import discord.app... | Qyriad/Seance | seance/discord_bot/dm_mode.py | .py | 337e421f0178aea3 | 7.62 | 16 |
""" The Telegram bot version of Seance. """
import os
import re
import sys
import argparse
from io import StringIO
import telegram
from telegram import Update
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext
class SeanceClient:
def __init__(self, ref_usernames, pattern... | Qyriad/Seance | seance/telegram_bot.py | .py | 7ea787896af9ef6e | 7.62 | 16 |
import warnings
from typing import Any, cast
import pydantic
from pydantic_apply.utils import assignment_validation_context, is_pydantic_apply_annotation
class ApplyModelMixin(pydantic.BaseModel):
"""Mixin to allow models to apply partly changes to their data."""
def model_apply(
self,
chan... | ddanier/pydantic-apply | pydantic_apply/apply.py | .py | c8f774435b4b8dc1 | 7.42 | 6 |
from collections.abc import Generator
from contextlib import contextmanager
from types import UnionType
from typing import Any, Union, get_args, get_origin
import pydantic
import pydantic_apply
from ._compat import PYDANTIC_GE_V2_11
def is_pydantic_apply_annotation(annotation: type | UnionType) -> bool:
"""Ret... | ddanier/pydantic-apply | pydantic_apply/utils.py | .py | 08beb23e94160000 | 7.42 | 6 |
"""Publish simple item state changes via MQTT."""
import asyncio
import logging
from homeassistant.components import mqtt
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.helpers.typing import ConfigType
from .const import DOMAIN, STARTUP_DELAY
from .mqttunit import MQTTUnit
from .schema ... | RogerSelwyn/mqtt_discoverystream_ha | custom_components/mqtt_discoverystream_alt/__init__.py | .py | baa4d78201178ae4 | 7.52 | 10 |
"""binary_sensor methods for MQTT Discovery Statestream."""
from homeassistant.const import STATE_OFF, STATE_ON, Platform
from ..helpers.base_entity import DiscoveryEntity
from ..utils import EntityInfo
class DiscoveryItem(DiscoveryEntity):
"""Binary_sensor class."""
PLATFORM = Platform.BINARY_SENSOR
... | RogerSelwyn/mqtt_discoverystream_ha | custom_components/mqtt_discoverystream_alt/classes/binary_sensor.py | .py | 3877f9394fc8ee7e | 7.52 | 10 |
"""Base for all discovery entities."""
import json
import logging
from homeassistant.components import mqtt
from homeassistant.const import ATTR_STATE
from homeassistant.helpers.json import JSONEncoder
from ..const import ATTR_ATTRIBUTES, SUPPORTED_ENTITY_TYPE_COMMANDS
from ..utils import EntityInfo
_LOGGER = loggi... | RogerSelwyn/mqtt_discoverystream_ha | custom_components/mqtt_discoverystream_alt/classes/entity.py | .py | 308fd6d653f553a4 | 7.52 | 10 |
"""event methods for MQTT Discovery Statestream."""
import logging
from homeassistant.components.event import (
EventEntityCapabilityAttribute,
EventEntityStateAttribute,
)
from homeassistant.components.mqtt.event import CONF_EVENT_TYPES
from homeassistant.const import ATTR_STATE, Platform
from ..helpers.bas... | RogerSelwyn/mqtt_discoverystream_ha | custom_components/mqtt_discoverystream_alt/classes/event.py | .py | 0a9d68c9a49108df | 7.52 | 10 |
"""Image methods for MQTT Discovery Statestream."""
import logging
from homeassistant.components.mqtt.const import ( # pylint: disable=home-assistant-component-root-import
CONF_ENTITY_PICTURE,
)
from homeassistant.components.mqtt.image import ( # pylint: disable=home-assistant-component-root-import
CONF_URL... | RogerSelwyn/mqtt_discoverystream_ha | custom_components/mqtt_discoverystream_alt/classes/image.py | .py | b4868e446bc22d0d | 7.52 | 10 |
"""Infrared methods for MQTT Discovery Statestream."""
import json
import logging
from homeassistant.components import mqtt
from homeassistant.components.infrared import (
InfraredDeviceClass,
InfraredReceivedSignal,
async_subscribe_receiver,
)
from homeassistant.components.mqtt.infrared import CONF_SCHEM... | RogerSelwyn/mqtt_discoverystream_ha | custom_components/mqtt_discoverystream_alt/classes/infrared.py | .py | f8dffcb5da562336 | 7.52 | 10 |
"""Lawn Mower methods for MQTT Discovery Statestream."""
import logging
from homeassistant.components.lawn_mower import (
SERVICE_DOCK,
SERVICE_PAUSE,
SERVICE_START_MOWING,
LawnMowerEntityFeature,
)
from homeassistant.components.mqtt.const import ( # pylint: disable=home-assistant-component-root-impo... | RogerSelwyn/mqtt_discoverystream_ha | custom_components/mqtt_discoverystream_alt/classes/lawn_mower.py | .py | 6d9d6ba430065e77 | 7.52 | 10 |
"""scene methods for MQTT Discovery Statestream."""
import logging
from homeassistant.components.mqtt.const import ( # pylint: disable=home-assistant-component-root-import
CONF_COMMAND_TOPIC,
)
from homeassistant.const import (
ATTR_ENTITY_ID,
CONF_PAYLOAD_ON,
SERVICE_TURN_ON,
STATE_ON,
Platf... | RogerSelwyn/mqtt_discoverystream_ha | custom_components/mqtt_discoverystream_alt/classes/scene.py | .py | 35da975468259fec | 7.52 | 10 |
"""sensor methods for MQTT Discovery Statestream."""
from homeassistant.components.mqtt.const import ( # pylint: disable=home-assistant-component-root-import
CONF_SUGGESTED_DISPLAY_PRECISION,
)
from homeassistant.components.sensor import CONF_STATE_CLASS, DOMAIN as SENSOR_DOMAIN
from homeassistant.const import Pl... | RogerSelwyn/mqtt_discoverystream_ha | custom_components/mqtt_discoverystream_alt/classes/sensor.py | .py | 3ab8a3dffe360e03 | 7.52 | 10 |
"""Water heater methods for MQTT Discovery Statestream."""
import logging
from homeassistant.components.mqtt.const import ( # pylint: disable=home-assistant-component-root-import
CONF_STATE_TOPIC,
)
from homeassistant.components.mqtt.water_heater import ( # pylint: disable=home-assistant-component-root-import
... | RogerSelwyn/mqtt_discoverystream_ha | custom_components/mqtt_discoverystream_alt/classes/water_heater.py | .py | 370acec8989e4fe4 | 7.52 | 10 |
"""Base for all discovery entities."""
import json
import logging
from homeassistant.components import mqtt
from homeassistant.const import ATTR_STATE
from homeassistant.core import HomeAssistant
from homeassistant.helpers.json import JSONEncoder
from ..const import ATTR_ATTRIBUTES, OUTPUT_ENTITIES, SUPPORTED_ENTITY... | RogerSelwyn/mqtt_discoverystream_ha | custom_components/mqtt_discoverystream_alt/helpers/base_entity.py | .py | dc7dd724139e56d3 | 7.52 | 10 |
"""Utilities for MQTT Discovery Stream."""
from dataclasses import dataclass, field
from typing import Any
from homeassistant.components.mqtt.abbreviations import ( # pylint: disable=home-assistant-component-root-import
ABBREVIATIONS,
DEVICE_ABBREVIATIONS,
ORIGIN_ABBREVIATIONS,
)
from homeassistant.compo... | RogerSelwyn/mqtt_discoverystream_ha | custom_components/mqtt_discoverystream_alt/utils.py | .py | f1a4c05bda7e926c | 7.52 | 10 |
from __future__ import annotations
from collections import Counter
from itertools import permutations
from math import factorial
from typing import Dict, List, Optional, Union
import numpy as np
from numpy.typing import NDArray
import daceypy
def fill_symmetric_tensor(
tensor: NDArray[np.float64],
indices:... | giovannipurpura/daceypy | daceypy/DA_utils.py | .py | c12b7ac25d48313e | 7.66 | 20 |
"""
# Differential Algebra Core Engine in Python - DACEyPy
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
Unless required by applicable law or agree... | giovannipurpura/daceypy | daceypy/_ADS.py | .py | 4c0b38acf4f8c817 | 7.66 | 20 |
"""
# Differential Algebra Core Engine in Python - DACEyPy
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
Unless required by applicable law or agree... | giovannipurpura/daceypy | daceypy/_PrettyType.py | .py | 2a12bb238256420b | 7.66 | 20 |
import daceypy_import_helper # noqa: F401
from daceypy import DA, array, ADS
import numpy as np
import matplotlib.pyplot as plt
def somb(x: array) -> DA:
"""
Evaluate sombrero function
"""
norm_x = x.vnorm()
return norm_x.sin() / norm_x
def eFun(domain_0: ADS) -> ADS:
"""
Evaluate tr... | giovannipurpura/daceypy | docs/ADS/1Basics-Ex.py | .py | 06b53b847e930048 | 7.66 | 20 |
import daceypy_import_helper # noqa: F401
from math import pi
from typing import Union, overload
from daceypy import DA
from daceypy.op import cos, sin, sqrt # can be used on DA and on floats
# Exercise 2.1.1: derivatives
@overload
def somb(x: DA, y: DA) -> DA: ... # only for typechecking
@overload
def somb(x... | giovannipurpura/daceypy | docs/Tutorials/Tutorial2/2IntDiff-Ex.py | .py | a33ca891717af6ea | 7.66 | 20 |
import daceypy_import_helper # noqa: F401
from inspect import getsourcefile
from math import pi, sin, sqrt
from pathlib import Path
import numpy as np
from daceypy import DA
sourcefile = getsourcefile(lambda: 0)
assert sourcefile is not None
thisfolder = Path(sourcefile).resolve().parent
val1 = 1.685401585899429 ... | giovannipurpura/daceypy | docs/Tutorials/Tutorial2/3Evaluation-Ex.py | .py | 3bfabe9c32024fce | 7.66 | 20 |
"""Shared fixtures for the DACEyPy test suite.
The DACE core keeps the polynomial order and the number of variables in
*global* state, set once by :meth:`daceypy.DA.init`. Re-initialising it
invalidates every DA object created before the call, so tests must never share
DA objects across an ``init``. The fixtures bel... | giovannipurpura/daceypy | tests/conftest.py | .py | c099bbe56eb6f7eb | 8.16 | 20 |
"""Tests for the ADS (Adaptive Domain Splitting) primitives.
The split-budget tests are *contract* tests: they check that the number of
splits a domain is allowed to undergo matches the number the API documents,
independently of whether the resulting Taylor maps are numerically good.
Note on initialisation: ``array.g... | giovannipurpura/daceypy | tests/test_ads.py | .py | fe2392d9ff32ac69 | 8.16 | 20 |
"""Value tests for the DA scalar type.
These check that the *numbers* the core computes are right, by comparing
Taylor expansions against closed-form results that are known independently of
DACEyPy (analytic derivatives, series identities, inverse-function round
trips).
"""
from __future__ import annotations
import ... | giovannipurpura/daceypy | tests/test_da_core.py | .py | d06e38073db97ba2 | 8.16 | 20 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.