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 |
|---|---|---|---|---|---|---|
"""Data loading and preparation.
Target units (in /data/gaultois_targets.csv):
- electrical resistivity (rho): Ohm * meter
- Seebeck coefficient (S): Volts / Kelvin
- thermal conductivity (kappa): Watts / (meter * Kelvin)
- thermoelectric figure of merit (zT): dimensionless
"""
from typing import Any
import numpy as... | janosh/thermo | thermo/data/transform.py | .py | 8787b3605919328a | 7.64 | 18 |
"""Error metrics and thermoelectric figure-of-merit computations."""
import numpy as np
import pandas as pd
from numpy.typing import NDArray
from pandas import Series
# scalar for 1d inputs, NDArray/Series/DataFrame for 2d inputs
FloatArray = float | NDArray[np.floating] | Series | pd.DataFrame
def rmse(arr1, arr2... | janosh/thermo | thermo/evaluate.py | .py | fdb22c9733f9bb2d | 7.64 | 18 |
"""Functions only needed once to generate CSV files."""
import pandas as pd
from matminer.featurizers import composition as cf
from matminer.featurizers.base import MultipleFeaturizer
from matminer.featurizers.conversions import StrToComposition
from thermo.utils import ROOT
def featurize_with_magpy(
df, input_... | janosh/thermo | thermo/featurize.py | .py | 1b0b44bdd18e8989 | 7.64 | 18 |
"""Plotting utilities for model accuracy and uncertainty diagnostics."""
from typing import Any
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pymatviz as pmv
import seaborn as sns
from matplotlib.offsetbox import AnchoredText
from scipy.stats import pearsonr
def plot_output(y_test, y... | janosh/thermo | thermo/plots.py | .py | 6776cb454e1d401d | 7.64 | 18 |
"""If enough time, compare our implementation
with https://github.com/CitrineInformatics/lolo.
"""
from __future__ import annotations
from typing import TYPE_CHECKING, Any
import numpy as np
from numpy.typing import NDArray
from sklearn.ensemble import RandomForestRegressor as SklRandomForestRegressor
if TYPE_CHEC... | janosh/thermo | thermo/rf.py | .py | 836f565531bf16f8 | 7.64 | 18 |
"""Project-wide utilities, paths and cross-validation helpers."""
from collections.abc import Callable
from os.path import dirname
from typing import Any
import numpy as np
import pandas as pd
from sklearn.model_selection import BaseCrossValidator
from tqdm import tqdm
# absolute path to the project's root director... | janosh/thermo | thermo/utils/__init__.py | .py | 953e702aef389511 | 7.64 | 18 |
"""Automatminer featurization and pipeline helpers."""
import os
from typing import Any
import automatminer as amm
import matminer.featurizers.composition as cf
from automatminer import MatPipe # make MatPipe importable from this file
from thermo.utils.decorators import interruptible
try:
os.remove(f"{os.getc... | janosh/thermo | thermo/utils/amm.py | .py | 1daba94e30512d7e | 7.64 | 18 |
"""This module was adapted from https://codereview.stackexchange.com/questions/181191.
Pass the total_atom_count/flatten_formula functions a chemical formula to get the
total number of atoms or the number of atoms for each element, respectively.
"""
import re
from typing import Any
RE = re.compile(
r"(?P<atom>[A... | janosh/thermo | thermo/utils/atom_count.py | .py | b0c407fe4e796c67 | 7.64 | 18 |
"""Decorators for timing, graceful interruption and output squeezing."""
from collections.abc import Callable
from functools import wraps
from time import perf_counter
from typing import Any, TypeVar
R = TypeVar("R")
def interruptible(
orig_func: Callable | None = None, handler: Callable | None = None
) -> Cal... | janosh/thermo | thermo/utils/decorators.py | .py | e09668685bf6c45e | 7.64 | 18 |
'''Test Script/CLI Interface to pyairnow'''
import argparse
import asyncio
from pyairnow import WebServiceAPI
def optionalArgs(args):
'''Load optional keyword arguments (date and dict)'''
kwargs = dict()
if args.date is not None:
kwargs['date'] = args.date
if args.distance is not None:
... | asymworks/pyairnow | examples/cli.py | .py | 7bd34c8a16cec9d4 | 7.59 | 14 |
'''Client to interact with AirNow Air Quality API'''
from json.decoder import JSONDecodeError
from typing import Optional, cast
from aiohttp import ClientSession, ClientTimeout
from .errors import AirNowError, EmptyResponseError, InvalidJsonError, \
InvalidKeyError
from .forecast import Forecast
from .observation... | asymworks/pyairnow | pyairnow/api.py | .py | bc554460d23f4cb5 | 7.59 | 14 |
'''Convert AQI to and from Pollutant Concentrations'''
from typing import TypedDict
class ConcBreakpointPair(TypedDict):
bL: float
bH: float
class EPATableRow(TypedDict):
iL: int
iH: int
breakpoints: dict[str, ConcBreakpointPair]
EPA_TABLE: list[EPATableRow] = [
{
'iL': 0,
... | asymworks/pyairnow | pyairnow/conv.py | .py | c991c278838b5c0d | 7.59 | 14 |
'''Retrieve Air Quality Forecasts'''
import warnings
from datetime import date as date_, datetime
from typing import Callable, Coroutine, Optional, Union
from pyairnow.util import coalesce
PARAMETER_NAME_MAP = {
'OZONE': 'O3',
}
def _normalize_forecast(raw: dict) -> dict:
'''Transform new API response form... | asymworks/pyairnow | pyairnow/forecast.py | .py | ae82736cebeb5750 | 7.59 | 14 |
'''Retrieve a list of Current Observations'''
import warnings
from typing import Callable, Coroutine, Optional, Union
from pyairnow.util import coalesce
CATEGORY_NAME_TO_NUMBER = {
'Good': 1,
'Moderate': 2,
'Unhealthy for Sensitive Groups': 3,
'Unhealthy': 4,
'Very Unhealthy': 5,
'Hazardous':... | asymworks/pyairnow | pyairnow/observation.py | .py | 907d0cae09e9f449 | 7.59 | 14 |
'''pyAirNow pytest Fixtures'''
import pytest
import re
from aioresponses import aioresponses
from .mock_api import mock_airnow_api
@pytest.fixture
def mock_aioresponse():
with aioresponses() as m:
yield m
@pytest.fixture
def mock_airnowapi(mock_aioresponse):
url_pattern = re.compile(r'^https://www... | asymworks/pyairnow | tests/conftest.py | .py | f2ff7df32011cabd | 7.59 | 14 |
"""
Provides functions to fetch passwords from passbolt api
"""
import configparser
import json
import logging
import uuid
from .api import PassboltClient, PassboltError
from .pgp_backend import SequoiaBackend
logger = logging.getLogger(__name__)
_CONFIG_PATH = "/etc/salt/passbolt.ini"
def get_password_list(client... | netzbegruenung/passbolt-salt | src/salt_passbolt/__init__.py | .py | 3ba592bb7d9c37d5 | 7.62 | 16 |
"""
Minimal Passbolt API client performing GPGAuth login with Sequoia (`sq`).
Only the read paths this module needs are implemented: authenticate, then GET
JSON. Decryption of the GPGAuth challenge is delegated to the same
SequoiaBackend that decrypts the secrets themselves, so no GnuPG keyring and no
gpg-agent are in... | netzbegruenung/passbolt-salt | src/salt_passbolt/api.py | .py | 8b7c556aa8930cd1 | 7.62 | 16 |
"""
Sequoia PGP backend for decryption using the `sq` CLI.
Each decryption runs in its own process, so concurrent pillar renders do not
contend on a single gpg-agent.
"""
import logging
import os
import re
import subprocess
from typing import Optional, Tuple
logger = logging.getLogger(__name__)
# Keep sq stateless:... | netzbegruenung/passbolt-salt | src/salt_passbolt/pgp_backend.py | .py | f71ad353cb03ab3e | 7.62 | 16 |
import os
import pathlib
import subprocess
import sys
import pytest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent.parent / "src"))
def _generate_key(home, password_file=None):
"""Generate a fresh key under SEQUOIA_HOME=home, return path to key file."""
key_file = home / "key.asc"
rev_fi... | netzbegruenung/passbolt-salt | tests/conftest.py | .py | d734ee04d85ffbb3 | 8.12 | 16 |
''' Module implementing ARM_AMMO command
For tests call python -m example_game.core.commands.arm_ammo -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that registers the co... | xdoko01/pgRPG | example_game/core/commands/arm_ammo.py | .py | 039bfab5bdaebaae | 7.45 | 7 |
''' Module implementing ARM_WEAPON command
For tests call python -m example_game.core.commands.arm_weapon -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that registers th... | xdoko01/pgRPG | example_game/core/commands/arm_weapon.py | .py | f323f6f28c5e7b7c | 7.45 | 7 |
''' Module implementing ATTACK command
For tests call `python -m example_game.core.commands.attack -v`
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that registers the comm... | xdoko01/pgRPG | example_game/core/commands/attack.py | .py | 9b34bdf341409aaa | 7.45 | 7 |
''' Module implementing DISARM_AMMO command
For tests call python -m example_game.core.commands.disarm_ammo -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that registers ... | xdoko01/pgRPG | example_game/core/commands/disarm_ammo.py | .py | b9ea5477e55a4739 | 7.45 | 7 |
''' Module implementing DISARM_WEAPON command
For tests call python -m example_game.core.commands.disarm_weapon -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that regist... | xdoko01/pgRPG | example_game/core/commands/disarm_weapon.py | .py | 6ce805e4ab98b331 | 7.45 | 7 |
''' Module implementing DO_PARALLEL command
For tests call python -m example_game.core.commands.do_parallel -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that registers ... | xdoko01/pgRPG | example_game/core/commands/do_parallel.py | .py | ea1e983eef98ee80 | 7.45 | 7 |
''' Module implementing DROP_ITEM command
For tests call python -m example_game.core.commands.drop_item -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that registers the ... | xdoko01/pgRPG | example_game/core/commands/drop_item.py | .py | d6366ba15afc1f09 | 7.45 | 7 |
''' Module implementing EXAMPLE command
For tests call python -m example_game.core.commands.example -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that registers the comm... | xdoko01/pgRPG | example_game/core/commands/example.py | .py | 127bb04eb3a89a3c | 7.45 | 7 |
''' Module implementing FACE_TARGET command
For tests call python -m example_game.core.commands.face_target -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that registers ... | xdoko01/pgRPG | example_game/core/commands/face_target.py | .py | 3e511c6556e2d7ef | 7.45 | 7 |
''' Module implementing INVENTORY_ACTION command
For tests call python -m example_game.core.commands.inventory_action -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that ... | xdoko01/pgRPG | example_game/core/commands/inventory_action.py | .py | 0f6ade3601c31ef4 | 7.45 | 7 |
''' Module implementing INVENTORY_MOVE_DIR command
For tests call python -m example_game.core.commands.inventory_move_dir -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function t... | xdoko01/pgRPG | example_game/core/commands/inventory_move_dir.py | .py | 67d85207322bfeb0 | 7.45 | 7 |
''' Module implementing LOAD_FROM_TEMPlATE command
For tests call python -m example_game.core.commands.load_from_template -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function t... | xdoko01/pgRPG | example_game/core/commands/load_from_template.py | .py | 056ea7f665435f0e | 7.45 | 7 |
''' Module implementing LOG command
For tests call python -m example_game.core.commands.log -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that registers the command with... | xdoko01/pgRPG | example_game/core/commands/log.py | .py | b7d88aca385258ef | 7.45 | 7 |
''' Module implementing MOVE_AUTO command
For tests call python -m example_game.core.commands.move_auto -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that registers the ... | xdoko01/pgRPG | example_game/core/commands/move_auto.py | .py | e74cfc70f70e9291 | 7.45 | 7 |
''' Module implementing MOVE_DIR command
For tests call python -m example_game.core.commands.move_dir -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that registers the co... | xdoko01/pgRPG | example_game/core/commands/move_dir.py | .py | e80bf93ab1195eed | 7.45 | 7 |
''' Module implementing MOVE_DIR_ADD command
For tests call python -m example_game.core.commands.move_dir_add -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that register... | xdoko01/pgRPG | example_game/core/commands/move_dir_add.py | .py | f4899c4d94eca37f | 7.45 | 7 |
''' Module implementing MOVE_TO command
For tests call python -m example_game.core.commands.move_to -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that registers the comm... | xdoko01/pgRPG | example_game/core/commands/move_to.py | .py | 3aeb94097d18ea4d | 7.45 | 7 |
''' Module implementing MOVE_TO_CHECKPOINTS command
For tests call python -m example_game.core.commands.move_to_checkpoints -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function... | xdoko01/pgRPG | example_game/core/commands/move_to_checkpoints.py | .py | 036c8ed34905867a | 7.45 | 7 |
''' Module implementing MOVE_TO_POS_PX command
For tests call python -m example_game.core.commands.move_to_pos_px -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that regi... | xdoko01/pgRPG | example_game/core/commands/move_to_pos_px.py | .py | 9389e1e25f4c9187 | 7.45 | 7 |
''' Module implementing MOVE_TO_POS_PX_VECT command
For tests call python -m example_game.core.commands.move_to_pos_px_vect -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function... | xdoko01/pgRPG | example_game/core/commands/move_to_pos_px_vect.py | .py | 7168c8f4b12e3e75 | 7.45 | 7 |
''' Module implementing MOVE_TO_POS_TARGET command
For tests call python -m example_game.core.commands.move_to_pos_target -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function t... | xdoko01/pgRPG | example_game/core/commands/move_to_pos_target.py | .py | 754e505e073f18c7 | 7.45 | 7 |
''' Module implementing MOVE_TO_POS_TARGET_VECT command
For tests call python -m example_game.core.commands.move_to_pos_target_vect -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... ... | xdoko01/pgRPG | example_game/core/commands/move_to_pos_target_vect.py | .py | 80624ccfe8c87f25 | 7.45 | 7 |
''' Module implementing MOVE_TO_POS_TILE command
For tests call python -m example_game.core.commands.move_to_pos_tile -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that ... | xdoko01/pgRPG | example_game/core/commands/move_to_pos_tile.py | .py | bc4ede6b1e709360 | 7.45 | 7 |
''' Module implementing MOVE_TO_POS_TILE_VECT command
For tests call python -m example_game.core.commands.move_to_pos_tile_vect -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Func... | xdoko01/pgRPG | example_game/core/commands/move_to_pos_tile_vect.py | .py | 8ff1ade489a1fcab | 7.45 | 7 |
''' Module implementing MOVE_TO_TARGET command
For tests call python -m example_game.core.commands.move_to_target -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that regi... | xdoko01/pgRPG | example_game/core/commands/move_to_target.py | .py | c2dc494362ebe657 | 7.45 | 7 |
''' Module implementing MOVE_TO_VECT command
For tests call python -m example_game.core.commands.move_to_vect -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that register... | xdoko01/pgRPG | example_game/core/commands/move_to_vect.py | .py | 25c10076a940d848 | 7.45 | 7 |
''' Module implementing MOVE_VECT command
For tests call python -m example_game.core.commands.move_vect -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that registers the ... | xdoko01/pgRPG | example_game/core/commands/move_vect.py | .py | d31169ed25ccad5d | 7.45 | 7 |
''' Module implementing PICK_ITEM command
For tests call python -m example_game.core.commands.pick_item -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that registers the ... | xdoko01/pgRPG | example_game/core/commands/pick_item.py | .py | a33e40556d11d409 | 7.45 | 7 |
''' Module implementing RESET_BRAIN command
For tests call python -m example_game.core.commands.reset_brain -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that registers ... | xdoko01/pgRPG | example_game/core/commands/reset_brain.py | .py | 813f1619ea6b9e5c | 7.45 | 7 |
''' Module implementing SET_BB_VALUE command
For tests call python -m example_game.core.commands.set_bb_value -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that register... | xdoko01/pgRPG | example_game/core/commands/set_bb_value.py | .py | 74b54b35994467b4 | 7.45 | 7 |
''' Module implementing TEST_BB_VALUE command
For tests call python -m example_game.core.commands.test_bb_value -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that regist... | xdoko01/pgRPG | example_game/core/commands/test_bb_value.py | .py | e0302d81e9b4e0b6 | 7.95 | 7 |
''' Module implementing TEST_CAN_HEAR command
For tests call python -m example_game.core.commands.test_can_hear -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that regist... | xdoko01/pgRPG | example_game/core/commands/test_can_hear.py | .py | 8c1e1420923c6821 | 7.95 | 7 |
''' Module implementing TEST_CAN_SEE command
For tests call python -m example_game.core.commands.test_can_see -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that register... | xdoko01/pgRPG | example_game/core/commands/test_can_see.py | .py | 4fd57d0dcc12cf1a | 7.95 | 7 |
''' Module implementing TEST_DAMAGED command
For tests call python -m example_game.core.commands.test_damaged -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that register... | xdoko01/pgRPG | example_game/core/commands/test_damaged.py | .py | da4bffba13156bed | 7.95 | 7 |
''' Module implementing TOGGLE_CONTROLS command
For tests call python -m example_game.core.commands.toggle_controls -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that re... | xdoko01/pgRPG | example_game/core/commands/toggle_controls.py | .py | a24258076afcc9c3 | 7.45 | 7 |
''' Module implementing TOGGLE_INVENTORY command
For tests call python -m example_game.core.commands.toggle_inventory -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that ... | xdoko01/pgRPG | example_game/core/commands/toggle_inventory.py | .py | e14ccc9b53467a01 | 7.45 | 7 |
''' Module implementing USE_WEAPON command
For tests call python -m example_game.core.commands.use_weapon -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that registers th... | xdoko01/pgRPG | example_game/core/commands/use_weapon.py | .py | 309f5f27c2ef71fb | 7.45 | 7 |
''' Module implementing WAIT command
For tests call python -m example_game.core.commands.wait -v
Command module represents one command only. The name of the module must be the same as the name of the
command.
Command module must consists of 3 functions:
- initialize() ... Function that registers the command wi... | xdoko01/pgRPG | example_game/core/commands/wait.py | .py | f81050dc81b4f4f4 | 7.45 | 7 |
''' Module "example_game.core.components.ammo_pack" contains
AmmoPack component implemented as a AmmoPack class.
Use 'python -m example_game.core.components.ammo_pack -v' to run
module tests.
'''
from pgrpg.core.ecs import Component
from .weapon import Weapon
class AmmoPack(Component):
''' Entity is an ammo pack... | xdoko01/pgRPG | example_game/core/components/ammo_pack.py | .py | fec47cc7cfdb0957 | 7.45 | 7 |
''' Module "example_game.core.components.blist_ai" contains
BListAI component implemented as a BList class.
Use 'python -m core.components.blist_ai -v' to run
module tests.
'''
import logging
# Create logger
logger = logging.getLogger(__name__)
from pgrpg.core.ecs import Component
from pgrpg.core.commands import cm... | xdoko01/pgRPG | example_game/core/components/blist_ai.py | .py | 36da55d94daa7e58 | 7.45 | 7 |
''' Module "example_game.core.components.brain" contains
Brain component implemented as a Brain class.
Use 'python -m example_game.core.components.brain -v' to run
module tests.
'''
from pgrpg.core.ecs import Component
class Brain(Component):
''' Entity can perform commands stored in its brain. Contains commands... | xdoko01/pgRPG | example_game/core/components/brain.py | .py | 4e848f82b254273f | 7.45 | 7 |
''' Module "core.components.brain_ai" contains
BrainAI component implemented as a BTree or BList class.
Use 'python -m core.components.brain_ai -v' to run
module tests.
'''
from dataclasses import dataclass
import logging
# Create logger
logger = logging.getLogger(__name__)
from pgrpg.core.ecs import Component
fro... | xdoko01/pgRPG | example_game/core/components/brain_ai.py | .py | 3745beb8eb3cd1d6 | 7.45 | 7 |
''' Module "example_game.core.components.btree_ai" contains
BTreeAI component implemented as a BTreeAI class.
Use 'python -m core.components.btree_ai -v' to run
module tests.
'''
import logging
# Create logger
logger = logging.getLogger(__name__)
from pgrpg.core.ecs import Component
from pgrpg.core.commands import ... | xdoko01/pgRPG | example_game/core/components/btree_ai.py | .py | 94f23fe0bb1174ef | 7.45 | 7 |
''' Module "example_game.core.components.camera" contains
Camera component implemented as a Camera class.
Use 'python -m example_game.core.components.camera -v' to run
module tests.
'''
from pygame import Surface
from pgrpg.core.ecs import Component
from pgrpg.core.config import DISPLAY
class Camera(Component):
... | xdoko01/pgRPG | example_game/core/components/camera.py | .py | c382f9f987904dac | 7.45 | 7 |
''' Module "core.components.can_hear" contains
CanHear component implemented as a CanHear class.
Use 'python -m core.components.can_hear -v' to run
module tests.
'''
from pgrpg.core.ecs import Component
from pgrpg.core.config import GAME # for TILE_RES_PX - in order to re-calculate tile distance to px
class CanHear(... | xdoko01/pgRPG | example_game/core/components/can_hear.py | .py | 98657c027a1679dc | 7.45 | 7 |
''' Module "core.components.can_see" contains
CanSee component implemented as a CanSee class.
Use 'python -m core.components.can_see -v' to run
module tests.
'''
from math import radians, sin, cos
from pgrpg.core.ecs import Component
from pgrpg.core.config import GAME # for TILE_RES_PX - in order to re-calculate tile... | xdoko01/pgRPG | example_game/core/components/can_see.py | .py | 95cdf6e1f47bdb85 | 7.45 | 7 |
''' Module "example_game.core.components.damageable" contains
Damageable component implemented as a Damageable class.
Use 'python -m example_game.core.components.damageable -v' to run
module tests.
'''
from pgrpg.core.ecs import Component
class Damageable(Component):
''' Entity has some health, i.e. is damageabl... | xdoko01/pgRPG | example_game/core/components/damageable.py | .py | 7f75b432de46cd7b | 7.45 | 7 |
"""
Adjustment Blend — velocity-matched keyframe interpolation for Maya.
Drop an additive animation layer with just a start and an end key to offset
some existing motion, then let this tool fill in the in-betweens. Instead of a
flat linear blend, the offset is distributed across the segment in proportion
to how fast t... | RedForty/AdjustmentBlend | adjustment_blend/__init__.py | .py | 8ac1739e536548c3 | 7.45 | 7 |
"""
Scene I/O and layer discovery for Adjustment Blend.
Everything that reads state out of the running Maya session lives here:
discovering which layer is the adjustment target and which layers sit below it,
listing animated attributes, and collecting adjustment keys.
Note on the UI dependency
-----------------------... | RedForty/AdjustmentBlend | adjustment_blend/maya_scene.py | .py | 365e39ea84d3a3b5 | 7.45 | 7 |
"""
A tiny, dockable Maya UI for Adjustment Blend.
One big button plus two toggles — Signal (Scalar / Vector) and Mode
(Normal / Smart) — that call :func:`adjustment_blend.run`. Deliberately thin:
all the real logic lives in the package; this just flips the two flags, wraps
the run in a single undo chunk, and reports ... | RedForty/AdjustmentBlend | adjustment_blend/ui.py | .py | dc170ce6823f8365 | 7.45 | 7 |
# >>> m = '''mutation{createAuthor(name: $name, enabled: $enabled){successful}}'''
# >>> m.replace('$name', 'Baruc')
# 'mutation{createAuthor(name: Baruc, enabled: $enabled){successful}}'
# >>> m.replace('$name', 'Baruc')
# 'mutation{createAuthor(name: Baruc, enabled: $enabled){successful}}'
# >>> m.replace('$name', 10... | valiot/pygqlc | pygqlc/MutationBatch.py | .py | 6b8c3731ee15a19b | 7.56 | 12 |
import re
"""
The purpose of this module is to prepare a graphql transaction, such as a query
or mutation, to be able to carry out a batch of them.
"""
mutation_regex = r"^\s*mutation\s*(\s+[a-zA-Z_]+[a-zA-Z_0-9]?)?\s*(\(\s*(((\$[a-zA-Z_]+[a-zA-Z_0-9]?)\s*:\s*([a-zA-Z_]+[a-zA-Z_0-9]?!?)\s*)+\s*)\))?\s*{\s*((.\s*)+\s... | valiot/pygqlc | pygqlc/MutationParser.py | .py | a345266cb99c2f39 | 7.56 | 12 |
class Singleton(type):
"""This class defines another classes to be a singleton.
Args:
type (cls): Class that wants to obtain the singleton pattern.
"""
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super(Singlet... | valiot/pygqlc | pygqlc/helper_modules/Singleton.py | .py | 7de78a8101049e35 | 7.06 | 12 |
"""
Logging wrapper module for pygqlc
This module provides a unified logging interface that works with or without
the valiotlogging package. If valiotlogging is available, it will be used.
Otherwise, a simple fallback implementation using print statements is provided.
"""
from enum import Enum
from typing import Dict... | valiot/pygqlc | pygqlc/logging.py | .py | b58398fd9faf9682 | 7.56 | 12 |
from socket import timeout
import pytest
from pygqlc import GraphQLClient # main package
class EnvironmentVariablesException(Exception):
"""Check your environment variables"""
class AuthorsModelException(Exception):
"""There is a problem with the author model."""
class RecordException(Exception):
"""... | valiot/pygqlc | tests/conftest.py | .py | 7f13e1a3fc4af270 | 8.06 | 12 |
"""Regression tests: stale httpx.AsyncClient instances must be aclose()d, not
leaked to GC. Orphaned transports' _SelectorTransport.__del__ finalizers run
during cyclic-GC sweeps on arbitrary threads, which contributed to false
TMPRL1101 deadlocks in Temporal workers (see valiot/python-tooling#151).
Clients are regist... | valiot/pygqlc | tests/pygqlc/gql_client/test_async_client_lifecycle.py | .py | eb9d5cf8c45a81ba | 7.06 | 12 |
"""Regression tests: the async client must be per-event-loop, never shared.
httpx.AsyncClient's connection-pool primitives (asyncio Events/Locks inside
httpcore) bind to the event loop that first awaits them. 3.8.6 cached ONE
client per GraphQLClient instance, so a consumer running coroutines on more
than one loop — e... | valiot/pygqlc | tests/pygqlc/gql_client/test_async_client_per_loop.py | .py | c3af1d35f3423797 | 8.06 | 12 |
from . import subscriptions as subs
from . import mutations as muts
import types
import time
import threading
from contextlib import contextmanager
from unittest.mock import MagicMock, patch
import pytest
from pygqlc import GraphQLClient
from pygqlc.helper_modules.Singleton import Singleton
from pygqlc.logging impor... | valiot/pygqlc | tests/pygqlc/gql_client/test_subscribe.py | .py | 22f663b74495cb2c | 7.06 | 12 |
"""Transport exceptions must not collapse into a blank `[{"message": ""}]`.
httpx timeout and connection-reset exceptions carry an empty message, so
`str(error)` is "". When `execute`/`async_execute` raise one, the high-level
`query`/`mutate` helpers must still report a non-empty, diagnosable error that
preserves the ... | valiot/pygqlc | tests/pygqlc/gql_client/test_timeout_empty_message.py | .py | 996f290b835a91d4 | 8.06 | 12 |
from . import queries as q
from pygqlc import QueryParser
# * Must pass tests: ****************************
def test_validate_q_short():
parser = QueryParser(q.q_short)
assert parser.validate(), f'"q_short" should be a valid query'
def test_validate_q_short_attrs():
parser = QueryParser(q.q_short_attrs)... | valiot/pygqlc | tests/pygqlc/gql_parsers/test_parser.py | .py | ea068ee0c6629042 | 7.06 | 12 |
from pygqlc.GraphQLClient import safe_pop
from pygqlc.helper_modules.Singleton import Singleton
def test_safe_pop_first():
data = [3, 4, 5]
datum = safe_pop(data, 0)
assert datum == 3, "Datum should be the first element"
def test_safe_pop_last():
data = [3, 4, 5]
datum = safe_pop(data, -1)
a... | valiot/pygqlc | tests/pygqlc/test_helpers.py | .py | 5d8eb1cb64ae5d5e | 7.06 | 12 |
from __future__ import annotations
import sublime
import sublime_plugin
class LspTexlabAutoCompleteCommand(sublime_plugin.TextCommand):
"""
This command is used to override ST's built-in `{` keybindings.
Originally, if the user press `{`, it will trigger ST's built-in command to insert `{$0}` snippet.
... | sublimelsp/LSP-TexLab | lsp_texlab_auto_complete.py | .py | 43b923c9e739de8e | 7.64 | 18 |
from __future__ import annotations
import os
from functools import lru_cache
import sublime
from .const import ARCH, PLATFORM, PLATFORM_ARCH_TO_TARBALL, PLUGIN_NAME, SERVER_VERSION, SETTINGS_FILENAME
@lru_cache
def get_plugin_storage_dir() -> str:
"""Gets this plugin's storage dir."""
return os.path.abspa... | sublimelsp/LSP-TexLab | server.py | .py | e82c1895a2976942 | 7.64 | 18 |
from __future__ import annotations
import gzip
import os
import tarfile
import urllib.request
import zipfile
from collections.abc import Iterable
def decompress(tarball: str, dst_dir: str | None = None) -> None:
"""
Decompress the tarball.
:param tarball: The tarball
:param dst_dir: The ... | sublimelsp/LSP-TexLab | tarball.py | .py | 15e0d0828c8fa84d | 7.64 | 18 |
"""Client for the Last.fm web API (https://www.last.fm/api)."""
from __future__ import annotations
import datetime as dt
import time
from collections.abc import Iterator
from types import TracebackType
from typing import Any, Self
import requests
from requests.adapters import HTTPAdapter, Retry
API_URL = "https://w... | hp0404/lastfm-to-sqlite | lastfm/client.py | .py | f035560bc7e335be | 7.42 | 6 |
import json
import requests
import os
import hashlib
from tqdm import tqdm
from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor, as_completed
#############
# LLM prompts for data augmentation
###################
SYSTEM_PROMPT = """
You are an expert NLP Data Scientist specialized in t... | TigreGotico/little_questions | datasets/llm_augment.py | .py | c9482c8efdd9c46f | 7.57 | 13 |
import json
import requests
import os
from tqdm import tqdm
from concurrent.futures import ThreadPoolExecutor, as_completed
#############
# LLM prompts to validate data
###################
SYSTEM_PROMPT = """
You are an expert NLP Classification Validator specialized in the TREC Question Taxonomy.
Your goal is to ve... | TigreGotico/little_questions | datasets/llm_validate.py | .py | 528766b45e7b1020 | 7.57 | 13 |
#!/usr/bin/env python3
"""Batch translate COSC dataset (5 sentences per request) - much faster."""
import os
import sys
from tqdm import tqdm
MODEL_REPO = "DZgas/Tower-Plus-2B-GGUF"
QUANT_FILES = {
"Q3_K_M": "Tower-Plus-2B.Q3_K_M.gguf",
"Q4_K_M": "Tower-Plus-2B.Q4_K_M.gguf",
"Q5_K_M": "Tower-Plus-2B.Q5_K_... | TigreGotico/little_questions | datasets/translate.py | .py | 03cff7febd089bc6 | 7.57 | 13 |
"""Model path resolution for little_questions.
Resolution order for every model lookup:
1. Bundled models shipped with the package (``little_questions/models/``)
2. User cache (``~/.local/share/little_questions/``)
3. HuggingFace Hub download (requires ``huggingface_hub`` and internet access)
HuggingFace is the... | TigreGotico/little_questions | little_questions/models.py | .py | 96bd0459b616c15a | 7.57 | 13 |
"""pytest configuration: stub out optional / unavailable heavy dependencies.
Pass --integration to also run @pytest.mark.integration tests (requires model files).
JarbasModelZoo and xdg (pyxdg) are optional packages not installed in all
environments. Stubbing them at import time prevents ImportError when the
langua... | TigreGotico/little_questions | test/conftest.py | .py | 25af6db4f998a787 | 8.07 | 13 |
#!/usr/bin/env python3
"""Evaluate and prune categorical features based on mutual information.
Computes MI for each categorical feature on the EN dataset and identifies
low-signal features (MI < 0.01 bits) for pruning.
Usage:
python -m train.eval_sentence_type_categorical
"""
from __future__ import annotations
... | TigreGotico/little_questions | train/eval_sentence_type_categorical.py | .py | 87175593dab4d998 | 7.57 | 13 |
"""EAT dataset loader for little_questions training scripts.
Primary source: HuggingFace dataset ``TigreGotico/EAT`` so results are reproducible.
Fallback: local TSV file with columns label, question, answer, lang.
"""
from __future__ import annotations
import csv
HF_DATASET_ID = "TigreGotico/EAT"
def load_eat_hf... | TigreGotico/little_questions | train/load_eat.py | .py | 9decb97f947bd129 | 7.57 | 13 |
"""Evaluation metrics for little_questions classifiers.
Provides a unified evaluation harness that works for any scorer/classifier
with a predict(text) -> str interface — trained models and baselines alike.
Usage::
from train.metrics import evaluate, EvalResult
from train.baselines import PunctuationScorer
... | TigreGotico/little_questions | train/metrics.py | .py | 2c530831f0d02bce | 7.57 | 13 |
"""MLflow configuration for little_questions training runs.
Reads connection settings from environment variables so credentials are never
hard-coded in source files. Set these before running any train script:
export MLFLOW_TRACKING_URI=https://mlflow.tigregotico.pt
export MLFLOW_TRACKING_USERNAME=admin
e... | TigreGotico/little_questions | train/mlflow_config.py | .py | dcf6adc722b7bc05 | 7.57 | 13 |
#!/usr/bin/env python3
"""Train sentence-type classifiers with optional categorical features.
Tests both TF-IDF-only (baseline) and TF-IDF+categorical pipelines to measure
feature engineering impact.
Usage:
python -m train.train_sentence_type_categorical --lang en
python -m train.train_sentence_type_categoric... | TigreGotico/little_questions | train/train_sentence_type_categorical.py | .py | b4c5fe896e3b76ca | 7.57 | 13 |
"""Shared YAML frontmatter helpers.
Both `pretalx` and `og` workflows rewrite specific keys in markdown
frontmatter while preserving the rest of the file. The implementation
lives here so it isn't duplicated across packages.
"""
from __future__ import annotations
import io
from pathlib import Path
import click
from... | pyohio/pyohio-static-website | pyohio-cli/src/pyohio_cli/_frontmatter.py | .py | 30c0f64c63e4409e | 7.52 | 10 |
"""CSV export CLI."""
from __future__ import annotations
import os
from pathlib import Path
import click
from pyohio_cli.csv_export.generator import generate
DEFAULT_BASE_URL = "https://www.pyohio.org"
@click.group()
def csv():
"""Generate CSV exports of site content."""
@csv.command("generate")
@click.opt... | pyohio/pyohio-static-website | pyohio-cli/src/pyohio_cli/csv_export/cli.py | .py | 7a89909b06186218 | 7.52 | 10 |
"""Build a speakers/talks CSV for the communications team.
Reads the content metadata Rockgarden exports during a build
(``ROCKGARDEN_CONTENT_JSON``) and writes one row per speaker/talk pairing.
Each speaker's social links are split into named columns by the ``mdi:*``
icon PreTalx assigns them (see ``pretalx/processor... | pyohio/pyohio-static-website | pyohio-cli/src/pyohio_cli/csv_export/generator.py | .py | d9bab2a555dd5682 | 7.52 | 10 |
"""Lightning-talk processing CLI.
Reads a plain-text list of accepted lightning talks in the format
Title - Speaker Name (email@example.com)
one per line, Wikipedia-title-cases the titles, randomizes the order, and writes
them into the lightning-talks page frontmatter. The speaker email addresses are
printed for... | pyohio/pyohio-static-website | pyohio-cli/src/pyohio_cli/lightning/cli.py | .py | 4c8eae1023c4231f | 7.52 | 10 |
"""Title-case strings using Wikipedia's Manual of Style rules.
Wikipedia lowercases articles, coordinating conjunctions, and prepositions of
four letters or fewer, while always capitalizing the first and last word and the
first word of a subtitle (after a colon). The first word after sentence-ending
punctuation (``.``... | pyohio/pyohio-static-website | pyohio-cli/src/pyohio_cli/lightning/titlecase.py | .py | 8da68ea61fd755bb | 7.52 | 10 |
"""Playwright wrapper for screenshotting OG card HTML to PNG."""
from __future__ import annotations
from pathlib import Path
from playwright.sync_api import sync_playwright
OG_WIDTH = 1200
OG_HEIGHT = 630
class OGRenderer:
"""Reusable Playwright browser+page for rendering many OG cards.
Usage:
wi... | pyohio/pyohio-static-website | pyohio-cli/src/pyohio_cli/og/renderer.py | .py | e3bf497f7d679ddf | 7.52 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.