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 |
|---|---|---|---|---|---|---|
"""
OpenAI embedding provider.
Wraps the OpenAI embedding API behind the AbstractEmbeddingProvider
interface. Requires the openai package (pip install popoto[openai]).
Example:
from popoto.embeddings.openai import OpenAIProvider
provider = OpenAIProvider(api_key="your-key")
vectors = provider.embed(["hell... | tomcounsell/popoto | src/popoto/embeddings/openai.py | .py | 35ed14e1b87ee290 | 7.5 | 9 |
"""
Sentence-Transformers embedding provider.
Wraps a local `sentence-transformers` model (``all-MiniLM-L6-v2`` by
default) behind the AbstractEmbeddingProvider interface. Inference runs
entirely on the local machine, so there is no API key, no per-token cost,
and no network dependency on a paid external provider.
Th... | tomcounsell/popoto | src/popoto/embeddings/sentence_transformers.py | .py | 95e6416a4da2100a | 7.5 | 9 |
"""
Voyage AI embedding provider.
Wraps the Voyage AI embedding API behind the AbstractEmbeddingProvider
interface. Requires the voyageai package (pip install popoto[voyage]).
Voyage AI provides high-quality embeddings optimized for retrieval,
with separate document/query embedding modes via the input_type parameter.... | tomcounsell/popoto | src/popoto/embeddings/voyage.py | .py | a1193d5918e5147d | 7.5 | 9 |
"""
Custom exceptions for the Popoto Redis ORM library.
"""
from typing import TYPE_CHECKING, Optional
if TYPE_CHECKING: # pragma: no cover - import cycle guard
from .privacy.never_record import NeverRecordVerdict
class ModelException(Exception):
"""Base exception for all Popoto ORM model-related errors.""... | tomcounsell/popoto | src/popoto/exceptions.py | .py | 7c9e1b888f62792c | 7.5 | 9 |
"""
Memory-extraction providers for Popoto's SubconsciousMemory recipe.
This module provides the AbstractExtractionProvider interface, the
ExtractedFact dataclass, and the built-in zero-dependency heuristic
provider used to turn raw LLM turn text into typed memory facts.
Providers are pluggable -- pass a provider ins... | tomcounsell/popoto | src/popoto/extraction/__init__.py | .py | 97db6dfdf7160506 | 7.5 | 9 |
"""Deterministic candidate enumeration for auditable extraction (M3, #562).
A *candidate* is a span of one conversation turn that the rest of the
extraction pipeline decides on: the firewall scans it, the verdict stage
votes on it, and the decision log records exactly one terminal state for it.
This module is the pip... | tomcounsell/popoto | src/popoto/extraction/candidates.py | .py | c952f549a70f80b2 | 7.5 | 9 |
"""AccessTrackerMixin — read pattern tracking with staged vs confirmed reads.
This module provides a mixin class that adds read access tracking to any Model.
It uses a staging pattern: reads are first recorded to a staging list, then
atomically promoted to the confirmed access log via a Lua script.
Design:
- on_r... | tomcounsell/popoto | src/popoto/fields/access_tracker.py | .py | 15b6bfd2dd3ab3db | 7.5 | 9 |
"""
ContentField: Large content storage with filesystem offloading.
Routes large content values (documents, text, binary data) to filesystem
storage via a pluggable ContentStore backend. Redis stores only a compact
reference string ($CF:{hash}:{path}), keeping memory usage minimal.
Content is lazy-loaded on attribute... | tomcounsell/popoto | src/popoto/fields/content_field.py | .py | f4e48e6e5d5e30ba | 7.5 | 9 |
"""
Field type for persisting Pandas DataFrame objects in Redis.
This module provides seamless integration between Pandas DataFrames and Popoto's
Redis-backed storage system. It enables storing, retrieving, and querying tabular
data without the overhead of managing CSV files or separate data stores.
Design Philosophy... | tomcounsell/popoto | src/popoto/fields/dataframe_field.py | .py | afae32cb48d58160 | 7.5 | 9 |
"""
Datetime field for storing Python datetime objects in Redis.
This module provides DatetimeField, a specialized field type that extends the base
Field class to handle datetime values with automatic timestamp management. It follows
Django's familiar auto_now and auto_now_add patterns, making it intuitive for develop... | tomcounsell/popoto | src/popoto/fields/datetime_field.py | .py | f1c20c3c4ed60a6b | 7.5 | 9 |
"""EventStreamMixin — append-only mutation log via Redis Streams.
This module provides a mixin class that automatically appends to a Redis Stream
on every save() or delete() call. It captures model class, primary key,
operation type, timestamp, and configurable metadata fields.
Design:
- _xadd_mutation() is calle... | tomcounsell/popoto | src/popoto/fields/event_stream.py | .py | 9f48c7cff6e908d3 | 7.5 | 9 |
"""
MIT License
Copyright (c) 2026-present ltzmax
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish... | ltzmax/maxcogs | afk/afk.py | .py | 6dbd360e17b33d73 | 7.64 | 18 |
"""
MIT License
Copyright (c) 2022-present ltzmax
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish... | ltzmax/maxcogs | autopublisher/autopublisher.py | .py | 180a73ae3948fe3b | 7.64 | 18 |
"""
MIT License
Copyright (c) 2022-present ltzmax
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish... | ltzmax/maxcogs | autopublisher/dashboard_integration.py | .py | 504ecd5301713840 | 7.64 | 18 |
"""
MIT License
Copyright (c) 2022-present ltzmax
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish... | ltzmax/maxcogs | autopublisher/utils.py | .py | 89fa2822a10f9672 | 7.64 | 18 |
"""
MIT License
Copyright (c) 2022-present ltzmax
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish... | ltzmax/maxcogs | counting/commands/user.py | .py | f5badcd3657d47f8 | 7.64 | 18 |
"""
MIT License
Copyright (c) 2022-present ltzmax
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish... | ltzmax/maxcogs | counting/settings.py | .py | b05579292d9de0a9 | 7.64 | 18 |
"""
MIT License
Copyright (c) 2022-present ltzmax
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish... | ltzmax/maxcogs | currency/currency.py | .py | 1cb3f869f56ff97a | 7.64 | 18 |
"""
MIT License
Copyright (c) 2022-present ltzmax
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish... | ltzmax/maxcogs | easterhunt/commands/owner.py | .py | 89ed97a91c36db93 | 7.64 | 18 |
"""
MIT License
Copyright (c) 2022-present ltzmax
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish... | ltzmax/maxcogs | enforce/enforce.py | .py | a4435f00db7c663f | 7.64 | 18 |
"""
MIT License
Copyright (c) 2022-present ltzmax
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish... | ltzmax/maxcogs | heist/commands/owner_commands.py | .py | b70838f06ffb68b5 | 7.64 | 18 |
"""
MIT License
Copyright (c) 2022-present ltzmax
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish... | ltzmax/maxcogs | heist/leveling.py | .py | f638a0dff71d269f | 7.64 | 18 |
"""
MIT License
Copyright (c) 2022-present ltzmax
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish... | ltzmax/maxcogs | history/history.py | .py | 4dc9fdc08128e6ec | 7.64 | 18 |
"""
MIT License
Copyright (c) 2022-present ltzmax
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish... | ltzmax/maxcogs | history/utils.py | .py | 75fbe1b3b59570c5 | 7.64 | 18 |
#!/usr/bin/env python3
"""Checks if a password has been leaked."""
from typing import Union
import getpass
import hashlib
import requests
def hash_password(pw_in) -> tuple:
"""Take password as input, hash it in SHA-1, and split it for use later on"""
pw_hash = hashlib.sha1()
pw_hash.update(str.encode(p... | luketainton/repos_PwnedPW | app/main.py | .py | b6e695b0f7131f01 | 7.42 | 6 |
#!/usr/bin/env python3
"""Test cases for pwned_pw.py."""
from app.main import hash_password, check
PASSWORD = "hello"
EXPECTED_HASH = "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
def test_hash_password():
"""Test case for hash_password()."""
result = hash_password(PASSWORD)
assert result == (EXPECTED_HA... | luketainton/repos_PwnedPW | tests/test_main.py | .py | ed04d968e6747c9d | 7.92 | 6 |
"""Base class to handle VASP files."""
import logging
import os
import sys
from abc import ABC, abstractmethod
class BaseParser(ABC):
"""Base class to handle VASP files."""
ERROR_USE_ONE_ARGUMENT = 10
ERROR_NO_ENTRIES = 11
ERROR_NO_KEY = 12
ERROR_KEY_INVALID_TYPE = 13
ERROR_FILE_NOT_FOUND = ... | aiida-vasp/parsevasp | parsevasp/base.py | .py | d42b7bee7341444a | 7.62 | 16 |
"""Handle CHGCAR."""
import sys
import numpy as np
from parsevasp import utils
from parsevasp.base import BaseParser
class Chgcar(BaseParser):
"""Class to handle CHGCAR."""
def __init__(self, file_path=None, file_handler=None, logger=None):
"""
Initialize an CHGCAR object and set content a... | aiida-vasp/parsevasp | parsevasp/chgcar.py | .py | 7c1711463c41f820 | 7.62 | 16 |
"""Handle DOSCAR."""
import sys
import numpy as np
from parsevasp import utils
from parsevasp.base import BaseParser
# Map from number of columns in DOSCAR to dtype for the total density of states.
DTYPES_DOS = {
3: np.dtype([('energy', float), ('total', float), ('integrated', float)]),
5: np.dtype([('energ... | aiida-vasp/parsevasp | parsevasp/doscar.py | .py | ff2c73bcd31739e0 | 7.62 | 16 |
"""Handle EIGENVAL."""
import re
import sys
import numpy as np
from parsevasp import utils
from parsevasp.base import BaseParser
class Eigenval(BaseParser):
"""Class to handle ENGENVAL."""
def __init__(self, file_path=None, file_handler=None, logger=None):
"""
Initialize an EIGENVAL object... | aiida-vasp/parsevasp | parsevasp/eigenval.py | .py | e26bc91923151164 | 7.62 | 16 |
"""Handle POTCAR
In order to not have pymatgen as a dependency, this parser takes parts of the
`pymatgen parser<https://github.com/materialsproject/pymatgen/blob/v2023.3.23/pymatgen/io/vasp/inputs.py#L1616-L2211>`_
for POTCAR here.
Copyright info from their MIT license:
Copyright (c) 2011-2012 MIT & The Regents of t... | aiida-vasp/parsevasp | parsevasp/potcar.py | .py | d424b0e7a65c4653 | 7.62 | 16 |
"""Test chgcar."""
import os
import numpy as np
import pytest
from parsevasp.chgcar import Chgcar
compare_charge_density = np.array(
[
[
[0.09329446, 0.18658892, 0.27988338],
[0.37317784, 0.4664723, 0.55976676],
[0.65306122, 0.74635569, 0.83965015],
[0.932... | aiida-vasp/parsevasp | tests/test_chgcar.py | .py | 4b2bbc9491ec381d | 8.12 | 16 |
"""Test doscar."""
import os
import numpy as np
import pytest
from parsevasp.doscar import DTYPES_PDOS_COLLINEAR, DTYPES_PDOS_NONCOLLINEAR, Doscar
compare_total_dos = np.array([(-3.44, -1.10400000e-43, -2.09900000e-43),
(-1.539, 1.40000000e-01, 2.66100000e-01),
(0.362, -3... | aiida-vasp/parsevasp | tests/test_doscar.py | .py | f89bcae925d0e074 | 7.12 | 16 |
"""Test eigenval."""
import os
import numpy as np
import pytest
from parsevasp.eigenval import Eigenval
compare_eigenvalues = np.array(
[[[-1.439825, 2.964373, 2.964373, 2.964373, 7.254542, 7.254542, 7.254542, 11.451811, 11.670398, 11.670398]]]
)
compare_kpoints = np.array([[0.25, 0.25, 0.25, 1.0]])
compare_met... | aiida-vasp/parsevasp | tests/test_eigenval.py | .py | 551cc837cc8ef948 | 8.12 | 16 |
"""Test incar."""
import os
import pytest
from parsevasp.incar import Incar, IncarItem
@pytest.fixture()
def incar_dict():
"""Create a dictionary of valid INCAR items."""
incar_dict = {'encut': 350, 'Sigma': '.5e-1 #comment', 'lreal': False, 'PREC': 'Accurate'}
return incar_dict
@pytest.fixture(scop... | aiida-vasp/parsevasp | tests/test_incar.py | .py | d8bc9882dcd32758 | 8.12 | 16 |
"""Test kpoints."""
import math
import os
import numpy as np
import pytest
from parsevasp.kpoints import Kpoint, Kpoints
@pytest.fixture(scope='module')
def kpoints_parser_auto():
"""Load KPOINTS file."""
testdir = os.path.dirname(__file__)
kpointsfile = testdir + '/KPOINTS'
kpoints = Kpoints(file... | aiida-vasp/parsevasp | tests/test_kpoints.py | .py | af2c94d3bc200021 | 7.12 | 16 |
"""Test poscar."""
import os
import numpy as np
import pytest
from parsevasp.poscar import Poscar, Site
@pytest.fixture(scope='module')
def poscar_parser(request):
"""Load POSCAR file."""
testdir = os.path.dirname(__file__)
poscarfile = testdir + '/POSCAR'
poscar = Poscar(file_path=poscarfile, wri... | aiida-vasp/parsevasp | tests/test_poscar.py | .py | 355f6fbf133973e6 | 7.12 | 16 |
"""Test potcar."""
import os
import pytest
from parsevasp.potcar import Potcar
@pytest.fixture(scope='module')
def potcar_reference_metadata():
"""Reference metadata for a dummy POTCAR"""
metadata = {
'VRHFIN': 'In: s1p1',
'LEXCH': 'CA',
'EATOM': 1111.1111,
'TITEL': 'PAW In_... | aiida-vasp/parsevasp | tests/test_potcar.py | .py | d14f651e379585a1 | 8.12 | 16 |
"""Test stream."""
import os
import pathlib
import re
import pytest
from parsevasp.stream import Stream
cwd = pathlib.Path(__file__).parent
@pytest.fixture()
def stream_parser(request, tmpdir_factory):
"""Load a stream."""
try:
name = request.param
except AttributeError:
# Test not par... | aiida-vasp/parsevasp | tests/test_stream.py | .py | 1ae14a93e4d52c77 | 8.12 | 16 |
#!/usr/bin/env python
"""
Post-process files in the AWS CLI v2 documentation in HTML-compiled form.
WARNING: All HTML sources will be overwritten.
"""
import itertools
from bs4 import BeautifulSoup, ResultSet
from glob2 import glob
from multiprocessing.pool import Pool
import re
import sys
from os import path
from u... | roberth-k/dash-docset-aws-cli | scripts/transform.py | .py | c959e93ce8b8c358 | 7.5 | 9 |
"""CommandCodes enum — the command catalogue.
Each entry carries ``(value, version, flags, sources)`` where *version*
gates model support, *flags* describe protocol behaviour (including update
loop participation), and *sources* gates both update polling and cached
accessors to a specific source set. Definitions are or... | elupus/arcam_fmj | src/arcam/fmj/commands.py | .py | 3a75aab3502884de | 7.56 | 12 |
"""Wire-protocol packet types and async serialization helpers.
The Arcam protocol frames every command and response with STR (0x21) and
ETR (0x0D) delimiters. AMX discovery uses a separate ``AMX\\r`` / ``AMXB``
framing that shares the same TCP connection.
"""
from __future__ import annotations
import asyncio
import l... | elupus/arcam_fmj | src/arcam/fmj/packets.py | .py | df66abb0b0e73c1e | 7.56 | 12 |
import asyncio
import aiohttp
from collections.abc import Coroutine
from copy import copy
import functools
import logging
import re
from defusedxml import ElementTree
from typing import Optional, Any
_LOGGER = logging.getLogger(__name__)
async def run_tasks(*tasks: Coroutine) -> None:
"""Run coroutines in a Task... | elupus/arcam_fmj | src/arcam/fmj/utils.py | .py | 5a96c9f9531374c3 | 7.56 | 12 |
import csv
import io
import zipfile
import fiona
import requests
from geojson import Feature, FeatureCollection, Point
def get_hms_fires():
"""
Get the latest fires from Hazard Mapping System satellites.
"""
# Read CSV
r = requests.get("https://satepsanone.nesdis.noaa.gov/pub/FIRE/HMS/latesthms.t... | datadesk/noaa-wildfires | noaa_wildfires/__init__.py | .py | fa525f919f391fb1 | 7.6 | 15 |
import click
from noaa_wildfires import get_hms_fires, get_hms_smoke
@click.group()
def cmd():
"""
A command-line interface for downloading wildfires data from NOAA.
Returns GeoJSON.
"""
pass
@cmd.command(help="The latest fires from Hazard Mapping System satellites")
def hms_fires():
click... | datadesk/noaa-wildfires | noaa_wildfires/cli.py | .py | 272f494444370c5c | 7.6 | 15 |
import os
from setuptools import setup
def read(fname):
with open(os.path.join(os.path.dirname(__file__), fname)) as f:
return f.read()
def version_scheme(version):
"""
Version scheme hack for setuptools_scm.
Appears to be necessary to due to the bug documented here: https://github.com/pyp... | datadesk/noaa-wildfires | setup.py | .py | 33491d4b17b61ee0 | 7.6 | 15 |
import click
from nifc_wildfires import get_active_perimeters, get_incidents
@click.group()
def cmd():
"""
A command-line interface for downloading wildfire perimeter and incident points data from NIFC.
Returns GeoJSON.
"""
pass
@cmd.command(help="Perimeters of active fires")
def active_perimet... | datadesk/nifc-wildfires | nifc_wildfires/cli.py | .py | 843133b8726002f8 | 7.62 | 16 |
"""Download wildfire incidents data from InciWeb."""
from __future__ import annotations
import requests
from geojson import Feature, FeatureCollection, Point
def get_data(t) -> FeatureCollection:
"""
Get all incidents data from InciWeb.
Passes in 't' parameter used to specify type of data (Wildfire, Pr... | datadesk/inciweb-wildfires | inciweb_wildfires/__init__.py | .py | ba903de01580dbf5 | 7.6 | 15 |
import click
from inciweb_wildfires import get_incidents, get_prescribed_fires
@click.group()
def cmd():
"""
A command-line interface for downloading wildfire incidents data from InciWeb.
Returns GeoJSON.
"""
pass
@cmd.command(help="Download active fire incidents from InciWeb")
def incidents()... | datadesk/inciweb-wildfires | inciweb_wildfires/cli.py | .py | e9650d2ca2ac2e18 | 7.6 | 15 |
import csv
import random
import sys
from collections import Counter
from collections.abc import Callable
from pathlib import Path
from typing import Any
import pytest
from tests.fixtures import ( # noqa: F401
example_large_game_result,
example_large_saved_game,
example_large_solverstate,
example_medi... | TylerYep/wolfbot | tests/conftest.py | .py | d48f6c2541bf725e | 8.02 | 10 |
import json
from wolfbot.encoder import ObjectInitializer, WolfBotDecoder, WolfBotEncoder
from wolfbot.enums import Role, SwitchPriority, Team
from wolfbot.roles import Player, Robber, Seer, Villager
from wolfbot.statements import Statement
from wolfbot.stats import GameResult, SavedGame
class TestWolfBotEncoderDeco... | TylerYep/wolfbot | tests/encoder_test.py | .py | 593fed61293ff79f | 7.02 | 10 |
from wolfbot import const
from wolfbot.enums import Role
from wolfbot.roles import Mason, Seer
class TestLRUCache:
"""Tests for the lru_cache function."""
@staticmethod
def test_lru_cache_hit() -> None:
"""Correctly cache a function call cache hit."""
result_1 = Seer.get_seer_statements(1... | TylerYep/wolfbot | tests/enums_test.py | .py | 3696a3529a8ac380 | 8.02 | 10 |
import pytest
from tests.conftest import override_input, verify_output_string
from wolfbot.enums import Role
from wolfbot.game_utils import (
find_all_player_indices,
get_center,
get_numeric_input,
get_player,
print_roles,
swap_characters,
)
class TestPrintRoles:
"""Tests for the print_ro... | TylerYep/wolfbot | tests/game_utils_test.py | .py | 807ea3a635501566 | 7.02 | 10 |
from tests.conftest import write_results
from wolfbot import const, one_night
from wolfbot.enums import Role
class TestMultistatement:
"""Tests for the play_one_night_werewolf function."""
@staticmethod
def test_random_wolf(standard_game_roles: tuple[Role, ...]) -> None:
"""Correctly play one rou... | TylerYep/wolfbot | tests/integration_test/multistatement_test.py | .py | 2881168753c125cb | 7.02 | 10 |
import logging
import random
from tests.conftest import set_roles, write_results
from wolfbot import const, one_night
from wolfbot.enums import Role, Solver, Team
from wolfbot.log import logger
from wolfbot.stats import Statistics
class TestStandard:
"""Tests for the play_one_night_werewolf function."""
@st... | TylerYep/wolfbot | tests/integration_test/standard_test.py | .py | 897e2dfae4403da5 | 7.02 | 10 |
import pytest
from tests.conftest import set_roles, verify_output, verify_output_string
from wolfbot import const, one_night
from wolfbot.enums import Role, Team
from wolfbot.roles import Drunk, Minion, Player, Robber, Seer, Wolf
from wolfbot.statements import Statement
class TestGetIndividualPreds:
"""Tests for... | TylerYep/wolfbot | tests/one_night_test.py | .py | 9bc0eb8516981fb9 | 7.02 | 10 |
import pytest
from tests.conftest import verify_output_file
from wolfbot import one_night
from wolfbot.stats import GameResult
class TestPlayOneNightWerewolf:
"""Tests for the play_one_night_werewolf function."""
@staticmethod
def test_one_night_small(
caplog: pytest.LogCaptureFixture,
e... | TylerYep/wolfbot | tests/output_test.py | .py | b182155199dbc75e | 7.02 | 10 |
from wolfbot import const, predictions
from wolfbot.enums import Role
from wolfbot.solvers import SolverState
class TestGetBasicGuesses:
"""Tests for the get_basic_guesses function."""
@staticmethod
def test_guesses_small(example_small_solverstate: SolverState) -> None:
"""
Should correct... | TylerYep/wolfbot | tests/predictions/engine_test.py | .py | d84a7cf4dc7916be | 7.02 | 10 |
from wolfbot import predictions
from wolfbot.enums import Role
from wolfbot.solvers import SolverState
class TestMakeRandomPrediction:
"""Tests for the random_prediction function."""
@staticmethod
def test_random_prediction(medium_game_roles: tuple[Role, ...]) -> None:
"""Should return a random s... | TylerYep/wolfbot | tests/predictions/evil_test.py | .py | 69ca493f484fdc58 | 7.02 | 10 |
from wolfbot import predictions
from wolfbot.enums import Role
from wolfbot.solvers import SolverState
class TestMakePrediction:
"""Tests for the make_prediction function."""
@staticmethod
def test_make_evil_prediction(
example_medium_solverstate_list: tuple[SolverState, ...],
) -> None:
... | TylerYep/wolfbot | tests/predictions/normal_test.py | .py | f7d9d911e18a23b6 | 7.02 | 10 |
from wolfbot import one_night, replay
from wolfbot.enums import Role
class TestReplay:
"""Tests for the replay_game function."""
@staticmethod
def test_replay_game_state_small(
small_game_roles: tuple[Role, ...], override_random: None
) -> None:
"""
Correctly replay last round... | TylerYep/wolfbot | tests/replay_test.py | .py | d6938356984992ad | 7.02 | 10 |
import pytest
from wolfbot import const
from wolfbot.enums import Role
from wolfbot.roles import Drunk, Hunter, Minion, Player, Robber, Seer, Villager, Wolf
from wolfbot.statements import KnowledgeBase, Statement
class TestPlayer:
"""Tests for the Player class."""
@staticmethod
def test_constructor() ->... | TylerYep/wolfbot | tests/roles/player_test.py | .py | f6836fdbbbdb8ec5 | 7.02 | 10 |
from tests.conftest import set_roles
from wolfbot import const
from wolfbot.enums import Role
from wolfbot.roles import Doppelganger
from wolfbot.statements import Statement
class TestDoppelganger:
"""Tests for the Doppelganger player class."""
@staticmethod
def test_awake_init(large_game_roles: tuple[Ro... | TylerYep/wolfbot | tests/roles/village/doppelganger_test.py | .py | 5529669fc2dec46a | 7.02 | 10 |
from tests.conftest import set_roles
from wolfbot import const
from wolfbot.enums import Role, SwitchPriority
from wolfbot.roles import Drunk
from wolfbot.statements import Statement
class TestDrunk:
"""Tests for the Drunk player class."""
@staticmethod
def test_awake_init(large_game_roles: tuple[Role, .... | TylerYep/wolfbot | tests/roles/village/drunk_test.py | .py | 59cd8f432945afc3 | 8.02 | 10 |
from wolfbot.enums import Role
from wolfbot.roles import Hunter
from wolfbot.statements import Statement
class TestHunter:
"""Tests for the Hunter player class."""
@staticmethod
def test_awake_init() -> None:
"""Should initialize a Hunter."""
player_index = 5
hunter = Hunter.awak... | TylerYep/wolfbot | tests/roles/village/hunter_test.py | .py | ceb4734487e2821a | 8.02 | 10 |
from tests.conftest import set_roles
from wolfbot.enums import Role
from wolfbot.roles import Insomniac
from wolfbot.statements import Statement
class TestInsomniac:
"""Tests for the Insomniac player class."""
@staticmethod
def test_awake_init() -> None:
"""Should initialize a Insomniac."""
... | TylerYep/wolfbot | tests/roles/village/insomniac_test.py | .py | 823a5e7b5076529a | 7.02 | 10 |
from tests.conftest import set_roles
from wolfbot import const
from wolfbot.enums import Role
from wolfbot.roles import Mason
from wolfbot.statements import Statement
class TestMason:
"""Tests for the Mason player class."""
@staticmethod
def test_awake_init(large_game_roles: tuple[Role, ...]) -> None:
... | TylerYep/wolfbot | tests/roles/village/mason_test.py | .py | fbb18b74f02d2067 | 7.02 | 10 |
from tests.conftest import set_roles
from wolfbot import const
from wolfbot.enums import Role, SwitchPriority
from wolfbot.roles import Robber
from wolfbot.statements import Statement
class TestRobber:
"""Tests for the Robber player class."""
@staticmethod
def test_awake_init(large_game_roles: tuple[Role... | TylerYep/wolfbot | tests/roles/village/robber_test.py | .py | f033cf636dfe6fa1 | 8.02 | 10 |
from tests.conftest import set_roles
from wolfbot import const
from wolfbot.enums import Role, SwitchPriority
from wolfbot.roles import Troublemaker
from wolfbot.statements import Statement
class TestTroublemaker:
"""Tests for the Troublemaker player class."""
@staticmethod
def test_awake_init(large_game... | TylerYep/wolfbot | tests/roles/village/troublemaker_test.py | .py | fc0563dec4c119e9 | 8.02 | 10 |
from wolfbot.enums import Role
from wolfbot.roles import Villager
from wolfbot.statements import Statement
class TestVillager:
"""Tests for the Villager player class."""
@staticmethod
def test_awake_init() -> None:
"""Should initialize a Villager."""
player_index = 5
villager = V... | TylerYep/wolfbot | tests/roles/village/villager_test.py | .py | 1f52e9e0b03d89ce | 8.02 | 10 |
from wolfbot import const
from wolfbot.enums import Role
from wolfbot.roles import Minion
from wolfbot.statements import KnowledgeBase
class TestMinion:
"""Tests for the Minion player class."""
@staticmethod
def test_awake_init(large_game_roles: tuple[Role, ...]) -> None:
"""Should initialize a M... | TylerYep/wolfbot | tests/roles/werewolf/minion_test.py | .py | 274e0b1763e80d4f | 7.02 | 10 |
from wolfbot.enums import Role
from wolfbot.roles import Tanner
from wolfbot.statements import KnowledgeBase
class TestTanner:
"""Tests for the Tanner player class."""
@staticmethod
def test_awake_init(large_game_roles: tuple[Role, ...]) -> None:
"""
Should initialize a Tanner. Note that ... | TylerYep/wolfbot | tests/roles/werewolf/tanner_test.py | .py | 0189526ca8d3f4d5 | 8.02 | 10 |
from tests.conftest import set_roles
from wolfbot import const
from wolfbot.enums import Role
from wolfbot.roles import Wolf
from wolfbot.statements import KnowledgeBase
class TestWolf:
"""Tests for the Wolf player class."""
@staticmethod
def test_awake_init_medium(medium_game_roles: tuple[Role, ...]) ->... | TylerYep/wolfbot | tests/roles/werewolf/wolf_test.py | .py | 17c59597bfecaa0d | 7.02 | 10 |
from wolfbot import solvers
from wolfbot.statements import Statement
class TestCachedSolver:
"""Tests for the cached_solver and count_roles function."""
@staticmethod
def test_solver_small(small_statement_list: tuple[Statement, ...]) -> None:
"""Should return a SolverState with the most likely so... | TylerYep/wolfbot | tests/solvers/cached_test.py | .py | 73a0e1cf41dce777 | 7.02 | 10 |
from wolfbot import const, solvers
from wolfbot.enums import Role, SwitchPriority
from wolfbot.solvers import SolverState
from wolfbot.statements import Statement
class TestRelaxedSolver:
"""Tests for the relaxed_solver."""
@staticmethod
def test_solver_small(
small_statement_list: tuple[Statemen... | TylerYep/wolfbot | tests/solvers/relaxed_test.py | .py | 74a2593f8c0bc444 | 8.02 | 10 |
from tests.conftest import set_roles
from wolfbot import const
from wolfbot.enums import Role, SwitchPriority
from wolfbot.solvers import SolverState
from wolfbot.statements import Statement
class TestSolverState:
"""Tests for the SolverState class."""
@staticmethod
def test_constructor() -> None:
... | TylerYep/wolfbot | tests/solvers/state_test.py | .py | a47f96634e0752ca | 8.02 | 10 |
from wolfbot import solvers
from wolfbot.enums import Role, SwitchPriority
from wolfbot.solvers import SolverState
from wolfbot.statements import Statement
class TestSwitchingSolver:
"""Tests for the switching_solver."""
@staticmethod
def test_solver_small(
small_statement_list: tuple[Statement],... | TylerYep/wolfbot | tests/solvers/switching_test.py | .py | b92a37cf95701666 | 8.02 | 10 |
from wolfbot import const, statements
from wolfbot.enums import Role, StatementLevel, SwitchPriority
from wolfbot.statements import KnowledgeBase, Statement
class TestKnowledgeBase:
"""Tests for the KnowledgeBase class."""
@staticmethod
def test_add_knowledge(example_statement: Statement) -> None:
... | TylerYep/wolfbot | tests/statements_test.py | .py | 602b1e0cb1fe4d3f | 8.02 | 10 |
"""Calls the tHMM functions and outputs the parameters needed to generate the Figures."""
import itertools
from typing import Any
import numpy as np
from scipy.optimize import linear_sum_assignment
from sklearn.metrics import rand_score
from .BaumWelch import (
calculate_log_likelihood,
do_E_step,
do_M_E... | meyer-lab/tHMM | lineage/Analyze.py | .py | 8a2721c9a38012a2 | 7.54 | 11 |
"""Re-calculates the tHMM parameters of pi, T, and emissions using Baum Welch."""
from typing import Any
import numpy as np
from .HMM.E_step import get_beta_and_NF, get_gamma, get_MSD
from .HMM.M_step import get_all_zetas, sum_nonleaf_gammas
from .LineageTree import get_Emission_Likelihoods
from .states.StateDistrib... | meyer-lab/tHMM | lineage/BaumWelch.py | .py | 45ade1a53fe17805 | 7.54 | 11 |
"""This file contains the class for CellVar which holds the state and observation information in the hidden and observed trees respectively."""
from __future__ import annotations
from dataclasses import dataclass
from typing import Any
import numpy as np
@dataclass(init=True, repr=True, eq=True, order=True)
class ... | meyer-lab/tHMM | lineage/CellVar.py | .py | 667836644cbfab08 | 7.54 | 11 |
import numpy as np
import numpy.typing as npt
from scipy.sparse import csr_array
def get_MSD(
tree: csr_array,
pi: npt.NDArray[np.float64],
T: npt.NDArray[np.float64],
) -> npt.NDArray[np.float64]:
r"""Marginal State Distribution (MSD) matrix by upward recursion.
This is the probability that a hid... | meyer-lab/tHMM | lineage/HMM/E_step.py | .py | 08314452ff735fe3 | 7.54 | 11 |
import numpy as np
import numpy.typing as npt
from scipy.sparse import csr_array
def sum_nonleaf_gammas(leaves_idx, gammas: npt.NDArray[np.float64]) -> npt.NDArray[np.float64]:
"""
Sum of the gammas of the cells that are able to divide, that is,
sum the of the gammas of all the nonleaf cells. It is used i... | meyer-lab/tHMM | lineage/HMM/M_step.py | .py | 835ead3a49763acb | 7.54 | 11 |
"""The file contains the methods used to input lineage data from the Heiser lab."""
import logging
import math
import numpy as np
import pandas as pd
from .CellVar import CellVar as c
def import_exp_data(path):
global_exp_time = [-1]
"""
Imports data from the Heiser lab
Outputs a list of lists cont... | meyer-lab/tHMM | lineage/LineageInputOutput.py | .py | f5e70dd29889ca25 | 7.54 | 11 |
"""This file contains the LineageTree class."""
import operator
from collections.abc import Sequence
import numpy as np
import numpy.typing as npt
from scipy.sparse import csr_array
from .CellVar import CellVar
from .states.stateCommon import censor_lineage_gamma
from .states.StateDistributionGamma import StateDistr... | meyer-lab/tHMM | lineage/LineageTree.py | .py | fbda89332b9ac0f7 | 7.54 | 11 |
"""This file contains the methods for the Viterbi algorithm implemented in an upward recursion."""
import numpy as np
from .LineageTree import get_Emission_Likelihoods
def get_deltas(X: list, E: list, T: np.ndarray) -> tuple[list[np.ndarray], list[np.ndarray]]:
"""
Delta matrix and base case at the leaves.
... | meyer-lab/tHMM | lineage/Viterbi.py | .py | 5b5599f953d8d32c | 7.54 | 11 |
"""Cross validation."""
from concurrent.futures import ProcessPoolExecutor
from copy import deepcopy
import numpy as np
from scipy.special import logsumexp
from scipy.stats import bernoulli
from .Analyze import Analyze_list
exe = ProcessPoolExecutor()
def hide_observation(lineages: list, percentage: float, rng=No... | meyer-lab/tHMM | lineage/crossval.py | .py | 475106d2d2526127 | 7.54 | 11 |
"""
File: figure1.py
Purpose: Generates figure 1.
Figure 1 is the tHMM model and its purpose.
"""
import random
from string import ascii_lowercase
from lineage.Lineage_collections import Gem10uM
from lineage.Lineage_collections import Gemcitabine_Control as control
from ..plotTree import plotLineage
fro... | meyer-lab/tHMM | lineage/figures/figure1.py | .py | 6a7f02410bba9309 | 7.54 | 11 |
"""Plotting the results for HGF. This file depicts the distribution of phase lengths versus the states for each concentration of lapatinib."""
from string import ascii_lowercase
import numpy as np
import pandas as pd
import seaborn as sns
from matplotlib import gridspec, rcParams
from matplotlib import pyplot as plt
... | meyer-lab/tHMM | lineage/figures/figure13.py | .py | 51d97c1a9e2d86d6 | 7.54 | 11 |
"""Figure 18 benchmark model with 5 states."""
import itertools as it
import numpy as np
import pandas as pd
import seaborn as sns
from ..BaumWelch import calculate_stationary
from ..LineageTree import LineageTree
from ..states.StateDistributionGaPhs import StateDistribution as phaseStateDist
from .common import com... | meyer-lab/tHMM | lineage/figures/figure18.py | .py | 3202c2e30dd4f42a | 7.54 | 11 |
"""Figure 20 for correlations between cell observations in the lineages."""
import numpy as np
import pandas as pd
from ..Lineage_collections import AllGemcitabine, AllLapatinib
from .common import getSetup
def makeFigure():
"""
Makes figure 9.
"""
ax, f = getSetup((9, 4), (1, 2))
labels = ["G1... | meyer-lab/tHMM | lineage/figures/figure20.py | .py | 7cda7b41e8a1472f | 7.54 | 11 |
"""This file contains functions for plotting the performance of the model for censored data."""
from copy import deepcopy
import numpy as np
import pandas as pd
import seaborn as sns
from ..LineageTree import LineageTree
from ..plotTree import plotLineage
from .common import (
E2,
T,
commonAnalyze,
g... | meyer-lab/tHMM | lineage/figures/figure4.py | .py | d1bc089da5b801be | 7.54 | 11 |
"""This file contains figures related to how far the states need to be,
which is shown by Wasserestein distance."""
import numpy as np
import pandas as pd
import seaborn as sns
from sklearn.metrics import rand_score
from ..LineageTree import LineageTree
from ..states.StateDistributionGaPhs import StateDistribution
fr... | meyer-lab/tHMM | lineage/figures/figure6.py | .py | d1c11bd297396660 | 7.54 | 11 |
"""
File: figure8.py
Purpose: Generates figure 8.
BIC for synthetic data.
"""
from concurrent.futures import ProcessPoolExecutor
import numpy as np
from matplotlib.ticker import MaxNLocator
from ..Analyze import run_Analyze_over
from ..BaumWelch import calculate_stationary
from ..LineageTree import LineageTree
from ... | meyer-lab/tHMM | lineage/figures/figure8.py | .py | df05294b02c705b8 | 7.54 | 11 |
"""This file plots the BIC for the experimental data."""
import numpy as np
from matplotlib.ticker import MaxNLocator
from ..Analyze import run_Analyze_over
from ..Lineage_collections import AllGemcitabine, AllLapatinib, GFs
from .common import getSetup
desired_num_states = np.arange(1, 8)
def find_BIC(data, desir... | meyer-lab/tHMM | lineage/figures/figure9.py | .py | 999bd698a74a4eb0 | 7.54 | 11 |
"""
File: figureS03.py
Purpose: Generates figure S03.
Figure S03 analyzes heterogeneous (2 state), censored (by both time and fate),
populations of lineages (more than one lineage per populations).
"""
import numpy as np
from ..LineageTree import LineageTree
from .common import (
E,
T,
commonAnalyze,
... | meyer-lab/tHMM | lineage/figures/figureS03.py | .py | 6754d92e4803530d | 7.54 | 11 |
"""
File: figureS04.py
Purpose: Generates figure S04.
Figure S04 analyzes heterogeneous (2 state), NOT censored,
single lineages (more than one lineage per population)
with different proportions of cells in states by
changing the values in the transition matrices.
"""
from ..BaumWelch import calculate_stationary
from ... | meyer-lab/tHMM | lineage/figures/figureS04.py | .py | cf479751d0684026 | 7.54 | 11 |
"""
File: figureS05.py
Purpose: Generates figure S05.
Figure 05 analyzes heterogeneous (2 state), censored (by both time and fate),
single lineages (more than one lineage per population)
with different proportions of cells in states by
changing the values in the transition matrices.
"""
from ..BaumWelch import calcula... | meyer-lab/tHMM | lineage/figures/figureS05.py | .py | 6643dd7c507d2f1c | 7.54 | 11 |
"""
File: figureS06.py
Purpose: Generates figure S06.
Figure S06 analyzes heterogeneous (2 state), NOT censored,
single lineages (more than one lineage per population)
with similar proportions of cells in states but
of varying distributions.
"""
import numpy as np
from ..LineageTree import LineageTree
from ..states.S... | meyer-lab/tHMM | lineage/figures/figureS06.py | .py | d1255054841e5006 | 7.54 | 11 |
"""
File: figureS07.py
Purpose: Generates figure S07.
Figure S07 analyzes heterogeneous (2 state), censored (by both time and fate),
single lineages (more than one lineage per population)
with similar proportions of cells in states but
of varying distributions.
"""
import numpy as np
from ..LineageTree import Lineage... | meyer-lab/tHMM | lineage/figures/figureS07.py | .py | 4d5b25ae36c31e28 | 7.54 | 11 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.