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 abc import ABC from qibo.config import raise_error class QibotnBackend(ABC): def __init__(self): super().__init__() def apply_gate(self, gate, state, nqubits): # pragma: no cover raise_error(NotImplementedError, "QiboTN cannot apply gates directly.") def apply_gate_density_matrix...
qiboteam/qibotn
src/qibotn/backends/abstract.py
.py
bfd6e5241e8f765f
7.62
16
"""Implementation of Quantum Matcha Tea backend.""" import re from dataclasses import dataclass import numpy as np import qiskit import qmatchatea import qtealeaves from qibo.backends import NumpyBackend from qibo.config import raise_error from qibotn.backends.abstract import QibotnBackend from qibotn.result import ...
qiboteam/qibotn
src/qibotn/backends/qmatchatea.py
.py
b9daf6b8e46e2ed8
7.62
16
import cupy as cp import numpy as np # Reference: https://github.com/NVIDIA/cuQuantum/tree/main/python/samples/cutensornet/circuit_converter class QiboCircuitToEinsum: """Convert a circuit to a Tensor Network (TN) representation. The circuit is first processed to an intermediate form by grouping each gate m...
qiboteam/qibotn
src/qibotn/circuit_convertor.py
.py
75b676e1a806073a
7.62
16
import cupy as cp import cuquantum.bindings.cutensornet as cutn import numpy as np from qibotn.circuit_convertor import QiboCircuitToEinsum from qibotn.mps_utils import apply_gate, initial class QiboCircuitToMPS: """A helper class to convert Qibo circuit to MPS. Parameters: circ_qibo: The quantum ci...
qiboteam/qibotn
src/qibotn/circuit_to_mps.py
.py
9774f6af7d35157d
7.62
16
import numpy as np import quimb.tensor as qtn def init_state_tn(nqubits, init_state_sv): """Create a matrix product state directly from a dense vector. Args: nqubits (int): Total number of qubits in the circuit. init_state_sv (list): Initial state in the dense vector form. Returns: ...
qiboteam/qibotn
src/qibotn/eval_qu.py
.py
9232d884aab3d152
7.62
16
from cuquantum.tensornet import contract, contract_path # Reference: https://github.com/NVIDIA/cuQuantum/blob/main/python/samples/cutensornet/tn_algorithms/mps_algorithms.ipynb class MPSContractionHelper: """A helper class to compute various quantities for a given MPS. Interleaved format is used to construc...
qiboteam/qibotn
src/qibotn/mps_contraction_helper.py
.py
e2c86c783f477571
7.62
16
import cupy as cp from cuquantum.tensornet import contract from cuquantum.tensornet.experimental import contract_decompose def initial(num_qubits, dtype): r"""Generate the MPS with an initial state of :math:`\ket{00...00}` Parameters: num_qubits: Number of qubits in the Quantum Circuit. dtype...
qiboteam/qibotn
src/qibotn/mps_utils.py
.py
9a9ab6d25f47f853
7.62
16
from copy import deepcopy from dataclasses import dataclass from typing import Union from numpy import ndarray from qibo.config import raise_error from qibotn.backends.abstract import QibotnBackend @dataclass class TensorNetworkResult: """ Object to store and process the output of a Tensor Network simulatio...
qiboteam/qibotn
src/qibotn/result.py
.py
403ac077866f5cc5
7.62
16
"""conftest.py. Pytest fixtures. """ import sys import pytest # backends to be tested # TODO: add cutensornet and quimb here as well BACKENDS = ["cutensornet"] # BACKENDS = ["qmatchatea"] def get_backend(backend_name): from qibotn.backends.cutensornet import CuTensorNet from qibotn.backends.qmatchatea im...
qiboteam/qibotn
tests/conftest.py
.py
dd901b519de23242
7.12
16
import math import pytest from qibo import Circuit, gates, hamiltonians from qibo.symbols import X, Z from qibotn.backends.qmatchatea import QMatchaTeaBackend def build_observable(nqubits): """Helper function to construct a target observable.""" hamiltonian_form = 0 for i in range(nqubits): hami...
qiboteam/qibotn
tests/test_circuit_execution.py
.py
f5235c3929e6a9a0
8.12
16
import math import cupy as cp import pytest import qibo from qibo import construct_backend, hamiltonians from qibo.models import QFT from qibo.symbols import X, Z ABS_TOL = 1e-7 def qibo_qft(nqubits, swaps): circ_qibo = QFT(nqubits, swaps) state_vec = circ_qibo().state(numpy=True) return circ_qibo, stat...
qiboteam/qibotn
tests/test_cuquantum_cutensor_backend.py
.py
e7411d1a971389c6
7.12
16
# mpirun --allow-run-as-root -np 2 python -m pytest --with-mpi test_cuquantum_cutensor_mpi_backend.py import math import cupy as cp import numpy as np import pytest import qibo from qibo import construct_backend, hamiltonians from qibo.models import QFT from qibo.symbols import X, Z ABS_TOL = 1e-7 def qibo_qft(nqu...
qiboteam/qibotn
tests/test_cuquantum_cutensor_mpi_backend.py
.py
8bf3bab339b7bc5c
7.12
16
import copy import os import config import numpy as np import pytest import qibo from qibo.models import QFT def create_init_state(nqubits): init_state = np.random.random(2**nqubits) + 1j * np.random.random(2**nqubits) init_state = init_state / np.sqrt((np.abs(init_state) ** 2).sum()) return init_state ...
qiboteam/qibotn
tests/test_quimb_backend.py
.py
5cc02059009ca396
8.12
16
from typing import Union from qibojit.backends.cpu import NumbaBackend from qibojit.backends.gpu import CupyBackend, CuQuantumBackend QibojitBackend = Union[NumbaBackend, CupyBackend, CuQuantumBackend] PLATFORMS = ("numba", "cupy", "cuquantum") class MetaBackend: """Meta-backend class which takes care of loadi...
qiboteam/qibojit
src/qibojit/backends/__init__.py
.py
5054a737fee4fb91
7.64
18
from functools import cached_property # pylint: disable=E0611 import numpy as np from qibo.backends.npmatrices import NumpyMatrices class CustomMatrices(NumpyMatrices): """Matrices used by custom operators. They may not correspond to the mathematical representation of each gate. """ def CRX(self, ...
qiboteam/qibojit
src/qibojit/backends/matrices.py
.py
be7c46fa67aad9a9
7.64
18
import numpy as np import random import operator from functools import reduce import torch def print_spans_loc(spans_start, spans_end): """ 输出spans的位置 """ assert len(spans_start) == len(spans_end) for i in range(len(spans_start)): try: print((spans_start[i].item(), spans_end[i].ite...
cheniison/e2e-joint-coref
tools.py
.py
6ca6e8252b3c7fcd
7.42
6
import model import config import torch import time import tools import json import _pickle import os import copy import numpy as np import random import math import pprint from torch.utils.data import BatchSampler, SequentialSampler, RandomSampler from transformers import AutoTokenizer, AutoModel, AdamW torch.backend...
cheniison/e2e-joint-coref
train.py
.py
336de125fec565b1
7.42
6
from typing import Optional, Tuple import numpy as np import matplotlib.axes import matplotlib.patches as mpatches import matplotlib.ticker as mticker import cartopy.mpl.geoaxes import cartopy.mpl.gridliner from cartopy import crs as ccrs from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter from cedar...
cemc-oper/cedarkit-plots
cedarkit/plots/bindutils.py
.py
6ca17c0214dfdd76
7.48
8
from typing import Tuple, NamedTuple from dataclasses import dataclass import math import sys @dataclass class LevelSetting: min_value: float max_value: float step: float def calculate_levels_automatic(min_value: float, max_value: float, max_count: int, outside: bool) -> LevelSetting: """ calcul...
cemc-oper/cedarkit-plots
cedarkit/plots/calculate.py
.py
4f4853436e307fb5
7.48
8
from typing import List, Optional, Any, TYPE_CHECKING from cartopy import crs as ccrs from cedarkit.plots.style import Style from cedarkit.plots.types import AxesRect from cedarkit.plots.template import XYTemplate from .layer import Layer from .renderer import get_renderer if TYPE_CHECKING: from .panel import Pa...
cemc-oper/cedarkit-plots
cedarkit/plots/chart/chart.py
.py
ad0107aec42749eb
7.48
8
from typing import Optional, TYPE_CHECKING import xarray as xr import numpy as np import matplotlib.axes import matplotlib.colors as mcolors import matplotlib.contour import matplotlib.quiver import cartopy.crs as ccrs from cedarkit.plots.style import ContourStyle, BarbStyle, ContourLabelStyle from cedarkit.plots.gra...
cemc-oper/cedarkit-plots
cedarkit/plots/chart/layer.py
.py
1e52a8bf32fb33c1
7.48
8
from dataclasses import dataclass from typing import Optional, Tuple, Union, List, Any, Iterable, TYPE_CHECKING import matplotlib.pyplot as plt import xarray as xr from cedarkit.plots.style import Style from cedarkit.plots.template import XYTemplate from .chart import Chart @dataclass class Schema: figsize: Tu...
cemc-oper/cedarkit-plots
cedarkit/plots/chart/panel.py
.py
ec5d7f04692fd18d
7.48
8
from abc import ABC, abstractmethod from typing import Any, Dict, Type, TYPE_CHECKING from cedarkit.plots.style import Style, ContourStyle, BarbStyle if TYPE_CHECKING: from .layer import Layer class PlotRenderer(ABC): """绘图渲染器接口。""" @abstractmethod def render(self, layer: "Layer", data: Any, style:...
cemc-oper/cedarkit-plots
cedarkit/plots/chart/renderer.py
.py
5a429f198ac5af95
7.48
8
import importlib.resources import re from typing import Optional, List import numpy as np import pandas as pd import matplotlib.colors as mcolors def get_ncl_colormap( name, index: Optional[np.ndarray] = None, count: Optional[int] = None, spread_start: Optional[int] = None, sp...
cemc-oper/cedarkit-plots
cedarkit/plots/colormap.py
.py
0ddb4a57f47b134a
7.48
8
from typing import Optional, TYPE_CHECKING from cartopy import crs as ccrs from cedarkit.plots.types import AreaRange from cedarkit.plots.painter.map_painter import MapPainter, MapInfo from cedarkit.plots.painter.axes_component_painter import ( AxesComponentPainter, MapBoxOption, ColorBarOption, ) from cedarkit.p...
cemc-oper/cedarkit-plots
cedarkit/plots/domains/east_asia.py
.py
820e28c98fff13f7
7.48
8
from typing import Optional, TYPE_CHECKING import numpy as np from cartopy import crs as ccrs import matplotlib.path as mpath from cedarkit.plots.chart import Layer from cedarkit.plots.types import AreaRange from cedarkit.plots.painter.map_painter import MapPainter, MapInfo from cedarkit.plots.painter.axes_component_...
cemc-oper/cedarkit-plots
cedarkit/plots/domains/europe_asia.py
.py
e82f6d9564c4a77f
7.48
8
from typing import Optional, TYPE_CHECKING import numpy as np import pandas as pd from cartopy import crs as ccrs from cedarkit.plots.chart import Layer from cedarkit.plots.map import MapType from cedarkit.plots.types import AreaRange, GraphTitle from cedarkit.plots.painter.map_painter import MapPainter, MapInfo from...
cemc-oper/cedarkit-plots
cedarkit/plots/domains/global_template.py
.py
986dc05cee235268
7.48
8
from dataclasses import dataclass from typing import Optional @dataclass class LayoutConfig: """地图模板布局配置。 将 MapTemplate 中散落的布局属性(width、height、aspect、 xticks_interval、yticks_interval)集中为独立的数据类, 通过组合方式注入模板,支持灵活定制。 Parameters ---------- width : float 主图层宽度(相对于 figure),默认 0.75。 h...
cemc-oper/cedarkit-plots
cedarkit/plots/domains/layout.py
.py
b03a120ed8a91b3f
7.48
8
from typing import Optional, TYPE_CHECKING import numpy as np from cartopy import crs as ccrs import matplotlib.path as mpath from cedarkit.plots.chart import Layer from cedarkit.plots.types import AreaRange from cedarkit.plots.painter.map_painter import MapPainter, MapInfo from cedarkit.plots.painter.axes_component_...
cemc-oper/cedarkit-plots
cedarkit/plots/domains/north_polar.py
.py
2971f172b2af30c1
7.48
8
"""Recipe YAML schema (pydantic). A recipe is a declarative plot product definition: which fields to load (``data``), how to transform them (``transforms`` / ``compute`` ops), how to draw them (``layers`` with style references), plus ``domain``, ``title``, ``params`` and ``colorbar`` sections. The schema is a closed ...
cemc-oper/cedarkit-plots
cedarkit/plots/engine/recipe.py
.py
cd028fd53a7ab192
7.48
8
import importlib from enum import Enum from typing import Dict, List, Optional import cartopy.feature as cfeature import matplotlib.axes DEFAULT_MAP_LOADER_PACKAGE = "cedarkit.plots.map.default" class MapType(Enum): Portrait = "portrait" SouthChinaSea = "south_china_sea" Global = "global" class MapLo...
cemc-oper/cedarkit-plots
cedarkit/plots/map/__init__.py
.py
b65e77b099a05a59
7.48
8
import warnings from typing import TYPE_CHECKING, Dict, Optional from dataclasses import dataclass, field from cedarkit.plots.map import MapLoader from cedarkit.plots.painter.component_bindutils import add_map_info_text if TYPE_CHECKING: from cedarkit.plots.chart import Layer @dataclass class MapFeatureConfig:...
cemc-oper/cedarkit-plots
cedarkit/plots/painter/map_painter.py
.py
138677fd977d02ac
7.48
8
"""pydantic models for style YAML files (G2 style library). A style YAML file describes one field (element), including: * ``id`` — style id, aligned with the cemc element name (``t2m``, ``psl``...) or ``cemc_name + "_" + level value`` for element+level styles (``h_500``). * ``criteria`` — identity rules used to mat...
cemc-oper/cedarkit-plots
cedarkit/plots/style/schema.py
.py
d5733e1aa09127e9
7.48
8
""" 预设样式。 本模块封装了文档样例与集成测试常用的几种 :class:`~cedarkit.plots.style.Style` 实例(温度填充、降水填充、气压等值线、风羽)。让示例代码不必每次 重复给出色表与等级。 """ from __future__ import annotations import numpy as np import matplotlib.colors as mcolors from cedarkit.plots.colormap import ( get_ncl_colormap, generate_colormap_using_ncl_colors, ) from ceda...
cemc-oper/cedarkit-plots
cedarkit/plots/testing/styles.py
.py
bbdf2dc32235c9f0
7.98
8
from argparse import ArgumentParser from collections.abc import Callable from glob import glob from logging import getLogger, StreamHandler from os.path import dirname, exists, join from platform import python_compiler from shlex import split from shutil import rmtree from subprocess import CalledProcessError, PIPE, Po...
zevlee/passphraser
build.py
.py
81980b5297c4c87d
7.48
8
from json import dumps, loads from os.path import dirname, join from platformdirs import user_config_dir # Application version __version__ = "1.0.7" # Application name APPNAME = "Passphraser" # Application ID ID = "me.zevlee.Passphraser" # Application directory APPDIR = dirname(dirname(__file__)) # Config directory C...
zevlee/passphraser
passphraser/__init__.py
.py
aa93a897ed29a4e8
7.48
8
from os.path import join from platform import system from gi import require_versions require_versions({"Gtk": "4.0", "Adw": "1"}) from gi.repository import Gtk from . import __version__ from . import * class About(Gtk.AboutDialog): """ About dialog window :param parent: Parent window :type parent: ...
zevlee/passphraser
passphraser/about.py
.py
afe4c3b41d8dd1e4
7.48
8
from json import dumps from os import mkdir from os.path import exists, join from platform import system from shutil import copytree from gi import require_versions require_versions({"Gtk": "4.0", "Adw": "1"}) from gi.repository import Gtk, Gdk, Gio, GLib, Adw from . import * from .window import Window class Applic...
zevlee/passphraser
passphraser/application.py
.py
a5cc3307a31c2b18
7.48
8
from re import split from secrets import choice, randbelow from . import * class Password: """ Password generator :param lst: Word list filename :type lst: str :param mnw: Minimum word length :type mnw: int :param mxw: Maximum word length :type mxw: int :param wrd: Number of ...
zevlee/passphraser
passphraser/password.py
.py
426e413d22f803e2
7.48
8
from json import dumps from os.path import join from platform import system from shutil import copyfile from gi import require_versions require_versions({"Gtk": "4.0", "Adw": "1"}) from gi.repository import Gtk, Adw from . import * class Preferences(Gtk.Window): """ Preferences window :param parent...
zevlee/passphraser
passphraser/preferences.py
.py
444f70f5260bec0b
7.48
8
from json import dumps from os.path import join from platform import system from shutil import copyfile from gi import require_versions require_versions({"Gtk": "4.0", "Adw": "1"}) from gi.repository import Gtk, Gio from . import * from .about import About from .password import Password from .preferences import Prefe...
zevlee/passphraser
passphraser/window.py
.py
9e20aefb1bcbb0e6
7.48
8
from abc import ABC, abstractmethod import numpy as np from numpy.typing import ArrayLike class StiffnessMatrix(ABC): _base_shape = (6, 6) def __init__(self, n_states: int): self.n_states = n_states self._actual_shape = self._base_shape + (n_states,) self.stiffness = np.zeros(self._a...
vbr-calc/pyVBRc
pyVBRc/materials/_stiffness.py
.py
9fc78523b0018181
7.42
6
from pathlib import PosixPath from typing import List, Tuple, Union import numpy as np from packaging.version import Version from scipy.interpolate import RegularGridInterpolator from scipy.io import loadmat from unyt import unyt_array from unyt.unit_object import UnitParseError from pyVBRc.logging import pyvbrc_log ...
vbr-calc/pyVBRc
pyVBRc/vbrc_structure.py
.py
9b7888bfb021417e
7.42
6
#!/usr/bin/env python import importlib import inspect from typing import Any __all__: list[str] = [] CORE_MODULES: list[str] = [ "servicenow_api.api_client", "servicenow_api.servicenow_models", ] OPTIONAL_MODULES = { "servicenow_api.agent_server": "agent_server", "servicenow_api.mcp_server": "mcp_se...
Knuckles-Team/servicenow-api
servicenow_api/__init__.py
.py
f801148bc8ddb5a1
7.65
19
#!/usr/bin/python import base64 import gzip import json import sys from base64 import b64encode from collections import defaultdict from datetime import datetime from typing import Any from urllib.parse import urlencode import requests from agent_utilities.base_utilities import get_logger from agent_utilities.core.ex...
Knuckles-Team/servicenow-api
servicenow_api/api/api_client_base.py
.py
3873ce00cf859141
7.65
19
#!/usr/bin/python import base64 import gzip import json from collections import defaultdict from datetime import datetime from typing import Any from agent_utilities.base_utilities import get_logger from agent_utilities.core.decorators import require_auth # noqa: F401 from servicenow_api.servicenow_models import ( ...
Knuckles-Team/servicenow-api
servicenow_api/api_client.py
.py
4c4e517ebe85e37b
7.65
19
#!/usr/bin/env python import importlib import inspect from typing import Any import warnings # Suppress RequestsDependencyWarning due to chardet 6.x / requests 2.32.x mismatch # Centralized here to ensure it runs before any sub-package imports warnings.filterwarnings("ignore", message=".*urllib3.*or chardet.*") __al...
Knuckles-Team/listmonk-api
listmonk_api/__init__.py
.py
135d1edd06c0b625
7.5
9
"""Native epistemic-graph ingestion for Listmonk records and documents. All writes use the required ``agent_utilities.knowledge_graph.memory.native_ingest`` primitive. Nodes use canonical ``node_type`` and edges use canonical ``relationship``; nodes and edges commit in one native transaction. Missing engine dependenci...
Knuckles-Team/listmonk-api
listmonk_api/kg_ingest.py
.py
88a7f48396c2bf38
7.5
9
"""Verify CONCEPT ID parity between docs/concepts.md and codebase. Tests that all concepts documented in docs/concepts.md are referenced somewhere in the source code, and that no undocumented concepts exist. """ import re from pathlib import Path import pytest PKG_DIR = Path(__file__).resolve().parent.parent PKG_NA...
Knuckles-Team/listmonk-api
tests/test_concept_parity.py
.py
e2dfd91b7a5c1636
8
9
import sys import pytest from unittest.mock import patch, MagicMock import listmonk_api def test_init_available_flags(): # Test _MCP_AVAILABLE and _AGENT_AVAILABLE dynamic checks assert listmonk_api._MCP_AVAILABLE is True assert listmonk_api._AGENT_AVAILABLE is True def test_init_lazy_loading(): # T...
Knuckles-Team/listmonk-api
tests/test_init.py
.py
68ba2cd181f6958e
7
9
"""Verify package initialization and version metadata.""" import importlib import pytest PKG_NAME = __name__.rsplit(".", 1)[0] if "." in __name__ else None def _get_pkg_name(): """Derive package name from test location.""" import pathlib test_dir = pathlib.Path(__file__).resolve().parent project_d...
Knuckles-Team/listmonk-api
tests/test_init_dynamics.py
.py
a9fe8dd4cbc1f186
7
9
"""Basic startup smoke tests.""" import subprocess import sys import pytest def test_module_runnable(): """Package module should be runnable with --help or similar.""" pkg_name = ( __import__("pathlib") .Path(__file__) .resolve() .parent.parent.name.replace("-", "_") ) ...
Knuckles-Team/listmonk-api
tests/test_startup.py
.py
a78cbfdc92109893
7
9
"""Entry point for checkupdate.exe -- installs a newer release if one exists.""" from __future__ import annotations import sys from pathlib import Path if not getattr(sys, "frozen", False): sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) import logging import subprocess import time import urllib...
ThiaudioTT/hoi4-presence
src/entrypoints/checkupdate.py
.py
2d701b563ef50c64
7.57
13
"""Entry point for setup.exe -- installs the presence into a HOI4 install. This is a console wizard, so it talks to the user through :class:`hoi4presence.ui.Wizard` rather than the logger; the windowed executables are the ones that need a log file. What it does, in order: 1. verify the unpacked release contains ever...
ThiaudioTT/hoi4-presence
src/entrypoints/installer.py
.py
0b91c27b65424b20
7.57
13
"""The edits the installer makes to the user's files, as pure transforms. Every function here takes and returns data rather than touching the disk, so the installer's effect on a real HOI4 install is testable without one. """ from __future__ import annotations from collections.abc import Iterable, Sequence # The fi...
ThiaudioTT/hoi4-presence
src/hoi4presence/install/steps.py
.py
8e2544b02a8d93fc
7.57
13
"""Filesystem discovery shared by the presence, the updater and the installer. Nothing here touches ``os.environ`` or the disk at import time: the Windows defaults are exposed as functions taking an explicit environment, so this module imports cleanly on Linux CI where ``USERPROFILE`` does not exist. """ from __futur...
ThiaudioTT/hoi4-presence
src/hoi4presence/paths.py
.py
4300b07fa8f3ff0c
7.57
13
"""Building the payloads sent to Discord. Kept free of :mod:`pypresence` on purpose: the payload is the part worth testing, and keeping the dependency out means the suite runs anywhere. The save stores HOI4's internal names -- ``very_hard``, ``neutrality`` -- which are not what the game shows the player. Everything u...
ThiaudioTT/hoi4-presence
src/hoi4presence/presence.py
.py
54f4773ee3b12028
7.57
13
"""The presence loop. This is the only module in the package that imports :mod:`pypresence` and :mod:`psutil`, so everything else stays importable on any platform. The test suite never imports it. """ from __future__ import annotations import logging import os import time import psutil from pypresence import Presen...
ThiaudioTT/hoi4-presence
src/hoi4presence/runner.py
.py
69d085320d069368
7.57
13
"""Reading and parsing HOI4 save headers. A plaintext save starts with a fixed block of ``key=value`` lines:: HOI4txt player="GER" ideology=fascism date="1936.1.1.12" difficulty="normal" version="Operation Postern v1.19.2.0.a729 (d245)" ironman="Ironman Finland 1.hoi4" Only those first fe...
ThiaudioTT/hoi4-presence
src/hoi4presence/saves.py
.py
a398564231a87519
7.57
13
"""The console UI shared by setup.exe, uninstall.exe and checkupdate.exe. These three are built with a console window, and their output *is* the user interface. Left as bare ``print`` the whole install finished faster than anyone could read it, so :class:`Wizard` gives every stage a progress bar and holds it on screen...
ThiaudioTT/hoi4-presence
src/hoi4presence/ui.py
.py
f64f7bc090c23ab0
7.57
13
"""Naming and progress helpers for GitHub releases. Standard library only, so the test suite does not need :mod:`requests`. """ from __future__ import annotations # build.spec names the artifact hoi4-presence-v<version>.zip, so a release tag # must be exactly "v<version>" for this to match. See AGENTS.md. ASSET_NAME...
ThiaudioTT/hoi4-presence
src/hoi4presence/updater/release.py
.py
c26a7da70df84b0e
7.57
13
"""Comparing the installed version against the one published on GitHub. Deliberately free of :mod:`requests` so the test suite need not install it. """ from __future__ import annotations import json import os from pathlib import Path from semantic_version import Version VERSION_FILE = "version.json" # Where the p...
ThiaudioTT/hoi4-presence
src/hoi4presence/updater/version_check.py
.py
be5c92a5d3eec282
7.57
13
"""Shared fixtures. Everything here is platform-neutral: the suite runs on Linux CI even though the product only runs on Windows. """ from __future__ import annotations import ast import json import shutil from pathlib import Path import pytest REPO_ROOT = Path(__file__).resolve().parents[1] DATA_DIR = Path(__file...
ThiaudioTT/hoi4-presence
tests/conftest.py
.py
70b31e55abb4ecea
8.07
13
"""Behaviour of the tag -> country lookup.""" from __future__ import annotations import pytest from hoi4presence.countries import DEFAULT_LARGE_IMAGE, Country, countries, getCountry def test_known_tag_returns_name_and_flag(): assert getCountry("GER") == Country("German Reich", "ger") def test_lowercase_tag_i...
ThiaudioTT/hoi4-presence
tests/test_countries.py
.py
c69f29ce608c8f85
7.07
13
"""Integrity of the country table itself. These read countries.py as source rather than importing it, so they can see mistakes that Python resolves silently -- a duplicate key being the main one. """ from __future__ import annotations import re from hoi4presence.countries import DEFAULT_LARGE_IMAGE # Tags that del...
ThiaudioTT/hoi4-presence
tests/test_countries_data.py
.py
1197785c42acff47
8.07
13
"""The launcher shim -- what the Paradox launcher actually spawns. This used to be a `.bat` file, so none of it was testable. It is the whole runtime chain in one function: get this wrong and clicking Play does nothing. """ from __future__ import annotations from pathlib import Path import launcher import pytest ...
ThiaudioTT/hoi4-presence
tests/test_launcher.py
.py
7e05391e1dba4b3f
8.07
13
"""Repository consistency checks that do not need PyInstaller or Windows. The Windows build cannot run on Linux CI, so these guard the parts of it that can be checked statically -- above all that build.spec still points at scripts that exist, which is the failure mode a package move causes. """ from __future__ import...
ThiaudioTT/hoi4-presence
tests/test_packaging.py
.py
86eb6de93e15d95c
8.07
13
"""The presence loop's connection lifecycle. ``runner`` is the one module that imports :mod:`pypresence` and :mod:`psutil`, which CI deliberately does not install, so both are stubbed into ``sys.modules`` before it is imported. That keeps the suite Linux-clean while still covering the reconnect logic -- the only part ...
ThiaudioTT/hoi4-presence
tests/test_runner.py
.py
294dda4967ff7efe
8.07
13
"""The console wizard the three windowed-console executables share. Everything here drives a :class:`Wizard` over an in-memory console. With a non-terminal console rich's live display refreshes to nothing, and the progress bar is transient anyway, so the only thing that lands in the buffer is the permanent line each f...
ThiaudioTT/hoi4-presence
tests/test_ui.py
.py
a1644148bce32fd5
8.07
13
import rsa, socket, typing class TcpClient: """Connected game client.""" def __init__(self, conn: tuple[socket.socket, typing.Any]): self.conn = conn[0] self.addr = conn[1] self.game_pubkey: rsa.PublicKey = None self.sv_pubkey: rsa.PublicKey = None self.sv_privkey: rsa.PrivateKey = None sel...
michal-kapala/ubi-gs
client.py
.py
2531171e31729b43
7.62
16
from abc import ABC, abstractmethod from enum import Enum class DATA_TYPE(Enum): """Serializable data type.""" STR = 1, BIN = 2, LIST = 3, LONG = 4, STR_REF = 5, REF = 6 class Data(ABC): """`clData` interface.""" def __init__(self, type: DATA_TYPE): self.type = type @abstractmethod def __st...
michal-kapala/ubi-gs
data.py
.py
795b553a9bdb213e
7.62
16
from abc import ABC, abstractmethod from enum import Enum from typing import TypedDict from utils import write_u16, write_u32 class LSM(Enum): """Lobby Service Mask""" LSM_PRIVATE = 1 """Group is password-protected.""" LSM_NEEDMASTER = 2 """Group needs a master.""" LSM_ETERNEL = 4 """Group is not deleted...
michal-kapala/ubi-gs
group.py
.py
1c2244ce1bfdb5ff
7.62
16
""" This is a modified version of https://github.com/jaraco/irc/blob/main/irc/server.py. Adjusted for Ubi's GameService IRC implementation. """ import sys, os import argparse, errno, logging, re, select, socketserver, typing from irc.client import NickMask from irc.events import codes import jaraco.logging from jaraco....
michal-kapala/ubi-gs
homm5/gsirc.py
.py
6e7ae7446ede77ed
7.62
16
from enum import Enum ENDPOINTS = { "router": ('localhost', 7777), "irc": ('localhost', 7779), "cdkey": ('localhost', 7780), "nat": ('localhost', 7781), "router_wm": ('localhost', 7782), "proxy": ('localhost', 7783), "proxy_wm": ('localhost', 7784), "lobby": ('localhost', 7785) } """Service endpoints f...
michal-kapala/ubi-gs
homm5/h5.py
.py
e9934139895b21f7
7.62
16
import socket, sys, os # relative module import stuff root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) sys.path.append(root_dir) import gsm, client, h5 from group import Room, LSM, MemberInfo, PLAYER_STATUS from h5_data import H5_Room, H5_RoomInfo, H5_Serializer SERVER_ADDRESS = h5.ENDPOINTS["...
michal-kapala/ubi-gs
homm5/lobby.py
.py
22e357b98fa0c533
7.62
16
import socket, sys, os # relative module import stuff root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) sys.path.append(root_dir) import gsm, pkc, client, h5 SERVER_ADDRESS = h5.ENDPOINTS["proxy"] """Address of the persistent data proxy module service.""" WAIT_MODULE = h5.ENDPOINTS["proxy_wm"]...
michal-kapala/ubi-gs
homm5/proxy.py
.py
505ecf37a7921391
7.62
16
import socket, sys, os # relative module import stuff root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) sys.path.append(root_dir) import gsm, pkc, client, h5 SERVER_ADDRESS = h5.ENDPOINTS["proxy_wm"] """Address of the proxy's wait module service.""" CLIENTS: list[client.TcpClient] = [] """Glob...
michal-kapala/ubi-gs
homm5/proxy_wm.py
.py
095e4a0cfbe29328
7.62
16
import socket, sys, os # relative module import stuff root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) sys.path.append(root_dir) import gsm, pkc, client, h5 SERVER_ADDRESS = h5.ENDPOINTS["router"] """Address of the router service.""" WAIT_MODULE = h5.ENDPOINTS["router_wm"] """Address of the w...
michal-kapala/ubi-gs
homm5/router.py
.py
0ba6842f1b53b0e4
7.62
16
import socket, sys, os # relative module import stuff root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) sys.path.append(root_dir) import gsm, pkc, client, group, h5 SERVER_ADDRESS = h5.ENDPOINTS["router_wm"] """Address of the router's wait module service.""" PROXY = h5.ENDPOINTS["proxy"] """Ad...
michal-kapala/ubi-gs
homm5/router_wm.py
.py
e92d524f41ad0d18
7.62
16
from blowfish import Cipher import utils BLOWFISH_KEY = bytes([ 0x06, 0xE2, 0xC8, 0x46, 0x01, 0x90, 0x55, 0x7C, 0x3C, 0xA1, 0xCD, 0xA3, 0xE3, 0xA1, 0x10, 0x6C ]) """Static Blowfish key for IRC service.""" BLOWFISH = Cipher(BLOWFISH_KEY) IRCM_HEADER_SIZE = 2 """Length of `IRCMessage` header in bytes.""" class IR...
michal-kapala/ubi-gs
ircm.py
.py
0d44dc3638469a17
7.62
16
import rsa, utils MAX_RSA_MODULUS_LEN = 128 """Max length of modulus (n) in bytes.""" PUBLIC_KEY_LEN = 512 """Public key length in bits.""" class RsaPublicKey: """Interface for public RSA key serialization.""" def __init__(self, bits: int, n: int, e: int): self.bits = bits self.modulus = n self.expon...
michal-kapala/ubi-gs
pkc.py
.py
ef998c7cdd407ff5
7.62
16
import struct from enum import Enum from utils import write_u16 import gsm, client SRP_HEADER_SIZE = 12 """Length of SRP header in bytes.""" SRP_WINDOW_SIZE = 8 """Length of SRP window data in bytes.""" class SRPHeaderFlags(Enum): """Flags of SRPHeader.""" FIN = 1 SYN = 2 ACK = 4 URG = 8 SRP_ID = 0x3040 ...
michal-kapala/ubi-gs
srp.py
.py
d8b8d9142800b53f
7.62
16
import sys, os, unittest # relative module import stuff root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) sys.path.append(root_dir) from blowfish import Blowfish, Cipher class BlowfishTests(unittest.TestCase): """Tests for Blowfish encryption algorithm.""" def test_bf(self): L = 1 R...
michal-kapala/ubi-gs
tests/test_blowfish.py
.py
d71e3bab9ef01e98
8.12
16
import sys, os, unittest # relative module import stuff root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) sys.path.append(root_dir) from data import List, Bin class DataTests(unittest.TestCase): """Tests for data parsing and other utilities.""" def test_serialize_outer_dl(self): list = ...
michal-kapala/ubi-gs
tests/test_data.py
.py
9db614a8c4a37bc7
8.12
16
import array, socket def read_u16(bts: bytes): """Reads a little endian u16.""" return bts[0] + (bts[1] << 8) def read_u16_be(bts: bytes): """Reads a big endian u16.""" return (bts[0] << 8) + bts[1] def write_u16_be(number: int): """Serializes 16-bit integer into a BE buffer.""" return number.to_bytes(2,...
michal-kapala/ubi-gs
utils.py
.py
b2e25aeaa6090962
7.62
16
# Copyright 2021 Agnostiq Inc. # # This file is part of Covalent. # # Licensed under the Apache License 2.0 (the "License"). A copy of the # License may be obtained with this software package or at # # https://www.apache.org/licenses/LICENSE-2.0 # # Use of this file is prohibited except in compliance with the Licen...
AgnostiqHQ/covalent-ssh-plugin
tests/ssh_test.py
.py
338963e7d822b750
8.02
10
#!/usr/bin/env python3 # Copyright 2021-2024 Elliot Jordan # # 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 applicabl...
homebysix/repo-lasso
shared/branch.py
.py
b552655fb66f5e19
7.6
15
#!/usr/bin/env python3 # Copyright 2021-2024 Elliot Jordan # # 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 applicabl...
homebysix/repo-lasso
shared/check.py
.py
7066e083a18c2c71
7.6
15
#!/usr/bin/env python3 # Copyright 2021-2024 Elliot Jordan # # 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 applicabl...
homebysix/repo-lasso
shared/pr.py
.py
5af74681c75de49b
7.6
15
#!/usr/bin/env python3 # Copyright 2021-2024 Elliot Jordan # # 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 applicabl...
homebysix/repo-lasso
shared/report.py
.py
fed768c228c2b9c6
7.6
15
#!/usr/bin/env python3 # Copyright 2021-2024 Elliot Jordan # # 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 applicabl...
homebysix/repo-lasso
shared/sync.py
.py
429305610561d515
7.6
15
import os import sys import unittest from argparse import Namespace from unittest.mock import MagicMock, mock_open, patch # Add the parent directory to sys.path to import the shared module sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) from shared import check class TestCheck(unittest.TestCase): ...
homebysix/repo-lasso
tests/test_check.py
.py
241a2e8144879e54
8.1
15
import os import sys import unittest from argparse import Namespace from unittest.mock import MagicMock, patch # Add the parent directory to sys.path to import the shared module sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) from shared import commit class TestCommit(unittest.TestCase): """Test ...
homebysix/repo-lasso
tests/test_commit.py
.py
172b384ec7ee77f5
7.1
15
import os import sys import unittest from argparse import Namespace from unittest.mock import MagicMock, patch # Add the parent directory to sys.path to import RepoLasso sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) import RepoLasso class TestRepoLasso(unittest.TestCase): """Test class for main...
homebysix/repo-lasso
tests/test_main.py
.py
7174c75005d34f5c
8.1
15
import os import sys import unittest from argparse import Namespace from unittest.mock import MagicMock, mock_open, patch # Add the parent directory to sys.path to import the shared module sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) from github import BadCredentialsException, GithubException, RateL...
homebysix/repo-lasso
tests/test_pr.py
.py
e053cbd7403235f1
7.1
15
import os import sys import unittest from argparse import Namespace from unittest.mock import MagicMock, patch sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) from shared import report class TestReport(unittest.TestCase): """Test class for report module.""" def setUp(self): """Set up...
homebysix/repo-lasso
tests/test_report.py
.py
c26e2acf85031bff
8.1
15
import os import sys import unittest from argparse import Namespace from unittest.mock import MagicMock, patch # Add the parent directory to sys.path to import the shared module sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) from shared import reset class TestReset(unittest.TestCase): """Test cl...
homebysix/repo-lasso
tests/test_reset.py
.py
5942e72c75e9c5c9
7.1
15
import os import sys import unittest from argparse import Namespace from unittest.mock import patch # Add the parent directory to sys.path to import the shared module sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) from shared import status class TestStatus(unittest.TestCase): """Test class for s...
homebysix/repo-lasso
tests/test_status.py
.py
19ef8567b8b8039a
7.1
15
#!/usr/bin/env python3 """Collage CLI Generator for lastfm-collage-generator. Generates Last.fm collages with support for live API credentials or offline mock mode. """ import argparse import io import os import sys from typing import List, Optional, Tuple # Add src to sys.path project_root = os.path.abspath( os...
paurieraf/lastfm-collage-generator
.gemini/skills/collage-cli-workflow/scripts/generate_collage_cli.py
.py
7e873d968a723a93
7.59
14
"""Pytest Fixture Templates & Mock Builders for lastfm-collage-generator. Provides synthetic image generation, pylast entity mocking, and HTML retrieval response simulators for offline, zero-network automated testing. """ import io from typing import Any, List, Optional, Tuple, Union from unittest.mock import MagicMo...
paurieraf/lastfm-collage-generator
.gemini/skills/lastfm-mocking-fixtures/references/fixture_templates.py
.py
0d1a7f5d8d5a50c0
7.59
14